summaryrefslogtreecommitdiff
path: root/spec/views
diff options
context:
space:
mode:
Diffstat (limited to 'spec/views')
-rw-r--r--spec/views/admin/dashboard/index.html.haml_spec.rb2
-rw-r--r--spec/views/admin/services/index.html.haml_spec.rb30
-rw-r--r--spec/views/dashboard/projects/index.html.haml_spec.rb28
-rw-r--r--spec/views/groups/settings/_remove.html.haml_spec.rb17
-rw-r--r--spec/views/layouts/_search.html.haml_spec.rb68
-rw-r--r--spec/views/layouts/header/_new_dropdown.haml_spec.rb1
-rw-r--r--spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb1
-rw-r--r--spec/views/layouts/nav/sidebar/_profile.html.haml_spec.rb1
-rw-r--r--spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb132
-rw-r--r--spec/views/layouts/profile.html.haml_spec.rb19
-rw-r--r--spec/views/profiles/keys/_form.html.haml_spec.rb50
-rw-r--r--spec/views/profiles/keys/_key.html.haml_spec.rb123
-rw-r--r--spec/views/projects/commit/_commit_box.html.haml_spec.rb34
-rw-r--r--spec/views/projects/empty.html.haml_spec.rb10
-rw-r--r--spec/views/projects/pipelines/_stage.html.haml_spec.rb73
-rw-r--r--spec/views/projects/settings/operations/show.html.haml_spec.rb4
-rw-r--r--spec/views/projects/tags/index.html.haml_spec.rb1
-rw-r--r--spec/views/registrations/welcome/show.html.haml_spec.rb26
-rw-r--r--spec/views/search/_results.html.haml_spec.rb15
-rw-r--r--spec/views/shared/nav/_sidebar.html.haml_spec.rb44
-rw-r--r--spec/views/shared/runners/show.html.haml_spec.rb6
21 files changed, 510 insertions, 175 deletions
diff --git a/spec/views/admin/dashboard/index.html.haml_spec.rb b/spec/views/admin/dashboard/index.html.haml_spec.rb
index 5494b908705..6c7d8d2c165 100644
--- a/spec/views/admin/dashboard/index.html.haml_spec.rb
+++ b/spec/views/admin/dashboard/index.html.haml_spec.rb
@@ -29,7 +29,7 @@ RSpec.describe 'admin/dashboard/index.html.haml' do
it "includes revision of GitLab" do
render
- expect(rendered).to have_content "#{Gitlab::VERSION} (#{Gitlab.revision})"
+ expect(rendered).to have_content "#{Gitlab::VERSION} #{Gitlab.revision}"
end
it 'does not include license breakdown' do
diff --git a/spec/views/admin/services/index.html.haml_spec.rb b/spec/views/admin/services/index.html.haml_spec.rb
deleted file mode 100644
index e8cd2dde67e..00000000000
--- a/spec/views/admin/services/index.html.haml_spec.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe 'admin/services/index.html.haml' do
- before do
- assign(:services, build_stubbed_list(:service, 1))
- assign(:existing_instance_types, [])
- end
-
- context 'user has not dismissed Service Templates deprecation message' do
- it 'shows the message' do
- allow(view).to receive(:show_service_templates_deprecated?).and_return(true)
-
- render
-
- expect(rendered).to have_content('Service Templates will soon be deprecated.')
- end
- end
-
- context 'user has dismissed Service Templates deprecation message' do
- it 'does not show the message' do
- allow(view).to receive(:show_service_templates_deprecated?).and_return(false)
-
- render
-
- expect(rendered).not_to have_content('Service Templates will soon be deprecated.')
- end
- end
-end
diff --git a/spec/views/dashboard/projects/index.html.haml_spec.rb b/spec/views/dashboard/projects/index.html.haml_spec.rb
new file mode 100644
index 00000000000..72b5901d5e5
--- /dev/null
+++ b/spec/views/dashboard/projects/index.html.haml_spec.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'dashboard/projects/index.html.haml' do
+ let_it_be(:user) { build(:user) }
+
+ before do
+ allow(view).to receive(:limited_counter_with_delimiter)
+ allow(view).to receive(:current_user).and_return(user)
+ allow(view).to receive(:project_list_cache_key)
+ allow(view).to receive(:time_ago_with_tooltip)
+ allow(view).to receive(:project_icon)
+ assign(:projects, [build(:project, name: 'awesome stuff')])
+ end
+
+ it 'shows the project the user is a member of in the list' do
+ render
+
+ expect(rendered).to have_content('awesome stuff')
+ end
+
+ it 'shows the "New project" button' do
+ render
+
+ expect(rendered).to have_link('New project')
+ end
+end
diff --git a/spec/views/groups/settings/_remove.html.haml_spec.rb b/spec/views/groups/settings/_remove.html.haml_spec.rb
new file mode 100644
index 00000000000..07fe900bc2d
--- /dev/null
+++ b/spec/views/groups/settings/_remove.html.haml_spec.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'groups/settings/_remove.html.haml' do
+ describe 'render' do
+ it 'enables the Remove group button for a group' do
+ group = build(:group)
+
+ render 'groups/settings/remove', group: group
+
+ expect(rendered).to have_selector '[data-testid="remove-group-button"]'
+ expect(rendered).not_to have_selector '[data-testid="remove-group-button"].disabled'
+ expect(rendered).not_to have_selector '[data-testid="group-has-linked-subscription-alert"]'
+ end
+ end
+end
diff --git a/spec/views/layouts/_search.html.haml_spec.rb b/spec/views/layouts/_search.html.haml_spec.rb
new file mode 100644
index 00000000000..f0c7cb57b25
--- /dev/null
+++ b/spec/views/layouts/_search.html.haml_spec.rb
@@ -0,0 +1,68 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'layouts/_search' do
+ let(:group) { nil }
+ let(:project) { nil }
+ let(:scope) { 'issues' }
+ let(:search_context) do
+ instance_double(Gitlab::SearchContext,
+ project: project,
+ group: group,
+ scope: scope,
+ ref: nil,
+ snippets: [],
+ search_url: '/search',
+ project_metadata: {},
+ group_metadata: {})
+ end
+
+ before do
+ allow(view).to receive(:search_context).and_return(search_context)
+ allow(search_context).to receive(:code_search?).and_return(false)
+ allow(search_context).to receive(:for_snippets?).and_return(false)
+ end
+
+ shared_examples 'search context scope is set' do
+ context 'when on issues' do
+ it 'sets scope to issues' do
+ render
+
+ expect(rendered).to have_css("input[name='scope'][value='issues']", count: 1, visible: false)
+ end
+ end
+
+ context 'when on merge requests' do
+ let(:scope) { 'merge_requests' }
+
+ it 'sets scope to merge_requests' do
+ render
+
+ expect(rendered).to have_css("input[name='scope'][value='merge_requests']", count: 1, visible: false)
+ end
+ end
+ end
+
+ context 'when doing project level search' do
+ let(:project) { create(:project) }
+
+ before do
+ allow(search_context).to receive(:for_project?).and_return(true)
+ allow(search_context).to receive(:for_group?).and_return(false)
+ end
+
+ it_behaves_like 'search context scope is set'
+ end
+
+ context 'when doing group level search' do
+ let(:group) { create(:group) }
+
+ before do
+ allow(search_context).to receive(:for_project?).and_return(false)
+ allow(search_context).to receive(:for_group?).and_return(true)
+ end
+
+ it_behaves_like 'search context scope is set'
+ end
+end
diff --git a/spec/views/layouts/header/_new_dropdown.haml_spec.rb b/spec/views/layouts/header/_new_dropdown.haml_spec.rb
index 80342cbdb41..cec095f93ad 100644
--- a/spec/views/layouts/header/_new_dropdown.haml_spec.rb
+++ b/spec/views/layouts/header/_new_dropdown.haml_spec.rb
@@ -163,6 +163,7 @@ RSpec.describe 'layouts/header/_new_dropdown' do
end
it 'has a "New project" link' do
+ render('layouts/header/new_repo_experiment')
render
expect(rendered).to have_link('New project', href: new_project_path)
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 b3c8450fb48..640f463b45d 100644
--- a/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb
+++ b/spec/views/layouts/nav/sidebar/_group.html.haml_spec.rb
@@ -10,4 +10,5 @@ RSpec.describe 'layouts/nav/sidebar/_group' do
end
it_behaves_like 'has nav sidebar'
+ it_behaves_like 'sidebar includes snowplow attributes', 'render', 'groups_side_navigation', 'groups_side_navigation'
end
diff --git a/spec/views/layouts/nav/sidebar/_profile.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_profile.html.haml_spec.rb
index 0f6dcf8e57f..3d28be68b25 100644
--- a/spec/views/layouts/nav/sidebar/_profile.html.haml_spec.rb
+++ b/spec/views/layouts/nav/sidebar/_profile.html.haml_spec.rb
@@ -10,4 +10,5 @@ RSpec.describe 'layouts/nav/sidebar/_profile' do
end
it_behaves_like 'has nav sidebar'
+ it_behaves_like 'sidebar includes snowplow attributes', 'render', 'user_side_navigation', 'user_side_navigation'
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 99d7dfc8acb..bc5b3b7bfc6 100644
--- a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
+++ b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
@@ -5,16 +5,128 @@ require 'spec_helper'
RSpec.describe 'layouts/nav/sidebar/_project' do
let_it_be_with_reload(:project) { create(:project, :repository) }
+ let(:user) { project.owner }
+ let(:current_ref) { 'master' }
+
before do
assign(:project, project)
assign(:repository, project.repository)
- allow(view).to receive(:current_ref).and_return('master')
+ allow(view).to receive(:current_ref).and_return(current_ref)
allow(view).to receive(:can?).and_return(true)
+ allow(view).to receive(:current_user).and_return(user)
end
it_behaves_like 'has nav sidebar'
+ describe 'Project Overview' do
+ 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 rspec-project-link))
+ expect(rendered).to have_selector('[aria-label="Project overview"]')
+ end
+
+ describe 'Details' do
+ it 'has a link to the projects path' do
+ 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
+
+ describe 'Activity' do
+ it 'has a link to the project activity path' do
+ render
+
+ expect(rendered).to have_link('Activity', href: activity_project_path(project), class: 'shortcuts-project-activity')
+ end
+ end
+
+ describe 'Releases' do
+ it 'has a link to the project releases path' do
+ render
+
+ expect(rendered).to have_link('Releases', href: project_releases_path(project), class: 'shortcuts-project-releases')
+ end
+ end
+ end
+
+ describe 'Learn GitLab' do
+ it 'has a link to the learn GitLab experiment' do
+ allow(view).to receive(:learn_gitlab_experiment_enabled?).and_return(true)
+
+ render
+
+ expect(rendered).to have_link('Learn GitLab', href: project_learn_gitlab_path(project))
+ end
+ end
+
+ describe 'Repository' do
+ it 'has a link to the project tree path' do
+ render
+
+ expect(rendered).to have_link('Repository', href: project_tree_path(project, current_ref), class: 'shortcuts-tree')
+ end
+
+ describe 'Files' do
+ it 'has a link to the project tree path' do
+ render
+
+ expect(rendered).to have_link('Files', href: project_tree_path(project, current_ref))
+ end
+ end
+
+ describe 'Commits' do
+ 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
+
+ describe 'Branches' do
+ it 'has a link to the project branches path' do
+ render
+
+ expect(rendered).to have_link('Branches', href: project_branches_path(project), id: 'js-onboarding-branches-link')
+ end
+ end
+
+ describe 'Tags' do
+ it 'has a link to the project tags path' do
+ render
+
+ expect(rendered).to have_link('Tags', href: project_tags_path(project))
+ end
+ end
+
+ describe 'Contributors' 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))
+ end
+ end
+
+ describe 'Graph' do
+ it 'has a link to the project graph path' do
+ render
+
+ expect(rendered).to have_link('Graph', href: project_network_path(project, current_ref))
+ end
+ end
+
+ describe 'Compare' do
+ it 'has a link to the project compare path' do
+ render
+
+ expect(rendered).to have_link('Compare', href: project_compare_index_path(project, from: project.repository.root_ref, to: current_ref))
+ end
+ end
+ end
+
describe 'issue boards' do
it 'has board tab' do
render
@@ -99,19 +211,11 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
end
- describe 'releases entry' do
- it 'renders releases link' do
- render
-
- expect(rendered).to have_link('Releases', href: project_releases_path(project))
- end
- end
-
describe 'wiki entry tab' do
let(:can_read_wiki) { true }
before do
- allow(view).to receive(:can?).with(nil, :read_wiki, project).and_return(can_read_wiki)
+ allow(view).to receive(:can?).with(user, :read_wiki, project).and_return(can_read_wiki)
end
describe 'when wiki is enabled' do
@@ -146,7 +250,7 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
it 'shows the external wiki tab with the external wiki service link' do
render
- expect(rendered).to have_link('External Wiki', href: properties['external_wiki_url'])
+ expect(rendered).to have_link('External wiki', href: properties['external_wiki_url'])
end
end
@@ -156,7 +260,7 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
it 'does not show the external wiki tab' do
render
- expect(rendered).not_to have_link('External Wiki')
+ expect(rendered).not_to have_link('External wiki')
end
end
end
@@ -299,7 +403,7 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
let(:read_cycle_analytics) { true }
before do
- allow(view).to receive(:can?).with(nil, :read_cycle_analytics, project).and_return(read_cycle_analytics)
+ allow(view).to receive(:can?).with(user, :read_cycle_analytics, project).and_return(read_cycle_analytics)
end
describe 'when value stream analytics is enabled' do
@@ -346,4 +450,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
end
end
+
+ it_behaves_like 'sidebar includes snowplow attributes', 'render', 'projects_side_navigation', 'projects_side_navigation'
end
diff --git a/spec/views/layouts/profile.html.haml_spec.rb b/spec/views/layouts/profile.html.haml_spec.rb
index 93f8a075209..77474555771 100644
--- a/spec/views/layouts/profile.html.haml_spec.rb
+++ b/spec/views/layouts/profile.html.haml_spec.rb
@@ -19,21 +19,8 @@ RSpec.describe 'layouts/profile' do
.with({ locals: { container_class: 'gl-my-5' } })
end
- context 'when search_settings_in_page feature flag is on' do
- it 'displays the search settings entry point' do
- render
- expect(rendered).to include('js-search-settings-app')
- end
- end
-
- context 'when search_settings_in_page feature flag is off' do
- before do
- stub_feature_flags(search_settings_in_page: false)
- end
-
- it 'does not display the search settings entry point' do
- render
- expect(rendered).not_to include('js-search-settings-app')
- end
+ it 'displays the search settings entry point' do
+ render
+ expect(rendered).to include('js-search-settings-app')
end
end
diff --git a/spec/views/profiles/keys/_form.html.haml_spec.rb b/spec/views/profiles/keys/_form.html.haml_spec.rb
new file mode 100644
index 00000000000..62bb271bd9c
--- /dev/null
+++ b/spec/views/profiles/keys/_form.html.haml_spec.rb
@@ -0,0 +1,50 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'profiles/keys/_form.html.haml' do
+ let_it_be(:key) { Key.new }
+
+ let(:page) { Capybara::Node::Simple.new(rendered) }
+
+ before do
+ assign(:key, key)
+ end
+
+ context 'when the form partial is used' do
+ before do
+ allow(view).to receive(:ssh_key_expires_field_description).and_return('Key can still be used after expiration.')
+
+ render
+ end
+
+ it 'renders the form with the correct action' do
+ expect(page.find('form')['action']).to eq('/-/profile/keys')
+ end
+
+ it 'has the key field', :aggregate_failures do
+ expect(rendered).to have_field('Key', type: 'textarea', placeholder: 'Typically starts with "ssh-ed25519 …" or "ssh-rsa …"')
+ expect(rendered).to have_text("Paste your public SSH key, which is usually contained in the file '~/.ssh/id_ed25519.pub' or '~/.ssh/id_rsa.pub' and begins with 'ssh-ed25519' or 'ssh-rsa'. Do not paste your private SSH key, as that can compromise your identity.")
+ end
+
+ it 'has the title field', :aggregate_failures do
+ expect(rendered).to have_field('Title', type: 'text', placeholder: 'e.g. My MacBook key')
+ expect(rendered).to have_text('Give your individual key a title.')
+ end
+
+ it 'has the expires at field', :aggregate_failures do
+ expect(rendered).to have_field('Expires at', type: 'date')
+ expect(page.find_field('Expires at')['min']).to eq(l(1.day.from_now, format: "%Y-%m-%d"))
+ expect(rendered).to have_text('Key can still be used after expiration.')
+ end
+
+ it 'has the validation warning', :aggregate_failures do
+ expect(rendered).to have_text("Oops, are you sure? Publicly visible private SSH keys can compromise your system.")
+ expect(rendered).to have_button('Yes, add it')
+ end
+
+ it 'has the submit button' do
+ expect(rendered).to have_button('Add key')
+ end
+ end
+end
diff --git a/spec/views/profiles/keys/_key.html.haml_spec.rb b/spec/views/profiles/keys/_key.html.haml_spec.rb
new file mode 100644
index 00000000000..bb101198ac3
--- /dev/null
+++ b/spec/views/profiles/keys/_key.html.haml_spec.rb
@@ -0,0 +1,123 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'profiles/keys/_key.html.haml' do
+ let_it_be(:user) { create(:user) }
+
+ before do
+ allow(view).to receive(:key).and_return(key)
+ allow(view).to receive(:is_admin).and_return(false)
+ end
+
+ context 'when the key partial is used' do
+ let_it_be(:key) do
+ create(:personal_key,
+ user: user,
+ last_used_at: 7.days.ago,
+ expires_at: 2.days.from_now)
+ end
+
+ it 'displays the correct values', :aggregate_failures do
+ render
+
+ expect(rendered).to have_text(key.title)
+ expect(rendered).to have_css('[data-testid="key-icon"]')
+ expect(rendered).to have_text(key.fingerprint)
+ expect(rendered).to have_text(l(key.last_used_at, format: "%b %d, %Y"))
+ expect(rendered).to have_text(l(key.created_at, format: "%b %d, %Y"))
+ expect(rendered).to have_text(key.expires_at.to_date)
+ expect(response).to render_template(partial: 'shared/ssh_keys/_key_delete')
+ end
+
+ context 'when the key has not been used' do
+ let_it_be(:key) do
+ create(:personal_key,
+ user: user,
+ last_used_at: nil)
+ end
+
+ it 'renders "Never" for last used' do
+ render
+
+ expect(rendered).to have_text('Last used: Never')
+ end
+ end
+
+ context 'when the key does not have an expiration date' do
+ let_it_be(:key) do
+ create(:personal_key,
+ user: user,
+ expires_at: nil)
+ end
+
+ it 'renders "Never" for expires' do
+ render
+
+ expect(rendered).to have_text('Expires: Never')
+ end
+ end
+
+ context 'when the key has expired' do
+ let_it_be(:key) do
+ create(:personal_key,
+ user: user,
+ expires_at: 2.days.ago)
+ end
+
+ it 'renders "Expired:" as the expiration date label' do
+ render
+
+ expect(rendered).to have_text('Expired:')
+ end
+ end
+
+ context 'when the key is not deletable' do
+ # Turns out key.can_delete? is only false for LDAP keys
+ # but LDAP keys don't exist outside EE
+ before do
+ allow(key).to receive(:can_delete?).and_return(false)
+ end
+
+ it 'does not render the partial' do
+ render
+
+ expect(response).not_to render_template(partial: 'shared/ssh_keys/_key_delete')
+ end
+ end
+
+ context 'icon tooltip' do
+ using RSpec::Parameterized::TableSyntax
+
+ where(:valid, :expiry, :result) do
+ false | 2.days.from_now | 'Key type is forbidden. Must be DSA, ECDSA, or ED25519'
+ false | 2.days.ago | 'Key type is forbidden. Must be DSA, ECDSA, or ED25519'
+ true | 2.days.ago | 'Key usable beyond expiration date.'
+ true | 2.days.from_now | ''
+ end
+
+ with_them do
+ let_it_be(:key) do
+ create(:personal_key, user: user)
+ end
+
+ it 'renders the correct icon', :aggregate_failures do
+ unless valid
+ stub_application_setting(rsa_key_restriction: ApplicationSetting::FORBIDDEN_KEY_VALUE)
+ end
+
+ key.expires_at = expiry
+
+ render
+
+ if result.empty?
+ expect(rendered).to have_css('[data-testid="key-icon"]')
+ else
+ expect(rendered).to have_css('[data-testid="warning-solid-icon"]')
+ expect(rendered).to have_selector("span.has-tooltip[title='#{result}']")
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/spec/views/projects/commit/_commit_box.html.haml_spec.rb b/spec/views/projects/commit/_commit_box.html.haml_spec.rb
index 9d18519ade6..c503e085d02 100644
--- a/spec/views/projects/commit/_commit_box.html.haml_spec.rb
+++ b/spec/views/projects/commit/_commit_box.html.haml_spec.rb
@@ -34,14 +34,6 @@ RSpec.describe 'projects/commit/_commit_box.html.haml' do
expect(rendered).to have_selector('.js-commit-pipeline-mini-graph')
end
-
- it 'shows pipeline stages in haml when feature flag is disabled' do
- stub_feature_flags(ci_commit_pipeline_mini_graph_vue: false)
-
- render
-
- expect(rendered).to have_selector('.js-commit-pipeline-graph')
- end
end
context 'when there are multiple pipelines for a commit' do
@@ -74,30 +66,4 @@ RSpec.describe 'projects/commit/_commit_box.html.haml' do
end
end
end
-
- context 'viewing a commit' do
- context 'as a developer' do
- before do
- allow(view).to receive(:can_collaborate_with_project?).and_return(true)
- end
-
- it 'has a link to create a new tag' do
- render
-
- expect(rendered).to have_link('Tag')
- end
- end
-
- context 'as a non-developer' do
- before do
- project.add_guest(user)
- end
-
- it 'does not have a link to create a new tag' do
- render
-
- expect(rendered).not_to have_link('Tag')
- end
- end
- end
end
diff --git a/spec/views/projects/empty.html.haml_spec.rb b/spec/views/projects/empty.html.haml_spec.rb
index de83722160e..dd7b1bd94a9 100644
--- a/spec/views/projects/empty.html.haml_spec.rb
+++ b/spec/views/projects/empty.html.haml_spec.rb
@@ -36,6 +36,16 @@ RSpec.describe 'projects/empty' do
end
end
+ context 'project is archived' do
+ let(:project) { ProjectPresenter.new(create(:project, :empty_repo, :archived), current_user: user) }
+
+ it 'shows archived notice' do
+ render
+
+ expect(rendered).to have_content('Archived project!')
+ end
+ end
+
describe 'invite_members_empty_project_version_a experiment' do
let(:can_import_members) { true }
diff --git a/spec/views/projects/pipelines/_stage.html.haml_spec.rb b/spec/views/projects/pipelines/_stage.html.haml_spec.rb
deleted file mode 100644
index c8f6784a0f6..00000000000
--- a/spec/views/projects/pipelines/_stage.html.haml_spec.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe 'projects/pipelines/_stage' do
- let(:project) { create(:project, :repository) }
- let(:pipeline) { create(:ci_pipeline, project: project) }
- let(:stage) { build(:ci_stage, pipeline: pipeline) }
-
- before do
- assign :stage, stage
- end
-
- context 'when there are only latest builds present' do
- before do
- create(:ci_build, name: 'test:build',
- stage: stage.name,
- pipeline: pipeline)
- end
-
- it 'shows the builds in the stage' do
- render
-
- expect(rendered).to have_text 'test:build'
- end
- end
-
- context 'when build belongs to different stage' do
- before do
- create(:ci_build, name: 'test:build',
- stage: 'other:stage',
- pipeline: pipeline)
- end
-
- it 'does not render build' do
- render
-
- expect(rendered).not_to have_text 'test:build'
- end
- end
-
- context 'when there are retried builds present' do
- before do
- create(:ci_build, name: 'test:build', stage: stage.name, pipeline: pipeline, retried: true)
- create(:ci_build, name: 'test:build', stage: stage.name, pipeline: pipeline)
- end
-
- it 'shows only latest builds' do
- render
-
- expect(rendered).to have_text 'test:build', count: 1
- end
- end
-
- context 'when there are multiple builds' do
- before do
- Ci::HasStatus::AVAILABLE_STATUSES.each do |status|
- create_build(status)
- end
- end
-
- it 'shows them in order' do
- render
-
- expect(rendered).to have_text(Ci::HasStatus::ORDERED_STATUSES.join(" "))
- end
-
- def create_build(status)
- create(:ci_build, name: status, status: status,
- pipeline: pipeline, stage: stage.name)
- 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 b2dd3556098..e6d53c526e2 100644
--- a/spec/views/projects/settings/operations/show.html.haml_spec.rb
+++ b/spec/views/projects/settings/operations/show.html.haml_spec.rb
@@ -36,8 +36,8 @@ RSpec.describe 'projects/settings/operations/show' 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.')
+ expect(rendered).to have_content _('Alert integrations')
+ expect(rendered).to have_content _('Display alerts from all configured monitoring tools.')
end
end
diff --git a/spec/views/projects/tags/index.html.haml_spec.rb b/spec/views/projects/tags/index.html.haml_spec.rb
index dc008875062..18b42f98e0b 100644
--- a/spec/views/projects/tags/index.html.haml_spec.rb
+++ b/spec/views/projects/tags/index.html.haml_spec.rb
@@ -21,6 +21,7 @@ RSpec.describe 'projects/tags/index.html.haml' do
end
it 'defaults sort dropdown toggle to last updated' do
+ stub_feature_flags(gldropdown_tags: false)
render
expect(rendered).to have_button('Last updated')
end
diff --git a/spec/views/registrations/welcome/show.html.haml_spec.rb b/spec/views/registrations/welcome/show.html.haml_spec.rb
index f731594e9ee..639759ae095 100644
--- a/spec/views/registrations/welcome/show.html.haml_spec.rb
+++ b/spec/views/registrations/welcome/show.html.haml_spec.rb
@@ -3,7 +3,7 @@
require 'spec_helper'
RSpec.describe 'registrations/welcome/show' do
- using RSpec::Parameterized::TableSyntax
+ let(:is_gitlab_com) { false }
let_it_be(:user) { User.new }
@@ -11,9 +11,9 @@ RSpec.describe 'registrations/welcome/show' 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(:in_invitation_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(Gitlab).to receive(:com?).and_return(false)
+ allow(Gitlab).to receive(:com?).and_return(is_gitlab_com)
render
end
@@ -22,4 +22,24 @@ RSpec.describe 'registrations/welcome/show' do
it { is_expected.not_to have_selector('label[for="user_setup_for_company"]') }
it { is_expected.to have_button('Get started!') }
+ it { is_expected.to have_selector('input[name="user[email_opted_in]"]') }
+
+ describe 'email opt in' do
+ context 'when on gitlab.com' do
+ let(:is_gitlab_com) { true }
+
+ it 'hides the email-opt in by default' do
+ expect(subject).to have_css('.js-email-opt-in.hidden')
+ end
+ end
+
+ context 'when not on gitlab.com' do
+ let(:is_gitlab_com) { false }
+
+ it 'hides the email-opt in by default' do
+ expect(subject).not_to have_css('.js-email-opt-in.hidden')
+ expect(subject).to have_css('.js-email-opt-in')
+ end
+ end
+ end
end
diff --git a/spec/views/search/_results.html.haml_spec.rb b/spec/views/search/_results.html.haml_spec.rb
index 8960d096143..11f2a4082e7 100644
--- a/spec/views/search/_results.html.haml_spec.rb
+++ b/spec/views/search/_results.html.haml_spec.rb
@@ -28,6 +28,21 @@ RSpec.describe 'search/_results' do
expect(rendered).to have_content('Showing 1 - 2 of 3 issues for foo')
end
+ context 'when searching notes which contain quotes in markdown' 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' }
+
+ it 'renders plain quotes' do
+ render
+
+ expect(rendered).to include('"<mark>helloworld</mark>"')
+ end
+ end
+
context 'when search results do not have a count' do
before do
@search_objects = @search_objects.without_count
diff --git a/spec/views/shared/nav/_sidebar.html.haml_spec.rb b/spec/views/shared/nav/_sidebar.html.haml_spec.rb
new file mode 100644
index 00000000000..268d2952683
--- /dev/null
+++ b/spec/views/shared/nav/_sidebar.html.haml_spec.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'shared/nav/_sidebar.html.haml' do
+ let(:project) { build(:project, id: non_existing_record_id) }
+ let(:context) { Sidebars::Projects::Context.new(current_user: nil, container: project)}
+ let(:sidebar) { Sidebars::Projects::Panel.new(context) }
+
+ before do
+ assign(:project, project)
+ assign(:sidebar, sidebar)
+
+ allow(sidebar).to receive(:renderable_menus).and_return([])
+ end
+
+ context 'when sidebar has a scope menu' do
+ it 'renders the scope menu' do
+ render
+
+ expect(rendered).to render_template('shared/nav/_scope_menu')
+ end
+ end
+
+ context 'when sidebar does not have a scope menu' do
+ let(:scope_menu_view_path) { 'shared/nav/' }
+ let(:scope_menu_view_name) { 'scope_menu.html.haml' }
+ let(:scope_menu_view) { "#{scope_menu_view_path}#{scope_menu_view_name}" }
+ let(:scope_menu_partial) { "#{scope_menu_view_path}_#{scope_menu_view_name}" }
+ let(:content) { 'Custom test content' }
+
+ context 'when sidebar has a custom scope menu partial defined' do
+ it 'renders the custom partial' do
+ allow(sidebar).to receive(:render_raw_scope_menu_partial).and_return(scope_menu_view)
+ allow(sidebar).to receive(:scope_menu).and_return(nil)
+ stub_template(scope_menu_partial => content)
+
+ render
+
+ expect(rendered).to have_text(content)
+ end
+ end
+ end
+end
diff --git a/spec/views/shared/runners/show.html.haml_spec.rb b/spec/views/shared/runners/show.html.haml_spec.rb
index 5e2812eb48a..91a6a31daae 100644
--- a/spec/views/shared/runners/show.html.haml_spec.rb
+++ b/spec/views/shared/runners/show.html.haml_spec.rb
@@ -34,19 +34,19 @@ RSpec.describe 'shared/runners/show.html.haml' do
describe 'Runner id and type' do
context 'when runner is of type instance' do
- it { is_expected.to have_content("Runner ##{runner.id} Shared") }
+ it { is_expected.to have_content("Runner ##{runner.id} shared") }
end
context 'when runner is of type group' do
let(:runner) { create(:ci_runner, :group) }
- it { is_expected.to have_content("Runner ##{runner.id} Group") }
+ it { is_expected.to have_content("Runner ##{runner.id} group") }
end
context 'when runner is of type project' do
let(:runner) { create(:ci_runner, :project) }
- it { is_expected.to have_content("Runner ##{runner.id} Specific") }
+ it { is_expected.to have_content("Runner ##{runner.id} specific") }
end
end