summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-11-19 20:34:05 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2012-11-19 20:34:05 +0300
commit3d71d9a6b7a4d954bbb6f8fbf64d94c99677038b (patch)
tree1f396261f2c48bcc26b10b8af304b55b619f255c
parentf21ea7ececc62424ce9403fd19154a7152f7797c (diff)
downloadgitlab-ci-3d71d9a6b7a4d954bbb6f8fbf64d94c99677038b.tar.gz
Add running status and support for sha status
-rw-r--r--app/assets/images/.directory3
-rw-r--r--app/controllers/projects_controller.rb10
-rw-r--r--app/models/project.rb17
-rw-r--r--public/running.pngbin0 -> 2091 bytes
-rw-r--r--spec/models/project_spec.rb2
5 files changed, 30 insertions, 2 deletions
diff --git a/app/assets/images/.directory b/app/assets/images/.directory
new file mode 100644
index 0000000..0b788a9
--- /dev/null
+++ b/app/assets/images/.directory
@@ -0,0 +1,3 @@
+[Dolphin]
+PreviewsShown=true
+Timestamp=2012,11,20,17,40,33
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index ac65195..793e181 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -78,6 +78,14 @@ class ProjectsController < ApplicationController
def status
@project = Project.find(params[:id])
- send_file Rails.root.join('public', @project.status_image(params[:ref])), filename: 'success.png', disposition: 'inline'
+ image_name = if params[:sha]
+ @project.sha_status_image(params[:sha])
+ elsif params[:ref]
+ @project.status_image(params[:ref])
+ else
+ 'unknown.png'
+ end
+
+ send_file Rails.root.join('public', image_name), filename: image_name, disposition: 'inline'
end
end
diff --git a/app/models/project.rb b/app/models/project.rb
index 43bd68a..0d867b8 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -66,10 +66,27 @@ class Project < ActiveRecord::Base
def status_image ref = 'master'
build = self.builds.where(ref: ref).latest_sha.last
+ image_for_build build
+ end
+
+ def last_build_for_sha sha
+ builds.where(sha: sha).order('id DESC').limit(1).first
+ end
+
+ def sha_status_image sha
+ build = last_build_for_sha(sha)
+ image_for_build build
+ end
+
+ def image_for_build build
+ return 'unknown.png' unless build
+
if build.success?
'success.png'
elsif build.failed?
'failed.png'
+ elsif build.active?
+ 'running.png'
else
'unknown.png'
end
diff --git a/public/running.png b/public/running.png
new file mode 100644
index 0000000..8d2e7f5
--- /dev/null
+++ b/public/running.png
Binary files differ
diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb
index f085b7f..009c2c3 100644
--- a/spec/models/project_spec.rb
+++ b/spec/models/project_spec.rb
@@ -36,7 +36,7 @@ describe Project do
it { project.status.should == 'pending' }
it { project.last_build.should be_kind_of(Build) }
it { project.human_status.should == 'pending' }
- it { project.status_image.should == 'unknown.png' }
+ it { project.status_image.should == 'running.png' }
it { project.last_commit.sha.should == 'a26f8df380e56dc79cd74087c8ed4f031eef0460' }
end
end