diff --git a/app/models/procedure.rb b/app/models/procedure.rb index 38c7200e3..c5a0ce236 100644 --- a/app/models/procedure.rb +++ b/app/models/procedure.rb @@ -112,7 +112,7 @@ class Procedure < ActiveRecord::Base end def publish!(path) - self.update_attributes!({published: true, archived: false}) + self.update_attributes!({ published: true, archived: false, published_at: Time.now }) ProcedurePath.create!(path: path, procedure: self, administrateur: self.administrateur) end diff --git a/spec/models/procedure_spec.rb b/spec/models/procedure_spec.rb index 7f37f0833..88e3fbd16 100644 --- a/spec/models/procedure_spec.rb +++ b/spec/models/procedure_spec.rb @@ -224,10 +224,12 @@ describe Procedure do before do procedure.publish!("example-path") + Timecop.freeze(Time.now) end it { expect(procedure.published).to eq(true) } it { expect(procedure.archived).to eq(false) } + it { expect(procedure.published_at).to eq(Time.now) } it { expect(ProcedurePath.find_by_path("example-path")).to be } it { expect(ProcedurePath.find_by_path("example-path").procedure).to eq(procedure) } it { expect(ProcedurePath.find_by_path("example-path").administrateur).to eq(procedure.administrateur) }