Skip to content

Fixes uninitialized constant PaperTrail::RecordTrail::ActiveRecordError#984

Merged
jaredbeck merged 1 commit intopaper-trail-gem:masterfrom
evmorov:master
Aug 18, 2017
Merged

Fixes uninitialized constant PaperTrail::RecordTrail::ActiveRecordError#984
jaredbeck merged 1 commit intopaper-trail-gem:masterfrom
evmorov:master

Conversation

@evmorov
Copy link
Copy Markdown
Contributor

@evmorov evmorov commented Aug 17, 2017

Fixes #663.

I didn't found the right place for the spec so I put it in spec/models/thing_spec.rb:

  describe "#touch_with_version", versioning: true do
    let(:thing) { Thing.new(name: "pencil") }

    context "when record isn't persisted" do
      it "raises an error" do
        expect {
          thing.paper_trail.touch_with_version
        }.to raise_error(ActiveRecord::ActiveRecordError, "can not touch on a new record object")
      end
    end

Without the fix the spec would say:

expected ActiveRecord::ActiveRecordError with "can not touch on a new record object",
got #<NameError: uninitialized constant PaperTrail::RecordTrail::ActiveRecordError> with backtrace:
# ./lib/paper_trail/record_trail.rb:402:in `touch_with_version'

It's the exception I had in the app I'm working on. The message doesn't help so I was forced to look into the code.

@jaredbeck
Copy link
Copy Markdown
Member

Thanks Evgeny.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants