typus 3.0.2 → 3.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (343) hide show
  1. data/Gemfile +20 -9
  2. data/Gemfile.lock +93 -65
  3. data/MIT-LICENSE +1 -1
  4. data/README.md +61 -0
  5. data/Rakefile +5 -0
  6. data/app/controllers/admin/account_controller.rb +7 -10
  7. data/app/controllers/admin/base_controller.rb +16 -1
  8. data/app/controllers/admin/resources_controller.rb +270 -159
  9. data/app/controllers/admin/session_controller.rb +8 -9
  10. data/app/helpers/admin/base_helper.rb +13 -28
  11. data/app/helpers/admin/dashboard_helper.rb +4 -10
  12. data/app/helpers/admin/file_preview_helper.rb +70 -0
  13. data/app/helpers/admin/filters_helper.rb +64 -45
  14. data/app/helpers/admin/form_helper.rb +37 -62
  15. data/app/helpers/admin/relationships_helper.rb +63 -78
  16. data/app/helpers/admin/resources_helper.rb +10 -31
  17. data/app/helpers/admin/search_helper.rb +6 -9
  18. data/app/helpers/admin/sidebar_helper.rb +15 -20
  19. data/app/helpers/admin/table_helper.rb +79 -170
  20. data/app/mailers/admin/mailer.rb +1 -1
  21. data/app/views/admin/account/forgot_password.html.erb +2 -2
  22. data/app/views/admin/account/new.html.erb +8 -4
  23. data/app/views/admin/base/user_guide.html.erb +85 -0
  24. data/app/views/admin/dashboard/_sidebar.html.erb +3 -1
  25. data/app/views/admin/dashboard/show.html.erb +2 -2
  26. data/app/views/admin/dashboard/styles.html.erb +2 -2
  27. data/app/views/admin/helpers/_apps.html.erb +5 -4
  28. data/app/views/admin/helpers/_file_preview.html.erb +3 -0
  29. data/app/views/admin/helpers/_header.html.erb +3 -3
  30. data/app/views/admin/helpers/_login_info.html.erb +2 -2
  31. data/app/views/admin/helpers/dashboard/_applications.html.erb +6 -9
  32. data/app/views/admin/helpers/dashboard/_resources.html.erb +2 -3
  33. data/app/views/admin/helpers/filters/_filters.html.erb +1 -1
  34. data/app/views/admin/helpers/resources/_display_link_to_previous.html.erb +1 -1
  35. data/app/views/admin/helpers/resources/_errors.html.erb +10 -0
  36. data/app/views/admin/helpers/search/_search.html.erb +1 -1
  37. data/app/views/admin/helpers/sidebar/_sidebar.html.erb +6 -3
  38. data/app/views/admin/helpers/table/_table.html.erb +17 -5
  39. data/app/views/admin/mailer/reset_password_link.text.erb +2 -2
  40. data/app/views/admin/resources/_form.html.erb +3 -12
  41. data/app/views/admin/resources/edit.html.erb +7 -5
  42. data/app/views/admin/resources/index.html.erb +13 -18
  43. data/app/views/admin/resources/new.html.erb +4 -4
  44. data/app/views/admin/resources/show.html.erb +9 -13
  45. data/app/views/admin/session/new.html.erb +8 -4
  46. data/app/views/admin/templates/_belongs_to.html.erb +1 -1
  47. data/app/views/admin/templates/_boolean.html.erb +2 -2
  48. data/app/views/admin/templates/_date.html.erb +2 -2
  49. data/app/views/admin/templates/_datetime.html.erb +2 -2
  50. data/app/views/admin/templates/_file.html.erb +3 -19
  51. data/app/views/admin/templates/_has_n.html.erb +4 -4
  52. data/app/views/admin/templates/_has_one.html.erb +14 -0
  53. data/app/views/admin/templates/_password.html.erb +2 -2
  54. data/app/views/admin/templates/_profile_sidebar.html.erb +3 -0
  55. data/app/views/admin/templates/_relate_form.html.erb +2 -1
  56. data/app/views/admin/templates/_selector.html.erb +1 -1
  57. data/app/views/admin/templates/_string.html.erb +6 -6
  58. data/app/views/admin/templates/_text.html.erb +11 -4
  59. data/app/views/admin/templates/_time.html.erb +2 -2
  60. data/app/views/admin/templates/_tree.html.erb +1 -1
  61. data/app/views/layouts/admin/base.html.erb +7 -6
  62. data/app/views/layouts/admin/session.html.erb +4 -14
  63. data/config/{available_locales/ca_models.yml → locales/typus.ca.models.yml} +5 -4
  64. data/config/locales/typus.ca.yml +81 -0
  65. data/config/{available_locales/de_models.yml → locales/typus.de.models.yml} +6 -2
  66. data/config/locales/typus.de.yml +80 -0
  67. data/config/locales/typus.el.models.yml +17 -0
  68. data/config/locales/typus.el.yml +82 -0
  69. data/config/{available_locales/es_models.yml → locales/typus.es.models.yml} +9 -4
  70. data/config/locales/typus.es.yml +82 -0
  71. data/config/{available_locales/fr_models.yml → locales/typus.fr.models.yml} +8 -3
  72. data/config/locales/typus.fr.yml +87 -0
  73. data/config/{available_locales/hu_models.yml → locales/typus.hu.models.yml} +6 -2
  74. data/config/locales/typus.hu.yml +80 -0
  75. data/config/{available_locales/it_models.yml → locales/typus.it.models.yml} +7 -4
  76. data/config/locales/typus.it.yml +89 -0
  77. data/config/{available_locales/language_models.yml.template → locales/typus.locale.models.yml.template} +8 -4
  78. data/config/locales/typus.locale.yml.template +81 -0
  79. data/config/{available_locales/pt-BR_models.yml → locales/typus.pt-BR.models.yml} +6 -2
  80. data/config/locales/typus.pt-BR.yml +80 -0
  81. data/config/{available_locales/ru_models.yml → locales/typus.ru.models.yml} +6 -2
  82. data/config/locales/typus.ru.yml +80 -0
  83. data/config/locales/typus.zh-CN.models.yml +17 -0
  84. data/config/locales/typus.zh-CN.yml +79 -0
  85. data/config/routes.rb +11 -7
  86. data/lib/generators/templates/config/initializers/typus.rb +8 -5
  87. data/lib/generators/templates/config/initializers/typus_resources.rb +0 -3
  88. data/lib/generators/templates/config/typus/README +6 -6
  89. data/lib/generators/templates/config/typus/typus.yml +5 -5
  90. data/lib/generators/templates/controller.rb +1 -1
  91. data/lib/generators/templates/migration.rb +1 -0
  92. data/lib/generators/templates/public/admin/javascripts/application.js +0 -4
  93. data/lib/generators/templates/public/admin/javascripts/jquery-1.4.4.min.js +167 -0
  94. data/lib/generators/templates/public/admin/javascripts/jquery.application.js +16 -0
  95. data/lib/generators/templates/public/admin/javascripts/jquery.rails.js +50 -22
  96. data/lib/generators/templates/public/admin/stylesheets/screen.css +43 -34
  97. data/lib/generators/templates/public/admin/vendor/fancybox/fancy_loading.png +0 -0
  98. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.easing-1.3.pack.js +32 -32
  99. data/lib/generators/templates/public/admin/vendor/fancybox/{jquery.fancybox-1.3.1.css → jquery.fancybox-1.3.4.css} +359 -363
  100. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.4.js +1156 -0
  101. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.4.pack.js +46 -0
  102. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.mousewheel-3.0.4.pack.js +14 -0
  103. data/lib/generators/typus/assets_generator.rb +23 -0
  104. data/lib/generators/typus/controller_generator.rb +29 -0
  105. data/lib/generators/typus/migration_generator.rb +39 -20
  106. data/lib/generators/typus/typus_generator.rb +17 -57
  107. data/lib/generators/typus/views_generator.rb +2 -6
  108. data/lib/support/active_record.rb +8 -20
  109. data/lib/support/fake_user.rb +6 -1
  110. data/lib/support/hash.rb +1 -2
  111. data/lib/support/object.rb +4 -17
  112. data/lib/support/string.rb +34 -3
  113. data/lib/tasks/typus.rake +1 -1
  114. data/lib/typus.rb +60 -48
  115. data/lib/typus/actions.rb +27 -0
  116. data/lib/typus/authentication/base.rb +3 -4
  117. data/lib/typus/authentication/http_basic.rb +1 -1
  118. data/lib/typus/authentication/none.rb +1 -1
  119. data/lib/typus/authentication/session.rb +53 -108
  120. data/lib/typus/configuration.rb +13 -11
  121. data/lib/typus/filters.rb +12 -0
  122. data/lib/typus/format.rb +9 -13
  123. data/lib/typus/i18n.rb +30 -0
  124. data/lib/typus/orm/active_record.rb +97 -194
  125. data/lib/typus/orm/active_record/search.rb +91 -0
  126. data/lib/typus/resources.rb +6 -10
  127. data/lib/typus/user.rb +20 -40
  128. data/lib/typus/version.rb +1 -1
  129. metadata +77 -231
  130. data/CHANGELOG +0 -102
  131. data/README.rdoc +0 -48
  132. data/app/helpers/admin/preview_helper.rb +0 -46
  133. data/app/views/admin/helpers/_preview.html.erb +0 -13
  134. data/app/views/admin/templates/_has_many.html.erb +0 -22
  135. data/config/available_locales/ca.yml +0 -122
  136. data/config/available_locales/de.yml +0 -122
  137. data/config/available_locales/es.yml +0 -122
  138. data/config/available_locales/fr.yml +0 -127
  139. data/config/available_locales/hu.yml +0 -122
  140. data/config/available_locales/it.yml +0 -132
  141. data/config/available_locales/language.yml.template +0 -120
  142. data/config/available_locales/pt-BR.yml +0 -122
  143. data/config/available_locales/ru.yml +0 -122
  144. data/lib/generators/templates/functional_test.rb +0 -10
  145. data/lib/generators/templates/model.rb +0 -8
  146. data/lib/generators/templates/public/admin/images/ui-icons.png +0 -0
  147. data/lib/generators/templates/public/admin/javascripts/jquery-1.4.2.min.js +0 -154
  148. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.js +0 -1077
  149. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.fancybox-1.3.1.pack.js +0 -44
  150. data/lib/generators/templates/public/admin/vendor/fancybox/jquery.mousewheel-3.0.2.pack.js +0 -13
  151. data/lib/typus/pagination.rb +0 -18
  152. data/test/factories.rb +0 -43
  153. data/test/fixtures/config/broken/application.yml +0 -68
  154. data/test/fixtures/config/broken/application_roles.yml +0 -20
  155. data/test/fixtures/config/broken/empty.yml +0 -0
  156. data/test/fixtures/config/broken/empty_roles.yml +0 -0
  157. data/test/fixtures/config/broken/undefined.yml +0 -3
  158. data/test/fixtures/config/broken/undefined_roles.yml +0 -6
  159. data/test/fixtures/config/default/typus.yml +0 -13
  160. data/test/fixtures/config/default/typus_roles.yml +0 -2
  161. data/test/fixtures/config/empty/empty_01.yml +0 -0
  162. data/test/fixtures/config/empty/empty_01_roles.yml +0 -0
  163. data/test/fixtures/config/empty/empty_02.yml +0 -0
  164. data/test/fixtures/config/empty/empty_02_roles.yml +0 -0
  165. data/test/fixtures/config/locales/es.yml +0 -10
  166. data/test/fixtures/config/namespaced/application.yml +0 -5
  167. data/test/fixtures/config/namespaced/application_roles.yml +0 -2
  168. data/test/fixtures/config/ordered/001_roles.yml +0 -2
  169. data/test/fixtures/config/ordered/002_roles.yml +0 -2
  170. data/test/fixtures/config/unordered/app_one_roles.yml +0 -2
  171. data/test/fixtures/config/unordered/app_two_roles.yml +0 -2
  172. data/test/fixtures/config/working/application.yml +0 -73
  173. data/test/fixtures/config/working/application_roles.yml +0 -24
  174. data/test/fixtures/config/working/typus.yml +0 -13
  175. data/test/fixtures/config/working/typus_roles.yml +0 -2
  176. data/test/fixtures/rails_app/Rakefile +0 -7
  177. data/test/fixtures/rails_app/app/controllers/admin/assets_controller.rb +0 -2
  178. data/test/fixtures/rails_app/app/controllers/admin/categories_controller.rb +0 -2
  179. data/test/fixtures/rails_app/app/controllers/admin/comments_controller.rb +0 -2
  180. data/test/fixtures/rails_app/app/controllers/admin/pages_controller.rb +0 -2
  181. data/test/fixtures/rails_app/app/controllers/admin/pictures_controller.rb +0 -2
  182. data/test/fixtures/rails_app/app/controllers/admin/posts_controller.rb +0 -2
  183. data/test/fixtures/rails_app/app/controllers/admin/status_controller.rb +0 -2
  184. data/test/fixtures/rails_app/app/controllers/admin/typus_users_controller.rb +0 -2
  185. data/test/fixtures/rails_app/app/controllers/admin/watch_dog_controller.rb +0 -2
  186. data/test/fixtures/rails_app/app/controllers/application_controller.rb +0 -3
  187. data/test/fixtures/rails_app/app/models/asset.rb +0 -5
  188. data/test/fixtures/rails_app/app/models/category.rb +0 -11
  189. data/test/fixtures/rails_app/app/models/comment.rb +0 -6
  190. data/test/fixtures/rails_app/app/models/custom_user.rb +0 -2
  191. data/test/fixtures/rails_app/app/models/delayed/task.rb +0 -5
  192. data/test/fixtures/rails_app/app/models/page.rb +0 -5
  193. data/test/fixtures/rails_app/app/models/picture.rb +0 -6
  194. data/test/fixtures/rails_app/app/models/post.rb +0 -21
  195. data/test/fixtures/rails_app/app/models/typus_user.rb +0 -8
  196. data/test/fixtures/rails_app/app/models/view.rb +0 -5
  197. data/test/fixtures/rails_app/app/views/admin/categories/_form.html.erb +0 -1
  198. data/test/fixtures/rails_app/app/views/admin/dashboard/_sidebar.html.erb +0 -1
  199. data/test/fixtures/rails_app/app/views/admin/mailer/reset_password_link.text.erb +0 -6
  200. data/test/fixtures/rails_app/app/views/admin/posts/_edit.html.erb +0 -1
  201. data/test/fixtures/rails_app/app/views/admin/posts/_index.html.erb +0 -1
  202. data/test/fixtures/rails_app/app/views/admin/posts/_new.html.erb +0 -1
  203. data/test/fixtures/rails_app/app/views/admin/posts/_show.html.erb +0 -1
  204. data/test/fixtures/rails_app/app/views/admin/posts/_sidebar.html.erb +0 -1
  205. data/test/fixtures/rails_app/app/views/admin/resources/_sidebar.html.erb +0 -1
  206. data/test/fixtures/rails_app/app/views/admin/status/index.html.erb +0 -1
  207. data/test/fixtures/rails_app/app/views/admin/templates/_datepicker.html.erb +0 -1
  208. data/test/fixtures/rails_app/config.ru +0 -4
  209. data/test/fixtures/rails_app/config/application.rb +0 -53
  210. data/test/fixtures/rails_app/config/boot.rb +0 -13
  211. data/test/fixtures/rails_app/config/database.yml +0 -14
  212. data/test/fixtures/rails_app/config/environment.rb +0 -5
  213. data/test/fixtures/rails_app/config/environments/test.rb +0 -34
  214. data/test/fixtures/rails_app/config/initializers/secret_token.rb +0 -7
  215. data/test/fixtures/rails_app/config/initializers/session_store.rb +0 -8
  216. data/test/fixtures/rails_app/config/initializers/typus.rb +0 -6
  217. data/test/fixtures/rails_app/config/routes.rb +0 -5
  218. data/test/fixtures/rails_app/config/typus/application.yml +0 -79
  219. data/test/fixtures/rails_app/config/typus/application_roles.yml +0 -25
  220. data/test/fixtures/rails_app/config/typus/typus.yml +0 -12
  221. data/test/fixtures/rails_app/config/typus/typus_roles.yml +0 -2
  222. data/test/fixtures/rails_app/db/test.sqlite3 +0 -0
  223. data/test/fixtures/rails_app/tmp/export-posts-20101012213057.csv +0 -2
  224. data/test/fixtures/rails_app/tmp/export-posts-20101012213132.csv +0 -2
  225. data/test/fixtures/rails_app/tmp/export-posts-20101012213234.csv +0 -2
  226. data/test/fixtures/rails_app/tmp/export-posts-20101012213506.csv +0 -2
  227. data/test/fixtures/rails_app/tmp/export-posts-20101012215057.csv +0 -2
  228. data/test/fixtures/rails_app/tmp/export-posts-20101012215217.csv +0 -2
  229. data/test/fixtures/rails_app/tmp/export-posts-20101012215415.csv +0 -2
  230. data/test/fixtures/rails_app/tmp/export-posts-20101012215443.csv +0 -2
  231. data/test/fixtures/rails_app/tmp/export-posts-20101012215509.csv +0 -2
  232. data/test/fixtures/rails_app/tmp/export-posts-20101012215528.csv +0 -2
  233. data/test/fixtures/rails_app/tmp/export-posts-20101012215551.csv +0 -2
  234. data/test/fixtures/rails_app/tmp/export-posts-20101012215615.csv +0 -2
  235. data/test/fixtures/rails_app/tmp/export-posts-20101012215640.csv +0 -2
  236. data/test/fixtures/rails_app/tmp/export-posts-20101012215714.csv +0 -2
  237. data/test/fixtures/rails_app/tmp/export-posts-20101012215744.csv +0 -2
  238. data/test/fixtures/rails_app/tmp/export-posts-20101012215814.csv +0 -2
  239. data/test/fixtures/rails_app/tmp/export-posts-20101012215836.csv +0 -2
  240. data/test/fixtures/rails_app/tmp/export-posts-20101012215906.csv +0 -2
  241. data/test/fixtures/rails_app/tmp/export-posts-20101012220659.csv +0 -2
  242. data/test/fixtures/rails_app/tmp/export-posts-20101012221043.csv +0 -2
  243. data/test/fixtures/rails_app/tmp/export-posts-20101012221258.csv +0 -2
  244. data/test/fixtures/rails_app/tmp/export-posts-20101012222558.csv +0 -2
  245. data/test/fixtures/rails_app/tmp/export-posts-20101012222752.csv +0 -2
  246. data/test/fixtures/rails_app/tmp/export-posts-20101012222848.csv +0 -2
  247. data/test/fixtures/rails_app/tmp/export-posts-20101012223433.csv +0 -2
  248. data/test/fixtures/rails_app/tmp/export-posts-20101012223535.csv +0 -2
  249. data/test/fixtures/rails_app/tmp/export-posts-20101012224003.csv +0 -2
  250. data/test/fixtures/rails_app/tmp/export-posts-20101012224052.csv +0 -2
  251. data/test/fixtures/rails_app/tmp/export-posts-20101012224109.csv +0 -2
  252. data/test/fixtures/rails_app/tmp/export-posts-20101012224139.csv +0 -2
  253. data/test/fixtures/rails_app/tmp/export-posts-20101012224205.csv +0 -2
  254. data/test/fixtures/rails_app/tmp/export-posts-20101012224243.csv +0 -2
  255. data/test/fixtures/rails_app/tmp/export-posts-20101012225119.csv +0 -2
  256. data/test/fixtures/rails_app/tmp/export-posts-20101013063215.csv +0 -2
  257. data/test/fixtures/rails_app/tmp/export-posts-20101013063300.csv +0 -2
  258. data/test/fixtures/rails_app/tmp/export-posts-20101013063352.csv +0 -2
  259. data/test/fixtures/rails_app/tmp/export-posts-20101013063427.csv +0 -2
  260. data/test/fixtures/rails_app/tmp/export-posts-20101013063448.csv +0 -2
  261. data/test/fixtures/rails_app/tmp/export-posts-20101013063530.csv +0 -2
  262. data/test/fixtures/rails_app/tmp/export-posts-20101013063559.csv +0 -2
  263. data/test/fixtures/rails_app/tmp/export-posts-20101013063646.csv +0 -2
  264. data/test/fixtures/rails_app/tmp/export-posts-20101013063737.csv +0 -2
  265. data/test/fixtures/rails_app/tmp/export-posts-20101013063822.csv +0 -2
  266. data/test/fixtures/rails_app/tmp/export-posts-20101013063837.csv +0 -2
  267. data/test/fixtures/rails_app/tmp/export-posts-20101013063919.csv +0 -2
  268. data/test/fixtures/rails_app/tmp/export-posts-20101013063939.csv +0 -2
  269. data/test/fixtures/rails_app/tmp/export-posts-20101013063952.csv +0 -2
  270. data/test/fixtures/rails_app/tmp/export-posts-20101013064220.csv +0 -2
  271. data/test/fixtures/rails_app/tmp/export-posts-20101013064253.csv +0 -2
  272. data/test/fixtures/rails_app/tmp/export-posts-20101013064318.csv +0 -2
  273. data/test/fixtures/rails_app/tmp/export-posts-20101013064404.csv +0 -2
  274. data/test/fixtures/rails_app/tmp/export-posts-20101013064452.csv +0 -2
  275. data/test/fixtures/rails_app/tmp/export-posts-20101013064536.csv +0 -2
  276. data/test/fixtures/rails_app/tmp/export-posts-20101013064652.csv +0 -2
  277. data/test/fixtures/rails_app/tmp/export-posts-20101013064845.csv +0 -2
  278. data/test/fixtures/rails_app/tmp/export-posts-20101013065023.csv +0 -2
  279. data/test/fixtures/rails_app/tmp/export-posts-20101013065137.csv +0 -2
  280. data/test/fixtures/rails_app/tmp/export-posts-20101013065713.csv +0 -2
  281. data/test/fixtures/rails_app/tmp/export-posts-20101013065954.csv +0 -2
  282. data/test/fixtures/rails_app/tmp/export-posts-20101013070057.csv +0 -2
  283. data/test/fixtures/rails_app/tmp/export-posts-20101013070116.csv +0 -2
  284. data/test/fixtures/rails_app/tmp/export-posts-20101013070156.csv +0 -2
  285. data/test/fixtures/rails_app/tmp/export-posts-20101013070349.csv +0 -2
  286. data/test/fixtures/rails_app/tmp/export-posts-20101013070429.csv +0 -2
  287. data/test/fixtures/rails_app/tmp/export-posts-20101013070448.csv +0 -2
  288. data/test/fixtures/rails_app/tmp/export-posts-20101013070514.csv +0 -2
  289. data/test/fixtures/rails_app/tmp/export-posts-20101013070709.csv +0 -2
  290. data/test/fixtures/rails_app/tmp/export-posts-20101013070745.csv +0 -2
  291. data/test/fixtures/rails_app/tmp/export-posts-20101013070809.csv +0 -2
  292. data/test/fixtures/rails_app/tmp/export-posts-20101013070905.csv +0 -2
  293. data/test/fixtures/rails_app/tmp/export-posts-20101013070955.csv +0 -2
  294. data/test/fixtures/rails_app/tmp/export-posts-20101013071116.csv +0 -2
  295. data/test/fixtures/rails_app/tmp/export-posts-20101013071209.csv +0 -2
  296. data/test/fixtures/rails_app/tmp/export-posts-20101013071335.csv +0 -2
  297. data/test/fixtures/rails_app/tmp/export-posts-20101013071632.csv +0 -2
  298. data/test/fixtures/rails_app/tmp/export-posts-20101013071643.csv +0 -2
  299. data/test/fixtures/rails_app/tmp/export-posts-20101013071735.csv +0 -2
  300. data/test/fixtures/rails_app/tmp/export-posts-20101013071749.csv +0 -2
  301. data/test/fixtures/rails_app/tmp/export-posts-20101013072030.csv +0 -2
  302. data/test/fixtures/rails_app/tmp/export-posts-20101013072050.csv +0 -2
  303. data/test/fixtures/rails_app/tmp/export-posts-20101013072108.csv +0 -2
  304. data/test/fixtures/rails_app/tmp/export-posts-20101013072713.csv +0 -2
  305. data/test/fixtures/rails_app/tmp/export-posts-20101013072751.csv +0 -2
  306. data/test/fixtures/rails_app/tmp/export-posts-20101013072912.csv +0 -2
  307. data/test/fixtures/rails_app/tmp/export-posts-20101013074546.csv +0 -2
  308. data/test/fixtures/rails_app/tmp/export-posts-20101018180512.csv +0 -2
  309. data/test/fixtures/rails_app/tmp/export-posts-20101018183359.csv +0 -2
  310. data/test/fixtures/rails_app/tmp/export-posts-20101018183608.csv +0 -2
  311. data/test/fixtures/rails_app/tmp/export-posts-20101018183759.csv +0 -2
  312. data/test/functional/admin/account_controller_test.rb +0 -90
  313. data/test/functional/admin/assets_controller_test.rb +0 -55
  314. data/test/functional/admin/categories_controller_test.rb +0 -62
  315. data/test/functional/admin/comments_controller_test.rb +0 -21
  316. data/test/functional/admin/dashboard_controller_test.rb +0 -138
  317. data/test/functional/admin/posts_controller_test.rb +0 -548
  318. data/test/functional/admin/session_controller_test.rb +0 -85
  319. data/test/functional/admin/status_controller_test.rb +0 -46
  320. data/test/functional/admin/typus_users_controller_test.rb +0 -159
  321. data/test/helpers/admin/base_helper_test.rb +0 -67
  322. data/test/helpers/admin/dashboard_helper_test.rb +0 -19
  323. data/test/helpers/admin/form_helper_test.rb +0 -117
  324. data/test/helpers/admin/resources_helper_test.rb +0 -64
  325. data/test/helpers/admin/sidebar_helper_test.rb +0 -274
  326. data/test/helpers/admin/table_helper_test.rb +0 -219
  327. data/test/integration/login_test.rb +0 -13
  328. data/test/integration_test_helper.rb +0 -21
  329. data/test/lib/support/active_record_test.rb +0 -86
  330. data/test/lib/support/array_test.rb +0 -11
  331. data/test/lib/support/hash_test.rb +0 -11
  332. data/test/lib/support/string_test.rb +0 -39
  333. data/test/lib/typus/active_record_test.rb +0 -451
  334. data/test/lib/typus/configuration_test.rb +0 -52
  335. data/test/lib/typus/resource_test.rb +0 -17
  336. data/test/lib/typus/routes_test.rb +0 -29
  337. data/test/lib/typus_test.rb +0 -107
  338. data/test/schema.rb +0 -100
  339. data/test/test_helper.rb +0 -16
  340. data/test/unit/admin/mailer_test.rb +0 -32
  341. data/test/unit/typus_user_roles_test.rb +0 -105
  342. data/test/unit/typus_user_test.rb +0 -142
  343. data/typus.gemspec +0 -25
