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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

111 lines
3.5 KiB
Ruby
Raw Permalink 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],
2020-11-24 15:15:51 +05:30
reviewers: [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
2023-07-09 08:55:56 +05:30
shared_examples 'merge request shows editable fields' do
it 'shows editable fields' do
2016-09-29 09:46:39 +05:30
render
expect(rendered).to have_field('merge_request[title]')
2023-06-20 00:43:36 +05:30
expect(rendered).to have_selector('input[name="merge_request[description]"]', visible: false)
2023-01-13 00:05:48 +05:30
expect(rendered).to have_selector('.js-milestone-dropdown-root')
2023-07-09 08:55:56 +05:30
expect(rendered).to have_selector('#merge_request_target_branch', visible: false)
2016-09-29 09:46:39 +05:30
end
end
2023-07-09 08:55:56 +05:30
context 'with the visible_label_selection_on_metadata feature flag enabled' do
before do
stub_feature_flags(visible_label_selection_on_metadata: true)
end
2016-09-29 09:46:39 +05:30
2023-07-09 08:55:56 +05:30
context 'when a merge request without fork' do
it_behaves_like 'merge request shows editable fields'
it "shows editable fields" do
unlink_project.execute
closed_merge_request.reload
render
expect(rendered).not_to have_selector('#merge_request_target_branch', visible: false)
expect(rendered).to have_selector('.js-issuable-form-label-selector')
end
end
context 'when a merge request with an existing source project is closed' do
it_behaves_like 'merge request shows editable fields'
it "shows editable fields" do
render
expect(rendered).to have_selector('#merge_request_target_branch', visible: false)
expect(rendered).to have_selector('.js-issuable-form-label-selector')
end
end
end
context 'with the visible_label_selection_on_metadata feature flag disabled' do
before do
stub_feature_flags(visible_label_selection_on_metadata: false)
end
context 'when a merge request without fork' do
it_behaves_like 'merge request shows editable fields'
it "shows editable fields" do
unlink_project.execute
closed_merge_request.reload
render
expect(rendered).not_to have_selector('#merge_request_target_branch', visible: false)
expect(rendered).not_to have_selector('.js-issuable-form-label-selector')
end
end
context 'when a merge request with an existing source project is closed' do
it_behaves_like 'merge request shows editable fields'
it "shows editable fields" do
render
expect(rendered).to have_selector('#merge_request_target_branch', visible: false)
expect(rendered).not_to have_selector('.js-issuable-form-label-selector')
end
2016-09-29 09:46:39 +05:30
end
end
end