debian-mirror-gitlab/spec/lib/bulk_imports/pipeline/context_spec.rb

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

78 lines
2 KiB
Ruby
Raw Permalink Normal View History

2021-01-29 00:20:46 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe BulkImports::Pipeline::Context do
2021-04-29 21:17:54 +05:30
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:bulk_import) { create(:bulk_import, user: user) }
2021-09-04 01:27:46 +05:30
let_it_be(:project) { create(:project) }
let_it_be(:project_entity) { create(:bulk_import_entity, :project_entity, project: project) }
let_it_be(:project_tracker) { create(:bulk_import_tracker, entity: project_entity) }
2021-04-29 21:17:54 +05:30
let_it_be(:entity) do
create(
:bulk_import_entity,
source_full_path: 'source/full/path',
2023-04-23 21:23:45 +05:30
destination_slug: 'My-Destination-Group',
2021-04-29 21:17:54 +05:30
destination_namespace: group.full_path,
group: group,
bulk_import: bulk_import
)
end
let_it_be(:tracker) do
create(
:bulk_import_tracker,
entity: entity,
pipeline_name: described_class.name
2021-03-11 19:13:27 +05:30
)
end
2021-04-29 21:17:54 +05:30
subject { described_class.new(tracker, extra: :data) }
describe '#entity' do
it { expect(subject.entity).to eq(entity) }
end
2021-01-29 00:20:46 +05:30
2021-03-11 19:13:27 +05:30
describe '#group' do
it { expect(subject.group).to eq(group) }
end
2021-04-29 21:17:54 +05:30
describe '#bulk_import' do
it { expect(subject.bulk_import).to eq(bulk_import) }
end
2021-03-11 19:13:27 +05:30
describe '#current_user' do
it { expect(subject.current_user).to eq(user) }
end
2021-01-29 00:20:46 +05:30
2021-04-29 21:17:54 +05:30
describe '#configuration' do
2021-03-11 19:13:27 +05:30
it { expect(subject.configuration).to eq(bulk_import.configuration) }
2021-01-29 00:20:46 +05:30
end
2021-04-29 21:17:54 +05:30
describe '#extra' do
it { expect(subject.extra).to eq(extra: :data) }
end
2021-09-04 01:27:46 +05:30
describe '#portable' do
it { expect(subject.portable).to eq(group) }
context 'when portable is project' do
subject { described_class.new(project_tracker) }
it { expect(subject.portable).to eq(project) }
end
end
describe '#import_export_config' do
it { expect(subject.import_export_config).to be_instance_of(BulkImports::FileTransfer::GroupConfig) }
context 'when portable is project' do
subject { described_class.new(project_tracker) }
it { expect(subject.import_export_config).to be_instance_of(BulkImports::FileTransfer::ProjectConfig) }
end
end
2021-01-29 00:20:46 +05:30
end