admin_assistant 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (418) hide show
  1. data/Rakefile +2 -2
  2. data/VERSION +1 -1
  3. data/admin_assistant.gemspec +404 -8
  4. data/rails_2_test/README +256 -0
  5. data/rails_2_test/Rakefile +13 -0
  6. data/rails_2_test/app/controllers/admin/appointments2_controller.rb +15 -0
  7. data/rails_2_test/app/controllers/admin/appointments_controller.rb +11 -0
  8. data/rails_2_test/app/controllers/admin/blog_posts2_controller.rb +138 -0
  9. data/rails_2_test/app/controllers/admin/blog_posts3_controller.rb +76 -0
  10. data/rails_2_test/app/controllers/admin/blog_posts4_controller.rb +21 -0
  11. data/rails_2_test/app/controllers/admin/blog_posts5_controller.rb +27 -0
  12. data/rails_2_test/app/controllers/admin/blog_posts6_controller.rb +10 -0
  13. data/rails_2_test/app/controllers/admin/blog_posts_controller.rb +8 -0
  14. data/rails_2_test/app/controllers/admin/blog_posts_custom_new_and_edit_controller.rb +15 -0
  15. data/rails_2_test/app/controllers/admin/blog_posts_read_only_controller.rb +19 -0
  16. data/rails_2_test/app/controllers/admin/bookmarks_controller.rb +11 -0
  17. data/rails_2_test/app/controllers/admin/comments2_controller.rb +14 -0
  18. data/rails_2_test/app/controllers/admin/comments_controller.rb +12 -0
  19. data/rails_2_test/app/controllers/admin/file_column_images2_controller.rb +10 -0
  20. data/rails_2_test/app/controllers/admin/file_column_images_controller.rb +6 -0
  21. data/rails_2_test/app/controllers/admin/images2_controller.rb +11 -0
  22. data/rails_2_test/app/controllers/admin/images_controller.rb +6 -0
  23. data/rails_2_test/app/controllers/admin/misconfigured1_controller.rb +7 -0
  24. data/rails_2_test/app/controllers/admin/not_migrated_yets_controller.rb +9 -0
  25. data/rails_2_test/app/controllers/admin/product_categories2_controller.rb +7 -0
  26. data/rails_2_test/app/controllers/admin/product_categories_controller.rb +5 -0
  27. data/rails_2_test/app/controllers/admin/products2_controller.rb +15 -0
  28. data/rails_2_test/app/controllers/admin/products_controller.rb +31 -0
  29. data/rails_2_test/app/controllers/admin/television_airings_controller.rb +5 -0
  30. data/rails_2_test/app/controllers/admin/television_time_slots_controller.rb +5 -0
  31. data/rails_2_test/app/controllers/admin/users2_controller.rb +10 -0
  32. data/rails_2_test/app/controllers/admin/users_controller.rb +63 -0
  33. data/rails_2_test/app/controllers/application.rb +16 -0
  34. data/rails_2_test/app/controllers/application_controller.rb +16 -0
  35. data/rails_2_test/app/controllers/blog_posts_controller.rb +5 -0
  36. data/rails_2_test/app/helpers/admin/appointments2_helper.rb +2 -0
  37. data/rails_2_test/app/helpers/admin/appointments_helper.rb +2 -0
  38. data/rails_2_test/app/helpers/admin/blog_posts2_helper.rb +27 -0
  39. data/rails_2_test/app/helpers/admin/blog_posts3_helper.rb +2 -0
  40. data/rails_2_test/app/helpers/admin/blog_posts4_helper.rb +2 -0
  41. data/rails_2_test/app/helpers/admin/blog_posts6_helper.rb +16 -0
  42. data/rails_2_test/app/helpers/admin/blog_posts_custom_new_and_edit_helper.rb +29 -0
  43. data/rails_2_test/app/helpers/admin/blog_posts_helper.rb +2 -0
  44. data/rails_2_test/app/helpers/admin/blog_posts_read_only_helper.rb +2 -0
  45. data/rails_2_test/app/helpers/admin/bookmarks_helper.rb +2 -0
  46. data/rails_2_test/app/helpers/admin/comments2_helper.rb +2 -0
  47. data/rails_2_test/app/helpers/admin/comments_helper.rb +2 -0
  48. data/rails_2_test/app/helpers/admin/file_column_images2_helper.rb +2 -0
  49. data/rails_2_test/app/helpers/admin/file_column_images_helper.rb +2 -0
  50. data/rails_2_test/app/helpers/admin/images2_helper.rb +8 -0
  51. data/rails_2_test/app/helpers/admin/images_helper.rb +2 -0
  52. data/rails_2_test/app/helpers/admin/misconfigured1_helper.rb +2 -0
  53. data/rails_2_test/app/helpers/admin/not_migrated_yets_helper.rb +2 -0
  54. data/rails_2_test/app/helpers/admin/product_categories2_helper.rb +2 -0
  55. data/rails_2_test/app/helpers/admin/product_categories_helper.rb +2 -0
  56. data/rails_2_test/app/helpers/admin/products2_helper.rb +3 -0
  57. data/rails_2_test/app/helpers/admin/products_helper.rb +6 -0
  58. data/rails_2_test/app/helpers/admin/television_airings_helper.rb +2 -0
  59. data/rails_2_test/app/helpers/admin/television_time_slots_helper.rb +2 -0
  60. data/rails_2_test/app/helpers/admin/users2_helper.rb +2 -0
  61. data/rails_2_test/app/helpers/admin/users_helper.rb +25 -0
  62. data/rails_2_test/app/helpers/application_helper.rb +3 -0
  63. data/rails_2_test/app/helpers/blog_posts_helper.rb +2 -0
  64. data/rails_2_test/app/models/appointment.rb +5 -0
  65. data/rails_2_test/app/models/blog_post.rb +14 -0
  66. data/rails_2_test/app/models/blog_post_tag.rb +6 -0
  67. data/rails_2_test/app/models/bookmark.rb +6 -0
  68. data/rails_2_test/app/models/comment.rb +4 -0
  69. data/rails_2_test/app/models/file_column_image.rb +3 -0
  70. data/rails_2_test/app/models/image.rb +3 -0
  71. data/rails_2_test/app/models/not_migrated_yet.rb +2 -0
  72. data/rails_2_test/app/models/product.rb +7 -0
  73. data/rails_2_test/app/models/product_category.rb +9 -0
  74. data/rails_2_test/app/models/tag.rb +4 -0
  75. data/rails_2_test/app/models/television_airing.rb +3 -0
  76. data/rails_2_test/app/models/television_time_slot.rb +11 -0
  77. data/rails_2_test/app/models/user.rb +14 -0
  78. data/rails_2_test/app/views/admin/appointments/_subject_input.html.erb +2 -0
  79. data/rails_2_test/app/views/admin/appointments2/_time_input.html.erb +31 -0
  80. data/rails_2_test/app/views/admin/blog_posts2/_after_form.html.erb +5 -0
  81. data/rails_2_test/app/views/admin/blog_posts2/_after_index.html.erb +1 -0
  82. data/rails_2_test/app/views/admin/blog_posts2/_after_tags_input.html.erb +16 -0
  83. data/rails_2_test/app/views/admin/blog_posts2/_before_index.html.erb +2 -0
  84. data/rails_2_test/app/views/admin/blog_posts5/_after_index_header.html.erb +8 -0
  85. data/rails_2_test/app/views/admin/blog_posts_read_only/_body_for_show.html.erb +1 -0
  86. data/rails_2_test/app/views/admin/products/_name_input.html.erb +2 -0
  87. data/rails_2_test/app/views/admin/products/_percent_off_input.html.erb +2 -0
  88. data/rails_2_test/app/views/admin/products/_price_input.html.erb +10 -0
  89. data/rails_2_test/app/views/blog_posts/show.html.erb +13 -0
  90. data/rails_2_test/app/views/layouts/admin.html.erb +31 -0
  91. data/rails_2_test/config/boot.rb +109 -0
  92. data/rails_2_test/config/database.yml +28 -0
  93. data/rails_2_test/config/environment.rb +78 -0
  94. data/rails_2_test/config/environments/development.rb +17 -0
  95. data/rails_2_test/config/environments/production.rb +24 -0
  96. data/rails_2_test/config/environments/test.rb +24 -0
  97. data/rails_2_test/config/initializers/inflections.rb +10 -0
  98. data/rails_2_test/config/initializers/mime_types.rb +5 -0
  99. data/rails_2_test/config/initializers/new_rails_defaults.rb +17 -0
  100. data/rails_2_test/config/locales/en.yml +5 -0
  101. data/rails_2_test/config/routes.rb +43 -0
  102. data/rails_2_test/db/migrate/20090213215514_create_blog_posts.rb +12 -0
  103. data/rails_2_test/db/migrate/20090217225542_add_body_to_blog_posts.rb +9 -0
  104. data/rails_2_test/db/migrate/20090221220917_create_tags.rb +13 -0
  105. data/rails_2_test/db/migrate/20090221220947_create_blog_post_tags.rb +14 -0
  106. data/rails_2_test/db/migrate/20090222162204_add_textile_to_blog_posts.rb +9 -0
  107. data/rails_2_test/db/migrate/20090222163231_add_published_at_to_blog_posts.rb +9 -0
  108. data/rails_2_test/db/migrate/20090301191722_create_images.rb +16 -0
  109. data/rails_2_test/db/migrate/20090305165345_create_accounts.rb +14 -0
  110. data/rails_2_test/db/migrate/20090307225027_rename_accounts_to_users.rb +9 -0
  111. data/rails_2_test/db/migrate/20090307225750_add_user_id_to_blog_posts.rb +9 -0
  112. data/rails_2_test/db/migrate/20090309185114_change_blog_posts_textile.rb +9 -0
  113. data/rails_2_test/db/migrate/20090309193635_create_products.rb +14 -0
  114. data/rails_2_test/db/migrate/20090309203056_create_comments.rb +15 -0
  115. data/rails_2_test/db/migrate/20090323005947_create_file_column_images.rb +12 -0
  116. data/rails_2_test/db/migrate/20090326160049_add_birthday_to_users.rb +9 -0
  117. data/rails_2_test/db/migrate/20090326223606_add_state_to_users.rb +9 -0
  118. data/rails_2_test/db/migrate/20090503134004_add_file_column_image_to_products.rb +9 -0
  119. data/rails_2_test/db/migrate/20090617173651_create_bookmarks.rb +15 -0
  120. data/rails_2_test/db/migrate/20090624165355_add_tags_string_to_blog_post.rb +9 -0
  121. data/rails_2_test/db/migrate/20090625144313_add_avatar_fields_to_user.rb +11 -0
  122. data/rails_2_test/db/migrate/20090629202956_add_merged_into_to_blog_posts.rb +9 -0
  123. data/rails_2_test/db/migrate/20090701171857_add_force_textile_to_users.rb +9 -0
  124. data/rails_2_test/db/migrate/20090704163647_add_deleted_at_to_products.rb +9 -0
  125. data/rails_2_test/db/migrate/20090704173800_add_sale_fields_to_products.rb +13 -0
  126. data/rails_2_test/db/migrate/20090714024501_create_product_categories.rb +15 -0
  127. data/rails_2_test/db/migrate/20090819162835_add_admin_level_to_users.rb +9 -0
  128. data/rails_2_test/db/migrate/20091115134559_add_first_and_last_names_to_users.rb +11 -0
  129. data/rails_2_test/db/migrate/20091221011256_add_position_to_product_categories.rb +9 -0
  130. data/rails_2_test/db/migrate/20091222160814_create_appointments.rb +14 -0
  131. data/rails_2_test/db/migrate/20091227224547_add_user_id_to_appointments.rb +9 -0
  132. data/rails_2_test/db/migrate/20100214213359_create_television_time_slots.rb +13 -0
  133. data/rails_2_test/db/migrate/20100214213451_create_television_airings.rb +15 -0
  134. data/rails_2_test/doc/README_FOR_APP +5 -0
  135. data/rails_2_test/lib/tasks/rspec.rake +163 -0
  136. data/rails_2_test/public/404.html +30 -0
  137. data/rails_2_test/public/422.html +30 -0
  138. data/rails_2_test/public/500.html +33 -0
  139. data/rails_2_test/public/dispatch.cgi +10 -0
  140. data/rails_2_test/public/dispatch.fcgi +24 -0
  141. data/rails_2_test/public/dispatch.rb +10 -0
  142. data/rails_2_test/public/favicon.ico +0 -0
  143. data/rails_2_test/public/images/rails.png +0 -0
  144. data/rails_2_test/public/index.html +274 -0
  145. data/rails_2_test/public/javascripts/application.js +2 -0
  146. data/rails_2_test/public/javascripts/jquery-1.4.4.min.js +167 -0
  147. data/rails_2_test/public/robots.txt +5 -0
  148. data/rails_2_test/public/stylesheets/admin.css +3 -0
  149. data/rails_2_test/public/stylesheets/scaffold.css +54 -0
  150. data/rails_2_test/script/about +4 -0
  151. data/rails_2_test/script/autospec +5 -0
  152. data/rails_2_test/script/console +3 -0
  153. data/rails_2_test/script/dbconsole +3 -0
  154. data/rails_2_test/script/destroy +3 -0
  155. data/rails_2_test/script/generate +3 -0
  156. data/rails_2_test/script/performance/benchmarker +3 -0
  157. data/rails_2_test/script/performance/profiler +3 -0
  158. data/rails_2_test/script/performance/request +3 -0
  159. data/rails_2_test/script/plugin +3 -0
  160. data/rails_2_test/script/populate_tables.rb +49 -0
  161. data/rails_2_test/script/process/inspector +3 -0
  162. data/rails_2_test/script/process/reaper +3 -0
  163. data/rails_2_test/script/process/spawner +3 -0
  164. data/rails_2_test/script/runner +3 -0
  165. data/rails_2_test/script/server +3 -0
  166. data/rails_2_test/script/spec +5 -0
  167. data/rails_2_test/script/spec_server +125 -0
  168. data/rails_2_test/test/data/ruby_throated.jpg +0 -0
  169. data/rails_2_test/test/data/tweenbot.jpg +0 -0
  170. data/rails_2_test/test/fixtures/file_column_images.yml +7 -0
  171. data/rails_2_test/test/integration/admin/appointments2_integration_test.rb +79 -0
  172. data/rails_2_test/test/integration/admin/appointments_integration_test.rb +367 -0
  173. data/rails_2_test/test/integration/admin/blog_posts2_integration_test.rb +806 -0
  174. data/rails_2_test/test/integration/admin/blog_posts3_integration_test.rb +418 -0
  175. data/rails_2_test/test/integration/admin/blog_posts4_integration_test.rb +189 -0
  176. data/rails_2_test/test/integration/admin/blog_posts5_integration_test.rb +75 -0
  177. data/rails_2_test/test/integration/admin/blog_posts6_integration_test.rb +39 -0
  178. data/rails_2_test/test/integration/admin/blog_posts_custom_new_and_edit_integration_test.rb +89 -0
  179. data/rails_2_test/test/integration/admin/blog_posts_integration_test.rb +788 -0
  180. data/rails_2_test/test/integration/admin/blog_posts_read_only_integration_test.rb +69 -0
  181. data/rails_2_test/test/integration/admin/bookmarks_integration_test.rb +445 -0
  182. data/rails_2_test/test/integration/admin/comments2_integration_test.rb +52 -0
  183. data/rails_2_test/test/integration/admin/comments_integration_test.rb +50 -0
  184. data/rails_2_test/test/integration/admin/file_column_images2_integration_test.rb +19 -0
  185. data/rails_2_test/test/integration/admin/file_column_images_integration_test.rb +69 -0
  186. data/rails_2_test/test/integration/admin/images2_integration_test.rb +33 -0
  187. data/rails_2_test/test/integration/admin/images_integration_test.rb +79 -0
  188. data/rails_2_test/test/integration/admin/misconfigured1_integration_test.rb +17 -0
  189. data/rails_2_test/test/integration/admin/product_categories2_integration_test.rb +179 -0
  190. data/rails_2_test/test/integration/admin/product_categories_integration_test.rb +12 -0
  191. data/rails_2_test/test/integration/admin/products2_integration_test.rb +155 -0
  192. data/rails_2_test/test/integration/admin/products_integration_test.rb +210 -0
  193. data/rails_2_test/test/integration/admin/television_airings_integration_test.rb +25 -0
  194. data/rails_2_test/test/integration/admin/users2_integration_test.rb +48 -0
  195. data/rails_2_test/test/integration/admin/users_integration_test.rb +266 -0
  196. data/rails_2_test/test/integration/blog_posts_integration_test.rb +9 -0
  197. data/rails_2_test/test/test_helper.rb +114 -0
  198. data/rails_2_test/vendor/plugins/file_column/CHANGELOG +69 -0
  199. data/rails_2_test/vendor/plugins/file_column/README +54 -0
  200. data/rails_2_test/vendor/plugins/file_column/Rakefile +36 -0
  201. data/rails_2_test/vendor/plugins/file_column/TODO +6 -0
  202. data/rails_2_test/vendor/plugins/file_column/init.rb +13 -0
  203. data/rails_2_test/vendor/plugins/file_column/lib/file_column.rb +723 -0
  204. data/rails_2_test/vendor/plugins/file_column/lib/file_column_helper.rb +150 -0
  205. data/rails_2_test/vendor/plugins/file_column/lib/file_compat.rb +28 -0
  206. data/rails_2_test/vendor/plugins/file_column/lib/magick_file_column.rb +260 -0
  207. data/rails_2_test/vendor/plugins/file_column/lib/rails_file_column.rb +19 -0
  208. data/rails_2_test/vendor/plugins/file_column/lib/test_case.rb +124 -0
  209. data/rails_2_test/vendor/plugins/file_column/lib/validations.rb +112 -0
  210. data/rails_2_test/vendor/plugins/file_column/test/abstract_unit.rb +63 -0
  211. data/rails_2_test/vendor/plugins/file_column/test/connection.rb +17 -0
  212. data/rails_2_test/vendor/plugins/file_column/test/file_column_helper_test.rb +97 -0
  213. data/rails_2_test/vendor/plugins/file_column/test/file_column_test.rb +650 -0
  214. data/rails_2_test/vendor/plugins/file_column/test/fixtures/entry.rb +32 -0
  215. data/rails_2_test/vendor/plugins/file_column/test/fixtures/invalid-image.jpg +1 -0
  216. data/rails_2_test/vendor/plugins/file_column/test/fixtures/kerb.jpg +0 -0
  217. data/rails_2_test/vendor/plugins/file_column/test/fixtures/mysql.sql +25 -0
  218. data/rails_2_test/vendor/plugins/file_column/test/fixtures/schema.rb +10 -0
  219. data/rails_2_test/vendor/plugins/file_column/test/fixtures/skanthak.png +0 -0
  220. data/rails_2_test/vendor/plugins/file_column/test/magick_test.rb +380 -0
  221. data/rails_2_test/vendor/plugins/file_column/test/magick_view_only_test.rb +21 -0
  222. data/rails_3_test/.gitignore +4 -0
  223. data/rails_3_test/Gemfile +12 -0
  224. data/rails_3_test/Gemfile.lock +100 -0
  225. data/rails_3_test/README +256 -0
  226. data/rails_3_test/Rakefile +7 -0
  227. data/rails_3_test/app/controllers/admin/appointments2_controller.rb +15 -0
  228. data/rails_3_test/app/controllers/admin/appointments_controller.rb +11 -0
  229. data/rails_3_test/app/controllers/admin/blog_posts2_controller.rb +138 -0
  230. data/rails_3_test/app/controllers/admin/blog_posts3_controller.rb +76 -0
  231. data/rails_3_test/app/controllers/admin/blog_posts4_controller.rb +21 -0
  232. data/rails_3_test/app/controllers/admin/blog_posts5_controller.rb +27 -0
  233. data/rails_3_test/app/controllers/admin/blog_posts6_controller.rb +10 -0
  234. data/rails_3_test/app/controllers/admin/blog_posts_controller.rb +9 -0
  235. data/rails_3_test/app/controllers/admin/blog_posts_custom_new_and_edit_controller.rb +15 -0
  236. data/rails_3_test/app/controllers/admin/blog_posts_read_only_controller.rb +19 -0
  237. data/rails_3_test/app/controllers/admin/bookmarks_controller.rb +11 -0
  238. data/rails_3_test/app/controllers/admin/comments2_controller.rb +14 -0
  239. data/rails_3_test/app/controllers/admin/comments_controller.rb +12 -0
  240. data/rails_3_test/app/controllers/admin/images2_controller.rb +11 -0
  241. data/rails_3_test/app/controllers/admin/images_controller.rb +6 -0
  242. data/rails_3_test/app/controllers/admin/misconfigured1_controller.rb +7 -0
  243. data/rails_3_test/app/controllers/admin/not_migrated_yets_controller.rb +9 -0
  244. data/rails_3_test/app/controllers/admin/product_categories2_controller.rb +7 -0
  245. data/rails_3_test/app/controllers/admin/product_categories_controller.rb +5 -0
  246. data/rails_3_test/app/controllers/admin/television_airings_controller.rb +5 -0
  247. data/rails_3_test/app/controllers/admin/television_time_slots_controller.rb +5 -0
  248. data/rails_3_test/app/controllers/admin/users2_controller.rb +10 -0
  249. data/rails_3_test/app/controllers/admin/users_controller.rb +48 -0
  250. data/rails_3_test/app/controllers/application_controller.rb +7 -0
  251. data/rails_3_test/app/controllers/blog_posts_controller.rb +5 -0
  252. data/rails_3_test/app/helpers/admin/appointments_helper.rb +2 -0
  253. data/rails_3_test/app/helpers/admin/blog_posts2_helper.rb +27 -0
  254. data/rails_3_test/app/helpers/admin/blog_posts3_helper.rb +2 -0
  255. data/rails_3_test/app/helpers/admin/blog_posts4_helper.rb +2 -0
  256. data/rails_3_test/app/helpers/admin/blog_posts6_helper.rb +13 -0
  257. data/rails_3_test/app/helpers/admin/blog_posts_custom_new_and_edit_helper.rb +29 -0
  258. data/rails_3_test/app/helpers/admin/blog_posts_helper.rb +2 -0
  259. data/rails_3_test/app/helpers/admin/blog_posts_read_only_helper.rb +2 -0
  260. data/rails_3_test/app/helpers/admin/bookmarks_helper.rb +2 -0
  261. data/rails_3_test/app/helpers/admin/comments2_helper.rb +2 -0
  262. data/rails_3_test/app/helpers/admin/comments_helper.rb +2 -0
  263. data/rails_3_test/app/helpers/admin/images2_helper.rb +8 -0
  264. data/rails_3_test/app/helpers/admin/images_helper.rb +2 -0
  265. data/rails_3_test/app/helpers/admin/misconfigured1_helper.rb +2 -0
  266. data/rails_3_test/app/helpers/admin/not_migrated_yets_helper.rb +2 -0
  267. data/rails_3_test/app/helpers/admin/product_categories2_helper.rb +2 -0
  268. data/rails_3_test/app/helpers/admin/product_categories_helper.rb +2 -0
  269. data/rails_3_test/app/helpers/admin/television_airings_helper.rb +2 -0
  270. data/rails_3_test/app/helpers/admin/television_time_slots_helper.rb +2 -0
  271. data/rails_3_test/app/helpers/admin/users2_helper.rb +2 -0
  272. data/rails_3_test/app/helpers/admin/users_helper.rb +13 -0
  273. data/rails_3_test/app/helpers/application_helper.rb +2 -0
  274. data/rails_3_test/app/models/appointment.rb +5 -0
  275. data/rails_3_test/app/models/blog_post.rb +14 -0
  276. data/rails_3_test/app/models/blog_post_tag.rb +6 -0
  277. data/rails_3_test/app/models/bookmark.rb +6 -0
  278. data/rails_3_test/app/models/comment.rb +4 -0
  279. data/rails_3_test/app/models/image.rb +3 -0
  280. data/rails_3_test/app/models/not_migrated_yet.rb +2 -0
  281. data/rails_3_test/app/models/product.rb +5 -0
  282. data/rails_3_test/app/models/product_category.rb +9 -0
  283. data/rails_3_test/app/models/tag.rb +4 -0
  284. data/rails_3_test/app/models/television_airing.rb +3 -0
  285. data/rails_3_test/app/models/television_time_slot.rb +11 -0
  286. data/rails_3_test/app/models/user.rb +11 -0
  287. data/rails_3_test/app/views/admin/appointments/_subject_input.html.erb +2 -0
  288. data/rails_3_test/app/views/admin/appointments2/_time_input.html.erb +31 -0
  289. data/rails_3_test/app/views/admin/blog_posts2/_after_form.html.erb +5 -0
  290. data/rails_3_test/app/views/admin/blog_posts2/_after_index.html.erb +1 -0
  291. data/rails_3_test/app/views/admin/blog_posts2/_after_tags_input.html.erb +16 -0
  292. data/rails_3_test/app/views/admin/blog_posts2/_before_index.html.erb +2 -0
  293. data/rails_3_test/app/views/admin/blog_posts5/_after_index_header.html.erb +8 -0
  294. data/rails_3_test/app/views/admin/blog_posts_read_only/_body_for_show.html.erb +1 -0
  295. data/rails_3_test/app/views/layouts/admin.html.erb +32 -0
  296. data/rails_3_test/app/views/layouts/application.html.erb +14 -0
  297. data/rails_3_test/config/application.rb +42 -0
  298. data/rails_3_test/config/boot.rb +6 -0
  299. data/rails_3_test/config/database.yml +22 -0
  300. data/rails_3_test/config/environment.rb +5 -0
  301. data/rails_3_test/config/environments/development.rb +26 -0
  302. data/rails_3_test/config/environments/production.rb +49 -0
  303. data/rails_3_test/config/environments/test.rb +35 -0
  304. data/rails_3_test/config/initializers/backtrace_silencers.rb +7 -0
  305. data/rails_3_test/config/initializers/inflections.rb +10 -0
  306. data/rails_3_test/config/initializers/mime_types.rb +5 -0
  307. data/rails_3_test/config/initializers/secret_token.rb +7 -0
  308. data/rails_3_test/config/initializers/session_store.rb +8 -0
  309. data/rails_3_test/config/locales/en.yml +5 -0
  310. data/rails_3_test/config/routes.rb +63 -0
  311. data/rails_3_test/config.ru +4 -0
  312. data/rails_3_test/db/migrate/20090213215514_create_blog_posts.rb +12 -0
  313. data/rails_3_test/db/migrate/20090217225542_add_body_to_blog_posts.rb +9 -0
  314. data/rails_3_test/db/migrate/20090221220917_create_tags.rb +13 -0
  315. data/rails_3_test/db/migrate/20090221220947_create_blog_post_tags.rb +14 -0
  316. data/rails_3_test/db/migrate/20090222162204_add_textile_to_blog_posts.rb +9 -0
  317. data/rails_3_test/db/migrate/20090222163231_add_published_at_to_blog_posts.rb +9 -0
  318. data/rails_3_test/db/migrate/20090301191722_create_images.rb +16 -0
  319. data/rails_3_test/db/migrate/20090305165345_create_accounts.rb +14 -0
  320. data/rails_3_test/db/migrate/20090307225027_rename_accounts_to_users.rb +9 -0
  321. data/rails_3_test/db/migrate/20090307225750_add_user_id_to_blog_posts.rb +9 -0
  322. data/rails_3_test/db/migrate/20090309185114_change_blog_posts_textile.rb +9 -0
  323. data/rails_3_test/db/migrate/20090309193635_create_products.rb +14 -0
  324. data/rails_3_test/db/migrate/20090309203056_create_comments.rb +15 -0
  325. data/rails_3_test/db/migrate/20090323005947_create_file_column_images.rb +12 -0
  326. data/rails_3_test/db/migrate/20090326160049_add_birthday_to_users.rb +9 -0
  327. data/rails_3_test/db/migrate/20090326223606_add_state_to_users.rb +9 -0
  328. data/rails_3_test/db/migrate/20090503134004_add_file_column_image_to_products.rb +9 -0
  329. data/rails_3_test/db/migrate/20090617173651_create_bookmarks.rb +15 -0
  330. data/rails_3_test/db/migrate/20090624165355_add_tags_string_to_blog_post.rb +9 -0
  331. data/rails_3_test/db/migrate/20090625144313_add_avatar_fields_to_user.rb +11 -0
  332. data/rails_3_test/db/migrate/20090629202956_add_merged_into_to_blog_posts.rb +9 -0
  333. data/rails_3_test/db/migrate/20090701171857_add_force_textile_to_users.rb +9 -0
  334. data/rails_3_test/db/migrate/20090704163647_add_deleted_at_to_products.rb +9 -0
  335. data/rails_3_test/db/migrate/20090704173800_add_sale_fields_to_products.rb +13 -0
  336. data/rails_3_test/db/migrate/20090714024501_create_product_categories.rb +15 -0
  337. data/rails_3_test/db/migrate/20090819162835_add_admin_level_to_users.rb +9 -0
  338. data/rails_3_test/db/migrate/20091115134559_add_first_and_last_names_to_users.rb +11 -0
  339. data/rails_3_test/db/migrate/20091221011256_add_position_to_product_categories.rb +9 -0
  340. data/rails_3_test/db/migrate/20091222160814_create_appointments.rb +14 -0
  341. data/rails_3_test/db/migrate/20091227224547_add_user_id_to_appointments.rb +9 -0
  342. data/rails_3_test/db/migrate/20100214213359_create_television_time_slots.rb +13 -0
  343. data/rails_3_test/db/migrate/20100214213451_create_television_airings.rb +15 -0
  344. data/rails_3_test/db/migrate/20110426215702_remove_avatar_fields_from_users.rb +11 -0
  345. data/rails_3_test/db/seeds.rb +7 -0
  346. data/rails_3_test/doc/README_FOR_APP +2 -0
  347. data/rails_3_test/lib/tasks/.gitkeep +0 -0
  348. data/rails_3_test/public/404.html +26 -0
  349. data/rails_3_test/public/422.html +26 -0
  350. data/rails_3_test/public/500.html +26 -0
  351. data/rails_3_test/public/favicon.ico +0 -0
  352. data/rails_3_test/public/images/rails.png +0 -0
  353. data/rails_3_test/public/index.html +239 -0
  354. data/rails_3_test/public/javascripts/application.js +2 -0
  355. data/rails_3_test/public/javascripts/jquery-1.4.4.min.js +167 -0
  356. data/rails_3_test/public/javascripts/rails.js +191 -0
  357. data/rails_3_test/public/robots.txt +5 -0
  358. data/rails_3_test/public/stylesheets/.gitkeep +0 -0
  359. data/rails_3_test/public/stylesheets/admin.css +3 -0
  360. data/rails_3_test/public/stylesheets/scaffold.css +54 -0
  361. data/rails_3_test/script/rails +6 -0
  362. data/rails_3_test/test/data/ruby_throated.jpg +0 -0
  363. data/rails_3_test/test/data/tweenbot.jpg +0 -0
  364. data/rails_3_test/test/fixtures/placeholder.txt +0 -0
  365. data/rails_3_test/test/integration/admin/appointments2_integration_test.rb +79 -0
  366. data/rails_3_test/test/integration/admin/appointments_integration_test.rb +367 -0
  367. data/rails_3_test/test/integration/admin/blog_posts2_integration_test.rb +789 -0
  368. data/rails_3_test/test/integration/admin/blog_posts3_integration_test.rb +418 -0
  369. data/rails_3_test/test/integration/admin/blog_posts4_integration_test.rb +189 -0
  370. data/rails_3_test/test/integration/admin/blog_posts5_integration_test.rb +75 -0
  371. data/rails_3_test/test/integration/admin/blog_posts6_integration_test.rb +39 -0
  372. data/rails_3_test/test/integration/admin/blog_posts_custom_new_and_edit_integration_test.rb +89 -0
  373. data/rails_3_test/test/integration/admin/blog_posts_integration_test.rb +784 -0
  374. data/rails_3_test/test/integration/admin/blog_posts_read_only_integration_test.rb +69 -0
  375. data/rails_3_test/test/integration/admin/bookmarks_integration_test.rb +445 -0
  376. data/rails_3_test/test/integration/admin/comments2_integration_test.rb +52 -0
  377. data/rails_3_test/test/integration/admin/comments_integration_test.rb +50 -0
  378. data/rails_3_test/test/integration/admin/images2_integration_test.rb +33 -0
  379. data/rails_3_test/test/integration/admin/images_integration_test.rb +79 -0
  380. data/rails_3_test/test/integration/admin/misconfigured1_integration_test.rb +21 -0
  381. data/rails_3_test/test/integration/admin/product_categories2_integration_test.rb +179 -0
  382. data/rails_3_test/test/integration/admin/product_categories_integration_test.rb +12 -0
  383. data/rails_3_test/test/integration/admin/television_airings_integration_test.rb +25 -0
  384. data/rails_3_test/test/integration/admin/users2_integration_test.rb +48 -0
  385. data/rails_3_test/test/integration/admin/users_integration_test.rb +182 -0
  386. data/rails_3_test/test/integration/blog_posts_integration_test.rb +10 -0
  387. data/rails_3_test/test/performance/browsing_test.rb +9 -0
  388. data/rails_3_test/test/test_helper.rb +98 -0
  389. data/rails_3_test/vendor/plugins/.gitkeep +0 -0
  390. data/website/_layouts/api.html +20 -17
  391. data/website/_layouts/api1.html +42 -0
  392. data/website/_layouts/default.html +42 -18
  393. data/website/api/core.markdown +6 -3
  394. data/website/api/destroy.markdown +4 -2
  395. data/website/api/form.markdown +6 -5
  396. data/website/api/idx.markdown +8 -7
  397. data/website/api/index.markdown +9 -7
  398. data/website/api/search.markdown +5 -3
  399. data/website/api/show.markdown +4 -2
  400. data/website/community.markdown +3 -2
  401. data/website/css/main.css +83 -17
  402. data/website/design_principles.markdown +3 -8
  403. data/website/index.markdown +13 -9
  404. data/website/js/lightbox.js +2 -2
  405. data/website/quick_start.markdown +10 -10
  406. data/website/screenshots.markdown +11 -11
  407. data/website/tutorial.markdown +23 -14
  408. data/website/v1/api/core.markdown +108 -0
  409. data/website/v1/api/destroy.markdown +27 -0
  410. data/website/v1/api/form.markdown +293 -0
  411. data/website/v1/api/idx.markdown +288 -0
  412. data/website/v1/api/index.markdown +149 -0
  413. data/website/v1/api/search.markdown +110 -0
  414. data/website/v1/api/show.markdown +24 -0
  415. data/website/v1/index.markdown +10 -0
  416. data/website/v1/quick_start.markdown +48 -0
  417. data/website/v1/tutorial.markdown +60 -0
  418. metadata +407 -9
