Fix missing ignored? for GenericCommitStatus
This commit is contained in:
parent
1817b766b2
commit
aa812dbfcc
3 changed files with 33 additions and 29 deletions
|
@ -116,10 +116,6 @@ module Ci
|
|||
end
|
||||
end
|
||||
|
||||
def ignored?
|
||||
failed? && allow_failure?
|
||||
end
|
||||
|
||||
def retryable?
|
||||
project.builds_enabled? && commands.present?
|
||||
end
|
||||
|
|
|
@ -113,6 +113,10 @@ class CommitStatus < ActiveRecord::Base
|
|||
canceled? || success? || failed?
|
||||
end
|
||||
|
||||
def ignored?
|
||||
failed? && allow_failure?
|
||||
end
|
||||
|
||||
def duration
|
||||
if started_at && finished_at
|
||||
finished_at - started_at
|
||||
|
|
|
@ -2,36 +2,40 @@ require 'spec_helper'
|
|||
|
||||
describe Ci::Status do
|
||||
describe '.get_status' do
|
||||
subject { described_class.get_status(builds) }
|
||||
subject { described_class.get_status(statuses) }
|
||||
|
||||
context 'all builds successful' do
|
||||
let(:builds) { Array.new(2) { create(:ci_build, :success) } }
|
||||
[:ci_build, :generic_commit_status].each do |type|
|
||||
context "for #{type}" do
|
||||
context 'all successful' do
|
||||
let(:statuses) { Array.new(2) { create(type, status: :success) } }
|
||||
it { is_expected.to eq 'success' }
|
||||
end
|
||||
|
||||
context 'at least one build failed' do
|
||||
let(:builds) { [create(:ci_build, :success), create(:ci_build, :failed)] }
|
||||
context 'at least one failed' do
|
||||
let(:statuses) { [create(type, status: :success), create(type, status: :failed)] }
|
||||
it { is_expected.to eq 'failed' }
|
||||
end
|
||||
|
||||
context 'at least one running' do
|
||||
let(:builds) { [create(:ci_build, :success), create(:ci_build, :running)] }
|
||||
let(:statuses) { [create(type, status: :success), create(type, status: :running)] }
|
||||
it { is_expected.to eq 'running' }
|
||||
end
|
||||
|
||||
context 'at least one pending' do
|
||||
let(:builds) { [create(:ci_build, :success), create(:ci_build, :pending)] }
|
||||
let(:statuses) { [create(type, status: :success), create(type, status: :pending)] }
|
||||
it { is_expected.to eq 'running' }
|
||||
end
|
||||
|
||||
context 'build success and failed but allowed to fail' do
|
||||
let(:builds) { [create(:ci_build, :success), create(:ci_build, :failed, :allowed_to_fail)] }
|
||||
context 'success and failed but allowed to fail' do
|
||||
let(:statuses) { [create(type, status: :success), create(type, status: :failed, allow_failure: true)] }
|
||||
it { is_expected.to eq 'success' }
|
||||
end
|
||||
|
||||
context 'one build failed but allowed to fail' do
|
||||
let(:builds) { [create(:ci_build, :failed, :allowed_to_fail)] }
|
||||
context 'one failed but allowed to fail' do
|
||||
let(:statuses) { [create(type, status: :failed, allow_failure: true)] }
|
||||
it { is_expected.to eq 'success' }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue