aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2014-02-23 11:14:05 +0000
committerJon Leighton <j@jonathanleighton.com>2014-02-23 11:14:05 +0000
commit40a9d8987711f7973c5e95087bcc0c59e167294b (patch)
treed9de0a56382dea5500b308116c4ace2f2ca0fa08 /activerecord/test/cases
parentf8dcc485175d7e5ac3c5d2819b3a04cd2e5d4982 (diff)
downloadrails-40a9d8987711f7973c5e95087bcc0c59e167294b.tar.gz
rails-40a9d8987711f7973c5e95087bcc0c59e167294b.tar.bz2
rails-40a9d8987711f7973c5e95087bcc0c59e167294b.zip
Add tests for default scope behaviour change
See #13875
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/scoping/default_scoping_test.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/activerecord/test/cases/scoping/default_scoping_test.rb b/activerecord/test/cases/scoping/default_scoping_test.rb
index 170e9a49eb..9a4d8c6740 100644
--- a/activerecord/test/cases/scoping/default_scoping_test.rb
+++ b/activerecord/test/cases/scoping/default_scoping_test.rb
@@ -395,4 +395,22 @@ class DefaultScopingTest < ActiveRecord::TestCase
threads.each(&:join)
end
end
+
+ test "additional conditions are ANDed with the default scope" do
+ scope = DeveloperCalledJamis.where(name: "David")
+ assert_equal 2, scope.where_values.length
+ assert_equal [], scope.to_a
+ end
+
+ test "additional conditions in a scope are ANDed with the default scope" do
+ scope = DeveloperCalledJamis.david
+ assert_equal 2, scope.where_values.length
+ assert_equal [], scope.to_a
+ end
+
+ test "a scope can remove the condition from the default scope" do
+ scope = DeveloperCalledJamis.david2
+ assert_equal 1, scope.where_values.length
+ assert_equal Developer.where(name: "David").map(&:id), scope.map(&:id)
+ end
end