summaryrefslogtreecommitdiff
path: root/spec/controllers/projects/commit_controller_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/controllers/projects/commit_controller_spec.rb')
-rw-r--r--spec/controllers/projects/commit_controller_spec.rb26
1 files changed, 24 insertions, 2 deletions
diff --git a/spec/controllers/projects/commit_controller_spec.rb b/spec/controllers/projects/commit_controller_spec.rb
index 706bf787b2d..2d7f036be21 100644
--- a/spec/controllers/projects/commit_controller_spec.rb
+++ b/spec/controllers/projects/commit_controller_spec.rb
@@ -9,6 +9,8 @@ RSpec.describe Projects::CommitController do
let(:commit) { project.commit("master") }
let(:master_pickable_sha) { '7d3b0f7cff5f37573aea97cebfd5692ea1689924' }
let(:master_pickable_commit) { project.commit(master_pickable_sha) }
+ let(:pipeline) { create(:ci_pipeline, project: project, ref: project.default_branch, sha: commit.sha, status: :running) }
+ let(:build) { create(:ci_build, pipeline: pipeline, status: :running) }
before do
sign_in(user)
@@ -33,6 +35,19 @@ RSpec.describe Projects::CommitController do
expect(response).to be_ok
end
+
+ context 'when a pipeline job is running' do
+ before do
+ build.run
+ end
+
+ it 'defines last pipeline information' do
+ go(id: commit.id)
+
+ expect(assigns(:last_pipeline)).to have_attributes(id: pipeline.id, status: 'running')
+ expect(assigns(:last_pipeline_stages)).not_to be_empty
+ end
+ end
end
context 'with invalid id' do
@@ -363,15 +378,22 @@ RSpec.describe Projects::CommitController do
context 'when the commit exists' do
context 'when the commit has pipelines' do
before do
- create(:ci_pipeline, project: project, sha: commit.id)
+ build.run
end
context 'when rendering a HTML format' do
- it 'shows pipelines' do
+ before do
get_pipelines(id: commit.id)
+ end
+ it 'shows pipelines' do
expect(response).to be_ok
end
+
+ it 'defines last pipeline information' do
+ expect(assigns(:last_pipeline)).to have_attributes(id: pipeline.id, status: 'running')
+ expect(assigns(:last_pipeline_stages)).not_to be_empty
+ end
end
context 'when rendering a JSON format' do