From ef032bb9f11d0ebdef9a0faa7d394fd81bb86d49 Mon Sep 17 00:00:00 2001
From: Grzegorz Bizon <grzesiek.bizon@gmail.com>
Date: Fri, 22 Apr 2016 13:28:25 +0200
Subject: [PATCH] Fix error on commit builds page when no builds yet

Closes #15509
---
 .../projects/commit/_ci_commit.html.haml      |  2 +-
 spec/features/projects/commit/builds_spec.rb  | 27 +++++++++++++++++++
 2 files changed, 28 insertions(+), 1 deletion(-)
 create mode 100644 spec/features/projects/commit/builds_spec.rb

diff --git a/app/views/projects/commit/_ci_commit.html.haml b/app/views/projects/commit/_ci_commit.html.haml
index 25714e6cb47..d3acd33116c 100644
--- a/app/views/projects/commit/_ci_commit.html.haml
+++ b/app/views/projects/commit/_ci_commit.html.haml
@@ -16,7 +16,7 @@
     - if defined?(link_to_commit) && link_to_commit
       for commit
       = link_to ci_commit.short_sha, namespace_project_commit_path(@project.namespace, @project, ci_commit.sha), class: "monospace"
-    - if ci_commit.duration > 0
+    - if ci_commit.duration
       in
       = time_interval_in_words ci_commit.duration
 
diff --git a/spec/features/projects/commit/builds_spec.rb b/spec/features/projects/commit/builds_spec.rb
new file mode 100644
index 00000000000..40ba0bdc115
--- /dev/null
+++ b/spec/features/projects/commit/builds_spec.rb
@@ -0,0 +1,27 @@
+require 'spec_helper'
+
+feature 'project commit builds' do
+  given(:project) { create(:project) }
+
+  background do
+    user = create(:user)
+    project.team << [user, :master]
+    login_as(user)
+  end
+
+  context 'when no builds triggered yet' do
+    background do
+      create(:ci_commit, project: project,
+                         sha: project.commit.sha,
+                         ref: 'master')
+    end
+
+    scenario 'user views commit builds page' do
+      visit builds_namespace_project_commit_path(project.namespace,
+                                                 project, project.commit.sha)
+
+
+      expect(page).to have_content('Builds')
+    end
+  end
+end
-- 
GitLab