aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2006-10-09 02:46:57 +0000
committerRick Olson <technoweenie@gmail.com>2006-10-09 02:46:57 +0000
commit8e3bf70bcd496ae642fdae5ad7717ad8378de176 (patch)
tree61a47381adc2b388366bf1806ff3bedaeb570517 /activerecord/test
parentccd32adecae3e95836effe8c96ac215e9b9e580e (diff)
downloadrails-8e3bf70bcd496ae642fdae5ad7717ad8378de176.tar.gz
rails-8e3bf70bcd496ae642fdae5ad7717ad8378de176.tar.bz2
rails-8e3bf70bcd496ae642fdae5ad7717ad8378de176.zip
Removes the ability for eager loaded conditions to be interpolated, since there is no model instance to use as a context for interpolation. #5553 [turnip@turnipspatch.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5264 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/associations/eager_test.rb2
-rwxr-xr-xactiverecord/test/associations_test.rb8
-rw-r--r--activerecord/test/fixtures/author.rb3
-rw-r--r--activerecord/test/fixtures/category.rb3
-rwxr-xr-xactiverecord/test/fixtures/company.rb1
-rw-r--r--activerecord/test/reflection_test.rb4
6 files changed, 14 insertions, 7 deletions
diff --git a/activerecord/test/associations/eager_test.rb b/activerecord/test/associations/eager_test.rb
index bcdd63ce34..d6e795b1fe 100644
--- a/activerecord/test/associations/eager_test.rb
+++ b/activerecord/test/associations/eager_test.rb
@@ -283,7 +283,7 @@ class EagerAssociationTest < Test::Unit::TestCase
end
# Test regular association, association with conditions, association with
# STI, and association with conditions assured not to be true
- post_types = [:posts, :hello_posts, :special_posts, :nonexistent_posts]
+ post_types = [:posts, :other_posts, :special_posts]
# test both has_many and has_and_belongs_to_many
[Author, Category].each do |className|
d1 = find_all_ordered(className)
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb
index a75f708ea7..350799e306 100755
--- a/activerecord/test/associations_test.rb
+++ b/activerecord/test/associations_test.rb
@@ -315,6 +315,14 @@ class HasOneAssociationsTest < Test::Unit::TestCase
assert_equal a, firm.account
assert_equal a, firm.account(true)
end
+
+ def test_finding_with_interpolated_condition
+ firm = Firm.find(:first)
+ superior = firm.clients.create(:name => 'SuperiorCo')
+ superior.rating = 10
+ superior.save
+ assert_equal 10, firm.clients_with_interpolated_conditions.first.rating
+ end
def test_assignment_before_child_saved
firm = Firm.find(1)
diff --git a/activerecord/test/fixtures/author.rb b/activerecord/test/fixtures/author.rb
index 1c49b90fe5..7373639383 100644
--- a/activerecord/test/fixtures/author.rb
+++ b/activerecord/test/fixtures/author.rb
@@ -18,8 +18,7 @@ class Author < ActiveRecord::Base
has_many :funky_comments, :through => :posts, :source => :comments
has_many :special_posts, :class_name => "Post"
- has_many :hello_posts, :class_name => "Post", :conditions=>"\#{aliased_table_name}.body = 'hello'"
- has_many :nonexistent_posts, :class_name => "Post", :conditions=>"\#{aliased_table_name}.body = 'nonexistent'"
+ has_many :other_posts, :class_name => "Post"
has_many :posts_with_callbacks, :class_name => "Post", :before_add => :log_before_adding,
:after_add => :log_after_adding,
:before_remove => :log_before_removing,
diff --git a/activerecord/test/fixtures/category.rb b/activerecord/test/fixtures/category.rb
index 6917c51d34..295bd8277f 100644
--- a/activerecord/test/fixtures/category.rb
+++ b/activerecord/test/fixtures/category.rb
@@ -1,8 +1,7 @@
class Category < ActiveRecord::Base
has_and_belongs_to_many :posts
has_and_belongs_to_many :special_posts, :class_name => "Post"
- has_and_belongs_to_many :hello_posts, :class_name => "Post", :conditions => "\#{aliased_table_name}.body = 'hello'"
- has_and_belongs_to_many :nonexistent_posts, :class_name => "Post", :conditions=>"\#{aliased_table_name}.body = 'nonexistent'"
+ has_and_belongs_to_many :other_posts, :class_name => "Post"
def self.what_are_you
'a category...'
diff --git a/activerecord/test/fixtures/company.rb b/activerecord/test/fixtures/company.rb
index 37e4ebda56..c012a978a0 100755
--- a/activerecord/test/fixtures/company.rb
+++ b/activerecord/test/fixtures/company.rb
@@ -22,6 +22,7 @@ class Firm < Company
has_many :exclusively_dependent_clients_of_firm, :foreign_key => "client_of", :class_name => "Client", :order => "id", :dependent => :delete_all
has_many :limited_clients, :class_name => "Client", :order => "id", :limit => 1
has_many :clients_like_ms, :conditions => "name = 'Microsoft'", :class_name => "Client", :order => "id"
+ has_many :clients_with_interpolated_conditions, :class_name => "Client", :conditions => 'rating > #{rating}'
has_many :clients_like_ms_with_hash_conditions, :conditions => { :name => 'Microsoft' }, :class_name => "Client", :order => "id"
has_many :clients_using_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE client_of = #{id}'
has_many :clients_using_counter_sql, :class_name => "Client",
diff --git a/activerecord/test/reflection_test.rb b/activerecord/test/reflection_test.rb
index 76e42860fb..796076bc81 100644
--- a/activerecord/test/reflection_test.rb
+++ b/activerecord/test/reflection_test.rb
@@ -143,8 +143,8 @@ class ReflectionTest < Test::Unit::TestCase
end
def test_reflection_of_all_associations
- assert_equal 16, Firm.reflect_on_all_associations.size
- assert_equal 14, Firm.reflect_on_all_associations(:has_many).size
+ assert_equal 17, Firm.reflect_on_all_associations.size
+ assert_equal 15, Firm.reflect_on_all_associations(:has_many).size
assert_equal 2, Firm.reflect_on_all_associations(:has_one).size
assert_equal 0, Firm.reflect_on_all_associations(:belongs_to).size
end