2017-06-22 22:11:14 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
describe 'Labels subscription' do
|
2017-06-22 22:11:14 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:group) { create(:group) }
|
2018-09-27 10:19:28 -04:00
|
|
|
let!(:label1) { create(:group_label, group: group, title: 'foo') }
|
|
|
|
let!(:label2) { create(:group_label, group: group, title: 'bar') }
|
2017-06-22 22:11:14 -04:00
|
|
|
|
|
|
|
context 'when signed in' do
|
|
|
|
before do
|
|
|
|
group.add_developer(user)
|
|
|
|
gitlab_sign_in user
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'users can subscribe/unsubscribe to group labels', :js do
|
2017-06-22 22:11:14 -04:00
|
|
|
visit group_labels_path(group)
|
|
|
|
|
2018-09-27 10:19:28 -04:00
|
|
|
expect(page).to have_content(label1.title)
|
2017-06-22 22:11:14 -04:00
|
|
|
|
2018-09-27 10:19:28 -04:00
|
|
|
within "#group_label_#{label1.id}" do
|
2017-06-22 22:11:14 -04:00
|
|
|
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-09-27 10:19:28 -04:00
|
|
|
|
|
|
|
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-06-22 22:11:14 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when not signed in' do
|
2018-09-27 10:19:28 -04:00
|
|
|
before do
|
2017-06-22 22:11:14 -04:00
|
|
|
visit group_labels_path(group)
|
2018-09-27 10:19:28 -04:00
|
|
|
end
|
2017-06-22 22:11:14 -04:00
|
|
|
|
2018-09-27 10:19:28 -04:00
|
|
|
it 'users can not subscribe/unsubscribe to labels' do
|
|
|
|
expect(page).to have_content label1.title
|
2017-06-22 22:11:14 -04:00
|
|
|
expect(page).not_to have_button('Subscribe')
|
|
|
|
end
|
2018-09-27 10:19:28 -04:00
|
|
|
|
|
|
|
it 'does not show subscribed tab' do
|
|
|
|
page.within('.nav-tabs') do
|
|
|
|
expect(page).not_to have_link 'Subscribed'
|
|
|
|
end
|
|
|
|
end
|
2017-06-22 22:11:14 -04:00
|
|
|
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-09-27 10:19:28 -04:00
|
|
|
|
|
|
|
def click_subscribed_tab
|
|
|
|
page.within('.nav-tabs') do
|
|
|
|
click_link 'Subscribed'
|
|
|
|
end
|
|
|
|
end
|
2017-06-22 22:11:14 -04:00
|
|
|
end
|