Fix discarded procedures destruction
This commit is contained in:
parent
5b56ec425b
commit
6d37e1d133
2 changed files with 12 additions and 0 deletions
|
@ -18,6 +18,10 @@ class ProcedureRevision < ApplicationRecord
|
||||||
has_many :types_de_champ, through: :revision_types_de_champ, source: :type_de_champ
|
has_many :types_de_champ, through: :revision_types_de_champ, source: :type_de_champ
|
||||||
has_many :types_de_champ_private, through: :revision_types_de_champ_private, source: :type_de_champ
|
has_many :types_de_champ_private, through: :revision_types_de_champ_private, source: :type_de_champ
|
||||||
|
|
||||||
|
has_many :owned_types_de_champ, class_name: 'TypeDeChamp', foreign_key: :revision_id, dependent: :destroy, inverse_of: :revision
|
||||||
|
has_one :draft_procedure, class_name: 'Procedure', foreign_key: :draft_revision_id, dependent: :nullify, inverse_of: :draft_revision
|
||||||
|
has_one :published_procedure, class_name: 'Procedure', foreign_key: :published_revision_id, dependent: :nullify, inverse_of: :published_revision
|
||||||
|
|
||||||
def build_champs
|
def build_champs
|
||||||
types_de_champ.map(&:build_champ)
|
types_de_champ.map(&:build_champ)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1030,4 +1030,12 @@ describe Procedure do
|
||||||
it { is_expected.to be false }
|
it { is_expected.to be false }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#destroy" do
|
||||||
|
let(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||||
|
|
||||||
|
it "can destroy procedure" do
|
||||||
|
expect(procedure.destroy).to be_truthy
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue