Fix some buggy error handling code in Admin::ProcedureController#clone
This commit is contained in:
parent
45e5f77e52
commit
093d853ecc
3 changed files with 7 additions and 5 deletions
|
@ -160,13 +160,13 @@ class Admin::ProceduresController < AdminController
|
|||
|
||||
def clone
|
||||
procedure = Procedure.find(params[:procedure_id])
|
||||
|
||||
new_procedure = procedure.clone(current_administrateur)
|
||||
if new_procedure
|
||||
|
||||
if new_procedure.save
|
||||
flash.notice = 'Procédure clonée'
|
||||
redirect_to edit_admin_procedure_path(id: new_procedure.id)
|
||||
else
|
||||
flash.now.alert = procedure.errors.full_messages
|
||||
flash.now.alert = new_procedure.errors.full_messages
|
||||
render 'index'
|
||||
end
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ class Procedure < ActiveRecord::Base
|
|||
procedure.refused_mail = refused_mail.try(:dup)
|
||||
procedure.without_continuation_mail = without_continuation_mail.try(:dup)
|
||||
|
||||
return procedure if procedure.save
|
||||
procedure
|
||||
end
|
||||
|
||||
def brouillon?
|
||||
|
|
|
@ -167,6 +167,8 @@ describe Procedure do
|
|||
@logo = File.open('spec/fixtures/white.png')
|
||||
@signature = File.open('spec/fixtures/black.png')
|
||||
@attestation_template = create(:attestation_template, procedure: procedure, logo: @logo, signature: @signature)
|
||||
@procedure = procedure.clone(procedure.administrateur)
|
||||
@procedure.save
|
||||
end
|
||||
|
||||
after do
|
||||
|
@ -174,7 +176,7 @@ describe Procedure do
|
|||
@signature.close
|
||||
end
|
||||
|
||||
subject { procedure.clone(procedure.administrateur) }
|
||||
subject { @procedure }
|
||||
|
||||
it 'should duplicate specific objects with different id' do
|
||||
expect(subject.id).not_to eq(procedure.id)
|
||||
|
|
Loading…
Reference in a new issue