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