2016-04-04 05:50:53 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-10-03 08:35:01 +00:00
|
|
|
feature 'Create New Merge Request', :js do
|
2016-04-04 05:50:53 +00:00
|
|
|
let(:user) { create(:user) }
|
2017-07-26 21:52:10 +00:00
|
|
|
let(:project) { create(:project, :public, :repository) }
|
2016-04-04 05:50:53 +00:00
|
|
|
|
|
|
|
before do
|
|
|
|
project.team << [user, :master]
|
|
|
|
|
2017-06-21 23:44:10 +00:00
|
|
|
sign_in user
|
2016-04-04 05:50:53 +00:00
|
|
|
end
|
|
|
|
|
2017-02-24 12:13:42 +00:00
|
|
|
it 'selects the source branch sha when a tag with the same name exists' do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_requests_path(project)
|
2017-02-24 12:13:42 +00:00
|
|
|
|
2017-08-18 11:07:10 +00:00
|
|
|
page.within '.content' do
|
|
|
|
click_link 'New merge request'
|
|
|
|
end
|
2017-02-24 12:13:42 +00:00
|
|
|
expect(page).to have_content('Source branch')
|
|
|
|
expect(page).to have_content('Target branch')
|
|
|
|
|
|
|
|
first('.js-source-branch').click
|
2017-04-21 15:05:38 +00:00
|
|
|
find('.dropdown-source-branch .dropdown-content a', match: :first).click
|
2017-02-24 12:13:42 +00:00
|
|
|
|
|
|
|
expect(page).to have_content "b83d6e3"
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'selects the target branch sha when a tag with the same name exists' do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_requests_path(project)
|
2017-04-05 12:43:03 +00:00
|
|
|
|
2017-08-18 11:07:10 +00:00
|
|
|
page.within '.content' do
|
|
|
|
click_link 'New merge request'
|
|
|
|
end
|
2017-02-24 12:13:42 +00:00
|
|
|
|
|
|
|
expect(page).to have_content('Source branch')
|
|
|
|
expect(page).to have_content('Target branch')
|
|
|
|
|
|
|
|
first('.js-target-branch').click
|
2017-05-03 11:29:59 +00:00
|
|
|
find('.dropdown-target-branch .dropdown-content a', text: 'v1.1.0', match: :first).click
|
2017-02-24 12:13:42 +00:00
|
|
|
|
|
|
|
expect(page).to have_content "b83d6e3"
|
|
|
|
end
|
|
|
|
|
2016-04-04 05:50:53 +00:00
|
|
|
it 'generates a diff for an orphaned branch' do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_merge_requests_path(project)
|
2016-08-11 08:02:27 +00:00
|
|
|
|
2017-08-18 11:07:10 +00:00
|
|
|
page.within '.content' do
|
|
|
|
click_link 'New merge request'
|
|
|
|
end
|
2016-08-11 16:48:32 +00:00
|
|
|
expect(page).to have_content('Source branch')
|
|
|
|
expect(page).to have_content('Target branch')
|
2016-04-06 15:25:38 +00:00
|
|
|
|
2017-04-21 15:05:38 +00:00
|
|
|
find('.js-source-branch', match: :first).click
|
|
|
|
find('.dropdown-source-branch .dropdown-content a', text: 'orphaned-branch', match: :first).click
|
2016-04-06 15:25:38 +00:00
|
|
|
|
2016-04-04 05:50:53 +00:00
|
|
|
click_button "Compare branches"
|
2016-04-06 15:25:38 +00:00
|
|
|
click_link "Changes"
|
2016-04-04 05:50:53 +00:00
|
|
|
|
|
|
|
expect(page).to have_content "README.md"
|
|
|
|
expect(page).to have_content "wm.png"
|
|
|
|
|
|
|
|
fill_in "merge_request_title", with: "Orphaned MR test"
|
|
|
|
click_button "Submit merge request"
|
|
|
|
|
2016-04-06 15:25:38 +00:00
|
|
|
click_link "Check out branch"
|
|
|
|
|
2016-04-04 05:50:53 +00:00
|
|
|
expect(page).to have_content 'git checkout -b orphaned-branch origin/orphaned-branch'
|
|
|
|
end
|
2016-04-25 13:46:15 +00:00
|
|
|
|
2017-11-06 13:12:06 +00:00
|
|
|
it 'allows filtering multiple dropdowns' do
|
|
|
|
visit project_new_merge_request_path(project)
|
|
|
|
|
|
|
|
first('.js-source-branch').click
|
|
|
|
|
|
|
|
input = find('.dropdown-source-branch .dropdown-input-field')
|
|
|
|
input.click
|
|
|
|
input.send_keys('orphaned-branch')
|
|
|
|
|
|
|
|
find('.dropdown-source-branch .dropdown-content li', match: :first)
|
|
|
|
source_items = all('.dropdown-source-branch .dropdown-content li')
|
|
|
|
|
|
|
|
expect(source_items.count).to eq(1)
|
|
|
|
|
|
|
|
first('.js-target-branch').click
|
|
|
|
|
|
|
|
find('.dropdown-target-branch .dropdown-content li', match: :first)
|
|
|
|
target_items = all('.dropdown-target-branch .dropdown-content li')
|
|
|
|
|
|
|
|
expect(target_items.count).to be > 1
|
|
|
|
end
|
|
|
|
|
2016-04-25 13:46:15 +00:00
|
|
|
context 'when target project cannot be viewed by the current user' do
|
|
|
|
it 'does not leak the private project name & namespace' do
|
2017-07-26 21:52:10 +00:00
|
|
|
private_project = create(:project, :private, :repository)
|
2016-04-25 13:46:15 +00:00
|
|
|
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_new_merge_request_path(project, merge_request: { target_project_id: private_project.id })
|
2016-04-25 13:46:15 +00:00
|
|
|
|
2017-07-20 09:34:09 +00:00
|
|
|
expect(page).not_to have_content private_project.full_path
|
|
|
|
expect(page).to have_content project.full_path
|
2017-04-03 18:47:14 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when source project cannot be viewed by the current user' do
|
|
|
|
it 'does not leak the private project name & namespace' do
|
2017-07-26 21:52:10 +00:00
|
|
|
private_project = create(:project, :private, :repository)
|
2017-04-03 18:47:14 +00:00
|
|
|
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_new_merge_request_path(project, merge_request: { source_project_id: private_project.id })
|
2017-04-03 18:47:14 +00:00
|
|
|
|
2017-07-20 09:34:09 +00:00
|
|
|
expect(page).not_to have_content private_project.full_path
|
|
|
|
expect(page).to have_content project.full_path
|
2016-04-25 13:46:15 +00:00
|
|
|
end
|
|
|
|
end
|
2016-08-11 08:02:27 +00:00
|
|
|
|
2017-03-20 11:05:32 +00:00
|
|
|
it 'populates source branch button' do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_new_merge_request_path(project, change_branches: true, merge_request: { target_branch: 'master', source_branch: 'fix' })
|
2017-03-20 11:05:32 +00:00
|
|
|
|
|
|
|
expect(find('.js-source-branch')).to have_content('fix')
|
|
|
|
end
|
|
|
|
|
2016-08-11 08:02:27 +00:00
|
|
|
it 'allows to change the diff view' do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_new_merge_request_path(project, merge_request: { target_branch: 'master', source_branch: 'fix' })
|
2016-08-11 08:02:27 +00:00
|
|
|
|
|
|
|
click_link 'Changes'
|
|
|
|
|
2016-08-18 12:33:27 +00:00
|
|
|
expect(page).to have_css('a.btn.active', text: 'Inline')
|
|
|
|
expect(page).not_to have_css('a.btn.active', text: 'Side-by-side')
|
2016-08-11 08:02:27 +00:00
|
|
|
|
|
|
|
click_link 'Side-by-side'
|
|
|
|
|
2016-08-18 03:55:24 +00:00
|
|
|
within '.merge-request' do
|
|
|
|
expect(page).not_to have_css('a.btn.active', text: 'Inline')
|
|
|
|
expect(page).to have_css('a.btn.active', text: 'Side-by-side')
|
|
|
|
end
|
2016-08-11 08:02:27 +00:00
|
|
|
end
|
2016-10-07 01:09:15 +00:00
|
|
|
|
|
|
|
it 'does not allow non-existing branches' do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_new_merge_request_path(project, merge_request: { target_branch: 'non-exist-target', source_branch: 'non-exist-source' })
|
2016-10-07 01:09:15 +00:00
|
|
|
|
|
|
|
expect(page).to have_content('The form contains the following errors')
|
|
|
|
expect(page).to have_content('Source branch "non-exist-source" does not exist')
|
|
|
|
expect(page).to have_content('Target branch "non-exist-target" does not exist')
|
|
|
|
end
|
2016-08-28 03:59:48 +00:00
|
|
|
|
|
|
|
context 'when a branch contains commits that both delete and add the same image' do
|
|
|
|
it 'renders the diff successfully' do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_new_merge_request_path(project, merge_request: { target_branch: 'master', source_branch: 'deleted-image-test' })
|
2016-08-28 03:59:48 +00:00
|
|
|
|
|
|
|
click_link "Changes"
|
|
|
|
|
|
|
|
expect(page).to have_content "6049019_460s.jpg"
|
|
|
|
end
|
|
|
|
end
|
2016-11-19 15:28:56 +00:00
|
|
|
|
|
|
|
# Isolates a regression (see #24627)
|
|
|
|
it 'does not show error messages on initial form' do
|
2017-07-06 16:20:50 +00:00
|
|
|
visit project_new_merge_request_path(project)
|
2016-11-19 15:28:56 +00:00
|
|
|
expect(page).not_to have_selector('#error_explanation')
|
|
|
|
expect(page).not_to have_content('The form contains the following error')
|
|
|
|
end
|
2017-02-07 15:36:29 +00:00
|
|
|
|
|
|
|
context 'when a new merge request has a pipeline' do
|
|
|
|
let!(:pipeline) do
|
|
|
|
create(:ci_pipeline, sha: project.commit('fix').id,
|
|
|
|
ref: 'fix',
|
|
|
|
project: project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'shows pipelines for a new merge request' do
|
2017-06-29 17:06:35 +00:00
|
|
|
visit project_new_merge_request_path(
|
|
|
|
project,
|
2017-02-07 15:36:29 +00:00
|
|
|
merge_request: { target_branch: 'master', source_branch: 'fix' })
|
|
|
|
|
|
|
|
page.within('.merge-request') do
|
|
|
|
click_link 'Pipelines'
|
2017-05-17 18:25:13 +00:00
|
|
|
wait_for_requests
|
2017-02-07 15:36:29 +00:00
|
|
|
|
|
|
|
expect(page).to have_content "##{pipeline.id}"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2016-04-04 05:50:53 +00:00
|
|
|
end
|