2019-10-17 02:07:30 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-13 18:12:31 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe Projects::MergeRequests::DiffsController, '(JavaScript fixtures)', type: :controller do
|
2017-06-13 18:12:31 -04: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 }
|
2021-02-09 07:09:48 -05:00
|
|
|
let(:merge_request) { create(:merge_request, source_project: project, target_project: project, description: '- [ ] Task List Item') }
|
2017-06-13 18:12:31 -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-06-13 18:12:31 -04:00
|
|
|
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 18:31:42 -04:00
|
|
|
before do
|
2021-04-13 14:11:28 -04:00
|
|
|
# Create a user that matches the project.commit author
|
|
|
|
# This is so that the "author" information will be populated
|
|
|
|
create(:user, email: project.commit.author_email, name: project.commit.author_name)
|
|
|
|
|
2020-12-07 07:10:00 -05:00
|
|
|
sign_in(user)
|
2017-06-13 18:12:31 -04: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_request_diffs/with_commit.json' do
|
2020-04-15 17:09:18 -04:00
|
|
|
render_merge_request(merge_request, commit_id: project.commit.sha)
|
2018-09-26 04:28:50 -04:00
|
|
|
end
|
|
|
|
|
2021-04-13 14:11:28 -04:00
|
|
|
it 'merge_request_diffs/diffs_metadata.json' do
|
|
|
|
render_merge_request(merge_request, action: :diffs_metadata)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'merge_request_diffs/diffs_batch.json' do
|
|
|
|
render_merge_request(merge_request, action: :diffs_batch, page: 1, per_page: 30)
|
|
|
|
end
|
|
|
|
|
2017-06-13 18:12:31 -04:00
|
|
|
private
|
|
|
|
|
2021-04-13 14:11:28 -04:00
|
|
|
def render_merge_request(merge_request, action: :show, view: 'inline', **extra_params)
|
|
|
|
get action, params: {
|
2017-06-13 18:12:31 -04:00
|
|
|
namespace_id: project.namespace.to_param,
|
|
|
|
project_id: project,
|
|
|
|
id: merge_request.to_param,
|
2018-09-26 04:28:50 -04:00
|
|
|
view: view,
|
|
|
|
**extra_params
|
2018-12-19 14:50:20 -05:00
|
|
|
}, format: :json
|
2017-06-13 18:12:31 -04:00
|
|
|
|
2019-07-17 18:15:53 -04:00
|
|
|
expect(response).to be_successful
|
2017-06-13 18:12:31 -04:00
|
|
|
end
|
|
|
|
end
|