diff options
author | Matthew Draper <matthew@trebex.net> | 2016-02-21 09:06:41 +1030 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2016-02-21 09:13:56 +1030 |
commit | 22c318d6cfe39933b2f5adb383cb6f0153f505d3 (patch) | |
tree | a8438098dadf03b2c6c994d84b845d4cef328058 /activerecord/test | |
parent | e30897f8b948bd7248090518fca63895a19bd6e8 (diff) | |
parent | cdd45fa09d76f7c16ccbb6682e672a44f82174a0 (diff) | |
download | rails-22c318d6cfe39933b2f5adb383cb6f0153f505d3.tar.gz rails-22c318d6cfe39933b2f5adb383cb6f0153f505d3.tar.bz2 rails-22c318d6cfe39933b2f5adb383cb6f0153f505d3.zip |
Merge pull request #23794 from matthewd/mutation-safe-to_a
Mutating the result of Relation#to_a should not affect the relation
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 090b885dd5..4c15ab6644 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -1273,6 +1273,16 @@ class RelationTest < ActiveRecord::TestCase assert posts.loaded? end + def test_to_a_should_dup_target + posts = Post.all + + original_size = posts.size + removed = posts.to_a.pop + + assert_equal original_size, posts.size + assert_includes posts.to_a, removed + end + def test_build posts = Post.all |