diff --git a/app/models/procedure_revision.rb b/app/models/procedure_revision.rb index a59da2c4e..7f4bf8464 100644 --- a/app/models/procedure_revision.rb +++ b/app/models/procedure_revision.rb @@ -1,4 +1,5 @@ class ProcedureRevision < ApplicationRecord + self.implicit_order_column = :created_at belongs_to :procedure, -> { with_discarded }, inverse_of: :revisions has_many :revision_types_de_champ, -> { public_only.ordered }, class_name: 'ProcedureRevisionTypeDeChamp', foreign_key: :revision_id, dependent: :destroy, inverse_of: :revision diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 042753f45..48fbb5454 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -687,7 +687,7 @@ describe Procedure do expect(procedure.published_revision).not_to be_nil expect(procedure.draft_revision).not_to be_nil expect(procedure.revisions.count).to eq(2) - expect(procedure.revisions.last).to eq(procedure.draft_revision) + expect(procedure.revisions).to eq([procedure.published_revision, procedure.draft_revision]) end end @@ -768,7 +768,7 @@ describe Procedure do expect(procedure.published_revision).not_to be_nil expect(procedure.draft_revision).not_to be_nil expect(procedure.revisions.count).to eq(2) - expect(procedure.revisions.last).to eq(procedure.draft_revision) + expect(procedure.revisions).to eq([procedure.published_revision, procedure.draft_revision]) end end