2016-07-18 09:21:30 -04:00
|
|
|
require 'rails_helper'
|
|
|
|
|
2017-06-29 00:13:10 -04:00
|
|
|
describe 'New/edit merge request', :js do
|
2017-07-26 17:52:10 -04:00
|
|
|
let!(:project) { create(:project, :public, :repository) }
|
|
|
|
let(:fork_project) { create(:project, :repository, forked_from_project: project) }
|
|
|
|
let!(:user) { create(:user) }
|
|
|
|
let!(:user2) { create(:user) }
|
|
|
|
let!(:milestone) { create(:milestone, project: project) }
|
|
|
|
let!(:label) { create(:label, project: project) }
|
|
|
|
let!(:label2) { create(:label, project: project) }
|
2016-07-18 09:21:30 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
project.team << [user, :master]
|
2017-02-22 02:26:32 -05:00
|
|
|
project.team << [user2, :master]
|
2016-07-18 09:21:30 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'owned projects' do
|
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2016-07-18 09:21:30 -04:00
|
|
|
end
|
2016-07-21 03:52:37 -04:00
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
context 'new merge request' do
|
|
|
|
before do
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_new_merge_request_path(
|
2016-07-19 05:05:38 -04:00
|
|
|
project,
|
|
|
|
merge_request: {
|
|
|
|
source_project_id: project.id,
|
|
|
|
target_project_id: project.id,
|
|
|
|
source_branch: 'fix',
|
|
|
|
target_branch: 'master'
|
|
|
|
})
|
|
|
|
end
|
2016-07-18 09:21:30 -04:00
|
|
|
|
2016-07-21 03:52:37 -04:00
|
|
|
it 'creates new merge request' do
|
2016-07-19 05:05:38 -04:00
|
|
|
click_button 'Assignee'
|
|
|
|
page.within '.dropdown-menu-user' do
|
2017-02-22 02:26:32 -05:00
|
|
|
click_link user2.name
|
2016-07-19 05:05:38 -04:00
|
|
|
end
|
2017-02-22 02:26:32 -05:00
|
|
|
expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user2.id.to_s)
|
|
|
|
page.within '.js-assignee-search' do
|
|
|
|
expect(page).to have_content user2.name
|
|
|
|
end
|
|
|
|
|
2017-08-07 17:44:42 -04:00
|
|
|
find('a', text: 'Assign to me').trigger('click')
|
2016-07-19 05:05:38 -04:00
|
|
|
expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user.id.to_s)
|
|
|
|
page.within '.js-assignee-search' do
|
|
|
|
expect(page).to have_content user.name
|
|
|
|
end
|
2016-07-18 10:13:56 -04:00
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
click_button 'Milestone'
|
|
|
|
page.within '.issue-milestone' do
|
|
|
|
click_link milestone.title
|
|
|
|
end
|
|
|
|
expect(find('input[name="merge_request[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)
|
|
|
|
page.within '.js-milestone-select' do
|
|
|
|
expect(page).to have_content milestone.title
|
|
|
|
end
|
|
|
|
|
|
|
|
click_button 'Labels'
|
|
|
|
page.within '.dropdown-menu-labels' do
|
|
|
|
click_link label.title
|
|
|
|
click_link label2.title
|
|
|
|
end
|
|
|
|
page.within '.js-label-select' do
|
|
|
|
expect(page).to have_content label.title
|
|
|
|
end
|
|
|
|
expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)
|
|
|
|
expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)
|
|
|
|
|
|
|
|
click_button 'Submit merge request'
|
|
|
|
|
|
|
|
page.within '.issuable-sidebar' do
|
|
|
|
page.within '.assignee' do
|
|
|
|
expect(page).to have_content user.name
|
|
|
|
end
|
2016-07-18 10:13:56 -04:00
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
page.within '.milestone' do
|
|
|
|
expect(page).to have_content milestone.title
|
|
|
|
end
|
2016-07-18 10:13:56 -04:00
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
page.within '.labels' do
|
|
|
|
expect(page).to have_content label.title
|
|
|
|
expect(page).to have_content label2.title
|
|
|
|
end
|
|
|
|
end
|
2017-03-08 19:14:16 -05:00
|
|
|
|
|
|
|
page.within '.issuable-meta' do
|
|
|
|
merge_request = MergeRequest.find_by(source_branch: 'fix')
|
|
|
|
|
2017-05-18 15:52:40 -04:00
|
|
|
expect(page).to have_text("Merge request #{merge_request.to_reference}")
|
2017-03-08 19:14:16 -05:00
|
|
|
# compare paths because the host differ in test
|
|
|
|
expect(find_link(merge_request.to_reference)[:href])
|
|
|
|
.to end_with(merge_request_path(merge_request))
|
|
|
|
end
|
2016-07-18 10:13:56 -04:00
|
|
|
end
|
2017-06-12 16:46:51 -04:00
|
|
|
|
|
|
|
it 'description has autocomplete' do
|
|
|
|
find('#merge_request_description').native.send_keys('')
|
|
|
|
fill_in 'merge_request_description', with: '@'
|
|
|
|
|
|
|
|
expect(page).to have_selector('.atwho-view')
|
|
|
|
end
|
2016-07-19 05:05:38 -04:00
|
|
|
end
|
2016-07-18 10:13:56 -04:00
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
context 'edit merge request' do
|
|
|
|
before do
|
|
|
|
merge_request = create(:merge_request,
|
|
|
|
source_project: project,
|
|
|
|
target_project: project,
|
|
|
|
source_branch: 'fix',
|
|
|
|
target_branch: 'master'
|
|
|
|
)
|
2016-07-18 10:13:56 -04:00
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit edit_project_merge_request_path(project, merge_request)
|
2016-07-18 10:13:56 -04:00
|
|
|
end
|
|
|
|
|
2016-07-21 03:52:37 -04:00
|
|
|
it 'updates merge request' do
|
2016-07-19 05:05:38 -04:00
|
|
|
click_button 'Assignee'
|
|
|
|
page.within '.dropdown-menu-user' do
|
|
|
|
click_link user.name
|
|
|
|
end
|
|
|
|
expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user.id.to_s)
|
|
|
|
page.within '.js-assignee-search' do
|
|
|
|
expect(page).to have_content user.name
|
|
|
|
end
|
|
|
|
|
|
|
|
click_button 'Milestone'
|
|
|
|
page.within '.issue-milestone' do
|
|
|
|
click_link milestone.title
|
|
|
|
end
|
|
|
|
expect(find('input[name="merge_request[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)
|
|
|
|
page.within '.js-milestone-select' do
|
|
|
|
expect(page).to have_content milestone.title
|
|
|
|
end
|
|
|
|
|
|
|
|
click_button 'Labels'
|
|
|
|
page.within '.dropdown-menu-labels' do
|
|
|
|
click_link label.title
|
|
|
|
click_link label2.title
|
|
|
|
end
|
|
|
|
expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)
|
|
|
|
expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)
|
|
|
|
page.within '.js-label-select' do
|
|
|
|
expect(page).to have_content label.title
|
|
|
|
end
|
|
|
|
|
|
|
|
click_button 'Save changes'
|
|
|
|
|
|
|
|
page.within '.issuable-sidebar' do
|
|
|
|
page.within '.assignee' do
|
|
|
|
expect(page).to have_content user.name
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within '.milestone' do
|
|
|
|
expect(page).to have_content milestone.title
|
|
|
|
end
|
2016-07-18 10:13:56 -04:00
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
page.within '.labels' do
|
|
|
|
expect(page).to have_content label.title
|
|
|
|
expect(page).to have_content label2.title
|
|
|
|
end
|
|
|
|
end
|
2016-07-18 10:13:56 -04:00
|
|
|
end
|
2017-06-12 16:46:51 -04:00
|
|
|
|
|
|
|
it 'description has autocomplete' do
|
|
|
|
find('#merge_request_description').native.send_keys('')
|
|
|
|
fill_in 'merge_request_description', with: '@'
|
|
|
|
|
|
|
|
expect(page).to have_selector('.atwho-view')
|
|
|
|
end
|
2016-07-18 09:21:30 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'forked project' do
|
|
|
|
before do
|
|
|
|
fork_project.team << [user, :master]
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(user)
|
2016-07-19 05:05:38 -04:00
|
|
|
end
|
2016-07-18 09:21:30 -04:00
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
context 'new merge request' do
|
|
|
|
before do
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_new_merge_request_path(
|
2016-07-19 05:05:38 -04:00
|
|
|
fork_project,
|
|
|
|
merge_request: {
|
|
|
|
source_project_id: fork_project.id,
|
|
|
|
target_project_id: project.id,
|
|
|
|
source_branch: 'fix',
|
|
|
|
target_branch: 'master'
|
|
|
|
})
|
|
|
|
end
|
2016-07-18 09:21:30 -04:00
|
|
|
|
2016-07-21 03:52:37 -04:00
|
|
|
it 'creates new merge request' do
|
2016-07-19 05:05:38 -04:00
|
|
|
click_button 'Assignee'
|
|
|
|
page.within '.dropdown-menu-user' do
|
|
|
|
click_link user.name
|
|
|
|
end
|
|
|
|
expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user.id.to_s)
|
|
|
|
page.within '.js-assignee-search' do
|
|
|
|
expect(page).to have_content user.name
|
|
|
|
end
|
2016-07-18 09:21:30 -04:00
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
click_button 'Milestone'
|
|
|
|
page.within '.issue-milestone' do
|
|
|
|
click_link milestone.title
|
|
|
|
end
|
|
|
|
expect(find('input[name="merge_request[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)
|
|
|
|
page.within '.js-milestone-select' do
|
|
|
|
expect(page).to have_content milestone.title
|
|
|
|
end
|
2016-07-18 09:21:30 -04:00
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
click_button 'Labels'
|
|
|
|
page.within '.dropdown-menu-labels' do
|
|
|
|
click_link label.title
|
|
|
|
click_link label2.title
|
|
|
|
end
|
|
|
|
page.within '.js-label-select' do
|
|
|
|
expect(page).to have_content label.title
|
|
|
|
end
|
|
|
|
expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)
|
|
|
|
expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)
|
2016-07-18 09:21:30 -04:00
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
click_button 'Submit merge request'
|
|
|
|
|
|
|
|
page.within '.issuable-sidebar' do
|
|
|
|
page.within '.assignee' do
|
|
|
|
expect(page).to have_content user.name
|
|
|
|
end
|
2016-07-18 09:21:30 -04:00
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
page.within '.milestone' do
|
|
|
|
expect(page).to have_content milestone.title
|
|
|
|
end
|
2016-07-18 09:21:30 -04:00
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
page.within '.labels' do
|
|
|
|
expect(page).to have_content label.title
|
|
|
|
expect(page).to have_content label2.title
|
|
|
|
end
|
|
|
|
end
|
2016-07-18 10:13:56 -04:00
|
|
|
end
|
2016-07-19 05:05:38 -04:00
|
|
|
end
|
2016-07-18 09:21:30 -04:00
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
context 'edit merge request' do
|
|
|
|
before do
|
|
|
|
merge_request = create(:merge_request,
|
|
|
|
source_project: fork_project,
|
|
|
|
target_project: project,
|
|
|
|
source_branch: 'fix',
|
|
|
|
target_branch: 'master'
|
|
|
|
)
|
2016-07-18 09:21:30 -04:00
|
|
|
|
2017-07-06 12:20:50 -04:00
|
|
|
visit edit_project_merge_request_path(project, merge_request)
|
2016-07-18 10:13:56 -04:00
|
|
|
end
|
2016-07-18 09:21:30 -04:00
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
it 'should update merge request' do
|
|
|
|
click_button 'Assignee'
|
|
|
|
page.within '.dropdown-menu-user' do
|
|
|
|
click_link user.name
|
|
|
|
end
|
|
|
|
expect(find('input[name="merge_request[assignee_id]"]', visible: false).value).to match(user.id.to_s)
|
|
|
|
page.within '.js-assignee-search' do
|
|
|
|
expect(page).to have_content user.name
|
|
|
|
end
|
|
|
|
|
|
|
|
click_button 'Milestone'
|
|
|
|
page.within '.issue-milestone' do
|
|
|
|
click_link milestone.title
|
|
|
|
end
|
|
|
|
expect(find('input[name="merge_request[milestone_id]"]', visible: false).value).to match(milestone.id.to_s)
|
|
|
|
page.within '.js-milestone-select' do
|
|
|
|
expect(page).to have_content milestone.title
|
|
|
|
end
|
|
|
|
|
|
|
|
click_button 'Labels'
|
|
|
|
page.within '.dropdown-menu-labels' do
|
|
|
|
click_link label.title
|
|
|
|
click_link label2.title
|
|
|
|
end
|
|
|
|
expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[1].value).to match(label.id.to_s)
|
|
|
|
expect(page.all('input[name="merge_request[label_ids][]"]', visible: false)[2].value).to match(label2.id.to_s)
|
|
|
|
page.within '.js-label-select' do
|
|
|
|
expect(page).to have_content label.title
|
|
|
|
end
|
|
|
|
|
|
|
|
click_button 'Save changes'
|
|
|
|
|
|
|
|
page.within '.issuable-sidebar' do
|
|
|
|
page.within '.assignee' do
|
|
|
|
expect(page).to have_content user.name
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within '.milestone' do
|
|
|
|
expect(page).to have_content milestone.title
|
|
|
|
end
|
2016-07-18 09:21:30 -04:00
|
|
|
|
2016-07-19 05:05:38 -04:00
|
|
|
page.within '.labels' do
|
|
|
|
expect(page).to have_content label.title
|
|
|
|
expect(page).to have_content label2.title
|
|
|
|
end
|
|
|
|
end
|
2016-07-18 10:13:56 -04:00
|
|
|
end
|
2016-07-18 09:21:30 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|