summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-09-18 20:22:08 +0000
committerStan Hu <stanhu@gmail.com>2016-09-18 20:22:08 +0000
commit1d51bc7dfd04886fa5af69a60bb509691d697813 (patch)
tree2837bea8a6ae93267548dc99e26e49eeede6af27
parentf374379834b13f574015917440b0e7e702d8198f (diff)
parentbf41ab2640d215dccd890cc9ba3dd4f3f72cf84a (diff)
downloadgitlab-ce-1d51bc7dfd04886fa5af69a60bb509691d697813.tar.gz
Merge branch '22286-fix-missing-status' into 'master'
Return created status ## What does this MR do? Properly handles status created which results in 500 when viewing Merge Request pipelines. ## Are there points in the code the reviewer needs to double check? ## Why was this MR needed? ## Screenshots (if relevant) ## Does this MR meet the acceptance criteria? - Tests - [x] Added for this feature/bug - [x] All builds are passing - [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html) - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) ## What are the relevant issue numbers? Closes #22286 See merge request !6404
-rw-r--r--app/models/concerns/has_status.rb2
-rw-r--r--spec/requests/api/commits_spec.rb2
-rw-r--r--spec/views/projects/pipelines/show.html.haml_spec.rb17
3 files changed, 12 insertions, 9 deletions
diff --git a/app/models/concerns/has_status.rb b/app/models/concerns/has_status.rb
index d658552f695..0fa4df0fb56 100644
--- a/app/models/concerns/has_status.rb
+++ b/app/models/concerns/has_status.rb
@@ -20,7 +20,7 @@ module HasStatus
skipped = scope.skipped.select('count(*)').to_sql
deduce_status = "(CASE
- WHEN (#{builds})=(#{created}) THEN NULL
+ WHEN (#{builds})=(#{created}) THEN 'created'
WHEN (#{builds})=(#{skipped}) THEN 'skipped'
WHEN (#{builds})=(#{success})+(#{ignored})+(#{skipped}) THEN 'success'
WHEN (#{builds})=(#{created})+(#{pending})+(#{skipped}) THEN 'pending'
diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb
index 5b3dc60aba2..10f772c5b1a 100644
--- a/spec/requests/api/commits_spec.rb
+++ b/spec/requests/api/commits_spec.rb
@@ -110,7 +110,7 @@ describe API::API, api: true do
get api("/projects/#{project.id}/repository/commits/#{project.repository.commit.id}", user)
expect(response).to have_http_status(200)
- expect(json_response['status']).to be_nil
+ expect(json_response['status']).to eq("created")
end
end
diff --git a/spec/views/projects/pipelines/show.html.haml_spec.rb b/spec/views/projects/pipelines/show.html.haml_spec.rb
index c5b16c1c304..ac7f3ffb157 100644
--- a/spec/views/projects/pipelines/show.html.haml_spec.rb
+++ b/spec/views/projects/pipelines/show.html.haml_spec.rb
@@ -9,11 +9,13 @@ describe 'projects/pipelines/show' do
before do
controller.prepend_view_path('app/views/projects')
- create_build('build', 0, 'build')
- create_build('test', 1, 'rspec 0:2')
- create_build('test', 1, 'rspec 1:2')
- create_build('test', 1, 'audit')
- create_build('deploy', 2, 'production')
+ create_build('build', 0, 'build', :success)
+ create_build('test', 1, 'rspec 0:2', :pending)
+ create_build('test', 1, 'rspec 1:2', :running)
+ create_build('test', 1, 'spinach 0:2', :created)
+ create_build('test', 1, 'spinach 1:2', :created)
+ create_build('test', 1, 'audit', :created)
+ create_build('deploy', 2, 'production', :created)
create(:generic_commit_status, pipeline: pipeline, stage: 'external', name: 'jenkins', stage_idx: 3)
@@ -37,6 +39,7 @@ describe 'projects/pipelines/show' do
# builds
expect(rendered).to have_text('rspec')
+ expect(rendered).to have_text('spinach')
expect(rendered).to have_text('rspec 0:2')
expect(rendered).to have_text('production')
expect(rendered).to have_text('jenkins')
@@ -44,7 +47,7 @@ describe 'projects/pipelines/show' do
private
- def create_build(stage, stage_idx, name)
- create(:ci_build, pipeline: pipeline, stage: stage, stage_idx: stage_idx, name: name)
+ def create_build(stage, stage_idx, name, status)
+ create(:ci_build, pipeline: pipeline, stage: stage, stage_idx: stage_idx, name: name, status: status)
end
end