blob: 685272acf5ca770d4d11174ad3cdf71753d36855 (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# frozen_string_literal: true
FactoryBot.define do
factory :diff_position, class: 'Gitlab::Diff::Position' do
skip_create # non-model factories (i.e. without #save)
transient do
file { 'path/to/file' }
# Allow diff to be passed as a single object.
diff_refs do
::Gitlab::Diff::DiffRefs.new(
base_sha: Digest::SHA1.hexdigest(SecureRandom.hex),
head_sha: Digest::SHA1.hexdigest(SecureRandom.hex),
start_sha: Digest::SHA1.hexdigest(SecureRandom.hex)
)
end
end
old_path { file }
new_path { file }
base_sha { diff_refs&.base_sha }
head_sha { diff_refs&.head_sha }
start_sha { diff_refs&.start_sha }
initialize_with { new(attributes) }
trait :moved do
new_path { 'path/to/new.file' }
end
factory :text_diff_position do
position_type { 'text' }
old_line { 10 }
new_line { 10 }
line_range { nil }
trait :added do
old_line { nil }
end
trait :multi_line do
line_range do
{
start_line_code: Gitlab::Git.diff_line_code(file, 10, 10),
end_line_code: Gitlab::Git.diff_line_code(file, 12, 13)
}
end
end
end
factory :image_diff_position do
position_type { 'image' }
x { 1 }
y { 1 }
width { 10 }
height { 10 }
end
end
end
|