debian-mirror-gitlab/spec/lib/gitlab/ci/status/bridge/common_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

72 lines
1.8 KiB
Ruby
Raw Normal View History

2020-11-24 15:15:51 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-04-23 21:23:45 +05:30
RSpec.describe Gitlab::Ci::Status::Bridge::Common, feature_category: :continuous_integration do
2020-11-24 15:15:51 +05:30
let_it_be(:user) { create(:user) }
let_it_be(:bridge) { create(:ci_bridge) }
let_it_be(:downstream_pipeline) { create(:ci_pipeline) }
before_all do
create(:ci_sources_pipeline,
source_pipeline: bridge.pipeline,
source_project: bridge.pipeline.project,
source_job: bridge,
pipeline: downstream_pipeline,
project: downstream_pipeline.project)
end
subject do
Gitlab::Ci::Status::Core
.new(bridge, user)
.extend(described_class)
end
describe '#details_path' do
context 'when user has access to read downstream pipeline' do
before do
downstream_pipeline.project.add_developer(user)
end
it { expect(subject).to have_details }
2022-08-27 11:52:29 +05:30
it { expect(subject.details_path).to include "pipelines/#{downstream_pipeline.id}" }
2020-11-24 15:15:51 +05:30
end
context 'when user does not have access to read downstream pipeline' do
it { expect(subject).not_to have_details }
it { expect(subject.details_path).to be_nil }
end
end
2023-04-23 21:23:45 +05:30
describe '#label' do
let(:description) { 'my description' }
let(:bridge) { create(:ci_bridge, description: description) }
subject do
Gitlab::Ci::Status::Created
.new(bridge, user)
.extend(described_class)
end
it 'returns description' do
expect(subject.label).to eq description
end
context 'when description is nil' do
let(:description) { nil }
it 'returns core status label' do
expect(subject.label).to eq('created')
end
end
context 'when description is empty string' do
let(:description) { '' }
it 'returns core status label' do
expect(subject.label).to eq('created')
end
end
end
2020-11-24 15:15:51 +05:30
end