2016-03-05 22:07:32 +00:00
|
|
|
require "rails_helper"
|
2015-07-09 03:21:44 +00:00
|
|
|
|
2016-02-16 03:32:40 +00:00
|
|
|
describe NotOnUpdate, type: :model do
|
|
|
|
describe "#touch_with_version", versioning: true do
|
2015-07-09 03:21:44 +00:00
|
|
|
let!(:record) { described_class.create! }
|
|
|
|
|
|
|
|
it "should create a version, regardless" do
|
2016-02-23 22:59:14 +00:00
|
|
|
expect { record.paper_trail.touch_with_version }.to change {
|
2015-07-09 03:21:44 +00:00
|
|
|
PaperTrail::Version.count
|
|
|
|
}.by(+1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "increments the `:updated_at` timestamp" do
|
|
|
|
before = record.updated_at
|
2016-01-12 03:07:57 +00:00
|
|
|
# Travel 1 second because MySQL lacks sub-second resolution
|
|
|
|
Timecop.travel(1) do
|
2016-02-23 22:59:14 +00:00
|
|
|
record.paper_trail.touch_with_version
|
2016-01-12 03:07:57 +00:00
|
|
|
end
|
2015-07-09 03:21:44 +00:00
|
|
|
expect(record.updated_at).to be > before
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|