find_cache 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/CHANGE-LOG +8 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +80 -0
  4. data/Rakefile +38 -0
  5. data/lib/find_cache.rb +5 -0
  6. data/lib/find_cache/cacheable.rb +88 -0
  7. data/lib/find_cache/init.rb +1 -0
  8. data/lib/find_cache/key_gen.rb +27 -0
  9. data/lib/find_cache/version.rb +3 -0
  10. data/lib/tasks/find_cache_tasks.rake +4 -0
  11. data/test/dummy/README.rdoc +261 -0
  12. data/test/dummy/Rakefile +7 -0
  13. data/test/dummy/app/assets/javascripts/application.js +15 -0
  14. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  15. data/test/dummy/app/controllers/application_controller.rb +3 -0
  16. data/test/dummy/app/helpers/application_helper.rb +2 -0
  17. data/test/dummy/app/models/comment.rb +6 -0
  18. data/test/dummy/app/models/post.rb +7 -0
  19. data/test/dummy/app/models/user.rb +13 -0
  20. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  21. data/test/dummy/config.ru +4 -0
  22. data/test/dummy/config/application.rb +59 -0
  23. data/test/dummy/config/boot.rb +10 -0
  24. data/test/dummy/config/database.yml +25 -0
  25. data/test/dummy/config/environment.rb +5 -0
  26. data/test/dummy/config/environments/development.rb +39 -0
  27. data/test/dummy/config/environments/production.rb +67 -0
  28. data/test/dummy/config/environments/test.rb +37 -0
  29. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  30. data/test/dummy/config/initializers/counter_cache_patch.rb +19 -0
  31. data/test/dummy/config/initializers/inflections.rb +15 -0
  32. data/test/dummy/config/initializers/mime_types.rb +5 -0
  33. data/test/dummy/config/initializers/secret_token.rb +7 -0
  34. data/test/dummy/config/initializers/session_store.rb +8 -0
  35. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  36. data/test/dummy/config/locales/en.yml +5 -0
  37. data/test/dummy/config/routes.rb +58 -0
  38. data/test/dummy/db/development.sqlite3 +0 -0
  39. data/test/dummy/db/migrate/20120824210455_create_users.rb +10 -0
  40. data/test/dummy/db/migrate/20120824210731_create_comments.rb +11 -0
  41. data/test/dummy/db/migrate/20120824210927_create_posts.rb +13 -0
  42. data/test/dummy/db/schema.rb +43 -0
  43. data/test/dummy/db/test.sqlite3 +0 -0
  44. data/test/dummy/log/development.log +498 -0
  45. data/test/dummy/log/test.log +224 -0
  46. data/test/dummy/public/404.html +26 -0
  47. data/test/dummy/public/422.html +26 -0
  48. data/test/dummy/public/500.html +25 -0
  49. data/test/dummy/public/favicon.ico +0 -0
  50. data/test/dummy/script/rails +6 -0
  51. data/test/dummy/test/fixtures/comments.yml +9 -0
  52. data/test/dummy/test/fixtures/posts.yml +13 -0
  53. data/test/dummy/test/fixtures/users.yml +9 -0
  54. data/test/dummy/test/unit/comment_test.rb +7 -0
  55. data/test/dummy/test/unit/post_test.rb +7 -0
  56. data/test/dummy/test/unit/user_test.rb +7 -0
  57. data/test/dummy/tmp/cache/26E/540/User%2F1 +0 -0
  58. data/test/dummy/tmp/cache/26F/550/User%2F2 +0 -0
  59. data/test/dummy/tmp/cache/270/560/User%2F3 +0 -0
  60. data/test/dummy/tmp/cache/271/570/User%2F4 +0 -0
  61. data/test/dummy/tmp/cache/272/580/User%2F5 +0 -0
  62. data/test/dummy/tmp/cache/273/590/User%2F6 +0 -0
  63. data/test/dummy/tmp/cache/275/6E0/Post%2F1 +0 -0
  64. data/test/dummy/tmp/cache/276/6F0/Post%2F2 +0 -0
  65. data/test/dummy/tmp/cache/277/700/Post%2F3 +0 -0
  66. data/test/dummy/tmp/cache/3A8/070/Comment%2F7 +0 -0
  67. data/test/dummy/tmp/cache/3A9/080/Comment%2F8 +0 -0
  68. data/test/dummy/tmp/cache/3AA/090/Comment%2F9 +0 -0
  69. data/test/dummy/tmp/cache/3D2/D30/Comment%2F10 +0 -0
  70. data/test/dummy/tmp/cache/3D4/D50/Comment%2F12 +0 -0
  71. data/test/dummy/tmp/cache/3D5/D60/Comment%2F13 +0 -0
  72. data/test/dummy/tmp/cache/3D6/D70/Comment%2F14 +0 -0
  73. data/test/dummy/tmp/cache/3D7/D80/Comment%2F15 +0 -0
  74. data/test/dummy/tmp/cache/58D/B70/Post%2Fuser_id-1 +1 -0
  75. data/test/find_cache_test.rb +51 -0
  76. data/test/test_helper.rb +15 -0
  77. metadata +261 -0
