diff --git a/app/controllers/replies_controller.rb b/app/controllers/replies_controller.rb index ad3e890..817f953 100644 --- a/app/controllers/replies_controller.rb +++ b/app/controllers/replies_controller.rb @@ -7,15 +7,23 @@ class RepliesController < ApplicationController forbid unless reply.can_edit_reply?(current_user) end + before_action only: %i[update] do + forbid unless reply.can_update_reply?(current_user) + end + + before_action only: %i[submit complete] do + forbid unless reply.can_complete_reply?(current_user) + end + + before_action only: %i[preview] do + forbid unless survey.can_preview?(current_user) + end + def edit tracker.view_submission_form(reply) render :edit, locals: { reply: } end - before_action only: %i[update] do - forbid unless reply.can_update_reply?(current_user) - end - def update if reply.update(reply_params) tracker.update_submission_form(reply) @@ -25,10 +33,6 @@ def update end end - before_action only: %i[submit] do - forbid unless reply.can_complete_reply?(current_user) - end - def submit if reply.submit(reply_params) tracker.complete_submission_form(reply) @@ -38,18 +42,10 @@ def submit end end - before_action only: %i[complete] do - forbid unless reply.can_complete_reply?(current_user) - end - def complete render :success, locals: { reply: } end - before_action only: %i[preview] do - forbid unless survey.can_preview?(current_user) - end - def preview render :edit, locals: { reply: survey.replies.build } end