Commit 2c7d9cfa authored by Tomasz Maczukin's avatar Tomasz Maczukin

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

parent 405b82af
...@@ -97,10 +97,6 @@ module Ci ...@@ -97,10 +97,6 @@ module Ci
new_build.save new_build.save
new_build new_build
end end
def available_statuses
state_machines[:status].states.map &:value
end
end end
state_machine :status, initial: :pending do state_machine :status, initial: :pending do
......
...@@ -56,6 +56,8 @@ class CommitStatus < ActiveRecord::Base ...@@ -56,6 +56,8 @@ class CommitStatus < ActiveRecord::Base
scope :ordered, -> { order(:ref, :stage_idx, :name) } scope :ordered, -> { order(:ref, :stage_idx, :name) }
scope :for_ref, ->(ref) { where(ref: ref) } scope :for_ref, ->(ref) { where(ref: ref) }
AVAILABLE_STATUSES = ['pending', 'running', 'success', 'failed', 'canceled']
state_machine :status, initial: :pending do state_machine :status, initial: :pending do
event :run do event :run do
transition pending: :running transition pending: :running
......
...@@ -125,7 +125,7 @@ module API ...@@ -125,7 +125,7 @@ module API
def filter_builds(builds, scope) def filter_builds(builds, scope)
return builds if scope.nil? || scope.empty? return builds if scope.nil? || scope.empty?
available_statuses = Ci::Build.available_statuses available_statuses = ::CommitStatus::AVAILABLE_STATUSES
scope = scope =
if scope.is_a?(String) if scope.is_a?(String)
[scope] [scope]
......
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