1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

loaded relations cannot be mutated by extending!

This commit is contained in:
Juanjo Bazán 2012-09-25 00:34:30 +02:00
parent c6f47c1980
commit 35ca953a27

View file

@ -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