mirror of
https://github.com/plashchynski/crono.git
synced 2026-07-02 19:11:41 +02:00
Add Job#load to load info from DB
This commit is contained in:
@@ -35,6 +35,10 @@ module Crono
|
|||||||
model.update(last_performed_at: last_performed_at)
|
model.update(last_performed_at: last_performed_at)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def load
|
||||||
|
self.last_performed_at = model.last_performed_at
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def model
|
def model
|
||||||
@model ||= Crono::CronoJob.find_or_create_by(job_id: job_id)
|
@model ||= Crono::CronoJob.find_or_create_by(job_id: job_id)
|
||||||
|
|||||||
@@ -40,4 +40,17 @@ describe Crono::Job do
|
|||||||
expect(@crono_job.last_performed_at).to be_eql(job.last_performed_at)
|
expect(@crono_job.last_performed_at).to be_eql(job.last_performed_at)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#load" do
|
||||||
|
before do
|
||||||
|
@saved_last_performed_at = job.last_performed_at = Time.now
|
||||||
|
job.save
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should load info from DB" do
|
||||||
|
@job = Crono::Job.new(TestJob, period)
|
||||||
|
@job.load
|
||||||
|
expect(@job.last_performed_at).to be_eql @saved_last_performed_at
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user