diff options
author | namusyaka <namusyaka@gmail.com> | 2017-02-08 00:41:56 +0900 |
---|---|---|
committer | namusyaka <namusyaka@gmail.com> | 2017-02-09 01:57:50 +0900 |
commit | 3df9117abc7980c54df675503409d9bdcddc1fee (patch) | |
tree | 5dcdeb89934e04b4a53a624b912e2f3699afc149 /activerecord/test/cases | |
parent | 47113df0341cd7bf56056bc666527978c586c7c5 (diff) | |
download | rails-3df9117abc7980c54df675503409d9bdcddc1fee.tar.gz rails-3df9117abc7980c54df675503409d9bdcddc1fee.tar.bz2 rails-3df9117abc7980c54df675503409d9bdcddc1fee.zip |
Fix inspection behavior when the :id column is not primary key
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/primary_keys_test.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/activerecord/test/cases/primary_keys_test.rb b/activerecord/test/cases/primary_keys_test.rb index f92ee15cfa..1baf7c4902 100644 --- a/activerecord/test/cases/primary_keys_test.rb +++ b/activerecord/test/cases/primary_keys_test.rb @@ -7,6 +7,7 @@ require "models/movie" require "models/keyboard" require "models/mixed_case_monkey" require "models/dashboard" +require "models/non_primary_key" class PrimaryKeysTest < ActiveRecord::TestCase fixtures :topics, :subscribers, :movies, :mixed_case_monkeys @@ -89,6 +90,12 @@ class PrimaryKeysTest < ActiveRecord::TestCase assert_equal("John Doe", subscriberReloaded.name) end + def test_id_column_that_is_not_primary_key + NonPrimaryKey.create!(id: 100) + actual = NonPrimaryKey.find_by(id: 100) + assert_match %r{<NonPrimaryKey id: 100}, actual.inspect + end + def test_find_with_more_than_one_string_key assert_equal 2, Subscriber.find(subscribers(:first).nick, subscribers(:second).nick).length end |