diff options
Diffstat (limited to 'spec/views')
-rw-r--r-- | spec/views/admin/application_settings/general.html.haml_spec.rb | 27 | ||||
-rw-r--r-- | spec/views/admin/dashboard/index.html.haml_spec.rb | 29 | ||||
-rw-r--r-- | spec/views/devise/shared/_signup_box.html.haml_spec.rb | 16 | ||||
-rw-r--r-- | spec/views/groups/settings/_transfer.html.haml_spec.rb | 17 | ||||
-rw-r--r-- | spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb | 18 | ||||
-rw-r--r-- | spec/views/profiles/keys/_key.html.haml_spec.rb | 4 | ||||
-rw-r--r-- | spec/views/projects/edit.html.haml_spec.rb | 34 | ||||
-rw-r--r-- | spec/views/projects/services/_form.haml_spec.rb | 52 | ||||
-rw-r--r-- | spec/views/shared/_gl_toggle.haml_spec.rb | 85 | ||||
-rw-r--r-- | spec/views/shared/_global_alert.html.haml_spec.rb | 10 | ||||
-rw-r--r-- | spec/views/shared/issuable/_sidebar.html.haml_spec.rb | 39 |
11 files changed, 240 insertions, 91 deletions
diff --git a/spec/views/admin/application_settings/general.html.haml_spec.rb b/spec/views/admin/application_settings/general.html.haml_spec.rb index 434ca8bf0e7..7d28175d134 100644 --- a/spec/views/admin/application_settings/general.html.haml_spec.rb +++ b/spec/views/admin/application_settings/general.html.haml_spec.rb @@ -33,4 +33,31 @@ RSpec.describe 'admin/application_settings/general.html.haml' do end end end + + describe 'prompt user about registration features' do + before do + assign(:application_setting, app_settings) + allow(view).to receive(:current_user).and_return(user) + end + + context 'when service ping is enabled' do + before do + stub_application_setting(usage_ping_enabled: true) + end + + it_behaves_like 'does not render registration features prompt', :application_setting_disabled_repository_size_limit + end + + context 'with no license and service ping disabled' do + before do + stub_application_setting(usage_ping_enabled: false) + + if Gitlab.ee? + allow(License).to receive(:current).and_return(nil) + end + end + + it_behaves_like 'renders registration features prompt', :application_setting_disabled_repository_size_limit + end + end end diff --git a/spec/views/admin/dashboard/index.html.haml_spec.rb b/spec/views/admin/dashboard/index.html.haml_spec.rb index 9db2bd3741a..9f1ff960444 100644 --- a/spec/views/admin/dashboard/index.html.haml_spec.rb +++ b/spec/views/admin/dashboard/index.html.haml_spec.rb @@ -63,4 +63,33 @@ RSpec.describe 'admin/dashboard/index.html.haml' do expect(rendered).to have_selector('.js-gitlab-version-check') end end + + describe 'GitLab KAS' do + before do + allow(Gitlab::Kas).to receive(:enabled?).and_return(enabled) + allow(Gitlab::Kas).to receive(:version).and_return('kas-1.2.3') + end + + context 'KAS enabled' do + let(:enabled) { true } + + it 'includes KAS version' do + render + + expect(rendered).to have_content('GitLab KAS') + expect(rendered).to have_content('kas-1.2.3') + end + end + + context 'KAS disabled' do + let(:enabled) { false } + + it 'does not include KAS version' do + render + + expect(rendered).not_to have_content('GitLab KAS') + expect(rendered).not_to have_content('kas-1.2.3') + end + end + end end diff --git a/spec/views/devise/shared/_signup_box.html.haml_spec.rb b/spec/views/devise/shared/_signup_box.html.haml_spec.rb index 6efb2730964..37dbfd39f2d 100644 --- a/spec/views/devise/shared/_signup_box.html.haml_spec.rb +++ b/spec/views/devise/shared/_signup_box.html.haml_spec.rb @@ -63,6 +63,22 @@ RSpec.describe 'devise/shared/_signup_box' do end end + context 'using the borderless option' do + let(:border_css_classes) { '.gl-border-gray-100.gl-border-1.gl-border-solid.gl-rounded-base' } + + it 'renders with a border by default' do + render + + expect(rendered).to have_selector(border_css_classes) + end + + it 'renders without a border when borderless is truthy' do + render('devise/shared/signup_box', borderless: true) + + expect(rendered).not_to have_selector(border_css_classes) + end + end + def stub_devise allow(view).to receive(:devise_mapping).and_return(Devise.mappings[:user]) allow(view).to receive(:resource).and_return(spy) diff --git a/spec/views/groups/settings/_transfer.html.haml_spec.rb b/spec/views/groups/settings/_transfer.html.haml_spec.rb deleted file mode 100644 index 911eb5b7ab3..00000000000 --- a/spec/views/groups/settings/_transfer.html.haml_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'groups/settings/_transfer.html.haml' do - describe 'render' do - it 'enables the Select parent group dropdown and does not show an alert for a group' do - group = build(:group) - - render 'groups/settings/transfer', group: group - - expect(rendered).to have_button 'Select parent group' - expect(rendered).not_to have_button 'Select parent group', disabled: true - expect(rendered).not_to have_text "This group can't be transfered because it is linked to a subscription." - end - end -end diff --git a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb index f7da288b9f3..22e925e22ae 100644 --- a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb +++ b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' RSpec.describe 'layouts/nav/sidebar/_project' do let_it_be_with_reload(:project) { create(:project, :repository) } - let(:user) { project.owner } + let(:user) { project.first_owner } let(:current_ref) { 'master' } before do @@ -286,10 +286,20 @@ RSpec.describe 'layouts/nav/sidebar/_project' do end describe 'Pipeline Editor' do - it 'has a link to the pipeline editor' do - render + context 'with a current_ref' do + it 'has a link to the pipeline editor' do + render + + expect(rendered).to have_link('Editor', href: project_ci_pipeline_editor_path(project, params: { branch_name: current_ref })) + end + end + + context 'with the default_branch' do + it 'has a link to the pipeline editor' do + render - expect(rendered).to have_link('Editor', href: project_ci_pipeline_editor_path(project)) + expect(rendered).to have_link('Editor', href: project_ci_pipeline_editor_path(project, params: { branch_name: project.default_branch })) + end end context 'when user cannot access pipeline editor' do diff --git a/spec/views/profiles/keys/_key.html.haml_spec.rb b/spec/views/profiles/keys/_key.html.haml_spec.rb index bb101198ac3..ed8026d2453 100644 --- a/spec/views/profiles/keys/_key.html.haml_spec.rb +++ b/spec/views/profiles/keys/_key.html.haml_spec.rb @@ -90,8 +90,8 @@ RSpec.describe 'profiles/keys/_key.html.haml' do using RSpec::Parameterized::TableSyntax where(:valid, :expiry, :result) do - false | 2.days.from_now | 'Key type is forbidden. Must be DSA, ECDSA, or ED25519' - false | 2.days.ago | 'Key type is forbidden. Must be DSA, ECDSA, or ED25519' + false | 2.days.from_now | 'Key type is forbidden. Must be DSA, ECDSA, ED25519, ECDSA_SK, or ED25519_SK' + false | 2.days.ago | 'Key type is forbidden. Must be DSA, ECDSA, ED25519, ECDSA_SK, or ED25519_SK' true | 2.days.ago | 'Key usable beyond expiration date.' true | 2.days.from_now | '' end diff --git a/spec/views/projects/edit.html.haml_spec.rb b/spec/views/projects/edit.html.haml_spec.rb index 11f542767f4..a85ddf7a005 100644 --- a/spec/views/projects/edit.html.haml_spec.rb +++ b/spec/views/projects/edit.html.haml_spec.rb @@ -45,10 +45,10 @@ RSpec.describe 'projects/edit' do end context 'merge commit template' do - it 'displays a placeholder if none is set' do + it 'displays default template if none is set' do render - expect(rendered).to have_field('project[merge_commit_template]', placeholder: <<~MSG.rstrip) + expect(rendered).to have_field('project[merge_commit_template_or_default]', with: <<~MSG.rstrip) Merge branch '%{source_branch}' into '%{target_branch}' %{title} @@ -64,15 +64,15 @@ RSpec.describe 'projects/edit' do render - expect(rendered).to have_field('project[merge_commit_template]', with: '%{title}') + expect(rendered).to have_field('project[merge_commit_template_or_default]', with: '%{title}') end end context 'squash template' do - it 'displays a placeholder if none is set' do + it 'displays default template if none is set' do render - expect(rendered).to have_field('project[squash_commit_template]', placeholder: '%{title}') + expect(rendered).to have_field('project[squash_commit_template_or_default]', with: '%{title}') end it 'displays the user entered value' do @@ -80,7 +80,7 @@ RSpec.describe 'projects/edit' do render - expect(rendered).to have_field('project[squash_commit_template]', with: '%{first_multiline_commit}') + expect(rendered).to have_field('project[squash_commit_template_or_default]', with: '%{first_multiline_commit}') end end @@ -139,4 +139,26 @@ RSpec.describe 'projects/edit' do end end end + + describe 'prompt user about registration features' do + context 'when service ping is enabled' do + before do + stub_application_setting(usage_ping_enabled: true) + end + + it_behaves_like 'does not render registration features prompt', :project_disabled_repository_size_limit + end + + context 'with no license and service ping disabled' do + before do + stub_application_setting(usage_ping_enabled: false) + + if Gitlab.ee? + allow(License).to receive(:current).and_return(nil) + end + end + + it_behaves_like 'renders registration features prompt', :project_disabled_repository_size_limit + end + end end diff --git a/spec/views/projects/services/_form.haml_spec.rb b/spec/views/projects/services/_form.haml_spec.rb deleted file mode 100644 index f212fd78b1a..00000000000 --- a/spec/views/projects/services/_form.haml_spec.rb +++ /dev/null @@ -1,52 +0,0 @@ -# frozen_string_literal: true - -require 'spec_helper' - -RSpec.describe 'projects/services/_form' do - let(:project) { create(:redmine_project) } - let(:user) { create(:admin) } - - before do - assign(:project, project) - - allow(controller).to receive(:current_user).and_return(user) - - allow(view).to receive_messages( - current_user: user, - can?: true, - current_application_settings: Gitlab::CurrentSettings.current_application_settings, - integration: project.redmine_integration, - request: double(referer: '/services') - ) - end - - context 'integrations form' do - it 'does not render form element' do - render - - expect(rendered).not_to have_selector('[data-testid="integration-form"]') - end - - context 'when vue_integration_form feature flag is disabled' do - before do - stub_feature_flags(vue_integration_form: false) - end - - it 'renders form element' do - render - - expect(rendered).to have_selector('[data-testid="integration-form"]') - end - - context 'commit_events and merge_request_events' do - it 'display merge_request_events and commit_events descriptions' do - allow(Integrations::Redmine).to receive(:supported_events).and_return(%w(commit merge_request)) - - render - - expect(rendered).to have_css("input[name='redirect_to'][value='/services']", count: 1, visible: false) - end - end - end - end -end diff --git a/spec/views/shared/_gl_toggle.haml_spec.rb b/spec/views/shared/_gl_toggle.haml_spec.rb new file mode 100644 index 00000000000..3ac1ef30c84 --- /dev/null +++ b/spec/views/shared/_gl_toggle.haml_spec.rb @@ -0,0 +1,85 @@ +# frozen_string_literal: true +require 'spec_helper' + +RSpec.describe 'shared/_gl_toggle.html.haml' do + context 'defaults' do + before do + render partial: 'shared/gl_toggle', locals: { + classes: '.js-gl-toggle' + } + end + + it 'does not set a name' do + expect(rendered).not_to have_selector('[data-name]') + end + + it 'sets default is-checked attributes' do + expect(rendered).to have_selector('[data-is-checked="false"]') + end + + it 'sets default disabled attributes' do + expect(rendered).to have_selector('[data-disabled="false"]') + end + + it 'sets default is-loading attributes' do + expect(rendered).to have_selector('[data-is-loading="false"]') + end + + it 'does not set a label' do + expect(rendered).not_to have_selector('[data-label]') + end + + it 'does not set a label position' do + expect(rendered).not_to have_selector('[data-label-position]') + end + end + + context 'with custom options' do + before do + render partial: 'shared/gl_toggle', locals: { + classes: 'js-custom-gl-toggle', + name: 'toggle-name', + is_checked: true, + disabled: true, + is_loading: true, + label: 'Custom label', + label_position: 'top', + data: { + foo: 'bar' + } + } + end + + it 'sets the custom class' do + expect(rendered).to have_selector('.js-custom-gl-toggle') + end + + it 'sets the custom name' do + expect(rendered).to have_selector('[data-name="toggle-name"]') + end + + it 'sets the custom is-checked attributes' do + expect(rendered).to have_selector('[data-is-checked="true"]') + end + + it 'sets the custom disabled attributes' do + expect(rendered).to have_selector('[data-disabled="true"]') + end + + it 'sets the custom is-loading attributes' do + expect(rendered).to have_selector('[data-is-loading="true"]') + end + + it 'sets the custom label' do + expect(rendered).to have_selector('[data-label="Custom label"]') + end + + it 'sets the cutom label position' do + expect(rendered).to have_selector('[data-label-position="top"]') + end + + it 'sets cutom data attributes' do + expect(rendered).to have_selector('[data-foo="bar"]') + end + end +end diff --git a/spec/views/shared/_global_alert.html.haml_spec.rb b/spec/views/shared/_global_alert.html.haml_spec.rb index 7eec068645a..84198cbb75e 100644 --- a/spec/views/shared/_global_alert.html.haml_spec.rb +++ b/spec/views/shared/_global_alert.html.haml_spec.rb @@ -49,12 +49,6 @@ RSpec.describe 'shared/_global_alert.html.haml' do allow(view).to receive(:fluid_layout).and_return(false) end - it 'does not add layout limited class' do - render - - expect(rendered).not_to have_selector('.gl-alert-layout-limited') - end - it 'adds container classes' do render @@ -74,10 +68,6 @@ RSpec.describe 'shared/_global_alert.html.haml' do render end - it 'adds layout limited class' do - expect(rendered).to have_selector('.gl-alert-layout-limited') - end - it 'does not add container classes' do expect(rendered).not_to have_selector('.container-fluid.container-limited') end diff --git a/spec/views/shared/issuable/_sidebar.html.haml_spec.rb b/spec/views/shared/issuable/_sidebar.html.haml_spec.rb new file mode 100644 index 00000000000..2097b8890cc --- /dev/null +++ b/spec/views/shared/issuable/_sidebar.html.haml_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'shared/issuable/_sidebar.html.haml' do + let_it_be(:user) { create(:user) } + + subject(:rendered) do + render 'shared/issuable/sidebar', issuable_sidebar: IssueSerializer.new(current_user: user) + .represent(issuable, serializer: 'sidebar'), assignees: [] + end + + context 'project in a group' do + let_it_be(:group) { create(:group) } + let_it_be(:project) { create(:project, group: group) } + let_it_be(:issue) { create(:issue, project: project) } + let_it_be(:incident) { create(:incident, project: project) } + + before do + assign(:project, project) + end + + context 'issuable that does not support escalations' do + let(:issuable) { incident } + + it 'shows escalation policy dropdown' do + expect(rendered).to have_css('[data-testid="escalation_status_container"]') + end + end + + context 'issuable that supports escalations' do + let(:issuable) { issue } + + it 'does not show escalation policy dropdown' do + expect(rendered).not_to have_css('[data-testid="escalation_status_container"]') + end + end + end +end |