From fda1d011824c24fc38dcac0e2fc795a4515ae2ec Mon Sep 17 00:00:00 2001 From: ubudzisz Date: Mon, 11 Jul 2016 09:11:20 +0200 Subject: [PATCH] add git-commit-title-method into pipeline model and modify view add git-commit-title-method into tests --- app/models/ci/pipeline.rb | 4 ++++ app/views/projects/builds/_sidebar.html.haml | 2 +- spec/views/projects/builds/show.html.haml_spec.rb | 9 +++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index b468434866b..a65a826536d 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -51,6 +51,10 @@ module Ci commit.try(:message) end + def git_commit_title + commit.try(:title) + end + def short_sha Ci::Pipeline.truncate_sha(sha) end diff --git a/app/views/projects/builds/_sidebar.html.haml b/app/views/projects/builds/_sidebar.html.haml index 3fc1157ddcb..396cc4ad925 100644 --- a/app/views/projects/builds/_sidebar.html.haml +++ b/app/views/projects/builds/_sidebar.html.haml @@ -96,7 +96,7 @@ .title Commit title %p.build-light-text.append-bottom-0 - #{@build.pipeline.commit.try(:title)} + #{@build.pipeline.git_commit_title} - if @build.tags.any? .block diff --git a/spec/views/projects/builds/show.html.haml_spec.rb b/spec/views/projects/builds/show.html.haml_spec.rb index cd18d19ef5e..7051e084375 100644 --- a/spec/views/projects/builds/show.html.haml_spec.rb +++ b/spec/views/projects/builds/show.html.haml_spec.rb @@ -22,6 +22,10 @@ describe 'projects/builds/show' do it 'does not show retry button' do expect(rendered).not_to have_link('Retry') end + + it 'shows commit title' do + expect(rendered).to have_text(@git_commit_title) + end end context 'when build is not running' do @@ -33,5 +37,10 @@ describe 'projects/builds/show' do it 'shows retry button' do expect(rendered).to have_link('Retry') end + + it 'shows commit title' do + expect(rendered).to have_text(@git_commit_title) + end end + end