2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe DiscussionDiffFileEntity do
|
2019-02-15 15:39:39 +05:30
|
|
|
include RepoHelpers
|
|
|
|
|
|
|
|
let(:project) { create(:project, :repository) }
|
|
|
|
let(:repository) { project.repository }
|
|
|
|
let(:commit) { project.commit(sample_commit.id) }
|
|
|
|
let(:diff_refs) { commit.diff_refs }
|
|
|
|
let(:diff) { commit.raw_diffs.first }
|
|
|
|
let(:diff_file) { Gitlab::Diff::File.new(diff, diff_refs: diff_refs, repository: repository) }
|
|
|
|
let(:entity) { described_class.new(diff_file, request: {}) }
|
|
|
|
|
|
|
|
subject { entity.as_json }
|
|
|
|
|
|
|
|
context 'when there is no merge request' do
|
|
|
|
it_behaves_like 'diff file discussion entity'
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when there is a merge request' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:request) { EntityRequest.new(project: project, current_user: user) }
|
|
|
|
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
|
|
|
|
let(:entity) { described_class.new(diff_file, request: request, merge_request: merge_request) }
|
|
|
|
|
|
|
|
it_behaves_like 'diff file discussion entity'
|
|
|
|
|
|
|
|
it 'exposes additional attributes' do
|
|
|
|
expect(subject).to include(:edit_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'exposes no diff lines' do
|
2023-06-20 00:43:36 +05:30
|
|
|
expect(subject).not_to include(:highlighted_diff_lines, :parallel_diff_lines)
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|