blob: 33c3ebc506f5403b94f1a1df6d529e3b508b83f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe DiscussionDiffFileEntity do
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
expect(subject).not_to include(:highlighted_diff_lines, :parallel_diff_lines)
end
end
end
|