2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'rails_helper'
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
describe 'Merge request > User cherry-picks', :js do
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:group) { create(:group) }
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:project) { create(:project, :repository, namespace: group) }
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:user) { project.creator }
|
2016-06-02 11:05:42 +05:30
|
|
|
let(:merge_request) { create(:merge_request_with_diffs, source_project: project, author: user) }
|
|
|
|
|
|
|
|
before do
|
2018-11-18 11:00:15 +05:30
|
|
|
project.add_maintainer(user)
|
2018-03-17 18:26:18 +05:30
|
|
|
sign_in(user)
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
context 'Viewing a merged merge request' do
|
2016-06-02 11:05:42 +05:30
|
|
|
before do
|
|
|
|
service = MergeRequests::MergeService.new(project, user)
|
|
|
|
|
|
|
|
perform_enqueued_jobs do
|
|
|
|
service.execute(merge_request)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# Fast-forward merge, or merged before GitLab 8.5.
|
2018-11-18 11:00:15 +05:30
|
|
|
context 'without a merge commit' do
|
2016-06-02 11:05:42 +05:30
|
|
|
before do
|
|
|
|
merge_request.merge_commit_sha = nil
|
|
|
|
merge_request.save
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
it 'does not show a Cherry-pick button' do
|
2017-09-10 17:25:29 +05:30
|
|
|
visit project_merge_request_path(project, merge_request)
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(page).not_to have_link 'Cherry-pick'
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
context 'with a merge commit' do
|
2018-03-17 18:26:18 +05:30
|
|
|
it 'shows a Cherry-pick button' do
|
2017-09-10 17:25:29 +05:30
|
|
|
visit project_merge_request_path(project, merge_request)
|
2016-06-02 11:05:42 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
expect(page).to have_link 'Cherry-pick'
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
it 'hides the cherry pick button for an archived project' do
|
|
|
|
project.update!(archived: true)
|
|
|
|
|
|
|
|
visit project_merge_request_path(project, merge_request)
|
|
|
|
|
|
|
|
expect(page).not_to have_link 'Cherry-pick'
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
2018-11-18 11:00:15 +05:30
|
|
|
|
|
|
|
context 'and seeing the cherry-pick modal' do
|
|
|
|
before do
|
|
|
|
visit project_merge_request_path(project, merge_request)
|
|
|
|
|
|
|
|
click_link('Cherry-pick')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows the cherry-pick modal' do
|
|
|
|
expect(page).to have_content('Cherry-pick this merge request')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'closes the cherry-pick modal with escape keypress' do
|
|
|
|
find('#modal-cherry-pick-commit').send_keys(:escape)
|
|
|
|
|
|
|
|
expect(page).not_to have_content('Start a new merge request with these changes')
|
|
|
|
end
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
end
|