2016-04-04 01:50:53 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2016-04-06 11:25:38 -04:00
|
|
|
feature 'Create New Merge Request', feature: true, js: true do
|
2016-04-04 01:50:53 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, :public) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.team << [user, :master]
|
|
|
|
|
|
|
|
login_as user
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'generates a diff for an orphaned branch' do
|
2016-08-11 04:02:27 -04:00
|
|
|
visit namespace_project_merge_requests_path(project.namespace, project)
|
|
|
|
|
2016-04-04 01:50:53 -04:00
|
|
|
click_link 'New Merge Request'
|
2016-08-11 12:48:32 -04:00
|
|
|
expect(page).to have_content('Source branch')
|
|
|
|
expect(page).to have_content('Target branch')
|
2016-04-06 11:25:38 -04:00
|
|
|
|
|
|
|
first('.js-source-branch').click
|
|
|
|
first('.dropdown-source-branch .dropdown-content a', text: 'orphaned-branch').click
|
|
|
|
|
2016-04-04 01:50:53 -04:00
|
|
|
click_button "Compare branches"
|
2016-04-06 11:25:38 -04:00
|
|
|
click_link "Changes"
|
2016-04-04 01:50:53 -04: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 11:25:38 -04:00
|
|
|
click_link "Check out branch"
|
|
|
|
|
2016-04-04 01:50:53 -04:00
|
|
|
expect(page).to have_content 'git checkout -b orphaned-branch origin/orphaned-branch'
|
|
|
|
end
|
2016-04-25 09:46:15 -04:00
|
|
|
|
|
|
|
context 'when target project cannot be viewed by the current user' do
|
|
|
|
it 'does not leak the private project name & namespace' do
|
|
|
|
private_project = create(:project, :private)
|
|
|
|
|
|
|
|
visit new_namespace_project_merge_request_path(project.namespace, project, merge_request: { target_project_id: private_project.id })
|
|
|
|
|
|
|
|
expect(page).not_to have_content private_project.to_reference
|
|
|
|
end
|
|
|
|
end
|
2016-08-11 04:02:27 -04:00
|
|
|
|
|
|
|
it 'allows to change the diff view' do
|
|
|
|
visit new_namespace_project_merge_request_path(project.namespace, project, merge_request: { target_branch: 'master', source_branch: 'fix' })
|
|
|
|
|
|
|
|
click_link 'Changes'
|
|
|
|
|
2016-08-18 08:33:27 -04: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 04:02:27 -04:00
|
|
|
|
|
|
|
click_link 'Side-by-side'
|
|
|
|
|
2016-08-17 23:55:24 -04: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 04:02:27 -04:00
|
|
|
end
|
2016-10-06 21:09:15 -04:00
|
|
|
|
|
|
|
it 'does not allow non-existing branches' do
|
|
|
|
visit new_namespace_project_merge_request_path(project.namespace, project, merge_request: { target_branch: 'non-exist-target', source_branch: 'non-exist-source' })
|
|
|
|
|
|
|
|
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-04-04 01:50:53 -04:00
|
|
|
end
|