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,789 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/../../test_helper")
2
+
3
+ class Admin::BlogPosts2IntegrationTest < ActionController::IntegrationTest
4
+ def setup
5
+ User.destroy_all
6
+ @user = User.find_or_create_by_username 'soren'
7
+ end
8
+
9
+ def create_foobar_blog_posts
10
+ BlogPost.destroy_all
11
+ BlogPost.create!(
12
+ :title => 'textile_false_foobar', :textile => false, :user => @user
13
+ )
14
+ BlogPost.create!(
15
+ :title => 'textile_true_foobar', :textile => true, :user => @user
16
+ )
17
+ BlogPost.create!(
18
+ :title => 'not_in_the_title', :textile => false,
19
+ :body => 'foobar here though', :user => @user
20
+ )
21
+ BlogPost.create!(
22
+ :title => 'textile is false', :textile => false,
23
+ :body => "body doesn't say f**bar", :user => @user
24
+ )
25
+ BlogPost.create!(
26
+ :title => 'already published', :textile => false,
27
+ :body => "body doesn't say f**bar", :user => @user,
28
+ :published_at => Time.now.utc
29
+ )
30
+ end
31
+
32
+ def test_comes_back_to_index_sorted_by_published_at_after_preview_then_create
33
+ BlogPost.create! :title => random_word, :user => @user
34
+ visit "/admin/blog_posts2"
35
+ click_link "Published at"
36
+ click_link "New blog post"
37
+ fill_in "blog_post[title]", :with => 'Funny ha ha'
38
+ select "soren", :from => "blog_post[user_id]"
39
+ click_button 'Preview'
40
+ click_button 'Update'
41
+ assert_select 'th.asc', :text => 'Published at'
42
+ end
43
+
44
+ def test_create_when_there_are_no_validation_errors
45
+ title = random_word
46
+ post(
47
+ "/admin/blog_posts2",
48
+ :blog_post => {
49
+ :title => title, :tags => 'tag1 tag2', :publish => '1',
50
+ :user_id => @user.id
51
+ }
52
+ )
53
+ @blog_post = BlogPost.find_by_title title
54
+
55
+ # should create a new BlogPost
56
+ assert @blog_post
57
+
58
+ # should create tags
59
+ assert_equal(2, @blog_post.tags.size)
60
+ %w(tag1 tag2).each do |tag_str|
61
+ assert(@blog_post.tags.any? { |tag| tag.tag == tag_str })
62
+ end
63
+
64
+ # should set published_at because of the publish flag
65
+ assert @blog_post.published_at
66
+
67
+ # should set the tags_string
68
+ assert_match(/tag1,tag2/, @blog_post.tags_string)
69
+ end
70
+
71
+ def test_create_when_the_user_has_clicked_Preview
72
+ title = random_word
73
+ post(
74
+ "/admin/blog_posts2",
75
+ :blog_post => {
76
+ :title => title, :tags => 'tag1 tag2', :publish => '1',
77
+ :user_id => @user.id
78
+ },
79
+ :commit => 'Preview'
80
+ )
81
+ @blog_post = BlogPost.find_by_title title
82
+
83
+ # should redirect to the edit page with the preview flag
84
+ assert_redirected_to(
85
+ "/admin/blog_posts2/#{@blog_post.id}/edit?preview=1"
86
+ )
87
+ end
88
+
89
+ def test_create_with_a_bad_tag
90
+ @title = random_word
91
+ post(
92
+ "/admin/blog_posts2",
93
+ :blog_post => {
94
+ :title => @title, :tags => 'foo bar! baz', :user_id => @user.id
95
+ }
96
+ )
97
+
98
+ # should not create a new BlogPost
99
+ assert_nil BlogPost.find_by_title(@title)
100
+
101
+ # should keep the title in the form
102
+ assert_select(
103
+ "input[name=?][value=?]", 'blog_post[title]', @title
104
+ )
105
+
106
+ # should render a useful error
107
+ assert_select("div.errorExplanation") do
108
+ assert_select 'li', :text => "Tags contain invalid string 'bar!'"
109
+ end
110
+
111
+ # should highlight the tag string entry
112
+ assert_select("div.field_with_errors") do
113
+ assert_select "input[name=?][value=?]", "blog_post[tags]", "foo bar! baz"
114
+ end
115
+ end
116
+
117
+ def test_create_with_a_bad_tag_and_a_missing_title
118
+ @orig_count = BlogPost.count
119
+ post(
120
+ "/admin/blog_posts2",
121
+ :blog_post => {
122
+ :title => '', :tags => 'foo bar! baz', :user_id => @user.id
123
+ }
124
+ )
125
+
126
+ # should not create a new BlogPost
127
+ assert_equal(@orig_count, BlogPost.count)
128
+
129
+ # should render a useful tags error
130
+ assert_select("div.errorExplanation") do
131
+ assert_select 'li', :text => "Tags contain invalid string 'bar!'"
132
+ end
133
+
134
+ # should highlight the tag string entry
135
+ assert_select("div.field_with_errors") do
136
+ assert_select "input[name=?][value=?]", "blog_post[tags]", "foo bar! baz"
137
+ end
138
+
139
+ # should render a useful title error
140
+ assert_select("div.errorExplanation") do
141
+ assert_select 'li', :text => "Title can't be blank"
142
+ end
143
+
144
+ # should highlight the title string entry
145
+ assert_select("div.field_with_errors") do
146
+ assert_select "input[name=?][value=?]", "blog_post[title]", ""
147
+ end
148
+ end
149
+
150
+ def test_create_with_a_bad_publish_value_somehow
151
+ @title = random_word
152
+ post(
153
+ "/admin/blog_posts2",
154
+ :blog_post => {
155
+ :title => @title, :tags => 'tag1 tag2', :publish => 'FOOBAR',
156
+ }
157
+ )
158
+
159
+ # should be successful
160
+ assert_response :success
161
+
162
+ # should not save the blog post
163
+ assert_nil BlogPost.find_by_title(@title)
164
+
165
+ # should display the publish error
166
+ assert_match(/Publish can't be .*FOOBAR.*/, response.body)
167
+
168
+ # should display a user error too
169
+ assert_match(/User can't be blank/, response.body)
170
+ end
171
+
172
+ def test_edit
173
+ BlogPost.destroy_all
174
+ @blog_post = BlogPost.create!(
175
+ :title => "blog post title", :body => 'blog post body', :user => @user
176
+ )
177
+ tag1 = Tag.find_or_create_by_tag 'tag1'
178
+ BlogPostTag.create! :blog_post => @blog_post, :tag => tag1
179
+ tag2 = Tag.find_or_create_by_tag 'tag2'
180
+ BlogPostTag.create! :blog_post => @blog_post, :tag => tag2
181
+ get "/admin/blog_posts2/#{@blog_post.id}/edit"
182
+ assert_response :success
183
+
184
+ # should show the tags
185
+ assert_match(%r|<input.*name="blog_post\[tags\]"|m, response.body)
186
+ assert_match(/(tag2 tag1|tag1 tag2)/, response.body)
187
+
188
+ # should show a preview button
189
+ assert_select('input[type=submit][value=Preview]')
190
+ end
191
+
192
+ def test_edit_in_preview_mode
193
+ @blog_post = BlogPost.create!(
194
+ :title => "blog post title", :body => 'blog post body', :user => @user
195
+ )
196
+ get "/admin/blog_posts2/#{@blog_post.id}/edit?preview=1"
197
+ assert_response :success
198
+
199
+ # should render the preview HTML
200
+ assert_select('html') do
201
+ assert_select 'h4', 'Preview'
202
+ end
203
+ end
204
+
205
+ def test_edit_when_there_are_more_than_15_users
206
+ @blog_post = BlogPost.create! :title => random_word, :user => @user
207
+ 1.upto(16) do |i|
208
+ User.create! :username => "--user #{i}--"
209
+ end
210
+ get "/admin/blog_posts2/#{@blog_post.id}/edit"
211
+
212
+ # should use the token input instead of a drop-down
213
+ assert_select("select[name=?]", "blog_post[user_id]", false)
214
+ assert_select("input[name=?][value=?]", 'blog_post[user_id]', @user.id)
215
+ assert_match(
216
+ %r|
217
+ \$\("\#blog_post_user_id"\)\.tokenInput\(
218
+ \s*"/admin/blog_posts2/autocomplete_user",
219
+ .*prePopulate
220
+ .*"id":\s*#{@user.id}
221
+ |mx,
222
+ response.body
223
+ )
224
+ end
225
+
226
+ def test_edit_when_there_are_less_than_15_users
227
+ @blog_post = BlogPost.create! :title => random_word, :user => @user
228
+ User.count.downto(14) do
229
+ user = User.find(
230
+ :first, :conditions => ['username != ?', @user.username]
231
+ )
232
+ user.destroy
233
+ end
234
+ get "/admin/blog_posts2/#{@blog_post.id}/edit"
235
+
236
+ # should use a drop-down without a blank option
237
+ assert_select('select[name=?]', 'blog_post[user_id]') do
238
+ assert_select("option[value='']", false)
239
+ end
240
+ end
241
+
242
+ def test_edit_a_blog_post_that_has_already_been_published
243
+ @blog_post = BlogPost.create!(
244
+ :title => "blog post title", :body => 'blog post body', :user => @user,
245
+ :published_at => Time.now.utc
246
+ )
247
+ get "/admin/blog_posts2/#{@blog_post.id}/edit"
248
+ assert_response :success
249
+
250
+ # should show the publish check-box checked
251
+ assert_select(
252
+ 'input[type=checkbox][name=?][checked=checked]', 'blog_post[publish]'
253
+ )
254
+ end
255
+
256
+ def test_index_when_there_is_one_record_and_15_or_less_users
257
+ BlogPost.destroy_all
258
+ @blog_post = BlogPost.create!(
259
+ :title => "blog post title", :body => 'blog post body',
260
+ :user => @user
261
+ )
262
+ tag1 = Tag.find_or_create_by_tag 'tag1'
263
+ BlogPostTag.create! :blog_post => @blog_post, :tag => tag1
264
+ tag2 = Tag.find_or_create_by_tag 'tag2'
265
+ BlogPostTag.create! :blog_post => @blog_post, :tag => tag2
266
+ User.count.downto(15) do
267
+ user = User.find(:first, :conditions => ['id != ?', @user.id])
268
+ user.destroy
269
+ end
270
+ get "/admin/blog_posts2"
271
+ assert_response :success
272
+
273
+ # should show the tags
274
+ assert_match(/(tag2 tag1|tag1 tag2)/, response.body)
275
+
276
+ # should show the title
277
+ assert_match(/blog post title/, response.body)
278
+
279
+ # should not show the body
280
+ assert_no_match(/blog post body/, response.body)
281
+
282
+ # should show a link to the all index page
283
+ assert_match(%r|<a.*href="/admin/blog_posts2\?all=1"|, response.body)
284
+
285
+ # should not show a sort link for tags
286
+ assert_no_match(%r|<a [^>]*>Tags</a>|, response.body)
287
+
288
+ # should show a sort link for users
289
+ assert_a_tag_with_get_args(
290
+ 'Author', '/admin/blog_posts2',
291
+ {:sort => 'user', :sort_order => 'asc'}, response.body
292
+ )
293
+
294
+ # should render the author as a username with a link
295
+ assert_select('td') do
296
+ assert_select(
297
+ "a[href=?]", "/admin/users/#{@user.id}/edit", :text => 'soren'
298
+ )
299
+ end
300
+
301
+ # should say 'Yes' or 'No' for the textile field
302
+ assert_match(/No/, response.body)
303
+
304
+ # should show a search form with specific fields
305
+ assert_select(
306
+ 'form[id=search_form][method=get]', :text => /Title/
307
+ ) do
308
+ assert_select(
309
+ 'input[type=radio][name=?][value=all][checked=checked]',
310
+ 'search[(all_or_any)]'
311
+ )
312
+ assert_select(
313
+ 'input[type=radio][name=?][value=any]', 'search[(all_or_any)]'
314
+ )
315
+ assert_select('input[name=?]', 'search[title]')
316
+ assert_select('input[name=?]', 'search[body]')
317
+ assert_select('select[name=?]', 'search[textile]') do
318
+ assert_select("option[value='']", :text => '')
319
+ assert_select("option[value='true']", :text => 'Yes')
320
+ assert_select("option[value='false']", :text => 'No')
321
+ end
322
+ assert_select('select[name=?]', 'search[user_id]') do
323
+ assert_select("option[value='']", :text => '')
324
+ assert_select("option[value=?]", @user.id)
325
+ end
326
+ end
327
+
328
+ # should show a link to /admin/comments/new
329
+ assert_select('td') do
330
+ assert_select(
331
+ "a[href=?]",
332
+ "/admin/comments/new?comment[blog_post_id]=#{@blog_post.id}",
333
+ :text => "New comment"
334
+ )
335
+ end
336
+
337
+ # should have a header of 'Blog posts (unpublished)'
338
+ assert_select('h2', :text => 'Blog posts (unpublished)')
339
+
340
+ # should render custom HTML after the index
341
+ assert_select(
342
+ '#after_index', :text => 'Custom HTML rendered after the index'
343
+ )
344
+
345
+ # should render custom HTML before the index
346
+ assert_select(
347
+ '#before_index', :text => 'Custom HTML rendered before the index'
348
+ )
349
+
350
+ # should not have a blank checkbox for the body search field
351
+ assert_select('form[id=search_form][method=get]') do
352
+ assert_select(
353
+ "input[type=checkbox][name=?]", "search[body(blank)]", false
354
+ )
355
+ end
356
+
357
+ # should output ivar set by index_before_render controller hook
358
+ assert assigns(:var_set_by_before_render_for_index_hook)
359
+ assert_match(/Confirmed that we have some records/, response.body)
360
+ end
361
+
362
+ def test_index_when_there_is_one_published_post_and_one_unpublished_post
363
+ BlogPost.create! :title => "--unpublished--", :user => @user
364
+ BlogPost.create!(
365
+ :title => "--published--", :published_at => Time.now.utc,
366
+ :user => @user
367
+ )
368
+ get "/admin/blog_posts2"
369
+ assert_response :success
370
+
371
+ # should show the unpublished post
372
+ assert_match(/--unpublished--/, response.body)
373
+
374
+ # should not show the published post
375
+ assert_no_match(/--published--/, response.body)
376
+ end
377
+
378
+ def test_index_when_there_is_1_blog_post_and_16_users
379
+ @blog_post = BlogPost.create! :title => random_word, :user => @user
380
+ User.count.upto(16) do |i|
381
+ User.create! :username => random_word
382
+ end
383
+ get "/admin/blog_posts2"
384
+
385
+ # should use the token input in the search form for users
386
+ assert_select("select[name=?]", "search[user_id]]", false)
387
+ assert_select("input:not([value])[name=?]", 'search[user_id]')
388
+ assert_match(
389
+ %r|
390
+ \$\("\#search_user_id"\)\.tokenInput\(
391
+ \s*"/admin/blog_posts2/autocomplete_user"
392
+ |mx,
393
+ response.body
394
+ )
395
+ end
396
+
397
+ def test_index_all_1
398
+ BlogPost.create!(
399
+ :title => "--published--", :published_at => Time.now.utc,
400
+ :user => @user
401
+ )
402
+ get "/admin/blog_posts2", :all => '1'
403
+ assert_response :success
404
+
405
+ # should show published posts
406
+ assert_match(/--published--/, response.body)
407
+
408
+ # should show a sort link for titles that includes all=1
409
+ assert_a_tag_with_get_args(
410
+ 'Title', '/admin/blog_posts2',
411
+ {:sort => 'title', :sort_order => 'asc', :all => '1'}, response.body
412
+ )
413
+
414
+ # should have a header of 'Blog posts (all)'
415
+ assert_select('h2', :text => 'Blog posts (all)')
416
+ end
417
+
418
+ def test_index_all_1_with_two_published_posts
419
+ BlogPost.create!(
420
+ :title => 'published later', :published_at => Time.utc(2009, 2, 1),
421
+ :user => @user
422
+ )
423
+ BlogPost.create!(
424
+ :title => 'published earlier', :published_at => Time.utc(2009, 1, 1),
425
+ :user => @user
426
+ )
427
+ get "/admin/blog_posts2", :all => '1'
428
+
429
+ # should order by published_at desc
430
+ assert_match(/published later.*published earlier/m, response.body)
431
+ end
432
+
433
+ def test_index_when_searching_for_title_with_foobar
434
+ create_foobar_blog_posts
435
+ get(
436
+ "/admin/blog_posts2",
437
+ :search => {
438
+ :body => "", :title => "foobar", :textile => "", :id => "",
439
+ :user => ''
440
+ }
441
+ )
442
+ assert_response :success
443
+
444
+ # should match records where textile=true
445
+ assert_select('td', :text => 'textile_true_foobar')
446
+
447
+ # should match records where textile=false
448
+ assert_select('td', :text => 'textile_false_foobar')
449
+
450
+ # should show the textile and title search fields pre-set
451
+ assert_select('form[id=search_form][method=get]') do
452
+ assert_select('input[name=?][value=foobar]', 'search[title]')
453
+ assert_select('select[name=?]', 'search[textile]') do
454
+ assert_select("option[value='']", :text => '')
455
+ assert_select("option:not(selected)[value='true']", :text => 'Yes')
456
+ assert_select("option:not(selected)[value='false']", :text => 'No')
457
+ end
458
+ end
459
+ end
460
+
461
+ def test_index_when_searching_for_title_with_foobar_and_textile_false
462
+ create_foobar_blog_posts
463
+ get(
464
+ "/admin/blog_posts2",
465
+ :search => {
466
+ :textile => 'false', :title => 'foobar', '(all_or_any)' => 'all',
467
+ :user => ''
468
+ }
469
+ )
470
+ assert_response :success
471
+
472
+ # should show blog posts with textile=false and the word 'foobar' in the title
473
+ assert_select('td', :text => 'textile_false_foobar')
474
+
475
+ # should not show a blog post with textile=true
476
+ assert_no_match(%r|<td[^>]*>textile_true_foobar</td>|, response.body)
477
+
478
+ # should not show a blog post just 'cause it has 'foobar' in the body
479
+ assert_no_match(%r|<td[^>]*>not_in_the_title</td>|, response.body)
480
+
481
+ # should show the textile, title, and all-or-any search fields pre-set
482
+ assert_select('form[id=search_form][method=get]') do
483
+ assert_select(
484
+ 'input[type=radio][name=?][value=all][checked=checked]',
485
+ 'search[(all_or_any)]'
486
+ )
487
+ assert_select('input[name=?][value=foobar]', 'search[title]')
488
+ assert_select('select[name=?]', 'search[textile]') do
489
+ assert_select("option[value='']", :text => '')
490
+ assert_select("option[value='true']", :text => 'Yes')
491
+ assert_select("option[value='false'][selected=selected]", :text => 'No')
492
+ end
493
+ end
494
+ end
495
+
496
+ def test_index_for_title_with_foobar_and_textile_false
497
+ create_foobar_blog_posts
498
+ get(
499
+ "/admin/blog_posts2",
500
+ :search => {
501
+ :textile => 'false', :title => 'foobar', '(all_or_any)' => 'any',
502
+ :user => ''
503
+ }
504
+ )
505
+ assert_response :success
506
+
507
+ # should show a blog post with 'foobar' in the title
508
+ assert_select('td', :text => 'textile_true_foobar')
509
+
510
+ # should show a blog post with textile=false
511
+ assert_select('td', :text => 'textile is false')
512
+
513
+ # should not show a blog post that's already published, because of the conditions set in controller
514
+ assert_no_match(%r|<td[^>]*>already published</td>|, response.body)
515
+
516
+ # should show the textile, title, and all-or-any search fields pre-set
517
+ assert_select('form[id=search_form][method=get]') do
518
+ assert_select(
519
+ 'input[type=radio][name=?][value=any][checked=checked]',
520
+ 'search[(all_or_any)]'
521
+ )
522
+ assert_select('input[name=?][value=foobar]', 'search[title]')
523
+ assert_select('select[name=?]', 'search[textile]') do
524
+ assert_select("option[value='']", :text => '')
525
+ assert_select("option[value='true']", :text => 'Yes')
526
+ assert_select("option[value='false'][selected=selected]", :text => 'No')
527
+ end
528
+ end
529
+ end
530
+
531
+ def test_index_when_searching_by_user_and_there_are_less_than_15_users
532
+ @user2 = User.create! :username => 'Jean-Paul'
533
+ User.count.downto(14) do
534
+ user = User.find(
535
+ :first,
536
+ :conditions => [
537
+ 'username != ? and username != ?', @user.username, @user.username
538
+ ]
539
+ )
540
+ user.destroy
541
+ end
542
+ BlogPost.destroy_all
543
+ BlogPost.create! :title => "Soren's first post", :user => @user
544
+ BlogPost.create! :title => "Soren's second post", :user => @user
545
+ BlogPost.create! :title => "Jean-Paul's post", :user => @user2
546
+ get(
547
+ "/admin/blog_posts2",
548
+ :search => {:textile => '', :title => '', :user_id => @user2.id.to_s}
549
+ )
550
+ assert_response :success
551
+
552
+ # should show blog posts by Jean-Paul
553
+ assert_select('td', :text => "Jean-Paul's post")
554
+
555
+ # should not show blog posts by Soren
556
+ assert_no_match(%r|<td[^>]*>Soren's first post</td>|, response.body)
557
+ assert_no_match(%r|<td[^>]*>Soren's second post</td>|, response.body)
558
+
559
+ # should show the user field pre-set
560
+ assert_select(
561
+ 'form[id=search_form][method=get]', :text => /Title/
562
+ ) do
563
+ assert_select('select[name=?]', 'search[user_id]') do
564
+ assert_select("option[value='']", :text => '')
565
+ assert_select("option[value=?][selected=selected]", @user2.id)
566
+ end
567
+ end
568
+ end
569
+
570
+ def test_index_when_searching_by_user_and_there_are_more_than_15_users
571
+ @blog_post = BlogPost.create! :title => random_word, :user => @user
572
+ User.count.upto(16) do |i|
573
+ User.create! :username => "--user #{i}--"
574
+ end
575
+ get(
576
+ "/admin/blog_posts2",
577
+ :search => {:textile => '', :title => '', :user_id => @user.id.to_s}
578
+ )
579
+ assert_response :success
580
+
581
+ # should show pre-populated user token input in the search form
582
+ assert_select("select[name=?]", "search[user_id]]", false)
583
+ assert_select("input[name=?][value=?]", 'search[user_id]', @user.id)
584
+ assert_match(
585
+ %r|
586
+ \$\("\#search_user_id"\)\.tokenInput\(
587
+ \s*"/admin/blog_posts2/autocomplete_user",
588
+ .*prePopulate
589
+ .*"id":\s*#{@user.id}
590
+ |mx,
591
+ response.body
592
+ )
593
+ end
594
+
595
+ def test_index_with_a_blank_search
596
+ get(
597
+ "/admin/blog_posts2",
598
+ :search => {
599
+ :body => '', :title => '', :textile => '', :id => '', :user_id => '',
600
+ '(all_or_any)' => 'all', 'id(comparator)' => ''
601
+ }
602
+ )
603
+
604
+ # should be successful
605
+ assert_response :success
606
+ end
607
+
608
+ def test_index_with_one_record_with_a_false_textile_field
609
+ BlogPost.destroy_all
610
+ @blog_post = BlogPost.create!(
611
+ :title => random_word, :user => @user, :textile => false
612
+ )
613
+ get "/admin/blog_posts2"
614
+
615
+ # should make the textile field an Ajax toggle
616
+ toggle_div_id = "blog_post_#{@blog_post.id}_textile"
617
+ post_url =
618
+ "/admin/blog_posts2/#{@blog_post.id}?" +
619
+ 'blog_post[textile]' + "=1&amp;from=#{toggle_div_id}"
620
+ assert_select("div[id=?]", toggle_div_id) do
621
+ assert_select("a.toggle[href=?]", post_url, :text => 'No')
622
+ end
623
+ end
624
+
625
+ def test_index_with_11_blog_posts
626
+ BlogPost.destroy_all
627
+ 1.upto(11) do |i|
628
+ BlogPost.create!(
629
+ :title => "--post #{i}--", :user => @user
630
+ )
631
+ end
632
+ get "/admin/blog_posts2"
633
+
634
+ # should show link to page 2
635
+ assert_select("a[href=/admin/blog_posts2?page=2]")
636
+
637
+ # should say 11 blog posts found
638
+ assert_match(/11 blog posts found/, response.body)
639
+
640
+ # should mark the table rows with custom CSS class
641
+ assert_select('tr[class~="custom_tr_css_class"]')
642
+
643
+ # should mark the user cells with custom CSS class
644
+ assert_select('td[class~="custom_td_css_class"]', :text => @user.username)
645
+ end
646
+
647
+ def test_new
648
+ Tag.find_or_create_by_tag 'tag_from_yesterday'
649
+ get "/admin/blog_posts2/new"
650
+
651
+ # should show a field for tags
652
+ assert_match(%r|<input.*name="blog_post\[tags\]"|m, response.body)
653
+
654
+ # should show current tags
655
+ assert_match(/tag_from_yesterday/, response.body)
656
+
657
+ # should show a checkbox for the 'publish' virtual field
658
+ assert_match(
659
+ %r!
660
+ <input[^>]*
661
+ (name="blog_post\[publish\][^>]*type="hidden"[^>]value="0"|
662
+ type="hidden"[^>]*name="blog_post\[publish\][^>]value="0")
663
+ .*
664
+ <input[^>]*
665
+ (name="blog_post\[publish\][^>]*type="checkbox"[^>]value="1"|
666
+ type="checkbox"[^>]*name="blog_post\[publish\][^>]value="1")
667
+ !x,
668
+ response.body
669
+ )
670
+
671
+ # should not duplicate the DOM ID of the 'publish' checkbox on the page
672
+ assert_equal(
673
+ 1,
674
+ response.body.scan(
675
+ /id="blog_post_publish"|id="blog_post\[publish\]"/
676
+ ).size
677
+ )
678
+
679
+ # should show the description for the 'publish' virtual field
680
+ assert_match(
681
+ /Click this and published_at will be set automatically/,
682
+ response.body
683
+ )
684
+
685
+ # should show a preview button
686
+ assert_select('input[type=submit][value=Preview]')
687
+
688
+ # should use a textarea for the body field
689
+ assert_select(
690
+ 'textarea[name=?][cols=20][rows=40]', 'blog_post[body]'
691
+ )
692
+
693
+ # should use a checkbox for the boolean field 'textile'
694
+ assert_match(
695
+ %r!
696
+ <input[^>]*
697
+ (name="blog_post\[textile\][^>]*type="checkbox"|
698
+ type="checkbox"[^>]*name="blog_post\[textile\])
699
+ !x,
700
+ response.body
701
+ )
702
+
703
+ # should say 'Author' instead of 'User'
704
+ assert_match(/Author/, response.body)
705
+ end
706
+
707
+ def test_show
708
+ @blog_post = BlogPost.create! :title => random_word, :user => @user
709
+ get "/admin/blog_posts2/#{@blog_post.id}"
710
+ assert_response :success
711
+
712
+ # should show user
713
+ assert_match(/soren/, response.body)
714
+
715
+ # should not show created at
716
+ assert_no_match(/Created at/, response.body)
717
+ end
718
+
719
+ def test_update_when_there_are_no_validation_errors
720
+ @blog_post = BlogPost.create! :title => random_word, :user => @user
721
+ put(
722
+ "/admin/blog_posts2/#{@blog_post.id}",
723
+ :blog_post => {:tags => 'tag1 tag2 tag3'}
724
+ )
725
+
726
+ # should set the tags_string
727
+ @blog_post.reload
728
+ assert_match(/tag1,tag2,tag3/, @blog_post.tags_string)
729
+ end
730
+
731
+ def test_update_when_the_user_has_clicked_Preview
732
+ @blog_post = BlogPost.create! :title => random_word, :user => @user
733
+ title2 = random_word
734
+ put(
735
+ "/admin/blog_posts2/#{@blog_post.id}",
736
+ :blog_post => {:title => title2},
737
+ :commit => 'Preview'
738
+ )
739
+
740
+ # should redirect to the edit page with the preview flag
741
+ assert_redirected_to("/admin/blog_posts2/#{@blog_post.id}/edit?preview=1")
742
+ end
743
+
744
+ def test_update_with_a_bad_tag
745
+ @blog_post = BlogPost.create! :title => random_word, :user => @user
746
+ put(
747
+ "/admin/blog_posts2/#{@blog_post.id}",
748
+ :blog_post => {:tags => "foo bar! baz"}
749
+ )
750
+
751
+ # should render a useful error
752
+ assert_select("div.errorExplanation") do
753
+ assert_select 'li', :text => "Tags contain invalid string 'bar!'"
754
+ end
755
+
756
+ # should highlight the tag string entry
757
+ assert_select("div.field_with_errors") do
758
+ assert_select "input[name=?][value=?]", "blog_post[tags]", "foo bar! baz"
759
+ end
760
+ end
761
+
762
+ def test_update_with_a_bad_tag_and_a_missing_title
763
+ @blog_post = BlogPost.create! :title => random_word, :user => @user
764
+ put(
765
+ "/admin/blog_posts2/#{@blog_post.id}",
766
+ :blog_post => {:tags => "foo bar! baz", :title => ''}
767
+ )
768
+
769
+ # should render a useful tags error
770
+ assert_select("div.errorExplanation") do
771
+ assert_select 'li', :text => "Tags contain invalid string 'bar!'"
772
+ end
773
+
774
+ # should highlight the tag string entry
775
+ assert_select("div.field_with_errors") do
776
+ assert_select "input[name=?][value=?]", "blog_post[tags]", "foo bar! baz"
777
+ end
778
+
779
+ # should render a useful title error
780
+ assert_select("div.errorExplanation") do
781
+ assert_select 'li', :text => "Title can't be blank"
782
+ end
783
+
784
+ # should highlight the title string entry
785
+ assert_select("div.field_with_errors") do
786
+ assert_select "input[name=?][value=?]", "blog_post[title]", ""
787
+ end
788
+ end
789
+ end