diff options
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relation_test.rb | 6 | ||||
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 9 |
2 files changed, 15 insertions, 0 deletions
diff --git a/activerecord/test/cases/relation_test.rb b/activerecord/test/cases/relation_test.rb index 6399111be6..98e278df82 100644 --- a/activerecord/test/cases/relation_test.rb +++ b/activerecord/test/cases/relation_test.rb @@ -256,5 +256,11 @@ module ActiveRecord test 'merge with a proc' do assert_equal [:foo], relation.merge(-> { where(:foo) }).where_values end + + test 'none!' do + assert relation.none!.equal?(relation) + assert_equal [NullRelation], relation.extending_values + assert relation.is_a?(NullRelation) + end end end 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 |