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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# frozen_string_literal: true
RSpec.shared_examples 'rebase quick action' do
context 'when updating the description' do
before do
sign_in(user)
visit edit_project_merge_request_path(project, merge_request)
end
it 'rebases the MR', :sidekiq_inline do
fill_in('Description', with: '/rebase')
click_button('Save changes')
expect(page).not_to have_content('commit behind the target branch')
expect(merge_request.reload).not_to be_merged
end
it 'ignores /merge if /rebase is specified', :sidekiq_inline do
fill_in('Description', with: "/merge\n/rebase")
click_button('Save changes')
expect(page).not_to have_content('commit behind the target branch')
expect(merge_request.reload).not_to be_merged
end
end
context 'when creating a new note' do
context 'when the current user can rebase the MR' do
before do
sign_in(user)
visit project_merge_request_path(project, merge_request)
end
it 'rebase the MR', :sidekiq_inline do
add_note("/rebase")
expect(page).to have_content "Scheduled a rebase of branch #{merge_request.source_branch}."
end
context 'when the merge request is closed' do
before do
merge_request.close!
end
it 'does not rebase the MR', :sidekiq_inline do
add_note("/rebase")
expect(page).not_to have_content 'Scheduled a rebase'
end
end
context 'when a rebase is in progress', :sidekiq_inline, :clean_gitlab_redis_shared_state do
before do
jid = SecureRandom.hex
merge_request.update!(rebase_jid: jid)
Gitlab::SidekiqStatus.set(jid)
end
it 'tells the user a rebase is in progress' do
add_note('/rebase')
expect(page).to have_content 'A rebase is already in progress.'
expect(page).not_to have_content 'Scheduled a rebase'
end
end
context 'when there are conflicts in the merge request' do
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project, source_branch: 'conflict-missing-side', target_branch: 'conflict-start', merge_status: :cannot_be_merged) }
it 'does not rebase the MR' do
add_note("/rebase")
expect(page).to have_content 'This merge request cannot be rebased while there are conflicts.'
end
end
context 'when the merge request branch is protected from force push' do
let!(:protected_branch) { create(:protected_branch, project: project, name: merge_request.source_branch, allow_force_push: false) }
it 'does not rebase the MR' do
add_note("/rebase")
expect(page).to have_content 'This merge request branch is protected from force push.'
end
end
end
context 'when the current user cannot rebase the MR' do
before do
project.add_guest(guest)
sign_in(guest)
visit project_merge_request_path(project, merge_request)
end
it 'does not rebase the MR' do
add_note("/rebase")
expect(page).not_to have_content 'Scheduled a rebase'
end
end
end
end
|