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/post_with_status_spec.rb

28 lines
830 B
Ruby
Raw Normal View History

require "rails_helper"
# This model is in the test suite soley for the purpose of testing ActiveRecord::Enum,
# which is available in ActiveRecord4+ only
2016-02-15 22:32:40 -05:00
describe PostWithStatus, type: :model do
if defined?(ActiveRecord::Enum)
with_versioning do
let(:post) { PostWithStatus.create!(status: "draft") }
it "should stash the enum value properly in versions" do
post.published!
post.archived!
expect(post.previous_version.published?).to be true
end
context "storing enum object_changes" do
subject { post.versions.last }
it "should stash the enum value properly in versions object_changes" do
post.published!
post.archived!
expect(subject.changeset["status"]).to eql %w(published archived)
end
end
end
end
end