diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-06-23 18:13:46 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-06-23 18:13:46 -0300 |
commit | b9088dce07f8525cdb84a1312a77b81db79067d6 (patch) | |
tree | 72ace069842b074981ba814ef1c335271176ce27 /activerecord/test/cases | |
parent | 4864f92ee34e840307d968fa8b04972b6d786fe8 (diff) | |
parent | 4417a19b035d73eb46a5e06e296a4b1c8091bef1 (diff) | |
download | rails-b9088dce07f8525cdb84a1312a77b81db79067d6.tar.gz rails-b9088dce07f8525cdb84a1312a77b81db79067d6.tar.bz2 rails-b9088dce07f8525cdb84a1312a77b81db79067d6.zip |
Merge commit 'rails/master'
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/associations/has_many_through_associations_test.rb | 6 | ||||
-rw-r--r-- | activerecord/test/cases/migration_test.rb | 33 |
2 files changed, 39 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb index 4254badef2..7a4712d7c8 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -157,6 +157,12 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase assert_equal peeps + 1, posts(:thinking).people.count end + def test_associate_with_create_with_through_having_conditions + impatient_people = posts(:thinking).impatient_people.count + posts(:thinking).impatient_people.create!(:first_name => 'foo') + assert_equal impatient_people + 1, posts(:thinking).impatient_people.count + end + def test_associate_with_create_exclamation_and_no_options peeps = posts(:thinking).people.count posts(:thinking).people.create!(:first_name => 'foo') diff --git a/activerecord/test/cases/migration_test.rb b/activerecord/test/cases/migration_test.rb index 16861f21b1..215b5a427a 100644 --- a/activerecord/test/cases/migration_test.rb +++ b/activerecord/test/cases/migration_test.rb @@ -293,6 +293,13 @@ if ActiveRecord::Base.connection.supports_migrations? Person.connection.drop_table table_name rescue nil end + def test_create_table_without_a_block + table_name = :testings + Person.connection.create_table table_name + ensure + Person.connection.drop_table table_name rescue nil + end + # Sybase, and SQLite3 will not allow you to add a NOT NULL # column to a table without a default value. unless current_adapter?(:SybaseAdapter, :SQLiteAdapter) @@ -635,6 +642,32 @@ if ActiveRecord::Base.connection.supports_migrations? end end + if current_adapter?(:SQLiteAdapter) + def test_rename_table_for_sqlite_should_work_with_reserved_words + begin + assert_nothing_raised do + ActiveRecord::Base.connection.rename_table :references, :old_references + ActiveRecord::Base.connection.create_table :octopuses do |t| + t.column :url, :string + end + end + + assert_nothing_raised { ActiveRecord::Base.connection.rename_table :octopuses, :references } + + # Using explicit id in insert for compatibility across all databases + con = ActiveRecord::Base.connection + assert_nothing_raised do + con.execute "INSERT INTO 'references' (#{con.quote_column_name('id')}, #{con.quote_column_name('url')}) VALUES (1, 'http://rubyonrails.com')" + end + assert_equal 'http://rubyonrails.com', ActiveRecord::Base.connection.select_value("SELECT url FROM 'references' WHERE id=1") + + ensure + ActiveRecord::Base.connection.drop_table :references + ActiveRecord::Base.connection.rename_table :old_references, :references + end + end + end + def test_rename_table begin ActiveRecord::Base.connection.create_table :octopuses do |t| |