aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2015-04-28 11:28:43 +0200
committerYves Senn <yves.senn@gmail.com>2015-04-28 11:37:59 +0200
commit80f011ea542c801afc852e1a5f9efa9a30dd4219 (patch)
tree77d25c2dde52b7625e92cb002875f4e2a97e941f /activerecord/test
parentcdf3548a452bbe5cddaad0a398d4266b36f9e388 (diff)
parentc6e05d68400361921c4ba6f0888979e92a4a801b (diff)
downloadrails-80f011ea542c801afc852e1a5f9efa9a30dd4219.tar.gz
rails-80f011ea542c801afc852e1a5f9efa9a30dd4219.tar.bz2
rails-80f011ea542c801afc852e1a5f9efa9a30dd4219.zip
Merge pull request #19546 from DianthuDia/fix_unscope_for_less_than
Fix unscope for less than
Diffstat (limited to 'activerecord/test')
-rw-r--r--activerecord/test/cases/scoping/default_scoping_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/scoping/default_scoping_test.rb b/activerecord/test/cases/scoping/default_scoping_test.rb
index 4137b20c4a..0dbc60940e 100644
--- a/activerecord/test/cases/scoping/default_scoping_test.rb
+++ b/activerecord/test/cases/scoping/default_scoping_test.rb
@@ -153,6 +153,18 @@ class DefaultScopingTest < ActiveRecord::TestCase
assert_equal expected_7, received_7
end
+ def test_unscope_comparison_where_clauses
+ # unscoped for WHERE (`developers`.`id` <= 2)
+ expected = Developer.order('salary DESC').collect(&:name)
+ received = DeveloperOrderedBySalary.where(id: -Float::INFINITY..2).unscope(where: :id).collect { |dev| dev.name }
+ assert_equal expected, received
+
+ # unscoped for WHERE (`developers`.`id` < 2)
+ expected = Developer.order('salary DESC').collect(&:name)
+ received = DeveloperOrderedBySalary.where(id: -Float::INFINITY...2).unscope(where: :id).collect { |dev| dev.name }
+ assert_equal expected, received
+ end
+
def test_unscope_multiple_where_clauses
expected = Developer.order('salary DESC').collect(&:name)
received = DeveloperOrderedBySalary.where(name: 'Jamis').where(id: 1).unscope(where: [:name, :id]).collect(&:name)