summaryrefslogtreecommitdiff
path: root/spec/views
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
committerRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
commit6438df3a1e0fb944485cebf07976160184697d72 (patch)
tree00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /spec/views
parent42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff)
downloadgitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'spec/views')
-rw-r--r--spec/views/layouts/_head.html.haml_spec.rb2
-rw-r--r--spec/views/layouts/header/_new_dropdown.haml_spec.rb111
-rw-r--r--spec/views/notify/pipeline_failed_email.html.haml_spec.rb2
-rw-r--r--spec/views/notify/pipeline_failed_email.text.erb_spec.rb2
-rw-r--r--spec/views/notify/pipeline_fixed_email.html.haml_spec.rb2
-rw-r--r--spec/views/notify/pipeline_fixed_email.text.erb_spec.rb2
-rw-r--r--spec/views/notify/pipeline_success_email.html.haml_spec.rb2
-rw-r--r--spec/views/notify/pipeline_success_email.text.erb_spec.rb2
-rw-r--r--spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb4
-rw-r--r--spec/views/projects/settings/operations/show.html.haml_spec.rb51
-rw-r--r--spec/views/shared/wikis/_sidebar.html.haml_spec.rb24
11 files changed, 154 insertions, 50 deletions
diff --git a/spec/views/layouts/_head.html.haml_spec.rb b/spec/views/layouts/_head.html.haml_spec.rb
index d8748873f64..15fdfaaaa65 100644
--- a/spec/views/layouts/_head.html.haml_spec.rb
+++ b/spec/views/layouts/_head.html.haml_spec.rb
@@ -59,7 +59,7 @@ RSpec.describe 'layouts/_head' do
render
- expect(rendered).to match('<link rel="stylesheet" media="all" href="/stylesheets/highlight/themes/solarised-light.css" />')
+ expect(rendered).to match('<link rel="stylesheet" media="print" href="/stylesheets/highlight/themes/solarised-light.css" />')
end
context 'when an asset_host is set and snowplow url is set' do
diff --git a/spec/views/layouts/header/_new_dropdown.haml_spec.rb b/spec/views/layouts/header/_new_dropdown.haml_spec.rb
index cf33ec9884b..01892e72c97 100644
--- a/spec/views/layouts/header/_new_dropdown.haml_spec.rb
+++ b/spec/views/layouts/header/_new_dropdown.haml_spec.rb
@@ -3,10 +3,42 @@
require 'spec_helper'
RSpec.describe 'layouts/header/_new_dropdown' do
- let(:user) { create(:user) }
+ let_it_be(:user) { create(:user) }
+
+ shared_examples_for 'invite member quick link' do
+ context 'when an experiment is active' do
+ before do
+ allow(Gitlab::Experimentation).to receive(:active?).and_return(true)
+ allow(view).to receive(:experiment_tracking_category_and_group)
+ allow(view).to receive(:tracking_label).with(user)
+ end
+
+ context 'with ability to invite members' do
+ it { is_expected.to have_link('Invite members', href: href) }
+
+ it 'records the experiment' do
+ subject
+
+ expect(view).to have_received(:experiment_tracking_category_and_group)
+ .with(:invite_members_new_dropdown, subject: user)
+ expect(view).to have_received(:tracking_label).with(user)
+ end
+ end
+
+ context 'without ability to invite members' do
+ let(:invite_member) { false }
+
+ it { is_expected.not_to have_link('Invite members') }
+ end
+ end
+
+ context 'when experiment is not active' do
+ it { is_expected.not_to have_link('Invite members') }
+ end
+ end
context 'group-specific links' do
- let(:group) { create(:group) }
+ let_it_be(:group) { create(:group) }
before do
stub_current_user(user)
@@ -22,25 +54,39 @@ RSpec.describe 'layouts/header/_new_dropdown' do
it 'has a "New project" link' do
render
- expect(rendered).to have_link(
- 'New project',
- href: new_project_path(namespace_id: group.id)
- )
+ expect(rendered).to have_link('New project', href: new_project_path(namespace_id: group.id))
end
it 'has a "New subgroup" link' do
render
- expect(rendered).to have_link(
- 'New subgroup',
- href: new_group_path(parent_id: group.id)
- )
+ expect(rendered).to have_link('New subgroup', href: new_group_path(parent_id: group.id))
end
end
+
+ describe 'invite members quick link' do
+ let(:href) { group_group_members_path(group) }
+ let(:invite_member) { true }
+
+ before do
+ allow(view).to receive(:can?).with(user, :create_projects, group).and_return(true)
+ allow(view).to receive(:can?).with(user, :admin_group_member, group).and_return(invite_member)
+ allow(view).to receive(:can_import_members?).and_return(invite_member)
+ allow(view).to receive(:experiment_enabled?)
+ end
+
+ subject do
+ render
+
+ rendered
+ end
+
+ it_behaves_like 'invite member quick link'
+ end
end
context 'project-specific links' do
- let(:project) { create(:project, creator: user, namespace: user.namespace) }
+ let_it_be(:project) { create(:project, creator: user, namespace: user.namespace) }
before do
assign(:project, project)
@@ -54,33 +100,24 @@ RSpec.describe 'layouts/header/_new_dropdown' do
it 'has a "New issue" link' do
render
- expect(rendered).to have_link(
- 'New issue',
- href: new_project_issue_path(project)
- )
+ expect(rendered).to have_link('New issue', href: new_project_issue_path(project))
end
it 'has a "New merge request" link' do
render
- expect(rendered).to have_link(
- 'New merge request',
- href: project_new_merge_request_path(project)
- )
+ expect(rendered).to have_link('New merge request', href: project_new_merge_request_path(project))
end
it 'has a "New snippet" link' do
render
- expect(rendered).to have_link(
- 'New snippet',
- href: new_project_snippet_path(project)
- )
+ expect(rendered).to have_link('New snippet', href: new_project_snippet_path(project))
end
end
context 'as a Project guest' do
- let(:guest) { create(:user) }
+ let_it_be(:guest) { create(:user) }
before do
stub_current_user(guest)
@@ -96,12 +133,28 @@ RSpec.describe 'layouts/header/_new_dropdown' do
it 'has no "New snippet" link' do
render
- expect(rendered).not_to have_link(
- 'New snippet',
- href: new_project_snippet_path(project)
- )
+ expect(rendered).not_to have_link('New snippet', href: new_project_snippet_path(project))
end
end
+
+ describe 'invite members quick link' do
+ let(:invite_member) { true }
+ let(:href) { project_project_members_path(project) }
+
+ before do
+ allow(view).to receive(:can_import_members?).and_return(invite_member)
+ stub_current_user(user)
+ allow(view).to receive(:experiment_enabled?)
+ end
+
+ subject do
+ render
+
+ rendered
+ end
+
+ it_behaves_like 'invite member quick link'
+ end
end
context 'global links' do
@@ -128,7 +181,7 @@ RSpec.describe 'layouts/header/_new_dropdown' do
end
context 'when the user is not allowed to create snippets' do
- let(:user) { create(:user, :external)}
+ let(:user) { create(:user, :external) }
it 'has no "New snippet" link' do
render
diff --git a/spec/views/notify/pipeline_failed_email.html.haml_spec.rb b/spec/views/notify/pipeline_failed_email.html.haml_spec.rb
index b41933f9c36..defd8190eda 100644
--- a/spec/views/notify/pipeline_failed_email.html.haml_spec.rb
+++ b/spec/views/notify/pipeline_failed_email.html.haml_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe 'notify/pipeline_failed_email.html.haml' do
it_behaves_like 'pipeline status changes email' do
- let(:title) { 'Your pipeline has failed' }
+ let(:title) { "Pipeline ##{pipeline.id} has failed!" }
let(:status) { :failed }
end
end
diff --git a/spec/views/notify/pipeline_failed_email.text.erb_spec.rb b/spec/views/notify/pipeline_failed_email.text.erb_spec.rb
index a5c31632b0d..dd637af5137 100644
--- a/spec/views/notify/pipeline_failed_email.text.erb_spec.rb
+++ b/spec/views/notify/pipeline_failed_email.text.erb_spec.rb
@@ -27,7 +27,7 @@ RSpec.describe 'notify/pipeline_failed_email.text.erb' do
it 'renders the email correctly' do
render
- expect(rendered).to have_content('Your pipeline has failed')
+ expect(rendered).to have_content("Pipeline ##{pipeline.id} has failed!")
expect(rendered).to have_content(pipeline.project.name)
expect(rendered).to have_content(pipeline.git_commit_message.truncate(50).gsub(/\s+/, ' '))
expect(rendered).to have_content(pipeline.commit.author_name)
diff --git a/spec/views/notify/pipeline_fixed_email.html.haml_spec.rb b/spec/views/notify/pipeline_fixed_email.html.haml_spec.rb
index 2b3b08f8e8c..bdfc8fb5f6b 100644
--- a/spec/views/notify/pipeline_fixed_email.html.haml_spec.rb
+++ b/spec/views/notify/pipeline_fixed_email.html.haml_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe 'notify/pipeline_fixed_email.html.haml' do
it_behaves_like 'pipeline status changes email' do
- let(:title) { 'Your pipeline has been fixed!' }
+ let(:title) { "Pipeline has been fixed and ##{pipeline.id} has passed!" }
let(:status) { :success }
end
end
diff --git a/spec/views/notify/pipeline_fixed_email.text.erb_spec.rb b/spec/views/notify/pipeline_fixed_email.text.erb_spec.rb
index 8640998acaa..d0bc110f95c 100644
--- a/spec/views/notify/pipeline_fixed_email.text.erb_spec.rb
+++ b/spec/views/notify/pipeline_fixed_email.text.erb_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe 'notify/pipeline_fixed_email.text.erb' do
it_behaves_like 'pipeline status changes email' do
- let(:title) { 'Your pipeline has been fixed!' }
+ let(:title) { "Pipeline has been fixed and ##{pipeline.id} has passed!" }
let(:status) { :success }
end
end
diff --git a/spec/views/notify/pipeline_success_email.html.haml_spec.rb b/spec/views/notify/pipeline_success_email.html.haml_spec.rb
index 51ea7ef5066..ce03f672700 100644
--- a/spec/views/notify/pipeline_success_email.html.haml_spec.rb
+++ b/spec/views/notify/pipeline_success_email.html.haml_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe 'notify/pipeline_success_email.html.haml' do
it_behaves_like 'pipeline status changes email' do
- let(:title) { 'Your pipeline has passed' }
+ let(:title) { "Pipeline ##{pipeline.id} has passed!" }
let(:status) { :success }
end
end
diff --git a/spec/views/notify/pipeline_success_email.text.erb_spec.rb b/spec/views/notify/pipeline_success_email.text.erb_spec.rb
index 3acf4dd3e26..02334a48fa3 100644
--- a/spec/views/notify/pipeline_success_email.text.erb_spec.rb
+++ b/spec/views/notify/pipeline_success_email.text.erb_spec.rb
@@ -4,7 +4,7 @@ require 'spec_helper'
RSpec.describe 'notify/pipeline_success_email.text.erb' do
it_behaves_like 'pipeline status changes email' do
- let(:title) { 'Your pipeline has passed' }
+ let(:title) { "Pipeline ##{pipeline.id} has passed!" }
let(:status) { :success }
end
end
diff --git a/spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb b/spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb
index b3f59a59ac8..95c51be9867 100644
--- a/spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb
+++ b/spec/views/projects/settings/ci_cd/_autodevops_form.html.haml_spec.rb
@@ -13,7 +13,7 @@ RSpec.describe 'projects/settings/ci_cd/_autodevops_form' do
it 'shows a warning message about Kubernetes cluster' do
render
- expect(rendered).to have_text('Add a Kubernetes cluster integration with a domain or create an AUTO_DEVOPS_PLATFORM_TARGET CI variable')
+ expect(rendered).to have_text('Add a Kubernetes cluster integration with a domain, or create an AUTO_DEVOPS_PLATFORM_TARGET CI variable.')
end
context 'when the project has an available kubernetes cluster' do
@@ -28,7 +28,7 @@ RSpec.describe 'projects/settings/ci_cd/_autodevops_form' do
it 'shows a warning message about base domain' do
render
- expect(rendered).to have_text('You must add a base domain to your Kubernetes cluster in order for your deployment strategy to work.')
+ expect(rendered).to have_text('Add a base domain to your Kubernetes cluster for your deployment strategy to work.')
end
end
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 facb4e2016d..a22853d40d8 100644
--- a/spec/views/projects/settings/operations/show.html.haml_spec.rb
+++ b/spec/views/projects/settings/operations/show.html.haml_spec.rb
@@ -15,14 +15,6 @@ RSpec.describe 'projects/settings/operations/show' do
end
let_it_be(:prometheus_service) { create(:prometheus_service, project: project) }
- let_it_be(:alerts_service) { create(:alerts_service, project: project) }
-
- let(:operations_show_locals) do
- {
- prometheus_service: prometheus_service,
- alerts_service: alerts_service
- }
- end
before_all do
project.add_maintainer(user)
@@ -35,13 +27,24 @@ 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(:current_user).and_return(user)
end
+ describe 'Operations > Alerts' do
+ it 'renders the Operations Settings page' do
+ render
+
+ expect(rendered).to have_content _('Alerts')
+ expect(rendered).to have_content _('Display alerts from all your monitoring tools directly within GitLab.')
+ end
+ end
+
describe 'Operations > Error Tracking' do
context 'Settings page ' do
it 'renders the Operations Settings page' do
- render template: 'projects/settings/operations/show', locals: operations_show_locals
+ render
expect(rendered).to have_content _('Error tracking')
expect(rendered).to have_content _('To link Sentry to GitLab, enter your Sentry URL and Auth Token')
@@ -49,10 +52,34 @@ RSpec.describe 'projects/settings/operations/show' do
end
end
+ describe 'Operations > Prometheus' do
+ context 'when settings_operations_prometheus_service flag is enabled' do
+ it 'renders the Operations Settings page' do
+ render
+
+ expect(rendered).to have_content _('Prometheus')
+ expect(rendered).to have_content _('Link Prometheus monitoring to GitLab.')
+ expect(rendered).to have_content _('To enable the installation of Prometheus on your clusters, deactivate the manual configuration below')
+ end
+ end
+
+ context 'when settings_operations_prometheus_service is disabled' do
+ before do
+ stub_feature_flags(settings_operations_prometheus_service: false)
+ end
+
+ it 'renders the Operations Settings page' do
+ render
+
+ expect(rendered).not_to have_content _('Select the Active checkbox to override the Auto Configuration with custom settings. If unchecked, Auto Configuration settings are used.')
+ end
+ end
+ end
+
describe 'Operations > Tracing' do
context 'with project.tracing_external_url' do
it 'links to project.tracing_external_url' do
- render template: 'projects/settings/operations/show', locals: operations_show_locals
+ render
expect(rendered).to have_link('Tracing', href: tracing_setting.external_url)
end
@@ -66,7 +93,7 @@ RSpec.describe 'projects/settings/operations/show' do
end
it 'sanitizes external_url' do
- render template: 'projects/settings/operations/show', locals: operations_show_locals
+ render
expect(tracing_setting.external_url).to eq(malicious_tracing_url)
expect(rendered).to have_link('Tracing', href: cleaned_url)
@@ -82,7 +109,7 @@ RSpec.describe 'projects/settings/operations/show' do
end
it 'links to Tracing page' do
- render template: 'projects/settings/operations/show', locals: operations_show_locals
+ render
expect(rendered).to have_link('Tracing', href: project_tracing_path(project))
end
diff --git a/spec/views/shared/wikis/_sidebar.html.haml_spec.rb b/spec/views/shared/wikis/_sidebar.html.haml_spec.rb
index 3e691862937..70991369506 100644
--- a/spec/views/shared/wikis/_sidebar.html.haml_spec.rb
+++ b/spec/views/shared/wikis/_sidebar.html.haml_spec.rb
@@ -80,4 +80,28 @@ RSpec.describe 'shared/wikis/_sidebar.html.haml' do
end
end
end
+
+ describe 'link to edit the sidebar' do
+ before do
+ allow(view).to receive(:can?).with(anything, :create_wiki, anything).and_return(can_edit)
+
+ render
+ end
+
+ context 'when the user has edit permission' do
+ let(:can_edit) { true }
+
+ it 'renders the link' do
+ expect(rendered).to have_link('Edit sidebar', href: wiki_page_path(wiki, Wiki::SIDEBAR, action: :edit))
+ end
+ end
+
+ context 'when the user does not have edit permission' do
+ let(:can_edit) { false }
+
+ it 'does not render the link' do
+ expect(rendered).not_to have_link('Edit sidebar')
+ end
+ end
+ end
end