2019-10-17 06:07:30 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-13 22:12:31 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Projects::MergeRequests::DiffsController, '(JavaScript fixtures)', type: :controller do
|
|
|
|
include JavaScriptFixturesHelpers
|
|
|
|
|
|
|
|
let(:admin) { create(:admin) }
|
|
|
|
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') }
|
2017-06-13 22:12:31 +00:00
|
|
|
let(:merge_request) { create(:merge_request, :with_diffs, source_project: project, target_project: project, description: '- [ ] Task List Item') }
|
|
|
|
let(:path) { "files/ruby/popen.rb" }
|
2018-09-26 08:28:50 +00:00
|
|
|
let(:selected_commit) { merge_request.all_commits[0] }
|
2017-06-13 22:12:31 +00:00
|
|
|
let(:position) do
|
|
|
|
Gitlab::Diff::Position.new(
|
|
|
|
old_path: path,
|
|
|
|
new_path: path,
|
|
|
|
old_line: nil,
|
|
|
|
new_line: 14,
|
|
|
|
diff_refs: merge_request.diff_refs
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
render_views
|
|
|
|
|
|
|
|
before(:all) do
|
|
|
|
clean_frontend_fixtures('merge_request_diffs/')
|
|
|
|
end
|
|
|
|
|
2017-08-10 22:31:42 +00:00
|
|
|
before do
|
2017-06-13 22:12:31 +00:00
|
|
|
sign_in(admin)
|
|
|
|
end
|
|
|
|
|
2017-08-22 23:19:35 +00:00
|
|
|
after do
|
|
|
|
remove_repository(project)
|
|
|
|
end
|
|
|
|
|
2019-04-21 10:58:07 +00:00
|
|
|
it 'merge_request_diffs/with_commit.json' do
|
2018-09-26 08:28:50 +00:00
|
|
|
# Create a user that matches the selected commit author
|
|
|
|
# This is so that the "author" information will be populated
|
|
|
|
create(:user, email: selected_commit.author_email, name: selected_commit.author_name)
|
|
|
|
|
2019-04-23 10:21:36 +00:00
|
|
|
render_merge_request(merge_request, commit_id: selected_commit.sha)
|
2018-09-26 08:28:50 +00:00
|
|
|
end
|
|
|
|
|
2019-04-21 10:58:07 +00:00
|
|
|
it 'merge_request_diffs/inline_changes_tab_with_comments.json' do
|
2017-06-13 22:12:31 +00:00
|
|
|
create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request)
|
|
|
|
create(:note_on_merge_request, author: admin, project: project, noteable: merge_request)
|
2019-04-23 10:21:36 +00:00
|
|
|
render_merge_request(merge_request)
|
2017-06-13 22:12:31 +00:00
|
|
|
end
|
|
|
|
|
2019-04-21 10:58:07 +00:00
|
|
|
it 'merge_request_diffs/parallel_changes_tab_with_comments.json' do
|
2017-06-13 22:12:31 +00:00
|
|
|
create(:diff_note_on_merge_request, project: project, author: admin, position: position, noteable: merge_request)
|
|
|
|
create(:note_on_merge_request, author: admin, project: project, noteable: merge_request)
|
2019-04-23 10:21:36 +00:00
|
|
|
render_merge_request(merge_request, view: 'parallel')
|
2017-06-13 22:12:31 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2019-04-23 10:21:36 +00:00
|
|
|
def render_merge_request(merge_request, view: 'inline', **extra_params)
|
2018-12-19 19:50:20 +00:00
|
|
|
get :show, params: {
|
2017-06-13 22:12:31 +00:00
|
|
|
namespace_id: project.namespace.to_param,
|
|
|
|
project_id: project,
|
|
|
|
id: merge_request.to_param,
|
2018-09-26 08:28:50 +00:00
|
|
|
view: view,
|
|
|
|
**extra_params
|
2018-12-19 19:50:20 +00:00
|
|
|
}, format: :json
|
2017-06-13 22:12:31 +00:00
|
|
|
|
2019-07-17 22:15:53 +00:00
|
|
|
expect(response).to be_successful
|
2017-06-13 22:12:31 +00:00
|
|
|
end
|
|
|
|
end
|