From a93cb4adafc5a71765f2e68c4314e1486ca9f977 Mon Sep 17 00:00:00 2001 From: oleg dashevskii Date: Thu, 26 Aug 2010 11:22:27 +0700 Subject: [PATCH] Verify that there is no unwanted implicit readonly set on Model.has_many_throughs.find(id) [#5442 state:resolved] --- activerecord/test/cases/readonly_test.rb | 17 ++++++++++++++++- 1 files changed, 16 insertions(+), 1 deletions(-) diff --git a/activerecord/test/cases/readonly_test.rb b/activerecord/test/cases/readonly_test.rb index 98011f4..01ede92 100644 --- a/activerecord/test/cases/readonly_test.rb +++ b/activerecord/test/cases/readonly_test.rb @@ -12,7 +12,7 @@ def Project.foo() find :first end class ReadOnlyTest < ActiveRecord::TestCase - fixtures :posts, :comments, :developers, :projects, :developers_projects + fixtures :posts, :comments, :developers, :projects, :developers_projects, :people, :readers def test_cant_save_readonly_record dev = Developer.find(1) @@ -71,6 +71,21 @@ class ReadOnlyTest < ActiveRecord::TestCase assert !people.any?(&:readonly?) end + def test_has_many_with_through_is_not_implicitly_marked_readonly_while_finding_by_id + assert person = Post.find(1).people.find(1) + assert !person.readonly? + end + + def test_has_many_with_through_is_not_implicitly_marked_readonly_while_finding_first + assert person = Post.find(1).people.first + assert !person.readonly? + end + + def test_has_many_with_through_is_not_implicitly_marked_readonly_while_finding_last + assert person = Post.find(1).people.first + assert !person.readonly? + end + def test_readonly_scoping Post.send(:with_scope, :find => { :conditions => '1=1' }) do assert !Post.find(1).readonly? -- 1.7.1