1
0
Fork 0
mirror of https://github.com/paper-trail-gem/paper_trail.git synced 2022-11-09 11:33:19 -05:00
paper-trail-gem--paper_trail/spec/models/fruit_spec.rb

21 lines
828 B
Ruby
Raw Normal View History

2017-12-10 23:05:11 -05:00
# frozen_string_literal: true
require "spec_helper"
if ENV["DB"] == "postgres" || JsonVersion.table_exists?
RSpec.describe Fruit, type: :model, versioning: true do
describe "have_a_version_with_changes matcher" do
it "works with Fruit because Fruit uses JsonVersion" do
# As of PT 9.0.0, with_version_changes only supports json(b) columns,
# so that's why were testing the have_a_version_with_changes matcher
# here.
banana = Fruit.create!(color: "Red", name: "Banana")
banana.update_attributes!(color: "Yellow")
expect(banana).to have_a_version_with_changes(color: "Yellow")
expect(banana).not_to have_a_version_with_changes(color: "Pink")
expect(banana).not_to have_a_version_with_changes(color: "Yellow", name: "Kiwi")
end
end
end
end