aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/method_scoping_test.rb
diff options
context:
space:
mode:
authorFilip H.F. "FiXato" Slagter <fixato@gmail.com>2008-10-30 11:40:09 +0100
committerPratik Naik <pratiknaik@gmail.com>2009-01-28 19:50:55 +0000
commita0d8202bb9fa55c328a3170836b0cddb40631e83 (patch)
treef3f7da237b473f7408780550c31b4d47c7463316 /activerecord/test/cases/method_scoping_test.rb
parentf725b1971072a2203d6d433149730289cbb80128 (diff)
downloadrails-a0d8202bb9fa55c328a3170836b0cddb40631e83.tar.gz
rails-a0d8202bb9fa55c328a3170836b0cddb40631e83.tar.bz2
rails-a0d8202bb9fa55c328a3170836b0cddb40631e83.zip
Ensure whitespaces are stripped when merging string joins. [#1297 state:resolved]
Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
Diffstat (limited to 'activerecord/test/cases/method_scoping_test.rb')
-rw-r--r--activerecord/test/cases/method_scoping_test.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/method_scoping_test.rb b/activerecord/test/cases/method_scoping_test.rb
index 80a06116ad..71e2ce8790 100644
--- a/activerecord/test/cases/method_scoping_test.rb
+++ b/activerecord/test/cases/method_scoping_test.rb
@@ -186,6 +186,16 @@ class MethodScopingTest < ActiveRecord::TestCase
assert_equal authors(:david).attributes, scoped_authors.first.attributes
end
+ def test_scoped_find_strips_spaces_from_string_joins_and_eliminates_duplicate_string_joins
+ scoped_authors = Author.with_scope(:find => { :joins => ' INNER JOIN posts ON posts.author_id = authors.id '}) do
+ Author.find(:all, :select => 'DISTINCT authors.*', :joins => ['INNER JOIN posts ON posts.author_id = authors.id'], :conditions => 'posts.id = 1')
+ end
+ assert scoped_authors.include?(authors(:david))
+ assert !scoped_authors.include?(authors(:mary))
+ assert_equal 1, scoped_authors.size
+ assert_equal authors(:david).attributes, scoped_authors.first.attributes
+ end
+
def test_scoped_count_include
# with the include, will retrieve only developers for the given project
Developer.with_scope(:find => { :include => :projects }) do