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