debian-mirror-gitlab/spec/lib/gitlab/github_import/settings_spec.rb

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

96 lines
2.9 KiB
Ruby
Raw Normal View History

2022-11-25 23:54:43 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Gitlab::GithubImport::Settings do
subject(:settings) { described_class.new(project) }
let_it_be(:project) { create(:project) }
let(:optional_stages) do
{
single_endpoint_issue_events_import: true,
single_endpoint_notes_import: false,
2023-07-09 08:55:56 +05:30
attachments_import: false,
collaborators_import: false
2022-11-25 23:54:43 +05:30
}
end
describe '.stages_array' do
let(:expected_list) do
stages = described_class::OPTIONAL_STAGES
[
{
name: 'single_endpoint_issue_events_import',
label: stages[:single_endpoint_issue_events_import][:label],
2023-07-09 08:55:56 +05:30
selected: false,
2022-11-25 23:54:43 +05:30
details: stages[:single_endpoint_issue_events_import][:details]
},
{
name: 'single_endpoint_notes_import',
label: stages[:single_endpoint_notes_import][:label],
2023-07-09 08:55:56 +05:30
selected: false,
2022-11-25 23:54:43 +05:30
details: stages[:single_endpoint_notes_import][:details]
},
{
name: 'attachments_import',
label: stages[:attachments_import][:label].strip,
2023-07-09 08:55:56 +05:30
selected: false,
2022-11-25 23:54:43 +05:30
details: stages[:attachments_import][:details]
2023-07-09 08:55:56 +05:30
},
{
name: 'collaborators_import',
label: stages[:collaborators_import][:label].strip,
selected: true,
details: stages[:collaborators_import][:details]
2022-11-25 23:54:43 +05:30
}
]
end
it 'returns stages list as array' do
expect(described_class.stages_array).to match_array(expected_list)
end
end
describe '#write' do
let(:data_input) do
{
single_endpoint_issue_events_import: true,
single_endpoint_notes_import: 'false',
attachments_import: nil,
2023-07-09 08:55:56 +05:30
collaborators_import: false,
2022-11-25 23:54:43 +05:30
foo: :bar
}.stringify_keys
end
it 'puts optional steps flags into projects import_data' do
settings.write(data_input)
expect(project.import_data.data['optional_stages'])
.to eq optional_stages.stringify_keys
end
end
describe '#enabled?' do
it 'returns is enabled or not specific optional stage' do
project.create_or_update_import_data(data: { optional_stages: optional_stages })
expect(settings.enabled?(:single_endpoint_issue_events_import)).to eq true
expect(settings.enabled?(:single_endpoint_notes_import)).to eq false
expect(settings.enabled?(:attachments_import)).to eq false
2023-07-09 08:55:56 +05:30
expect(settings.enabled?(:collaborators_import)).to eq false
2022-11-25 23:54:43 +05:30
end
end
describe '#disabled?' do
it 'returns is disabled or not specific optional stage' do
project.create_or_update_import_data(data: { optional_stages: optional_stages })
expect(settings.disabled?(:single_endpoint_issue_events_import)).to eq false
expect(settings.disabled?(:single_endpoint_notes_import)).to eq true
expect(settings.disabled?(:attachments_import)).to eq true
2023-07-09 08:55:56 +05:30
expect(settings.disabled?(:collaborators_import)).to eq true
2022-11-25 23:54:43 +05:30
end
end
end