2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe Projects::MergeRequests::DiffsController, '(JavaScript fixtures)', type: :controller do
|
2017-09-10 17:25:29 +05:30
|
|
|
include JavaScriptFixturesHelpers
|
|
|
|
|
|
|
|
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
|
|
|
|
let(:project) { create(:project, :repository, namespace: namespace, path: 'merge-requests-project') }
|
2022-04-04 11:22:00 +05:30
|
|
|
let(:user) { project.first_owner }
|
2021-03-11 19:13:27 +05:30
|
|
|
let(:merge_request) { create(:merge_request, source_project: project, target_project: project, description: '- [ ] Task List Item') }
|
2017-09-10 17:25:29 +05:30
|
|
|
let(:path) { "files/ruby/popen.rb" }
|
|
|
|
let(:position) do
|
2020-03-13 15:44:24 +05:30
|
|
|
build(:text_diff_position, :added,
|
|
|
|
file: path,
|
2017-09-10 17:25:29 +05:30
|
|
|
new_line: 14,
|
|
|
|
diff_refs: merge_request.diff_refs
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
render_views
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
before do
|
2021-04-29 21:17:54 +05:30
|
|
|
# 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)
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
sign_in(user)
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
after do
|
|
|
|
remove_repository(project)
|
|
|
|
end
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
it 'merge_request_diffs/with_commit.json' do
|
2020-04-22 19:07:51 +05:30
|
|
|
render_merge_request(merge_request, commit_id: project.commit.sha)
|
2018-12-05 23:21:45 +05:30
|
|
|
end
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
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-09-10 17:25:29 +05:30
|
|
|
private
|
|
|
|
|
2021-04-29 21:17:54 +05:30
|
|
|
def render_merge_request(merge_request, action: :show, view: 'inline', **extra_params)
|
|
|
|
get action, params: {
|
2017-09-10 17:25:29 +05:30
|
|
|
namespace_id: project.namespace.to_param,
|
|
|
|
project_id: project,
|
|
|
|
id: merge_request.to_param,
|
2018-12-05 23:21:45 +05:30
|
|
|
view: view,
|
|
|
|
**extra_params
|
2019-02-15 15:39:39 +05:30
|
|
|
}, format: :json
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2019-10-12 21:52:04 +05:30
|
|
|
expect(response).to be_successful
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|