Move Ci::Build#available_statuses to AVAILABLE_STATUSES constant in CommitStatus

This commit is contained in:
Tomasz Maczukin 2016-01-14 14:59:04 +01:00
parent 405b82af23
commit 2c7d9cfa7d
3 changed files with 3 additions and 5 deletions

View file

@ -97,10 +97,6 @@ module Ci
new_build.save
new_build
end
def available_statuses
state_machines[:status].states.map &:value
end
end
state_machine :status, initial: :pending do

View file

@ -56,6 +56,8 @@ class CommitStatus < ActiveRecord::Base
scope :ordered, -> { order(:ref, :stage_idx, :name) }
scope :for_ref, ->(ref) { where(ref: ref) }
AVAILABLE_STATUSES = ['pending', 'running', 'success', 'failed', 'canceled']
state_machine :status, initial: :pending do
event :run do
transition pending: :running

View file

@ -125,7 +125,7 @@ module API
def filter_builds(builds, scope)
return builds if scope.nil? || scope.empty?
available_statuses = Ci::Build.available_statuses
available_statuses = ::CommitStatus::AVAILABLE_STATUSES
scope =
if scope.is_a?(String)
[scope]