aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/identity_map_test.rb
diff options
context:
space:
mode:
authorMarcin Raczkowski <marcin.raczkowski@gmail.com>2010-08-29 12:04:43 +0200
committerEmilio Tagua <miloops@gmail.com>2010-11-19 19:04:39 -0300
commitccb335da1f293dc745be0171ce3d95e50223d934 (patch)
treef4526ff6fddd72274a7dc11c355ba365b501da07 /activerecord/test/cases/identity_map_test.rb
parent3ab625f984d3f014735117fb7d0fcf2ff076ff11 (diff)
downloadrails-ccb335da1f293dc745be0171ce3d95e50223d934.tar.gz
rails-ccb335da1f293dc745be0171ce3d95e50223d934.tar.bz2
rails-ccb335da1f293dc745be0171ce3d95e50223d934.zip
IdentityMap - Adjustments to test cases
Diffstat (limited to 'activerecord/test/cases/identity_map_test.rb')
-rw-r--r--activerecord/test/cases/identity_map_test.rb32
1 files changed, 23 insertions, 9 deletions
diff --git a/activerecord/test/cases/identity_map_test.rb b/activerecord/test/cases/identity_map_test.rb
index 915f3abd26..bc0ceae605 100644
--- a/activerecord/test/cases/identity_map_test.rb
+++ b/activerecord/test/cases/identity_map_test.rb
@@ -70,14 +70,22 @@ class IdentityMapTest < ActiveRecord::TestCase
assert_same(t1, t2)
end
- def test_updating_of_pkey
- s = Subscriber.find_by_nick('swistak')
- assert s.update_attribute(:nick, 'swistakTheJester')
- assert_equal('swistakTheJester', s.nick)
-
- assert stj = Subscriber.find_by_nick('swistakTheJester')
- assert_same(s, stj)
- end
+# Currently AR is not allowing changing primary key (see Persistence#update)
+# So we ignore it. If this changes, this test needs to be uncommented.
+# def test_updating_of_pkey
+# assert client = Client.find(3),
+# client.update_attribute(:id, 666)
+#
+# assert Client.find(666)
+# assert_same(client, Client.find(666))
+#
+# s = Subscriber.find_by_nick('swistak')
+# assert s.update_attribute(:nick, 'swistakTheJester')
+# assert_equal('swistakTheJester', s.nick)
+#
+# assert stj = Subscriber.find_by_nick('swistakTheJester')
+# assert_same(s, stj)
+# end
def test_changing_associations
t1 = Topic.create("title" => "t1")
@@ -176,7 +184,7 @@ class IdentityMapTest < ActiveRecord::TestCase
end
assert_equal posts(:welcome, :thinking), posts
- posts = assert_queries(2) do
+ posts = assert_queries(1) do
Post.find(:all, :include => :author, :joins => {:taggings => {:tag => :taggings}}, :conditions => "taggings_tags.super_tag_id=2", :order => 'posts.id')
end
assert_equal posts(:welcome, :thinking), posts
@@ -195,4 +203,10 @@ class IdentityMapTest < ActiveRecord::TestCase
assert_equal [posts(:welcome)], posts
assert_equal authors(:david), assert_no_queries { posts[0].author}
end
+
+ # Second search should not change read only status for collection
+ def test_find_with_joins_option_implies_readonly
+ Developer.joins(', projects').each { |d| assert d.readonly? }
+ Developer.joins(', projects').readonly(false).each { |d| assert d.readonly? }
+ end
end