diff options
Diffstat (limited to 'spec/migrations')
-rw-r--r-- | spec/migrations/db/migrate/20230823160533_update_package_metadata_sync_setting_spec.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/spec/migrations/db/migrate/20230823160533_update_package_metadata_sync_setting_spec.rb b/spec/migrations/db/migrate/20230823160533_update_package_metadata_sync_setting_spec.rb new file mode 100644 index 00000000000..0e1f6cd9b69 --- /dev/null +++ b/spec/migrations/db/migrate/20230823160533_update_package_metadata_sync_setting_spec.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +require 'spec_helper' +require_migration! + +RSpec.describe UpdatePackageMetadataSyncSetting, feature_category: :software_composition_analysis do + let(:settings) { table(:application_settings) } + let(:fully_enabled_sync_setting) { [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] } + + describe "#up" do + context 'with default value' do + let(:fully_disabled_sync) { [] } + + it 'updates setting' do + settings.create!(package_metadata_purl_types: fully_disabled_sync) + + migrate! + + expect(ApplicationSetting.last.package_metadata_purl_types).to eq(fully_enabled_sync_setting) + end + end + + context 'with custom value' do + let(:partially_enabled_sync) { [1, 2, 3, 4, 5] } + + it 'does not change setting' do + settings.create!(package_metadata_purl_types: partially_enabled_sync) + + migrate! + + expect(ApplicationSetting.last.package_metadata_purl_types).to eq(partially_enabled_sync) + end + end + end +end |