summaryrefslogtreecommitdiff
path: root/spec/views
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 01:45:44 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-09-19 01:45:44 +0000
commit85dc423f7090da0a52c73eb66faf22ddb20efff9 (patch)
tree9160f299afd8c80c038f08e1545be119f5e3f1e1 /spec/views
parent15c2c8c66dbe422588e5411eee7e68f1fa440bb8 (diff)
downloadgitlab-ce-85dc423f7090da0a52c73eb66faf22ddb20efff9.tar.gz
Add latest changes from gitlab-org/gitlab@13-4-stable-ee
Diffstat (limited to 'spec/views')
-rw-r--r--spec/views/admin/application_settings/_package_registry.html.haml_spec.rb65
-rw-r--r--spec/views/admin/services/index.html.haml_spec.rb30
-rw-r--r--spec/views/admin/sessions/two_factor.html.haml_spec.rb4
-rw-r--r--spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb8
-rw-r--r--spec/views/layouts/nav/sidebar/_instance_statistics.html.haml_spec.rb7
-rw-r--r--spec/views/notify/autodevops_disabled_email.text.erb_spec.rb38
-rw-r--r--spec/views/projects/ci/lints/show.html.haml_spec.rb34
-rw-r--r--spec/views/projects/merge_requests/edit.html.haml_spec.rb1
-rw-r--r--spec/views/projects/pipelines/new.html.haml_spec.rb2
-rw-r--r--spec/views/projects/pipelines/show.html.haml_spec.rb26
-rw-r--r--spec/views/registrations/welcome.html.haml_spec.rb26
-rw-r--r--spec/views/search/_results.html.haml_spec.rb37
-rw-r--r--spec/views/shared/deploy_tokens/_form.html.haml_spec.rb62
13 files changed, 288 insertions, 52 deletions
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
new file mode 100644
index 00000000000..ef40829c29b
--- /dev/null
+++ b/spec/views/admin/application_settings/_package_registry.html.haml_spec.rb
@@ -0,0 +1,65 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+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
+ assign(:application_setting, application_setting)
+ allow(view).to receive(:current_user) { admin }
+ allow(view).to receive(:expanded) { true }
+ end
+
+ subject { render partial: 'admin/application_settings/package_registry' }
+
+ context 'package file size limits' do
+ before do
+ assign(:plans, [default_plan_limits.plan])
+ end
+
+ it 'has fields for max package file sizes' do
+ subject
+
+ expect(rendered).to have_field('Maximum Conan package file size in bytes', type: 'number')
+ expect(page.find_field('Maximum Conan package file size in bytes').value).to eq(default_plan_limits.conan_max_file_size.to_s)
+
+ expect(rendered).to have_field('Maximum Maven package file size in bytes', type: 'number')
+ expect(page.find_field('Maximum Maven package file size in bytes').value).to eq(default_plan_limits.maven_max_file_size.to_s)
+
+ expect(rendered).to have_field('Maximum NPM package file size in bytes', type: 'number')
+ expect(page.find_field('Maximum NPM package file size in bytes').value).to eq(default_plan_limits.npm_max_file_size.to_s)
+
+ expect(rendered).to have_field('Maximum NuGet package file size in bytes', type: 'number')
+ expect(page.find_field('Maximum NuGet package file size in bytes').value).to eq(default_plan_limits.nuget_max_file_size.to_s)
+
+ expect(rendered).to have_field('Maximum PyPI package file size in bytes', type: 'number')
+ expect(page.find_field('Maximum PyPI package file size in bytes').value).to eq(default_plan_limits.pypi_max_file_size.to_s)
+ end
+
+ it 'does not display the plan name when there is only one plan' do
+ subject
+
+ expect(page).not_to have_content('Default')
+ end
+ end
+
+ context 'with multiple plans' do
+ let_it_be(:plan) { create(:plan, name: 'Gold') }
+ let_it_be(:gold_plan_limits) { create(:plan_limits, :with_package_file_sizes, plan: plan) }
+
+ before do
+ assign(:plans, [default_plan_limits.plan, gold_plan_limits.plan])
+ end
+
+ it 'displays the plan name when there is more than one plan' do
+ subject
+
+ expect(page).to have_content('Default')
+ expect(page).to have_content('Gold')
+ end
+ end
+end
diff --git a/spec/views/admin/services/index.html.haml_spec.rb b/spec/views/admin/services/index.html.haml_spec.rb
new file mode 100644
index 00000000000..e8cd2dde67e
--- /dev/null
+++ b/spec/views/admin/services/index.html.haml_spec.rb
@@ -0,0 +1,30 @@
+# 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/admin/sessions/two_factor.html.haml_spec.rb b/spec/views/admin/sessions/two_factor.html.haml_spec.rb
index 9c5ff9925c1..c7e0edbcd58 100644
--- a/spec/views/admin/sessions/two_factor.html.haml_spec.rb
+++ b/spec/views/admin/sessions/two_factor.html.haml_spec.rb
@@ -32,6 +32,10 @@ RSpec.describe 'admin/sessions/two_factor.html.haml' do
context 'user has u2f active' do
let(:user) { create(:admin, :two_factor_via_u2f) }
+ before do
+ stub_feature_flags(webauthn: false)
+ end
+
it 'shows enter u2f form' do
render
diff --git a/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb
index d1e756422d5..777dc0c8571 100644
--- a/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb
+++ b/spec/views/layouts/nav/sidebar/_admin.html.haml_spec.rb
@@ -66,6 +66,14 @@ RSpec.describe 'layouts/nav/sidebar/_admin' do
it_behaves_like 'page has active tab', 'Messages'
end
+ context 'on analytics' do
+ before do
+ allow(controller).to receive(:controller_name).and_return('dev_ops_report')
+ end
+
+ it_behaves_like 'page has active tab', 'Analytics'
+ end
+
context 'on hooks' do
before do
allow(controller).to receive(:controller_name).and_return('hooks')
diff --git a/spec/views/layouts/nav/sidebar/_instance_statistics.html.haml_spec.rb b/spec/views/layouts/nav/sidebar/_instance_statistics.html.haml_spec.rb
deleted file mode 100644
index d3b57f6dfcf..00000000000
--- a/spec/views/layouts/nav/sidebar/_instance_statistics.html.haml_spec.rb
+++ /dev/null
@@ -1,7 +0,0 @@
-# frozen_string_literal: true
-
-require 'spec_helper'
-
-RSpec.describe 'layouts/nav/sidebar/_instance_statistics' do
- it_behaves_like 'has nav sidebar'
-end
diff --git a/spec/views/notify/autodevops_disabled_email.text.erb_spec.rb b/spec/views/notify/autodevops_disabled_email.text.erb_spec.rb
new file mode 100644
index 00000000000..c3cb0c83f35
--- /dev/null
+++ b/spec/views/notify/autodevops_disabled_email.text.erb_spec.rb
@@ -0,0 +1,38 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'notify/autodevops_disabled_email.text.erb' do
+ include Devise::Test::ControllerHelpers
+
+ let(:user) { create(:user, developer_projects: [project]) }
+ let(:project) { create(:project, :repository) }
+
+ let(:pipeline) do
+ create(:ci_pipeline,
+ :failed,
+ project: project,
+ user: user,
+ ref: project.default_branch,
+ sha: project.commit.sha)
+ end
+
+ before do
+ assign(:project, project)
+ assign(:pipeline, pipeline)
+ end
+
+ context 'when the pipeline contains a failed job' do
+ let!(:build) { create(:ci_build, :failed, :trace_live, pipeline: pipeline, project: pipeline.project) }
+
+ it 'renders the email correctly' do
+ render
+
+ expect(rendered).to have_content("Auto DevOps pipeline was disabled for #{project.name}")
+ expect(rendered).to match(/Pipeline ##{pipeline.id} .* triggered by #{pipeline.user.name}/)
+ expect(rendered).to have_content("Stage: #{build.stage}")
+ expect(rendered).to have_content("Name: #{build.name}")
+ expect(rendered).not_to have_content("Trace:")
+ end
+ end
+end
diff --git a/spec/views/projects/ci/lints/show.html.haml_spec.rb b/spec/views/projects/ci/lints/show.html.haml_spec.rb
index a71cea6d3c8..f59ad3f5f84 100644
--- a/spec/views/projects/ci/lints/show.html.haml_spec.rb
+++ b/spec/views/projects/ci/lints/show.html.haml_spec.rb
@@ -4,16 +4,16 @@ require 'spec_helper'
RSpec.describe 'projects/ci/lints/show' do
include Devise::Test::ControllerHelpers
- let(:project) { create(:project, :repository) }
- let(:config_processor) { Gitlab::Ci::YamlProcessor.new(YAML.dump(content)) }
+ let_it_be(:user) { create(:user) }
+ let_it_be(:project) { create(:project, :repository) }
+ let(:lint) { Gitlab::Ci::Lint.new(project: project, current_user: user) }
+ let(:result) { lint.validate(YAML.dump(content)) }
describe 'XSS protection' do
before do
assign(:project, project)
- assign(:status, true)
- assign(:builds, config_processor.builds)
- assign(:stages, config_processor.stages)
- assign(:jobs, config_processor.jobs)
+ assign(:result, result)
+ stub_feature_flags(ci_lint_vue: false)
end
context 'when builds attrbiutes contain HTML nodes' do
@@ -66,10 +66,8 @@ RSpec.describe 'projects/ci/lints/show' do
before do
assign(:project, project)
- assign(:status, true)
- assign(:builds, config_processor.builds)
- assign(:stages, config_processor.stages)
- assign(:jobs, config_processor.jobs)
+ assign(:result, result)
+ stub_feature_flags(ci_lint_vue: false)
end
it 'shows the correct values' do
@@ -85,13 +83,13 @@ RSpec.describe 'projects/ci/lints/show' do
context 'when content has warnings' do
before do
- assign(:warnings, ['Warning 1', 'Warning 2'])
+ allow(result).to receive(:warnings).and_return(['Warning 1', 'Warning 2'])
end
it 'shows warning messages' do
render
- expect(rendered).to have_content('Warning:')
+ expect(rendered).to have_content('2 warning(s) found:')
expect(rendered).to have_content('Warning 1')
expect(rendered).to have_content('Warning 2')
end
@@ -99,11 +97,15 @@ RSpec.describe 'projects/ci/lints/show' do
end
context 'when the content is invalid' do
+ let(:content) { double(:content) }
+
before do
+ allow(result).to receive(:warnings).and_return(['Warning 1', 'Warning 2'])
+ allow(result).to receive(:errors).and_return(['Undefined error'])
+
assign(:project, project)
- assign(:status, false)
- assign(:errors, ['Undefined error'])
- assign(:warnings, ['Warning 1', 'Warning 2'])
+ assign(:result, result)
+ stub_feature_flags(ci_lint_vue: false)
end
it 'shows error message' do
@@ -117,7 +119,7 @@ RSpec.describe 'projects/ci/lints/show' do
it 'shows warning messages' do
render
- expect(rendered).to have_content('Warning:')
+ expect(rendered).to have_content('2 warning(s) found:')
expect(rendered).to have_content('Warning 1')
expect(rendered).to have_content('Warning 2')
end
diff --git a/spec/views/projects/merge_requests/edit.html.haml_spec.rb b/spec/views/projects/merge_requests/edit.html.haml_spec.rb
index 55a74dc8229..215d404e395 100644
--- a/spec/views/projects/merge_requests/edit.html.haml_spec.rb
+++ b/spec/views/projects/merge_requests/edit.html.haml_spec.rb
@@ -20,6 +20,7 @@ RSpec.describe 'projects/merge_requests/edit.html.haml' do
target_project: project,
author: user,
assignees: [user],
+ reviewers: [user],
milestone: milestone)
end
diff --git a/spec/views/projects/pipelines/new.html.haml_spec.rb b/spec/views/projects/pipelines/new.html.haml_spec.rb
index 2deacfa8478..9c5e46b6a17 100644
--- a/spec/views/projects/pipelines/new.html.haml_spec.rb
+++ b/spec/views/projects/pipelines/new.html.haml_spec.rb
@@ -26,7 +26,7 @@ RSpec.describe 'projects/pipelines/new' do
it 'displays the warnings' do
render
- expect(rendered).to have_css('div.alert-warning')
+ expect(rendered).to have_css('div.bs-callout-warning')
expect(rendered).to have_content('warning 1')
expect(rendered).to have_content('warning 2')
end
diff --git a/spec/views/projects/pipelines/show.html.haml_spec.rb b/spec/views/projects/pipelines/show.html.haml_spec.rb
index 49add434ab5..b998023b40e 100644
--- a/spec/views/projects/pipelines/show.html.haml_spec.rb
+++ b/spec/views/projects/pipelines/show.html.haml_spec.rb
@@ -16,24 +16,6 @@ RSpec.describe 'projects/pipelines/show' do
stub_feature_flags(new_pipeline_form: false)
end
- shared_examples 'pipeline with warning messages' do
- let(:warning_messages) do
- [double(content: 'warning 1'), double(content: 'warning 2')]
- end
-
- before do
- allow(pipeline).to receive(:warning_messages).and_return(warning_messages)
- end
-
- it 'displays the warnings' do
- render
-
- expect(rendered).to have_css('.bs-callout-warning')
- expect(rendered).to have_content('warning 1')
- expect(rendered).to have_content('warning 2')
- end
- end
-
context 'when pipeline has errors' do
before do
allow(pipeline).to receive(:yaml_errors).and_return('some errors')
@@ -51,10 +33,6 @@ RSpec.describe 'projects/pipelines/show' do
expect(rendered).not_to have_css('ul.pipelines-tabs')
end
-
- context 'when pipeline has also warnings' do
- it_behaves_like 'pipeline with warning messages'
- end
end
context 'when pipeline is valid' do
@@ -69,9 +47,5 @@ RSpec.describe 'projects/pipelines/show' do
expect(rendered).to have_css('ul.pipelines-tabs')
end
-
- context 'when pipeline has warnings' do
- it_behaves_like 'pipeline with warning messages'
- end
end
end
diff --git a/spec/views/registrations/welcome.html.haml_spec.rb b/spec/views/registrations/welcome.html.haml_spec.rb
new file mode 100644
index 00000000000..56a7784a134
--- /dev/null
+++ b/spec/views/registrations/welcome.html.haml_spec.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'registrations/welcome' do
+ using RSpec::Parameterized::TableSyntax
+
+ let_it_be(:user) { User.new }
+
+ before 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(:in_oauth_flow?).and_return(false)
+ allow(view).to receive(:experiment_enabled?).with(:onboarding_issues).and_return(false)
+ allow(Gitlab).to receive(:com?).and_return(false)
+
+ render
+ end
+
+ subject { rendered }
+
+ it { is_expected.not_to have_selector('label[for="user_setup_for_company"]') }
+ it { is_expected.to have_button('Get started!') }
+end
diff --git a/spec/views/search/_results.html.haml_spec.rb b/spec/views/search/_results.html.haml_spec.rb
index cd7a3559538..9e95dc40ff8 100644
--- a/spec/views/search/_results.html.haml_spec.rb
+++ b/spec/views/search/_results.html.haml_spec.rb
@@ -3,13 +3,16 @@
require 'spec_helper'
RSpec.describe 'search/_results' do
+ let(:search_objects) { Issue.page(1).per(2) }
+ let(:scope) { 'issues' }
+
before do
controller.params[:action] = 'show'
create_list(:issue, 3)
- @search_objects = Issue.page(1).per(2)
- @scope = 'issues'
+ @search_objects = search_objects
+ @scope = scope
@search_term = 'foo'
end
@@ -30,4 +33,34 @@ RSpec.describe 'search/_results' do
expect(rendered).not_to have_content(/Showing .* of .*/)
end
end
+
+ context 'rendering all types of search results' do
+ let_it_be(:project) { create(:project, :repository, :wiki_repo) }
+ let_it_be(:issue) { create(:issue, project: project, title: '*') }
+ 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(:user) { create(:admin) }
+
+ %w[issues blobs notes wiki_blobs merge_requests milestones].each do |search_scope|
+ context "when scope is #{search_scope}" do
+ let(:scope) { search_scope }
+ let(:search_objects) { Gitlab::ProjectSearchResults.new(user, '*', project: project).objects(scope) }
+
+ it 'renders the click text event tracking attributes' do
+ render
+
+ expect(rendered).to have_selector('[data-track-event=click_text]')
+ expect(rendered).to have_selector('[data-track-property=search_result]')
+ end
+
+ it 'renders the state filter drop down' do
+ render
+
+ expect(rendered).to have_selector('#js-search-filter-by-state')
+ end
+ end
+ end
+ end
end
diff --git a/spec/views/shared/deploy_tokens/_form.html.haml_spec.rb b/spec/views/shared/deploy_tokens/_form.html.haml_spec.rb
new file mode 100644
index 00000000000..3508ba8cca9
--- /dev/null
+++ b/spec/views/shared/deploy_tokens/_form.html.haml_spec.rb
@@ -0,0 +1,62 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'shared/deploy_tokens/_form.html.haml' do
+ using RSpec::Parameterized::TableSyntax
+
+ let_it_be(:user) { create(:user) }
+ let_it_be(:token) { build(:deploy_token) }
+
+ RSpec.shared_examples "display deploy token settings" do |role, shows_package_registry_permissions|
+ before do
+ subject.add_user(user, role)
+ allow(view).to receive(:current_user).and_return(user)
+ stub_config(packages: { enabled: packages_enabled })
+ end
+
+ it "correctly renders the form" do
+ render 'shared/deploy_tokens/form', token: token, group_or_project: subject
+
+ if shows_package_registry_permissions
+ expect(rendered).to have_content('Allows read access to the package registry')
+ else
+ expect(rendered).not_to have_content('Allows read access to the package registry')
+ end
+ end
+ end
+
+ context "when the subject is a project" do
+ let_it_be(:subject, refind: true) { create(:project, :private) }
+
+ where(:packages_enabled, :feature_enabled, :role, :shows_package_registry_permissions) do
+ true | true | :maintainer | true
+ false | true | :maintainer | false
+ true | false | :maintainer | false
+ false | false | :maintainer | false
+ end
+
+ with_them do
+ before do
+ subject.update!(packages_enabled: feature_enabled)
+ end
+
+ it_behaves_like 'display deploy token settings', params[:role], params[:shows_package_registry_permissions]
+ end
+ end
+
+ context "when the subject is a group" do
+ let_it_be(:subject, refind: true) { create(:group, :private) }
+
+ where(:packages_enabled, :role, :shows_package_registry_permissions) do
+ true | :owner | true
+ false | :owner | false
+ true | :maintainer | true
+ false | :maintainer | false
+ end
+
+ with_them do
+ it_behaves_like 'display deploy token settings', params[:role], params[:shows_package_registry_permissions]
+ end
+ end
+end