@@ -1,55 +0,0 @@
1
- require "test_helper"
2
-
3
- class Admin::AssetsControllerTest < ActionController::TestCase
4
-
5
- setup do
6
- @request.session[:typus_user_id] = Factory(:typus_user).id
7
- @post = Factory(:post)
8
- end
9
-
10
- should "verify polymorphic relationship message" do
11
- get :new, { :back_to => "/admin/posts/#{@post.id}/edit",
12
- :resource => @post.class.name, :resource_id => @post.id }
13
-
14
- assert_select 'body div#flash', "You're adding a new Asset to Post. Do you want to cancel it?"
15
- assert_select 'body div#flash a', "Do you want to cancel it?"
16
- end
17
-
18
- should "create a polymorphic relationship" do
19
- assert_difference('@post.assets.count') do
20
- post :create, { :back_to => "/admin/posts/edit/#{@post.id}",
21
- :resource => @post.class.name,
22
- :resource_id => @post.id }
23
- end
24
-
25
- assert_response :redirect
26
- assert_redirected_to '/admin/posts/edit/1'
27
- assert_equal "Asset successfully assigned to Post.", flash[:notice]
28
- end
29
-
30
- should "render edit and verify message on polymorphic relationship" do
31
- asset = Factory(:asset)
32
-
33
- get :edit, { :id => asset.id,
34
- :back_to => "/admin/posts/#{@post.id}/edit",
35
- :resource => @post.class.name, :resource_id => @post.id }
36
-
37
- assert_select 'body div#flash', "You're updating a Asset for Post. Do you want to cancel it?"
38
- assert_select 'body div#flash a', "Do you want to cancel it?"
39
- end
40
-
41
- should "return to back_to url" do
42
- asset = Factory(:asset)
43
- back_to = "#assets"
44
-
45
- post :update, { :id => asset.id,
46
- :back_to => back_to,
47
- :resource => @post.class.name,
48
- :resource_id => @post.id }
49
-
50
- assert_response :redirect
51
- assert_redirected_to :action => "edit", :id => asset.id, :back_to => back_to
52
- assert_equal "Asset successfully updated.", flash[:notice]
53
- end
54
-
55
- end
@@ -1,62 +0,0 @@
1
- require File.dirname(__FILE__) + '/../../test_helper'
2
-
3
- class Admin::CategoriesControllerTest < ActionController::TestCase
4
-
5
- setup do
6
- @request.session[:typus_user_id] = Factory(:typus_user).id
7
- @request.env['HTTP_REFERER'] = '/admin/categories'
8
- end
9
-
10
- context "Categories Views" do
11
-
12
- should "verify form partial can overwrited by model" do
13
- get :new
14
- assert_match "categories#_form.html.erb", @response.body
15
- end
16
-
17
- end
18
-
19
- context "Categories List" do
20
-
21
- setup do
22
- @first_category = Factory(:category, :position => 1)
23
- @second_category = Factory(:category, :position => 2)
24
- end
25
-
26
- should "verify referer" do
27
- get :position, { :id => @first_category.id, :go => 'move_lower' }
28
- assert_response :redirect
29
- assert_redirected_to @request.env['HTTP_REFERER']
30
- end
31
-
32
- should "position item one step down" do
33
- get :position, { :id => @first_category.id, :go => 'move_lower' }
34
-
35
- assert_equal "Record moved lower.", flash[:notice]
36
- assert_equal 2, @first_category.reload.position
37
- assert_equal 1, @second_category.reload.position
38
- end
39
-
40
- should "position item one step up" do
41
- get :position, { :id => @second_category.id, :go => 'move_higher' }
42
-
43
- assert_equal "Record moved higher.", flash[:notice]
44
- assert_equal 2, @first_category.reload.position
45
- assert_equal 1, @second_category.reload.position
46
- end
47
-
48
- should "position top item to bottom" do
49
- get :position, { :id => @first_category.id, :go => 'move_to_bottom' }
50
- assert_equal "Record moved to bottom.", flash[:notice]
51
- assert_equal 2, @first_category.reload.position
52
- end
53
-
54
- should "position bottom item to top" do
55
- get :position, { :id => @second_category.id, :go => 'move_to_top' }
56
- assert_equal "Record moved to top.", flash[:notice]
57
- assert_equal 1, @second_category.reload.position
58
- end
59
-
60
- end
61
-
62
- end
@@ -1,21 +0,0 @@
1
- require "test_helper"
2
-
3
- class Admin::CommentsControllerTest < ActionController::TestCase
4
-
5
- setup do
6
- @typus_user = Factory(:typus_user)
7
- @request.session[:typus_user_id] = @typus_user.id
8
- @comment = Factory(:comment)
9
- @request.env['HTTP_REFERER'] = "/admin/comments"
10
- end
11
-
12
- should "toggle" do
13
- get :toggle, { :id => @comment.id, :field => "spam" }
14
-
15
- assert_response :redirect
16
- assert_redirected_to @request.env["HTTP_REFERER"]
17
- assert_equal "Comment spam changed.", flash[:notice]
18
- assert @comment.reload.spam
19
- end
20
-
21
- end
@@ -1,138 +0,0 @@
1
- require "test_helper"
2
-
3
- class Admin::DashboardControllerTest < ActionController::TestCase
4
-
5
- context "When authentication is http_basic" do
6
-
7
- setup do
8
- Typus.stubs(:authentication).returns(:http_basic)
9
- end
10
-
11
- should_eventually "return a 401 message when no credentials sent" do
12
- get :show
13
- assert_response 401
14
- end
15
-
16
- should_eventually "authenticate user" do
17
- @request.env['HTTP_AUTHORIZATION'] = 'Basic ' + Base64::encode64("admin:columbia")
18
- get :show
19
- assert_response :success
20
- end
21
-
22
- end
23
-
24
- context "When authentication is none" do
25
-
26
- setup do
27
- Typus.stubs(:authentication).returns(:none)
28
- end
29
-
30
- should_eventually "render dashboard" do
31
- get :show
32
- assert_response :success
33
- end
34
-
35
- end
36
-
37
- context "Not logged" do
38
-
39
- setup do
40
- @request.session[:typus_user_id] = nil
41
- end
42
-
43
- should "redirect to sign in when not signed in" do
44
- get :show
45
- assert_response :redirect
46
- assert_redirected_to new_admin_session_path
47
- end
48
-
49
- end
50
-
51
- should "verify_a_removed_role_cannot_sign_in" do
52
- typus_user = Factory(:typus_user, :role => "removed")
53
- @request.session[:typus_user_id] = typus_user.id
54
-
55
- get :show
56
-
57
- assert_response :redirect
58
- assert_redirected_to new_admin_session_path
59
- assert_nil @request.session[:typus_user_id]
60
- assert_equal "Role does no longer exists.", flash[:notice]
61
- end
62
-
63
- context "Admin is logged and gets dashboard" do
64
-
65
- setup do
66
- @typus_user = Factory(:typus_user)
67
- @request.session[:typus_user_id] = @typus_user.id
68
- get :show
69
- end
70
-
71
- should "render dashboard" do
72
- assert_response :success
73
- assert_template "show"
74
- end
75
-
76
- should "render admin layout" do
77
- assert_match "layouts/admin", @controller.inspect
78
- end
79
-
80
- should "verify title" do
81
- assert_select "title", "Dashboard"
82
- end
83
-
84
- should "verify link to session sign out" do
85
- link = %(href="/admin/session")
86
- assert_match link, @response.body
87
- end
88
-
89
- should "verify link to edit user" do
90
- link = %(href="/admin/typus_users/edit/#{@request.session[:typus_user_id]})
91
- assert_match link, @response.body
92
- end
93
-
94
- should "verify resources have a link to new" do
95
- %w( typus_users posts pages assets ).each { |r| assert_match "/admin/#{r}/new", @response.body }
96
- end
97
-
98
- should "verify tableless resources do have link to new" do
99
- %w( statuses orders ).each { |r| assert_no_match /\/admin\/#{r}\n/, @response.body }
100
- end
101
-
102
- should "verify we can set our own partials" do
103
- partials = %w( _sidebar.html.erb )
104
- partials.each { |p| assert_match p, @response.body }
105
- end
106
-
107
- should "block users_on_the_fly" do
108
- @typus_user.status = false
109
- @typus_user.save
110
-
111
- get :show
112
-
113
- assert_response :redirect
114
- assert_redirected_to new_admin_session_path
115
- assert_equal "Typus user has been disabled.", flash[:notice]
116
- assert_nil @request.session[:typus_user_id]
117
- end
118
-
119
- end
120
-
121
- context "When designer is logged in" do
122
-
123
- setup do
124
- @request.session[:typus_user_id] = Factory(:typus_user, :role => "designer").id
125
- get :show
126
- end
127
-
128
- should "not have links to new posts" do
129
- assert_no_match /\/admin\/posts\/new/, @response.body
130
- end
131
-
132
- should "not have links to new typus_users" do
133
- assert_no_match /\/admin\/typus_users\/new/, @response.body
134
- end
135
-
136
- end
137
-
138
- end
@@ -1,548 +0,0 @@
1
- require "test_helper"
2
-
3
- class Admin::PostsControllerTest < ActionController::TestCase
4
-
5
- setup do
6
- @typus_user = Factory(:typus_user)
7
- @request.session[:typus_user_id] = @typus_user.id
8
- @post = Factory(:post)
9
- end
10
-
11
- teardown do
12
- Post.delete_all
13
- TypusUser.delete_all
14
- end
15
-
16
- ##############################################################################
17
- #
18
- ##############################################################################
19
-
20
- context "CRUD" do
21
-
22
- should "render index" do
23
- get :index
24
- assert_response :success
25
- assert_template 'index'
26
- end
27
-
28
- should "render new" do
29
- get :new
30
- assert_response :success
31
- assert_template 'new'
32
- end
33
-
34
- should "create" do
35
- assert_difference('Post.count') do
36
- post :create, { :post => { :title => 'This is another title', :body => 'Body' } }
37
- assert_response :redirect
38
- assert_redirected_to :controller => 'admin/posts', :action => 'edit', :id => Post.last
39
- end
40
- end
41
-
42
- should "render show" do
43
- get :show, { :id => @post.id }
44
- assert_response :success
45
- assert_template 'show'
46
- end
47
-
48
- should "render edit" do
49
- get :edit, { :id => @post.id }
50
- assert_response :success
51
- assert_template 'edit'
52
- end
53
-
54
- should "update" do
55
- post :update, { :id => @post.id, :title => 'Updated' }
56
- assert_response :redirect
57
- assert_redirected_to :controller => 'admin/posts', :action => 'edit', :id => @post.id
58
- end
59
-
60
- end
61
-
62
- context "Forms" do
63
-
64
- setup do
65
- get :new
66
- end
67
-
68
- should "verify forms" do
69
- assert_select "form"
70
- end
71
-
72
- # We have 3 inputs: 1 hidden which is the UTF8 stuff, one which is the
73
- # Post#title and finally the submit button.
74
- should "have 3 inputs" do
75
- assert_select "form input", 3
76
-
77
- # Post#title: Input
78
- assert_select 'label[for="post_title"]'
79
- assert_select 'input#post_title[type="text"]'
80
- end
81
-
82
- should "have 1 textarea" do
83
- assert_select "form textarea", 1
84
-
85
- # Post#body: Text Area
86
- assert_select 'label[for="post_body"]'
87
- assert_select 'textarea#post_body'
88
- end
89
-
90
- should "have 6 selectors" do
91
- assert_select "form select", 6
92
-
93
- # Post#created_at: Datetime
94
- assert_select 'label[for="post_created_at"]'
95
- assert_select 'select#post_created_at_1i'
96
- assert_select 'select#post_created_at_2i'
97
- assert_select 'select#post_created_at_3i'
98
- assert_select 'select#post_created_at_4i'
99
- assert_select 'select#post_created_at_5i'
100
-
101
- # Post#status: Selector
102
- assert_select 'label[for="post_status"]'
103
- assert_select 'select#post_status'
104
- end
105
-
106
- should "have 1 template" do
107
- assert_match "templates#datepicker_template_published_at", @response.body
108
- end
109
-
110
- end
111
-
112
- context "Overwrite action_after_save" do
113
-
114
- setup do
115
- Typus::Resources.expects(:action_after_save).returns("index")
116
- end
117
-
118
- should "create an item and redirect to index" do
119
- assert_difference('Post.count') do
120
- post :create, { :post => { :title => 'This is another title', :body => 'Body' } }
121
- assert_response :redirect
122
- assert_redirected_to :action => 'index'
123
- end
124
- end
125
-
126
- should "update an item and redirect to index" do
127
- post :update, { :id => Factory(:post).id, :title => 'Updated' }
128
- assert_response :redirect
129
- assert_redirected_to :action => 'index'
130
- end
131
-
132
- end
133
-
134
- context "Formats" do
135
-
136
- should "render index and return xml" do
137
- expected = <<-RAW
138
- <?xml version="1.0" encoding="UTF-8"?>
139
- <posts type="array">
140
- <post>
141
- <title>#{@post.title}</title>
142
- <status>#{@post.status}</status>
143
- </post>
144
- </posts>
145
- RAW
146
-
147
- get :index, :format => "xml"
148
-
149
- assert_response :success
150
- assert_equal expected, @response.body
151
- end
152
-
153
- should "render index and return csv" do
154
- expected = <<-RAW
155
- title;status
156
- #{@post.title};#{@post.status}
157
- RAW
158
-
159
- get :index, :format => "csv"
160
-
161
- assert_response :success
162
- assert_equal expected, @response.body
163
- end
164
-
165
- end
166
-
167
- context "Permissions" do
168
-
169
- context "Root" do
170
-
171
- setup do
172
- editor = Factory(:typus_user, :email => "editor@example.com", :role => "editor")
173
- @post = Factory(:post, :typus_user => editor)
174
- end
175
-
176
- should "verify_root_can_edit_any_record" do
177
- Post.all.each do |post|
178
- get :edit, { :id => post.id }
179
- assert_response :success
180
- assert_template 'edit'
181
- end
182
- end
183
-
184
- should "verify_admin_updating_an_item_does_not_change_typus_user_id_if_not_defined" do
185
- post :update, { :id => @post.id, :post => { :title => 'Updated by admin' } }
186
- post_updated = Post.find(@post.id)
187
- assert_equal @post.typus_user_id, post_updated.typus_user_id
188
- end
189
-
190
- should "verify_admin_updating_an_item_does_change_typus_user_id_to_whatever_admin_wants" do
191
- post :update, { :id => @post.id, :post => { :title => 'Updated', :typus_user_id => 108 } }
192
- post_updated = Post.find(@post.id)
193
- assert_equal 108, post_updated.typus_user_id
194
- end
195
-
196
- end
197
-
198
- context "No root" do
199
-
200
- setup do
201
- @typus_user = Factory(:typus_user, :email => "editor@example.com", :role => "editor")
202
- @request.session[:typus_user_id] = @typus_user.id
203
- @request.env['HTTP_REFERER'] = '/admin/posts'
204
- end
205
-
206
- should "not be root" do
207
- assert @typus_user.is_not_root?
208
- end
209
-
210
- should "verify_editor_can_show_any_record" do
211
- Post.all.each do |post|
212
- get :show, { :id => post.id }
213
- assert_response :success
214
- assert_template 'show'
215
- end
216
- end
217
-
218
- should "verify_editor_tried_to_edit_a_post_owned_by_himself" do
219
- post_ = Factory(:post, :typus_user => @typus_user)
220
- get :edit, { :id => post_.id }
221
- assert_response :success
222
- end
223
-
224
- should "verify_editor_tries_to_edit_a_post_owned_by_the_admin" do
225
- get :edit, { :id => Factory(:post).id }
226
-
227
- assert_response :redirect
228
- assert_redirected_to @request.env['HTTP_REFERER']
229
- assert_equal "You don't have permission to access this item.", flash[:alert]
230
- end
231
-
232
- should "verify_editor_tries_to_show_a_post_owned_by_the_admin" do
233
- get :show, { :id => Factory(:post).id }
234
- assert_response :success
235
- end
236
-
237
- should "verify_editor_tries_to_show_a_post_owned_by_the_admin whe only user items" do
238
- Typus::Resources.expects(:only_user_items).returns(true)
239
- post = Factory(:post)
240
- get :show, { :id => post.id }
241
-
242
- assert_response :redirect
243
- assert_redirected_to @request.env['HTTP_REFERER']
244
- assert_equal "You don't have permission to access this item.", flash[:alert]
245
- end
246
-
247
- should "verify_typus_user_id_of_item_when_creating_record" do
248
- post :create, { :post => { :title => "Chunky Bacon", :body => "Lorem ipsum ..." } }
249
- post_ = Post.find_by_title("Chunky Bacon")
250
-
251
- assert_equal @request.session[:typus_user_id], post_.typus_user_id
252
- end
253
-
254
- should "verify_editor_updating_an_item_does_not_change_typus_user_id" do
255
- [ 108, nil ].each do |typus_user_id|
256
- post_ = Factory(:post, :typus_user => @typus_user)
257
- post :update, { :id => post_.id, :post => { :title => 'Updated', :typus_user_id => @typus_user.id } }
258
- post_updated = Post.find(post_.id)
259
- assert_equal @request.session[:typus_user_id], post_updated.typus_user_id
260
- end
261
- end
262
-
263
- end
264
-
265
- end
266
-
267
- context "Roles" do
268
-
269
- setup do
270
- @request.env['HTTP_REFERER'] = '/admin/posts'
271
- end
272
-
273
- context "Admin" do
274
-
275
- should "be able to add posts" do
276
- assert @typus_user.can?("create", "Post")
277
- end
278
-
279
- should "be able to destroy posts" do
280
- get :destroy, { :id => Factory(:post).id, :method => :delete }
281
-
282
- assert_response :redirect
283
- assert_equal "Post successfully removed.", flash[:notice]
284
- assert_redirected_to :action => :index
285
- end
286
-
287
- end
288
-
289
- context "Designer" do
290
-
291
- setup do
292
- Typus.user_class.delete_all
293
- @designer = Factory(:typus_user, :role => "designer")
294
- @request.session[:typus_user_id] = @designer.id
295
- @post = Factory(:post)
296
- end
297
-
298
- should "not be able to add posts" do
299
- get :new
300
-
301
- assert_response :redirect
302
- assert_equal "Designer can't perform action. (new)", flash[:notice]
303
- assert_redirected_to :action => :index
304
- end
305
-
306
- should "not_be_able_to_destroy_posts" do
307
- assert_no_difference('Post.count') do
308
- get :destroy, { :id => @post.id, :method => :delete }
309
- end
310
- assert_response :redirect
311
- assert_equal "You don't have permission to access this item.", flash[:alert]
312
- assert_redirected_to :action => :index
313
- end
314
-
315
- end
316
-
317
- end
318
-
319
- context "Relationships" do
320
-
321
- ##
322
- # Post => has_many :comments
323
- ##
324
-
325
- should "relate_comment_with_post_and_then_unrelate" do
326
-
327
- comment = Factory(:comment, :post => nil)
328
- post_ = Factory(:post)
329
- @request.env['HTTP_REFERER'] = "/admin/posts/edit/#{post_.id}#comments"
330
-
331
- assert_difference('post_.comments.count') do
332
- post :relate, { :id => post_.id,
333
- :related => { :model => 'Comment', :id => comment.id } }
334
- end
335
-
336
- assert_response :redirect
337
- assert_redirected_to @request.env['HTTP_REFERER']
338
- assert_equal "Comment related to Post", flash[:notice]
339
-
340
- assert_difference('post_.comments.count', -1) do
341
- post :unrelate, { :id => post_.id,
342
- :resource => 'Comment', :resource_id => comment.id }
343
- end
344
-
345
- assert_response :redirect
346
- assert_redirected_to @request.env['HTTP_REFERER']
347
- assert_equal "Comment unrelated from Post", flash[:notice]
348
-
349
- end
350
-
351
- ##
352
- # Post => has_and_belongs_to_many :categories
353
- ##
354
-
355
- should "relate_category_with_post_and_then_unrelate" do
356
- category = Factory(:category)
357
- post_ = Factory(:post)
358
- @request.env['HTTP_REFERER'] = "/admin/posts/edit/#{post_.id}#categories"
359
-
360
- ##
361
- # First Step: Relate
362
- #
363
-
364
- assert_difference('category.posts.count') do
365
- post :relate, { :id => post_.id, :related => { :model => 'Category', :id => category.id } }
366
- end
367
-
368
- assert_response :redirect
369
- assert_redirected_to @request.env['HTTP_REFERER']
370
- assert_equal "Category related to Post", flash[:notice]
371
-
372
- ##
373
- # Second Step: Unrelate
374
- #
375
-
376
- assert_difference('category.posts.count', -1) do
377
- post :unrelate, { :id => post_.id, :resource => 'Category', :resource_id => category.id }
378
- end
379
-
380
- assert_response :redirect
381
- assert_redirected_to @request.env['HTTP_REFERER']
382
- assert_equal "Category unrelated from Post", flash[:notice]
383
- end
384
-
385
- ##
386
- # Post => has_many :assets, :as => resource (Polimorphic)
387
- ##
388
-
389
- should "relate_asset_with_post_and_then_unrelate" do
390
- post_ = Factory(:post)
391
- asset = Factory(:asset)
392
- post_.assets << asset
393
-
394
- @request.env['HTTP_REFERER'] = "/admin/posts/edit/#{post_.id}#assets"
395
-
396
- assert_difference('post_.assets.count', -1) do
397
- get :unrelate, { :id => post_.id, :resource => 'Asset', :resource_id => asset.id }
398
- end
399
- assert_response :redirect
400
- assert_redirected_to @request.env['HTTP_REFERER']
401
- assert_equal "Asset unrelated from Post", flash[:notice]
402
- end
403
-
404
- end
405
-
406
- context "Views" do
407
-
408
- context "Index" do
409
-
410
- setup do
411
- get :index
412
- end
413
-
414
- should "render index and validates_presence_of_custom_partials" do
415
- assert_match "posts#_index.html.erb", @response.body
416
- end
417
-
418
- should "render_index_and_verify_page_title" do
419
- assert_select "title", "Posts"
420
- end
421
-
422
- should "render index_and_show_add_entry_link" do
423
- assert_select "#sidebar ul" do
424
- assert_select "li", "Add new"
425
- end
426
- end
427
-
428
- should "render_index_and_show_trash_item_image" do
429
- assert_response :success
430
- assert_select '.trash', 'Trash'
431
- end
432
-
433
- end
434
-
435
- context "New" do
436
-
437
- setup do
438
- get :new
439
- end
440
-
441
- should "render new and partials_on_new" do
442
- assert_match "posts#_new.html.erb", @response.body
443
- end
444
-
445
- should "render new and verify page title" do
446
- assert_select "title", "New Post"
447
- end
448
-
449
- end
450
-
451
- context "Edit" do
452
-
453
- setup do
454
- get :edit, { :id => Factory(:post).id }
455
- end
456
-
457
- should "render_edit_and_verify_presence_of_custom_partials" do
458
- assert_match "posts#_edit.html.erb", @response.body
459
- end
460
-
461
- should "render_edit_and_verify_page_title" do
462
- assert_select "title", "Edit Post"
463
- end
464
-
465
- end
466
-
467
- context "Show" do
468
-
469
- setup do
470
- get :show, { :id => Factory(:post).id }
471
- end
472
-
473
- should "render_show_and_verify_presence_of_custom_partials" do
474
- assert_match "posts#_show.html.erb", @response.body
475
- end
476
-
477
- should "render_show_and_verify_page_title" do
478
- assert_select "title", "Show Post"
479
- end
480
-
481
- end
482
-
483
- should "get_index_and_render_edit_or_show_links" do
484
- %w(edit show).each do |action|
485
- Typus::Resources.expects(:default_action_on_item).at_least_once.returns(action)
486
- get :index
487
- Post.all.each do |post|
488
- assert_match "/posts/#{action}/#{post.id}", @response.body
489
- end
490
- end
491
- end
492
-
493
- context "Designer" do
494
-
495
- setup do
496
- @typus_user = Factory(:typus_user, :email => "designer@example.com", :role => "designer")
497
- @request.session[:typus_user_id] = @typus_user.id
498
- end
499
-
500
- should "render_index_and_not_show_add_entry_link" do
501
- get :index
502
- assert_response :success
503
- assert_no_match /Add Post/, @response.body
504
- end
505
-
506
- should "render_index_and_not_show_trash_image" do
507
- get :index
508
- assert_response :success
509
- assert_select ".trash", false
510
- end
511
-
512
- end
513
-
514
- context "Editor" do
515
-
516
- setup do
517
- @typus_user = Factory(:typus_user, :email => "editor@example.com", :role => "editor")
518
- @request.session[:typus_user_id] = @typus_user.id
519
- end
520
-
521
- should "get_index_and_render_edit_or_show_links_on_owned_records" do
522
- get :index
523
- Post.all.each do |post|
524
- action = post.owned_by?(@typus_user) ? "edit" : "show"
525
- assert_match "/posts/#{action}/#{post.id}", @response.body
526
- end
527
- end
528
-
529
- should "get_index_and_render_edit_or_show_on_only_user_items" do
530
- %w(edit show).each do |action|
531
- Typus::Resources.stubs(:only_user_items).returns(true)
532
- Typus::Resources.stubs(:default_action_on_item).returns(action)
533
- get :index
534
- Post.all.each do |post|
535
- if post.owned_by?(@typus_user)
536
- assert_match "/posts/#{action}/#{post.id}", @response.body
537
- else
538
- assert_no_match /\/posts\/#{action}\/#{post.id}/, @response.body
539
- end
540
- end
541
- end
542
- end
543
-
544
- end
545
-
546
- end
547
-
548
- end