diff options
| author | Matthew Draper <matthew@trebex.net> | 2016-02-21 03:28:18 +1030 |
|---|---|---|
| committer | Matthew Draper <matthew@trebex.net> | 2016-02-21 03:28:18 +1030 |
| commit | cdd45fa09d76f7c16ccbb6682e672a44f82174a0 (patch) | |
| tree | 669f8316541c06bcf18692d7b4f6f9ba904ce119 /activerecord/test | |
| parent | 4f44348602446217df89536e911f516b065de33a (diff) | |
| download | rails-cdd45fa09d76f7c16ccbb6682e672a44f82174a0.tar.gz rails-cdd45fa09d76f7c16ccbb6682e672a44f82174a0.tar.bz2 rails-cdd45fa09d76f7c16ccbb6682e672a44f82174a0.zip | |
Mutating the result of Relation#to_a should not affect the relation
Clarifying this separation and enforcing relation immutability is the
culmination of the previous efforts to remove the mutator method
delegations.
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 |
