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

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

87 lines
2.3 KiB
Ruby
Raw Normal View History

2021-06-08 01:23:25 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-05-27 22:25:52 +05:30
RSpec.describe BulkImports::Export, type: :model, feature_category: :importers do
2021-06-08 01:23:25 +05:30
describe 'associations' do
it { is_expected.to belong_to(:group) }
it { is_expected.to belong_to(:project) }
it { is_expected.to have_one(:upload) }
2023-05-27 22:25:52 +05:30
it { is_expected.to have_many(:batches) }
2021-06-08 01:23:25 +05:30
end
describe 'validations' do
it { is_expected.to validate_presence_of(:relation) }
it { is_expected.to validate_presence_of(:status) }
context 'when not associated with a group or project' do
it 'is invalid' do
export = build(:bulk_import_export, group: nil, project: nil)
expect(export).not_to be_valid
end
end
context 'when associated with a group' do
it 'is valid' do
export = build(:bulk_import_export, group: build(:group), project: nil)
expect(export).to be_valid
end
end
context 'when associated with a project' do
it 'is valid' do
export = build(:bulk_import_export, group: nil, project: build(:project))
expect(export).to be_valid
end
end
context 'when relation is invalid' do
it 'is invalid' do
export = build(:bulk_import_export, relation: 'unsupported')
expect(export).not_to be_valid
expect(export.errors).to include(:relation)
end
end
end
describe '#portable' do
context 'when associated with project' do
it 'returns project' do
export = create(:bulk_import_export, project: create(:project), group: nil)
expect(export.portable).to be_instance_of(Project)
end
end
context 'when associated with group' do
it 'returns group' do
export = create(:bulk_import_export)
expect(export.portable).to be_instance_of(Group)
end
end
end
describe '#config' do
context 'when associated with project' do
it 'returns project config' do
export = create(:bulk_import_export, project: create(:project), group: nil)
expect(export.config).to be_instance_of(BulkImports::FileTransfer::ProjectConfig)
end
end
context 'when associated with group' do
it 'returns group config' do
export = create(:bulk_import_export)
expect(export.config).to be_instance_of(BulkImports::FileTransfer::GroupConfig)
end
end
end
end