summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-10-17 16:13:19 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-10-17 16:13:19 +0200
commit9b790f1cf97157240178601c62d2e557a404503e (patch)
tree5013faeb348f3b68c5066742bac575026d6e74a7 /app/controllers
parent50d3cc2b677dac855a6270f5ffed7085df8edcf8 (diff)
downloadgitlab-ce-9b790f1cf97157240178601c62d2e557a404503e.tar.gz
Improve after code review
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/projects/environments_controller.rb11
1 files changed, 5 insertions, 6 deletions
diff --git a/app/controllers/projects/environments_controller.rb b/app/controllers/projects/environments_controller.rb
index efdfbd24cae..86bc17a720a 100644
--- a/app/controllers/projects/environments_controller.rb
+++ b/app/controllers/projects/environments_controller.rb
@@ -8,11 +8,8 @@ class Projects::EnvironmentsController < Projects::ApplicationController
def index
@scope = params[:scope]
@all_environments = project.environments
- @environments =
- case @scope
- when 'stopped' then @all_environments.stopped
- else @all_environments.available
- end
+ @environments = @scope == 'stopped' ?
+ @all_environments.stopped : @all_environments.available
end
def show
@@ -45,9 +42,11 @@ class Projects::EnvironmentsController < Projects::ApplicationController
end
def stop
+ return render_404 unless @environment.stoppable?
+
action = @environment.stop_action
new_action = action.active? ? action : action.play(current_user)
- redirect_to [project.namespace.becomes(Namespace), project, new_action]
+ redirect_to polymorphic_path([project.namespace.becomes(Namespace), project, new_action])
end
private