diff options
author | thedarkone <thedarkone2@gmail.com> | 2013-09-11 14:18:31 +0200 |
---|---|---|
committer | thedarkone <thedarkone2@gmail.com> | 2013-09-11 14:18:31 +0200 |
commit | 5cbed2bc606750c71ee231d2b816471fe241459e (patch) | |
tree | dac1c587f0cf6f6388ad91a83fa689e7e5d6b71a /activerecord/test | |
parent | 05f88b7b0499781f87e9e79cbec4d01193db2352 (diff) | |
download | rails-5cbed2bc606750c71ee231d2b816471fe241459e.tar.gz rails-5cbed2bc606750c71ee231d2b816471fe241459e.tar.bz2 rails-5cbed2bc606750c71ee231d2b816471fe241459e.zip |
Relation#merge should not lose readonly(false) flag.
The original code ignores the `false` value because `false.blank? # => true`.
Diffstat (limited to 'activerecord/test')
-rw-r--r-- | activerecord/test/cases/relation_test.rb | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/test/cases/relation_test.rb b/activerecord/test/cases/relation_test.rb index a327b0d3e5..e77de19ac3 100644 --- a/activerecord/test/cases/relation_test.rb +++ b/activerecord/test/cases/relation_test.rb @@ -193,6 +193,14 @@ module ActiveRecord assert_equal ['foo = bar'], relation.where_values end + def test_merging_readonly_false + relation = Relation.new FakeKlass, :b + readonly_false_relation = relation.readonly(false) + # test merging in both directions + assert_equal false, relation.merge(readonly_false_relation).readonly_value + assert_equal false, readonly_false_relation.merge(relation).readonly_value + end + def test_relation_merging_with_merged_joins_as_symbols special_comments_with_ratings = SpecialComment.joins(:ratings) posts_with_special_comments_with_ratings = Post.group("posts.id").joins(:special_comments).merge(special_comments_with_ratings) |