DeletedDossier should have access to discarded demarche
This commit is contained in:
parent
e4ab2574ce
commit
bd81970f67
3 changed files with 16 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
class DeletedDossier < ApplicationRecord
|
||||
belongs_to :procedure
|
||||
belongs_to :procedure, -> { with_discarded }, inverse_of: :deleted_dossiers
|
||||
|
||||
validates :dossier_id, uniqueness: true
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
14
spec/models/deleted_dossier_spec.rb
Normal file
14
spec/models/deleted_dossier_spec.rb
Normal 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
|
Loading…
Reference in a new issue