@@ -0,0 +1,418 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
2
+
3
+ class Admin::BlogPosts3IntegrationTest < ActionController::IntegrationTest
4
+ def setup
5
+ User.destroy_all
6
+ @user = User.create! :username => 'soren', :password => 'password'
7
+ end
8
+
9
+ def test_create_with_no_title
10
+ @orig_blog_post_count = BlogPost.count
11
+ post "/admin/blog_posts3/create", :blog_post => {:user_id => @user.id}
12
+
13
+ # should redirect to the index
14
+ assert_redirected_to(:action => 'index')
15
+
16
+ # should create a new blog post with the title pre-filled as (draft)
17
+ assert_equal(@orig_blog_post_count + 1, BlogPost.count)
18
+ blog_post = BlogPost.last
19
+ assert_equal('(draft)', blog_post.title)
20
+ end
21
+
22
+ def test_edit
23
+ @blog_post = BlogPost.create! :title => random_word, :user => @user
24
+ get "/admin/blog_posts3/edit/#{@blog_post.id}"
25
+
26
+ # should have a body field
27
+ assert_select('textarea[name=?]', 'blog_post[body]')
28
+
29
+ # should not include textile
30
+ assert_no_match(/textile/, response.body)
31
+ end
32
+
33
+ def test_index_with_no_blog_posts
34
+ BlogPost.destroy_all
35
+ get "/admin/blog_posts3"
36
+ assert_response :success
37
+
38
+ # should use the activescaffold-themed CSS
39
+ assert_select(
40
+ 'link[href^=/stylesheets/admin_assistant/activescaffold.css]'
41
+ )
42
+
43
+ # should say 'Posts'
44
+ assert_select('h2', :text => 'Posts')
45
+ end
46
+
47
+ def test_index_with_one_unpublished_blog_post
48
+ BlogPost.destroy_all
49
+ @blog_post = BlogPost.create!(
50
+ :title => "unpublished blog post", :user => @user,
51
+ :published_at => nil
52
+ )
53
+ $cache.flush
54
+ get "/admin/blog_posts3"
55
+
56
+ # should show the blog post
57
+ assert_match(/unpublished blog post/, response.body)
58
+
59
+ # should show 'No' from having called BlogPost#published?
60
+ assert_select("tr[id=blog_post_#{@blog_post.id}]") do
61
+ assert_select "td", :text => 'No'
62
+ end
63
+
64
+ # should not have a comparator for the ID search field
65
+ assert_select('form[id=search_form][method=get]') do
66
+ assert_select("select[name=?]", "search[id(comparator)]", false)
67
+ end
68
+
69
+ # should have a blank checkbox for the body search field
70
+ assert_select('form[id=search_form][method=get]') do
71
+ assert_select("input[type=checkbox][name=?]", "search[body(blank)]")
72
+ end
73
+
74
+ # should render extra action links in order
75
+ assert_match(/Short title.*Blank body/m, response.body)
76
+
77
+ # should have a trinary select for the has_short_title search field
78
+ assert_select('form[id=search_form][method=get]') do
79
+ assert_select('select[name=?]', 'search[has_short_title]') do
80
+ assert_select("option[value='']", :text => '')
81
+ assert_select("option[value='true']", :text => 'Yes')
82
+ assert_select("option[value='false']", :text => 'No')
83
+ end
84
+ end
85
+
86
+ # should show a search form with specific fields
87
+ assert_select(
88
+ 'form[id=search_form][method=get]', :text => /Title/
89
+ ) do
90
+ assert_select('input[name=?]', 'search[title]')
91
+ assert_select('input[name=?]', 'search[body]')
92
+ assert_select('select[name=?]', 'search[textile]') do
93
+ assert_select("option[value='']", :text => '')
94
+ assert_select("option[value='true']", :text => 'true')
95
+ assert_select("option[value='false']", :text => 'false')
96
+ end
97
+ assert_select('label', :text => 'User')
98
+ assert_select('input[name=?]', 'search[user]')
99
+ end
100
+
101
+ # should set the count in memcache
102
+ key =
103
+ "AdminAssistant::Admin::BlogPosts3Controller_count_published_at_is_null_"
104
+ assert_equal(1, $cache.read(key))
105
+ assert_in_delta(12.hours, $cache.expires_in(key), 5.seconds)
106
+
107
+ # should not make the textile field an Ajax toggle
108
+ toggle_div_id = "blog_post_#{@blog_post.id}_textile"
109
+ assert_no_match(%r|new Ajax.Updater\('#{toggle_div_id}'|, response.body)
110
+ end
111
+
112
+ def test_index_with_a_published_blog_post
113
+ $cache.flush
114
+ BlogPost.destroy_all
115
+ BlogPost.create!(
116
+ :title => "published blog post", :user => @user,
117
+ :published_at => Time.now.utc
118
+ )
119
+ get "/admin/blog_posts3"
120
+
121
+ # should not show the blog post
122
+ assert_no_match(/published blog post/, response.body)
123
+ assert_match(/No posts found/, response.body)
124
+ end
125
+
126
+ def test_index_when_searching_by_user
127
+ User.destroy_all
128
+ tiffany = User.create!(:username => 'tiffany')
129
+ BlogPost.create! :title => "By Tiffany", :user => tiffany
130
+ BlogPost.create!(
131
+ :title => "Already published", :user => tiffany,
132
+ :published_at => Time.now
133
+ )
134
+ bill = User.create! :username => 'bill', :password => 'parsimony'
135
+ BlogPost.create! :title => "By Bill", :user => bill
136
+ brooklyn_steve = User.create!(
137
+ :username => 'brooklyn_steve', :state => 'NY'
138
+ )
139
+ BlogPost.create! :title => "By Brooklyn Steve", :user => brooklyn_steve
140
+ sadie = User.create!(
141
+ :username => 'Sadie', :password => 'sadie', :state => 'KY'
142
+ )
143
+ BlogPost.create! :title => "By Sadie", :user => sadie
144
+ get(
145
+ "/admin/blog_posts3",
146
+ :search => {
147
+ :body => "", :textile => "", :id => "", :user => 'ny',
148
+ :has_short_title => ''
149
+ }
150
+ )
151
+ assert_response :success
152
+
153
+ # should match the string to the username
154
+ assert_match(/By Tiffany/, response.body)
155
+
156
+ # should match the string to the password
157
+ assert_match(/By Bill/, response.body)
158
+
159
+ # should match the string to the state
160
+ assert_match(/By Brooklyn Steve/, response.body)
161
+
162
+ # should skip blog posts that don't match anything on the user
163
+ assert_no_match(/By Sadie/, response.body)
164
+
165
+ # should skip blog posts that have already been published
166
+ assert_no_match(/Already published/, response.body)
167
+ end
168
+
169
+ def test_index_with_blog_posts_from_two_different_users
170
+ aardvark_man = User.create!(:username => 'aardvark_man')
171
+ BlogPost.create! :title => 'AARDVARKS!!!!!1', :user => aardvark_man
172
+ ziggurat = User.create!(:username => 'zigguratz')
173
+ BlogPost.create! :title => "Wanna go climbing?", :user => ziggurat
174
+ get "/admin/blog_posts3"
175
+ assert_response :success
176
+
177
+ # should sort by username
178
+ assert_match(%r|AARDVARKS!!!!!1.*Wanna go climbing|m, response.body)
179
+ end
180
+
181
+ def test_index_when_searching_for_a_blank_body
182
+ BlogPost.destroy_all
183
+ @nil_body_post = BlogPost.create!(
184
+ :title => "nil", :user => @user, :body => nil
185
+ )
186
+ @empty_string_body_post = BlogPost.create!(
187
+ :title => "empty string", :user => @user, :body => ''
188
+ )
189
+ @non_blank_body_post = BlogPost.create!(
190
+ :title => "non-blank", :user => @user, :body => 'foo'
191
+ )
192
+ get(
193
+ "/admin/blog_posts3",
194
+ :search => {
195
+ "body(blank)" => '1', :user => '', :body => '', :title => '',
196
+ :textile => '', :id => '', '(all_or_any)' => 'all',
197
+ :has_short_title => ''
198
+ }
199
+ )
200
+
201
+ # should retrieve a blog post with a nil body
202
+ assert_select("tr[id=?]", "blog_post_#{@nil_body_post.id}")
203
+
204
+ # should retrieve a blog post with a space-only string body
205
+ assert_select(
206
+ "tr[id=?]", "blog_post_#{@empty_string_body_post.id}"
207
+ )
208
+
209
+ # should not retrieve a blog post with a non-blank body
210
+ assert_select(
211
+ "tr[id=?]", "blog_post_#{@non_blank_body_post.id}", false
212
+ )
213
+
214
+ # should have a checked blank checkbox for the body search field
215
+ assert_select('form[id=search_form][method=get]') do
216
+ assert_select(
217
+ "input[type=checkbox][checked=checked][name=?]",
218
+ "search[body(blank)]"
219
+ )
220
+ end
221
+ end
222
+
223
+ def test_index_when_searching_for_short_title_blog_posts
224
+ BlogPost.destroy_all
225
+ @bp1 = BlogPost.create!(
226
+ :title => 'short', :body => 'foobar', :user => @user
227
+ )
228
+ @bp2 = BlogPost.create!(
229
+ :title => "longer title", :body => 'foobar', :user => @user
230
+ )
231
+ get(
232
+ "/admin/blog_posts3",
233
+ :search => {
234
+ :body => "", "body(blank)" => '0', :textile => "", :id => "",
235
+ :user => '', :has_short_title => 'true'
236
+ }
237
+ )
238
+
239
+ # should return a short-titled blog post
240
+ assert_select('td', :text => 'short')
241
+
242
+ # should not return a longer-title blog post
243
+ assert_no_match(%r|<td[^>]*>longer title</td>|, response.body)
244
+
245
+ # should pre-select 'true' in the has_short_title search field
246
+ assert_select('form[id=search_form][method=get]') do
247
+ assert_select('select[name=?]', 'search[has_short_title]') do
248
+ assert_select("option[value='']", :text => '')
249
+ assert_select("option[value='true'][selected=selected]", :text => 'Yes')
250
+ assert_select("option[value='false']", :text => 'No')
251
+ end
252
+ end
253
+ end
254
+
255
+ def test_index_when_searching_for_long_titled_blog_posts
256
+ BlogPost.destroy_all
257
+ @bp1 = BlogPost.create!(
258
+ :title => 'short', :body => 'foobar', :user => @user
259
+ )
260
+ @bp2 = BlogPost.create!(
261
+ :title => "longer title", :body => 'foobar', :user => @user
262
+ )
263
+ get(
264
+ "/admin/blog_posts3",
265
+ :search => {
266
+ :body => "", "body(blank)" => '0', :textile => "", :id => "",
267
+ :user => '', :has_short_title => 'false'
268
+ }
269
+ )
270
+
271
+ # should not return a short-titled blog post
272
+ assert_no_match(%r|<td[^>]*>short</td>|, response.body)
273
+
274
+ # should return a longer-title blog post
275
+ assert_select('td', :text => 'longer title')
276
+
277
+ # should pre-select 'false' in the has_short_title search field
278
+ assert_select('form[id=search_form][method=get]') do
279
+ assert_select('select[name=?]', 'search[has_short_title]') do
280
+ assert_select("option[value='']", :text => '')
281
+ assert_select("option[value='true']", :text => 'Yes')
282
+ assert_select("option[value='false'][selected=selected]", :text => 'No')
283
+ end
284
+ end
285
+ end
286
+
287
+ def test_index_when_searching_for_blog_posts_of_any_title_length
288
+ BlogPost.destroy_all
289
+ @bp1 = BlogPost.create!(
290
+ :title => 'short', :body => 'foobar', :user => @user
291
+ )
292
+ @bp2 = BlogPost.create!(
293
+ :title => "longer title", :body => 'foobar', :user => @user
294
+ )
295
+ get(
296
+ "/admin/blog_posts3",
297
+ :search => {
298
+ :body => 'foobar', "body(blank)" => '0', :textile => "", :id => "",
299
+ :user => '', :has_short_title => ''
300
+ }
301
+ )
302
+
303
+ # should return a short-titled blog post
304
+ assert_select('td', :text => 'short')
305
+
306
+ # should return a longer-title blog post
307
+ assert_select('td', :text => 'longer title')
308
+ end
309
+
310
+ def test_index_when_searching_by_id
311
+ BlogPost.destroy_all
312
+ @blog_post1 = BlogPost.create! :title => random_word, :user => @user
313
+ blog_post2 = BlogPost.create! :title => random_word, :user => @user
314
+ BlogPost.update_all(
315
+ "id = #{@blog_post1.id * 10}", "id = #{blog_post2.id}"
316
+ )
317
+ @blog_post2 = BlogPost.find(@blog_post1.id * 10)
318
+ get(
319
+ "/admin/blog_posts3",
320
+ :search => {
321
+ :body => '', "body(blank)" => '0', :textile => "",
322
+ :id => @blog_post1.id.to_s, :user => '', :has_short_title => ''
323
+ }
324
+ )
325
+
326
+ # should match the record with that ID
327
+ assert_select("tr[id=?]", "blog_post_#{@blog_post1.id}")
328
+
329
+ # should not match a record with an ID that has the ID as a substring
330
+ assert_select("tr[id=?]", "blog_post_#{@blog_post2.id}", false)
331
+ end
332
+
333
+ def test_index_when_the_blank_body_count_has_been_cached_in_memcache_but_the_request_is_looking_for_the_default_index
334
+ $cache.flush
335
+ another_key =
336
+ "AdminAssistant::Admin::BlogPosts3Controller_count__body_is_null_or_body______"
337
+ $cache.write another_key, 1_000_000, :expires_in => 12.hours
338
+ get "/admin/blog_posts3"
339
+
340
+ # should not read a value from memcache
341
+ assert_no_match(/1000000 posts found/, response.body)
342
+
343
+ # should set the count in memcache
344
+ key =
345
+ "AdminAssistant::Admin::BlogPosts3Controller_count_published_at_is_null_"
346
+ assert $cache.read(key)
347
+ assert_in_delta(12.hours, $cache.expires_in(key), 5.seconds)
348
+ end
349
+
350
+ def test_index_when_the_count_has_been_cached_in_memcache
351
+ BlogPost.create!(:title => "title", :user => @user)
352
+ key =
353
+ "AdminAssistant::Admin::BlogPosts3Controller_count_published_at_is_null_"
354
+ $cache.write key, 1_000_000, :expires_in => 12.hours
355
+ $cache.raise_on_write
356
+ get "/admin/blog_posts3"
357
+
358
+ # should read memcache and not hit the database
359
+ assert_match(/1000000 posts found/, response.body)
360
+ end
361
+
362
+ def test_index_with_more_than_one_pages_worth_of_unpublished_blog_posts
363
+ $cache.flush
364
+ BlogPost.destroy_all
365
+ 1.upto(26) do |i|
366
+ BlogPost.create!(
367
+ :title => "unpublished blog post #{i}", :user => @user,
368
+ :published_at => nil
369
+ )
370
+ end
371
+ @unpub_count = BlogPost.count "published_at is null"
372
+ $cache.flush
373
+ get "/admin/blog_posts3"
374
+
375
+ # should cache the total number of entries, not the entries on just this page
376
+ key =
377
+ "AdminAssistant::Admin::BlogPosts3Controller_count_published_at_is_null_"
378
+ assert_equal(@unpub_count, $cache.read(key))
379
+ assert_in_delta(12.hours, $cache.expires_in(key), 5.seconds)
380
+ end
381
+
382
+ def test_new
383
+ @request_time = Time.now.utc
384
+ get "/admin/blog_posts3/new"
385
+
386
+ # should not have a body field
387
+ assert_select('textarea[name=?]', 'blog_post[body]', false)
388
+
389
+ # should have a published_at select that starts in the year 2009
390
+ name = 'blog_post[published_at(1i)]'
391
+ assert_select('select[name=?]', name) do
392
+ assert_select "option[value='2009']"
393
+ assert_select "option[value='2010']"
394
+ assert_select "option[value='2008']", false
395
+ end
396
+
397
+ # should have a published_at select that is set to now
398
+ name = 'blog_post[published_at(3i)]'
399
+ assert_select('select[name=?]', name) do
400
+ assert_select "option[value=?][selected=selected]", @request_time.day
401
+ end
402
+
403
+ # should not show a nullify link for published_at
404
+ assert_no_match(%r|<a [^>]*>Set "published at" to nil</a>|, response.body)
405
+
406
+ # should say 'New post'
407
+ assert_select('h2', :text => 'New post')
408
+ end
409
+
410
+ def test_show
411
+ @blog_post = BlogPost.create! :title => "title", :user => @user
412
+ get "/admin/blog_posts3/show/#{@blog_post.id}"
413
+ assert_response :success
414
+
415
+ # should say 'Post [ID]'
416
+ assert_select('h2', :text => "Post #{@blog_post.id}")
417
+ end
418
+ end
@@ -0,0 +1,189 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
2
+
3
+ class Admin::BlogPosts4IntegrationTest < ActionController::IntegrationTest
4
+ def setup
5
+ User.destroy_all
6
+ @user = User.create! :username => 'soren'
7
+ end
8
+
9
+ def test_index
10
+ BlogPost.create!(
11
+ :published_at => Time.utc(2009, 9, 1, 12, 30, 0), :user => @user,
12
+ :title => 'whatever'
13
+ )
14
+ get "/admin/blog_posts4"
15
+ assert_response :success
16
+
17
+ # should show datetime stuff in the search form for published_at
18
+ assert_select(
19
+ 'form[id=search_form][method=get]', :text => /Title/
20
+ ) do
21
+ assert_select('select[name=?]', 'search[published_at(comparator)]') do
22
+ assert_select("option[value=?]", ">", :text => 'greater than')
23
+ assert_select("option[value=?]", "<", :text => 'less than')
24
+ end
25
+ nums_and_dt_fields = {
26
+ 1 => :year, 2 => :month, 3 => :day, 4 => :hour, 5 => :min
27
+ }
28
+ nums_and_dt_fields.each do |num, dt_field|
29
+ name = "search[published_at(#{num}i)]"
30
+ value_for_now_option = Time.now.send(dt_field).to_s
31
+ if [:hour, :min].include?(dt_field) && value_for_now_option.size == 1
32
+ value_for_now_option = "0#{value_for_now_option}"
33
+ end
34
+ assert_select('select[name=?]', name) do
35
+ assert_select "option[value='']"
36
+ assert_select "option[value=?]", value_for_now_option
37
+ end
38
+ end
39
+ assert_select(
40
+ "a.clear_datetime_select[data-prefix=search_published_at]",
41
+ :text => 'Clear'
42
+ )
43
+ end
44
+
45
+ # should use strftime_format for displaying published_at
46
+ assert_select('td', :text => "Sep 01, 2009 12:30:00")
47
+ end
48
+
49
+ def test_index_when_searching_by_published_at_with_a_greater_than_comparator
50
+ @jun_blog_post = BlogPost.create!(
51
+ :published_at => Time.utc(2009,6,1), :title => 'June', :user => @user
52
+ )
53
+ @aug_blog_post = BlogPost.create!(
54
+ :published_at => Time.utc(2009,8,1), :title => 'August', :user => @user
55
+ )
56
+ get(
57
+ "/admin/blog_posts4",
58
+ :search => {
59
+ :textile => '', :title => '', :user_id => '',
60
+ 'published_at(comparator)' => '>',
61
+ 'published_at(1i)' => '2009', 'published_at(2i)' => '7',
62
+ 'published_at(3i)' => '1', 'published_at(4i)' => '1',
63
+ 'published_at(5i)' => '1'
64
+ }
65
+ )
66
+ assert_response :success
67
+
68
+ # should include a blog post with a published_at time after the entered time
69
+ assert_select('td', :text => 'August')
70
+
71
+ # should not include a blog post with a published_at time before the entered time
72
+ assert_no_match(%r|<td[^>]*>June</td>|, response.body)
73
+
74
+ # should show the right fields pre-filled in the search form
75
+ assert_select(
76
+ 'form[id=search_form][method=get]', :text => /Title/
77
+ ) do
78
+ assert_select('select[name=?]', 'search[published_at(comparator)]') do
79
+ assert_select(
80
+ "option[value=?][selected=selected]", ">", :text => 'greater than'
81
+ )
82
+ assert_select("option[value=?]", "<", :text => 'less than')
83
+ end
84
+ assert_select('select[name=?]', 'search[published_at(1i)]') do
85
+ assert_select "option[value=?][selected=selected]", "2009"
86
+ end
87
+ assert_select('select[name=?]', 'search[published_at(2i)]') do
88
+ assert_select "option[value=?][selected=selected]", "7"
89
+ end
90
+ assert_select('select[name=?]', 'search[published_at(3i)]') do
91
+ assert_select "option[value=?][selected=selected]", "1"
92
+ end
93
+ assert_select('select[name=?]', 'search[published_at(4i)]') do
94
+ assert_select "option[value=?][selected=selected]", "01"
95
+ end
96
+ assert_select('select[name=?]', 'search[published_at(5i)]') do
97
+ assert_select "option[value=?][selected=selected]", "01"
98
+ end
99
+ end
100
+ end
101
+
102
+ def test_index_when_searching_by_published_at_with_a_less_than_comparator
103
+ @jun_blog_post = BlogPost.create!(
104
+ :published_at => Time.utc(2009,6,1), :title => 'June', :user => @user
105
+ )
106
+ @aug_blog_post = BlogPost.create!(
107
+ :published_at => Time.utc(2009,8,1), :title => 'August', :user => @user
108
+ )
109
+ get(
110
+ "/admin/blog_posts4",
111
+ :search => {
112
+ :textile => '', :title => '', :user_id => '',
113
+ 'published_at(comparator)' => '<',
114
+ 'published_at(1i)' => '2009', 'published_at(2i)' => '7',
115
+ 'published_at(3i)' => '1', 'published_at(4i)' => '1',
116
+ 'published_at(5i)' => '1'
117
+ }
118
+ )
119
+ assert_response :success
120
+
121
+ # should not include a blog post with a published_at time after the entered time
122
+ assert_no_match(%r|<td[^>]*>August</td>|, response.body)
123
+
124
+ # should include a blog post with a published_at time before the entered time
125
+ assert_select('td', :text => 'June')
126
+
127
+ # should show the right fields pre-filled in the search form
128
+ assert_select(
129
+ 'form[id=search_form][method=get]', :text => /Title/
130
+ ) do
131
+ assert_select('select[name=?]', 'search[published_at(comparator)]') do
132
+ assert_select "option[value=?]", ">", :text => 'greater than'
133
+ assert_select(
134
+ "option[value=?][selected=selected]", "<", :text => 'less than'
135
+ )
136
+ end
137
+ assert_select('select[name=?]', 'search[published_at(1i)]') do
138
+ assert_select "option[value=?][selected=selected]", "2009"
139
+ end
140
+ assert_select('select[name=?]', 'search[published_at(2i)]') do
141
+ assert_select "option[value=?][selected=selected]", "7"
142
+ end
143
+ assert_select('select[name=?]', 'search[published_at(3i)]') do
144
+ assert_select "option[value=?][selected=selected]", "1"
145
+ end
146
+ assert_select('select[name=?]', 'search[published_at(4i)]') do
147
+ assert_select "option[value=?][selected=selected]", "01"
148
+ end
149
+ assert_select('select[name=?]', 'search[published_at(5i)]') do
150
+ assert_select "option[value=?][selected=selected]", "01"
151
+ end
152
+ end
153
+ end
154
+
155
+ def test_index_with_26_unpublished_blog_posts
156
+ BlogPost.destroy_all
157
+ 1.upto(26) do |i|
158
+ BlogPost.create!(
159
+ :title => "--post #{i}--", :user => @user, :published_at => nil
160
+ )
161
+ end
162
+ get "/admin/blog_posts4"
163
+
164
+ # should not show link to page 2
165
+ assert_select("a[href=/admin/blog_posts4?page=2]", false)
166
+
167
+ # should only say 25 blog posts found
168
+ assert_match(/25 blog posts found/, response.body)
169
+ end
170
+
171
+ def test_new
172
+ get "/admin/blog_posts4/new"
173
+
174
+ # should use a textarea for virtual_text
175
+ assert_select("textarea[name=?]", "blog_post[virtual_text]")
176
+ end
177
+
178
+ def test_show
179
+ @blog_post = BlogPost.create!(
180
+ :published_at => Time.utc(2009, 9, 1, 12, 30, 0), :user => @user,
181
+ :title => 'whatever'
182
+ )
183
+ get "/admin/blog_posts4/show/#{@blog_post.id}"
184
+ assert_response :success
185
+
186
+ # should use strftime_format for displaying published_at
187
+ assert_match(/Sep 01, 2009 12:30:00/, response.body)
188
+ end
189
+ end
@@ -0,0 +1,75 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
2
+
3
+ class Admin::BlogPosts5IntegrationTest < ActionController::IntegrationTest
4
+ def setup
5
+ User.destroy_all
6
+ @soren = User.create! :username => 'soren'
7
+ @jean = User.create! :username => 'jean'
8
+ end
9
+
10
+ def test_create_with_title_alt
11
+ post(
12
+ "/admin/blog_posts5/create",
13
+ :blog_post => {
14
+ :user_id => @soren.id, :title => '', :title_alt => 'alternate field'
15
+ }
16
+ )
17
+ assert_response :redirect
18
+
19
+ # should use the value of title alt for the title
20
+ bp = BlogPost.last
21
+ assert_equal('alternate field', bp.title)
22
+ end
23
+
24
+ def test_index
25
+ BlogPost.create!(
26
+ :published_at => Time.utc(2009, 9, 1, 12, 30, 0), :user => @soren,
27
+ :title => 'whatever'
28
+ )
29
+ BlogPost.create!(
30
+ :published_at => Time.utc(2009, 9, 1, 12, 30, 0), :user => @soren,
31
+ :title => 'just do it'
32
+ )
33
+ get "/admin/blog_posts5"
34
+ assert_response :success
35
+
36
+ # should render the filter.html.erb partial
37
+ assert_select('ul.aa_filter')
38
+ assert_select('ul.aa_filter li a', :text => "soren")
39
+ assert_select('td', :text => "whatever")
40
+ assert_select('td', :text => "just do it")
41
+ end
42
+
43
+ def test_index_filter
44
+ BlogPost.create!(
45
+ :published_at => Time.utc(2009, 9, 1, 12, 30, 0), :user => @soren,
46
+ :title => 'whatever'
47
+ )
48
+ BlogPost.create!(
49
+ :published_at => Time.utc(2009, 9, 1, 12, 30, 0), :user => @soren,
50
+ :title => 'whatever'
51
+ )
52
+
53
+ get "/admin/blog_posts5?filter=#{@soren.id}"
54
+ assert_response :success
55
+
56
+ # should filter blog posts by user id
57
+ assert_select('td', :text => "whatever")
58
+ assert_no_match(%r|<td[^>]*>just do it</td>|, response.body)
59
+ end
60
+
61
+ def test_search_retains_filter
62
+ user1 = User.find_or_create_by_username 'friedrich'
63
+ user2 = User.find_or_create_by_username 'rene'
64
+
65
+ BlogPost.create! :title => "God is dead", :user => user1
66
+ blog_post2 = BlogPost.create! :title => "I think therefore I am", :user => user2
67
+
68
+ visit "/admin/blog_posts5"
69
+ click_link "friedrich"
70
+ fill_in "search", :with => 'I think therefore I am'
71
+ click_button 'Search'
72
+
73
+ assert_select 'a[href=?]', "/admin/blog_posts5/edit/#{blog_post2.id}", false
74
+ end
75
+ end