@@ -0,0 +1,224 @@
1
+ Connecting to database specified by database.yml
2
+  (0.5ms) begin transaction
3
+  (0.1ms) rollback transaction
4
+ Connecting to database specified by database.yml
5
+  (0.6ms) begin transaction
6
+  (0.0ms) rollback transaction
7
+ Connecting to database specified by database.yml
8
+ Connecting to database specified by database.yml
9
+ Connecting to database specified by database.yml
10
+ Connecting to database specified by database.yml
11
+ Connecting to database specified by database.yml
12
+ Connecting to database specified by database.yml
13
+ Connecting to database specified by database.yml
14
+ Connecting to database specified by database.yml
15
+  (0.1ms) begin transaction
16
+ SQL (23.1ms) INSERT INTO "users" ("created_at", "email", "password", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Fri, 24 Aug 2012 21:42:47 UTC +00:00], ["email", "test@videofork.com"], ["password", "test1234"], ["updated_at", Fri, 24 Aug 2012 21:42:47 UTC +00:00]]
17
+ SQL (0.5ms) INSERT INTO "posts" ("body", "comments_count", "created_at", "title", "updated_at", "user_id") VALUES (?, ?, ?, ?, ?, ?) [["body", nil], ["comments_count", nil], ["created_at", Fri, 24 Aug 2012 21:42:47 UTC +00:00], ["title", nil], ["updated_at", Fri, 24 Aug 2012 21:42:47 UTC +00:00], ["user_id", 1]]
18
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 1 LIMIT 1
19
+  (1.7ms) commit transaction
20
+ User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
21
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
22
+ Connecting to database specified by database.yml
23
+ Connecting to database specified by database.yml
24
+ Connecting to database specified by database.yml
25
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" LIMIT 1
26
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
27
+  (0.1ms) begin transaction
28
+ SQL (5.0ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test content for comment"], ["created_at", Fri, 24 Aug 2012 22:01:42 UTC +00:00], ["post_id", 1], ["updated_at", Fri, 24 Aug 2012 22:01:42 UTC +00:00]]
29
+  (0.8ms) rollback transaction
30
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
31
+  (0.0ms) begin transaction
32
+ SQL (0.4ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test 1 content for comment"], ["created_at", Fri, 24 Aug 2012 22:01:42 UTC +00:00], ["post_id", 1], ["updated_at", Fri, 24 Aug 2012 22:01:42 UTC +00:00]]
33
+  (0.7ms) rollback transaction
34
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
35
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
36
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
37
+  (0.1ms) begin transaction
38
+ SQL (0.5ms) INSERT INTO "users" ("created_at", "email", "password", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Fri, 24 Aug 2012 22:01:42 UTC +00:00], ["email", "test@videofork.com"], ["password", "test1234"], ["updated_at", Fri, 24 Aug 2012 22:01:42 UTC +00:00]]
39
+ SQL (0.4ms) INSERT INTO "posts" ("body", "comments_count", "created_at", "title", "updated_at", "user_id") VALUES (?, ?, ?, ?, ?, ?) [["body", nil], ["comments_count", nil], ["created_at", Fri, 24 Aug 2012 22:01:42 UTC +00:00], ["title", nil], ["updated_at", Fri, 24 Aug 2012 22:01:42 UTC +00:00], ["user_id", 2]]
40
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 2 LIMIT 1
41
+  (2.3ms) commit transaction
42
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 2 LIMIT 1
43
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = 2 LIMIT 1
44
+ User Load (0.1ms) SELECT "users".* FROM "users" LIMIT 1
45
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 1 LIMIT 1
46
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 1 LIMIT 1
47
+ Connecting to database specified by database.yml
48
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
49
+  (0.1ms) begin transaction
50
+ SQL (4.1ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test content for comment"], ["created_at", Fri, 24 Aug 2012 22:02:05 UTC +00:00], ["post_id", 1], ["updated_at", Fri, 24 Aug 2012 22:02:05 UTC +00:00]]
51
+  (0.9ms) rollback transaction
52
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
53
+  (0.0ms) begin transaction
54
+ SQL (0.4ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test 1 content for comment"], ["created_at", Fri, 24 Aug 2012 22:02:05 UTC +00:00], ["post_id", 1], ["updated_at", Fri, 24 Aug 2012 22:02:05 UTC +00:00]]
55
+  (0.6ms) rollback transaction
56
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
57
+  (0.0ms) begin transaction
58
+  (0.4ms) UPDATE "posts" SET "title" = 'test', "body" = 'hello world!', "updated_at" = '2012-08-24 22:02:05.031746' WHERE "posts"."id" = 1
59
+  (1.6ms) commit transaction
60
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
61
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
62
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
63
+  (0.1ms) begin transaction
64
+ SQL (0.6ms) INSERT INTO "users" ("created_at", "email", "password", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Fri, 24 Aug 2012 22:02:05 UTC +00:00], ["email", "test@videofork.com"], ["password", "test1234"], ["updated_at", Fri, 24 Aug 2012 22:02:05 UTC +00:00]]
65
+ SQL (0.4ms) INSERT INTO "posts" ("body", "comments_count", "created_at", "title", "updated_at", "user_id") VALUES (?, ?, ?, ?, ?, ?) [["body", nil], ["comments_count", nil], ["created_at", Fri, 24 Aug 2012 22:02:05 UTC +00:00], ["title", nil], ["updated_at", Fri, 24 Aug 2012 22:02:05 UTC +00:00], ["user_id", 3]]
66
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 3 LIMIT 1
67
+  (1.9ms) commit transaction
68
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 3 LIMIT 1
69
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = 3 LIMIT 1
70
+ User Load (0.2ms) SELECT "users".* FROM "users" LIMIT 1
71
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 1 LIMIT 1
72
+ Connecting to database specified by database.yml
73
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
74
+  (0.1ms) begin transaction
75
+ SQL (4.6ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test content for comment"], ["created_at", Fri, 24 Aug 2012 22:02:50 UTC +00:00], ["post_id", 1], ["updated_at", Fri, 24 Aug 2012 22:02:50 UTC +00:00]]
76
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
77
+ SQL (0.2ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
78
+  (2.7ms) commit transaction
79
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
80
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
81
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" LIMIT 1
82
+  (0.0ms) begin transaction
83
+ SQL (0.4ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test 1 content for comment"], ["created_at", Fri, 24 Aug 2012 22:02:50 UTC +00:00], ["post_id", 1], ["updated_at", Fri, 24 Aug 2012 22:02:50 UTC +00:00]]
84
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
85
+ SQL (0.1ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
86
+  (1.8ms) commit transaction
87
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" LIMIT 1
88
+  (0.0ms) begin transaction
89
+ SQL (0.3ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test 2 content for comment"], ["created_at", Fri, 24 Aug 2012 22:02:50 UTC +00:00], ["post_id", 1], ["updated_at", Fri, 24 Aug 2012 22:02:50 UTC +00:00]]
90
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
91
+ SQL (0.1ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
92
+  (2.1ms) commit transaction
93
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
94
+  (0.1ms) begin transaction
95
+ SQL (0.3ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test 3 content for comment"], ["created_at", Fri, 24 Aug 2012 22:02:50 UTC +00:00], ["post_id", 1], ["updated_at", Fri, 24 Aug 2012 22:02:50 UTC +00:00]]
96
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
97
+ SQL (0.1ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
98
+  (1.8ms) commit transaction
99
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" LIMIT 1
100
+  (0.0ms) begin transaction
101
+ SQL (0.3ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test 4 content for comment"], ["created_at", Fri, 24 Aug 2012 22:02:50 UTC +00:00], ["post_id", 1], ["updated_at", Fri, 24 Aug 2012 22:02:50 UTC +00:00]]
102
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
103
+ SQL (0.1ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
104
+  (2.2ms) commit transaction
105
+ Post Load (0.3ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" IN (2, 3, 4, 5)
106
+ Post Load (0.3ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" IN (2, 3, 4, 5) ORDER BY id DESC
107
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
108
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
109
+  (0.0ms) begin transaction
110
+  (0.0ms) commit transaction
111
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
112
+ Post Load (0.3ms) SELECT "posts".* FROM "posts" LIMIT 1
113
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
114
+  (0.1ms) begin transaction
115
+ SQL (0.5ms) INSERT INTO "users" ("created_at", "email", "password", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Fri, 24 Aug 2012 22:02:50 UTC +00:00], ["email", "test@videofork.com"], ["password", "test1234"], ["updated_at", Fri, 24 Aug 2012 22:02:50 UTC +00:00]]
116
+ SQL (0.4ms) INSERT INTO "posts" ("body", "comments_count", "created_at", "title", "updated_at", "user_id") VALUES (?, ?, ?, ?, ?, ?) [["body", nil], ["comments_count", nil], ["created_at", Fri, 24 Aug 2012 22:02:50 UTC +00:00], ["title", nil], ["updated_at", Fri, 24 Aug 2012 22:02:50 UTC +00:00], ["user_id", 4]]
117
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 4 LIMIT 1
118
+  (2.7ms) commit transaction
119
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 4 LIMIT 1
120
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = 4 LIMIT 1
121
+ User Load (0.3ms) SELECT "users".* FROM "users" LIMIT 1
122
+ Post Load (0.3ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 1 LIMIT 1
123
+ Connecting to database specified by database.yml
124
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
125
+  (0.1ms) begin transaction
126
+ SQL (4.2ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test content for comment"], ["created_at", Fri, 24 Aug 2012 22:04:15 UTC +00:00], ["post_id", 1], ["updated_at", Fri, 24 Aug 2012 22:04:15 UTC +00:00]]
127
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
128
+ SQL (0.2ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
129
+  (2.5ms) commit transaction
130
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
131
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
132
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" LIMIT 1
133
+  (0.0ms) begin transaction
134
+ SQL (0.4ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test 1 content for comment"], ["created_at", Fri, 24 Aug 2012 22:04:15 UTC +00:00], ["post_id", 1], ["updated_at", Fri, 24 Aug 2012 22:04:15 UTC +00:00]]
135
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
136
+ SQL (0.1ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
137
+  (1.6ms) commit transaction
138
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
139
+  (0.0ms) begin transaction
140
+ SQL (0.3ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test 2 content for comment"], ["created_at", Fri, 24 Aug 2012 22:04:15 UTC +00:00], ["post_id", 1], ["updated_at", Fri, 24 Aug 2012 22:04:15 UTC +00:00]]
141
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
142
+ SQL (0.2ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
143
+  (1.6ms) commit transaction
144
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" LIMIT 1
145
+  (0.0ms) begin transaction
146
+ SQL (0.3ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test 3 content for comment"], ["created_at", Fri, 24 Aug 2012 22:04:15 UTC +00:00], ["post_id", 1], ["updated_at", Fri, 24 Aug 2012 22:04:15 UTC +00:00]]
147
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
148
+ SQL (0.1ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
149
+  (2.0ms) commit transaction
150
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" LIMIT 1
151
+  (0.0ms) begin transaction
152
+ SQL (0.3ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test 4 content for comment"], ["created_at", Fri, 24 Aug 2012 22:04:15 UTC +00:00], ["post_id", 1], ["updated_at", Fri, 24 Aug 2012 22:04:15 UTC +00:00]]
153
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
154
+ SQL (0.1ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
155
+  (1.8ms) commit transaction
156
+ Comment Load (0.3ms) SELECT "comments".* FROM "comments" WHERE "comments"."id" IN (7, 8, 9, 10)
157
+ Comment Load (0.3ms) SELECT "comments".* FROM "comments" WHERE "comments"."id" IN (7, 8, 9, 10) ORDER BY id DESC
158
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
159
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
160
+  (0.1ms) begin transaction
161
+  (0.1ms) commit transaction
162
+ Post Load (0.3ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
163
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
164
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
165
+  (0.1ms) begin transaction
166
+ SQL (0.5ms) INSERT INTO "users" ("created_at", "email", "password", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Fri, 24 Aug 2012 22:04:15 UTC +00:00], ["email", "test@videofork.com"], ["password", "test1234"], ["updated_at", Fri, 24 Aug 2012 22:04:15 UTC +00:00]]
167
+ SQL (0.4ms) INSERT INTO "posts" ("body", "comments_count", "created_at", "title", "updated_at", "user_id") VALUES (?, ?, ?, ?, ?, ?) [["body", nil], ["comments_count", nil], ["created_at", Fri, 24 Aug 2012 22:04:15 UTC +00:00], ["title", nil], ["updated_at", Fri, 24 Aug 2012 22:04:15 UTC +00:00], ["user_id", 5]]
168
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 5 LIMIT 1
169
+  (2.2ms) commit transaction
170
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 5 LIMIT 1
171
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = 5 LIMIT 1
172
+ User Load (0.1ms) SELECT "users".* FROM "users" LIMIT 1
173
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 1 LIMIT 1
174
+ Connecting to database specified by database.yml
175
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
176
+  (0.1ms) begin transaction
177
+ SQL (4.2ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test content for comment"], ["created_at", Fri, 24 Aug 2012 22:05:54 UTC +00:00], ["post_id", 1], ["updated_at", Fri, 24 Aug 2012 22:05:54 UTC +00:00]]
178
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
179
+ SQL (0.2ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
180
+  (3.0ms) commit transaction
181
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
182
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
183
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
184
+  (0.0ms) begin transaction
185
+ SQL (0.4ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test 1 content for comment"], ["created_at", Fri, 24 Aug 2012 22:05:54 UTC +00:00], ["post_id", 1], ["updated_at", Fri, 24 Aug 2012 22:05:54 UTC +00:00]]
186
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
187
+ SQL (0.1ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
188
+  (1.8ms) commit transaction
189
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" LIMIT 1
190
+  (0.0ms) begin transaction
191
+ SQL (0.3ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test 2 content for comment"], ["created_at", Fri, 24 Aug 2012 22:05:54 UTC +00:00], ["post_id", 1], ["updated_at", Fri, 24 Aug 2012 22:05:54 UTC +00:00]]
192
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
193
+ SQL (0.1ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
194
+  (1.9ms) commit transaction
195
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" LIMIT 1
196
+  (0.0ms) begin transaction
197
+ SQL (0.3ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test 3 content for comment"], ["created_at", Fri, 24 Aug 2012 22:05:54 UTC +00:00], ["post_id", 1], ["updated_at", Fri, 24 Aug 2012 22:05:54 UTC +00:00]]
198
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
199
+ SQL (0.1ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
200
+  (2.0ms) commit transaction
201
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" LIMIT 1
202
+  (0.0ms) begin transaction
203
+ SQL (0.3ms) INSERT INTO "comments" ("content", "created_at", "post_id", "updated_at") VALUES (?, ?, ?, ?) [["content", "test 4 content for comment"], ["created_at", Fri, 24 Aug 2012 22:05:54 UTC +00:00], ["post_id", 1], ["updated_at", Fri, 24 Aug 2012 22:05:54 UTC +00:00]]
204
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
205
+ SQL (0.1ms) UPDATE "posts" SET "comments_count" = COALESCE("comments_count", 0) + 1 WHERE "posts"."id" = 1
206
+  (1.5ms) commit transaction
207
+ Comment Load (0.3ms) SELECT "comments".* FROM "comments" WHERE "comments"."id" IN (12, 13, 14, 15) ORDER BY id ASC
208
+ Comment Load (0.3ms) SELECT "comments".* FROM "comments" WHERE "comments"."id" IN (12, 13, 14, 15) ORDER BY id ASC
209
+ Post Load (0.3ms) SELECT "posts".* FROM "posts" LIMIT 1
210
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
211
+  (0.1ms) begin transaction
212
+  (0.1ms) commit transaction
213
+ Post Load (0.3ms) SELECT "posts".* FROM "posts" WHERE "posts"."id" = 1 LIMIT 1
214
+ Post Load (0.2ms) SELECT "posts".* FROM "posts" LIMIT 1
215
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
216
+  (0.1ms) begin transaction
217
+ SQL (0.5ms) INSERT INTO "users" ("created_at", "email", "password", "updated_at") VALUES (?, ?, ?, ?) [["created_at", Fri, 24 Aug 2012 22:05:54 UTC +00:00], ["email", "test@videofork.com"], ["password", "test1234"], ["updated_at", Fri, 24 Aug 2012 22:05:54 UTC +00:00]]
218
+ SQL (0.4ms) INSERT INTO "posts" ("body", "comments_count", "created_at", "title", "updated_at", "user_id") VALUES (?, ?, ?, ?, ?, ?) [["body", nil], ["comments_count", nil], ["created_at", Fri, 24 Aug 2012 22:05:54 UTC +00:00], ["title", nil], ["updated_at", Fri, 24 Aug 2012 22:05:54 UTC +00:00], ["user_id", 6]]
219
+ Post Load (0.1ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 6 LIMIT 1
220
+  (2.5ms) commit transaction
221
+ User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = 6 LIMIT 1
222
+ User Load (0.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = 6 LIMIT 1
223
+ User Load (0.1ms) SELECT "users".* FROM "users" LIMIT 1
224
+ Post Load (0.3ms) SELECT "posts".* FROM "posts" WHERE "posts"."user_id" = 1 LIMIT 1
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,9 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ one:
4
+ post:
5
+ content: MyText
6
+
7
+ two:
8
+ post:
9
+ content: MyText
@@ -0,0 +1,13 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ one:
4
+ user:
5
+ title: MyString
6
+ body: MyText
7
+ comments_count: 1
8
+
9
+ two:
10
+ user:
11
+ title: MyString
12
+ body: MyText
13
+ comments_count: 1
@@ -0,0 +1,9 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ one:
4
+ email: MyString
5
+ password: MyString
6
+
7
+ two:
8
+ email: MyString
9
+ password: MyString
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class CommentTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class PostTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class UserTest < ActiveSupport::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1 @@
1
+ o: ActiveSupport::Cache::Entry :@compressedF:@expires_in0:@created_atf1345845702.720623: @value" i
@@ -0,0 +1,51 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require 'test_helper'
3
+
4
+ class FindCacheTest < Test::Unit::TestCase
5
+
6
+ # record test
7
+ def test_user_find_by_id_should_be_find_cache
8
+ user = User.create email: "test@videofork.com", password: "test1234"
9
+ id = user.id
10
+ assert_equal User.find_by_id(id), User.find_cache(id)
11
+ end
12
+
13
+ # find_cache_has_one test
14
+ def test_user_post_should_be_user_post_cache
15
+ user = User.first
16
+ assert_equal user.post, user.post_cache
17
+ end
18
+
19
+ # find_cache_belongs_to test
20
+ def test_post_user_should_be_post_user_cache
21
+ post = Post.first
22
+ assert_equal post.user, post.user_cache
23
+ end
24
+
25
+ # record update test
26
+ def test_post_update_should_expire_the_post_cache
27
+ post = Post.first
28
+ Post.find_cache(post.id) # to cache the post
29
+ post.update_attributes(title: "test", body: "hello world!")
30
+ assert_equal post, Post.find_cache(post.id)
31
+ end
32
+
33
+ # counter cache fix test
34
+ def test_after_adding_comment_post_should_expire_the_post_cache
35
+ post = Post.first
36
+ Post.find_cache(post.id) # to cache the post
37
+ Comment.create post_id: post.id, content: "test content for comment"
38
+ assert_equal Post.find_by_id(post.id), Post.find_cache(post.id)
39
+ end
40
+
41
+ # find_all_cache test
42
+ def test_find_all_by_id_should_be_find_all_cache
43
+ c1 = Comment.create post_id: Post.first.id, content: "test 1 content for comment"
44
+ c2 = Comment.create post_id: Post.first.id, content: "test 2 content for comment"
45
+ c3 = Comment.create post_id: Post.first.id, content: "test 3 content for comment"
46
+ c4 = Comment.create post_id: Post.first.id, content: "test 4 content for comment"
47
+ ids = [c1.id, c2.id, c3.id, c4.id]
48
+ assert_equal Comment.order("id ASC").find_all_by_id(ids), Comment.find_all_cache(ids, "id ASC")
49
+ end
50
+
51
+ end