diff options
Diffstat (limited to 'spec/migrations/add_repository_storages_weighted_to_application_settings_spec.rb')
-rw-r--r-- | spec/migrations/add_repository_storages_weighted_to_application_settings_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/migrations/add_repository_storages_weighted_to_application_settings_spec.rb b/spec/migrations/add_repository_storages_weighted_to_application_settings_spec.rb new file mode 100644 index 00000000000..6c6c63d8614 --- /dev/null +++ b/spec/migrations/add_repository_storages_weighted_to_application_settings_spec.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +require 'spec_helper' +require Rails.root.join('db', 'migrate', '20200508203901_add_repository_storages_weighted_to_application_settings.rb') + +RSpec.describe AddRepositoryStoragesWeightedToApplicationSettings, :migration do + let(:storages) { { "foo" => {}, "baz" => {} } } + let(:application_settings) do + table(:application_settings).tap do |klass| + klass.class_eval do + serialize :repository_storages + end + end + end + + before do + allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) + end + + let(:application_setting) { application_settings.create! } + let(:repository_storages) { ["foo"] } + + it 'populates repository_storages_weighted properly' do + application_setting.repository_storages = repository_storages + application_setting.save! + + migrate! + + expect(application_settings.find(application_setting.id).repository_storages_weighted).to eq({ "foo" => 100, "baz" => 0 }) + end +end |