Commit cb071654 authored by James Fargher's avatar James Fargher

Merge branch 'pl-harden-repository-storage-specs' into 'master'

Harden specs for repositories storage weights.

See merge request gitlab-org/gitlab!84169
parents 3f866ad3 44374fb8
...@@ -149,7 +149,7 @@ RSpec.describe ApplicationSettingsHelper do ...@@ -149,7 +149,7 @@ RSpec.describe ApplicationSettingsHelper do
end end
end end
describe '.storage_weights' do describe '#storage_weights' do
let(:application_setting) { build(:application_setting) } let(:application_setting) { build(:application_setting) }
before do before do
...@@ -158,12 +158,13 @@ RSpec.describe ApplicationSettingsHelper do ...@@ -158,12 +158,13 @@ RSpec.describe ApplicationSettingsHelper do
stub_application_setting(repository_storages_weighted: { 'default' => 100, 'storage_1' => 50, 'storage_2' => nil }) stub_application_setting(repository_storages_weighted: { 'default' => 100, 'storage_1' => 50, 'storage_2' => nil })
end end
it 'returns storages correctly' do it 'returns storage objects with assigned weights' do
expect(helper.storage_weights).to eq(OpenStruct.new( expect(helper.storage_weights)
default: 100, .to have_attributes(
storage_1: 50, default: 100,
storage_2: 0 storage_1: 50,
)) storage_2: 0
)
end end
end end
......
...@@ -10,42 +10,32 @@ RSpec.describe 'admin/application_settings/_repository_storage.html.haml' do ...@@ -10,42 +10,32 @@ RSpec.describe 'admin/application_settings/_repository_storage.html.haml' do
assign(:application_setting, app_settings) assign(:application_setting, app_settings)
end end
context 'additional storage config' do context 'with storage weights configured' do
let(:repository_storages_weighted) do let(:repository_storages_weighted) do
{ {
'default' => 100, 'default' => 100,
'mepmep' => 50 'mepmep' => 50,
'something_old' => 100
} }
end end
it 'lists them all' do it 'lists storages with weight', :aggregate_failures do
render render
Gitlab.config.repositories.storages.keys.each do |storage_name| expect(rendered).to have_field('default', with: 100)
expect(rendered).to have_content(storage_name) expect(rendered).to have_field('mepmep', with: 50)
end
expect(rendered).to have_content('foobar')
end end
end
context 'fewer storage configs' do it 'lists storages without weight' do
let(:repository_storages_weighted) do render
{
'default' => 100, expect(rendered).to have_field('foobar', with: 0)
'mepmep' => 50,
'something_old' => 100
}
end end
it 'lists only configured storages' do it 'lists only configured storages' do
render render
Gitlab.config.repositories.storages.keys.each do |storage_name| expect(rendered).not_to have_field('something_old')
expect(rendered).to have_content(storage_name)
end
expect(rendered).not_to have_content('something_old')
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment