rails/rails — pull request #14457 by kemper (2014-03-23 13:04:24+00:00)
Title: Don't recurse infinitely when calling non-existent method on super

This defect was introduced from this commit:

commit 252539c0366f3c3c222b809444d68f06383ca8ea
Author: Matt Jones
Date: Thu Oct 24 15:06:53 2013 -0400

always check to see if methods exist after calling define_attribute_methods

In which the return value from self.class.define_attribute_methods was ignored. That return value indicates whether the methods have been previously defined. I reviewed the history of this method over the last couple years, and general behavior has been to retry the method call to an attribute method one time, only if the attribute methods were just defined. Otherwise, delegate to super.

The defect generally causes problem in development, as my guard and spork setup fails somewhat quietly when an infinite loop happens. However, some gems expect to receive a NoMethodError in the cause of calling super in a method where super does not define that method. Specifically, this expectation exists in the StateMachine gem.

I added a test to show the problem and provided a fix. Thanks.