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 d8745de commit 80f61259f927e5e37e7f7b0ce0da44da1dc84efe @jfirebaugh jfirebaugh committed Jul 17, 2012
Showing with 7 additions and 1 deletion.
  1. +1 −1 activerecord/lib/active_record/model.rb
  2. +6 −0 activerecord/test/cases/base_test.rb
@@ -74,9 +74,9 @@ def self.append_features(base)
include Inheritance
include Scoping
include Sanitization
- include Integration
include AttributeAssignment
include ActiveModel::Conversion
+ include Integration
include Validations
include CounterCache
include Locking::Optimistic
@@ -1684,6 +1684,12 @@ def test_to_param_should_return_string
assert_kind_of String, Client.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 80f6125

Please sign in to comment.