diff options
author | Yves Senn <yves.senn@gmail.com> | 2015-01-05 10:08:06 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2015-01-05 10:08:56 +0100 |
commit | 3ae98181433dda1b5e19910e107494762512a86c (patch) | |
tree | 6c23a60344040edc6e55f02323dd3e7a33c4c44c /activerecord/test | |
parent | 65520c29f7e9fbd654446624a5c267bdc6285341 (diff) | |
download | rails-3ae98181433dda1b5e19910e107494762512a86c.tar.gz rails-3ae98181433dda1b5e19910e107494762512a86c.tar.bz2 rails-3ae98181433dda1b5e19910e107494762512a86c.zip |
remove deprecation warning when modifying a Relation with cached arel.
This adresses https://github.com/rails/rails/commit/1b7aa62b184c4410c99208f71b59bbac5c5f03be#commitcomment-9147803
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 2e2c5ee10b..9631ea79be 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -1651,6 +1651,14 @@ class RelationTest < ActiveRecord::TestCase end end + test "relations with cached arel can't be mutated [internal API]" do + relation = Post.all + relation.count + + assert_raises(ActiveRecord::ImmutableRelation) { relation.limit!(5) } + assert_raises(ActiveRecord::ImmutableRelation) { relation.where!("1 = 2") } + 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 |