diff options
Diffstat (limited to 'spec/features/issues/user_uses_slash_commands_spec.rb')
-rw-r--r-- | spec/features/issues/user_uses_slash_commands_spec.rb | 72 |
1 files changed, 57 insertions, 15 deletions
diff --git a/spec/features/issues/user_uses_slash_commands_spec.rb b/spec/features/issues/user_uses_slash_commands_spec.rb index ea7a97d02a0..17818beb947 100644 --- a/spec/features/issues/user_uses_slash_commands_spec.rb +++ b/spec/features/issues/user_uses_slash_commands_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' feature 'Issues > User uses quick actions', :js do - include QuickActionsHelpers + include Spec::Support::Helpers::Features::NotesHelpers it_behaves_like 'issuable record that supports quick actions in its description and notes', :issue do let(:issuable) { create(:issue, project: project) } @@ -36,7 +36,7 @@ feature 'Issues > User uses quick actions', :js do context 'when the current user can update the due date' do it 'does not create a note, and sets the due date accordingly' do - write_note("/due 2016-08-28") + add_note("/due 2016-08-28") expect(page).not_to have_content '/due 2016-08-28' expect(page).to have_content 'Commands applied' @@ -57,7 +57,7 @@ feature 'Issues > User uses quick actions', :js do end it 'does not create a note, and sets the due date accordingly' do - write_note("/due 2016-08-28") + add_note("/due 2016-08-28") expect(page).not_to have_content 'Commands applied' @@ -75,7 +75,7 @@ feature 'Issues > User uses quick actions', :js do it 'does not create a note, and removes the due date accordingly' do expect(issue.due_date).to eq Date.new(2016, 8, 28) - write_note("/remove_due_date") + add_note("/remove_due_date") expect(page).not_to have_content '/remove_due_date' expect(page).to have_content 'Commands applied' @@ -96,7 +96,7 @@ feature 'Issues > User uses quick actions', :js do end it 'does not create a note, and sets the due date accordingly' do - write_note("/remove_due_date") + add_note("/remove_due_date") expect(page).not_to have_content 'Commands applied' @@ -111,7 +111,7 @@ feature 'Issues > User uses quick actions', :js do let(:issue) { create(:issue, project: project) } it 'does not recognize the command nor create a note' do - write_note("/wip") + add_note("/wip") expect(page).not_to have_content '/wip' end @@ -123,7 +123,7 @@ feature 'Issues > User uses quick actions', :js do context 'when the current user can update issues' do it 'does not create a note, and marks the issue as a duplicate' do - write_note("/duplicate ##{original_issue.to_reference}") + add_note("/duplicate ##{original_issue.to_reference}") expect(page).not_to have_content "/duplicate #{original_issue.to_reference}" expect(page).to have_content 'Commands applied' @@ -143,7 +143,7 @@ feature 'Issues > User uses quick actions', :js do end it 'does not create a note, and does not mark the issue as a duplicate' do - write_note("/duplicate ##{original_issue.to_reference}") + add_note("/duplicate ##{original_issue.to_reference}") expect(page).not_to have_content 'Commands applied' expect(page).not_to have_content "marked this issue as a duplicate of #{original_issue.to_reference}" @@ -153,6 +153,42 @@ feature 'Issues > User uses quick actions', :js do end end + describe 'make issue confidential' do + let(:issue) { create(:issue, project: project) } + let(:original_issue) { create(:issue, project: project) } + + context 'when the current user can update issues' do + it 'does not create a note, and marks the issue as confidential' do + add_note("/confidential") + + expect(page).not_to have_content "/confidential" + expect(page).to have_content 'Commands applied' + expect(page).to have_content "made the issue confidential" + + expect(issue.reload).to be_confidential + end + end + + context 'when the current user cannot update the issue' do + let(:guest) { create(:user) } + before do + project.add_guest(guest) + gitlab_sign_out + sign_in(guest) + visit project_issue_path(project, issue) + end + + it 'does not create a note, and does not mark the issue as confidential' do + add_note("/confidential") + + expect(page).not_to have_content 'Commands applied' + expect(page).not_to have_content "made the issue confidential" + + expect(issue.reload).not_to be_confidential + end + end + end + describe 'move the issue to another project' do let(:issue) { create(:issue, project: project) } @@ -161,12 +197,13 @@ feature 'Issues > User uses quick actions', :js do before do target_project.add_master(user) + gitlab_sign_out sign_in(user) visit project_issue_path(project, issue) end it 'moves the issue' do - write_note("/move #{target_project.full_path}") + add_note("/move #{target_project.full_path}") expect(page).to have_content 'Commands applied' expect(issue.reload).to be_closed @@ -178,29 +215,33 @@ feature 'Issues > User uses quick actions', :js do end context 'when the project is valid but the user not authorized' do - let(:project_unauthorized) {create(:project, :public)} + let(:project_unauthorized) { create(:project, :public) } before do + gitlab_sign_out sign_in(user) visit project_issue_path(project, issue) end it 'does not move the issue' do - write_note("/move #{project_unauthorized.full_path}") + add_note("/move #{project_unauthorized.full_path}") - expect(page).not_to have_content 'Commands applied' + wait_for_requests + + expect(page).to have_content 'Commands applied' expect(issue.reload).to be_open end end context 'when the project is invalid' do before do + gitlab_sign_out sign_in(user) visit project_issue_path(project, issue) end it 'does not move the issue' do - write_note("/move not/valid") + add_note("/move not/valid") expect(page).not_to have_content 'Commands applied' expect(issue.reload).to be_open @@ -218,12 +259,13 @@ feature 'Issues > User uses quick actions', :js do before do target_project.add_master(user) + gitlab_sign_out sign_in(user) visit project_issue_path(project, issue) end it 'applies the commands to both issues and moves the issue' do - write_note("/label ~#{bug.title} ~#{wontfix.title}\n\n/milestone %\"#{milestone.title}\"\n\n/move #{target_project.full_path}") + add_note("/label ~#{bug.title} ~#{wontfix.title}\n\n/milestone %\"#{milestone.title}\"\n\n/move #{target_project.full_path}") expect(page).to have_content 'Commands applied' expect(issue.reload).to be_closed @@ -242,7 +284,7 @@ feature 'Issues > User uses quick actions', :js do end it 'moves the issue and applies the commands to both issues' do - write_note("/move #{target_project.full_path}\n\n/label ~#{bug.title} ~#{wontfix.title}\n\n/milestone %\"#{milestone.title}\"") + add_note("/move #{target_project.full_path}\n\n/label ~#{bug.title} ~#{wontfix.title}\n\n/milestone %\"#{milestone.title}\"") expect(page).to have_content 'Commands applied' expect(issue.reload).to be_closed |