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