Merge pull request #6242 from tchak/fix-discarded-procedures
Fix destoying discarded procedures
This commit is contained in:
commit
fefbf93be6
2 changed files with 8 additions and 3 deletions
|
@ -19,8 +19,8 @@ class ProcedureRevision < ApplicationRecord
|
|||
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
|
||||
has_one :draft_procedure, -> { with_discarded }, class_name: 'Procedure', foreign_key: :draft_revision_id, dependent: :nullify, inverse_of: :draft_revision
|
||||
has_one :published_procedure, -> { with_discarded }, class_name: 'Procedure', foreign_key: :published_revision_id, dependent: :nullify, inverse_of: :published_revision
|
||||
|
||||
def build_champs
|
||||
types_de_champ.map(&:build_champ)
|
||||
|
|
|
@ -1032,9 +1032,14 @@ describe Procedure do
|
|||
end
|
||||
|
||||
describe "#destroy" do
|
||||
let(:procedure) { create(:procedure, :with_type_de_champ) }
|
||||
let(:procedure) { create(:procedure, :closed, :with_type_de_champ) }
|
||||
|
||||
before do
|
||||
procedure.discard!
|
||||
end
|
||||
|
||||
it "can destroy procedure" do
|
||||
expect(procedure.revisions.count).to eq(2)
|
||||
expect(procedure.destroy).to be_truthy
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue