DeletedDossier should have access to discarded demarche

This commit is contained in:
Paul Chavard 2020-03-26 20:25:19 +01:00
parent e4ab2574ce
commit bd81970f67
3 changed files with 16 additions and 1 deletions

View file

@ -1,5 +1,5 @@
class DeletedDossier < ApplicationRecord
belongs_to :procedure
belongs_to :procedure, -> { with_discarded }, inverse_of: :deleted_dossiers
validates :dossier_id, uniqueness: true

View file

@ -2,6 +2,7 @@ FactoryBot.define do
factory :deleted_dossier do
dossier_id { 1111 }
state { Dossier.states.fetch(:en_construction) }
reason { DeletedDossier.reasons.fetch(:user_request) }
deleted_at { Time.zone.now }
association :procedure, :published

View file

@ -0,0 +1,14 @@
require 'spec_helper'
describe DeletedDossier do
let(:deleted_dossier) { create(:deleted_dossier) }
describe 'with discarded procedure' do
before do
deleted_dossier.procedure.discard!
deleted_dossier.reload
end
it { expect(deleted_dossier.procedure).not_to be_nil }
end
end