summaryrefslogtreecommitdiff
path: root/spec/views
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzegorz@gitlab.com>2019-03-05 08:43:29 +0000
committerGrzegorz Bizon <grzegorz@gitlab.com>2019-03-05 08:43:29 +0000
commitd317aaf70f49fc71be2bfa43e0668cc5e5277ddc (patch)
tree2bb9cebd328d4b0f2b0466af9ac3e6fd3d3da1c4 /spec/views
parent17a014faa6a64dfd6695c227e6f3d6c5edc43c26 (diff)
parent99b2a5a2ebcf878b09e0591a7e4c39fe533e8e74 (diff)
downloadgitlab-ce-d317aaf70f49fc71be2bfa43e0668cc5e5277ddc.tar.gz
Merge branch '45305-ci-status-icon-mismatch-on-merge-requests-page-and-the-mr-itself' into 'master'
Resolve "CI status icon mismatch on Merge Requests page and the MR itself" Closes #45305 See merge request gitlab-org/gitlab-ce!25407
Diffstat (limited to 'spec/views')
-rw-r--r--spec/views/ci/status/_icon.html.haml_spec.rb89
1 files changed, 89 insertions, 0 deletions
diff --git a/spec/views/ci/status/_icon.html.haml_spec.rb b/spec/views/ci/status/_icon.html.haml_spec.rb
new file mode 100644
index 00000000000..626159fc512
--- /dev/null
+++ b/spec/views/ci/status/_icon.html.haml_spec.rb
@@ -0,0 +1,89 @@
+# frozen_string_literal: true
+require 'spec_helper'
+
+describe 'ci/status/_icon' do
+ let(:user) { create(:user) }
+ let(:project) { create(:project, :private) }
+ let(:pipeline) { create(:ci_pipeline, project: project) }
+
+ context 'when rendering status for build' do
+ let(:build) do
+ create(:ci_build, :success, pipeline: pipeline)
+ end
+
+ context 'when user has ability to see details' do
+ before do
+ project.add_developer(user)
+ end
+
+ it 'has link to build details page' do
+ details_path = project_job_path(project, build)
+
+ render_status(build)
+
+ expect(rendered).to have_link(href: details_path)
+ end
+ end
+
+ context 'when user do not have ability to see build details' do
+ before do
+ render_status(build)
+ end
+
+ it 'contains build status text' do
+ expect(rendered).to have_css('.ci-status-icon.ci-status-icon-success')
+ end
+
+ it 'does not contain links' do
+ expect(rendered).not_to have_link
+ end
+ end
+ end
+
+ context 'when rendering status for external job' do
+ context 'when user has ability to see commit status details' do
+ before do
+ project.add_developer(user)
+ end
+
+ context 'status has external target url' do
+ before do
+ external_job = create(:generic_commit_status,
+ status: :running,
+ pipeline: pipeline,
+ target_url: 'http://gitlab.com')
+
+ render_status(external_job)
+ end
+
+ it 'contains valid commit status text' do
+ expect(rendered).to have_css('.ci-status-icon.ci-status-icon-running')
+ end
+
+ it 'has link to external status page' do
+ expect(rendered).to have_link(href: 'http://gitlab.com')
+ end
+ end
+
+ context 'status do not have external target url' do
+ before do
+ external_job = create(:generic_commit_status, status: :canceled)
+
+ render_status(external_job)
+ end
+
+ it 'contains valid commit status text' do
+ expect(rendered).to have_css('.ci-status-icon.ci-status-icon-canceled')
+ end
+
+ it 'has link to external status page' do
+ expect(rendered).not_to have_link
+ end
+ end
+ end
+ end
+
+ def render_status(resource)
+ render 'ci/status/icon', status: resource.detailed_status(user)
+ end
+end