1

I ran into a strange infinite recursion that appears only in an Rspec test. Oddly, this was caused by adding auditing to my User object, even though the spec that it is failing on is not actually related to my User object

Here's the test it was failing on. Like all infinite recursion, I get no actual stracktrace, only the stack level too deep failure:

 1) Spree::CheckoutController order in address state #update payment to complete step should set the address id on a newly created credit card; does not regress https://www.pivotaltracker.com/story/show/84864964
     Failure/Error: Unable to find matching line from backtrace
     SystemStackError:
       stack level too deep
     # /Users/jason/.rvm/gems/ruby-2.1.5/gems/activerecord-4.1.11/lib/active_record/connection_adapters/abstract/database_statements.rb:212
Jason FB
  • 4,752
  • 3
  • 38
  • 69

1 Answers1

1

I isolated this to my after hook in Rspec, which was configured according to the Database cleaner setup, like so:

  config.after(:each) do
    DatabaseCleaner.clean
    Warden.test_reset!
  end

The fix is simply to turn off auditing on my user model, like so:

  config.after(:each) do
    Spree::User.auditing_enabled = false # disable acts_as_audited during database cleanup
    DatabaseCleaner.clean
    Warden.test_reset!
  end
Jason FB
  • 4,752
  • 3
  • 38
  • 69