diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-12-01 21:55:59 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-12-01 23:41:51 +0000 |
commit | e9fb6d04bdfbe3dfc4ba1a3cf442ec5d25764300 (patch) | |
tree | 9e6bb6b8c7fbcc4cdcf3cea1e5cacaf6c846ee54 /activerecord/test/cases/primary_keys_test.rb | |
parent | f1a534af98950efd9969deea1540717c4516d673 (diff) | |
download | rails-e9fb6d04bdfbe3dfc4ba1a3cf442ec5d25764300.tar.gz rails-e9fb6d04bdfbe3dfc4ba1a3cf442ec5d25764300.tar.bz2 rails-e9fb6d04bdfbe3dfc4ba1a3cf442ec5d25764300.zip |
Add test for read_attribute(:id) with non-standard PK.
Also make it actually work.
It slows down all read_attribute accesses to map 'id' to whatever the PK
actually is, inside read_attribute. So instead make sure the necessary
methods are defined and that they redirect wherever they need to go.
Diffstat (limited to 'activerecord/test/cases/primary_keys_test.rb')
-rw-r--r-- | activerecord/test/cases/primary_keys_test.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/test/cases/primary_keys_test.rb b/activerecord/test/cases/primary_keys_test.rb index cc8ffb5f27..8d248c3f9f 100644 --- a/activerecord/test/cases/primary_keys_test.rb +++ b/activerecord/test/cases/primary_keys_test.rb @@ -23,6 +23,11 @@ class PrimaryKeysTest < ActiveRecord::TestCase assert_equal keyboard.to_key, [keyboard.id] end + def test_read_attribute_with_custom_primary_key + keyboard = Keyboard.create! + assert_equal keyboard.key_number, keyboard.read_attribute(:id) + end + def test_to_key_with_primary_key_after_destroy topic = Topic.find(1) topic.destroy |