summaryrefslogtreecommitdiff
path: root/spec/support/features/issuable_slash_commands_shared_examples.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/features/issuable_slash_commands_shared_examples.rb')
-rw-r--r--spec/support/features/issuable_slash_commands_shared_examples.rb91
1 files changed, 71 insertions, 20 deletions
diff --git a/spec/support/features/issuable_slash_commands_shared_examples.rb b/spec/support/features/issuable_slash_commands_shared_examples.rb
index 5bbe36d9b7f..68f0ce8afb3 100644
--- a/spec/support/features/issuable_slash_commands_shared_examples.rb
+++ b/spec/support/features/issuable_slash_commands_shared_examples.rb
@@ -1,13 +1,18 @@
# Specifications for behavior common to all objects with executable attributes.
# It takes a `issuable_type`, and expect an `issuable`.
-shared_examples 'issuable record that supports slash commands in its description and notes' do |issuable_type|
- include SlashCommandsHelpers
+shared_examples 'issuable record that supports quick actions in its description and notes' do |issuable_type|
+ include QuickActionsHelpers
let(:master) { create(:user) }
- let(:assignee) { create(:user, username: 'bob') }
- let(:guest) { create(:user) }
- let(:project) { create(:project, :public) }
+ let(:project) do
+ case issuable_type
+ when :merge_request
+ create(:project, :public, :repository)
+ when :issue
+ create(:project, :public)
+ end
+ end
let!(:milestone) { create(:milestone, project: project, title: 'ASAP') }
let!(:label_bug) { create(:label, project: project, title: 'bug') }
let!(:label_feature) { create(:label, project: project, title: 'feature') }
@@ -15,20 +20,24 @@ shared_examples 'issuable record that supports slash commands in its description
before do
project.team << [master, :master]
- project.team << [assignee, :developer]
- project.team << [guest, :guest]
- login_with(master)
+
+ sign_in(master)
end
after do
# Ensure all outstanding Ajax requests are complete to avoid database deadlocks
- wait_for_ajax
+ wait_for_requests
end
- describe "new #{issuable_type}" do
+ describe "new #{issuable_type}", js: true do
context 'with commands in the description' do
it "creates the #{issuable_type} and interpret commands accordingly" do
- visit public_send("new_namespace_project_#{issuable_type}_path", project.namespace, project, new_url_opts)
+ case issuable_type
+ when :merge_request
+ visit public_send("namespace_project_new_merge_request_path", project.namespace, project, new_url_opts)
+ when :issue
+ visit public_send("new_namespace_project_issue_path", project.namespace, project, new_url_opts)
+ end
fill_in "#{issuable_type}_title", with: 'bug 345'
fill_in "#{issuable_type}_description", with: "bug description\n/label ~bug\n/milestone %\"ASAP\""
click_button "Submit #{issuable_type}".humanize
@@ -44,13 +53,14 @@ shared_examples 'issuable record that supports slash commands in its description
end
end
- describe "note on #{issuable_type}" do
+ describe "note on #{issuable_type}", js: true do
before do
visit public_send("namespace_project_#{issuable_type}_path", project.namespace, project, issuable)
end
context 'with a note containing commands' do
it 'creates a note without the commands and interpret the commands accordingly' do
+ assignee = create(:user, username: 'bob')
write_note("Awesome!\n/assign @bob\n/label ~bug\n/milestone %\"ASAP\"")
expect(page).to have_content 'Awesome!'
@@ -58,11 +68,12 @@ shared_examples 'issuable record that supports slash commands in its description
expect(page).not_to have_content '/label ~bug'
expect(page).not_to have_content '/milestone %"ASAP"'
+ wait_for_requests
issuable.reload
note = issuable.notes.user.first
expect(note.note).to eq "Awesome!"
- expect(issuable.assignee).to eq assignee
+ expect(issuable.assignees).to eq [assignee]
expect(issuable.labels).to eq [label_bug]
expect(issuable.milestone).to eq milestone
end
@@ -70,6 +81,7 @@ shared_examples 'issuable record that supports slash commands in its description
context 'with a note containing only commands' do
it 'does not create a note but interpret the commands accordingly' do
+ assignee = create(:user, username: 'bob')
write_note("/assign @bob\n/label ~bug\n/milestone %\"ASAP\"")
expect(page).not_to have_content '/assign @bob'
@@ -80,7 +92,7 @@ shared_examples 'issuable record that supports slash commands in its description
issuable.reload
expect(issuable.notes.user).to be_empty
- expect(issuable.assignee).to eq assignee
+ expect(issuable.assignees).to eq [assignee]
expect(issuable.labels).to eq [label_bug]
expect(issuable.milestone).to eq milestone
end
@@ -104,8 +116,12 @@ shared_examples 'issuable record that supports slash commands in its description
context "when current user cannot close #{issuable_type}" do
before do
- logout
- login_with(guest)
+ guest = create(:user)
+ project.add_guest(guest)
+
+ sign_out(:user)
+ sign_in(guest)
+
visit public_send("namespace_project_#{issuable_type}_path", project.namespace, project, issuable)
end
@@ -139,8 +155,12 @@ shared_examples 'issuable record that supports slash commands in its description
context "when current user cannot reopen #{issuable_type}" do
before do
- logout
- login_with(guest)
+ guest = create(:user)
+ project.add_guest(guest)
+
+ sign_out(:user)
+ sign_in(guest)
+
visit public_send("namespace_project_#{issuable_type}_path", project.namespace, project, issuable)
end
@@ -169,8 +189,11 @@ shared_examples 'issuable record that supports slash commands in its description
context "when current user cannot change title of #{issuable_type}" do
before do
- logout
- login_with(guest)
+ guest = create(:user)
+ project.add_guest(guest)
+
+ sign_out(:user)
+ sign_in(guest)
visit public_send("namespace_project_#{issuable_type}_path", project.namespace, project, issuable)
end
@@ -256,5 +279,33 @@ shared_examples 'issuable record that supports slash commands in its description
expect(issuable.subscribed?(master, project)).to be_falsy
end
end
+
+ context "with a note assigning the #{issuable_type} to the current user" do
+ it "assigns the #{issuable_type} to the current user" do
+ write_note("/assign me")
+
+ expect(page).not_to have_content '/assign me'
+ expect(page).to have_content 'Commands applied'
+
+ expect(issuable.reload.assignees).to eq [master]
+ end
+ end
+ end
+
+ describe "preview of note on #{issuable_type}" do
+ it 'removes quick actions from note and explains them' do
+ create(:user, username: 'bob')
+
+ visit public_send("namespace_project_#{issuable_type}_path", project.namespace, project, issuable)
+
+ page.within('.js-main-target-form') do
+ fill_in 'note[note]', with: "Awesome!\n/assign @bob "
+ click_on 'Preview'
+
+ expect(page).to have_content 'Awesome!'
+ expect(page).not_to have_content '/assign @bob'
+ expect(page).to have_content 'Assigns @bob.'
+ end
+ end
end
end