debian-mirror-gitlab/spec/views/projects/merge_requests/edit.html.haml_spec.rb

64 lines
2.2 KiB
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2016-09-29 09:46:39 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe 'projects/merge_requests/edit.html.haml' do
2016-11-03 12:29:30 +05:30
include Devise::Test::ControllerHelpers
2018-03-17 18:26:18 +05:30
include ProjectForksHelper
2016-09-29 09:46:39 +05:30
let(:user) { create(:user) }
2017-08-17 22:00:37 +05:30
let(:project) { create(:project, :repository) }
2018-03-17 18:26:18 +05:30
let(:forked_project) { fork_project(project, user, repository: true) }
let(:unlink_project) { Projects::UnlinkForkService.new(forked_project, user) }
2016-11-03 12:29:30 +05:30
let(:milestone) { create(:milestone, project: project) }
2016-09-29 09:46:39 +05:30
let(:closed_merge_request) do
2018-03-17 18:26:18 +05:30
project.add_developer(user)
2016-09-29 09:46:39 +05:30
create(:closed_merge_request,
2018-03-17 18:26:18 +05:30
source_project: forked_project,
2016-09-29 09:46:39 +05:30
target_project: project,
2016-11-03 12:29:30 +05:30
author: user,
2019-07-31 22:56:46 +05:30
assignees: [user],
2016-11-03 12:29:30 +05:30
milestone: milestone)
2016-09-29 09:46:39 +05:30
end
before do
assign(:project, project)
2019-10-12 21:52:04 +05:30
assign(:target_project, project)
2016-09-29 09:46:39 +05:30
assign(:merge_request, closed_merge_request)
2018-11-08 19:23:39 +05:30
assign(:mr_presenter, closed_merge_request.present(current_user: user))
2016-09-29 09:46:39 +05:30
allow(view).to receive(:can?).and_return(true)
allow(view).to receive(:current_user)
.and_return(User.find(closed_merge_request.author_id))
end
context 'when a merge request without fork' do
it "shows editable fields" do
unlink_project.execute
closed_merge_request.reload
render
expect(rendered).to have_field('merge_request[title]')
expect(rendered).to have_field('merge_request[description]')
2019-07-31 22:56:46 +05:30
expect(rendered).to have_selector('input[name="merge_request[label_ids][]"]', visible: false)
2016-09-29 09:46:39 +05:30
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
context 'when a merge request with an existing source project is closed' do
it "shows editable fields" do
render
expect(rendered).to have_field('merge_request[title]')
expect(rendered).to have_field('merge_request[description]')
2019-07-31 22:56:46 +05:30
expect(rendered).to have_selector('input[name="merge_request[label_ids][]"]', visible: false)
2016-09-29 09:46:39 +05:30
expect(rendered).to have_selector('#merge_request_milestone_id', visible: false)
expect(rendered).to have_selector('#merge_request_target_branch', visible: false)
end
end
end