2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-08-29 07:56:52 +00:00
|
|
|
require 'spec_helper'
|
2016-12-10 11:58:15 +00:00
|
|
|
|
2020-06-16 18:09:01 +00:00
|
|
|
RSpec.describe 'Merge request < User customizes merge commit message', :js do
|
2017-07-26 21:52:10 +00:00
|
|
|
let(:project) { create(:project, :public, :repository) }
|
2017-08-01 18:03:07 +00:00
|
|
|
let(:user) { project.creator }
|
2022-07-29 21:08:53 +00:00
|
|
|
let(:issue_1) { create(:issue, project: project) }
|
|
|
|
let(:issue_2) { create(:issue, project: project) }
|
2021-11-25 00:10:49 +00:00
|
|
|
let(:source_branch) { 'csv' }
|
|
|
|
let(:target_branch) { 'master' }
|
|
|
|
let(:squash) { false }
|
2016-12-10 11:58:15 +00:00
|
|
|
let(:merge_request) do
|
|
|
|
create(
|
|
|
|
:merge_request,
|
|
|
|
source_project: project,
|
2021-11-25 00:10:49 +00:00
|
|
|
target_project: project,
|
|
|
|
source_branch: source_branch,
|
|
|
|
target_branch: target_branch,
|
|
|
|
description: "Description\n\nclosing #{issue_1.to_reference}, #{issue_2.to_reference}",
|
|
|
|
squash: squash
|
2016-12-10 11:58:15 +00:00
|
|
|
)
|
|
|
|
end
|
2020-08-11 03:11:00 +00:00
|
|
|
|
2021-11-25 00:10:49 +00:00
|
|
|
let(:merge_textbox) { page.find(:css, '#merge-message-edit', visible: false) }
|
|
|
|
let(:squash_textbox) { page.find(:css, '#squash-message-edit', visible: false) }
|
|
|
|
let(:default_merge_commit_message) do
|
2016-12-10 11:58:15 +00:00
|
|
|
[
|
2021-11-25 00:10:49 +00:00
|
|
|
"Merge branch '#{source_branch}' into '#{target_branch}'",
|
2016-12-10 11:58:15 +00:00
|
|
|
merge_request.title,
|
2016-12-13 13:00:00 +00:00
|
|
|
"Closes #{issue_1.to_reference} and #{issue_2.to_reference}",
|
2017-08-13 12:39:30 +00:00
|
|
|
"See merge request #{merge_request.to_reference(full: true)}"
|
2016-12-10 11:58:15 +00:00
|
|
|
].join("\n\n")
|
|
|
|
end
|
2020-08-11 03:11:00 +00:00
|
|
|
|
2016-12-10 11:58:15 +00:00
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2017-08-01 18:03:07 +00:00
|
|
|
sign_in(user)
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_request_path(project, merge_request)
|
2017-08-01 18:03:07 +00:00
|
|
|
end
|
2016-12-10 11:58:15 +00:00
|
|
|
|
2021-11-11 09:12:21 +00:00
|
|
|
it 'has commit message without description' do
|
2019-02-07 15:14:56 +00:00
|
|
|
expect(page).not_to have_selector('#merge-message-edit')
|
2022-05-05 15:08:47 +00:00
|
|
|
find('[data-testid="widget_edit_commit_message"]').click
|
2021-11-25 00:10:49 +00:00
|
|
|
expect(merge_textbox).to be_visible
|
|
|
|
expect(merge_textbox.value).to eq(default_merge_commit_message)
|
2021-11-11 09:12:21 +00:00
|
|
|
end
|
2016-12-10 11:58:15 +00:00
|
|
|
|
2021-11-11 09:12:21 +00:00
|
|
|
context 'when target project has merge commit template set' do
|
|
|
|
let(:project) { create(:project, :public, :repository, merge_commit_template: '%{title}') }
|
2016-12-10 11:58:15 +00:00
|
|
|
|
2021-11-11 09:12:21 +00:00
|
|
|
it 'uses merge commit template' do
|
|
|
|
expect(page).not_to have_selector('#merge-message-edit')
|
2022-05-05 15:08:47 +00:00
|
|
|
find('[data-testid="widget_edit_commit_message"]').click
|
2021-11-25 00:10:49 +00:00
|
|
|
expect(merge_textbox).to be_visible
|
|
|
|
expect(merge_textbox.value).to eq(merge_request.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when squash is performed' do
|
|
|
|
let(:squash) { true }
|
|
|
|
|
|
|
|
it 'has default message with merge request title' do
|
|
|
|
expect(page).not_to have_selector('#squash-message-edit')
|
2022-05-05 15:08:47 +00:00
|
|
|
find('[data-testid="widget_edit_commit_message"]').click
|
2021-11-25 00:10:49 +00:00
|
|
|
expect(squash_textbox).to be_visible
|
|
|
|
expect(merge_textbox).to be_visible
|
|
|
|
expect(squash_textbox.value).to eq(merge_request.title)
|
|
|
|
expect(merge_textbox.value).to eq(default_merge_commit_message)
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when target project has squash commit template set' do
|
|
|
|
let(:project) { create(:project, :public, :repository, squash_commit_template: '%{description}') }
|
|
|
|
|
|
|
|
it 'uses squash commit template' do
|
|
|
|
expect(page).not_to have_selector('#squash-message-edit')
|
2022-05-05 15:08:47 +00:00
|
|
|
find('[data-testid="widget_edit_commit_message"]').click
|
2021-11-25 00:10:49 +00:00
|
|
|
expect(squash_textbox).to be_visible
|
|
|
|
expect(merge_textbox).to be_visible
|
|
|
|
expect(squash_textbox.value).to eq(merge_request.description)
|
|
|
|
expect(merge_textbox.value).to eq(default_merge_commit_message)
|
|
|
|
end
|
2021-11-11 09:12:21 +00:00
|
|
|
end
|
2016-12-10 11:58:15 +00:00
|
|
|
end
|
|
|
|
end
|