Commit 21f3e9ce authored by Grzegorz Bizon's avatar Grzegorz Bizon

Move custom compound status method to commit status

parent 64e09a1b
......@@ -103,6 +103,12 @@ class CommitStatus < ActiveRecord::Base
end
end
def self.status
super.tap do |status|
return 'success' if status == 'skipped' && all.failed_but_allowed.any?
end
end
def locking_enabled?
status_changed?
end
......
......@@ -37,9 +37,7 @@ module HasStatus
end
def status
all.pluck(status_sql).first.tap do |status|
return 'success' if status == 'skipped' && all.failed_but_allowed.any?
end
all.pluck(status_sql).first
end
def started_at
......
......@@ -284,6 +284,30 @@ describe CommitStatus, :models do
end
end
describe '.status' do
context 'when there are multiple statuses present' do
before do
create_status(status: 'running')
create_status(status: 'success')
create_status(allow_failure: true, status: 'failed')
end
it 'returns a correct compound status' do
expect(described_class.all.status).to eq 'running'
end
end
context 'when there are only allowed to fail commit statuses present' do
before do
create_status(allow_failure: true, status: 'failed')
end
it 'returns status that indicates success' do
expect(described_class.all.status).to eq 'success'
end
end
end
describe '#before_sha' do
subject { commit_status.before_sha }
......
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