debian-mirror-gitlab/spec/models/bulk_imports/failure_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

48 lines
1.3 KiB
Ruby
Raw Permalink Normal View History

2021-02-22 17:27:13 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe BulkImports::Failure, type: :model do
2022-11-25 23:54:43 +05:30
let(:failure) { create(:bulk_import_failure) }
2021-02-22 17:27:13 +05:30
describe 'associations' do
it { is_expected.to belong_to(:entity).required }
end
describe 'validations' do
2022-11-25 23:54:43 +05:30
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
2021-02-22 17:27:13 +05:30
end
2022-11-25 23:54:43 +05:30
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
2021-02-22 17:27:13 +05:30
end
end