From ec586042e0f23696f0b3b34a7e7d5bf7c36ea2c7 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Fri, 21 Apr 2017 22:17:14 +0200 Subject: Fix lastest commit status text on main project page --- spec/views/projects/_last_commit.html.haml_spec.rb | 22 ++++++++++++++ .../projects/commit/_commit_box.html.haml_spec.rb | 34 ++++++++++++++++------ 2 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 spec/views/projects/_last_commit.html.haml_spec.rb (limited to 'spec') diff --git a/spec/views/projects/_last_commit.html.haml_spec.rb b/spec/views/projects/_last_commit.html.haml_spec.rb new file mode 100644 index 00000000000..eea1695b171 --- /dev/null +++ b/spec/views/projects/_last_commit.html.haml_spec.rb @@ -0,0 +1,22 @@ +require 'spec_helper' + +describe 'projects/_last_commit', :view do + let(:project) { create(:project, :repository) } + + context 'when there is a pipeline present for the commit' do + context 'when pipeline is blocked' do + let!(:pipeline) do + create(:ci_pipeline, :blocked, project: project, + sha: project.commit.id) + end + + it 'shows correct pipeline badge' do + render 'projects/last_commit', commit: project.commit, + project: project, + ref: :master + + expect(rendered).to have_text "blocked #{project.commit.short_id}" + end + end + end +end diff --git a/spec/views/projects/commit/_commit_box.html.haml_spec.rb b/spec/views/projects/commit/_commit_box.html.haml_spec.rb index cec87dcecc8..ab120929c6c 100644 --- a/spec/views/projects/commit/_commit_box.html.haml_spec.rb +++ b/spec/views/projects/commit/_commit_box.html.haml_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' -describe 'projects/commit/_commit_box.html.haml' do - include Devise::Test::ControllerHelpers - +describe 'projects/commit/_commit_box.html.haml', :view do let(:user) { create(:user) } let(:project) { create(:project, :repository) } @@ -18,14 +16,32 @@ describe 'projects/commit/_commit_box.html.haml' do expect(rendered).to have_text("#{Commit.truncate_sha(project.commit.sha)}") end - it 'shows the last pipeline that ran for the commit' do - create(:ci_pipeline, project: project, sha: project.commit.id, status: 'success') - create(:ci_pipeline, project: project, sha: project.commit.id, status: 'canceled') - third_pipeline = create(:ci_pipeline, project: project, sha: project.commit.id, status: 'failed') + context 'when there is a pipeline present' do + context 'when there are multiple pipelines for a commit' do + it 'shows the last pipeline' do + create(:ci_pipeline, project: project, sha: project.commit.id, status: 'success') + create(:ci_pipeline, project: project, sha: project.commit.id, status: 'canceled') + third_pipeline = create(:ci_pipeline, project: project, sha: project.commit.id, status: 'failed') - render + render + + expect(rendered).to have_text("Pipeline ##{third_pipeline.id} failed") + end + end - expect(rendered).to have_text("Pipeline ##{third_pipeline.id} failed") + context 'when pipeline for the commit is blocked' do + let!(:pipeline) do + create(:ci_pipeline, :blocked, project: project, + sha: project.commit.id) + end + + it 'shows correct pipeline description' do + render + + expect(rendered).to have_text "Pipeline ##{pipeline.id} " \ + 'waiting for manual action' + end + end end context 'viewing a commit' do -- cgit v1.2.1