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-22 18:45:36 +00:00
|
|
|
|
2020-07-17 21:09:23 +00:00
|
|
|
RSpec.describe 'Merge request > User sees draft help message' do
|
2017-08-01 18:03:07 +00:00
|
|
|
let(:project) { create(:project, :public, :repository) }
|
|
|
|
let(:user) { project.creator }
|
2016-12-22 18:45:36 +00:00
|
|
|
|
|
|
|
before do
|
2018-07-11 14:36:08 +00:00
|
|
|
project.add_maintainer(user)
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in(user)
|
2016-12-22 18:45:36 +00:00
|
|
|
end
|
|
|
|
|
2020-07-17 21:09:23 +00:00
|
|
|
context 'with draft commits' do
|
|
|
|
it 'shows a specific draft hint' do
|
2017-06-29 17:06:35 +00:00
|
|
|
visit project_new_merge_request_path(
|
2016-12-22 18:45:36 +00:00
|
|
|
project,
|
|
|
|
merge_request: {
|
|
|
|
source_project_id: project.id,
|
|
|
|
target_project_id: project.id,
|
2018-11-07 13:32:20 +00:00
|
|
|
source_branch: 'wip',
|
2016-12-22 18:45:36 +00:00
|
|
|
target_branch: 'master'
|
2017-07-06 16:20:50 +00:00
|
|
|
})
|
2016-12-22 18:45:36 +00:00
|
|
|
|
|
|
|
within_wip_explanation do
|
|
|
|
expect(page).to have_text(
|
2020-07-17 21:09:23 +00:00
|
|
|
'It looks like you have some draft commits in this branch'
|
2016-12-22 18:45:36 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-07-17 21:09:23 +00:00
|
|
|
context 'without draft commits' do
|
|
|
|
it 'shows the regular draft message' do
|
2017-06-29 17:06:35 +00:00
|
|
|
visit project_new_merge_request_path(
|
2016-12-22 18:45:36 +00:00
|
|
|
project,
|
|
|
|
merge_request: {
|
|
|
|
source_project_id: project.id,
|
|
|
|
target_project_id: project.id,
|
2018-11-07 13:32:20 +00:00
|
|
|
source_branch: 'fix',
|
2016-12-22 18:45:36 +00:00
|
|
|
target_branch: 'master'
|
2017-07-06 16:20:50 +00:00
|
|
|
})
|
2016-12-22 18:45:36 +00:00
|
|
|
|
|
|
|
within_wip_explanation do
|
|
|
|
expect(page).not_to have_text(
|
2020-07-17 21:09:23 +00:00
|
|
|
'It looks like you have some draft commits in this branch'
|
2016-12-22 18:45:36 +00:00
|
|
|
)
|
|
|
|
expect(page).to have_text(
|
2021-11-18 09:10:16 +00:00
|
|
|
"Start the title with Draft: to prevent a merge request draft \
|
|
|
|
from merging before it's ready."
|
2016-12-22 18:45:36 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def within_wip_explanation(&block)
|
|
|
|
page.within '.js-no-wip-explanation' do
|
|
|
|
yield
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|