diff options
Diffstat (limited to 'spec/views/projects/commit/_commit_box.html.haml_spec.rb')
-rw-r--r-- | spec/views/projects/commit/_commit_box.html.haml_spec.rb | 64 |
1 files changed, 54 insertions, 10 deletions
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 e741e3cf9b6..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,13 +1,13 @@ require 'spec_helper' -describe 'projects/commit/_commit_box.html.haml' do - include Devise::Test::ControllerHelpers - - let(:project) { create(:project) } +describe 'projects/commit/_commit_box.html.haml', :view do + let(:user) { create(:user) } + let(:project) { create(:project, :repository) } before do assign(:project, project) assign(:commit, project.commit) + allow(view).to receive(:can_collaborate_with_project?).and_return(false) end it 'shows the commit SHA' do @@ -16,13 +16,57 @@ 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 + + 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 + context 'as a developer' do + before do + expect(view).to receive(:can_collaborate_with_project?).and_return(true) + end + + it 'has a link to create a new tag' do + render + + expect(rendered).to have_link('Tag') + end + end + + context 'as a non-developer' do + before do + expect(view).to receive(:can_collaborate_with_project?).and_return(false) + end + + it 'does not have a link to create a new tag' do + render - expect(rendered).to have_text("Pipeline ##{third_pipeline.id} for #{Commit.truncate_sha(project.commit.sha)} failed") + expect(rendered).not_to have_link('Tag') + end + end end end |