diff options
author | Alfredo Sumaran <alfredo@gitlab.com> | 2016-06-03 02:14:39 -0500 |
---|---|---|
committer | Alfredo Sumaran <alfredo@gitlab.com> | 2016-06-06 11:59:49 -0500 |
commit | 2ca32a09b68b1b74e8142d6211ffc8f70acf472e (patch) | |
tree | 4817bdc36ebbff2d3cecef91ea57870a720c900d /spec/features | |
parent | a966e6e4512e8073d7193c540fafba3fe86ea228 (diff) | |
download | gitlab-ce-2ca32a09b68b1b74e8142d6211ffc8f70acf472e.tar.gz |
Add test for the case when user can't prioritize labels
Diffstat (limited to 'spec/features')
-rw-r--r-- | spec/features/projects/labels/update_prioritization_spec.rb | 124 |
1 files changed, 77 insertions, 47 deletions
diff --git a/spec/features/projects/labels/update_prioritization_spec.rb b/spec/features/projects/labels/update_prioritization_spec.rb index 2fcaed84169..2a0bf6548db 100644 --- a/spec/features/projects/labels/update_prioritization_spec.rb +++ b/spec/features/projects/labels/update_prioritization_spec.rb @@ -3,76 +3,106 @@ require 'spec_helper' feature 'Prioritize labels', feature: true do include WaitForAjax - let(:user) { create(:user) } - let(:project) { create(:project, name: 'test', namespace: user.namespace) } + context 'when project belongs to user' do + let(:user) { create(:user) } + let(:project) { create(:project, name: 'test', namespace: user.namespace) } - scenario 'user can prioritize a label', js: true do - bug = create(:label, title: 'bug') - wontfix = create(:label, title: 'wontfix') + scenario 'user can prioritize a label', js: true do + bug = create(:label, title: 'bug') + wontfix = create(:label, title: 'wontfix') - project.labels << bug - project.labels << wontfix + project.labels << bug + project.labels << wontfix - login_as user - visit namespace_project_labels_path(project.namespace, project) + login_as user + visit namespace_project_labels_path(project.namespace, project) - expect(page).to have_content('No prioritized labels yet') + expect(page).to have_content('No prioritized labels yet') - page.within('.other-labels') do - first('.js-toggle-priority').click - wait_for_ajax - expect(page).not_to have_content('bug') + 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 + expect(page).not_to have_content('No prioritized labels yet') + expect(page).to have_content('bug') + end end - page.within('.prioritized-labels') do - expect(page).not_to have_content('No prioritized labels yet') + scenario 'user can unprioritize a label', js: true do + bug = create(:label, title: 'bug', priority: 1) + wontfix = create(:label, title: 'wontfix') + + project.labels << bug + project.labels << wontfix + + login_as user + visit namespace_project_labels_path(project.namespace, project) + expect(page).to have_content('bug') + + page.within('.prioritized-labels') do + 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 - end - scenario 'user can unprioritize a label', js: true do - bug = create(:label, title: 'bug', priority: 1) - wontfix = create(:label, title: 'wontfix') + scenario 'user can sort prioritized labels', js: true do + bug = create(:label, title: 'bug', priority: 1) + wontfix = create(:label, title: 'wontfix', priority: 2) - project.labels << bug - project.labels << wontfix + project.labels << bug + project.labels << wontfix - login_as user - visit namespace_project_labels_path(project.namespace, project) + login_as user + visit namespace_project_labels_path(project.namespace, project) - expect(page).to have_content('bug') + expect(page).to have_content 'bug' + expect(page).to have_content 'wontfix' - page.within('.prioritized-labels') do - first('.js-toggle-priority').click - wait_for_ajax - expect(page).not_to have_content('bug') - end + # Sort labels + find("#label_#{bug.id}").drag_to find("#label_#{wontfix.id}") - page.within('.other-labels') do - expect(page).to have_content('bug') - expect(page).to have_content('wontfix') + page.within('.prioritized-labels') do + expect(first('li')).to have_content('wontfix') + expect(page.all('li').last).to have_content('bug') + end end end - scenario 'user can sort prioritized labels', js: true do - bug = create(:label, title: 'bug', priority: 1) - wontfix = create(:label, title: 'wontfix', priority: 2) + context 'as a guest' do + it 'can not prioritize labels' do + user = create(:user) + guest = create(:user) + project = create(:project, name: 'test', namespace: user.namespace) + + create(:label, title: 'bug') - project.labels << bug - project.labels << wontfix + login_as guest + visit namespace_project_labels_path(project.namespace, project) + + expect(page).not_to have_css('.prioritized-labels') + end + end - login_as user - visit namespace_project_labels_path(project.namespace, project) + context 'as a non signed in user' do + it 'can not prioritize labels' do + user = create(:user) + project = create(:project, name: 'test', namespace: user.namespace) - expect(page).to have_content 'bug' - expect(page).to have_content 'wontfix' + create(:label, title: 'bug') - # Sort labels - find("#label_#{bug.id}").drag_to find("#label_#{wontfix.id}") + visit namespace_project_labels_path(project.namespace, project) - page.within('.prioritized-labels') do - expect(first('li')).to have_content('wontfix') - expect(page.all('li').last).to have_content('bug') + expect(page).not_to have_css('.prioritized-labels') end end end |