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/controllers | |
parent | 50d3cc2b677dac855a6270f5ffed7085df8edcf8 (diff) | |
download | gitlab-ce-9b790f1cf97157240178601c62d2e557a404503e.tar.gz |
Improve after code review
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/projects/environments_controller.rb | 11 |
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 |