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/on/update_spec.rb
Jared Beck 7295f65a3c Organizing model tests
model_spec is far too long, let's break it up into specs for individual
models in the dummy app.

Extract spec/models/legacy_widget_spec.rb

Extract spec/models/on/empty_array_spec.rb

Extract spec/models/on/create_spec.rb

Extract spec/models/on/update_spec.rb

Extract spec/models/on/destroy_spec.rb

Move an example to config_spec.rb

Extract spec/models/translation_spec.rb

Extract spec/models/article_spec.rb

Move examples to document_spec.rb
2017-07-05 00:15:15 -04:00

27 lines
861 B
Ruby

require "spec_helper"
require_dependency "on/update"
module On
RSpec.describe Update, type: :model, versioning: true do
describe "#versions" do
it "only creates one version record, for the update event" do
record = described_class.create(name: "Alice")
record.update_attributes(name: "blah")
record.destroy
expect(record.versions.length).to(eq(1))
expect(record.versions.last.event).to(eq("update"))
end
end
context "#paper_trail_event" do
it "rembembers the custom event name" do
record = described_class.create(name: "Alice")
record.paper_trail_event = "banana"
record.update_attributes(name: "blah")
record.destroy
expect(record.versions.length).to(eq(1))
expect(record.versions.last.event).to(eq("banana"))
end
end
end
end