summaryrefslogtreecommitdiff
path: root/spec/migrations/add_repository_storages_weighted_to_application_settings_spec.rb
blob: 6c6c63d8614274cc54ed22a77196aaed84b4a662 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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