From 49ee28e1075f8c92b34933c934a4e1c6e37b41cd Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 10 Jul 2015 16:48:17 +0200 Subject: Fix specs --- app/models/commit.rb | 16 ++++++++++------ app/views/builds/show.html.haml | 2 +- app/views/commits/show.html.haml | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/app/models/commit.rb b/app/models/commit.rb index c7584c6..eea3653 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -138,20 +138,24 @@ class Commit < ActiveRecord::Base end def builds_without_retry - return unless config_processor @builds_without_retry ||= begin - job_types = config_processor.types grouped_builds = builds.group_by(&:name) - grouped_builds = grouped_builds.map do |name, builds| + grouped_builds.map do |name, builds| builds.sort_by(&:id).last end - grouped_builds.sort_by do |build| - [job_types.index(build.job_type), build.name] - end end end + def builds_without_retry_sorted + return builds_without_retry unless config_processor + + job_types = config_processor.types + builds_without_retry.sort_by do |build| + [job_types.index(build.job_type) || -1, build.name || ""] + end + end + def retried_builds @retried_builds ||= (builds.order(id: :desc) - builds_without_retry) end diff --git a/app/views/builds/show.html.haml b/app/views/builds/show.html.haml index 5ddaa3c..55ac8af 100644 --- a/app/views/builds/show.html.haml +++ b/app/views/builds/show.html.haml @@ -10,7 +10,7 @@ #up-build-trace - if @commit.matrix? %ul.nav.nav-tabs.append-bottom-10 - - @commit.builds_without_retry.each do |build| + - @commit.builds_without_retry_sorted.each do |build| %li{class: ('active' if build == @build) } = link_to build_url(build) do %i{class: build_icon_css_class(build)} diff --git a/app/views/commits/show.html.haml b/app/views/commits/show.html.haml index 5925b9d..d335754 100644 --- a/app/views/commits/show.html.haml +++ b/app/views/commits/show.html.haml @@ -75,7 +75,7 @@ - if @project.coverage_enabled? %th Coverage %th - = render @commit.builds_without_retry, controls: true + = render @commit.builds_without_retry_sorted, controls: true - if @commit.retried_builds.any? %h3 -- cgit v1.2.1