Record published_at when publishing a procedure

This commit is contained in:
gregoirenovel 2017-06-27 11:23:02 +02:00
parent 1b808d9abe
commit cf5398fe99
2 changed files with 3 additions and 1 deletions

View file

@ -112,7 +112,7 @@ class Procedure < ActiveRecord::Base
end end
def publish!(path) 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) ProcedurePath.create!(path: path, procedure: self, administrateur: self.administrateur)
end end

View file

@ -224,10 +224,12 @@ describe Procedure do
before do before do
procedure.publish!("example-path") procedure.publish!("example-path")
Timecop.freeze(Time.now)
end end
it { expect(procedure.published).to eq(true) } it { expect(procedure.published).to eq(true) }
it { expect(procedure.archived).to eq(false) } 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")).to be }
it { expect(ProcedurePath.find_by_path("example-path").procedure).to eq(procedure) } 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) } it { expect(ProcedurePath.find_by_path("example-path").administrateur).to eq(procedure.administrateur) }