summaryrefslogtreecommitdiff
path: root/spec/views
diff options
context:
space:
mode:
Diffstat (limited to 'spec/views')
-rw-r--r--spec/views/admin/application_settings/_eks.html.haml_spec.rb1
-rw-r--r--spec/views/admin/application_settings/_package_registry.html.haml_spec.rb1
-rw-r--r--spec/views/admin/application_settings/ci_cd.html.haml_spec.rb56
-rw-r--r--spec/views/admin/application_settings/repository.html.haml_spec.rb2
-rw-r--r--spec/views/devise/sessions/new.html.haml_spec.rb26
-rw-r--r--spec/views/groups/_home_panel.html.haml_spec.rb26
-rw-r--r--spec/views/groups/runners/_group_runners.html.haml_spec.rb43
-rw-r--r--spec/views/groups/settings/_transfer.html.haml_spec.rb17
-rw-r--r--spec/views/help/show.html.haml_spec.rb2
-rw-r--r--spec/views/layouts/_head.html.haml_spec.rb2
-rw-r--r--spec/views/layouts/_search.html.haml_spec.rb9
-rw-r--r--spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb51
-rw-r--r--spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb347
-rw-r--r--spec/views/projects/_flash_messages.html.haml_spec.rb69
-rw-r--r--spec/views/projects/_home_panel.html.haml_spec.rb32
-rw-r--r--spec/views/projects/empty.html.haml_spec.rb1
-rw-r--r--spec/views/projects/pipelines/show.html.haml_spec.rb1
-rw-r--r--spec/views/projects/runners/_specific_runners.html.haml_spec.rb43
-rw-r--r--spec/views/projects/services/_form.haml_spec.rb2
-rw-r--r--spec/views/projects/settings/operations/show.html.haml_spec.rb6
-rw-r--r--spec/views/search/_results.html.haml_spec.rb3
-rw-r--r--spec/views/shared/_global_alert.html.haml_spec.rb85
-rw-r--r--spec/views/shared/_label_row.html.haml_spec.rb3
-rw-r--r--spec/views/shared/milestones/_top.html.haml_spec.rb1
24 files changed, 427 insertions, 402 deletions
diff --git a/spec/views/admin/application_settings/_eks.html.haml_spec.rb b/spec/views/admin/application_settings/_eks.html.haml_spec.rb
index 2f45eaadc9f..e407970c7a4 100644
--- a/spec/views/admin/application_settings/_eks.html.haml_spec.rb
+++ b/spec/views/admin/application_settings/_eks.html.haml_spec.rb
@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe 'admin/application_settings/_eks' do
let_it_be(:admin) { create(:admin) }
+
let(:page) { Capybara::Node::Simple.new(rendered) }
before do
diff --git a/spec/views/admin/application_settings/_package_registry.html.haml_spec.rb b/spec/views/admin/application_settings/_package_registry.html.haml_spec.rb
index e0aa2fc8d56..72e32643a49 100644
--- a/spec/views/admin/application_settings/_package_registry.html.haml_spec.rb
+++ b/spec/views/admin/application_settings/_package_registry.html.haml_spec.rb
@@ -6,6 +6,7 @@ RSpec.describe 'admin/application_settings/_package_registry' do
let_it_be(:admin) { create(:admin) }
let_it_be(:default_plan_limits) { create(:plan_limits, :default_plan, :with_package_file_sizes) }
let_it_be(:application_setting) { build(:application_setting) }
+
let(:page) { Capybara::Node::Simple.new(rendered) }
before do
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..4d40bf5671e
--- /dev/null
+++ b/spec/views/admin/application_settings/ci_cd.html.haml_spec.rb
@@ -0,0 +1,56 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'admin/application_settings/ci_cd.html.haml' do
+ let_it_be(:app_settings) { build(:application_setting) }
+ let_it_be(:user) { create(:admin) }
+
+ let_it_be(:default_plan_limits) { create(:plan_limits, :default_plan, :with_package_file_sizes) }
+
+ before do
+ assign(:application_setting, app_settings)
+ assign(:plans, [default_plan_limits.plan])
+ allow(view).to receive(:current_user).and_return(user)
+ end
+
+ describe 'CI CD Runner Registration' do
+ context 'when feature flag is enabled' do
+ before do
+ stub_feature_flags(runner_registration_control: true)
+ end
+
+ it 'has the setting section' do
+ render
+
+ expect(rendered).to have_css("#js-runner-settings")
+ end
+
+ it 'renders the correct setting section content' do
+ render
+
+ expect(rendered).to have_content("Runner registration")
+ expect(rendered).to have_content("If no options are selected, only administrators can register runners.")
+ end
+ end
+
+ context 'when feature flag is disabled' do
+ before do
+ stub_feature_flags(runner_registration_control: false)
+ end
+
+ it 'does not have the setting section' do
+ render
+
+ expect(rendered).not_to have_css("#js-runner-settings")
+ end
+
+ it 'does not render the correct setting section content' do
+ render
+
+ expect(rendered).not_to have_content("Runner registration")
+ expect(rendered).not_to have_content("If no options are selected, only administrators can register runners.")
+ end
+ end
+ end
+end
diff --git a/spec/views/admin/application_settings/repository.html.haml_spec.rb b/spec/views/admin/application_settings/repository.html.haml_spec.rb
index 47cadd29e33..30047878b0f 100644
--- a/spec/views/admin/application_settings/repository.html.haml_spec.rb
+++ b/spec/views/admin/application_settings/repository.html.haml_spec.rb
@@ -22,7 +22,7 @@ RSpec.describe 'admin/application_settings/repository.html.haml' do
render
expect(rendered).to have_content("Default initial branch name")
- expect(rendered).to have_content("Set the default name of the initial branch when creating new repositories through the user interface.")
+ expect(rendered).to have_content("The default name for the initial branch of new repositories created in the instance.")
end
end
end
diff --git a/spec/views/devise/sessions/new.html.haml_spec.rb b/spec/views/devise/sessions/new.html.haml_spec.rb
index b5c69f4f04d..d3552bf2e5a 100644
--- a/spec/views/devise/sessions/new.html.haml_spec.rb
+++ b/spec/views/devise/sessions/new.html.haml_spec.rb
@@ -3,6 +3,32 @@
require 'spec_helper'
RSpec.describe 'devise/sessions/new' do
+ describe 'marketing text' do
+ subject { render(template: 'devise/sessions/new', layout: 'layouts/devise') }
+
+ before do
+ stub_devise
+ disable_captcha
+ allow(Gitlab).to receive(:dev_env_or_com?).and_return(true)
+ end
+
+ it 'when flash is anything it renders marketing text' do
+ flash[:notice] = "You can't do that"
+
+ subject
+
+ expect(rendered).to have_content('A complete DevOps platform')
+ end
+
+ it 'when flash notice is devise confirmed message it hides marketing text' do
+ flash[:notice] = t(:confirmed, scope: [:devise, :confirmations])
+
+ subject
+
+ expect(rendered).not_to have_content('A complete DevOps platform')
+ end
+ end
+
describe 'ldap' do
include LdapHelpers
diff --git a/spec/views/groups/_home_panel.html.haml_spec.rb b/spec/views/groups/_home_panel.html.haml_spec.rb
index b8168b20450..e76862cdaea 100644
--- a/spec/views/groups/_home_panel.html.haml_spec.rb
+++ b/spec/views/groups/_home_panel.html.haml_spec.rb
@@ -14,4 +14,30 @@ RSpec.describe 'groups/_home_panel' do
expect(rendered).to have_content("Group ID: #{group.id}")
end
+
+ context 'admin area link' do
+ it 'renders admin area link for admin' do
+ allow(view).to receive(:current_user).and_return(create(:admin))
+
+ render
+
+ expect(rendered).to have_link(href: admin_group_path(group))
+ end
+
+ it 'does not render admin area link for non-admin' do
+ allow(view).to receive(:current_user).and_return(create(:user))
+
+ render
+
+ expect(rendered).not_to have_link(href: admin_group_path(group))
+ end
+
+ it 'does not render admin area link for anonymous' do
+ allow(view).to receive(:current_user).and_return(nil)
+
+ render
+
+ expect(rendered).not_to have_link(href: admin_group_path(group))
+ end
+ end
end
diff --git a/spec/views/groups/runners/_group_runners.html.haml_spec.rb b/spec/views/groups/runners/_group_runners.html.haml_spec.rb
new file mode 100644
index 00000000000..0d47409c658
--- /dev/null
+++ b/spec/views/groups/runners/_group_runners.html.haml_spec.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'groups/runners/group_runners.html.haml' do
+ describe 'render' do
+ let_it_be(:user) { create(:user) }
+ let_it_be(:group) { create(:group) }
+
+ before do
+ @group = group
+ allow(view).to receive(:current_user).and_return(user)
+ allow(view).to receive(:reset_registration_token_group_settings_ci_cd_path).and_return('banana_url')
+ allow(view).to receive(:can?).with(user, :admin_pipeline, group).and_return(true)
+ end
+
+ context 'when group runner registration is allowed' do
+ before do
+ stub_application_setting(valid_runner_registrars: ['group'])
+ end
+
+ it 'enables the Remove group button for a group' do
+ render 'groups/runners/group_runners', group: group
+
+ expect(rendered).to have_selector '#js-install-runner'
+ expect(rendered).not_to have_content 'Please contact an admin to register runners.'
+ end
+ end
+
+ context 'when group runner registration is not allowed' do
+ before do
+ stub_application_setting(valid_runner_registrars: ['project'])
+ end
+
+ it 'does not enable the the Remove group button for a group' do
+ render 'groups/runners/group_runners', group: group
+
+ expect(rendered).to have_content 'Please contact an admin to register runners.'
+ expect(rendered).not_to have_selector '#js-install-runner'
+ end
+ end
+ end
+end
diff --git a/spec/views/groups/settings/_transfer.html.haml_spec.rb b/spec/views/groups/settings/_transfer.html.haml_spec.rb
new file mode 100644
index 00000000000..aeb70251a62
--- /dev/null
+++ b/spec/views/groups/settings/_transfer.html.haml_spec.rb
@@ -0,0 +1,17 @@
+# 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_selector '[data-qa-selector="select_group_dropdown"]'
+ expect(rendered).not_to have_selector '[data-qa-selector="select_group_dropdown"][disabled]'
+ expect(rendered).not_to have_selector '[data-testid="group-to-transfer-has-linked-subscription-alert"]'
+ end
+ end
+end
diff --git a/spec/views/help/show.html.haml_spec.rb b/spec/views/help/show.html.haml_spec.rb
index ab303919673..dc73b4a2cfe 100644
--- a/spec/views/help/show.html.haml_spec.rb
+++ b/spec/views/help/show.html.haml_spec.rb
@@ -5,7 +5,7 @@ require 'spec_helper'
RSpec.describe 'help/show' do
describe 'Markdown rendering' do
before do
- assign(:path, 'ssh/README')
+ assign(:path, 'ssh/index')
assign(:markdown, 'Welcome to [GitLab](https://about.gitlab.com/) Documentation.')
end
diff --git a/spec/views/layouts/_head.html.haml_spec.rb b/spec/views/layouts/_head.html.haml_spec.rb
index 6752bdc8337..2c7289deaef 100644
--- a/spec/views/layouts/_head.html.haml_spec.rb
+++ b/spec/views/layouts/_head.html.haml_spec.rb
@@ -100,7 +100,7 @@ RSpec.describe 'layouts/_head' do
it 'add a Matomo Javascript' do
render
- expect(rendered).to match(/<script.*>.*var u="\/\/#{matomo_host}\/".*<\/script>/m)
+ expect(rendered).to match(%r{<script.*>.*var u="//#{matomo_host}/".*</script>}m)
expect(rendered).to match(%r(<noscript>.*<img src="//#{matomo_host}/matomo.php.*</noscript>))
expect(rendered).not_to include('_paq.push(["disableCookies"])')
end
diff --git a/spec/views/layouts/_search.html.haml_spec.rb b/spec/views/layouts/_search.html.haml_spec.rb
index f0c7cb57b25..ceb82e3640e 100644
--- a/spec/views/layouts/_search.html.haml_spec.rb
+++ b/spec/views/layouts/_search.html.haml_spec.rb
@@ -25,6 +25,15 @@ RSpec.describe 'layouts/_search' do
end
shared_examples 'search context scope is set' do
+ context 'when rendering' do
+ it 'sets the placeholder' do
+ render
+
+ expect(rendered).to include('placeholder="Search GitLab"')
+ expect(rendered).to include('aria-label="Search GitLab"')
+ end
+ end
+
context 'when on issues' do
it 'sets scope to issues' do
render
diff --git a/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb
index 50390964e1b..7df076d35c4 100644
--- a/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb
+++ b/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb
@@ -27,62 +27,11 @@ RSpec.describe 'layouts/nav/sidebar/_group' do
expect(rendered).to have_link('Group information', href: activity_group_path(group))
end
- it 'does not have a link to the details menu item' do
- render
-
- expect(rendered).not_to have_link('Details', href: details_group_path(group))
- end
-
it 'has a link to the members page' do
render
expect(rendered).to have_selector('.sidebar-top-level-items > li.home a[title="Members"]')
expect(rendered).to have_link('Members', href: group_group_members_path(group))
end
-
- context 'when feature flag :sidebar_refactor is disabled' do
- before do
- stub_feature_flags(sidebar_refactor: false)
- end
-
- it 'has a link to the group path with the "Group overview" title' do
- render
-
- expect(rendered).to have_link('Group overview', href: group_path(group))
- end
-
- it 'has a link to the details menu item' do
- render
-
- expect(rendered).to have_link('Details', href: details_group_path(group))
- end
-
- it 'does not have a link to the members page' do
- render
-
- expect(rendered).not_to have_selector('.sidebar-top-level-items > li.home a[title="Members"]')
- end
- end
- end
-
- describe 'Members' do
- it 'does not have a Members menu' do
- render
-
- expect(rendered).not_to have_selector('.nav-item-name', text: 'Members')
- end
-
- context 'when feature flag :sidebar_refactor is disabled' do
- before do
- stub_feature_flags(sidebar_refactor: false)
- end
-
- it 'has a Member menu' do
- render
-
- expect(rendered).to have_selector('.nav-item-name', text: 'Members')
- expect(rendered).to have_link('Members', href: group_group_members_path(group))
- end
- 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 a1aa7c04b67..f2de43dfd19 100644
--- a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
+++ b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
@@ -36,38 +36,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
expect(rendered).to have_selector('[aria-label="Project information"]')
end
- context 'when feature flag :sidebar_refactor is disabled' do
- before do
- stub_feature_flags(sidebar_refactor: false)
- end
-
- it 'has a link to the project path' do
- render
-
- expect(rendered).to have_link('Project overview', href: project_path(project), class: %w(shortcuts-project))
- expect(rendered).to have_selector('[aria-label="Project overview"]')
- end
- end
-
- describe 'Details' do
- it 'does not have a link to the details menu' do
- render
-
- expect(rendered).not_to have_link('Details', href: project_path(project))
- end
-
- context 'when feature flag :sidebar_refactor is disabled' do
- it 'has a link to the projects path' do
- stub_feature_flags(sidebar_refactor: false)
-
- render
-
- expect(rendered).to have_link('Details', href: project_path(project), class: 'shortcuts-project')
- expect(rendered).to have_selector('[aria-label="Project details"]')
- end
- end
- end
-
describe 'Activity' do
it 'has a link to the project activity path' do
render
@@ -76,24 +44,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
end
- describe 'Releases' do
- it 'does not have a link to the project releases path' do
- render
-
- expect(rendered).not_to have_link('Releases', href: project_releases_path(project), class: 'shortcuts-project-releases')
- end
-
- context 'when feature flag :sidebar refactor is disabled' do
- it 'has a link to the project releases path' do
- stub_feature_flags(sidebar_refactor: false)
-
- render
-
- expect(rendered).to have_link('Releases', href: project_releases_path(project), class: 'shortcuts-project-releases')
- end
- end
- end
-
describe 'Labels' do
let(:page) { Nokogiri::HTML.parse(rendered) }
@@ -103,16 +53,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
expect(page.at_css('.shortcuts-project-information').parent.css('[aria-label="Labels"]')).not_to be_empty
expect(rendered).to have_link('Labels', href: project_labels_path(project))
end
-
- context 'when feature flag :sidebar_refactor is disabled' do
- it 'does not have the labels menu item' do
- stub_feature_flags(sidebar_refactor: false)
-
- render
-
- expect(page.at_css('.shortcuts-project').parent.css('[aria-label="Labels"]')).to be_empty
- end
- end
end
describe 'Members' do
@@ -124,16 +64,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
expect(page.at_css('.shortcuts-project-information').parent.css('[aria-label="Members"]')).not_to be_empty
expect(rendered).to have_link('Members', href: project_project_members_path(project))
end
-
- context 'when feature flag :sidebar_refactor is disabled' do
- it 'does not have a link to the members page' do
- stub_feature_flags(sidebar_refactor: false)
-
- render
-
- expect(page.at_css('.shortcuts-project').parent.css('[aria-label="Members"]')).to be_empty
- end
- end
end
end
@@ -243,27 +173,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
end
- describe 'Labels' do
- let(:page) { Nokogiri::HTML.parse(rendered) }
-
- it 'does not have a link to the labels page' do
- render
-
- expect(page.at_css('.shortcuts-issues').parent.css('[aria-label="Labels"]')).to be_empty
- end
-
- context 'when feature flag :sidebar_refactor is disabled' do
- it 'has a link to the labels page' do
- stub_feature_flags(sidebar_refactor: false)
-
- render
-
- expect(page.at_css('.shortcuts-issues').parent.css('[aria-label="Labels"]')).not_to be_empty
- expect(rendered).to have_link('Labels', href: project_labels_path(project))
- end
- end
- end
-
describe 'Service Desk' do
it 'has a link to the service desk path' do
render
@@ -313,7 +222,7 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
context 'with Jira issue tracker' do
- let_it_be(:jira) { create(:jira_service, project: project, issues_enabled: false) }
+ let_it_be(:jira) { create(:jira_integration, project: project, issues_enabled: false) }
it 'has a link to the Jira issue tracker' do
render
@@ -323,40 +232,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
end
- describe 'Labels' do
- it 'does not show the labels menu' do
- project.project_feature.update!(issues_access_level: ProjectFeature::DISABLED)
-
- render
-
- expect(rendered).not_to have_link('Labels', href: project_labels_path(project), class: 'shortcuts-labels')
- end
-
- context 'when feature flag :sidebar_refactor is disabled' do
- before do
- stub_feature_flags(sidebar_refactor: false)
- end
-
- context 'when issues are not enabled' do
- it 'has a link to the labels path' do
- project.project_feature.update!(issues_access_level: ProjectFeature::DISABLED)
-
- render
-
- expect(rendered).to have_link('Labels', href: project_labels_path(project), class: 'shortcuts-labels')
- end
- end
-
- context 'when issues are enabled' do
- it 'does not have a link to the labels path' do
- render
-
- expect(rendered).not_to have_link('Labels', href: project_labels_path(project), class: 'shortcuts-labels')
- end
- end
- end
- end
-
describe 'Merge Requests' do
it 'has a link to the merge request list path' do
render
@@ -479,16 +354,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
expect(rendered).not_to have_link('Feature Flags')
end
end
-
- context 'when feature flag :sidebar_refactor is disabled' do
- it 'does not have a Feature Flags menu item' do
- stub_feature_flags(sidebar_refactor: false)
-
- render
-
- expect(rendered).not_to have_selector('.shortcuts-deployments')
- end
- end
end
describe 'Environments' do
@@ -508,16 +373,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
expect(rendered).not_to have_link('Environments')
end
end
-
- context 'when feature flag :sidebar_refactor is disabled' do
- it 'does not have a Environments menu item' do
- stub_feature_flags(sidebar_refactor: false)
-
- render
-
- expect(rendered).not_to have_selector('.shortcuts-deployments')
- end
- end
end
describe 'Releases' do
@@ -526,16 +381,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
expect(rendered).to have_link('Releases', href: project_releases_path(project), class: 'shortcuts-deployments-releases')
end
-
- context 'when feature flag :sidebar refactor is disabled' do
- it 'does not have a link to the project releases path' do
- stub_feature_flags(sidebar_refactor: false)
-
- render
-
- expect(rendered).not_to have_link('Releases', href: project_releases_path(project), class: 'shortcuts-deployments-releases')
- end
- end
end
end
@@ -662,141 +507,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
end
- context 'when feature flag :sidebar_refactor is disabled' do
- before do
- stub_feature_flags(sidebar_refactor: false)
- end
-
- describe 'Serverless' do
- it 'has a link to the serverless page' do
- render
-
- page = Nokogiri::HTML.parse(rendered)
-
- expect(page.at_css('.shortcuts-operations').parent.css('[aria-label="Serverless"]')).not_to be_empty
- expect(rendered).to have_link('Serverless', href: project_serverless_functions_path(project))
- end
-
- describe 'when the user does not have access' do
- let(:user) { nil }
-
- it 'does not have a link to the serverless page' do
- render
-
- expect(rendered).not_to have_link('Serverless')
- end
- end
- end
-
- describe 'Terraform' do
- it 'has a link to the terraform page' do
- render
-
- page = Nokogiri::HTML.parse(rendered)
-
- expect(page.at_css('.shortcuts-operations').parent.css('[aria-label="Terraform"]')).not_to be_empty
- expect(rendered).to have_link('Terraform', href: project_terraform_index_path(project))
- end
-
- describe 'when the user does not have access' do
- let(:user) { nil }
-
- it 'does not have a link to the terraform page' do
- render
-
- expect(rendered).not_to have_link('Terraform')
- end
- end
- end
-
- describe 'Kubernetes' do
- it 'has a link to the kubernetes page' do
- render
-
- page = Nokogiri::HTML.parse(rendered)
-
- expect(page.at_css('.shortcuts-operations').parent.css('[aria-label="Kubernetes"]')).not_to be_empty
- expect(rendered).to have_link('Kubernetes', href: project_clusters_path(project))
- end
-
- describe 'when the user does not have access' do
- let(:user) { nil }
-
- it 'does not have a link to the kubernetes page' do
- render
-
- expect(rendered).not_to have_link('Kubernetes')
- end
- end
- end
- end
-
- describe 'Environments' do
- let(:page) { Nokogiri::HTML.parse(rendered) }
-
- it 'does not have a link to the environments page' do
- render
-
- expect(page.at_css('.shortcuts-monitor').parent.css('[aria-label="Environments"]')).to be_empty
- end
-
- context 'when feature flag :sidebar_refactor is disabled' do
- before do
- stub_feature_flags(sidebar_refactor: false)
- end
-
- it 'has a link to the environments page' do
- render
-
- expect(page.at_css('.shortcuts-operations').parent.css('[aria-label="Environments"]')).not_to be_empty
- expect(rendered).to have_link('Environments', href: project_environments_path(project))
- end
-
- describe 'when the user does not have access' do
- let(:user) { nil }
-
- it 'does not have a link to the environments page' do
- render
-
- expect(rendered).not_to have_link('Environments')
- end
- end
- end
- end
-
- describe 'Feature Flags' do
- let(:page) { Nokogiri::HTML.parse(rendered) }
-
- it 'does not have a link to the feature flags page' do
- render
-
- expect(page.at_css('.shortcuts-monitor').parent.css('[aria-label="Feature Flags"]')).to be_empty
- end
-
- context 'when feature flag :sidebar_refactor is disabled' do
- before do
- stub_feature_flags(sidebar_refactor: false)
- end
-
- it 'has a link to the feature flags page' do
- render
-
- expect(page.at_css('.shortcuts-operations').parent.css('[aria-label="Feature Flags"]')).not_to be_empty
- expect(rendered).to have_link('Feature Flags', href: project_feature_flags_path(project))
- end
-
- describe 'when the user does not have access' do
- let(:user) { nil }
-
- it 'does not have a link to the feature flags page' do
- render
-
- expect(rendered).not_to have_link('Feature Flags')
- end
- end
- end
- end
-
describe 'Product Analytics' do
it 'has a link to the product analytics page' do
render
@@ -985,11 +695,11 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
end
- describe 'Value Stream' do
+ describe 'Value stream' do
it 'has a link to the value stream page' do
render
- expect(rendered).to have_link('Value Stream', href: project_cycle_analytics_path(project))
+ expect(rendered).to have_link('Value stream', href: project_cycle_analytics_path(project))
end
context 'when user does not have access' do
@@ -998,7 +708,7 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
it 'does not have a link to the value stream page' do
render
- expect(rendered).not_to have_link('Value Stream', href: project_cycle_analytics_path(project))
+ expect(rendered).not_to have_link('Value stream', href: project_cycle_analytics_path(project))
end
end
end
@@ -1104,35 +814,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
end
- describe 'Members' do
- it 'does not show the Member menu item' do
- expect(rendered).not_to have_selector('.sidebar-top-level-items > li > a[aria-label="Members"]')
- end
-
- context 'when feature flag :sidebar_refactor is disabled' do
- before do
- stub_feature_flags(sidebar_refactor: false)
-
- render
- end
-
- context 'when user can access members' do
- it 'show Members link' do
- expect(rendered).to have_selector('.sidebar-top-level-items > li > a[aria-label="Members"]')
- expect(rendered).to have_link('Members', href: project_project_members_path(project))
- end
- end
-
- context 'when user cannot access members' do
- let(:user) { nil }
-
- it 'show Members link' do
- expect(rendered).not_to have_link('Members')
- end
- end
- end
- end
-
describe 'Settings' do
describe 'General' do
it 'has a link to the General settings' do
@@ -1275,16 +956,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
expect(rendered).to have_link('Packages & Registries', href: project_settings_packages_and_registries_path(project))
end
-
- context 'when feature flag :sidebar_refactor is disabled' do
- it 'does not have a link to the Packages & Registries settings' do
- stub_feature_flags(sidebar_refactor: false)
-
- render
-
- expect(rendered).not_to have_link('Packages & Registries', href: project_settings_packages_and_registries_path(project))
- end
- end
end
context 'when registry is not enabled' do
@@ -1345,15 +1016,5 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
expect(rendered).not_to have_selector('.sidebar-sub-level-items > li.fly-out-top-item > a')
end
-
- context 'when feature flag :sidebar_refactor is disabled' do
- it 'renders the collapsed top menu as a link' do
- stub_feature_flags(sidebar_refactor: false)
-
- render
-
- expect(rendered).to have_selector('.sidebar-sub-level-items > li.fly-out-top-item > a')
- 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
new file mode 100644
index 00000000000..e1858229208
--- /dev/null
+++ b/spec/views/projects/_flash_messages.html.haml_spec.rb
@@ -0,0 +1,69 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'projects/_flash_messages' do
+ let_it_be(:template) { 'projects/flash_messages' }
+ let_it_be(:user) { create(:user) }
+
+ let_it_be(:ruby) { create(:programming_language, name: 'Ruby') }
+ let_it_be(:html) { create(:programming_language, name: 'HTML') }
+ let_it_be(:hcl) { create(:programming_language, name: 'HCL') }
+
+ before do
+ allow(view).to receive(:current_user).and_return(user)
+ allow(view).to receive(:can?).with(user, :download_code, project).and_return(true)
+ end
+
+ context 'when current_user has download_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) }
+
+ it "doesn't show the terraform notification banner" do
+ render(template, project: project)
+ expect(view.content_for(:flash_message)).not_to have_selector('.js-terraform-notification')
+ end
+ end
+
+ context 'when there are no .tf files in the repository' do
+ let_it_be(:project) { create(:project) }
+ let_it_be(:mock_repo_languages) do
+ { project => { ruby => 0.5, html => 0.5 } }
+ end
+
+ before do
+ mock_repo_languages.each do |project, lang_shares|
+ lang_shares.each do |lang, share|
+ create(:repository_language, project: project, programming_language: lang, share: share)
+ end
+ end
+ end
+
+ it "doesn't show the terraform notification banner" do
+ render(template, project: project)
+ expect(view.content_for(:flash_message)).not_to have_selector('.js-terraform-notification')
+ end
+ end
+
+ context 'when .tf files are present in the repository and user does not have any terraform states' do
+ let_it_be(:project) { create(:project) }
+ let_it_be(:mock_repo_languages) do
+ { project => { ruby => 0.5, hcl => 0.5 } }
+ end
+
+ before do
+ mock_repo_languages.each do |project, lang_shares|
+ lang_shares.each do |lang, share|
+ create(:repository_language, project: project, programming_language: lang, share: share)
+ end
+ end
+ end
+
+ it 'shows the terraform notification banner' do
+ render(template, project: project)
+ expect(view.content_for(:flash_message)).to have_selector('.js-terraform-notification')
+ end
+ end
+ end
+end
diff --git a/spec/views/projects/_home_panel.html.haml_spec.rb b/spec/views/projects/_home_panel.html.haml_spec.rb
index d329c57af00..78131937d3c 100644
--- a/spec/views/projects/_home_panel.html.haml_spec.rb
+++ b/spec/views/projects/_home_panel.html.haml_spec.rb
@@ -5,6 +5,38 @@ require 'spec_helper'
RSpec.describe 'projects/_home_panel' do
include ProjectForksHelper
+ context 'admin area link' do
+ let(:project) { create(:project) }
+
+ before do
+ assign(:project, project)
+ end
+
+ it 'renders admin area link for admin' do
+ allow(view).to receive(:current_user).and_return(create(:admin))
+
+ render
+
+ expect(rendered).to have_link(href: admin_project_path(project))
+ end
+
+ it 'does not render admin area link for non-admin' do
+ allow(view).to receive(:current_user).and_return(create(:user))
+
+ render
+
+ expect(rendered).not_to have_link(href: admin_project_path(project))
+ end
+
+ it 'does not render admin area link for anonymous' do
+ allow(view).to receive(:current_user).and_return(nil)
+
+ render
+
+ expect(rendered).not_to have_link(href: admin_project_path(project))
+ end
+ end
+
context 'notifications' do
let(:project) { create(:project) }
diff --git a/spec/views/projects/empty.html.haml_spec.rb b/spec/views/projects/empty.html.haml_spec.rb
index 7fa95507f75..0fb0ae5ff29 100644
--- a/spec/views/projects/empty.html.haml_spec.rb
+++ b/spec/views/projects/empty.html.haml_spec.rb
@@ -64,6 +64,7 @@ RSpec.describe 'projects/empty' do
expect(rendered).to have_selector('.js-invite-members-modal')
expect(rendered).to have_selector('[data-label=invite_members_empty_project]')
expect(rendered).to have_selector('[data-event=click_button]')
+ expect(rendered).to have_selector('[data-trigger-source=project-empty-page]')
end
context 'when user does not have permissions to invite members' do
diff --git a/spec/views/projects/pipelines/show.html.haml_spec.rb b/spec/views/projects/pipelines/show.html.haml_spec.rb
index 5b5c05527de..fcae587f8c8 100644
--- a/spec/views/projects/pipelines/show.html.haml_spec.rb
+++ b/spec/views/projects/pipelines/show.html.haml_spec.rb
@@ -6,6 +6,7 @@ RSpec.describe 'projects/pipelines/show' do
include Devise::Test::ControllerHelpers
let_it_be(:project) { create(:project, :repository) }
let_it_be(:user) { create(:user) }
+
let(:pipeline) { create(:ci_pipeline, project: project) }
let(:presented_pipeline) { pipeline.present(current_user: user) }
diff --git a/spec/views/projects/runners/_specific_runners.html.haml_spec.rb b/spec/views/projects/runners/_specific_runners.html.haml_spec.rb
new file mode 100644
index 00000000000..ace3502dd1e
--- /dev/null
+++ b/spec/views/projects/runners/_specific_runners.html.haml_spec.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'projects/runners/specific_runners.html.haml' do
+ describe 'render' do
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project) }
+
+ before do
+ @project = project
+ @assignable_runners = []
+ @project_runners = []
+ allow(view).to receive(:reset_registration_token_namespace_project_settings_ci_cd_path).and_return('banana_url')
+ end
+
+ context 'when project runner registration is allowed' do
+ before do
+ stub_application_setting(valid_runner_registrars: ['project'])
+ end
+
+ it 'enables the Remove project button for a project' do
+ render 'projects/runners/specific_runners', project: project
+
+ expect(rendered).to have_selector '#js-install-runner'
+ expect(rendered).not_to have_content 'Please contact an admin to register runners.'
+ end
+ end
+
+ context 'when project runner registration is not allowed' do
+ before do
+ stub_application_setting(valid_runner_registrars: ['group'])
+ end
+
+ it 'does not enable the the Remove project button for a project' do
+ render 'projects/runners/specific_runners', project: project
+
+ expect(rendered).to have_content 'Please contact an admin to register runners.'
+ expect(rendered).not_to have_selector '#js-install-runner'
+ end
+ end
+ end
+end
diff --git a/spec/views/projects/services/_form.haml_spec.rb b/spec/views/projects/services/_form.haml_spec.rb
index f063e73dae4..177f703ba6c 100644
--- a/spec/views/projects/services/_form.haml_spec.rb
+++ b/spec/views/projects/services/_form.haml_spec.rb
@@ -15,7 +15,7 @@ RSpec.describe 'projects/services/_form' do
current_user: user,
can?: true,
current_application_settings: Gitlab::CurrentSettings.current_application_settings,
- integration: project.redmine_service,
+ integration: project.redmine_integration,
request: double(referer: '/services')
)
end
diff --git a/spec/views/projects/settings/operations/show.html.haml_spec.rb b/spec/views/projects/settings/operations/show.html.haml_spec.rb
index 43c064e1a2b..c0ec86a41a7 100644
--- a/spec/views/projects/settings/operations/show.html.haml_spec.rb
+++ b/spec/views/projects/settings/operations/show.html.haml_spec.rb
@@ -14,7 +14,7 @@ RSpec.describe 'projects/settings/operations/show' do
create(:project_tracing_setting, project: project)
end
- let_it_be(:prometheus_service) { create(:prometheus_service, project: project) }
+ let_it_be(:prometheus_integration) { create(:prometheus_integration, project: project) }
before_all do
project.add_maintainer(user)
@@ -27,8 +27,8 @@ RSpec.describe 'projects/settings/operations/show' do
.and_return(error_tracking_setting)
allow(view).to receive(:tracing_setting)
.and_return(tracing_setting)
- allow(view).to receive(:prometheus_service)
- .and_return(prometheus_service)
+ allow(view).to receive(:prometheus_integration)
+ .and_return(prometheus_integration)
allow(view).to receive(:current_user).and_return(user)
end
diff --git a/spec/views/search/_results.html.haml_spec.rb b/spec/views/search/_results.html.haml_spec.rb
index 11f2a4082e7..ecfcf74edc1 100644
--- a/spec/views/search/_results.html.haml_spec.rb
+++ b/spec/views/search/_results.html.haml_spec.rb
@@ -32,6 +32,7 @@ RSpec.describe 'search/_results' do
let_it_be(:project) { create(:project) }
let_it_be(:issue) { create(:issue, project: project, title: '*') }
let_it_be(:note) { create(:discussion_note_on_issue, noteable: issue, project: issue.project, note: '```"helloworld"```') }
+
let(:scope) { 'notes' }
let(:search_objects) { Note.page(1).per(2) }
let(:term) { 'helloworld' }
@@ -61,7 +62,7 @@ RSpec.describe 'search/_results' do
let_it_be(:merge_request) { create(:merge_request, title: '*', source_project: project, target_project: project) }
let_it_be(:milestone) { create(:milestone, title: '*', project: project) }
let_it_be(:note) { create(:discussion_note_on_issue, project: project, note: '*') }
- let_it_be(:wiki_blob) { create(:wiki_page, project: project, content: '*') }
+ let_it_be(:wiki_blob) { create(:wiki_page, wiki: project.wiki, content: '*') }
let_it_be(:user) { create(:admin) }
%w[issues merge_requests].each do |search_scope|
diff --git a/spec/views/shared/_global_alert.html.haml_spec.rb b/spec/views/shared/_global_alert.html.haml_spec.rb
new file mode 100644
index 00000000000..7eec068645a
--- /dev/null
+++ b/spec/views/shared/_global_alert.html.haml_spec.rb
@@ -0,0 +1,85 @@
+# 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
+
+ context 'fixed layout' do
+ before 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
+
+ expect(rendered).to have_selector('.container-fluid.container-limited')
+ end
+
+ it 'does not add container classes if is_contained is true' do
+ render partial: 'shared/global_alert', locals: { is_contained: true }
+
+ expect(rendered).not_to have_selector('.container-fluid.container-limited')
+ end
+ end
+
+ context 'fluid layout' do
+ before do
+ allow(view).to receive(:fluid_layout).and_return(true)
+ 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
+ end
+end
diff --git a/spec/views/shared/_label_row.html.haml_spec.rb b/spec/views/shared/_label_row.html.haml_spec.rb
index e9a0bfdcd4e..6fe74b6633b 100644
--- a/spec/views/shared/_label_row.html.haml_spec.rb
+++ b/spec/views/shared/_label_row.html.haml_spec.rb
@@ -3,6 +3,7 @@ require 'spec_helper'
RSpec.describe 'shared/_label_row.html.haml' do
let_it_be(:group) { create(:group) }
+
let(:label) { build_stubbed(:group_label, group: group).present(issuable_subject: group) }
before do
@@ -11,6 +12,7 @@ RSpec.describe 'shared/_label_row.html.haml' do
context 'with a project context' do
let_it_be(:project) { create(:project, group: group) }
+
let(:label) { build_stubbed(:label, project: project).present(issuable_subject: project) }
before do
@@ -42,6 +44,7 @@ RSpec.describe 'shared/_label_row.html.haml' do
context 'with a subgroup context' do
let_it_be(:subgroup) { create(:group, parent: group) }
+
let(:label) { build_stubbed(:group_label, group: subgroup).present(issuable_subject: subgroup) }
before do
diff --git a/spec/views/shared/milestones/_top.html.haml_spec.rb b/spec/views/shared/milestones/_top.html.haml_spec.rb
index 1aa971709f1..aa989d3e441 100644
--- a/spec/views/shared/milestones/_top.html.haml_spec.rb
+++ b/spec/views/shared/milestones/_top.html.haml_spec.rb
@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe 'shared/milestones/_top.html.haml' do
let_it_be(:group) { create(:group) }
+
let(:project) { create(:project, group: group) }
let(:milestone) { create(:milestone, project: project) }