diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-03-23 05:00:25 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-03-23 05:00:25 +0000 |
commit | 0ff031992f1dc36cf36eaf26a1e476f67c29c048 (patch) | |
tree | 6be43ca85183d7b332e6f9627ad68394495e734b /activerecord/test | |
parent | e1790efb85010c5e6f39eef029abf7b71ae3b9a6 (diff) | |
download | rails-0ff031992f1dc36cf36eaf26a1e476f67c29c048.tar.gz rails-0ff031992f1dc36cf36eaf26a1e476f67c29c048.tar.bz2 rails-0ff031992f1dc36cf36eaf26a1e476f67c29c048.zip |
Fix merging blank conditions. Closes #10764 [mcmire, cavalle]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9082 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/method_scoping_test.rb | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/activerecord/test/cases/method_scoping_test.rb b/activerecord/test/cases/method_scoping_test.rb index 478050f207..4b5bd6c951 100644 --- a/activerecord/test/cases/method_scoping_test.rb +++ b/activerecord/test/cases/method_scoping_test.rb @@ -150,7 +150,7 @@ class NestedScopingTest < ActiveRecord::TestCase Developer.with_scope(:find => { :conditions => "name = 'David'" }) do Developer.with_scope(:find => { :conditions => 'salary = 80000' }) do appended_condition = Developer.instance_eval('current_scoped_methods')[:find][:conditions] - assert_equal("( name = 'David' ) AND ( salary = 80000 )", appended_condition) + assert_equal("(name = 'David') AND (salary = 80000)", appended_condition) assert_equal(1, Developer.count) end Developer.with_scope(:find => { :conditions => "name = 'Maiha'" }) do @@ -163,7 +163,7 @@ class NestedScopingTest < ActiveRecord::TestCase Developer.with_scope(:find => { :conditions => 'salary = 80000', :limit => 10 }) do Developer.with_scope(:find => { :conditions => "name = 'David'" }) do merged_option = Developer.instance_eval('current_scoped_methods')[:find] - assert_equal({ :conditions => "( salary = 80000 ) AND ( name = 'David' )", :limit => 10 }, merged_option) + assert_equal({ :conditions => "(salary = 80000) AND (name = 'David')", :limit => 10 }, merged_option) end end end @@ -275,6 +275,26 @@ class NestedScopingTest < ActiveRecord::TestCase end end + def test_merged_scoped_find_on_blank_conditions + [nil, " ", [], {}].each do |blank| + Developer.with_scope(:find => {:conditions => blank}) do + Developer.with_scope(:find => {:conditions => blank}) do + assert_nothing_raised { Developer.find(:first) } + end + end + end + end + + def test_merged_scoped_find_on_blank_bind_conditions + [ [""], ["",{}] ].each do |blank| + Developer.with_scope(:find => {:conditions => blank}) do + Developer.with_scope(:find => {:conditions => blank}) do + assert_nothing_raised { Developer.find(:first) } + end + end + end + end + def test_immutable_nested_scope options1 = { :conditions => "name = 'Jamis'" } options2 = { :conditions => "name = 'David'" } |