From 87d7bd4fb2c7496a409a5cd2242bdc4e48a36c7a Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Mon, 28 May 2018 14:58:40 +0200 Subject: [PATCH] Fix clone procedure --- app/models/procedure.rb | 2 ++ spec/models/procedure_spec.rb | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/models/procedure.rb b/app/models/procedure.rb index af06414c2..dbf8ede3d 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -193,6 +193,8 @@ class Procedure < ApplicationRecord types_de_champ: :drop_down_list, types_de_champ_private: :drop_down_list }) + procedure.aasm_state = :brouillon + procedure.test_started_at = nil procedure.archived_at = nil procedure.published_at = nil procedure.logo_secure_token = nil diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 97a8ca7e6..15efdf5e2 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -248,10 +248,8 @@ describe Procedure do end describe 'clone' do - let(:archived_at) { nil } - let(:published_at) { nil } let!(:service) { create(:service) } - let(:procedure) { create(:procedure, archived_at: archived_at, published_at: published_at, received_mail: received_mail, service: service) } + let(:procedure) { create(:procedure, received_mail: received_mail, service: service) } let!(:type_de_champ_0) { create(:type_de_champ, procedure: procedure, order_place: 0) } let!(:type_de_champ_1) { create(:type_de_champ, procedure: procedure, order_place: 1) } let!(:type_de_champ_2) { create(:type_de_champ_drop_down_list, procedure: procedure, order_place: 2) } @@ -340,11 +338,13 @@ describe Procedure do end describe 'procedure status is reset' do - let(:archived_at) { Time.now } - let(:published_at) { Time.now } + let(:procedure) { create(:procedure, :archived, received_mail: received_mail, service: service) } + it 'Not published nor archived' do expect(subject.archived_at).to be_nil expect(subject.published_at).to be_nil + expect(subject.test_started_at).to be_nil + expect(subject.aasm_state).to eq "brouillon" expect(subject.path).to be_nil end end