diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-25 00:08:11 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-25 00:08:11 +0000 |
commit | 23bc19cb73aad969c9636b8b935111645e809e54 (patch) | |
tree | 887c9e014f8345f577769db4f75315ca59853b98 /spec/support/shared_examples | |
parent | c4db541c1b2c97ab1eda354ea3899489fe5c33e5 (diff) | |
download | gitlab-ce-23bc19cb73aad969c9636b8b935111645e809e54.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/shared_examples')
-rw-r--r-- | spec/support/shared_examples/models/concerns/has_repository_shared_examples.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/support/shared_examples/models/concerns/has_repository_shared_examples.rb b/spec/support/shared_examples/models/concerns/has_repository_shared_examples.rb index d5606e65981..5a5d7c8f038 100644 --- a/spec/support/shared_examples/models/concerns/has_repository_shared_examples.rb +++ b/spec/support/shared_examples/models/concerns/has_repository_shared_examples.rb @@ -168,4 +168,37 @@ RSpec.shared_examples 'model with repository' do it { is_expected.to respond_to(:base_dir) } it { is_expected.to respond_to(:disk_path) } end + + describe '.pick_repository_storage' do + subject { described_class.pick_repository_storage } + + before do + storages = { + 'default' => Gitlab::GitalyClient::StorageSettings.new('path' => 'tmp/tests/repositories'), + 'picked' => Gitlab::GitalyClient::StorageSettings.new('path' => 'tmp/tests/repositories') + } + allow(Gitlab.config.repositories).to receive(:storages).and_return(storages) + end + + it 'picks storage from ApplicationSetting' do + expect_next_instance_of(ApplicationSetting) do |instance| + expect(instance).to receive(:pick_repository_storage).and_return('picked') + end + + expect(subject).to eq('picked') + end + + it 'picks from the latest available storage', :request_store do + stub_env('IN_MEMORY_APPLICATION_SETTINGS', 'false') + Gitlab::CurrentSettings.current_application_settings + + settings = ApplicationSetting.last + settings.repository_storages = %w(picked) + settings.save! + + expect(Gitlab::CurrentSettings.repository_storages).to eq(%w(default)) + expect(subject).to eq('picked') + expect(Gitlab::CurrentSettings.repository_storages).to eq(%w(picked)) + end + end end |