2019-10-17 06:07:30 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-02-12 22:49:29 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 18:09:01 +00:00
|
|
|
RSpec.describe Projects::MergeRequestsController, '(JavaScript fixtures)', type: :controller do
|
2017-02-12 22:49:29 +00:00
|
|
|
include JavaScriptFixturesHelpers
|
|
|
|
|
|
|
|
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
|
2017-08-01 18:51:52 +00:00
|
|
|
let(:project) { create(:project, :repository, namespace: namespace, path: 'merge-requests-project') }
|
2020-12-07 12:10:00 +00:00
|
|
|
let(:user) { project.owner }
|
2019-11-15 15:06:12 +00:00
|
|
|
|
|
|
|
# rubocop: disable Layout/TrailingWhitespace
|
2020-02-17 21:09:20 +00:00
|
|
|
let(:description) do
|
|
|
|
<<~MARKDOWN.strip_heredoc
|
|
|
|
- [ ] Task List Item
|
2020-12-03 09:09:33 +00:00
|
|
|
- [ ]
|
2020-02-17 21:09:20 +00:00
|
|
|
- [ ] Task List Item 2
|
|
|
|
MARKDOWN
|
|
|
|
end
|
|
|
|
# rubocop: enable Layout/TrailingWhitespace
|
|
|
|
|
2019-11-15 15:06:12 +00:00
|
|
|
let(:merge_request) do
|
|
|
|
create(
|
|
|
|
:merge_request,
|
|
|
|
source_project: project,
|
|
|
|
target_project: project,
|
2020-02-17 21:09:20 +00:00
|
|
|
description: description
|
2019-11-15 15:06:12 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2017-04-12 07:03:39 +00:00
|
|
|
let(:merged_merge_request) { create(:merge_request, :merged, source_project: project, target_project: project) }
|
2017-03-23 02:39:09 +00:00
|
|
|
let(:pipeline) do
|
|
|
|
create(
|
|
|
|
:ci_pipeline,
|
|
|
|
project: merge_request.source_project,
|
|
|
|
ref: merge_request.source_branch,
|
|
|
|
sha: merge_request.diff_head_sha
|
|
|
|
)
|
|
|
|
end
|
2020-08-11 03:11:00 +00:00
|
|
|
|
2017-05-08 13:31:11 +00:00
|
|
|
let(:path) { "files/ruby/popen.rb" }
|
|
|
|
let(:position) do
|
2020-02-17 18:09:00 +00:00
|
|
|
build(:text_diff_position, :added,
|
|
|
|
file: path,
|
2017-05-08 13:31:11 +00:00
|
|
|
new_line: 14,
|
|
|
|
diff_refs: merge_request.diff_refs
|
|
|
|
)
|
|
|
|
end
|
2017-02-12 22:49:29 +00:00
|
|
|
|
|
|
|
render_views
|
|
|
|
|
2017-08-10 22:31:42 +00:00
|
|
|
before do
|
2020-12-07 12:10:00 +00:00
|
|
|
sign_in(user)
|
2019-02-21 16:55:01 +00:00
|
|
|
allow(Discussion).to receive(:build_discussion_id).and_return(['discussionid:ceterumcenseo'])
|
2017-02-12 22:49:29 +00:00
|
|
|
end
|
|
|
|
|
2017-08-22 23:19:35 +00:00
|
|
|
after do
|
|
|
|
remove_repository(project)
|
|
|
|
end
|
|
|
|
|
2021-04-21 06:09:28 +00:00
|
|
|
it 'merge_requests/merge_request_with_single_assignee_feature.html' do
|
|
|
|
stub_licensed_features(multiple_merge_request_assignees: false)
|
|
|
|
|
|
|
|
render_merge_request(merge_request)
|
|
|
|
end
|
|
|
|
|
2019-04-21 10:58:07 +00:00
|
|
|
it 'merge_requests/merge_request_of_current_user.html' do
|
2021-04-26 12:09:44 +00:00
|
|
|
merge_request.update!(author: user)
|
2017-09-07 20:25:50 +00:00
|
|
|
|
2019-04-23 10:21:36 +00:00
|
|
|
render_merge_request(merge_request)
|
2017-09-07 20:25:50 +00:00
|
|
|
end
|
|
|
|
|
2019-04-21 10:58:07 +00:00
|
|
|
it 'merge_requests/merge_request_with_task_list.html' do
|
2017-03-23 02:39:09 +00:00
|
|
|
create(:ci_build, :pending, pipeline: pipeline)
|
|
|
|
|
2019-04-23 10:21:36 +00:00
|
|
|
render_merge_request(merge_request)
|
2017-02-12 22:49:29 +00:00
|
|
|
end
|
|
|
|
|
2019-04-21 10:58:07 +00:00
|
|
|
it 'merge_requests/diff_comment.html' do
|
2020-12-07 12:10:00 +00:00
|
|
|
create(:diff_note_on_merge_request, project: project, author: user, position: position, noteable: merge_request)
|
|
|
|
create(:note_on_merge_request, author: user, project: project, noteable: merge_request)
|
2019-04-23 10:21:36 +00:00
|
|
|
render_merge_request(merge_request)
|
2017-05-08 13:31:11 +00:00
|
|
|
end
|
|
|
|
|
2019-04-21 10:58:07 +00:00
|
|
|
it 'merge_requests/diff_discussion.json' do
|
2020-12-07 12:10:00 +00:00
|
|
|
create(:diff_note_on_merge_request, project: project, author: user, position: position, noteable: merge_request)
|
2019-04-23 10:21:36 +00:00
|
|
|
render_discussions_json(merge_request)
|
2018-02-28 00:10:43 +00:00
|
|
|
end
|
|
|
|
|
2019-04-21 10:58:07 +00:00
|
|
|
it 'merge_requests/resolved_diff_discussion.json' do
|
2020-12-07 12:10:00 +00:00
|
|
|
note = create(:discussion_note_on_merge_request, :resolved, project: project, author: user, position: position, noteable: merge_request)
|
|
|
|
create(:system_note, project: project, author: user, noteable: merge_request, discussion_id: note.discussion.id)
|
2018-07-05 22:10:38 +00:00
|
|
|
|
2019-04-23 10:21:36 +00:00
|
|
|
render_discussions_json(merge_request)
|
2018-07-05 22:10:38 +00:00
|
|
|
end
|
|
|
|
|
2018-02-28 00:10:43 +00:00
|
|
|
context 'with image diff' do
|
|
|
|
let(:merge_request2) { create(:merge_request_with_diffs, :with_image_diffs, source_project: project, title: "Added images") }
|
|
|
|
let(:image_path) { "files/images/ee_repo_logo.png" }
|
|
|
|
let(:image_position) do
|
2020-02-17 18:09:00 +00:00
|
|
|
build(:image_diff_position,
|
|
|
|
file: image_path,
|
2018-02-28 00:10:43 +00:00
|
|
|
diff_refs: merge_request2.diff_refs
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2019-04-21 10:58:07 +00:00
|
|
|
it 'merge_requests/image_diff_discussion.json' do
|
2018-02-28 00:10:43 +00:00
|
|
|
create(:diff_note_on_merge_request, project: project, noteable: merge_request2, position: image_position)
|
2019-04-23 10:21:36 +00:00
|
|
|
render_discussions_json(merge_request2)
|
2018-02-28 00:10:43 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-02-17 21:09:20 +00:00
|
|
|
context 'with mentions' do
|
|
|
|
let(:group) { create(:group) }
|
2020-12-07 12:10:00 +00:00
|
|
|
let(:description) { "@#{group.full_path} @all @#{user.username}" }
|
2020-02-17 21:09:20 +00:00
|
|
|
|
|
|
|
it 'merge_requests/merge_request_with_mentions.html' do
|
|
|
|
render_merge_request(merge_request)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-02-12 22:49:29 +00:00
|
|
|
private
|
|
|
|
|
2019-04-23 10:21:36 +00:00
|
|
|
def render_discussions_json(merge_request)
|
2018-12-19 19:50:20 +00:00
|
|
|
get :discussions, params: {
|
2018-02-28 00:10:43 +00:00
|
|
|
namespace_id: project.namespace.to_param,
|
|
|
|
project_id: project,
|
2018-12-19 19:50:20 +00:00
|
|
|
id: merge_request.to_param
|
|
|
|
}, format: :json
|
2018-02-28 00:10:43 +00:00
|
|
|
end
|
|
|
|
|
2019-04-23 10:21:36 +00:00
|
|
|
def render_merge_request(merge_request)
|
2018-12-19 19:50:20 +00:00
|
|
|
get :show, params: {
|
2017-02-12 22:49:29 +00:00
|
|
|
namespace_id: project.namespace.to_param,
|
2017-02-23 23:55:01 +00:00
|
|
|
project_id: project,
|
2018-12-19 19:50:20 +00:00
|
|
|
id: merge_request.to_param
|
|
|
|
}, format: :html
|
2017-02-12 22:49:29 +00:00
|
|
|
|
2019-07-17 22:15:53 +00:00
|
|
|
expect(response).to be_successful
|
2017-02-12 22:49:29 +00:00
|
|
|
end
|
|
|
|
end
|