diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-09-26 18:14:16 +0100 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-09-26 18:15:09 +0100 |
commit | b3407c86cfccd2cc6258b8879e91600fe25c6e48 (patch) | |
tree | 0dce9206faba6e2df06245850b0bf46c96bca56c /activerecord/test | |
parent | e97b6f2ef747f013f8d71d7d97dc88acc673ee6d (diff) | |
download | rails-b3407c86cfccd2cc6258b8879e91600fe25c6e48.tar.gz rails-b3407c86cfccd2cc6258b8879e91600fe25c6e48.tar.bz2 rails-b3407c86cfccd2cc6258b8879e91600fe25c6e48.zip |
Don't require a DB connection when setting primary key.
Closes #2807.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/primary_keys_test.rb | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/test/cases/primary_keys_test.rb b/activerecord/test/cases/primary_keys_test.rb index 05a41d8a0a..489c7d8310 100644 --- a/activerecord/test/cases/primary_keys_test.rb +++ b/activerecord/test/cases/primary_keys_test.rb @@ -145,4 +145,20 @@ class PrimaryKeysTest < ActiveRecord::TestCase k.set_primary_key "bar" assert_equal k.connection.quote_column_name("bar"), k.quoted_primary_key end + + def test_set_primary_key_with_no_connection + return skip("disconnect wipes in-memory db") if in_memory_db? + + connection = ActiveRecord::Base.remove_connection + + model = Class.new(ActiveRecord::Base) do + set_primary_key 'foo' + end + + assert_equal 'foo', model.primary_key + + ActiveRecord::Base.establish_connection(connection) + + assert_equal 'foo', model.primary_key + end end |