summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-11-17 12:08:28 +0100
committerKamil Trzcinski <ayufan@ayufan.eu>2016-11-17 12:08:28 +0100
commit43906336ff24e218cb1f7024d63a22367dd7e09a (patch)
tree326f69374123c68075942d45180b4c887376ba04 /app
parentd6e00f5373e24deaa7f143f5445ae9461ef5f615 (diff)
downloadgitlab-ce-43906336ff24e218cb1f7024d63a22367dd7e09a.tar.gz
Fix tests and add has_environment?
Diffstat (limited to 'app')
-rw-r--r--app/models/ci/build.rb10
-rw-r--r--app/views/projects/builds/show.html.haml2
-rw-r--r--app/workers/build_success_worker.rb2
3 files changed, 9 insertions, 5 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index e0e7a8caeea..7aa6d0a6bf2 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -131,12 +131,16 @@ module Ci
ExpandVariables.expand(environment, variables) if environment
end
+ def has_environment?
+ self.environment.present?
+ end
+
def starts_environment?
- self.environment.present? && self.environment_action == 'start'
+ has_environment? && self.environment_action == 'start'
end
def stops_environment?
- self.environment.present? && self.environment_action == 'stop'
+ has_environment? && self.environment_action == 'stop'
end
def environment_action
@@ -148,7 +152,7 @@ module Ci
end
def last_deployment
- deployments.order(id: :desc).last
+ deployments.last
end
def depends_on_builds
diff --git a/app/views/projects/builds/show.html.haml b/app/views/projects/builds/show.html.haml
index d799671058d..efb130a5dd8 100644
--- a/app/views/projects/builds/show.html.haml
+++ b/app/views/projects/builds/show.html.haml
@@ -26,7 +26,7 @@
= link_to namespace_project_runners_path(@build.project.namespace, @build.project) do
Runners page
- - if @build.environment.present? && @build.starts_environment?
+ - if @build.starts_environment?
.prepend-top-default
.environment-information
- if @build.outdated_deployment?
diff --git a/app/workers/build_success_worker.rb b/app/workers/build_success_worker.rb
index 450ba871c4c..e17add7421f 100644
--- a/app/workers/build_success_worker.rb
+++ b/app/workers/build_success_worker.rb
@@ -4,7 +4,7 @@ class BuildSuccessWorker
def perform(build_id)
Ci::Build.find_by(id: build_id).try do |build|
- create_deployment(build) if build.environment.present?
+ create_deployment(build) if build.has_environment?
end
end