Commit f2c5e9a0 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'fix/ci-status-badge-view-specs' into 'master'

Add view specs for CI/CD detailed status badge

Closes #25611

See merge request !9473
parents 57c068e1 8d23b964
require 'spec_helper'
describe 'ci/status/_badge', :view do
let(:user) { create(:user) }
let(:project) { create(:empty_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 = namespace_project_build_path(
project.namespace, project, build)
render_status(build)
expect(rendered).to have_link 'passed', 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_content 'passed'
end
it 'does not contain links' do
expect(rendered).not_to have_link 'passed'
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_content 'running'
end
it 'has link to external status page' do
expect(rendered).to have_link 'running', 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_content 'canceled'
end
it 'has link to external status page' do
expect(rendered).not_to have_link 'canceled'
end
end
end
end
def render_status(resource)
render 'ci/status/badge', status: resource.detailed_status(user)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment