summaryrefslogtreecommitdiff
path: root/spec/views
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 18:42:06 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-08-20 18:42:06 +0000
commit6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch)
tree78be5963ec075d80116a932011d695dd33910b4e /spec/views
parent1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff)
downloadgitlab-ce-6e4e1050d9dba2b7b2523fdd1768823ab85feef4.tar.gz
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/views')
-rw-r--r--spec/views/admin/dashboard/index.html.haml_spec.rb9
-rw-r--r--spec/views/layouts/_flash.html.haml_spec.rb30
-rw-r--r--spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb52
-rw-r--r--spec/views/notify/changed_milestone_email.html.haml_spec.rb2
-rw-r--r--spec/views/profiles/preferences/show.html.haml_spec.rb41
-rw-r--r--spec/views/projects/ci/lints/show.html.haml_spec.rb23
-rw-r--r--spec/views/projects/commit/show.html.haml_spec.rb6
-rw-r--r--spec/views/projects/imports/new.html.haml_spec.rb2
-rw-r--r--spec/views/projects/merge_requests/show.html.haml_spec.rb18
-rw-r--r--spec/views/projects/pipelines/new.html.haml_spec.rb34
-rw-r--r--spec/views/projects/pipelines/show.html.haml_spec.rb77
-rw-r--r--spec/views/projects/services/_form.haml_spec.rb4
-rw-r--r--spec/views/projects/settings/operations/show.html.haml_spec.rb2
-rw-r--r--spec/views/search/show.html.haml_spec.rb32
-rw-r--r--spec/views/shared/_label_row.html.haml_spec.rb2
15 files changed, 308 insertions, 26 deletions
diff --git a/spec/views/admin/dashboard/index.html.haml_spec.rb b/spec/views/admin/dashboard/index.html.haml_spec.rb
index 569a20e8f08..70fb77944cc 100644
--- a/spec/views/admin/dashboard/index.html.haml_spec.rb
+++ b/spec/views/admin/dashboard/index.html.haml_spec.rb
@@ -32,4 +32,13 @@ RSpec.describe 'admin/dashboard/index.html.haml' do
expect(rendered).to have_content "#{Gitlab::VERSION} (#{Gitlab.revision})"
end
+
+ it 'does not include license breakdown' do
+ render
+
+ expect(rendered).not_to have_content "Users in License"
+ expect(rendered).not_to have_content "Active Users"
+ expect(rendered).not_to have_content "Maximum Users"
+ expect(rendered).not_to have_content "Users over License"
+ end
end
diff --git a/spec/views/layouts/_flash.html.haml_spec.rb b/spec/views/layouts/_flash.html.haml_spec.rb
new file mode 100644
index 00000000000..82c06feb4fb
--- /dev/null
+++ b/spec/views/layouts/_flash.html.haml_spec.rb
@@ -0,0 +1,30 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'layouts/_flash' do
+ before do
+ allow(view).to receive(:flash).and_return(flash)
+ render
+ end
+
+ describe 'closable flash messages' do
+ %w(alert notice success).each do |flash_type|
+ let(:flash) { { flash_type => 'This is a closable flash message' } }
+
+ it 'shows a close button' do
+ expect(rendered).to include('js-close-icon')
+ end
+ end
+ end
+
+ describe 'non closable flash messages' do
+ %w(error message toast warning).each do |flash_type|
+ let(:flash) { { flash_type => 'This is a non closable flash message' } }
+
+ it 'shows a close button' do
+ expect(rendered).not_to include('js-close-icon')
+ 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 bf0bf63e164..bf5b5785b8d 100644
--- a/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
+++ b/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
@@ -47,6 +47,58 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
end
+ describe 'Packages' do
+ let(:user) { create(:user) }
+
+ let_it_be(:package_menu_name) { 'Packages & Registries' }
+ let_it_be(:package_entry_name) { 'Package Registry' }
+
+ before do
+ project.team.add_developer(user)
+ sign_in(user)
+ stub_container_registry_config(enabled: true)
+ end
+
+ context 'when packages is enabled' do
+ it 'packages link is visible' do
+ render
+
+ expect(rendered).to have_link(package_menu_name, href: project_packages_path(project))
+ end
+
+ it 'packages list link is visible' do
+ render
+
+ expect(rendered).to have_link(package_entry_name, href: project_packages_path(project))
+ end
+
+ it 'container registry link is visible' do
+ render
+
+ expect(rendered).to have_link('Container Registry', href: project_container_registry_index_path(project))
+ end
+ end
+
+ context 'when container registry is disabled' do
+ before do
+ stub_container_registry_config(enabled: false)
+ end
+
+ it 'packages top level and list link are visible' do
+ render
+
+ expect(rendered).to have_link(package_menu_name, href: project_packages_path(project))
+ expect(rendered).to have_link(package_entry_name, href: project_packages_path(project))
+ end
+
+ it 'container registry link is not visible' do
+ render
+
+ expect(rendered).not_to have_link('Container Registry', href: project_container_registry_index_path(project))
+ end
+ end
+ end
+
describe 'releases entry' do
it 'renders releases link' do
render
diff --git a/spec/views/notify/changed_milestone_email.html.haml_spec.rb b/spec/views/notify/changed_milestone_email.html.haml_spec.rb
index 50a06683409..03904ff0747 100644
--- a/spec/views/notify/changed_milestone_email.html.haml_spec.rb
+++ b/spec/views/notify/changed_milestone_email.html.haml_spec.rb
@@ -22,7 +22,7 @@ RSpec.describe 'notify/changed_milestone_email.html.haml' do
context 'milestone with start and due dates' do
before do
- milestone.update(start_date: '2018-01-01', due_date: '2018-12-31')
+ milestone.update!(start_date: '2018-01-01', due_date: '2018-12-31')
end
it 'renders with date range' do
diff --git a/spec/views/profiles/preferences/show.html.haml_spec.rb b/spec/views/profiles/preferences/show.html.haml_spec.rb
index 5acfbfb9db1..1b8b28367c1 100644
--- a/spec/views/profiles/preferences/show.html.haml_spec.rb
+++ b/spec/views/profiles/preferences/show.html.haml_spec.rb
@@ -12,6 +12,26 @@ RSpec.describe 'profiles/preferences/show' do
allow(controller).to receive(:current_user).and_return(user)
end
+ context 'navigation theme' do
+ before do
+ render
+ end
+
+ it 'has an id for anchoring' do
+ expect(rendered).to have_css('#navigation-theme')
+ end
+ end
+
+ context 'syntax highlighting theme' do
+ before do
+ render
+ end
+
+ it 'has an id for anchoring' do
+ expect(rendered).to have_css('#syntax-highlighting-theme')
+ end
+ end
+
context 'behavior' do
before do
render
@@ -20,6 +40,25 @@ RSpec.describe 'profiles/preferences/show' do
it 'has option for Render whitespace characters in the Web IDE' do
expect(rendered).to have_unchecked_field('Render whitespace characters in the Web IDE')
end
+
+ it 'has an id for anchoring' do
+ expect(rendered).to have_css('#behavior')
+ end
+
+ it 'has helpful homepage setup guidance' do
+ expect(rendered).to have_field('Homepage content')
+ expect(rendered).to have_content('Choose what content you want to see on your homepage.')
+ end
+ end
+
+ context 'localization' do
+ before do
+ render
+ end
+
+ it 'has an id for anchoring' do
+ expect(rendered).to have_css('#localization')
+ end
end
context 'sourcegraph' do
@@ -28,7 +67,7 @@ RSpec.describe 'profiles/preferences/show' do
end
def have_integrations_section
- have_css('.profile-settings-sidebar', { text: 'Integrations' })
+ have_css('#integrations.profile-settings-sidebar', { text: 'Integrations' })
end
before do
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 bcfb952ca66..a71cea6d3c8 100644
--- a/spec/views/projects/ci/lints/show.html.haml_spec.rb
+++ b/spec/views/projects/ci/lints/show.html.haml_spec.rb
@@ -82,6 +82,20 @@ RSpec.describe 'projects/ci/lints/show' do
expect(rendered).to have_content('Environment: testing')
expect(rendered).to have_content('When: on_success')
end
+
+ context 'when content has warnings' do
+ before do
+ assign(:warnings, ['Warning 1', 'Warning 2'])
+ end
+
+ it 'shows warning messages' do
+ render
+
+ expect(rendered).to have_content('Warning:')
+ expect(rendered).to have_content('Warning 1')
+ expect(rendered).to have_content('Warning 2')
+ end
+ end
end
context 'when the content is invalid' do
@@ -89,6 +103,7 @@ RSpec.describe 'projects/ci/lints/show' do
assign(:project, project)
assign(:status, false)
assign(:errors, ['Undefined error'])
+ assign(:warnings, ['Warning 1', 'Warning 2'])
end
it 'shows error message' do
@@ -98,5 +113,13 @@ RSpec.describe 'projects/ci/lints/show' do
expect(rendered).to have_content('Undefined error')
expect(rendered).not_to have_content('Tag list:')
end
+
+ it 'shows warning messages' do
+ render
+
+ expect(rendered).to have_content('Warning:')
+ expect(rendered).to have_content('Warning 1')
+ expect(rendered).to have_content('Warning 2')
+ end
end
end
diff --git a/spec/views/projects/commit/show.html.haml_spec.rb b/spec/views/projects/commit/show.html.haml_spec.rb
index c2970abbe9f..e23ffe300c5 100644
--- a/spec/views/projects/commit/show.html.haml_spec.rb
+++ b/spec/views/projects/commit/show.html.haml_spec.rb
@@ -14,6 +14,12 @@ RSpec.describe 'projects/commit/show.html.haml' do
assign(:notes, [])
assign(:diffs, commit.diffs)
+ controller.params[:controller] = 'projects/commit'
+ controller.params[:action] = 'show'
+ controller.params[:namespace_id] = project.namespace.to_param
+ controller.params[:project_id] = project.to_param
+ controller.params[:id] = commit.id
+
allow(view).to receive(:current_user).and_return(nil)
allow(view).to receive(:can?).and_return(false)
allow(view).to receive(:can_collaborate_with_project?).and_return(false)
diff --git a/spec/views/projects/imports/new.html.haml_spec.rb b/spec/views/projects/imports/new.html.haml_spec.rb
index edf9eadf924..7c171ee65b9 100644
--- a/spec/views/projects/imports/new.html.haml_spec.rb
+++ b/spec/views/projects/imports/new.html.haml_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe "projects/imports/new.html.haml" do
let(:project) { create(:project_empty_repo, :import_failed, import_type: :gitlab_project, import_source: '/var/opt/gitlab/gitlab-rails/shared/tmp/project_exports/uploads/t.tar.gz', import_url: nil) }
before do
- project.import_state.update(last_error: '<a href="http://googl.com">Foo</a>')
+ project.import_state.update!(last_error: '<a href="http://googl.com">Foo</a>')
sign_in(user)
project.add_maintainer(user)
end
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 32819fc2cb0..1acc07dabb6 100644
--- a/spec/views/projects/merge_requests/show.html.haml_spec.rb
+++ b/spec/views/projects/merge_requests/show.html.haml_spec.rb
@@ -12,7 +12,7 @@ RSpec.describe 'projects/merge_requests/show.html.haml' do
describe 'merge request assignee sidebar' do
context 'when assignee is allowed to merge' do
it 'does not show a warning icon' do
- closed_merge_request.update(assignee_id: user.id)
+ closed_merge_request.update!(assignee_id: user.id)
project.add_maintainer(user)
assign(:issuable_sidebar, serialize_issuable_sidebar(user, project, closed_merge_request))
@@ -42,20 +42,4 @@ RSpec.describe 'projects/merge_requests/show.html.haml' do
expect(rendered).to have_css('a', visible: false, text: 'Close')
end
end
-
- context 'when the merge request is open' do
- it 'closes the merge request if the source project does not exist' do
- closed_merge_request.update(state: 'open')
- forked_project.destroy
- # Reload merge request so MergeRequest#source_project turns to `nil`
- closed_merge_request.reload
- preload_view_requirements
-
- render
-
- expect(closed_merge_request.reload.state).to eq('closed')
- expect(rendered).to have_css('a', visible: false, text: 'Reopen')
- expect(rendered).to have_css('a', visible: false, text: 'Close')
- end
- end
end
diff --git a/spec/views/projects/pipelines/new.html.haml_spec.rb b/spec/views/projects/pipelines/new.html.haml_spec.rb
new file mode 100644
index 00000000000..2deacfa8478
--- /dev/null
+++ b/spec/views/projects/pipelines/new.html.haml_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe 'projects/pipelines/new' do
+ include Devise::Test::ControllerHelpers
+ let_it_be(:project) { create(:project, :repository) }
+ let(:pipeline) { create(:ci_pipeline, project: project) }
+
+ before do
+ assign(:project, project)
+ assign(:pipeline, pipeline)
+
+ stub_feature_flags(new_pipeline_form: false)
+ end
+
+ describe '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('div.alert-warning')
+ expect(rendered).to have_content('warning 1')
+ expect(rendered).to have_content('warning 2')
+ end
+ end
+end
diff --git a/spec/views/projects/pipelines/show.html.haml_spec.rb b/spec/views/projects/pipelines/show.html.haml_spec.rb
new file mode 100644
index 00000000000..49add434ab5
--- /dev/null
+++ b/spec/views/projects/pipelines/show.html.haml_spec.rb
@@ -0,0 +1,77 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+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) }
+
+ before do
+ assign(:project, project)
+ assign(:pipeline, presented_pipeline)
+
+ 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')
+ end
+
+ it 'shows errors' do
+ render
+
+ expect(rendered).to have_content('Found errors in your .gitlab-ci.yml')
+ expect(rendered).to have_content('some errors')
+ end
+
+ it 'does not render the pipeline tabs' do
+ render
+
+ 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
+ it 'does not show errors' do
+ render
+
+ expect(rendered).not_to have_content('Found errors in your .gitlab-ci.yml')
+ end
+
+ it 'renders the pipeline tabs' do
+ render
+
+ 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/projects/services/_form.haml_spec.rb b/spec/views/projects/services/_form.haml_spec.rb
index f5c4e79a082..4ca64eb3129 100644
--- a/spec/views/projects/services/_form.haml_spec.rb
+++ b/spec/views/projects/services/_form.haml_spec.rb
@@ -7,8 +7,6 @@ RSpec.describe 'projects/services/_form' do
let(:user) { create(:admin) }
before do
- stub_feature_flags(integration_form_refactor: false)
-
assign(:project, project)
allow(controller).to receive(:current_user).and_return(user)
@@ -29,8 +27,6 @@ RSpec.describe 'projects/services/_form' do
render
- expect(rendered).to have_content('Event will be triggered when a commit is created/updated')
- expect(rendered).to have_content('Event will be triggered when a merge request is created/updated/merged')
expect(rendered).to have_css("input[name='redirect_to'][value='/services']", count: 1, visible: false)
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 1f0b0ea76bf..b4d20da0a5c 100644
--- a/spec/views/projects/settings/operations/show.html.haml_spec.rb
+++ b/spec/views/projects/settings/operations/show.html.haml_spec.rb
@@ -35,7 +35,7 @@ RSpec.describe 'projects/settings/operations/show' do
it 'renders the Operations Settings page' do
render template: 'projects/settings/operations/show', locals: operations_show_locals
- expect(rendered).to have_content _('Error Tracking')
+ expect(rendered).to have_content _('Error tracking')
expect(rendered).to have_content _('To link Sentry to GitLab, enter your Sentry URL and Auth Token')
end
end
diff --git a/spec/views/search/show.html.haml_spec.rb b/spec/views/search/show.html.haml_spec.rb
index 9ddfe08c8f3..eb763d424d3 100644
--- a/spec/views/search/show.html.haml_spec.rb
+++ b/spec/views/search/show.html.haml_spec.rb
@@ -33,5 +33,37 @@ RSpec.describe 'search/show' do
expect(rendered).to render_template('search/_category')
expect(rendered).to render_template('search/_results')
end
+
+ context 'unfurling support' do
+ let(:group) { build(:group) }
+ let(:search_results) do
+ instance_double(Gitlab::GroupSearchResults).tap do |double|
+ allow(double).to receive(:formatted_count).and_return(0)
+ end
+ end
+
+ before do
+ assign(:search_results, search_results)
+ assign(:scope, 'issues')
+ assign(:group, group)
+ end
+
+ it 'renders meta tags for a group' do
+ render
+
+ expect(view.page_description).to match(/\d+ issues for term '#{search_term}'/)
+ expect(view.page_card_attributes).to eq("Namespace" => group.full_path)
+ end
+
+ it 'renders meta tags for both group and project' do
+ project = build(:project, group: group)
+ assign(:project, project)
+
+ render
+
+ expect(view.page_description).to match(/\d+ issues for term '#{search_term}'/)
+ expect(view.page_card_attributes).to eq("Namespace" => group.full_path, "Project" => project.full_path)
+ end
+ 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 1e2ed41bafc..8f8aa3072e2 100644
--- a/spec/views/shared/_label_row.html.haml_spec.rb
+++ b/spec/views/shared/_label_row.html.haml_spec.rb
@@ -9,7 +9,7 @@ RSpec.describe 'shared/_label_row.html.haml' do
label_types.each do |label_type, label_factory|
let!(:label) do
- label_record = create(label_factory)
+ label_record = create(label_factory) # rubocop: disable Rails/SaveBang
label_record.present(issuable_subject: label_record.subject)
end