2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-16 15:23:15 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Labels subscription' do
|
2016-11-16 15:23:15 -05:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:group) { create(:group) }
|
2017-08-02 15:55:11 -04:00
|
|
|
let(:project) { create(:project, :public, namespace: group) }
|
2016-11-16 15:23:15 -05:00
|
|
|
let!(:bug) { create(:label, project: project, title: 'bug') }
|
|
|
|
let!(:feature) { create(:group_label, group: group, title: 'feature') }
|
|
|
|
|
|
|
|
context 'when signed in' do
|
|
|
|
before do
|
2017-12-22 03:18:28 -05:00
|
|
|
project.add_developer(user)
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in user
|
2016-11-16 15:23:15 -05:00
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'users can subscribe/unsubscribe to labels', :js do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_labels_path(project)
|
2016-11-16 15:23:15 -05:00
|
|
|
|
|
|
|
expect(page).to have_content('bug')
|
|
|
|
expect(page).to have_content('feature')
|
|
|
|
|
|
|
|
within "#project_label_#{bug.id}" do
|
|
|
|
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
|
|
|
|
|
|
|
|
within "#group_label_#{feature.id}" do
|
|
|
|
expect(page).not_to have_button 'Unsubscribe'
|
|
|
|
|
2018-05-29 05:25:21 -04:00
|
|
|
click_link_on_dropdown('Subscribe at group level')
|
2016-11-16 15:23:15 -05:00
|
|
|
|
|
|
|
expect(page).not_to have_selector('.dropdown-group-label')
|
|
|
|
expect(page).to have_button 'Unsubscribe'
|
|
|
|
|
|
|
|
click_button 'Unsubscribe'
|
|
|
|
|
|
|
|
expect(page).to have_selector('.dropdown-group-label')
|
|
|
|
|
2018-05-29 05:25:21 -04:00
|
|
|
click_link_on_dropdown('Subscribe at project level')
|
2016-11-16 15:23:15 -05:00
|
|
|
|
|
|
|
expect(page).not_to have_selector('.dropdown-group-label')
|
|
|
|
expect(page).to have_button 'Unsubscribe'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when not signed in' do
|
|
|
|
it 'users can not subscribe/unsubscribe to labels' do
|
2017-07-06 12:20:50 -04:00
|
|
|
visit project_labels_path(project)
|
2016-11-16 15:23:15 -05:00
|
|
|
|
|
|
|
expect(page).to have_content 'bug'
|
|
|
|
expect(page).to have_content 'feature'
|
|
|
|
expect(page).not_to have_button('Subscribe')
|
|
|
|
expect(page).not_to have_selector('.dropdown-group-label')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def click_link_on_dropdown(text)
|
|
|
|
find('.dropdown-group-label').click
|
|
|
|
|
|
|
|
page.within('.dropdown-group-label') do
|
2018-05-29 05:48:26 -04:00
|
|
|
find('.js-subscribe-button', text: text).click
|
2016-11-16 15:23:15 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|