aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorNeeraj Singh and John Leighton <neerajdotname@gmail.com>2013-03-07 18:35:02 -0500
committerNeeraj Singh <neerajdotname@gmail.com>2013-03-07 18:57:27 -0500
commitcd26b6ae7c1546ef8f38302661bbedf8cb487311 (patch)
treef55b6c7796bebb52d77712eab6b4b554d2c6a109 /activerecord/test
parentde4a60c9f468bb5bf4bd38220377cc5ac8385102 (diff)
downloadrails-cd26b6ae7c1546ef8f38302661bbedf8cb487311.tar.gz
rails-cd26b6ae7c1546ef8f38302661bbedf8cb487311.tar.bz2
rails-cd26b6ae7c1546ef8f38302661bbedf8cb487311.zip
Combine scope conditions using AND
Currently Post.active.inactive will result in Post.inactive since the last where clause wins when scopes are merged. This pull request will merge all scopes ( barring defaul scope) using AND. The default scope will be overridden if another scope acts on the same where clause. closes #7365
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/named_scope_test.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/test/cases/named_scope_test.rb b/activerecord/test/cases/named_scope_test.rb
index bd121126e7..c067db4cbe 100644
--- a/activerecord/test/cases/named_scope_test.rb
+++ b/activerecord/test/cases/named_scope_test.rb
@@ -325,11 +325,11 @@ class NamedScopeTest < ActiveRecord::TestCase
def test_chaining_should_use_latest_conditions_when_searching
# Normal hash conditions
- assert_equal Topic.where(:approved => true).to_a, Topic.rejected.approved.to_a
- assert_equal Topic.where(:approved => false).to_a, Topic.approved.rejected.to_a
+ assert_equal Topic.where(approved: false).where(approved: true).to_a, Topic.rejected.approved.to_a
+ assert_equal Topic.where(approved: true).where(approved: false).to_a, Topic.approved.rejected.to_a
# Nested hash conditions with same keys
- assert_equal [posts(:sti_comments)], Post.with_special_comments.with_very_special_comments.to_a
+ assert_equal [], Post.with_special_comments.with_very_special_comments.to_a
# Nested hash conditions with different keys
assert_equal [posts(:sti_comments)], Post.with_special_comments.with_post(4).to_a.uniq