Dossier: #accepter_automatiquement!
This commit is contained in:
parent
0f3dedb0b6
commit
6ab2d124f9
2 changed files with 64 additions and 0 deletions
|
@ -761,6 +761,57 @@ describe Dossier do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#accepter!' do
|
||||
let(:dossier) { create(:dossier) }
|
||||
let!(:gestionnaire) { create(:gestionnaire) }
|
||||
let!(:now) { Time.zone.parse('01/01/2100') }
|
||||
let(:attestation) { Attestation.new }
|
||||
|
||||
before do
|
||||
allow(NotificationMailer).to receive(:send_closed_notification).and_return(double(deliver_later: true))
|
||||
allow(dossier).to receive(:build_attestation).and_return(attestation)
|
||||
|
||||
Timecop.freeze(now)
|
||||
dossier.accepter!(gestionnaire, 'motivation')
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
after { Timecop.return }
|
||||
|
||||
it { expect(dossier.motivation).to eq('motivation') }
|
||||
it { expect(dossier.en_instruction_at).to eq(now) }
|
||||
it { expect(dossier.processed_at).to eq(now) }
|
||||
it { expect(dossier.state).to eq('accepte') }
|
||||
it { expect(dossier.dossier_operation_logs.pluck(:gestionnaire_id, :operation, :automatic_operation)).to match([[gestionnaire.id, 'accepter', false]]) }
|
||||
it { expect(NotificationMailer).to have_received(:send_closed_notification).with(dossier) }
|
||||
it { expect(dossier.attestation).to eq(attestation) }
|
||||
end
|
||||
|
||||
describe '#accepter_automatiquement!' do
|
||||
let(:dossier) { create(:dossier) }
|
||||
let!(:now) { Time.zone.parse('01/01/2100') }
|
||||
let(:attestation) { Attestation.new }
|
||||
|
||||
before do
|
||||
allow(NotificationMailer).to receive(:send_closed_notification).and_return(double(deliver_later: true))
|
||||
allow(dossier).to receive(:build_attestation).and_return(attestation)
|
||||
|
||||
Timecop.freeze(now)
|
||||
dossier.accepter_automatiquement!
|
||||
dossier.reload
|
||||
end
|
||||
|
||||
after { Timecop.return }
|
||||
|
||||
it { expect(dossier.motivation).to eq(nil) }
|
||||
it { expect(dossier.en_instruction_at).to eq(now) }
|
||||
it { expect(dossier.processed_at).to eq(now) }
|
||||
it { expect(dossier.state).to eq('accepte') }
|
||||
it { expect(dossier.dossier_operation_logs.pluck(:gestionnaire_id, :operation, :automatic_operation)).to match([[nil, 'accepter', true]]) }
|
||||
it { expect(NotificationMailer).to have_received(:send_closed_notification).with(dossier) }
|
||||
it { expect(dossier.attestation).to eq(attestation) }
|
||||
end
|
||||
|
||||
describe '#passer_en_instruction!' do
|
||||
let(:dossier) { create(:dossier) }
|
||||
let(:gestionnaire) { create(:gestionnaire) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue