From c1334e59cc869241f6a236029355ac588093210f Mon Sep 17 00:00:00 2001 From: Ana Date: Mon, 8 Aug 2016 23:57:03 +0200 Subject: [PATCH] Do not use unless with else Solve Rubocop offense introduced in https://github.com/openSUSE/osem/pull/1123 --- app/controllers/admin/questions_controller.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/questions_controller.rb b/app/controllers/admin/questions_controller.rb index 701f1fb2..b3f2be23 100644 --- a/app/controllers/admin/questions_controller.rb +++ b/app/controllers/admin/questions_controller.rb @@ -67,8 +67,9 @@ module Admin def destroy if can? :destroy, @question # Do not delete global questions - unless @question.global - + if @question.global + flash[:error] = 'You cannot delete global questions.' + else # Delete question and its answers begin Question.transaction do @@ -82,8 +83,6 @@ module Admin rescue ActiveRecord::RecordInvalid flash[:error] = 'Could not delete question.' end - else - flash[:error] = 'You cannot delete global questions.' end else flash[:error] = 'You must be an admin to delete a question.'