Commit bcc23320 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'commit-status-fix' into 'master'

Fix missing ignored? for GenericCommitStatus

This is pretty important fix. We should not release 8.5 without this.

It critical error when handling GenericCommitStatus:
```
undefined method `ignored?' for #<GenericCommitStatus:0x007fe1a2a20fe0>
```

cc @grzesiek 


See merge request !2899
parents 94915f97 aa812dbf
...@@ -120,10 +120,6 @@ module Ci ...@@ -120,10 +120,6 @@ module Ci
end end
end end
def ignored?
failed? && allow_failure?
end
def retryable? def retryable?
project.builds_enabled? && commands.present? project.builds_enabled? && commands.present?
end end
......
...@@ -113,6 +113,10 @@ class CommitStatus < ActiveRecord::Base ...@@ -113,6 +113,10 @@ class CommitStatus < ActiveRecord::Base
canceled? || success? || failed? canceled? || success? || failed?
end end
def ignored?
failed? && allow_failure?
end
def duration def duration
if started_at && finished_at if started_at && finished_at
finished_at - started_at finished_at - started_at
......
...@@ -2,36 +2,40 @@ require 'spec_helper' ...@@ -2,36 +2,40 @@ require 'spec_helper'
describe Ci::Status do describe Ci::Status do
describe '.get_status' do describe '.get_status' do
subject { described_class.get_status(builds) } subject { described_class.get_status(statuses) }
context 'all builds successful' do [:ci_build, :generic_commit_status].each do |type|
let(:builds) { Array.new(2) { create(:ci_build, :success) } } context "for #{type}" do
context 'all successful' do
let(:statuses) { Array.new(2) { create(type, status: :success) } }
it { is_expected.to eq 'success' } it { is_expected.to eq 'success' }
end end
context 'at least one build failed' do context 'at least one failed' do
let(:builds) { [create(:ci_build, :success), create(:ci_build, :failed)] } let(:statuses) { [create(type, status: :success), create(type, status: :failed)] }
it { is_expected.to eq 'failed' } it { is_expected.to eq 'failed' }
end end
context 'at least one running' do 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' } it { is_expected.to eq 'running' }
end end
context 'at least one pending' do 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' } it { is_expected.to eq 'running' }
end end
context 'build success and failed but allowed to fail' do context 'success and failed but allowed to fail' do
let(:builds) { [create(:ci_build, :success), create(:ci_build, :failed, :allowed_to_fail)] } let(:statuses) { [create(type, status: :success), create(type, status: :failed, allow_failure: true)] }
it { is_expected.to eq 'success' } it { is_expected.to eq 'success' }
end end
context 'one build failed but allowed to fail' do context 'one failed but allowed to fail' do
let(:builds) { [create(:ci_build, :failed, :allowed_to_fail)] } let(:statuses) { [create(type, status: :failed, allow_failure: true)] }
it { is_expected.to eq 'success' } it { is_expected.to eq 'success' }
end end
end end
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