blob: 928f14aacedb51d94b359dece097e078918cf37e (
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
require 'spec_helper'
RSpec.describe BulkImports::Failure, type: :model, feature_category: :importers do
let(:failure) { create(:bulk_import_failure) }
describe 'associations' do
it { is_expected.to belong_to(:entity).required }
end
describe 'validations' do
it { is_expected.to validate_presence_of(:entity) }
end
describe '#relation' do
context 'when pipeline class is valid' do
it 'returns pipeline defined relation' do
failure.update!(pipeline_class: 'BulkImports::Common::Pipelines::WikiPipeline')
expect(failure.relation).to eq('wiki')
end
end
context 'when pipeline class is invalid' do
it 'returns default relation' do
failure.update!(pipeline_class: 'foobar')
expect(failure.relation).to eq('foobar')
end
context 'when pipeline class is outside of BulkImports namespace' do
it 'returns default relation' do
failure.update!(pipeline_class: 'Gitlab::ImportExport::Importer')
expect(failure.relation).to eq('importer')
end
end
it 'returns demodulized, underscored, chomped string' do
failure.update!(pipeline_class: 'BulkImports::Pipelines::Test::TestRelationPipeline')
expect(failure.relation).to eq('test_relation')
end
end
end
describe '#exception_message=' do
it 'filters file paths' do
failure = described_class.new
failure.exception_message = 'Failed to read /FILE/PATH'
expect(failure.exception_message).to eq('Failed to read [FILTERED]')
end
it 'truncates long string' do
failure = described_class.new
failure.exception_message = 'A' * 1000
expect(failure.exception_message.size).to eq(255)
end
end
end
|