diff options
author | Juanjo Bazán <jjbazan@gmail.com> | 2012-09-25 00:34:30 +0200 |
---|---|---|
committer | Juanjo Bazán <jjbazan@gmail.com> | 2012-10-28 22:17:34 +0100 |
commit | 35ca953a27124bd6dcd7aef8a62ffa27ccab83f1 (patch) | |
tree | e28641fcaa1184c1903d5847a0fe588c64695aaa /activerecord | |
parent | c6f47c198034ed2031723a16069005b321846452 (diff) | |
download | rails-35ca953a27124bd6dcd7aef8a62ffa27ccab83f1.tar.gz rails-35ca953a27124bd6dcd7aef8a62ffa27ccab83f1.tar.bz2 rails-35ca953a27124bd6dcd7aef8a62ffa27ccab83f1.zip |
loaded relations cannot be mutated by extending!
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 5f96145b47..bc6cac0c6c 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -1391,6 +1391,15 @@ class RelationTest < ActiveRecord::TestCase end end + test "loaded relations cannot be mutated by extending!" do + relation = Post.all + relation.to_a + + assert_raises(ActiveRecord::ImmutableRelation) do + relation.extending! Module.new + end + end + test "relations show the records in #inspect" do relation = Post.limit(2) assert_equal "#<ActiveRecord::Relation [#{Post.limit(2).map(&:inspect).join(', ')}]>", relation.inspect |