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
end
end
describe '.storage_weights' do
describe '#storage_weights' do
let(:application_setting) { build(:application_setting) }
before do
......@@ -158,12 +158,13 @@ RSpec.describe ApplicationSettingsHelper do
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(OpenStruct.new(
default: 100,
storage_1: 50,
storage_2: 0
))
it 'returns storage objects with assigned weights' do
expect(helper.storage_weights)
.to have_attributes(
default: 100,
storage_1: 50,
storage_2: 0
)
end
end
......
......@@ -10,42 +10,32 @@ RSpec.describe 'admin/application_settings/_repository_storage.html.haml' do
assign(:application_setting, app_settings)
end
context 'additional storage config' do
context 'with storage weights configured' do
let(:repository_storages_weighted) do
{
'default' => 100,
'mepmep' => 50
'mepmep' => 50,
'something_old' => 100
}
end
it 'lists them all' do
it 'lists storages with weight', :aggregate_failures do
render
Gitlab.config.repositories.storages.keys.each do |storage_name|
expect(rendered).to have_content(storage_name)
end
expect(rendered).to have_content('foobar')
expect(rendered).to have_field('default', with: 100)
expect(rendered).to have_field('mepmep', with: 50)
end
end
context 'fewer storage configs' do
let(:repository_storages_weighted) do
{
'default' => 100,
'mepmep' => 50,
'something_old' => 100
}
it 'lists storages without weight' do
render
expect(rendered).to have_field('foobar', with: 0)
end
it 'lists only configured storages' do
render
Gitlab.config.repositories.storages.keys.each do |storage_name|
expect(rendered).to have_content(storage_name)
end
expect(rendered).not_to have_content('something_old')
expect(rendered).not_to have_field('something_old')
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