2016-07-26 07:57:43 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'projects/merge_requests/edit.html.haml' do
|
2016-09-21 19:06:33 -04:00
|
|
|
include Devise::Test::ControllerHelpers
|
2017-09-29 04:04:50 -04:00
|
|
|
include ProjectForksHelper
|
2016-07-26 07:57:43 -04:00
|
|
|
|
|
|
|
let(:user) { create(:user) }
|
2017-03-27 16:20:27 -04:00
|
|
|
let(:project) { create(:project, :repository) }
|
2017-09-29 04:04:50 -04:00
|
|
|
let(:forked_project) { fork_project(project, user, repository: true) }
|
|
|
|
let(:unlink_project) { Projects::UnlinkForkService.new(forked_project, user) }
|
2016-09-02 09:00:57 -04:00
|
|
|
let(:milestone) { create(:milestone, project: project) }
|
2016-08-09 09:43:15 -04:00
|
|
|
|
2016-07-26 07:57:43 -04:00
|
|
|
let(:closed_merge_request) do
|
2017-09-29 04:04:50 -04:00
|
|
|
project.add_developer(user)
|
|
|
|
|
2016-07-26 07:57:43 -04:00
|
|
|
create(:closed_merge_request,
|
2017-09-29 04:04:50 -04:00
|
|
|
source_project: forked_project,
|
2016-07-26 07:57:43 -04:00
|
|
|
target_project: project,
|
2016-09-02 09:00:57 -04:00
|
|
|
author: user,
|
|
|
|
assignee: user,
|
|
|
|
milestone: milestone)
|
2016-07-26 07:57:43 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
assign(:project, project)
|
|
|
|
assign(:merge_request, closed_merge_request)
|
2018-09-07 08:29:19 -04:00
|
|
|
assign(:mr_presenter, closed_merge_request.present(current_user: user))
|
2016-07-26 07:57:43 -04:00
|
|
|
|
|
|
|
allow(view).to receive(:can?).and_return(true)
|
2016-08-09 09:43:15 -04:00
|
|
|
allow(view).to receive(:current_user)
|
|
|
|
.and_return(User.find(closed_merge_request.author_id))
|
2016-07-26 07:57:43 -04:00
|
|
|
end
|
|
|
|
|
2016-08-10 09:36:30 -04:00
|
|
|
context 'when a merge request without fork' do
|
2016-07-26 07:57:43 -04:00
|
|
|
it "shows editable fields" do
|
|
|
|
unlink_project.execute
|
|
|
|
closed_merge_request.reload
|
2016-08-09 09:43:15 -04:00
|
|
|
|
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to have_field('merge_request[title]')
|
|
|
|
expect(rendered).to have_field('merge_request[description]')
|
|
|
|
expect(rendered).to have_selector('#merge_request_assignee_id', visible: false)
|
|
|
|
expect(rendered).to have_selector('#merge_request_milestone_id', visible: false)
|
|
|
|
expect(rendered).not_to have_selector('#merge_request_target_branch', visible: false)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-08-10 09:36:30 -04:00
|
|
|
context 'when a merge request with an existing source project is closed' do
|
2016-08-09 09:43:15 -04:00
|
|
|
it "shows editable fields" do
|
2016-07-26 07:57:43 -04:00
|
|
|
render
|
|
|
|
|
|
|
|
expect(rendered).to have_field('merge_request[title]')
|
|
|
|
expect(rendered).to have_field('merge_request[description]')
|
2016-08-09 09:43:15 -04:00
|
|
|
expect(rendered).to have_selector('#merge_request_assignee_id', visible: false)
|
|
|
|
expect(rendered).to have_selector('#merge_request_milestone_id', visible: false)
|
|
|
|
expect(rendered).to have_selector('#merge_request_target_branch', visible: false)
|
2016-07-26 07:57:43 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|