This project is archived and is in readonly mode.
ActiveRecord::Base.abstract_class? should return false not nil
Reported by Rohit Arondekar | August 3rd, 2010 @ 03:51 PM | in 3.0.2
Although this doesn't break anything, but ActiveRecord::Base.abstract_class? returns nil when @abstract_class is not defined. This still works as nil and false are treated as false in conditionals. But Ruby methods ending with a ?, by convention should return true/false. The attached patch ensures that it does return false if @abstract_class is not defined.
IMHO no test was needed as the existing tests cover the functionality provided by the method.
Credit: Neeraj Singh for originally spotting the discrepancy.
Comments and changes to this ticket
-
Neeraj Singh August 3rd, 2010 @ 04:16 PM
I think you should add the test that method returns false and not nil :-)
-
Rohit Arondekar August 4th, 2010 @ 03:29 AM
- State changed from new to invalid
This is actually not needed as both nil and false behave the same. Also it's acceptable that a method ending with a ? return either nil or false if the condition is not satisfied. Closing ticket. :)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>