summaryrefslogtreecommitdiff
path: root/spec/views
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 19:00:14 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2023-01-18 19:00:14 +0000
commit05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch)
tree11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /spec/views
parentec73467c23693d0db63a797d10194da9e72a74af (diff)
downloadgitlab-ce-05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2.tar.gz
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'spec/views')
-rw-r--r--spec/views/admin/application_settings/_repository_check.html.haml_spec.rb21
-rw-r--r--spec/views/admin/application_settings/general.html.haml_spec.rb6
-rw-r--r--spec/views/admin/broadcast_messages/index.html.haml_spec.rb52
-rw-r--r--spec/views/admin/dashboard/index.html.haml_spec.rb10
-rw-r--r--spec/views/errors/omniauth_error.html.haml_spec.rb6
-rw-r--r--spec/views/groups/edit.html.haml_spec.rb8
-rw-r--r--spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb18
-rw-r--r--spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb2
-rw-r--r--spec/views/layouts/snippets.html.haml_spec.rb48
-rw-r--r--spec/views/profiles/notifications/show.html.haml_spec.rb25
-rw-r--r--spec/views/profiles/preferences/show.html.haml_spec.rb5
-rw-r--r--spec/views/projects/_files.html.haml_spec.rb73
-rw-r--r--spec/views/projects/commit/show.html.haml_spec.rb7
-rw-r--r--spec/views/projects/edit.html.haml_spec.rb6
-rw-r--r--spec/views/registrations/welcome/show.html.haml_spec.rb4
-rw-r--r--spec/views/search/_results.html.haml_spec.rb9
-rw-r--r--spec/views/search/show.html.haml_spec.rb2
-rw-r--r--spec/views/shared/projects/_list.html.haml_spec.rb2
18 files changed, 118 insertions, 186 deletions
diff --git a/spec/views/admin/application_settings/_repository_check.html.haml_spec.rb b/spec/views/admin/application_settings/_repository_check.html.haml_spec.rb
index dc3459f84ef..011f05eac21 100644
--- a/spec/views/admin/application_settings/_repository_check.html.haml_spec.rb
+++ b/spec/views/admin/application_settings/_repository_check.html.haml_spec.rb
@@ -41,27 +41,6 @@ RSpec.describe 'admin/application_settings/_repository_check.html.haml', feature
expect(rendered).to have_field('Enable automatic repository housekeeping')
expect(rendered).to have_field('Optimize repository period')
-
- # TODO: Remove it along with optimized_housekeeping feature flag
- expect(rendered).not_to have_field('Incremental repack period')
- expect(rendered).not_to have_field('Full repack period')
- expect(rendered).not_to have_field('Git GC period')
- end
-
- context 'when optimized_housekeeping is disabled' do
- before do
- stub_feature_flags(optimized_housekeeping: false)
- end
-
- it 'renders the correct setting subsection content' do
- render
-
- expect(rendered).to have_field('Enable automatic repository housekeeping')
- expect(rendered).to have_field('Incremental repack period')
- expect(rendered).to have_field('Full repack period')
- expect(rendered).to have_field('Git GC period')
- expect(rendered).not_to have_field('Optimize repository period')
- end
end
end
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 f229fd2dcdc..dd49de8f880 100644
--- a/spec/views/admin/application_settings/general.html.haml_spec.rb
+++ b/spec/views/admin/application_settings/general.html.haml_spec.rb
@@ -46,13 +46,9 @@ RSpec.describe 'admin/application_settings/general.html.haml' do
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
+ context 'with no license and service ping disabled', :without_license 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
diff --git a/spec/views/admin/broadcast_messages/index.html.haml_spec.rb b/spec/views/admin/broadcast_messages/index.html.haml_spec.rb
deleted file mode 100644
index ba998085bf9..00000000000
--- a/spec/views/admin/broadcast_messages/index.html.haml_spec.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe 'admin/broadcast_messages/index' do
- let(:role_targeted_broadcast_messages) { true }
- let(:vue_broadcast_messages) { false }
-
- let_it_be(:message) { create(:broadcast_message, broadcast_type: 'banner', target_access_levels: [Gitlab::Access::GUEST, Gitlab::Access::DEVELOPER]) }
-
- before do
- assign(:broadcast_messages, BroadcastMessage.page(1))
- assign(:broadcast_message, BroadcastMessage.new)
-
- stub_feature_flags(role_targeted_broadcast_messages: role_targeted_broadcast_messages)
- stub_feature_flags(vue_broadcast_messages: vue_broadcast_messages)
-
- render
- end
-
- describe 'Target roles select and table column' do
- it 'rendered' do
- expect(rendered).to have_content('Target roles')
- expect(rendered).to have_content('Owner')
- expect(rendered).to have_content('Guest, Developer')
- end
-
- context 'when feature flag is off' do
- let(:role_targeted_broadcast_messages) { false }
-
- it 'is not rendered' do
- expect(rendered).not_to have_content('Target roles')
- expect(rendered).not_to have_content('Owner')
- expect(rendered).not_to have_content('Guest, Developer')
- end
- end
- end
-
- describe 'Vue application' do
- it 'is not rendered' do
- expect(rendered).not_to have_selector('#js-broadcast-messages')
- end
-
- context 'when feature flag is on' do
- let(:vue_broadcast_messages) { true }
-
- it 'is rendered' do
- expect(rendered).to have_selector('#js-broadcast-messages')
- end
- 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 337964f1354..6e9cb5e2657 100644
--- a/spec/views/admin/dashboard/index.html.haml_spec.rb
+++ b/spec/views/admin/dashboard/index.html.haml_spec.rb
@@ -51,6 +51,16 @@ RSpec.describe 'admin/dashboard/index.html.haml' do
expect(rendered).not_to have_content "Users over License"
end
+ it 'shows database versions for all database models' do
+ render
+
+ expect(rendered).to have_content /PostgreSQL \(main\).+?#{::Gitlab::Database::Reflection.new(ApplicationRecord).version}/
+
+ if Gitlab::Database.has_config?(:ci)
+ expect(rendered).to have_content /PostgreSQL \(ci\).+?#{::Gitlab::Database::Reflection.new(Ci::ApplicationRecord).version}/
+ end
+ end
+
describe 'when show_version_check? is true' do
before do
allow(view).to receive(:show_version_check?).and_return(true)
diff --git a/spec/views/errors/omniauth_error.html.haml_spec.rb b/spec/views/errors/omniauth_error.html.haml_spec.rb
index e99cb536bd8..487dd9f066f 100644
--- a/spec/views/errors/omniauth_error.html.haml_spec.rb
+++ b/spec/views/errors/omniauth_error.html.haml_spec.rb
@@ -15,8 +15,10 @@ RSpec.describe 'errors/omniauth_error' do
render
expect(rendered).to have_content(provider)
- expect(rendered).to have_content(_('Sign-in failed because %{error}.') % { error: error })
+ expect(rendered).to have_content(error)
expect(rendered).to have_link('Sign in')
- expect(rendered).to have_content(_('If none of the options work, try contacting a GitLab administrator.'))
+ expect(rendered).to have_content(
+ _('If you are unable to sign in or recover your password, contact a GitLab administrator.')
+ )
end
end
diff --git a/spec/views/groups/edit.html.haml_spec.rb b/spec/views/groups/edit.html.haml_spec.rb
index ddcfea0ab10..fda93ebab51 100644
--- a/spec/views/groups/edit.html.haml_spec.rb
+++ b/spec/views/groups/edit.html.haml_spec.rb
@@ -127,13 +127,7 @@ RSpec.describe 'groups/edit.html.haml' do
allow(view).to receive(:current_user) { user }
end
- context 'prompt user about registration features' do
- before do
- if Gitlab.ee?
- allow(License).to receive(:current).and_return(nil)
- end
- end
-
+ context 'prompt user about registration features', :without_license do
context 'with service ping disabled' do
before do
stub_application_setting(usage_ping_enabled: false)
diff --git a/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb
index d4e97d96dfd..163f39568e5 100644
--- a/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb
+++ b/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb
@@ -67,6 +67,24 @@ RSpec.describe 'layouts/nav/sidebar/_admin' do
it_behaves_like 'page has active sub tab', 'Topics'
end
+ context 'on runners' do
+ before do
+ allow(controller).to receive(:controller_name).and_return('runners')
+ end
+
+ it_behaves_like 'page has active tab', 'CI/CD'
+ it_behaves_like 'page has active sub tab', 'Runners'
+ end
+
+ context 'on jobs' do
+ before do
+ allow(controller).to receive(:controller_name).and_return('jobs')
+ end
+
+ it_behaves_like 'page has active tab', 'CI/CD'
+ it_behaves_like 'page has active sub tab', 'Jobs'
+ end
+
context 'on messages' do
before do
allow(controller).to receive(:controller_name).and_return('broadcast_messages')
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 080a53cc1a2..4de2c011b93 100644
--- a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
+++ b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
@@ -827,7 +827,7 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
end
- context 'gitlab.com' do
+ context 'gitlab.com', :with_license do
before do
allow(Gitlab).to receive(:com?).and_return(true)
end
diff --git a/spec/views/layouts/snippets.html.haml_spec.rb b/spec/views/layouts/snippets.html.haml_spec.rb
new file mode 100644
index 00000000000..69378906bcd
--- /dev/null
+++ b/spec/views/layouts/snippets.html.haml_spec.rb
@@ -0,0 +1,48 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'layouts/snippets', feature_category: :snippets do
+ before do
+ allow(view).to receive(:current_user).and_return(user)
+ allow(view).to receive(:current_user_mode).and_return(Gitlab::Auth::CurrentUserMode.new(user))
+ end
+
+ describe 'sidebar' do
+ context 'when feature flag is on' do
+ context 'when signed in' do
+ let(:user) { build_stubbed(:user) }
+
+ it 'renders the "Your work" sidebar' do
+ render
+
+ expect(rendered).to have_css('aside.nav-sidebar[aria-label="Your work"]')
+ end
+ end
+
+ context 'when not signed in' do
+ let(:user) { nil }
+
+ it 'renders no sidebar' do
+ render
+
+ expect(rendered).not_to have_css('aside.nav-sidebar')
+ end
+ end
+ end
+
+ context 'when feature flag is off' do
+ before do
+ stub_feature_flags(your_work_sidebar: false)
+ end
+
+ let(:user) { build_stubbed(:user) }
+
+ it 'renders no sidebar' do
+ render
+
+ expect(rendered).not_to have_css('aside.nav-sidebar')
+ end
+ end
+ end
+end
diff --git a/spec/views/profiles/notifications/show.html.haml_spec.rb b/spec/views/profiles/notifications/show.html.haml_spec.rb
index 9cdf8124fcf..1cfd8847bf8 100644
--- a/spec/views/profiles/notifications/show.html.haml_spec.rb
+++ b/spec/views/profiles/notifications/show.html.haml_spec.rb
@@ -5,6 +5,11 @@ require 'spec_helper'
RSpec.describe 'profiles/notifications/show' do
let(:groups) { GroupsFinder.new(user).execute.page(1) }
let(:user) { create(:user) }
+ let(:option_default) { _('Use primary email (%{email})') % { email: user.email } }
+ let(:option_primary_email) { user.email }
+ let(:expected_primary_email_attr) { "[data-emails='#{[option_primary_email].to_json}']" }
+ let(:expected_default_attr) { "[data-empty-value-text='#{option_default}']" }
+ let(:expected_selector) { expected_primary_email_attr + expected_default_attr + expected_value_attr }
before do
assign(:group_notifications, [])
@@ -16,14 +21,26 @@ RSpec.describe 'profiles/notifications/show' do
end
context 'when there is no database value for User#notification_email' do
- let(:option_default) { _('Use primary email (%{email})') % { email: user.email } }
- let(:option_primary_email) { user.email }
- let(:options) { [option_default, option_primary_email] }
+ let(:expected_value_attr) { ":not([data-value])" }
it 'displays the correct elements' do
render
- expect(rendered).to have_select('user_notification_email', options: options, selected: nil)
+ expect(rendered).to have_selector(expected_selector)
+ end
+ end
+
+ context 'when there is a database value for User#notification_email' do
+ let(:expected_value_attr) { "[data-value='#{option_primary_email}']" }
+
+ before do
+ user.notification_email = option_primary_email
+ end
+
+ it 'displays the correct elements' do
+ render
+
+ expect(rendered).to have_selector(expected_selector)
end
end
end
diff --git a/spec/views/profiles/preferences/show.html.haml_spec.rb b/spec/views/profiles/preferences/show.html.haml_spec.rb
index 4e4499c3252..6e0c6d67d85 100644
--- a/spec/views/profiles/preferences/show.html.haml_spec.rb
+++ b/spec/views/profiles/preferences/show.html.haml_spec.rb
@@ -54,8 +54,9 @@ RSpec.describe 'profiles/preferences/show' do
end
it 'has helpful homepage setup guidance' do
- expect(rendered).to have_field('Dashboard')
- expect(rendered).to have_content('Choose what content you want to see by default on your dashboard.')
+ expect(rendered).to have_selector('[data-label="Dashboard"]')
+ expect(rendered).to have_selector("[data-description=" \
+ "'Choose what content you want to see by default on your dashboard.']")
end
end
diff --git a/spec/views/projects/_files.html.haml_spec.rb b/spec/views/projects/_files.html.haml_spec.rb
deleted file mode 100644
index b6a8b4735b0..00000000000
--- a/spec/views/projects/_files.html.haml_spec.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe 'projects/_files' do
- include ProjectForksHelper
-
- let_it_be(:user) { create(:user) }
- let_it_be(:source_project) { create(:project, :repository, :public) }
-
- context 'when the project is a fork' do
- let_it_be(:project) { fork_project(source_project, user, { repository: true }) }
-
- before do
- assign(:project, project)
- assign(:ref, project.default_branch)
- assign(:path, '/')
- assign(:id, project.commit.id)
-
- allow(view).to receive(:current_user).and_return(user)
- end
-
- context 'when user can read fork source' do
- before do
- allow(view).to receive(:can?).with(user, :read_project, source_project).and_return(true)
- end
-
- it 'shows the forked-from project' do
- render
-
- expect(rendered).to have_content("Forked from #{source_project.full_name}")
- expect(rendered).to have_content("Up to date with upstream repository")
- end
-
- context 'when fork_divergence_counts is disabled' do
- before do
- stub_feature_flags(fork_divergence_counts: false)
- end
-
- it 'does not show fork info' do
- render
-
- expect(rendered).not_to have_content("Forked from #{source_project.full_name}")
- expect(rendered).not_to have_content("Up to date with upstream repository")
- end
- end
- end
-
- context 'when user cannot read fork source' do
- before do
- allow(view).to receive(:can?).with(user, :read_project, source_project).and_return(false)
- end
-
- it 'does not show the forked-from project' do
- render
-
- expect(rendered).to have_content("Forked from an inaccessible project")
- end
-
- context 'when fork_divergence_counts is disabled' do
- before do
- stub_feature_flags(fork_divergence_counts: false)
- end
-
- it 'does not show fork info' do
- render
-
- expect(rendered).not_to have_content("Forked from an inaccessible project")
- end
- end
- end
- end
-end
diff --git a/spec/views/projects/commit/show.html.haml_spec.rb b/spec/views/projects/commit/show.html.haml_spec.rb
index 1d9e5e782e5..52b3d5b95f9 100644
--- a/spec/views/projects/commit/show.html.haml_spec.rb
+++ b/spec/views/projects/commit/show.html.haml_spec.rb
@@ -92,7 +92,7 @@ RSpec.describe 'projects/commit/show.html.haml', feature_category: :source_code
let(:commit) { project.commit(GpgHelpers::SIGNED_COMMIT_SHA) }
it 'renders unverified badge' do
- expect(title).to include('This commit was signed with an <strong>unverified</strong> signature.')
+ expect(title).to include('This commit was signed with an unverified signature.')
expect(content).to include(commit.signature.gpg_key_primary_keyid)
end
end
@@ -101,8 +101,8 @@ RSpec.describe 'projects/commit/show.html.haml', feature_category: :source_code
let(:commit) { project.commit('7b5160f9bb23a3d58a0accdbe89da13b96b1ece9') }
it 'renders unverified badge' do
- expect(title).to include('This commit was signed with an <strong>unverified</strong> signature.')
- expect(content).to match(/SSH key fingerprint:[\s\S]+Unknown/)
+ expect(title).to include('This commit was signed with an unverified signature.')
+ expect(content).to match(/SSH key fingerprint:[\s\S].+#{commit.signature.key_fingerprint_sha256}/)
end
end
@@ -112,7 +112,6 @@ RSpec.describe 'projects/commit/show.html.haml', feature_category: :source_code
it 'renders unverified badge' do
expect(title).to include('This commit was signed with an <strong>unverified</strong> signature.')
expect(content).to include(commit.signature.x509_certificate.subject_key_identifier.tr(":", " "))
- expect(content).to include(commit.signature.x509_certificate.email)
end
end
end
diff --git a/spec/views/projects/edit.html.haml_spec.rb b/spec/views/projects/edit.html.haml_spec.rb
index 2935e4395ba..bf154b61609 100644
--- a/spec/views/projects/edit.html.haml_spec.rb
+++ b/spec/views/projects/edit.html.haml_spec.rb
@@ -93,13 +93,9 @@ RSpec.describe 'projects/edit' do
it_behaves_like 'does not render registration features prompt', :project_disabled_repository_size_limit
end
- context 'with no license and service ping disabled' do
+ context 'with no license and service ping disabled', :without_license 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
diff --git a/spec/views/registrations/welcome/show.html.haml_spec.rb b/spec/views/registrations/welcome/show.html.haml_spec.rb
index 99d87ac449b..372dbf01a64 100644
--- a/spec/views/registrations/welcome/show.html.haml_spec.rb
+++ b/spec/views/registrations/welcome/show.html.haml_spec.rb
@@ -7,10 +7,6 @@ RSpec.describe 'registrations/welcome/show' do
before do
allow(view).to receive(:current_user).and_return(user)
- allow(view).to receive(:in_subscription_flow?).and_return(false)
- allow(view).to receive(:in_trial_flow?).and_return(false)
- allow(view).to receive(:user_has_memberships?).and_return(false)
- allow(view).to receive(:in_oauth_flow?).and_return(false)
allow(view).to receive(:glm_tracking_params).and_return({})
render
diff --git a/spec/views/search/_results.html.haml_spec.rb b/spec/views/search/_results.html.haml_spec.rb
index e81462ee518..de994a0da2b 100644
--- a/spec/views/search/_results.html.haml_spec.rb
+++ b/spec/views/search/_results.html.haml_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe 'search/_results' do
+RSpec.describe 'search/_results', feature_category: :global_search do
using RSpec::Parameterized::TableSyntax
let_it_be(:user) { create(:user) }
@@ -11,7 +11,6 @@ RSpec.describe 'search/_results' do
let(:scope) { 'issues' }
let(:term) { 'foo' }
let(:search_results) { instance_double('Gitlab::SearchResults', { formatted_count: 10, current_user: user } ) }
- let(:search_service) { class_double(SearchServicePresenter, scope: scope, search: term, current_user: user) }
before do
controller.params[:action] = 'show'
@@ -20,6 +19,7 @@ RSpec.describe 'search/_results' do
create_list(:issue, 3)
allow(view).to receive(:current_user) { user }
+
assign(:search_count_path, 'test count link')
assign(:search_path, 'link test')
assign(:search_results, search_results)
@@ -27,8 +27,9 @@ RSpec.describe 'search/_results' do
assign(:search_term, term)
assign(:scope, scope)
- @search_service = SearchServicePresenter.new(SearchService.new(user, search: term, scope: scope))
- allow(@search_service).to receive(:search_objects).and_return(search_objects)
+ search_service_presenter = SearchServicePresenter.new(SearchService.new(user, search: term, scope: scope))
+ allow(search_service_presenter).to receive(:search_objects).and_return(search_objects)
+ assign(:search_service_presenter, search_service_presenter)
end
where(search_page_vertical_nav_enabled: [true, false])
diff --git a/spec/views/search/show.html.haml_spec.rb b/spec/views/search/show.html.haml_spec.rb
index 26ec2c6ae74..6adb2c77c4d 100644
--- a/spec/views/search/show.html.haml_spec.rb
+++ b/spec/views/search/show.html.haml_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe 'search/show', feature_category: :global_search do
stub_template "search/_category.html.haml" => 'Category Partial'
stub_template "search/_results.html.haml" => 'Results Partial'
- assign(:search_service, search_service_presenter)
+ assign(:search_service_presenter, search_service_presenter)
end
context 'search_page_vertical_nav feature flag enabled' do
diff --git a/spec/views/shared/projects/_list.html.haml_spec.rb b/spec/views/shared/projects/_list.html.haml_spec.rb
index 5c38bb79ea1..b7b4f97f2b6 100644
--- a/spec/views/shared/projects/_list.html.haml_spec.rb
+++ b/spec/views/shared/projects/_list.html.haml_spec.rb
@@ -82,7 +82,7 @@ RSpec.describe 'shared/projects/_list' do
it 'renders a no-content message' do
render
- expect(rendered).to have_content(s_('UserProfile|This user doesn\'t have any personal projects'))
+ expect(rendered).to have_content(s_('UserProfile|There are no projects available to be displayed here.'))
end
end
end