aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/associations/eager_test.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2016-08-18 23:17:23 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2016-08-18 23:17:23 -0300
commit28aaf77bb07af5e0108ff986e192e71da6d25078 (patch)
tree264a7b3676e48033f9f86b07de49f914800a8877 /activerecord/test/cases/associations/eager_test.rb
parent085166d59a039bce0e45979a2dec25160bc80f14 (diff)
parent411e4597d552aa091cfe3dc76a83bdaffe02da1a (diff)
downloadrails-28aaf77bb07af5e0108ff986e192e71da6d25078.tar.gz
rails-28aaf77bb07af5e0108ff986e192e71da6d25078.tar.bz2
rails-28aaf77bb07af5e0108ff986e192e71da6d25078.zip
Merge pull request #24099 from k0kubun/preserve-readonly
Preserve readonly flag only for readonly association
Diffstat (limited to 'activerecord/test/cases/associations/eager_test.rb')
-rw-r--r--activerecord/test/cases/associations/eager_test.rb22
1 files changed, 20 insertions, 2 deletions
diff --git a/activerecord/test/cases/associations/eager_test.rb b/activerecord/test/cases/associations/eager_test.rb
index 2c826acf96..6011c552b2 100644
--- a/activerecord/test/cases/associations/eager_test.rb
+++ b/activerecord/test/cases/associations/eager_test.rb
@@ -1424,6 +1424,24 @@ class EagerAssociationTest < ActiveRecord::TestCase
assert david.readonly_comments.first.readonly?
end
+ test "eager-loading non-readonly association" do
+ # has_one
+ firm = Firm.where(id: "1").eager_load(:account).first!
+ assert_not firm.account.readonly?
+
+ # has_and_belongs_to_many
+ project = Project.where(id: "2").eager_load(:developers).first!
+ assert_not project.developers.first.readonly?
+
+ # has_many :through
+ david = Author.where(id: "1").eager_load(:comments).first!
+ assert_not david.comments.first.readonly?
+
+ # belongs_to
+ post = Post.where(id: "1").eager_load(:author).first!
+ assert_not post.author.readonly?
+ end
+
test "eager-loading readonly association" do
# has-one
firm = Firm.where(id: "1").eager_load(:readonly_account).first!
@@ -1438,8 +1456,8 @@ class EagerAssociationTest < ActiveRecord::TestCase
assert david.readonly_comments.first.readonly?
# belongs_to
- post = Post.where(id: "1").eager_load(:author).first!
- assert post.author.readonly?
+ post = Post.where(id: "1").eager_load(:readonly_author).first!
+ assert post.readonly_author.readonly?
end
test "preloading a polymorphic association with references to the associated table" do