aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorEmilio Tagua <miloops@gmail.com>2009-06-23 18:13:46 -0300
committerEmilio Tagua <miloops@gmail.com>2009-06-23 18:13:46 -0300
commitb9088dce07f8525cdb84a1312a77b81db79067d6 (patch)
tree72ace069842b074981ba814ef1c335271176ce27 /activerecord/test
parent4864f92ee34e840307d968fa8b04972b6d786fe8 (diff)
parent4417a19b035d73eb46a5e06e296a4b1c8091bef1 (diff)
downloadrails-b9088dce07f8525cdb84a1312a77b81db79067d6.tar.gz
rails-b9088dce07f8525cdb84a1312a77b81db79067d6.tar.bz2
rails-b9088dce07f8525cdb84a1312a77b81db79067d6.zip
Merge commit 'rails/master'
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/associations/has_many_through_associations_test.rb6
-rw-r--r--activerecord/test/cases/migration_test.rb33
-rw-r--r--activerecord/test/models/post.rb2
-rw-r--r--activerecord/test/schema/schema.rb1
4 files changed, 42 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|
diff --git a/activerecord/test/models/post.rb b/activerecord/test/models/post.rb
index 374e536a5b..7392515ec7 100644
--- a/activerecord/test/models/post.rb
+++ b/activerecord/test/models/post.rb
@@ -69,6 +69,8 @@ class Post < ActiveRecord::Base
:after_add => lambda {|owner, reader| log(:added, :after, reader.first_name) },
:before_remove => lambda {|owner, reader| log(:removed, :before, reader.first_name) },
:after_remove => lambda {|owner, reader| log(:removed, :after, reader.first_name) }
+ has_many :skimmers, :class_name => 'Reader', :conditions => { :skimmer => true }
+ has_many :impatient_people, :through => :skimmers, :source => :person
def self.top(limit)
ranked_by_comments.limit(limit)
diff --git a/activerecord/test/schema/schema.rb b/activerecord/test/schema/schema.rb
index b2aaccb352..d2d6d1f4b3 100644
--- a/activerecord/test/schema/schema.rb
+++ b/activerecord/test/schema/schema.rb
@@ -364,6 +364,7 @@ ActiveRecord::Schema.define do
create_table :readers, :force => true do |t|
t.integer :post_id, :null => false
t.integer :person_id, :null => false
+ t.boolean :skimmer, :default => false
end
create_table :shape_expressions, :force => true do |t|