Tests for Admin::Targets controller

Authorization in index action is not needed.
Fix failed delete flash error message.
This commit is contained in:
Aditya Prakash 2016-03-01 03:01:49 +05:30
parent 680d23a64a
commit c219ffc9a3
2 changed files with 172 additions and 6 deletions

View file

@ -3,9 +3,7 @@ module Admin
load_and_authorize_resource :conference, find_by: :short_title
load_and_authorize_resource :target, through: :conference
def index
authorize! :update, Target.new(conference_id: @conference.id)
end
def index; end
def new
@target = @conference.targets.new
@ -39,9 +37,9 @@ module Admin
redirect_to(admin_conference_targets_path(conference_id: @conference.short_title),
notice: 'Target successfully destroyed.')
else
redirect_to(admin_conference_targets_path(conference_id: @conference.short_title),
error: 'Target was successfully destroyed.' \
"#{@target.errors.full_messages.join('. ')}.")
redirect_to admin_conference_targets_path(conference_id: @conference.short_title),
flash: { error: "Could not delete target for #{@conference.title}: "\
"#{@target.errors.full_messages.join('. ')}." }
end
end