Do not use unless with else
Solve Rubocop offense introduced in https://github.com/openSUSE/osem/pull/1123
This commit is contained in:
parent
859b3beda6
commit
c1334e59cc
1 changed files with 3 additions and 4 deletions
|
|
@ -67,8 +67,9 @@ module Admin
|
||||||
def destroy
|
def destroy
|
||||||
if can? :destroy, @question
|
if can? :destroy, @question
|
||||||
# Do not delete global questions
|
# Do not delete global questions
|
||||||
unless @question.global
|
if @question.global
|
||||||
|
flash[:error] = 'You cannot delete global questions.'
|
||||||
|
else
|
||||||
# Delete question and its answers
|
# Delete question and its answers
|
||||||
begin
|
begin
|
||||||
Question.transaction do
|
Question.transaction do
|
||||||
|
|
@ -82,8 +83,6 @@ module Admin
|
||||||
rescue ActiveRecord::RecordInvalid
|
rescue ActiveRecord::RecordInvalid
|
||||||
flash[:error] = 'Could not delete question.'
|
flash[:error] = 'Could not delete question.'
|
||||||
end
|
end
|
||||||
else
|
|
||||||
flash[:error] = 'You cannot delete global questions.'
|
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
flash[:error] = 'You must be an admin to delete a question.'
|
flash[:error] = 'You must be an admin to delete a question.'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue