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:
parent
c6f47c1980
commit
35ca953a27
1 changed files with 9 additions and 0 deletions
|
@ -1391,6 +1391,15 @@ class RelationTest < ActiveRecord::TestCase
|
||||||
end
|
end
|
||||||
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
|
test "relations show the records in #inspect" do
|
||||||
relation = Post.limit(2)
|
relation = Post.limit(2)
|
||||||
assert_equal "#<ActiveRecord::Relation [#{Post.limit(2).map(&:inspect).join(', ')}]>", relation.inspect
|
assert_equal "#<ActiveRecord::Relation [#{Post.limit(2).map(&:inspect).join(', ')}]>", relation.inspect
|
||||||
|
|
Loading…
Reference in a new issue