2016-06-16 23:09:34 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
feature 'Prioritize labels', feature: true do
|
2017-08-17 22:00:37 +05:30
|
|
|
include DragTo
|
2016-06-16 23:09:34 +05:30
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:project) { create(:empty_project, :public, namespace: group) }
|
|
|
|
let!(:bug) { create(:label, project: project, title: 'bug') }
|
|
|
|
let!(:wontfix) { create(:label, project: project, title: 'wontfix') }
|
|
|
|
let!(:feature) { create(:group_label, group: group, title: 'feature') }
|
2016-06-16 23:09:34 +05:30
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
context 'when user belongs to project team' do
|
|
|
|
before do
|
|
|
|
project.team << [user, :developer]
|
2016-06-16 23:09:34 +05:30
|
|
|
|
|
|
|
login_as user
|
2016-11-03 12:29:30 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'user can prioritize a group label', js: true do
|
|
|
|
visit namespace_project_labels_path(project.namespace, project)
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).to have_content('Star labels to start sorting by priority')
|
2016-11-03 12:29:30 +05:30
|
|
|
|
|
|
|
page.within('.other-labels') do
|
|
|
|
all('.js-toggle-priority')[1].click
|
|
|
|
wait_for_ajax
|
|
|
|
expect(page).not_to have_content('feature')
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within('.prioritized-labels') do
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).not_to have_content('Star labels to start sorting by priority')
|
2016-11-03 12:29:30 +05:30
|
|
|
expect(page).to have_content('feature')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'user can unprioritize a group label', js: true do
|
|
|
|
create(:label_priority, project: project, label: feature, priority: 1)
|
|
|
|
|
|
|
|
visit namespace_project_labels_path(project.namespace, project)
|
|
|
|
|
|
|
|
page.within('.prioritized-labels') do
|
|
|
|
expect(page).to have_content('feature')
|
|
|
|
|
|
|
|
first('.js-toggle-priority').click
|
|
|
|
wait_for_ajax
|
|
|
|
expect(page).not_to have_content('bug')
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within('.other-labels') do
|
|
|
|
expect(page).to have_content('feature')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'user can prioritize a project label', js: true do
|
2016-06-16 23:09:34 +05:30
|
|
|
visit namespace_project_labels_path(project.namespace, project)
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).to have_content('Star labels to start sorting by priority')
|
2016-06-16 23:09:34 +05:30
|
|
|
|
|
|
|
page.within('.other-labels') do
|
|
|
|
first('.js-toggle-priority').click
|
|
|
|
wait_for_ajax
|
|
|
|
expect(page).not_to have_content('bug')
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within('.prioritized-labels') do
|
2017-08-17 22:00:37 +05:30
|
|
|
expect(page).not_to have_content('Star labels to start sorting by priority')
|
2016-06-16 23:09:34 +05:30
|
|
|
expect(page).to have_content('bug')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
scenario 'user can unprioritize a project label', js: true do
|
|
|
|
create(:label_priority, project: project, label: bug, priority: 1)
|
2016-06-16 23:09:34 +05:30
|
|
|
|
|
|
|
visit namespace_project_labels_path(project.namespace, project)
|
|
|
|
|
|
|
|
page.within('.prioritized-labels') do
|
2016-11-03 12:29:30 +05:30
|
|
|
expect(page).to have_content('bug')
|
|
|
|
|
2016-06-16 23:09:34 +05:30
|
|
|
first('.js-toggle-priority').click
|
|
|
|
wait_for_ajax
|
|
|
|
expect(page).not_to have_content('bug')
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within('.other-labels') do
|
|
|
|
expect(page).to have_content('bug')
|
|
|
|
expect(page).to have_content('wontfix')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'user can sort prioritized labels and persist across reloads', js: true do
|
2016-11-03 12:29:30 +05:30
|
|
|
create(:label_priority, project: project, label: bug, priority: 1)
|
|
|
|
create(:label_priority, project: project, label: feature, priority: 2)
|
2016-06-16 23:09:34 +05:30
|
|
|
|
|
|
|
visit namespace_project_labels_path(project.namespace, project)
|
|
|
|
|
|
|
|
expect(page).to have_content 'bug'
|
2016-11-03 12:29:30 +05:30
|
|
|
expect(page).to have_content 'feature'
|
2016-06-16 23:09:34 +05:30
|
|
|
expect(page).to have_content 'wontfix'
|
|
|
|
|
|
|
|
# Sort labels
|
2017-08-17 22:00:37 +05:30
|
|
|
drag_to(selector: '.js-prioritized-labels', from_index: 1, to_index: 2)
|
2016-06-16 23:09:34 +05:30
|
|
|
|
|
|
|
page.within('.prioritized-labels') do
|
2016-11-03 12:29:30 +05:30
|
|
|
expect(first('li')).to have_content('feature')
|
2016-06-16 23:09:34 +05:30
|
|
|
expect(page.all('li').last).to have_content('bug')
|
|
|
|
end
|
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
refresh
|
2016-06-22 15:30:34 +05:30
|
|
|
wait_for_ajax
|
2016-06-16 23:09:34 +05:30
|
|
|
|
|
|
|
page.within('.prioritized-labels') do
|
2016-11-03 12:29:30 +05:30
|
|
|
expect(first('li')).to have_content('feature')
|
2016-06-16 23:09:34 +05:30
|
|
|
expect(page.all('li').last).to have_content('bug')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'as a guest' do
|
2016-09-13 17:45:13 +05:30
|
|
|
it 'does not prioritize labels' do
|
2016-06-16 23:09:34 +05:30
|
|
|
guest = create(:user)
|
|
|
|
|
|
|
|
login_as guest
|
2016-11-03 12:29:30 +05:30
|
|
|
|
2016-06-16 23:09:34 +05:30
|
|
|
visit namespace_project_labels_path(project.namespace, project)
|
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
expect(page).to have_content 'bug'
|
|
|
|
expect(page).to have_content 'wontfix'
|
|
|
|
expect(page).to have_content 'feature'
|
2016-06-16 23:09:34 +05:30
|
|
|
expect(page).not_to have_css('.prioritized-labels')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'as a non signed in user' do
|
2016-09-13 17:45:13 +05:30
|
|
|
it 'does not prioritize labels' do
|
2016-06-16 23:09:34 +05:30
|
|
|
visit namespace_project_labels_path(project.namespace, project)
|
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
expect(page).to have_content 'bug'
|
|
|
|
expect(page).to have_content 'wontfix'
|
|
|
|
expect(page).to have_content 'feature'
|
2016-06-16 23:09:34 +05:30
|
|
|
expect(page).not_to have_css('.prioritized-labels')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|