diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-07-20 12:56:57 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-20 12:56:57 -0300 |
commit | b1d48d542452e5d87b42a8af513b7102d92b0684 (patch) | |
tree | 28b7b4120a77673a172bc4774966f31c7128693c /activerecord/test | |
parent | 5757b9dbe732be03d41d4c23a6545bc396545421 (diff) | |
parent | 1a10d38d465b4f8843ec916538ad0fc70a890f4d (diff) | |
download | rails-b1d48d542452e5d87b42a8af513b7102d92b0684.tar.gz rails-b1d48d542452e5d87b42a8af513b7102d92b0684.tar.bz2 rails-b1d48d542452e5d87b42a8af513b7102d92b0684.zip |
Merge pull request #25786 from kamipo/add_exists_and_update_all_to_collection_proxy
Add `exists?` and `update_all` to `CollectionProxy` for respects an association scope
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/associations/has_many_associations_test.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index 61a5c2c3b7..325a06d724 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -439,6 +439,26 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_equal person, person.readers.first.person end + def test_update_all_respects_association_scope + person = Person.new + person.first_name = 'Naruto' + person.references << Reference.new + person.id = 10 + person.references + person.save! + assert_equal 1, person.references.update_all(favourite: true) + end + + def test_exists_respects_association_scope + person = Person.new + person.first_name = 'Sasuke' + person.references << Reference.new + person.id = 10 + person.references + person.save! + assert_predicate person.references, :exists? + end + def force_signal37_to_load_all_clients_of_firm companies(:first_firm).clients_of_firm.each {|f| } end |