2019-10-09 18:06:58 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 15:08:50 +00:00
|
|
|
RSpec.describe 'admin/application_settings/_repository_storage.html.haml' do
|
2020-05-29 18:08:26 +00:00
|
|
|
let(:app_settings) { create(:application_setting) }
|
2020-06-16 12:09:00 +00:00
|
|
|
let(:repository_storages_weighted_attributes) { [:repository_storages_weighted_default, :repository_storages_weighted_mepmep, :repository_storages_weighted_foobar]}
|
2020-05-29 18:08:26 +00:00
|
|
|
let(:repository_storages_weighted) do
|
2019-10-09 18:06:58 +00:00
|
|
|
{
|
2020-06-16 12:09:00 +00:00
|
|
|
"default" => 100,
|
|
|
|
"mepmep" => 50
|
2019-10-09 18:06:58 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
2020-05-29 18:08:26 +00:00
|
|
|
allow(app_settings).to receive(:repository_storages_weighted).and_return(repository_storages_weighted)
|
|
|
|
allow(app_settings).to receive(:repository_storages_weighted_mepmep).and_return(100)
|
|
|
|
allow(app_settings).to receive(:repository_storages_weighted_foobar).and_return(50)
|
2019-10-09 18:06:58 +00:00
|
|
|
assign(:application_setting, app_settings)
|
2020-06-16 12:09:00 +00:00
|
|
|
allow(ApplicationSetting).to receive(:repository_storages_weighted_attributes).and_return(repository_storages_weighted_attributes)
|
2019-10-09 18:06:58 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when multiple storages are available' do
|
|
|
|
it 'lists them all' do
|
|
|
|
render
|
|
|
|
|
2020-06-16 12:09:00 +00:00
|
|
|
# lists storages that are saved with weights
|
2020-05-29 18:08:26 +00:00
|
|
|
repository_storages_weighted.each do |storage_name, storage_weight|
|
2019-10-09 18:06:58 +00:00
|
|
|
expect(rendered).to have_content(storage_name)
|
|
|
|
end
|
2020-06-16 12:09:00 +00:00
|
|
|
|
|
|
|
# lists storage not saved with weight
|
|
|
|
expect(rendered).to have_content('foobar')
|
2019-10-09 18:06:58 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|