debian-mirror-gitlab/spec/features/groups/labels/subscription_spec.rb

94 lines
2.2 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
require 'spec_helper'
2020-06-23 00:09:42 +05:30
RSpec.describe 'Labels subscription' do
2017-09-10 17:25:29 +05:30
let(:user) { create(:user) }
let(:group) { create(:group) }
2018-12-05 23:21:45 +05:30
let!(:label1) { create(:group_label, group: group, title: 'foo') }
let!(:label2) { create(:group_label, group: group, title: 'bar') }
2017-09-10 17:25:29 +05:30
context 'when signed in' do
before do
group.add_developer(user)
gitlab_sign_in user
end
2018-11-08 19:23:39 +05:30
it 'users can subscribe/unsubscribe to group labels', :js do
2017-09-10 17:25:29 +05:30
visit group_labels_path(group)
2018-12-05 23:21:45 +05:30
expect(page).to have_content(label1.title)
2017-09-10 17:25:29 +05:30
2018-12-05 23:21:45 +05:30
within "#group_label_#{label1.id}" do
2017-09-10 17:25:29 +05:30
expect(page).not_to have_button 'Unsubscribe'
click_button 'Subscribe'
expect(page).not_to have_button 'Subscribe'
expect(page).to have_button 'Unsubscribe'
click_button 'Unsubscribe'
expect(page).to have_button 'Subscribe'
expect(page).not_to have_button 'Unsubscribe'
end
end
2018-12-05 23:21:45 +05:30
context 'subscription filter' do
before do
visit group_labels_path(group)
end
it 'shows only subscribed labels' do
label1.subscribe(user)
click_subscribed_tab
page.within('.labels-container') do
expect(page).to have_content label1.title
end
end
it 'shows no subscribed labels message' do
click_subscribed_tab
page.within('.labels-container') do
expect(page).not_to have_content label1.title
expect(page).to have_content('You do not have any subscriptions yet')
end
end
end
2017-09-10 17:25:29 +05:30
end
context 'when not signed in' do
2018-12-05 23:21:45 +05:30
before do
2017-09-10 17:25:29 +05:30
visit group_labels_path(group)
2018-12-05 23:21:45 +05:30
end
2017-09-10 17:25:29 +05:30
2018-12-05 23:21:45 +05:30
it 'users can not subscribe/unsubscribe to labels' do
expect(page).to have_content label1.title
2017-09-10 17:25:29 +05:30
expect(page).not_to have_button('Subscribe')
end
2018-12-05 23:21:45 +05:30
it 'does not show subscribed tab' do
2021-12-11 22:18:48 +05:30
page.within('.gl-tabs-nav') do
2018-12-05 23:21:45 +05:30
expect(page).not_to have_link 'Subscribed'
end
end
2017-09-10 17:25:29 +05:30
end
def click_link_on_dropdown(text)
find('.dropdown-group-label').click
page.within('.dropdown-group-label') do
find('a.js-subscribe-button', text: text).click
end
end
2018-12-05 23:21:45 +05:30
def click_subscribed_tab
2021-12-11 22:18:48 +05:30
page.within('.gl-tabs-nav') do
2018-12-05 23:21:45 +05:30
click_link 'Subscribed'
end
end
2017-09-10 17:25:29 +05:30
end