diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-17 12:45:31 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-17 12:45:31 +0200 |
commit | 6cdbb27ec3cf72ce6728986909aa3df54b7a26c6 (patch) | |
tree | b989b826e119a382e1bc0fde590e312c8d3bbcda /app/models/deployment.rb | |
parent | 7aea16b64624eb681a1c134759a8f4fa1e5b2a78 (diff) | |
download | gitlab-ce-6cdbb27ec3cf72ce6728986909aa3df54b7a26c6.tar.gz |
Refactor code to use available and stopped statuses and refactor views to use separate renders
Diffstat (limited to 'app/models/deployment.rb')
-rw-r--r-- | app/models/deployment.rb | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/app/models/deployment.rb b/app/models/deployment.rb index 054d54f124e..18d9e96301c 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -11,6 +11,8 @@ class Deployment < ActiveRecord::Base delegate :name, to: :environment, prefix: true + store :properties, accessors: [:on_stop] + after_save :create_ref def commit @@ -34,7 +36,7 @@ class Deployment < ActiveRecord::Base end def manual_actions - deployable.try(:other_actions) + @manual_actions ||= deployable.try(:other_actions) end def includes_commit?(commit) @@ -84,17 +86,14 @@ class Deployment < ActiveRecord::Base take end - def close_action + def stop_action return nil unless manual_actions - @close_action ||= - manual_actions.find do |manual_action| - manual_action.try(:closes_environment?, deployable.environment) - end + @stop_action ||= manual_actions.find_by(name: on_stop) end - def closeable? - close_action.present? + def stoppable? + on_stop.present? && stop_action.present? end def formatted_deployment_time |