From daff64452ff79b95eda5eb33c5aea8aface98f2b Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 22 Dec 2016 14:02:45 +0100 Subject: [PATCH] Do not show retried builds in pipeline stage dropdown --- app/views/projects/pipelines/_stage.html.haml | 2 +- .../pipelines/_stage.html.haml_spec.rb | 46 ++++++++++++++++--- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/app/views/projects/pipelines/_stage.html.haml b/app/views/projects/pipelines/_stage.html.haml index 20456e792e7..cf1b366bf2c 100644 --- a/app/views/projects/pipelines/_stage.html.haml +++ b/app/views/projects/pipelines/_stage.html.haml @@ -1,4 +1,4 @@ %ul - - @stage.statuses.each do |status| + - @stage.statuses.latest.each do |status| %li.dropdown-build = render 'ci/status/graph_badge', subject: status diff --git a/spec/views/projects/pipelines/_stage.html.haml_spec.rb b/spec/views/projects/pipelines/_stage.html.haml_spec.rb index eb7f7ca4a1a..d25de8af5d2 100644 --- a/spec/views/projects/pipelines/_stage.html.haml_spec.rb +++ b/spec/views/projects/pipelines/_stage.html.haml_spec.rb @@ -7,15 +7,47 @@ describe 'projects/pipelines/_stage', :view do before do assign :stage, stage - - create(:ci_build, name: 'test:build', - stage: stage.name, - pipeline: pipeline) end - it 'shows the builds in the stage' do - render + context 'when there are only latest builds present' do + before do + create(:ci_build, name: 'test:build', + stage: stage.name, + pipeline: pipeline) + end - expect(rendered).to have_text 'test:build' + it 'shows the builds in the stage' do + render + + expect(rendered).to have_text 'test:build' + end + end + + context 'when build belongs to different stage' do + before do + create(:ci_build, name: 'test:build', + stage: 'other:stage', + pipeline: pipeline) + end + + it 'does not render build' do + render + + expect(rendered).not_to have_text 'test:build' + end + end + + context 'when there are retried builds present' do + before do + create_list(:ci_build, 2, name: 'test:build', + stage: stage.name, + pipeline: pipeline) + end + + it 'shows only latest builds' do + render + + expect(rendered).to have_text 'test:build', count: 1 + end end end