Permalink
Browse files

AR::Integration must be included after AM::Conversion

Integration's definition of #to_param must override
Conversion's. Otherwise, there is a regression from
3.1 in the behavior of a non-persisted AR::Base instance
which nevertheless has an id.
  • Loading branch information...
1 parent 71d274d commit 9b5309fb6819d8f2a1b31e44ba61e682272c7aa3 @jfirebaugh jfirebaugh committed Jul 17, 2012
Showing with 7 additions and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/base.rb
  2. +6 −0 activerecord/test/cases/base_test.rb
@@ -697,9 +697,9 @@ def to_ary # :nodoc:
include Scoping
extend DynamicMatchers
include Sanitization
- include Integration
include AttributeAssignment
include ActiveModel::Conversion
+ include Integration
include Validations
extend CounterCache
include Locking::Optimistic, Locking::Pessimistic
@@ -1911,6 +1911,12 @@ def test_to_param_should_return_string
assert_kind_of String, Client.find(:first).to_param
end
+ def test_to_param_returns_id_even_if_not_persisted
+ client = Client.new
+ client.id = 1
+ assert_equal "1", client.to_param
+ end
+
def test_inspect_class
assert_equal 'ActiveRecord::Base', ActiveRecord::Base.inspect
assert_equal 'LoosePerson(abstract)', LoosePerson.inspect

0 comments on commit 9b5309f

Please sign in to comment.