summaryrefslogtreecommitdiff
path: root/spec/views
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-12-20 14:22:11 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-12-20 14:22:11 +0000
commit0c872e02b2c822e3397515ec324051ff540f0cd5 (patch)
treece2fb6ce7030e4dad0f4118d21ab6453e5938cdd /spec/views
parentf7e05a6853b12f02911494c4b3fe53d9540d74fc (diff)
downloadgitlab-ce-15.7.0-rc42.tar.gz
Add latest changes from gitlab-org/gitlab@15-7-stable-eev15.7.0-rc42
Diffstat (limited to 'spec/views')
-rw-r--r--spec/views/admin/application_settings/_ci_cd.html.haml_spec.rb8
-rw-r--r--spec/views/admin/application_settings/_repository_check.html.haml_spec.rb27
-rw-r--r--spec/views/admin/application_settings/general.html.haml_spec.rb12
-rw-r--r--spec/views/admin/dashboard/index.html.haml_spec.rb4
-rw-r--r--spec/views/help/index.html.haml_spec.rb2
-rw-r--r--spec/views/import/gitlab_projects/new.html.haml_spec.rb2
-rw-r--r--spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb40
-rw-r--r--spec/views/profiles/keys/_form.html.haml_spec.rb5
-rw-r--r--spec/views/profiles/keys/_key.html.haml_spec.rb20
-rw-r--r--spec/views/profiles/keys/_key_details.html.haml_spec.rb32
-rw-r--r--spec/views/projects/_files.html.haml_spec.rb73
-rw-r--r--spec/views/projects/_flash_messages.html.haml_spec.rb4
-rw-r--r--spec/views/projects/_home_panel.html.haml_spec.rb36
-rw-r--r--spec/views/projects/commit/show.html.haml_spec.rb42
-rw-r--r--spec/views/projects/issues/_related_branches.html.haml_spec.rb11
-rw-r--r--spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb6
-rw-r--r--spec/views/projects/pipelines/show.html.haml_spec.rb11
-rw-r--r--spec/views/projects/tree/show.html.haml_spec.rb2
-rw-r--r--spec/views/search/_results.html.haml_spec.rb66
-rw-r--r--spec/views/search/show.html.haml_spec.rb27
-rw-r--r--spec/views/shared/gitlab_version/_security_patch_upgrade_alert.html.haml_spec.rb20
-rw-r--r--spec/views/shared/ssh_keys/_key_delete.html.haml_spec.rb (renamed from spec/views/shared/ssh_keys/_key_details.html.haml_spec.rb)12
22 files changed, 372 insertions, 90 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
index 12593b88009..d5aa7139e2b 100644
--- a/spec/views/admin/application_settings/_ci_cd.html.haml_spec.rb
+++ b/spec/views/admin/application_settings/_ci_cd.html.haml_spec.rb
@@ -14,7 +14,8 @@ RSpec.describe 'admin/application_settings/_ci_cd' do
ci_pipeline_schedules: 40,
ci_needs_size_limit: 50,
ci_registered_group_runners: 60,
- ci_registered_project_runners: 70
+ ci_registered_project_runners: 70,
+ pipeline_hierarchy_size: 300
}
end
@@ -58,6 +59,11 @@ RSpec.describe 'admin/application_settings/_ci_cd' do
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')
+
+ expect(rendered).to have_field("Maximum number of downstream pipelines in a pipeline's hierarchy tree",
+type: 'number')
+ expect(page.find_field("Maximum number of downstream pipelines in a pipeline's hierarchy tree").value)
+ .to eq('300')
end
it 'does not display the plan name when there is only one plan' do
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 fbabc890a8b..dc3459f84ef 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
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe 'admin/application_settings/_repository_check.html.haml' do
+RSpec.describe 'admin/application_settings/_repository_check.html.haml', feature_category: :source_code_management do
let_it_be(:user) { create(:admin) }
let_it_be(:application_setting) { build(:application_setting) }
@@ -40,9 +40,28 @@ RSpec.describe 'admin/application_settings/_repository_check.html.haml' 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).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 a8c7bec36e3..f229fd2dcdc 100644
--- a/spec/views/admin/application_settings/general.html.haml_spec.rb
+++ b/spec/views/admin/application_settings/general.html.haml_spec.rb
@@ -75,18 +75,6 @@ RSpec.describe 'admin/application_settings/general.html.haml' do
expect(rendered).to have_css('#js-jira_connect-settings')
end
-
- context 'when the jira_connect_oauth_self_managed_setting feature flag is disabled' do
- before do
- stub_feature_flags(jira_connect_oauth_self_managed_setting: false)
- end
-
- it 'does not show the jira connect settings section' do
- render
-
- expect(rendered).not_to have_css('#js-jira_connect-settings')
- end
- end
end
describe 'sign-up restrictions' do
diff --git a/spec/views/admin/dashboard/index.html.haml_spec.rb b/spec/views/admin/dashboard/index.html.haml_spec.rb
index 6e06af92232..337964f1354 100644
--- a/spec/views/admin/dashboard/index.html.haml_spec.rb
+++ b/spec/views/admin/dashboard/index.html.haml_spec.rb
@@ -7,9 +7,7 @@ RSpec.describe 'admin/dashboard/index.html.haml' do
include StubVersion
before do
- counts = Admin::DashboardController::COUNTED_ITEMS.each_with_object({}) do |item, hash|
- hash[item] = 100
- end
+ counts = Admin::DashboardController::COUNTED_ITEMS.index_with { 100 }
assign(:counts, counts)
assign(:projects, create_list(:project, 1))
diff --git a/spec/views/help/index.html.haml_spec.rb b/spec/views/help/index.html.haml_spec.rb
index 1d26afcc567..c041c41a412 100644
--- a/spec/views/help/index.html.haml_spec.rb
+++ b/spec/views/help/index.html.haml_spec.rb
@@ -23,7 +23,7 @@ RSpec.describe 'help/index' do
context 'when logged in' do
def version_link_regexp(path)
base_url = "#{view.source_host_url}/#{view.source_code_group}"
- %r{#{Regexp.escape(base_url)}/(gitlab|gitlab\-foss)/#{Regexp.escape(path)}}
+ %r{#{Regexp.escape(base_url)}/(gitlab|gitlab-foss)/#{Regexp.escape(path)}}
end
before do
diff --git a/spec/views/import/gitlab_projects/new.html.haml_spec.rb b/spec/views/import/gitlab_projects/new.html.haml_spec.rb
index c09c798f487..68e7019c892 100644
--- a/spec/views/import/gitlab_projects/new.html.haml_spec.rb
+++ b/spec/views/import/gitlab_projects/new.html.haml_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe 'import/gitlab_projects/new.html.haml' do
render
- expect(rendered).to have_select('namespace_id', count: 1)
+ expect(rendered).to have_css('.js-vue-new-project-url-select', count: 1)
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 d0d220fed66..080a53cc1a2 100644
--- a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
+++ b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
@@ -96,10 +96,24 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
describe 'Commits' do
- it 'has a link to the project commits path' do
- render
+ context 'when the use_ref_type_parameter flag is not enabled' do
+ before do
+ stub_feature_flags(use_ref_type_parameter: false)
+ end
- expect(rendered).to have_link('Commits', href: project_commits_path(project, current_ref), id: 'js-onboarding-commits-link')
+ it 'has a link to the project commits path' do
+ render
+
+ expect(rendered).to have_link('Commits', href: project_commits_path(project, current_ref), id: 'js-onboarding-commits-link')
+ end
+ end
+
+ context 'when the use_ref_type_parameter flag is enabled' do
+ it 'has a link to the fully qualified project commits path' do
+ render
+
+ expect(rendered).to have_link('Commits', href: project_commits_path(project, current_ref, ref_type: 'heads'), id: 'js-onboarding-commits-link')
+ end
end
end
@@ -120,10 +134,24 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
describe 'Contributors' do
- it 'has a link to the project contributors path' do
- render
+ context 'and the use_ref_type_parameter flag is disabled' do
+ before do
+ stub_feature_flags(use_ref_type_parameter: false)
+ end
- expect(rendered).to have_link('Contributors', href: project_graph_path(project, current_ref))
+ it 'has a link to the project contributors path' do
+ render
+
+ expect(rendered).to have_link('Contributors', href: project_graph_path(project, current_ref))
+ end
+ end
+
+ context 'and the use_ref_type_parameter flag is enabled' do
+ it 'has a link to the project contributors path' do
+ render
+
+ expect(rendered).to have_link('Contributors', href: project_graph_path(project, current_ref, ref_type: 'heads'))
+ 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 3c61afb21c5..dd8af14100a 100644
--- a/spec/views/profiles/keys/_form.html.haml_spec.rb
+++ b/spec/views/profiles/keys/_form.html.haml_spec.rb
@@ -32,6 +32,11 @@ RSpec.describe 'profiles/keys/_form.html.haml' do
expect(rendered).to have_text('Key titles are publicly visible.')
end
+ it 'has the usage type field', :aggregate_failures do
+ expect(page).to have_select _('Usage type'),
+ selected: 'Authentication & Signing', options: ['Authentication & Signing', 'Authentication', 'Signing']
+ end
+
it 'has the expires at field', :aggregate_failures do
expect(rendered).to have_field('Expiration date', type: 'text')
expect(page.find_field('Expiration date')['min']).to eq(l(1.day.from_now, format: "%Y-%m-%d"))
diff --git a/spec/views/profiles/keys/_key.html.haml_spec.rb b/spec/views/profiles/keys/_key.html.haml_spec.rb
index 1040541332d..d2e27bd2ee0 100644
--- a/spec/views/profiles/keys/_key.html.haml_spec.rb
+++ b/spec/views/profiles/keys/_key.html.haml_spec.rb
@@ -30,6 +30,26 @@ RSpec.describe 'profiles/keys/_key.html.haml' do
expect(response).to render_template(partial: 'shared/ssh_keys/_key_delete')
end
+ context 'displays the usage type' do
+ where(:usage_type, :usage_type_text) do
+ [
+ [:auth, 'Authentication'],
+ [:auth_and_signing, 'Authentication & Signing'],
+ [:signing, 'Signing']
+ ]
+ end
+
+ with_them do
+ let(:key) { create(:key, user: user, usage_type: usage_type) }
+
+ it 'renders usage type text' do
+ render
+
+ expect(rendered).to have_text(usage_type_text)
+ end
+ end
+ end
+
context 'when the key has not been used' do
let_it_be(:key) do
create(:personal_key,
diff --git a/spec/views/profiles/keys/_key_details.html.haml_spec.rb b/spec/views/profiles/keys/_key_details.html.haml_spec.rb
new file mode 100644
index 00000000000..c223d6702c5
--- /dev/null
+++ b/spec/views/profiles/keys/_key_details.html.haml_spec.rb
@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'profiles/keys/_key_details.html.haml' do
+ let_it_be(:user) { create(:user) }
+
+ before do
+ assign(:key, key)
+ allow(view).to receive(:is_admin).and_return(false)
+ end
+
+ describe 'displays the usage type' do
+ where(:usage_type, :usage_type_text) do
+ [
+ [:auth, 'Authentication'],
+ [:auth_and_signing, 'Authentication & Signing'],
+ [:signing, 'Signing']
+ ]
+ end
+
+ with_them do
+ let(:key) { create(:key, user: user, usage_type: usage_type) }
+
+ it 'renders usage type text' do
+ render
+
+ expect(rendered).to have_text(usage_type_text)
+ end
+ end
+ end
+end
diff --git a/spec/views/projects/_files.html.haml_spec.rb b/spec/views/projects/_files.html.haml_spec.rb
new file mode 100644
index 00000000000..b6a8b4735b0
--- /dev/null
+++ b/spec/views/projects/_files.html.haml_spec.rb
@@ -0,0 +1,73 @@
+# 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/_flash_messages.html.haml_spec.rb b/spec/views/projects/_flash_messages.html.haml_spec.rb
index e1858229208..231aa12d920 100644
--- a/spec/views/projects/_flash_messages.html.haml_spec.rb
+++ b/spec/views/projects/_flash_messages.html.haml_spec.rb
@@ -12,10 +12,10 @@ RSpec.describe 'projects/_flash_messages' do
before do
allow(view).to receive(:current_user).and_return(user)
- allow(view).to receive(:can?).with(user, :download_code, project).and_return(true)
+ allow(view).to receive(:can?).with(user, :read_code, project).and_return(true)
end
- context 'when current_user has download_code permission' do
+ context 'when current_user has read_code permission' do
context 'when user has a terraform state' do
let_it_be(:project) { create(:project) }
let_it_be(:terraform_state) { create(:terraform_state, :locked, :with_version, project: project) }
diff --git a/spec/views/projects/_home_panel.html.haml_spec.rb b/spec/views/projects/_home_panel.html.haml_spec.rb
index 78131937d3c..6f6a2d9a04d 100644
--- a/spec/views/projects/_home_panel.html.haml_spec.rb
+++ b/spec/views/projects/_home_panel.html.haml_spec.rb
@@ -190,22 +190,50 @@ RSpec.describe 'projects/_home_panel' do
end
context 'user can read fork source' do
- it 'shows the forked-from project' do
+ before do
allow(view).to receive(:can?).with(user, :read_project, source_project).and_return(true)
+ end
+ it 'does not show the forked-from project' do
render
- expect(rendered).to have_content("Forked from #{source_project.full_name}")
+ expect(rendered).not_to have_content("Forked from #{source_project.full_name}")
+ end
+
+ context 'when fork_divergence_counts is disabled' do
+ before do
+ stub_feature_flags(fork_divergence_counts: false)
+ end
+
+ it 'shows the forked-from project' do
+ render
+
+ expect(rendered).to have_content("Forked from #{source_project.full_name}")
+ end
end
end
context 'user cannot read fork source' do
- it 'does not show the forked-from project' do
+ before do
allow(view).to receive(:can?).with(user, :read_project, source_project).and_return(false)
+ end
+ it 'shows the message that forked project is inaccessible' do
render
- expect(rendered).to have_content("Forked from an inaccessible project")
+ expect(rendered).not_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 'shows the message that forked project is inaccessible' do
+ render
+
+ expect(rendered).to have_content("Forked from an inaccessible project")
+ 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 4d5c987ce37..1d9e5e782e5 100644
--- a/spec/views/projects/commit/show.html.haml_spec.rb
+++ b/spec/views/projects/commit/show.html.haml_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe 'projects/commit/show.html.haml' do
+RSpec.describe 'projects/commit/show.html.haml', feature_category: :source_code do
let(:project) { create(:project, :repository) }
let(:commit) { project.commit }
@@ -76,4 +76,44 @@ RSpec.describe 'projects/commit/show.html.haml' do
end
end
end
+
+ context 'when commit is signed' do
+ let(:page) { Nokogiri::HTML.parse(rendered) }
+ let(:badge) { page.at('.gpg-status-box') }
+ let(:badge_attributes) { badge.attributes }
+ let(:title) { badge_attributes['data-title'].value }
+ let(:content) { badge_attributes['data-content'].value }
+
+ before do
+ render
+ end
+
+ context 'with GPG' do
+ 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(content).to include(commit.signature.gpg_key_primary_keyid)
+ end
+ end
+
+ context 'with SSH' do
+ 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/)
+ end
+ end
+
+ context 'with X.509' do
+ let(:commit) { project.commit('189a6c924013fc3fe40d6f1ec1dc20214183bc97') }
+
+ 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
end
diff --git a/spec/views/projects/issues/_related_branches.html.haml_spec.rb b/spec/views/projects/issues/_related_branches.html.haml_spec.rb
index ba6f7068024..deec2db6865 100644
--- a/spec/views/projects/issues/_related_branches.html.haml_spec.rb
+++ b/spec/views/projects/issues/_related_branches.html.haml_spec.rb
@@ -9,10 +9,13 @@ RSpec.describe 'projects/issues/_related_branches' do
let(:status) { pipeline.detailed_status(build(:user)) }
before do
- assign(:related_branches, [
- { name: 'other', link: 'link-to-other', pipeline_status: nil },
- { name: 'feature', link: 'link-to-feature', pipeline_status: status }
- ])
+ assign(:related_branches,
+ [
+ { name: 'other', link: 'link-to-other', pipeline_status: nil },
+ { name: 'feature', link: 'link-to-feature', pipeline_status: status }
+
+ ]
+ )
render
end
diff --git a/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb b/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb
index 3776af9e757..7886a811c9a 100644
--- a/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb
+++ b/spec/views/projects/notes/_more_actions_dropdown.html.haml_spec.rb
@@ -17,7 +17,7 @@ RSpec.describe 'projects/notes/_more_actions_dropdown' do
it 'shows Report abuse to admin button if not editable and not current users comment' do
render 'projects/notes/more_actions_dropdown', current_user: not_author_user, note_editable: false, note: note
- expect(rendered).to have_link('Report abuse to admin')
+ expect(rendered).to have_link('Report abuse to administrator')
end
it 'does not show the More actions button if not editable and current users comment' do
@@ -26,10 +26,10 @@ RSpec.describe 'projects/notes/_more_actions_dropdown' do
expect(rendered).not_to have_selector('.dropdown.more-actions')
end
- it 'shows Report abuse to admin and Delete buttons if editable and not current users comment' do
+ it 'shows Report abuse and Delete buttons if editable and not current users comment' do
render 'projects/notes/more_actions_dropdown', current_user: not_author_user, note_editable: true, note: note
- expect(rendered).to have_link('Report abuse to admin')
+ expect(rendered).to have_link('Report abuse to administrator')
expect(rendered).to have_link('Delete comment')
end
diff --git a/spec/views/projects/pipelines/show.html.haml_spec.rb b/spec/views/projects/pipelines/show.html.haml_spec.rb
index 7e300fb1e6e..b9c7da20d1a 100644
--- a/spec/views/projects/pipelines/show.html.haml_spec.rb
+++ b/spec/views/projects/pipelines/show.html.haml_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-RSpec.describe 'projects/pipelines/show' do
+RSpec.describe 'projects/pipelines/show', feature_category: :pipeline_authoring do
include Devise::Test::ControllerHelpers
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) }
@@ -13,7 +13,6 @@ 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
@@ -24,14 +23,14 @@ RSpec.describe 'projects/pipelines/show' do
it 'shows errors' do
render
- expect(rendered).to have_content('Found errors in your .gitlab-ci.yml')
+ expect(rendered).to have_content('Unable to create pipeline')
expect(rendered).to have_content('some errors')
end
it 'does not render the pipeline tabs' do
render
- expect(rendered).not_to have_css('ul.pipelines-tabs')
+ expect(rendered).not_to have_selector('#js-pipeline-tabs')
end
end
@@ -39,13 +38,13 @@ RSpec.describe 'projects/pipelines/show' do
it 'does not show errors' do
render
- expect(rendered).not_to have_content('Found errors in your .gitlab-ci.yml')
+ expect(rendered).not_to have_content('Unable to create pipeline')
end
it 'renders the pipeline tabs' do
render
- expect(rendered).to have_css('ul.pipelines-tabs')
+ expect(rendered).to have_selector('#js-pipeline-tabs')
end
end
end
diff --git a/spec/views/projects/tree/show.html.haml_spec.rb b/spec/views/projects/tree/show.html.haml_spec.rb
index 62a52bcf83f..5a1ae715f8f 100644
--- a/spec/views/projects/tree/show.html.haml_spec.rb
+++ b/spec/views/projects/tree/show.html.haml_spec.rb
@@ -35,7 +35,7 @@ RSpec.describe 'projects/tree/show' do
it 'displays correctly' do
render
- expect(rendered).to have_css('.js-project-refs-dropdown .dropdown-toggle-text', text: ref)
+ expect(rendered).to have_css('#js-tree-ref-switcher')
end
end
end
diff --git a/spec/views/search/_results.html.haml_spec.rb b/spec/views/search/_results.html.haml_spec.rb
index 2149c394320..e81462ee518 100644
--- a/spec/views/search/_results.html.haml_spec.rb
+++ b/spec/views/search/_results.html.haml_spec.rb
@@ -3,36 +3,60 @@
require 'spec_helper'
RSpec.describe 'search/_results' do
- let(:user) { create(:user) }
+ using RSpec::Parameterized::TableSyntax
+
+ let_it_be(:user) { create(:user) }
+
let(:search_objects) { Issue.page(1).per(2) }
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'
controller.params[:search] = term
- allow(self).to receive(:current_user).and_return(user)
- allow(@search_results).to receive(:formatted_count).with(scope).and_return(10)
- allow(self).to receive(:search_count_path).with(any_args).and_return("test count link")
- allow(self).to receive(:search_path).with(any_args).and_return("link test")
-
- stub_feature_flags(search_page_vertical_nav: false)
-
create_list(:issue, 3)
- @search_objects = search_objects
- @scope = scope
- @search_term = term
- @search_service = SearchServicePresenter.new(SearchService.new(user, search: term, scope: scope))
+ allow(view).to receive(:current_user) { user }
+ assign(:search_count_path, 'test count link')
+ assign(:search_path, 'link test')
+ assign(:search_results, search_results)
+ assign(:search_objects, search_objects)
+ 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)
end
- it 'displays the page size' do
- render
+ where(search_page_vertical_nav_enabled: [true, false])
+
+ with_them do
+ describe 'page size' do
+ before do
+ stub_feature_flags(search_page_vertical_nav: search_page_vertical_nav_enabled)
+ end
+
+ context 'when search results have a count' do
+ it 'displays the page size' do
+ render
+
+ expect(rendered).to have_content('Showing 1 - 2 of 3 issues for foo')
+ end
+ end
+
+ context 'when search results do not have a count' do
+ let(:search_objects) { Issue.page(1).per(2).without_count }
+
+ it 'does not display the page size' do
+ render
- expect(rendered).to have_content('Showing 1 - 2 of 3 issues for foo')
+ expect(rendered).not_to have_content(/Showing .* of .*/)
+ end
+ end
+ end
end
context 'when searching notes which contain quotes in markdown' do
@@ -51,18 +75,6 @@ RSpec.describe 'search/_results' do
end
end
- context 'when search results do not have a count' do
- before do
- @search_objects = @search_objects.without_count
- end
-
- it 'does not display the page size' do
- render
-
- expect(rendered).not_to have_content(/Showing .* of .*/)
- end
- end
-
context 'rendering all types of search results' do
let_it_be(:project) { create(:project, :repository, :wiki_repo) }
let_it_be(:issue) { create(:issue, project: project, title: 'testing') }
diff --git a/spec/views/search/show.html.haml_spec.rb b/spec/views/search/show.html.haml_spec.rb
index 5f9c6c65a08..26ec2c6ae74 100644
--- a/spec/views/search/show.html.haml_spec.rb
+++ b/spec/views/search/show.html.haml_spec.rb
@@ -2,27 +2,32 @@
require 'spec_helper'
-RSpec.describe 'search/show' do
+RSpec.describe 'search/show', feature_category: :global_search do
let(:search_term) { nil }
let(:user) { build(:user) }
+ let(:search_service_presenter) do
+ instance_double(SearchServicePresenter, without_count?: false, advanced_search_enabled?: false)
+ end
before do
stub_template "search/_category.html.haml" => 'Category Partial'
stub_template "search/_results.html.haml" => 'Results Partial'
+
+ assign(:search_service, search_service_presenter)
end
context 'search_page_vertical_nav feature flag enabled' do
before do
allow(view).to receive(:current_user) { user }
assign(:search_term, search_term)
-
- render
end
context 'when search term is supplied' do
let(:search_term) { 'Search Foo' }
it 'will not render category partial' do
+ render
+
expect(rendered).not_to render_template('search/_category')
expect(rendered).to render_template('search/_results')
end
@@ -34,17 +39,19 @@ RSpec.describe 'search/show' do
stub_feature_flags(search_page_vertical_nav: false)
assign(:search_term, search_term)
-
- render
end
context 'when the search page is opened' do
it 'displays the title' do
+ render
+
expect(rendered).to have_selector('h1.page-title', text: 'Search')
expect(rendered).not_to have_selector('h1.page-title code')
end
it 'does not render partials' do
+ render
+
expect(rendered).not_to render_template('search/_category')
expect(rendered).not_to render_template('search/_results')
end
@@ -54,6 +61,8 @@ RSpec.describe 'search/show' do
let(:search_term) { 'Search Foo' }
it 'renders partials' do
+ render
+
expect(rendered).to render_template('search/_category')
expect(rendered).to render_template('search/_results')
end
@@ -73,8 +82,8 @@ RSpec.describe 'search/show' do
end
context 'search with full count' do
- before do
- assign(:without_count, false)
+ let(:search_service_presenter) do
+ instance_double(SearchServicePresenter, without_count?: false, advanced_search_enabled?: false)
end
it 'renders meta tags for a group' do
@@ -96,8 +105,8 @@ RSpec.describe 'search/show' do
end
context 'search without full count' do
- before do
- assign(:without_count, true)
+ let(:search_service_presenter) do
+ instance_double(SearchServicePresenter, without_count?: true, advanced_search_enabled?: false)
end
it 'renders meta tags for a group' do
diff --git a/spec/views/shared/gitlab_version/_security_patch_upgrade_alert.html.haml_spec.rb b/spec/views/shared/gitlab_version/_security_patch_upgrade_alert.html.haml_spec.rb
new file mode 100644
index 00000000000..4387a3f5b07
--- /dev/null
+++ b/spec/views/shared/gitlab_version/_security_patch_upgrade_alert.html.haml_spec.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'shared/gitlab_version/_security_patch_upgrade_alert' do
+ describe 'when show_security_patch_upgrade_alert? is true' do
+ before do
+ allow(view).to receive(:show_security_patch_upgrade_alert?).and_return(true)
+ render
+ end
+
+ it 'renders the security patch upgrade alert' do
+ expect(rendered).to have_selector('#js-security-patch-upgrade-alert')
+ end
+
+ it 'renders the security patch upgrade alert modal' do
+ expect(rendered).to have_selector('#js-security-patch-upgrade-alert-modal')
+ end
+ end
+end
diff --git a/spec/views/shared/ssh_keys/_key_details.html.haml_spec.rb b/spec/views/shared/ssh_keys/_key_delete.html.haml_spec.rb
index 1bee9f7463f..c9bdcabb4b6 100644
--- a/spec/views/shared/ssh_keys/_key_details.html.haml_spec.rb
+++ b/spec/views/shared/ssh_keys/_key_delete.html.haml_spec.rb
@@ -2,19 +2,21 @@
require 'spec_helper'
RSpec.describe 'shared/ssh_keys/_key_delete.html.haml' do
- context 'when the text parameter is used' do
+ context 'when the icon parameter is used' do
it 'has text' do
- render partial: 'shared/ssh_keys/key_delete', formats: :html, locals: { text: 'Button', html_class: '', button_data: '' }
+ render partial: 'shared/ssh_keys/key_delete', formats: :html, locals: { icon: true, button_data: '' }
- expect(rendered).to have_button('Button')
+ expect(rendered).not_to have_button('Delete')
+ expect(rendered).to have_selector('[data-testid=remove-icon]')
end
end
- context 'when the text parameter is not used' do
+ context 'when the icon parameter is not used' do
it 'does not have text' do
- render partial: 'shared/ssh_keys/key_delete', formats: :html, locals: { html_class: '', button_data: '' }
+ render partial: 'shared/ssh_keys/key_delete', formats: :html, locals: { button_data: '' }
expect(rendered).to have_button('Delete')
+ expect(rendered).not_to have_selector('[data-testid=remove-icon]')
end
end
end