summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2015-09-28 15:18:25 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2015-09-29 10:47:03 +0200
commit8f8efcfa00c40beacae9886d7be51e82e7a67989 (patch)
tree2afcfcf856bdc8a538383ee910e3c086b9b71902 /app
parent2c1f7ccac8180a49e45fb3cf79e03318420d1037 (diff)
downloadgitlab-ce-8f8efcfa00c40beacae9886d7be51e82e7a67989.tar.gz
Fix tests
Diffstat (limited to 'app')
-rw-r--r--app/models/ci/project.rb6
-rw-r--r--app/models/project.rb1
-rw-r--r--app/views/ci/admin/projects/_project.html.haml2
3 files changed, 4 insertions, 5 deletions
diff --git a/app/models/ci/project.rb b/app/models/ci/project.rb
index 89bbbea5c5a..ba6e320426c 100644
--- a/app/models/ci/project.rb
+++ b/app/models/ci/project.rb
@@ -48,7 +48,7 @@ module Ci
accepts_nested_attributes_for :variables, allow_destroy: true
- delegate :commits, :builds, :last_commit, to: :gl_project
+ delegate :commits, :builds, to: :gl_project
#
# Validations
@@ -103,8 +103,8 @@ module Ci
end
def ordered_by_last_commit_date
- last_commit_subquery = "(SELECT project_id, MAX(committed_at) committed_at FROM #{Ci::Commit.table_name} GROUP BY project_id)"
- joins("LEFT JOIN #{last_commit_subquery} AS last_commit ON #{Ci::Project.table_name}.id = last_commit.project_id").
+ last_commit_subquery = "(SELECT gl_project_id, MAX(committed_at) committed_at FROM #{Ci::Commit.table_name} GROUP BY gl_project_id)"
+ joins("LEFT JOIN #{last_commit_subquery} AS last_commit ON #{Ci::Project.table_name}.gitlab_id = last_commit.gl_project_id").
order("CASE WHEN last_commit.committed_at IS NULL THEN 1 ELSE 0 END, last_commit.committed_at DESC")
end
diff --git a/app/models/project.rb b/app/models/project.rb
index ddf8526d6c2..a5393d396f8 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -120,7 +120,6 @@ class Project < ActiveRecord::Base
has_many :starrers, through: :users_star_projects, source: :user
has_many :commits, ->() { order('CASE WHEN ci_commits.committed_at IS NULL THEN 0 ELSE 1 END', :committed_at, :id) }, dependent: :destroy, class_name: 'Ci::Commit', foreign_key: :gl_project_id
has_many :builds, through: :commits, dependent: :destroy, class_name: 'Ci::Build'
- has_one :last_commit, -> { order 'ci_commits.created_at DESC' }, class_name: 'Ci::Commit', foreign_key: :gl_project_id
has_one :import_data, dependent: :destroy, class_name: "ProjectImportData"
has_one :gitlab_ci_project, dependent: :destroy, class_name: "Ci::Project", foreign_key: :gitlab_id
diff --git a/app/views/ci/admin/projects/_project.html.haml b/app/views/ci/admin/projects/_project.html.haml
index c461206c72a..a342d6e1cf0 100644
--- a/app/views/ci/admin/projects/_project.html.haml
+++ b/app/views/ci/admin/projects/_project.html.haml
@@ -1,4 +1,4 @@
-- last_commit = project.last_commit
+- last_commit = project.commits.last
%tr
%td
= project.id