diff options
Diffstat (limited to 'spec/helpers/application_settings_helper_spec.rb')
-rw-r--r-- | spec/helpers/application_settings_helper_spec.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/helpers/application_settings_helper_spec.rb b/spec/helpers/application_settings_helper_spec.rb index c2f3e26f97b..3fb754f1090 100644 --- a/spec/helpers/application_settings_helper_spec.rb +++ b/spec/helpers/application_settings_helper_spec.rb @@ -123,4 +123,27 @@ describe ApplicationSettingsHelper do end end end + + describe '.storage_weights' do + let(:application_setting) { build(:application_setting) } + + before do + helper.instance_variable_set(:@application_setting, application_setting) + stub_storage_settings({ 'default': {}, 'storage_1': {}, 'storage_2': {} }) + allow(ApplicationSetting).to receive(:repository_storages_weighted_attributes).and_return( + [:repository_storages_weighted_default, + :repository_storages_weighted_storage_1, + :repository_storages_weighted_storage_2]) + + stub_application_setting(repository_storages_weighted: { 'default' => 100, 'storage_1' => 50, 'storage_2' => nil }) + end + + it 'returns storages correctly' do + expect(helper.storage_weights).to eq([ + { name: :repository_storages_weighted_default, label: 'default', value: 100 }, + { name: :repository_storages_weighted_storage_1, label: 'storage_1', value: 50 }, + { name: :repository_storages_weighted_storage_2, label: 'storage_2', value: 0 } + ]) + end + end end |