aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2013-03-23 13:04:09 -0700
committerRafael Mendonça França <rafaelmfranca@gmail.com>2013-03-23 13:04:09 -0700
commitbad0b81a0736cd81f36541cff47d51a1b0e44fda (patch)
tree92f196ba95cc0b28bf135609212213bb5b107a95 /activerecord
parent9e8b7d9d5bb3537f113fbda2a1720c5f412fbe62 (diff)
parent36a45230dac4546b71b145681cf553a5a4f9eccb (diff)
downloadrails-bad0b81a0736cd81f36541cff47d51a1b0e44fda.tar.gz
rails-bad0b81a0736cd81f36541cff47d51a1b0e44fda.tar.bz2
rails-bad0b81a0736cd81f36541cff47d51a1b0e44fda.zip
Merge pull request #9889 from neerajdotname/unscoped
Unscoped works with other named scope even without block form
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/scoping/default.rb8
-rw-r--r--activerecord/test/cases/relation_scoping_test.rb4
2 files changed, 4 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/scoping/default.rb b/activerecord/lib/active_record/scoping/default.rb
index 5bd481082e..cde4f29d08 100644
--- a/activerecord/lib/active_record/scoping/default.rb
+++ b/activerecord/lib/active_record/scoping/default.rb
@@ -27,14 +27,6 @@ module ActiveRecord
# Post.unscoped {
# Post.limit(10) # Fires "SELECT * FROM posts LIMIT 10"
# }
- #
- # It is recommended that you use the block form of unscoped because
- # chaining unscoped with +scope+ does not work. Assuming that
- # +published+ is a +scope+, the following two statements
- # are equal: the +default_scope+ is applied on both.
- #
- # Post.unscoped.published
- # Post.published
def unscoped
block_given? ? relation.scoping { yield } : relation
end
diff --git a/activerecord/test/cases/relation_scoping_test.rb b/activerecord/test/cases/relation_scoping_test.rb
index 239004a223..6cd89b6227 100644
--- a/activerecord/test/cases/relation_scoping_test.rb
+++ b/activerecord/test/cases/relation_scoping_test.rb
@@ -634,7 +634,11 @@ class DefaultScopingTest < ActiveRecord::TestCase
assert_equal [DeveloperCalledJamis.find(developers(:poor_jamis).id)], DeveloperCalledJamis.poor
assert DeveloperCalledJamis.unscoped.poor.include?(developers(:david).becomes(DeveloperCalledJamis))
+
+ assert_equal 11, DeveloperCalledJamis.unscoped.length
+ assert_equal 1, DeveloperCalledJamis.poor.length
assert_equal 10, DeveloperCalledJamis.unscoped.poor.length
+ assert_equal 10, DeveloperCalledJamis.unscoped { DeveloperCalledJamis.poor }.length
end
def test_default_scope_select_ignored_by_aggregations