From dd6b16a111a6e6cce0be322be8ddba17a2a30534 Mon Sep 17 00:00:00 2001
From: Lin Jen-Shin <godfat@godfat.org>
Date: Mon, 21 Nov 2016 22:24:09 +0800
Subject: [PATCH] Use latest_for in latest_successful_for

---
 app/models/ci/pipeline.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index e566503bb1..95af8c7230 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -105,7 +105,7 @@ module Ci
     end
 
     def self.latest_successful_for(ref)
-      where(ref: ref).order(id: :desc).success.first
+      latest_for(ref).success.first
     end
 
     def self.truncate_sha(sha)
-- 
2.30.9