diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-17 16:13:19 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-10-17 16:13:19 +0200 |
commit | 9b790f1cf97157240178601c62d2e557a404503e (patch) | |
tree | 5013faeb348f3b68c5066742bac575026d6e74a7 /app/models/environment.rb | |
parent | 50d3cc2b677dac855a6270f5ffed7085df8edcf8 (diff) | |
download | gitlab-ce-9b790f1cf97157240178601c62d2e557a404503e.tar.gz |
Improve after code review
Diffstat (limited to 'app/models/environment.rb')
-rw-r--r-- | app/models/environment.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/app/models/environment.rb b/app/models/environment.rb index 93e7dedd6f8..20da71ccb3f 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -19,10 +19,7 @@ class Environment < ActiveRecord::Base allow_nil: true, addressable_url: true - delegate :stoppable?, :stop_action, to: :last_deployment, allow_nil: true - - scope :available, -> { where(state: [:available]) } - scope :stopped, -> { where(state: [:stopped]) } + delegate :stop_action, to: :last_deployment, allow_nil: true state_machine :state, initial: :available do event :start do @@ -84,4 +81,8 @@ class Environment < ActiveRecord::Base external_url.gsub(/\A.*?:\/\//, '') end + + def stoppable? + available? && stop_action.present? + end end |