diff options
author | Jacopo <beschi.jacopo@gmail.com> | 2018-10-19 09:16:58 +0200 |
---|---|---|
committer | Jacopo <beschi.jacopo@gmail.com> | 2018-11-14 15:16:19 +0100 |
commit | 6b0ea951cac3905437abb2bbacaf422371f097e0 (patch) | |
tree | 55b61f7c3a5a4447fb70733780fca614ac1a73ef /spec/features | |
parent | f5e3ce5ed612c9b247e362ed7c667557331e5bfd (diff) | |
download | gitlab-ce-6b0ea951cac3905437abb2bbacaf422371f097e0.tar.gz |
Creates /create_merge_request quickaction40085-add-a-create_merge_request-quick-action
With this quick action the user can create a new MR starting from
the current issue using as `source_branch` the given `branch name` and
as `target_branch` the project default branch. If the `branch name` is
omitted a name is automatically created starting from the issue title.
Diffstat (limited to 'spec/features')
-rw-r--r-- | spec/features/issues/user_creates_branch_and_merge_request_spec.rb | 4 | ||||
-rw-r--r-- | spec/features/issues/user_uses_quick_actions_spec.rb | 58 |
2 files changed, 60 insertions, 2 deletions
diff --git a/spec/features/issues/user_creates_branch_and_merge_request_spec.rb b/spec/features/issues/user_creates_branch_and_merge_request_spec.rb index 3dfcbc2fcb8..a912c327728 100644 --- a/spec/features/issues/user_creates_branch_and_merge_request_spec.rb +++ b/spec/features/issues/user_creates_branch_and_merge_request_spec.rb @@ -76,7 +76,7 @@ describe 'User creates branch and merge request on issue page', :js do visit project_issue_path(project, issue) - expect(page).to have_content('created branch 1-cherry-coloured-funk') + expect(page).to have_content("created merge request !1 to address this issue") expect(page).to have_content('mentioned in merge request !1') end @@ -106,7 +106,7 @@ describe 'User creates branch and merge request on issue page', :js do visit project_issue_path(project, issue) - expect(page).to have_content('created branch custom-branch-name') + expect(page).to have_content("created merge request !1 to address this issue") expect(page).to have_content('mentioned in merge request !1') end diff --git a/spec/features/issues/user_uses_quick_actions_spec.rb b/spec/features/issues/user_uses_quick_actions_spec.rb index 5926e442f24..27cffdc5f8b 100644 --- a/spec/features/issues/user_uses_quick_actions_spec.rb +++ b/spec/features/issues/user_uses_quick_actions_spec.rb @@ -303,5 +303,63 @@ 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 |