diff options
Diffstat (limited to 'spec/views/admin')
-rw-r--r-- | spec/views/admin/application_settings/_ci_cd.html.haml_spec.rb | 87 | ||||
-rw-r--r-- | spec/views/admin/application_settings/_repository_storage.html.haml_spec.rb | 32 |
2 files changed, 98 insertions, 21 deletions
diff --git a/spec/views/admin/application_settings/_ci_cd.html.haml_spec.rb b/spec/views/admin/application_settings/_ci_cd.html.haml_spec.rb new file mode 100644 index 00000000000..12593b88009 --- /dev/null +++ b/spec/views/admin/application_settings/_ci_cd.html.haml_spec.rb @@ -0,0 +1,87 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'admin/application_settings/_ci_cd' do + let_it_be(:admin) { create(:admin) } + let_it_be(:application_setting) { build(:application_setting) } + + let_it_be(:limits_attributes) do + { + ci_pipeline_size: 10, + ci_active_jobs: 20, + ci_project_subscriptions: 30, + ci_pipeline_schedules: 40, + ci_needs_size_limit: 50, + ci_registered_group_runners: 60, + ci_registered_project_runners: 70 + } + end + + let_it_be(:default_plan_limits) { create(:plan_limits, :default_plan, **limits_attributes) } + + let(:page) { Capybara::Node::Simple.new(rendered) } + + before do + assign(:application_setting, application_setting) + allow(view).to receive(:current_user) { admin } + allow(view).to receive(:expanded) { true } + end + + subject { render partial: 'admin/application_settings/ci_cd' } + + context 'limits' do + before do + assign(:plans, [default_plan_limits.plan]) + end + + it 'has fields for CI/CD limits', :aggregate_failures do + subject + + expect(rendered).to have_field('Maximum number of jobs in a single pipeline', type: 'number') + expect(page.find_field('Maximum number of jobs in a single pipeline').value).to eq('10') + + expect(rendered).to have_field('Total number of jobs in currently active pipelines', type: 'number') + expect(page.find_field('Total number of jobs in currently active pipelines').value).to eq('20') + + expect(rendered).to have_field('Maximum number of pipeline subscriptions to and from a project', type: 'number') + expect(page.find_field('Maximum number of pipeline subscriptions to and from a project').value).to eq('30') + + expect(rendered).to have_field('Maximum number of pipeline schedules', type: 'number') + expect(page.find_field('Maximum number of pipeline schedules').value).to eq('40') + + expect(rendered).to have_field('Maximum number of DAG dependencies that a job can have', type: 'number') + expect(page.find_field('Maximum number of DAG dependencies that a job can have').value).to eq('50') + + expect(rendered).to have_field('Maximum number of runners registered per group', type: 'number') + expect(page.find_field('Maximum number of runners registered per group').value).to eq('60') + + expect(rendered).to have_field('Maximum number of runners registered per project', type: 'number') + expect(page.find_field('Maximum number of runners registered per project').value).to eq('70') + end + + it 'does not display the plan name when there is only one plan' do + subject + + expect(page).not_to have_selector('a[data-action="plan0"]') + end + end + + context 'with multiple plans' do + let_it_be(:plan) { create(:plan, name: 'Ultimate') } + let_it_be(:ultimate_plan_limits) { create(:plan_limits, plan: plan, **limits_attributes) } + + before do + assign(:plans, [default_plan_limits.plan, ultimate_plan_limits.plan]) + end + + it 'displays the plan name when there is more than one plan' do + subject + + expect(page).to have_content('Default') + expect(page).to have_content('Ultimate') + expect(page).to have_selector('a[data-action="plan0"]') + expect(page).to have_selector('a[data-action="plan1"]') + end + end +end diff --git a/spec/views/admin/application_settings/_repository_storage.html.haml_spec.rb b/spec/views/admin/application_settings/_repository_storage.html.haml_spec.rb index dc8f259eb56..244157a3b14 100644 --- a/spec/views/admin/application_settings/_repository_storage.html.haml_spec.rb +++ b/spec/views/admin/application_settings/_repository_storage.html.haml_spec.rb @@ -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 |