blob: 159660e7d1d32bbbcfe7ce507479a50fd5a2437f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# frozen_string_literal: true
RSpec.shared_examples 'create_merge_request quick action' do
context 'create a merge request starting from an issue' do
def expect_mr_quickaction(success, branch_name = nil)
command_message = if branch_name
"Created branch '#{branch_name}' and a merge request to resolve this issue"
else
"Created a branch and a merge request to resolve this issue"
end
expect(page).to have_content command_message
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
branch_name = 'invalid branch name'
add_note("/create_merge_request #{branch_name}")
wait_for_requests
expect_mr_quickaction(false, branch_name)
end
it "doesn't create a merge request when a branch with that name already exists" do
branch_name = 'feature'
add_note("/create_merge_request #{branch_name}")
wait_for_requests
expect_mr_quickaction(false, branch_name)
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, branch_name)
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
|