diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 13:00:54 +0300 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/views | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/views')
14 files changed, 197 insertions, 200 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 diff --git a/spec/views/dashboard/milestones/index.html.haml_spec.rb b/spec/views/dashboard/milestones/index.html.haml_spec.rb new file mode 100644 index 00000000000..738d31bfa3f --- /dev/null +++ b/spec/views/dashboard/milestones/index.html.haml_spec.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'dashboard/milestones/index.html.haml' do + it_behaves_like 'milestone empty states' +end diff --git a/spec/views/groups/milestones/index.html.haml_spec.rb b/spec/views/groups/milestones/index.html.haml_spec.rb new file mode 100644 index 00000000000..40f175ebdc3 --- /dev/null +++ b/spec/views/groups/milestones/index.html.haml_spec.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'groups/milestones/index.html.haml' do + it_behaves_like 'milestone empty states' +end diff --git a/spec/views/groups/runners/_sort_dropdown.html.haml_spec.rb b/spec/views/groups/runners/_sort_dropdown.html.haml_spec.rb index 4b5027a5a56..5438fea85ee 100644 --- a/spec/views/groups/runners/_sort_dropdown.html.haml_spec.rb +++ b/spec/views/groups/runners/_sort_dropdown.html.haml_spec.rb @@ -4,27 +4,22 @@ require 'spec_helper' RSpec.describe 'groups/runners/sort_dropdown.html.haml' do describe 'render' do - let_it_be(:sort_options_hash) { { by_title: 'Title' } } - let_it_be(:sort_title_created_date) { 'Created date' } - - before do - allow(view).to receive(:sort).and_return('by_title') - end - describe 'when a sort option is not selected' do it 'renders a default sort option' do - render 'groups/runners/sort_dropdown', sort_options_hash: sort_options_hash, sort_title_created_date: sort_title_created_date + render 'groups/runners/sort_dropdown' - expect(rendered).to have_content 'Created date' + expect(rendered).to have_content _('Created date') end end describe 'when a sort option is selected' do - it 'renders the selected sort option' do - @sort = :by_title - render 'groups/runners/sort_dropdown', sort_options_hash: sort_options_hash, sort_title_created_date: sort_title_created_date + before do + assign(:sort, 'contacted_asc') + render 'groups/runners/sort_dropdown' + end - expect(rendered).to have_content 'Title' + it 'renders the selected sort option' do + expect(rendered).to have_content _('Last Contact') end end end diff --git a/spec/views/groups/show.html.haml_spec.rb b/spec/views/groups/show.html.haml_spec.rb deleted file mode 100644 index 43e11d31611..00000000000 --- a/spec/views/groups/show.html.haml_spec.rb +++ /dev/null @@ -1,118 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'groups/edit.html.haml' do - include Devise::Test::ControllerHelpers - - describe '"Share with group lock" setting' do - let(:root_owner) { create(:user) } - let(:root_group) { create(:group) } - - before do - root_group.add_owner(root_owner) - end - - shared_examples_for '"Share with group lock" setting' do |checkbox_options| - it 'has the correct label, help text, and checkbox options' do - assign(:group, test_group) - allow(view).to receive(:can?).with(test_user, :admin_group, test_group).and_return(true) - allow(view).to receive(:can_change_group_visibility_level?).and_return(false) - allow(view).to receive(:current_user).and_return(test_user) - expect(view).to receive(:can_change_share_with_group_lock?).and_return(!checkbox_options[:disabled]) - expect(view).to receive(:share_with_group_lock_help_text).and_return('help text here') - - render - - expect(rendered).to have_content("Prevent sharing a project within #{test_group.name} with other groups") - expect(rendered).to have_content('help text here') - expect(rendered).to have_field('group_share_with_group_lock', **checkbox_options) - end - end - - context 'for a root group' do - let(:test_group) { root_group } - let(:test_user) { root_owner } - - it_behaves_like '"Share with group lock" setting', { disabled: false, checked: false } - end - - context 'for a subgroup' do - let!(:subgroup) { create(:group, parent: root_group) } - let(:sub_owner) { create(:user) } - let(:test_group) { subgroup } - - context 'when the root_group has "Share with group lock" disabled' do - context 'when the subgroup has "Share with group lock" disabled' do - context 'as the root_owner' do - let(:test_user) { root_owner } - - it_behaves_like '"Share with group lock" setting', { disabled: false, checked: false } - end - - context 'as the sub_owner' do - let(:test_user) { sub_owner } - - it_behaves_like '"Share with group lock" setting', { disabled: false, checked: false } - end - end - - context 'when the subgroup has "Share with group lock" enabled' do - before do - subgroup.update_column(:share_with_group_lock, true) - end - - context 'as the root_owner' do - let(:test_user) { root_owner } - - it_behaves_like '"Share with group lock" setting', { disabled: false, checked: true } - end - - context 'as the sub_owner' do - let(:test_user) { sub_owner } - - it_behaves_like '"Share with group lock" setting', { disabled: false, checked: true } - end - end - end - - context 'when the root_group has "Share with group lock" enabled' do - before do - root_group.update_column(:share_with_group_lock, true) - end - - context 'when the subgroup has "Share with group lock" disabled (parent overridden)' do - context 'as the root_owner' do - let(:test_user) { root_owner } - - it_behaves_like '"Share with group lock" setting', { disabled: false, checked: false } - end - - context 'as the sub_owner' do - let(:test_user) { sub_owner } - - it_behaves_like '"Share with group lock" setting', { disabled: false, checked: false } - end - end - - context 'when the subgroup has "Share with group lock" enabled (same as parent)' do - before do - subgroup.update_column(:share_with_group_lock, true) - end - - context 'as the root_owner' do - let(:test_user) { root_owner } - - it_behaves_like '"Share with group lock" setting', { disabled: false, checked: true } - end - - context 'as the sub_owner' do - let(:test_user) { sub_owner } - - it_behaves_like '"Share with group lock" setting', { disabled: true, checked: true } - end - end - end - end - end -end diff --git a/spec/views/profiles/keys/_form.html.haml_spec.rb b/spec/views/profiles/keys/_form.html.haml_spec.rb index 624d7492aea..ba8394178d9 100644 --- a/spec/views/profiles/keys/_form.html.haml_spec.rb +++ b/spec/views/profiles/keys/_form.html.haml_spec.rb @@ -30,8 +30,8 @@ RSpec.describe 'profiles/keys/_form.html.haml' do end it 'has the title field', :aggregate_failures do - expect(rendered).to have_field('Title', type: 'text', placeholder: 'e.g. My MacBook key') - expect(rendered).to have_text('Give your individual key a title. This will be publicly visible.') + expect(rendered).to have_field('Title', type: 'text', placeholder: 'Example: MacBook key') + expect(rendered).to have_text('Key titles are publicly visible.') end it 'has the expires at field', :aggregate_failures do diff --git a/spec/views/projects/commit/show.html.haml_spec.rb b/spec/views/projects/commit/show.html.haml_spec.rb index e23ffe300c5..59182f6e757 100644 --- a/spec/views/projects/commit/show.html.haml_spec.rb +++ b/spec/views/projects/commit/show.html.haml_spec.rb @@ -25,6 +25,7 @@ RSpec.describe 'projects/commit/show.html.haml' do allow(view).to receive(:can_collaborate_with_project?).and_return(false) allow(view).to receive(:current_ref).and_return(project.repository.root_ref) allow(view).to receive(:diff_btn).and_return('') + allow(view).to receive(:pagination_params).and_return({}) end context 'inline diff view' do diff --git a/spec/views/projects/milestones/index.html.haml_spec.rb b/spec/views/projects/milestones/index.html.haml_spec.rb new file mode 100644 index 00000000000..f8117a71310 --- /dev/null +++ b/spec/views/projects/milestones/index.html.haml_spec.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'projects/milestones/index.html.haml' do + it_behaves_like 'milestone empty states' +end diff --git a/spec/views/projects/pipelines/show.html.haml_spec.rb b/spec/views/projects/pipelines/show.html.haml_spec.rb index fcae587f8c8..7e300fb1e6e 100644 --- a/spec/views/projects/pipelines/show.html.haml_spec.rb +++ b/spec/views/projects/pipelines/show.html.haml_spec.rb @@ -13,6 +13,7 @@ RSpec.describe 'projects/pipelines/show' do before do assign(:project, project) assign(:pipeline, presented_pipeline) + stub_feature_flags(pipeline_tabs_vue: false) end context 'when pipeline has errors' do diff --git a/spec/views/shared/_global_alert.html.haml_spec.rb b/spec/views/shared/_global_alert.html.haml_spec.rb deleted file mode 100644 index a400d5b39b0..00000000000 --- a/spec/views/shared/_global_alert.html.haml_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -# frozen_string_literal: true -require 'spec_helper' - -RSpec.describe 'shared/_global_alert.html.haml' do - before do - allow(view).to receive(:sprite_icon).and_return('<span class="icon"></span>'.html_safe) - end - - it 'renders the title' do - title = "The alert's title" - render partial: 'shared/global_alert', locals: { title: title } - - expect(rendered).to have_text(title) - end - - context 'variants' do - it 'renders an info alert by default' do - render - - expect(rendered).to have_selector(".gl-alert-info") - end - - %w[warning success danger tip].each do |variant| - it "renders a #{variant} variant" do - allow(view).to receive(:variant).and_return(variant) - render partial: 'shared/global_alert', locals: { variant: variant } - - expect(rendered).to have_selector(".gl-alert-#{variant}") - end - end - end - - context 'dismissible option' do - it 'shows the dismiss button by default' do - render - - expect(rendered).to have_selector('.gl-dismiss-btn') - end - - it 'does not show the dismiss button when dismissible is false' do - render partial: 'shared/global_alert', locals: { dismissible: false } - - expect(rendered).not_to have_selector('.gl-dismiss-btn') - end - end -end diff --git a/spec/views/shared/_milestones_sort_dropdown.html.haml_spec.rb b/spec/views/shared/_milestones_sort_dropdown.html.haml_spec.rb new file mode 100644 index 00000000000..2fc286d607a --- /dev/null +++ b/spec/views/shared/_milestones_sort_dropdown.html.haml_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'shared/_milestones_sort_dropdown.html.haml' do + describe 'render' do + describe 'when a sort option is not selected' do + it 'renders a default sort option' do + render 'shared/milestones_sort_dropdown' + + expect(rendered).to have_content 'Due soon' + end + end + + describe 'when a sort option is selected' do + before do + assign(:sort, 'due_date_desc') + + render 'shared/milestones_sort_dropdown' + end + + it 'renders the selected sort option' do + expect(rendered).to have_content 'Due later' + end + end + end +end diff --git a/spec/views/shared/groups/_dropdown.html.haml_spec.rb b/spec/views/shared/groups/_dropdown.html.haml_spec.rb new file mode 100644 index 00000000000..71fa3a30711 --- /dev/null +++ b/spec/views/shared/groups/_dropdown.html.haml_spec.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'shared/groups/_dropdown.html.haml' do + describe 'render' do + describe 'when a sort option is not selected' do + it 'renders a default sort option' do + render 'shared/groups/dropdown' + + expect(rendered).to have_content 'Last created' + end + end + + describe 'when a sort option is selected' do + before do + assign(:sort, 'name_desc') + + render 'shared/groups/dropdown' + end + + it 'renders the selected sort option' do + expect(rendered).to have_content 'Name, descending' + end + end + end +end diff --git a/spec/views/shared/projects/_list.html.haml_spec.rb b/spec/views/shared/projects/_list.html.haml_spec.rb index 037f988257b..5c38bb79ea1 100644 --- a/spec/views/shared/projects/_list.html.haml_spec.rb +++ b/spec/views/shared/projects/_list.html.haml_spec.rb @@ -20,6 +20,18 @@ RSpec.describe 'shared/projects/_list' do expect(rendered).to have_content(project.name) end end + + it "will not show elements a user shouldn't be able to see" do + allow(view).to receive(:can_show_last_commit_in_list?).and_return(false) + allow(view).to receive(:able_to_see_merge_requests?).and_return(false) + allow(view).to receive(:able_to_see_issues?).and_return(false) + + render + + expect(rendered).not_to have_css('a.commit-row-message') + expect(rendered).not_to have_css('a.issues') + expect(rendered).not_to have_css('a.merge-requests') + end end context 'without projects' do |