From 73fcfb296c90746f868ec11a19477a16039ef9a5 Mon Sep 17 00:00:00 2001
From: Grzegorz Bizon <grzesiek.bizon@gmail.com>
Date: Wed, 18 Jan 2017 11:34:55 +0100
Subject: [PATCH] Add a default status const to common status concern

---
 app/models/concerns/has_status.rb       | 1 +
 lib/gitlab/ci/status/factory.rb         | 2 +-
 spec/models/concerns/has_status_spec.rb | 6 ++++++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/app/models/concerns/has_status.rb b/app/models/concerns/has_status.rb
index 90432fc4050..431c0354969 100644
--- a/app/models/concerns/has_status.rb
+++ b/app/models/concerns/has_status.rb
@@ -1,6 +1,7 @@
 module HasStatus
   extend ActiveSupport::Concern
 
+  DEFAULT_STATUS = 'created'
   AVAILABLE_STATUSES = %w[created pending running success failed canceled skipped]
   STARTED_STATUSES = %w[running success failed skipped]
   ACTIVE_STATUSES = %w[pending running]
diff --git a/lib/gitlab/ci/status/factory.rb b/lib/gitlab/ci/status/factory.rb
index 4d7c71ed469..15836c699c7 100644
--- a/lib/gitlab/ci/status/factory.rb
+++ b/lib/gitlab/ci/status/factory.rb
@@ -5,7 +5,7 @@ module Gitlab
         def initialize(subject, user)
           @subject = subject
           @user = user
-          @status = subject.status || :created
+          @status = subject.status || HasStatus::DEFAULT_STATUS
         end
 
         def fabricate!
diff --git a/spec/models/concerns/has_status_spec.rb b/spec/models/concerns/has_status_spec.rb
index 4d0f51fe82a..dbfe3cd2d36 100644
--- a/spec/models/concerns/has_status_spec.rb
+++ b/spec/models/concerns/has_status_spec.rb
@@ -219,4 +219,10 @@ describe HasStatus do
       end
     end
   end
+
+  describe '::DEFAULT_STATUS' do
+    it 'is a status created' do
+      expect(described_class::DEFAULT_STATUS).to eq 'created'
+    end
+  end
 end
-- 
GitLab