diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-10-21 08:19:13 -0700 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-10-21 08:19:13 -0700 |
commit | 9a32c5f64576483dd22540d26aacdd695e05b285 (patch) | |
tree | 085b954b960d7cc08b915e2f3b14f0ff48505e2e /activerecord/test/cases | |
parent | 73641563917e3a69b63a1b11c8ebe33c469e8951 (diff) | |
parent | b05776581747057c162207d0a857c98fa326c11d (diff) | |
download | rails-9a32c5f64576483dd22540d26aacdd695e05b285.tar.gz rails-9a32c5f64576483dd22540d26aacdd695e05b285.tar.bz2 rails-9a32c5f64576483dd22540d26aacdd695e05b285.zip |
Merge pull request #12565 from stormsilver/unscope_fixes
Allow unscope to work with `where.not`
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/scoping/default_scoping_test.rb | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/activerecord/test/cases/scoping/default_scoping_test.rb b/activerecord/test/cases/scoping/default_scoping_test.rb index cd7d91ff85..526f7a8c25 100644 --- a/activerecord/test/cases/scoping/default_scoping_test.rb +++ b/activerecord/test/cases/scoping/default_scoping_test.rb @@ -122,17 +122,25 @@ class DefaultScopingTest < ActiveRecord::TestCase end def test_unscope_with_where_attributes - expected = Developer.order('salary DESC').collect { |dev| dev.name } - received = DeveloperOrderedBySalary.where(name: 'David').unscope(where: :name).collect { |dev| dev.name } + expected = Developer.order('salary DESC').collect(&:name) + received = DeveloperOrderedBySalary.where(name: 'David').unscope(where: :name).collect(&:name) assert_equal expected, received - expected_2 = Developer.order('salary DESC').collect { |dev| dev.name } - received_2 = DeveloperOrderedBySalary.select("id").where("name" => "Jamis").unscope({:where => :name}, :select).collect { |dev| dev.name } + expected_2 = Developer.order('salary DESC').collect(&:name) + received_2 = DeveloperOrderedBySalary.select("id").where("name" => "Jamis").unscope({:where => :name}, :select).collect(&:name) assert_equal expected_2, received_2 - expected_3 = Developer.order('salary DESC').collect { |dev| dev.name } - received_3 = DeveloperOrderedBySalary.select("id").where("name" => "Jamis").unscope(:select, :where).collect { |dev| dev.name } + expected_3 = Developer.order('salary DESC').collect(&:name) + received_3 = DeveloperOrderedBySalary.select("id").where("name" => "Jamis").unscope(:select, :where).collect(&:name) assert_equal expected_3, received_3 + + expected_4 = Developer.order('salary DESC').collect(&:name) + received_4 = DeveloperOrderedBySalary.where.not("name" => "Jamis").unscope(where: :name).collect(&:name) + assert_equal expected_4, received_4 + + expected_5 = Developer.order('salary DESC').collect(&:name) + received_5 = DeveloperOrderedBySalary.where.not("name" => ["Jamis", "David"]).unscope(where: :name).collect(&:name) + assert_equal expected_5, received_5 end def test_unscope_multiple_where_clauses |