Commit cb4c9a03 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Extend specs for code we use to calculate statuses

parent 80c463d9
...@@ -35,6 +35,10 @@ FactoryGirl.define do ...@@ -35,6 +35,10 @@ FactoryGirl.define do
status 'created' status 'created'
end end
trait :manual do
status 'manual'
end
after(:build) do |build, evaluator| after(:build) do |build, evaluator|
build.project = build.pipeline.project build.project = build.pipeline.project
end end
......
...@@ -109,6 +109,24 @@ describe HasStatus do ...@@ -109,6 +109,24 @@ describe HasStatus do
it { is_expected.to eq 'running' } it { is_expected.to eq 'running' }
end end
context 'when one status is a blocking manual action' do
let!(:statuses) do
[create(type, status: :failed),
create(type, status: :manual, allow_failure: false)]
end
it { is_expected.to eq 'manual' }
end
context 'when one status is a non-blocking manual action' do
let!(:statuses) do
[create(type, status: :failed),
create(type, status: :manual, allow_failure: true)]
end
it { is_expected.to eq 'failed' }
end
end end
context 'ci build statuses' do context 'ci build statuses' do
...@@ -218,6 +236,18 @@ describe HasStatus do ...@@ -218,6 +236,18 @@ describe HasStatus do
it_behaves_like 'not containing the job', status it_behaves_like 'not containing the job', status
end end
end end
describe '.manual' do
subject { CommitStatus.manual }
%i[manual].each do |status|
it_behaves_like 'containing the job', status
end
%i[failed success skipped canceled].each do |status|
it_behaves_like 'not containing the job', status
end
end
end end
describe '::DEFAULT_STATUS' do describe '::DEFAULT_STATUS' do
...@@ -225,4 +255,10 @@ describe HasStatus do ...@@ -225,4 +255,10 @@ describe HasStatus do
expect(described_class::DEFAULT_STATUS).to eq 'created' expect(described_class::DEFAULT_STATUS).to eq 'created'
end end
end end
describe '::BLOCKED_STATUS' do
it 'is a status manual' do
expect(described_class::BLOCKED_STATUS).to eq 'manual'
end
end
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