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.rb13
-rw-r--r--spec/views/groups/edit.html.haml_spec.rb48
-rw-r--r--spec/views/help/index.html.haml_spec.rb1
-rw-r--r--spec/views/layouts/header/_gitlab_version.html.haml_spec.rb16
-rw-r--r--spec/views/profiles/keys/_form.html.haml_spec.rb6
-rw-r--r--spec/views/projects/commits/_commit.html.haml_spec.rb2
-rw-r--r--spec/views/projects/edit.html.haml_spec.rb24
-rw-r--r--spec/views/projects/merge_requests/show.html.haml_spec.rb28
-rw-r--r--spec/views/projects/services/_form.haml_spec.rb30
-rw-r--r--spec/views/shared/access_tokens/_table.html.haml_spec.rb24
-rw-r--r--spec/views/shared/nav/_sidebar.html.haml_spec.rb3
-rw-r--r--spec/views/shared/wikis/_sidebar.html.haml_spec.rb2
12 files changed, 123 insertions, 74 deletions
diff --git a/spec/views/admin/dashboard/index.html.haml_spec.rb b/spec/views/admin/dashboard/index.html.haml_spec.rb
index 9fa95613d1c..9db2bd3741a 100644
--- a/spec/views/admin/dashboard/index.html.haml_spec.rb
+++ b/spec/views/admin/dashboard/index.html.haml_spec.rb
@@ -53,11 +53,14 @@ RSpec.describe 'admin/dashboard/index.html.haml' do
expect(rendered).not_to have_content "Users over License"
end
- it 'links to the GitLab Changelog' do
- stub_application_setting(version_check_enabled: true)
-
- render
+ describe 'when show_version_check? is true' do
+ before do
+ allow(view).to receive(:show_version_check?).and_return(true)
+ render
+ end
- expect(rendered).to have_link(href: 'https://gitlab.com/gitlab-org/gitlab/-/blob/master/CHANGELOG.md')
+ it 'renders the version check badge' do
+ expect(rendered).to have_selector('.js-gitlab-version-check')
+ end
end
end
diff --git a/spec/views/groups/edit.html.haml_spec.rb b/spec/views/groups/edit.html.haml_spec.rb
index 43e11d31611..eaa909a5da0 100644
--- a/spec/views/groups/edit.html.haml_spec.rb
+++ b/spec/views/groups/edit.html.haml_spec.rb
@@ -115,4 +115,52 @@ RSpec.describe 'groups/edit.html.haml' do
end
end
end
+
+ context 'ip_restriction' do
+ let(:group) { create(:group) }
+ let(:user) { create(:user) }
+
+ before do
+ group.add_owner(user)
+
+ assign(:group, group)
+ allow(view).to receive(:current_user) { user }
+ end
+
+ context 'prompt user about registration features' do
+ before do
+ if Gitlab.ee?
+ allow(License).to receive(:current).and_return(nil)
+ end
+ end
+
+ context 'with service ping disabled' do
+ before do
+ stub_application_setting(usage_ping_enabled: false)
+ end
+
+ it 'renders a placeholder input with registration features message' do
+ render
+
+ expect(rendered).to have_field(:group_disabled_ip_restriction_ranges, disabled: true)
+ expect(rendered).to have_content(s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: s_('RegistrationFeatures|use this feature') })
+ expect(rendered).to have_link(s_('RegistrationFeatures|Registration Features Program'))
+ end
+ end
+
+ context 'with service ping enabled' do
+ before do
+ stub_application_setting(usage_ping_enabled: true)
+ end
+
+ it 'does not render a placeholder input with registration features message' do
+ render
+
+ expect(rendered).not_to have_field(:group_disabled_ip_restriction_ranges, disabled: true)
+ expect(rendered).not_to have_content(s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: s_('RegistrationFeatures|use this feature') })
+ expect(rendered).not_to have_link(s_('RegistrationFeatures|Registration Features Program'))
+ end
+ end
+ end
+ end
end
diff --git a/spec/views/help/index.html.haml_spec.rb b/spec/views/help/index.html.haml_spec.rb
index 600e431b7ef..1d26afcc567 100644
--- a/spec/views/help/index.html.haml_spec.rb
+++ b/spec/views/help/index.html.haml_spec.rb
@@ -76,7 +76,6 @@ RSpec.describe 'help/index' do
def stub_helpers
allow(view).to receive(:markdown).and_return('')
- allow(view).to receive(:version_status_badge).and_return('')
allow(view).to receive(:current_application_settings).and_return(Gitlab::CurrentSettings.current_application_settings)
end
end
diff --git a/spec/views/layouts/header/_gitlab_version.html.haml_spec.rb b/spec/views/layouts/header/_gitlab_version.html.haml_spec.rb
new file mode 100644
index 00000000000..0e24810f835
--- /dev/null
+++ b/spec/views/layouts/header/_gitlab_version.html.haml_spec.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'layouts/header/_gitlab_version' do
+ describe 'when show_version_check? is true' do
+ before do
+ allow(view).to receive(:show_version_check?).and_return(true)
+ render
+ end
+
+ it 'renders the version check badge' do
+ expect(rendered).to have_selector('.js-gitlab-version-check')
+ 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 d5a605958dc..624d7492aea 100644
--- a/spec/views/profiles/keys/_form.html.haml_spec.rb
+++ b/spec/views/profiles/keys/_form.html.haml_spec.rb
@@ -3,6 +3,8 @@
require 'spec_helper'
RSpec.describe 'profiles/keys/_form.html.haml' do
+ include SshKeysHelper
+
let_it_be(:key) { Key.new }
let(:page) { Capybara::Node::Simple.new(rendered) }
@@ -23,8 +25,8 @@ RSpec.describe 'profiles/keys/_form.html.haml' do
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.")
+ expect(rendered).to have_field('Key', type: 'textarea')
+ expect(rendered).to have_text(s_('Profiles|Begins with %{ssh_key_algorithms}.') % { ssh_key_algorithms: ssh_key_allowed_algorithms })
end
it 'has the title field', :aggregate_failures do
diff --git a/spec/views/projects/commits/_commit.html.haml_spec.rb b/spec/views/projects/commits/_commit.html.haml_spec.rb
index ed93240abc1..5c66fbe7dd7 100644
--- a/spec/views/projects/commits/_commit.html.haml_spec.rb
+++ b/spec/views/projects/commits/_commit.html.haml_spec.rb
@@ -19,7 +19,7 @@ RSpec.describe 'projects/commits/_commit.html.haml' do
allow(commit).to receive(:different_committer?).and_return(true)
allow(commit).to receive(:committer).and_return(committer)
- render partial: template, locals: {
+ render partial: template, formats: :html, locals: {
project: project,
ref: ref,
commit: commit
diff --git a/spec/views/projects/edit.html.haml_spec.rb b/spec/views/projects/edit.html.haml_spec.rb
index 8c96f286c79..11f542767f4 100644
--- a/spec/views/projects/edit.html.haml_spec.rb
+++ b/spec/views/projects/edit.html.haml_spec.rb
@@ -29,19 +29,6 @@ RSpec.describe 'projects/edit' do
end
context 'merge suggestions settings' do
- it 'displays all possible variables' do
- render
-
- expect(rendered).to have_content('%{branch_name}')
- expect(rendered).to have_content('%{files_count}')
- expect(rendered).to have_content('%{file_paths}')
- expect(rendered).to have_content('%{project_name}')
- expect(rendered).to have_content('%{project_path}')
- expect(rendered).to have_content('%{user_full_name}')
- expect(rendered).to have_content('%{username}')
- expect(rendered).to have_content('%{suggestions_count}')
- end
-
it 'displays a placeholder if none is set' do
render
@@ -58,17 +45,6 @@ RSpec.describe 'projects/edit' do
end
context 'merge commit template' do
- it 'displays all possible variables' do
- render
-
- expect(rendered).to have_content('%{source_branch}')
- expect(rendered).to have_content('%{target_branch}')
- expect(rendered).to have_content('%{title}')
- expect(rendered).to have_content('%{issues}')
- expect(rendered).to have_content('%{description}')
- expect(rendered).to have_content('%{reference}')
- end
-
it 'displays a placeholder if none is set' do
render
diff --git a/spec/views/projects/merge_requests/show.html.haml_spec.rb b/spec/views/projects/merge_requests/show.html.haml_spec.rb
index 6b6bc1f0b14..6ffd0936003 100644
--- a/spec/views/projects/merge_requests/show.html.haml_spec.rb
+++ b/spec/views/projects/merge_requests/show.html.haml_spec.rb
@@ -45,32 +45,4 @@ RSpec.describe 'projects/merge_requests/show.html.haml', :aggregate_failures do
end
end
end
-
- describe 'gitpod modal' do
- let(:gitpod_modal_selector) { '#modal-enable-gitpod' }
- let(:user) { create(:user) }
- let(:user_gitpod_enabled) { create(:user).tap { |x| x.update!(gitpod_enabled: true) } }
-
- where(:site_enabled, :current_user, :should_show) do
- false | ref(:user) | false
- true | ref(:user) | true
- true | nil | true
- true | ref(:user_gitpod_enabled) | false
- end
-
- with_them do
- it 'handles rendering gitpod user enable modal' do
- allow(Gitlab::CurrentSettings).to receive(:gitpod_enabled).and_return(site_enabled)
- allow(view).to receive(:current_user).and_return(current_user)
-
- render
-
- if should_show
- expect(rendered).to have_css(gitpod_modal_selector)
- else
- expect(rendered).to have_no_css(gitpod_modal_selector)
- end
- 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 177f703ba6c..f212fd78b1a 100644
--- a/spec/views/projects/services/_form.haml_spec.rb
+++ b/spec/views/projects/services/_form.haml_spec.rb
@@ -20,13 +20,33 @@ RSpec.describe 'projects/services/_form' do
)
end
- context 'commit_events and merge_request_events' do
- it 'display merge_request_events and commit_events descriptions' do
- allow(Integrations::Redmine).to receive(:supported_events).and_return(%w(commit merge_request))
-
+ context 'integrations form' do
+ it 'does not render form element' do
render
- expect(rendered).to have_css("input[name='redirect_to'][value='/services']", count: 1, visible: false)
+ expect(rendered).not_to have_selector('[data-testid="integration-form"]')
+ end
+
+ context 'when vue_integration_form feature flag is disabled' do
+ before do
+ stub_feature_flags(vue_integration_form: false)
+ end
+
+ it 'renders form element' do
+ render
+
+ expect(rendered).to have_selector('[data-testid="integration-form"]')
+ end
+
+ context 'commit_events and merge_request_events' do
+ it 'display merge_request_events and commit_events descriptions' do
+ allow(Integrations::Redmine).to receive(:supported_events).and_return(%w(commit merge_request))
+
+ render
+
+ expect(rendered).to have_css("input[name='redirect_to'][value='/services']", count: 1, visible: false)
+ end
+ end
end
end
end
diff --git a/spec/views/shared/access_tokens/_table.html.haml_spec.rb b/spec/views/shared/access_tokens/_table.html.haml_spec.rb
index 0a23768b4f1..fca2fc3183c 100644
--- a/spec/views/shared/access_tokens/_table.html.haml_spec.rb
+++ b/spec/views/shared/access_tokens/_table.html.haml_spec.rb
@@ -11,7 +11,7 @@ RSpec.describe 'shared/access_tokens/_table.html.haml' do
let_it_be(:user) { create(:user) }
let_it_be(:tokens) { [create(:personal_access_token, user: user)] }
- let_it_be(:project) { false }
+ let_it_be(:resource) { false }
before do
stub_licensed_features(enforce_personal_access_token_expiration: true)
@@ -20,8 +20,8 @@ RSpec.describe 'shared/access_tokens/_table.html.haml' do
allow(view).to receive(:personal_access_token_expiration_enforced?).and_return(token_expiry_enforced?)
allow(view).to receive(:show_profile_token_expiry_notification?).and_return(true)
- if project
- project.add_maintainer(user)
+ if resource
+ resource.add_maintainer(user)
end
# Forcibly removing scopes from one token as it's not possible to do with the current modal on creation
@@ -34,7 +34,7 @@ RSpec.describe 'shared/access_tokens/_table.html.haml' do
type: type,
type_plural: type_plural,
active_tokens: tokens,
- project: project,
+ resource: resource,
impersonation: impersonation,
revoke_route_helper: ->(token) { 'path/' }
}
@@ -80,8 +80,8 @@ RSpec.describe 'shared/access_tokens/_table.html.haml' do
end
end
- context 'if project' do
- let_it_be(:project) { create(:project) }
+ context 'if resource is project' do
+ let_it_be(:resource) { create(:project) }
it 'shows the project content', :aggregate_failures do
expect(rendered).to have_selector 'th', text: 'Role'
@@ -92,6 +92,18 @@ RSpec.describe 'shared/access_tokens/_table.html.haml' do
end
end
+ context 'if resource is group' do
+ let_it_be(:resource) { create(:group) }
+
+ it 'shows the group content', :aggregate_failures do
+ expect(rendered).to have_selector 'th', text: 'Role'
+ expect(rendered).to have_selector 'td', text: 'Maintainer'
+
+ expect(rendered).not_to have_content 'Personal access tokens are not revoked upon expiration.'
+ expect(rendered).not_to have_content 'To see all the user\'s personal access tokens you must impersonate them first.'
+ end
+ end
+
context 'without tokens' do
let_it_be(:tokens) { [] }
diff --git a/spec/views/shared/nav/_sidebar.html.haml_spec.rb b/spec/views/shared/nav/_sidebar.html.haml_spec.rb
index 2eeebdff7a8..0eb945f5624 100644
--- a/spec/views/shared/nav/_sidebar.html.haml_spec.rb
+++ b/spec/views/shared/nav/_sidebar.html.haml_spec.rb
@@ -3,7 +3,8 @@
require 'spec_helper'
RSpec.describe 'shared/nav/_sidebar.html.haml' do
- let(:project) { build(:project, id: non_existing_record_id) }
+ let_it_be(:project) { create(:project) }
+
let(:context) { Sidebars::Projects::Context.new(current_user: nil, container: project) }
let(:sidebar) { Sidebars::Projects::Panel.new(context) }
diff --git a/spec/views/shared/wikis/_sidebar.html.haml_spec.rb b/spec/views/shared/wikis/_sidebar.html.haml_spec.rb
index 70991369506..bf050d601e3 100644
--- a/spec/views/shared/wikis/_sidebar.html.haml_spec.rb
+++ b/spec/views/shared/wikis/_sidebar.html.haml_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper'
RSpec.describe 'shared/wikis/_sidebar.html.haml' do
let_it_be(:project) { create(:project) }
- let_it_be(:wiki) { Wiki.for_container(project, project.default_owner) }
+ let_it_be(:wiki) { Wiki.for_container(project, project.first_owner) }
before do
assign(:wiki, wiki)