summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandru Croitor <acroitor@gitlab.com>2019-04-03 13:49:43 +0300
committerAlexandru Croitor <acroitor@gitlab.com>2019-04-08 11:30:54 +0300
commit6cb58cdb0aed3c9825d4a9a9f50daa9a305f4e11 (patch)
treea8e26eb12329ac9ffa8152e477def2df6b088ac8
parent435c492bac54f588b92e733b632edd4149a6db37 (diff)
downloadgitlab-ce-59570-create-merge-request-quick-action.tar.gz
Extract create merge request quick action spec59570-create-merge-request-quick-action
-rw-r--r--spec/features/issues/user_uses_quick_actions_spec.rb61
-rw-r--r--spec/support/shared_examples/quick_actions/issue/create_merge_request_quick_action_shared_examples.rb54
2 files changed, 56 insertions, 59 deletions
diff --git a/spec/features/issues/user_uses_quick_actions_spec.rb b/spec/features/issues/user_uses_quick_actions_spec.rb
index 9938a4e781c..ea474759547 100644
--- a/spec/features/issues/user_uses_quick_actions_spec.rb
+++ b/spec/features/issues/user_uses_quick_actions_spec.rb
@@ -42,7 +42,7 @@ describe 'Issues > User uses quick actions', :js do
describe 'issue-only commands' do
let(:user) { create(:user) }
- let(:project) { create(:project, :public) }
+ let(:project) { create(:project, :public, :repository) }
let(:issue) { create(:issue, project: project, due_date: Date.new(2016, 8, 28)) }
before do
@@ -59,6 +59,7 @@ describe 'Issues > User uses quick actions', :js do
it_behaves_like 'confidential quick action'
it_behaves_like 'remove_due_date quick action'
it_behaves_like 'duplicate quick action'
+ it_behaves_like 'create_merge_request quick action'
describe 'adding a due date from note' do
let(:issue) { create(:issue, project: project) }
@@ -207,63 +208,5 @@ describe 'Issues > User uses quick actions', :js do
end
end
end
-
- describe 'create a merge request starting from an issue' do
- let(:project) { create(:project, :public, :repository) }
- let(:issue) { create(:issue, project: project) }
-
- def expect_mr_quickaction(success)
- expect(page).to have_content 'Commands applied'
-
- if success
- expect(page).to have_content 'created merge request'
- else
- expect(page).not_to have_content 'created merge request'
- end
- end
-
- it "doesn't create a merge request when the branch name is invalid" do
- add_note("/create_merge_request invalid branch name")
-
- wait_for_requests
-
- expect_mr_quickaction(false)
- end
-
- it "doesn't create a merge request when a branch with that name already exists" do
- add_note("/create_merge_request feature")
-
- wait_for_requests
-
- expect_mr_quickaction(false)
- end
-
- it 'creates a new merge request using issue iid and title as branch name when the branch name is empty' do
- add_note("/create_merge_request")
-
- wait_for_requests
-
- expect_mr_quickaction(true)
-
- created_mr = project.merge_requests.last
- expect(created_mr.source_branch).to eq(issue.to_branch_name)
-
- visit project_merge_request_path(project, created_mr)
- expect(page).to have_content %{WIP: Resolve "#{issue.title}"}
- end
-
- it 'creates a merge request using the given branch name' do
- branch_name = '1-feature'
- add_note("/create_merge_request #{branch_name}")
-
- expect_mr_quickaction(true)
-
- created_mr = project.merge_requests.last
- expect(created_mr.source_branch).to eq(branch_name)
-
- visit project_merge_request_path(project, created_mr)
- expect(page).to have_content %{WIP: Resolve "#{issue.title}"}
- end
- end
end
end
diff --git a/spec/support/shared_examples/quick_actions/issue/create_merge_request_quick_action_shared_examples.rb b/spec/support/shared_examples/quick_actions/issue/create_merge_request_quick_action_shared_examples.rb
index 5bfc3bb222f..34dba5dbc31 100644
--- a/spec/support/shared_examples/quick_actions/issue/create_merge_request_quick_action_shared_examples.rb
+++ b/spec/support/shared_examples/quick_actions/issue/create_merge_request_quick_action_shared_examples.rb
@@ -1,4 +1,58 @@
# frozen_string_literal: true
shared_examples 'create_merge_request quick action' do
+ context 'create a merge request starting from an issue' do
+ def expect_mr_quickaction(success)
+ expect(page).to have_content 'Commands applied'
+
+ if success
+ expect(page).to have_content 'created merge request'
+ else
+ expect(page).not_to have_content 'created merge request'
+ end
+ end
+
+ it "doesn't create a merge request when the branch name is invalid" do
+ add_note("/create_merge_request invalid branch name")
+
+ wait_for_requests
+
+ expect_mr_quickaction(false)
+ end
+
+ it "doesn't create a merge request when a branch with that name already exists" do
+ add_note("/create_merge_request feature")
+
+ wait_for_requests
+
+ expect_mr_quickaction(false)
+ end
+
+ it 'creates a new merge request using issue iid and title as branch name when the branch name is empty' do
+ add_note("/create_merge_request")
+
+ wait_for_requests
+
+ expect_mr_quickaction(true)
+
+ created_mr = project.merge_requests.last
+ expect(created_mr.source_branch).to eq(issue.to_branch_name)
+
+ visit project_merge_request_path(project, created_mr)
+ expect(page).to have_content %{WIP: Resolve "#{issue.title}"}
+ end
+
+ it 'creates a merge request using the given branch name' do
+ branch_name = '1-feature'
+ add_note("/create_merge_request #{branch_name}")
+
+ expect_mr_quickaction(true)
+
+ created_mr = project.merge_requests.last
+ expect(created_mr.source_branch).to eq(branch_name)
+
+ visit project_merge_request_path(project, created_mr)
+ expect(page).to have_content %{WIP: Resolve "#{issue.title}"}
+ end
+ end
end