2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-04 22:31:34 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 18:09:01 +00:00
|
|
|
RSpec.describe 'User edits a merge request', :js do
|
2017-10-04 22:31:34 +00:00
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2017-10-04 22:31:34 +00:00
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
visit(edit_project_merge_request_path(project, merge_request))
|
|
|
|
end
|
|
|
|
|
2020-07-08 00:09:06 +00:00
|
|
|
describe 'Squash commits' do
|
2020-07-09 12:08:56 +00:00
|
|
|
it 'override MR setting if "Required" is saved' do
|
|
|
|
merge_request.update!(squash: false)
|
|
|
|
|
|
|
|
project.project_setting.update!(squash_option: 'always')
|
|
|
|
visit(edit_project_merge_request_path(project, merge_request))
|
|
|
|
click_button('Save changes')
|
|
|
|
|
|
|
|
project.project_setting.update!(squash_option: 'default_off')
|
|
|
|
visit(edit_project_merge_request_path(project, merge_request))
|
|
|
|
|
|
|
|
expect(find("#merge_request_squash").selected?).to be(true)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'recovers MR squash setting if "Required" is not saved' do
|
|
|
|
merge_request.update!(squash: false)
|
|
|
|
|
|
|
|
project.project_setting.update!(squash_option: 'always')
|
|
|
|
visit(edit_project_merge_request_path(project, merge_request))
|
|
|
|
|
|
|
|
project.project_setting.update!(squash_option: 'default_on')
|
|
|
|
visit(edit_project_merge_request_path(project, merge_request))
|
|
|
|
|
|
|
|
expect(find("#merge_request_squash").selected?).to be(false)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not override MR squash setting if "Do not allow" is saved' do
|
|
|
|
merge_request.update!(squash: true)
|
|
|
|
|
|
|
|
project.project_setting.update!(squash_option: 'never')
|
|
|
|
visit(edit_project_merge_request_path(project, merge_request))
|
|
|
|
click_button('Save changes')
|
|
|
|
|
|
|
|
expect(merge_request.squash).to be true
|
|
|
|
end
|
|
|
|
|
2020-07-08 00:09:06 +00:00
|
|
|
it 'displays "Required in this project" for "Required" project setting squash option' do
|
|
|
|
project.project_setting.update!(squash_option: 'always')
|
|
|
|
visit(edit_project_merge_request_path(project, merge_request))
|
|
|
|
|
|
|
|
expect(page).to have_content('Squash commits when merge request is accepted.')
|
|
|
|
expect(page).to have_content("Required in this project")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not display message for "Allow" project setting squash option' do
|
|
|
|
project.project_setting.update!(squash_option: 'default_off')
|
|
|
|
visit(edit_project_merge_request_path(project, merge_request))
|
|
|
|
|
|
|
|
expect(page).to have_content('Squash commits when merge request is accepted.')
|
|
|
|
expect(page).not_to have_content("Required in this project")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'does not display message for "Encourage" project setting squash option' do
|
|
|
|
project.project_setting.update!(squash_option: 'default_on')
|
|
|
|
visit(edit_project_merge_request_path(project, merge_request))
|
|
|
|
|
|
|
|
expect(page).to have_content('Squash commits when merge request is accepted.')
|
|
|
|
expect(page).not_to have_content("Required in this project")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'is hidden for "Do not allow" project setting squash option' do
|
|
|
|
project.project_setting.update!(squash_option: 'never')
|
|
|
|
visit(edit_project_merge_request_path(project, merge_request))
|
|
|
|
|
|
|
|
expect(page).not_to have_content('Squash commits when merge request is accepted.')
|
|
|
|
expect(page).not_to have_css('#merge_request_squash')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-08-17 12:10:12 +00:00
|
|
|
describe 'changing target branch' do
|
|
|
|
it 'allows user to change target branch' do
|
|
|
|
expect(page).to have_content('From master into feature')
|
2017-10-04 22:31:34 +00:00
|
|
|
|
2022-09-08 21:13:09 +00:00
|
|
|
first('.js-target-branch').click
|
|
|
|
|
|
|
|
wait_for_requests
|
|
|
|
|
|
|
|
first('.js-target-branch-dropdown a', text: 'merge-test').click
|
|
|
|
|
2020-08-17 12:10:12 +00:00
|
|
|
click_button('Save changes')
|
|
|
|
|
2022-05-18 06:08:06 +00:00
|
|
|
expect(page).to have_content("requested to merge #{merge_request.source_branch} into merge-test")
|
2020-08-17 12:10:12 +00:00
|
|
|
expect(page).to have_content("changed target branch from #{merge_request.target_branch} to merge-test")
|
|
|
|
end
|
2017-10-04 22:31:34 +00:00
|
|
|
|
2020-08-17 12:10:12 +00:00
|
|
|
describe 'merged merge request' do
|
|
|
|
let(:merge_request) { create(:merge_request, source_project: project, target_project: project, state: :merged) }
|
|
|
|
|
|
|
|
it 'does not allow user to change target branch' do
|
|
|
|
expect(page).to have_content('From master into feature')
|
2022-09-08 21:13:09 +00:00
|
|
|
expect(page).not_to have_selector('.js-target-branch.js-compare-dropdown')
|
2020-08-17 12:10:12 +00:00
|
|
|
end
|
|
|
|
end
|
2017-10-04 22:31:34 +00:00
|
|
|
end
|
|
|
|
end
|