diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-09-02 13:55:02 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-09-02 13:55:47 -0700 |
commit | 3b6a9a020e7e6f71ab6f9ffcf1ef59c57437ca69 (patch) | |
tree | 90df5808a8788bf48c1079989d0171495a75e0d6 /activerecord/test/cases/associations | |
parent | 723a47bfb3708f968821bc969a9a3fc873a3ed58 (diff) | |
download | rails-3b6a9a020e7e6f71ab6f9ffcf1ef59c57437ca69.tar.gz rails-3b6a9a020e7e6f71ab6f9ffcf1ef59c57437ca69.tar.bz2 rails-3b6a9a020e7e6f71ab6f9ffcf1ef59c57437ca69.zip |
Revert "Assert primary key does not exist in habtm when the association is defined, instead of doing that everytime a record is inserted."
Test failures on PostgreSQL.
[#3128 state:open]
This reverts commit da636809daca9c338200811d3590e446f57c8e81.
Diffstat (limited to 'activerecord/test/cases/associations')
-rw-r--r-- | activerecord/test/cases/associations/habtm_join_table_test.rb | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/activerecord/test/cases/associations/habtm_join_table_test.rb b/activerecord/test/cases/associations/habtm_join_table_test.rb index 745f169ad7..bf3e04c3eb 100644 --- a/activerecord/test/cases/associations/habtm_join_table_test.rb +++ b/activerecord/test/cases/associations/habtm_join_table_test.rb @@ -36,9 +36,21 @@ class HabtmJoinTableTest < ActiveRecord::TestCase uses_transaction :test_should_raise_exception_when_join_table_has_a_primary_key def test_should_raise_exception_when_join_table_has_a_primary_key if ActiveRecord::Base.connection.supports_primary_key? - assert_raise ActiveRecord::HasAndBelongsToManyAssociationWithPrimaryKeyError do - MyReader.has_and_belongs_to_many :my_books + assert_raise ActiveRecord::ConfigurationError do + jaime = MyReader.create(:name=>"Jaime") + jaime.my_books << MyBook.create(:name=>'Great Expectations') end end end + + uses_transaction :test_should_cache_result_of_primary_key_check + def test_should_cache_result_of_primary_key_check + if ActiveRecord::Base.connection.supports_primary_key? + ActiveRecord::Base.connection.stubs(:primary_key).with('my_books_my_readers').returns(false).once + weaz = MyReader.create(:name=>'Weaz') + + weaz.my_books << MyBook.create(:name=>'Great Expectations') + weaz.my_books << MyBook.create(:name=>'Greater Expectations') + end + end end |