typus 3.0.12 → 3.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (339) hide show
  1. data/Gemfile +10 -16
  2. data/README.md +7 -10
  3. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/blank.gif +0 -0
  4. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_close.png +0 -0
  5. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_loading.png +0 -0
  6. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_nav_left.png +0 -0
  7. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_nav_right.png +0 -0
  8. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_shadow_e.png +0 -0
  9. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_shadow_n.png +0 -0
  10. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_shadow_ne.png +0 -0
  11. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_shadow_nw.png +0 -0
  12. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_shadow_s.png +0 -0
  13. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_shadow_se.png +0 -0
  14. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_shadow_sw.png +0 -0
  15. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_shadow_w.png +0 -0
  16. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_title_left.png +0 -0
  17. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_title_main.png +0 -0
  18. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_title_over.png +0 -0
  19. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancy_title_right.png +0 -0
  20. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancybox-x.png +0 -0
  21. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancybox-y.png +0 -0
  22. data/app/assets/{vendor/typus/vendor/jquery.fancybox-1.3.4/fancybox → images/typus}/fancybox.png +0 -0
  23. data/app/assets/javascripts/typus/application.js +7 -0
  24. data/app/assets/{vendor/typus/javascripts/application.js → javascripts/typus/custom.js} +0 -0
  25. data/app/assets/{vendor/typus/javascripts → javascripts/typus}/jquery.application.js +6 -8
  26. data/app/assets/{vendor/typus/javascripts → javascripts/typus}/jquery.rails.autocomplete.js +0 -0
  27. data/app/assets/{vendor/typus/javascripts → javascripts/typus}/jquery.searchField.js +0 -0
  28. data/app/assets/stylesheets/typus/application.css +7 -0
  29. data/app/assets/{vendor/typus/stylesheets/application.css → stylesheets/typus/custom.css} +0 -0
  30. data/app/assets/stylesheets/typus/pagination.css +17 -0
  31. data/app/assets/{vendor/typus/stylesheets → stylesheets/typus}/reset.css +0 -0
  32. data/app/assets/{vendor/typus/stylesheets → stylesheets/typus}/screen.css +2 -27
  33. data/app/assets/vendor/{typus/vendor/jquery-tokeninput → jquery-tokeninput}/css/token-input-facebook.css +0 -0
  34. data/app/assets/vendor/{typus/vendor/jquery-tokeninput → jquery-tokeninput}/css/token-input-mac.css +0 -0
  35. data/app/assets/vendor/{typus/vendor/jquery-tokeninput → jquery-tokeninput}/css/token-input.css +0 -0
  36. data/app/assets/vendor/{typus/vendor/jquery-tokeninput → jquery-tokeninput}/js/jquery.tokeninput.js +0 -0
  37. data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  38. data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  39. data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
  40. data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  41. data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  42. data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  43. data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  44. data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  45. data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  46. data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
  47. data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
  48. data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
  49. data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
  50. data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
  51. data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/css/ui-lightness/jquery-ui-1.8.12.custom.css +0 -0
  52. data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/index.html +0 -0
  53. data/app/assets/vendor/{typus/vendor/jquery-ui-1.8.12.custom → jquery-ui-1.8.12.custom}/js/jquery-ui-1.8.12.custom.min.js +0 -0
  54. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/blank.gif +0 -0
  55. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_close.png +0 -0
  56. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_loading.png +0 -0
  57. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_nav_left.png +0 -0
  58. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_nav_right.png +0 -0
  59. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_shadow_e.png +0 -0
  60. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_shadow_n.png +0 -0
  61. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_shadow_ne.png +0 -0
  62. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_shadow_nw.png +0 -0
  63. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_shadow_s.png +0 -0
  64. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_shadow_se.png +0 -0
  65. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_shadow_sw.png +0 -0
  66. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_shadow_w.png +0 -0
  67. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_title_left.png +0 -0
  68. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_title_main.png +0 -0
  69. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_title_over.png +0 -0
  70. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancy_title_right.png +0 -0
  71. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancybox-x.png +0 -0
  72. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancybox-y.png +0 -0
  73. data/app/assets/vendor/jquery.fancybox-1.3.4/fancybox/fancybox.png +0 -0
  74. data/app/assets/vendor/{typus/vendor/jquery.fancybox-1.3.4 → jquery.fancybox-1.3.4}/fancybox/jquery.easing-1.3.pack.js +0 -0
  75. data/app/assets/vendor/{typus/vendor/jquery.fancybox-1.3.4 → jquery.fancybox-1.3.4}/fancybox/jquery.fancybox-1.3.4.css +0 -0
  76. data/app/assets/vendor/{typus/vendor/jquery.fancybox-1.3.4 → jquery.fancybox-1.3.4}/fancybox/jquery.fancybox-1.3.4.js +0 -0
  77. data/app/assets/vendor/{typus/vendor/jquery.fancybox-1.3.4 → jquery.fancybox-1.3.4}/fancybox/jquery.fancybox-1.3.4.pack.js +0 -0
  78. data/app/assets/vendor/{typus/vendor/jquery.fancybox-1.3.4 → jquery.fancybox-1.3.4}/fancybox/jquery.mousewheel-3.0.4.pack.js +0 -0
  79. data/app/controllers/admin/base_controller.rb +5 -3
  80. data/app/controllers/admin/resources_controller.rb +3 -7
  81. data/app/controllers/admin/session_controller.rb +2 -5
  82. data/app/helpers/admin/base_helper.rb +1 -1
  83. data/app/helpers/admin/display_helper.rb +0 -2
  84. data/app/helpers/admin/file_preview_helper.rb +10 -10
  85. data/app/helpers/admin/filters_helper.rb +1 -1
  86. data/app/helpers/admin/relationships_helper.rb +20 -21
  87. data/app/helpers/admin/sidebar_helper.rb +1 -8
  88. data/app/helpers/admin/table_helper.rb +8 -8
  89. data/app/views/admin/dashboard/_applications.html.erb +1 -1
  90. data/app/views/admin/helpers/base/_apps.html.erb +2 -7
  91. data/app/views/admin/helpers/base/_header.html.erb +1 -1
  92. data/app/views/admin/helpers/resources/_errors.html.erb +1 -1
  93. data/app/views/admin/helpers/sidebar/_sidebar.html.erb +1 -1
  94. data/app/views/admin/resources/index.html.erb +4 -4
  95. data/app/views/admin/shared/_head.html.erb +2 -17
  96. data/app/views/admin/templates/_belongs_to_with_autocomplete.html.erb +1 -1
  97. data/app/views/admin/templates/_has_n.html.erb +3 -3
  98. data/app/views/admin/templates/_has_one.html.erb +2 -2
  99. data/app/views/admin/templates/_selector.html.erb +7 -2
  100. data/config/locales/typus.ca.yml +1 -1
  101. data/config/locales/typus.de.models.yml +5 -6
  102. data/config/locales/typus.de.yml +36 -39
  103. data/config/locales/typus.el.yml +1 -1
  104. data/config/locales/typus.es.yml +1 -1
  105. data/config/locales/typus.fr.yml +1 -2
  106. data/config/locales/typus.hu.yml +1 -1
  107. data/config/locales/typus.locale.yml.template +1 -1
  108. data/config/locales/typus.pt-BR.yml +1 -1
  109. data/config/locales/typus.ru.yml +1 -1
  110. data/config/locales/typus.zh-CN.yml +1 -1
  111. data/config/routes.rb +2 -2
  112. data/lib/generators/templates/config/initializers/typus.rb +1 -3
  113. data/lib/generators/templates/config/typus/README +0 -1
  114. data/lib/generators/typus/migration_generator.rb +0 -3
  115. data/lib/support/active_record.rb +7 -9
  116. data/lib/typus.rb +7 -8
  117. data/lib/typus/authentication/session.rb +3 -2
  118. data/lib/typus/controller/associations.rb +2 -2
  119. data/lib/typus/controller/format.rb +3 -3
  120. data/lib/typus/engine.rb +2 -6
  121. data/lib/typus/i18n.rb +4 -0
  122. data/lib/typus/orm/active_record/admin_user_v1.rb +13 -12
  123. data/lib/typus/orm/active_record/admin_user_v2.rb +31 -1
  124. data/lib/typus/orm/active_record/class_methods.rb +1 -0
  125. data/lib/typus/orm/base.rb +0 -4
  126. data/lib/typus/regex.rb +2 -0
  127. data/lib/typus/version.rb +1 -1
  128. data/test/app/controllers/admin/account_controller_test.rb +94 -0
  129. data/test/app/controllers/admin/assets_controller_test.rb +156 -0
  130. data/test/app/controllers/admin/base_controller_test.rb +25 -0
  131. data/test/app/controllers/admin/birds_controller_test.rb +33 -0
  132. data/test/app/controllers/admin/cases_controller_test.rb +20 -0
  133. data/test/app/controllers/admin/categories_controller_test.rb +134 -0
  134. data/test/app/controllers/admin/comments_controller_test.rb +71 -0
  135. data/test/app/controllers/admin/dashboard_controller_test.rb +150 -0
  136. data/test/app/controllers/admin/image_holders_controller_test.rb +74 -0
  137. data/test/app/controllers/admin/invoices_controller_test.rb +77 -0
  138. data/test/app/controllers/admin/orders_controller_test.rb +17 -0
  139. data/test/app/controllers/admin/pages_controller_test.rb +33 -0
  140. data/test/app/controllers/admin/posts_controller_test.rb +764 -0
  141. data/test/app/controllers/admin/projects_controller_test.rb +48 -0
  142. data/test/app/controllers/admin/session_controller_test.rb +91 -0
  143. data/test/app/controllers/admin/status_controller_test.rb +33 -0
  144. data/test/app/controllers/admin/typus_users_controller_test.rb +154 -0
  145. data/test/app/controllers/admin/users_controller_test.rb +101 -0
  146. data/test/app/controllers/admin/views_controller_test.rb +36 -0
  147. data/test/app/helpers/admin/base_helper_test.rb +75 -0
  148. data/test/app/helpers/admin/dashboard_helper_test.rb +28 -0
  149. data/test/app/helpers/admin/file_preview_helper_test.rb +90 -0
  150. data/test/app/helpers/admin/filters_helper_test.rb +166 -0
  151. data/test/app/helpers/admin/form_helper_test.rb +126 -0
  152. data/test/app/helpers/admin/list_helper_test.rb +76 -0
  153. data/test/app/helpers/admin/relationships_helper_test.rb +19 -0
  154. data/test/app/helpers/admin/resources_helper_test.rb +46 -0
  155. data/test/app/helpers/admin/search_helper_test.rb +56 -0
  156. data/test/app/helpers/admin/sidebar_helper_test.rb +20 -0
  157. data/test/app/helpers/admin/table_helper_test.rb +245 -0
  158. data/test/app/mailers/admin/mailer_test.rb +20 -0
  159. data/test/app/models/admin_user_test.rb +22 -0
  160. data/test/app/models/typus_user_roles_test.rb +125 -0
  161. data/test/app/models/typus_user_test.rb +145 -0
  162. data/test/app/models/user_test.rb +38 -0
  163. data/test/config/routes_test.rb +30 -0
  164. data/test/factories.rb +134 -0
  165. data/test/fixtures/config/broken/application.yml +68 -0
  166. data/test/fixtures/config/broken/application_roles.yml +20 -0
  167. data/test/fixtures/config/broken/empty.yml +0 -0
  168. data/test/fixtures/config/broken/empty_roles.yml +0 -0
  169. data/test/fixtures/config/broken/undefined.yml +3 -0
  170. data/test/fixtures/config/broken/undefined_roles.yml +6 -0
  171. data/test/fixtures/config/default/typus.yml +13 -0
  172. data/test/fixtures/config/default/typus_roles.yml +2 -0
  173. data/test/fixtures/config/empty/empty_01.yml +0 -0
  174. data/test/fixtures/config/empty/empty_01_roles.yml +0 -0
  175. data/test/fixtures/config/empty/empty_02.yml +0 -0
  176. data/test/fixtures/config/empty/empty_02_roles.yml +0 -0
  177. data/test/fixtures/config/locales/es.yml +10 -0
  178. data/test/fixtures/config/namespaced/application.yml +5 -0
  179. data/test/fixtures/config/namespaced/application_roles.yml +2 -0
  180. data/test/fixtures/config/ordered/001_roles.yml +2 -0
  181. data/test/fixtures/config/ordered/002_roles.yml +2 -0
  182. data/test/fixtures/config/unordered/app_one_roles.yml +2 -0
  183. data/test/fixtures/config/unordered/app_two_roles.yml +2 -0
  184. data/test/fixtures/rails_app/.gitignore +4 -0
  185. data/test/fixtures/rails_app/Capfile +7 -0
  186. data/test/fixtures/rails_app/README +256 -0
  187. data/test/fixtures/rails_app/Rakefile +7 -0
  188. data/test/fixtures/rails_app/app/controllers/admin/admin_users_controller.rb +2 -0
  189. data/test/fixtures/rails_app/app/controllers/admin/animals_controller.rb +2 -0
  190. data/test/fixtures/rails_app/app/controllers/admin/article/entries_controller.rb +2 -0
  191. data/test/fixtures/rails_app/app/controllers/admin/assets_controller.rb +51 -0
  192. data/test/fixtures/rails_app/app/controllers/admin/birds_controller.rb +2 -0
  193. data/test/fixtures/rails_app/app/controllers/admin/cases_controller.rb +2 -0
  194. data/test/fixtures/rails_app/app/controllers/admin/categories_controller.rb +2 -0
  195. data/test/fixtures/rails_app/app/controllers/admin/comments_controller.rb +2 -0
  196. data/test/fixtures/rails_app/app/controllers/admin/dogs_controller.rb +2 -0
  197. data/test/fixtures/rails_app/app/controllers/admin/entries_controller.rb +2 -0
  198. data/test/fixtures/rails_app/app/controllers/admin/hits_controller.rb +37 -0
  199. data/test/fixtures/rails_app/app/controllers/admin/image_holders_controller.rb +2 -0
  200. data/test/fixtures/rails_app/app/controllers/admin/invoices_controller.rb +2 -0
  201. data/test/fixtures/rails_app/app/controllers/admin/orders_controller.rb +2 -0
  202. data/test/fixtures/rails_app/app/controllers/admin/pages_controller.rb +7 -0
  203. data/test/fixtures/rails_app/app/controllers/admin/posts_controller.rb +2 -0
  204. data/test/fixtures/rails_app/app/controllers/admin/project_collaborators_controller.rb +2 -0
  205. data/test/fixtures/rails_app/app/controllers/admin/projects_controller.rb +2 -0
  206. data/test/fixtures/rails_app/app/controllers/admin/status_controller.rb +2 -0
  207. data/test/fixtures/rails_app/app/controllers/admin/typus_users_controller.rb +2 -0
  208. data/test/fixtures/rails_app/app/controllers/admin/users_controller.rb +2 -0
  209. data/test/fixtures/rails_app/app/controllers/admin/views_controller.rb +8 -0
  210. data/test/fixtures/rails_app/app/controllers/admin/watch_dog_controller.rb +2 -0
  211. data/test/fixtures/rails_app/app/controllers/application_controller.rb +3 -0
  212. data/test/fixtures/rails_app/app/helpers/application_helper.rb +2 -0
  213. data/test/fixtures/rails_app/app/helpers/form_helper.rb +3 -0
  214. data/test/fixtures/rails_app/app/models/admin_user.rb +7 -0
  215. data/test/fixtures/rails_app/app/models/animal.rb +21 -0
  216. data/test/fixtures/rails_app/app/models/article.rb +10 -0
  217. data/test/fixtures/rails_app/app/models/article/entry.rb +2 -0
  218. data/test/fixtures/rails_app/app/models/asset.rb +45 -0
  219. data/test/fixtures/rails_app/app/models/bird.rb +2 -0
  220. data/test/fixtures/rails_app/app/models/case.rb +2 -0
  221. data/test/fixtures/rails_app/app/models/category.rb +31 -0
  222. data/test/fixtures/rails_app/app/models/comment.rb +17 -0
  223. data/test/fixtures/rails_app/app/models/delayed/task.rb +5 -0
  224. data/test/fixtures/rails_app/app/models/dog.rb +2 -0
  225. data/test/fixtures/rails_app/app/models/entry.rb +23 -0
  226. data/test/fixtures/rails_app/app/models/hit.rb +27 -0
  227. data/test/fixtures/rails_app/app/models/image_holder.rb +21 -0
  228. data/test/fixtures/rails_app/app/models/invoice.rb +10 -0
  229. data/test/fixtures/rails_app/app/models/order.rb +9 -0
  230. data/test/fixtures/rails_app/app/models/page.rb +24 -0
  231. data/test/fixtures/rails_app/app/models/post.rb +32 -0
  232. data/test/fixtures/rails_app/app/models/project.rb +17 -0
  233. data/test/fixtures/rails_app/app/models/project_collaborator.rb +16 -0
  234. data/test/fixtures/rails_app/app/models/site.rb +16 -0
  235. data/test/fixtures/rails_app/app/models/typus_user.rb +15 -0
  236. data/test/fixtures/rails_app/app/models/user.rb +16 -0
  237. data/test/fixtures/rails_app/app/models/view.rb +19 -0
  238. data/test/fixtures/rails_app/app/views/admin/assets/_index.html.erb +3 -0
  239. data/test/fixtures/rails_app/app/views/admin/cases/_index.html.erb +3 -0
  240. data/test/fixtures/rails_app/app/views/admin/categories/_index.html.erb +3 -0
  241. data/test/fixtures/rails_app/app/views/admin/dashboard/_sidebar.html.erb +11 -0
  242. data/test/fixtures/rails_app/app/views/admin/entries/_index.html.erb +3 -0
  243. data/test/fixtures/rails_app/app/views/admin/hits/_edit.html.erb +7 -0
  244. data/test/fixtures/rails_app/app/views/admin/hits/_index.html.erb +3 -0
  245. data/test/fixtures/rails_app/app/views/admin/hits/index.html.erb +28 -0
  246. data/test/fixtures/rails_app/app/views/admin/pages/_index.html.erb +3 -0
  247. data/test/fixtures/rails_app/app/views/admin/posts/_edit.html.erb +1 -0
  248. data/test/fixtures/rails_app/app/views/admin/posts/_index.html.erb +5 -0
  249. data/test/fixtures/rails_app/app/views/admin/posts/_new.html.erb +1 -0
  250. data/test/fixtures/rails_app/app/views/admin/posts/_show.html.erb +1 -0
  251. data/test/fixtures/rails_app/app/views/admin/resources/_sidebar.html.erb +1 -0
  252. data/test/fixtures/rails_app/app/views/admin/status/index.html.erb +9 -0
  253. data/test/fixtures/rails_app/app/views/admin/templates/_datepicker.html.erb +1 -0
  254. data/test/fixtures/rails_app/app/views/admin/watch_dog/index.html.erb +9 -0
  255. data/test/fixtures/rails_app/config.ru +4 -0
  256. data/test/fixtures/rails_app/config/application.rb +55 -0
  257. data/test/fixtures/rails_app/config/boot.rb +6 -0
  258. data/test/fixtures/rails_app/config/database.yml +42 -0
  259. data/test/fixtures/rails_app/config/deploy.rb +36 -0
  260. data/test/fixtures/rails_app/config/environment.rb +5 -0
  261. data/test/fixtures/rails_app/config/environments/development.rb +38 -0
  262. data/test/fixtures/rails_app/config/environments/production.rb +57 -0
  263. data/test/fixtures/rails_app/config/environments/test.rb +44 -0
  264. data/test/fixtures/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  265. data/test/fixtures/rails_app/config/initializers/dragonfly.rb +1 -0
  266. data/test/fixtures/rails_app/config/initializers/inflections.rb +11 -0
  267. data/test/fixtures/rails_app/config/initializers/mime_types.rb +5 -0
  268. data/test/fixtures/rails_app/config/initializers/secret_token.rb +7 -0
  269. data/test/fixtures/rails_app/config/initializers/session_store.rb +8 -0
  270. data/test/fixtures/rails_app/config/initializers/wrap_parameters.rb +12 -0
  271. data/test/fixtures/rails_app/config/locales/en.yml +5 -0
  272. data/test/fixtures/rails_app/config/mongoid.yml +20 -0
  273. data/test/fixtures/rails_app/config/routes.rb +61 -0
  274. data/test/fixtures/rails_app/config/typus/README +68 -0
  275. data/test/fixtures/rails_app/config/typus/admin.yml +16 -0
  276. data/test/fixtures/rails_app/config/typus/admin_roles.yml +3 -0
  277. data/test/fixtures/rails_app/config/typus/crud_basic.yml +10 -0
  278. data/test/fixtures/rails_app/config/typus/crud_basic_roles.yml +2 -0
  279. data/test/fixtures/rails_app/config/typus/crud_extended.yml +66 -0
  280. data/test/fixtures/rails_app/config/typus/crud_extended_roles.yml +18 -0
  281. data/test/fixtures/rails_app/config/typus/crud_namespaced.yml +10 -0
  282. data/test/fixtures/rails_app/config/typus/crud_namespaced_roles.yml +2 -0
  283. data/test/fixtures/rails_app/config/typus/has_many.yml +0 -0
  284. data/test/fixtures/rails_app/config/typus/has_many_roles.yml +0 -0
  285. data/test/fixtures/rails_app/config/typus/has_many_through.yml +23 -0
  286. data/test/fixtures/rails_app/config/typus/has_many_through_roles.yml +4 -0
  287. data/test/fixtures/rails_app/config/typus/has_one.yml +12 -0
  288. data/test/fixtures/rails_app/config/typus/has_one_roles.yml +3 -0
  289. data/test/fixtures/rails_app/config/typus/mongo_db.yml +4 -0
  290. data/test/fixtures/rails_app/config/typus/mongo_db_roles.yml +2 -0
  291. data/test/fixtures/rails_app/config/typus/polymorphic.yml +17 -0
  292. data/test/fixtures/rails_app/config/typus/polymorphic_roles.yml +5 -0
  293. data/test/fixtures/rails_app/config/typus/resource_roles.yml +7 -0
  294. data/test/fixtures/rails_app/config/typus/sti.yml +5 -0
  295. data/test/fixtures/rails_app/config/typus/sti_roles.yml +2 -0
  296. data/test/fixtures/rails_app/config/typus/unknown.yml +3 -0
  297. data/test/fixtures/rails_app/config/typus/unknown_roles.yml +5 -0
  298. data/test/fixtures/rails_app/db/.gitkeep +0 -0
  299. data/test/fixtures/rails_app/db/schema.rb +209 -0
  300. data/test/fixtures/rails_app/db/seeds.rb +58 -0
  301. data/test/fixtures/rails_app/db/seeds/assets/000.jpg +0 -0
  302. data/test/fixtures/rails_app/db/seeds/assets/001.jpg +0 -0
  303. data/test/fixtures/rails_app/db/seeds/assets/002.jpg +0 -0
  304. data/test/fixtures/rails_app/db/seeds/assets/003.jpg +0 -0
  305. data/test/fixtures/rails_app/db/seeds/assets/004.jpg +0 -0
  306. data/test/fixtures/rails_app/public/404.html +26 -0
  307. data/test/fixtures/rails_app/public/422.html +26 -0
  308. data/test/fixtures/rails_app/public/500.html +26 -0
  309. data/test/fixtures/rails_app/public/favicon.ico +0 -0
  310. data/test/fixtures/rails_app/public/images/rails.png +0 -0
  311. data/test/fixtures/rails_app/public/robots.txt +5 -0
  312. data/test/fixtures/rails_app/public/stylesheets/.gitkeep +0 -0
  313. data/test/fixtures/rails_app/script/rails +6 -0
  314. data/test/lib/support/active_record_test.rb +139 -0
  315. data/test/lib/support/fake_user_test.rb +63 -0
  316. data/test/lib/support/hash_test.rb +25 -0
  317. data/test/lib/support/object_test.rb +10 -0
  318. data/test/lib/support/string_test.rb +80 -0
  319. data/test/lib/typus/configuration_test.rb +48 -0
  320. data/test/lib/typus/controller/actions_test.rb +141 -0
  321. data/test/lib/typus/controller/associations_test.rb +7 -0
  322. data/test/lib/typus/controller/autocomplete_test.rb +7 -0
  323. data/test/lib/typus/controller/filters_test.rb +73 -0
  324. data/test/lib/typus/controller/format_test.rb +7 -0
  325. data/test/lib/typus/i18n_test.rb +13 -0
  326. data/test/lib/typus/orm/active_record/class_methods_test.rb +381 -0
  327. data/test/lib/typus/orm/active_record/search_test.rb +328 -0
  328. data/test/lib/typus/regex_test.rb +62 -0
  329. data/test/lib/typus/resources_test.rb +41 -0
  330. data/test/lib/typus_test.rb +132 -0
  331. data/test/test_helper.rb +41 -0
  332. data/typus.gemspec +3 -10
  333. metadata +525 -137
  334. data/.gitmodules +0 -3
  335. data/app/assets/vendor/typus/javascripts/jquery.rails.js +0 -158
  336. data/app/assets/vendor/typus/vendor/jquery-ui-1.8.12.custom/js/jquery-1.5.1.min.js +0 -16
  337. data/app/views/admin/templates/_text_with_ckeditor.html.erb +0 -13
  338. data/config/locales/typus.pt-PT.models.yml +0 -17
  339. data/config/locales/typus.pt-PT.yml +0 -83
@@ -0,0 +1,76 @@
1
+ require "test_helper"
2
+
3
+ class Admin::ListHelperTest < ActiveSupport::TestCase
4
+
5
+ include Admin::ListHelper
6
+
7
+ def render(*args); args; end
8
+
9
+ context "resources_actions" do
10
+
11
+ should "return a default value which is an empty array" do
12
+ assert resources_actions.empty?
13
+ end
14
+
15
+ should "return a predefined value" do
16
+ @resources_actions = "mock"
17
+ assert_equal "mock", resources_actions
18
+ end
19
+
20
+ end
21
+
22
+ context "list_actions" do
23
+
24
+ should "be empty" do
25
+ assert list_actions.empty?
26
+ end
27
+
28
+ should "not include actions that a role cannot perform" do
29
+ @resource = mock
30
+ @resource.stubs(:name).returns("resource")
31
+
32
+ self.stubs(:link_to).returns("some_link")
33
+ sample_action = ["a body", {:action => :some_action}, {}]
34
+ self.stubs(:resources_actions).returns([sample_action] * 3)
35
+
36
+ admin_user = mock
37
+ admin_user.stubs(:can?).returns(true, false, true)
38
+ self.stubs(:admin_user).returns(admin_user)
39
+ self.stubs(:params).returns({:action => 'some_other_action'})
40
+
41
+ results = list_actions.split("/")
42
+ assert results.size.eql?(2)
43
+ end
44
+
45
+ should_eventually "return an array with our custom actions"
46
+
47
+ end
48
+
49
+ context "build_list" do
50
+
51
+ setup do
52
+ @model = TypusUser
53
+ @fields = %w( email role status )
54
+ @items = TypusUser.all
55
+ @resource = "typus_users"
56
+ end
57
+
58
+ should "return a table" do
59
+ expected = [ "admin/typus_users/list", { :items => [] } ]
60
+ output = build_list(@model, @fields, @items, @resource)
61
+ assert_equal expected, output
62
+ end
63
+
64
+ should "return a template" do
65
+ self.stubs(:render).returns("a_template")
66
+ File.stubs(:exist?).returns(true)
67
+
68
+ expected = "a_template"
69
+ output = build_list(@model, @fields, @items, @resource)
70
+
71
+ assert_equal expected, output
72
+ end
73
+
74
+ end
75
+
76
+ end
@@ -0,0 +1,19 @@
1
+ require "test_helper"
2
+
3
+ class Admin::RelationshipsHelperTest < ActiveSupport::TestCase
4
+
5
+ include Admin::RelationshipsHelper
6
+
7
+ # should_eventually "test setup_relationship"
8
+ # should_eventually "test typus_form_has_many"
9
+ # should_eventually "test typus_form_has_and_belongs_to_many"
10
+ # should_eventually "test build_pagination"
11
+ # should_eventually "test build_relate_form"
12
+ # should_eventually "test build_relationship_table"
13
+ # should_eventually "test build_add_new"
14
+ # should_eventually "test set_condition"
15
+ # should_eventually "test set_conditions"
16
+ # should_eventually "test typus_form_has_one"
17
+ # should_eventually "test typus_belongs_to_field"
18
+
19
+ end
@@ -0,0 +1,46 @@
1
+ require "test_helper"
2
+
3
+ class Admin::ResourcesHelperTest < ActiveSupport::TestCase
4
+
5
+ include Admin::ResourcesHelper
6
+
7
+ include ActionView::Helpers::UrlHelper
8
+ include ActionView::Helpers::TagHelper
9
+
10
+ def render(*args); args; end
11
+
12
+ context "display_link_to_previous" do
13
+
14
+ setup do
15
+ @resource = Comment
16
+ end
17
+
18
+ should "set an url to new when not resource_id is passed" do
19
+ params = { :resource => "Post" }
20
+
21
+ expected = ["admin/helpers/resources/display_link_to_previous",
22
+ {:body=>"Cancel adding a new comment?", :url=>{:controller=>"/admin/posts", :action => 'new'}}]
23
+
24
+ assert_equal expected, display_link_to_previous(params)
25
+ end
26
+
27
+ should "set an url to edit when resource_id is passed" do
28
+ @post = Factory(:post)
29
+ params = { :resource => "Post", :resource_id => @post.id }
30
+
31
+ expected = ["admin/helpers/resources/display_link_to_previous",
32
+ {:body=>"Cancel adding a new comment?", :url=>{:controller=>"/admin/posts", :action => 'edit', :id => @post.id}}]
33
+
34
+ assert_equal expected, display_link_to_previous(params)
35
+ end
36
+
37
+ should "return nil if no resource is passed" do
38
+ params = { :action => "edit" }
39
+ self.expects(:params).at_least_once.returns(params)
40
+
41
+ assert_nil display_link_to_previous
42
+ end
43
+
44
+ end
45
+
46
+ end
@@ -0,0 +1,56 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require "test_helper"
4
+
5
+ class Admin::SearchHelperTest < ActiveSupport::TestCase
6
+
7
+ include Admin::SearchHelper
8
+
9
+ def render(*args); args; end
10
+
11
+ test "search rejects controller and action params" do
12
+ parameters = {"controller"=>"admin/posts", "action"=>"index"}
13
+ expected = ["admin/helpers/search/search", {:hidden_filters => {}}]
14
+ assert_equal expected, search(Entry, parameters)
15
+ end
16
+
17
+ # Why do you need the pagination page for a new search?
18
+ test "search rejects page param" do
19
+ parameters = {"page"=>"1"}
20
+ expected = ["admin/helpers/search/search", {:hidden_filters => {}}]
21
+ assert_equal expected, search(Entry, parameters)
22
+ end
23
+
24
+ # TODO: I want to think about it ...
25
+ test "search rejects locale params" do
26
+ parameters = {"locale"=>"jp"}
27
+ expected = ["admin/helpers/search/search", {:hidden_filters => {}}]
28
+ assert_equal expected, search(Entry, parameters)
29
+ end
30
+
31
+ # TODO: I want to think about it ...
32
+ test "search rejects to sort_order and order_by" do
33
+ parameters = {"sort_order"=>"asc", "order_by"=>"title"}
34
+ expected = ["admin/helpers/search/search", {:hidden_filters => {}}]
35
+ assert_equal expected, search(Entry, parameters)
36
+ end
37
+
38
+ test "search rejects utf8 param because form already contains it" do
39
+ parameters = {"utf8"=>"✓"}
40
+ expected = ["admin/helpers/search/search", {:hidden_filters => {}}]
41
+ assert_equal expected, search(Entry, parameters)
42
+ end
43
+
44
+ test "search rejects search param because form already contains it" do
45
+ parameters = {"search"=>"Chunky Bacon"}
46
+ expected = ["admin/helpers/search/search", {:hidden_filters => {}}]
47
+ assert_equal expected, search(Entry, parameters)
48
+ end
49
+
50
+ test "search not rejects applied filters" do
51
+ parameters = {"published"=>"true", "user_id"=>"1"}
52
+ expected = ["admin/helpers/search/search", {:hidden_filters=>{"published"=>"true", "user_id"=>"1"}}]
53
+ assert_equal expected, search(Entry, parameters)
54
+ end
55
+
56
+ end
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require "test_helper"
4
+
5
+ class Admin::SidebarHelperTest < ActiveSupport::TestCase
6
+
7
+ include Admin::SidebarHelper
8
+
9
+ include ActionView::Helpers::UrlHelper
10
+ include ActionView::Helpers::TagHelper
11
+ include ActionView::Helpers::FormTagHelper
12
+
13
+ def render(*args); args; end
14
+ def link_to(*args); args; end
15
+
16
+ setup do
17
+ default_url_options[:host] = 'test.host'
18
+ end
19
+
20
+ end
@@ -0,0 +1,245 @@
1
+ require "test_helper"
2
+
3
+ class FakeController
4
+ attr_accessor :request
5
+
6
+ def config
7
+ @config ||= ActiveSupport::InheritableOptions.new(ActionController::Base.config)
8
+ end
9
+ end
10
+
11
+ class Admin::TableHelperTest < ActiveSupport::TestCase
12
+
13
+ =begin
14
+
15
+ include Admin::TableHelper
16
+
17
+ include ActionView::Helpers::UrlHelper
18
+ include ActionView::Helpers::TagHelper
19
+ include ActionView::Helpers::TextHelper
20
+ # include ActionView::Helpers::RawOutputHelper
21
+
22
+ include ActionView::Context
23
+
24
+ include Rails.application.routes.url_helpers
25
+
26
+ def render(*args); args; end
27
+ def params; {} end
28
+ def admin_user; end
29
+
30
+ setup do
31
+ default_url_options[:host] = "test.host"
32
+ self.stubs(:controller).returns(FakeController.new)
33
+ end
34
+
35
+ context "table_header" do
36
+
37
+ should "work" do
38
+ params = { :controller => "/admin/typus_users", :action => "index" }
39
+ fields = TypusUser.typus_fields_for(:list)
40
+
41
+ expected = [ %(<a href="/admin/typus_users?order_by=email">Email</a>),
42
+ %(<a href="/admin/typus_users?order_by=role">Role</a>),
43
+ %(<a href="/admin/typus_users?order_by=status">Status</a>) ]
44
+
45
+ assert_equal expected, table_header(TypusUser, fields, params)
46
+ end
47
+
48
+ should "work with params" do
49
+ params = { :controller => "/admin/typus_users", :action => "index", :search => "admin" }
50
+ fields = TypusUser.typus_fields_for(:list)
51
+
52
+ expected = [ %(<a href="/admin/typus_users?order_by=email&amp;search=admin">Email</a>),
53
+ %(<a href="/admin/typus_users?order_by=role&amp;search=admin">Role</a>),
54
+ %(<a href="/admin/typus_users?order_by=status&amp;search=admin">Status</a>) ]
55
+
56
+ assert_equal expected, table_header(TypusUser, fields, params)
57
+ end
58
+
59
+ end
60
+
61
+ context "table_actions" do
62
+ setup do
63
+ admin_user = mock
64
+ admin_user.stubs(:can?).returns(true)
65
+ self.stubs(:admin_user).returns(admin_user)
66
+ self.stubs(:params).returns({:controller => 'admin/comments', :action => 'some_other_action'})
67
+ end
68
+
69
+ should "work" do
70
+ item = Factory(:comment)
71
+ @resource_actions = [["Show", {:action => :show}, {}]]
72
+ expected = %Q(<a href="/admin/comments/show/#{item.id}">Show</a>)
73
+
74
+ assert_equal expected, table_actions(Comment, item, nil)
75
+ end
76
+
77
+ should "work with conditions" do
78
+ item = Factory(:comment, :id => 1)
79
+ proc1 = Proc.new {|item| item.id != 1}
80
+ @resource_actions = [["Show", {:action => :show}, {}, proc1], ["Edit", {:action => :edit}, {}]]
81
+ expected = %Q(<a href="/admin/comments/edit/#{item.id}">Edit</a>)
82
+
83
+ assert_equal expected, table_actions(Comment, item, nil)
84
+ end
85
+ end
86
+
87
+ context "resource_actions" do
88
+
89
+ should "return a default value which is an empty array" do
90
+ assert resource_actions.empty?
91
+ end
92
+
93
+ should "return a predefined value" do
94
+ @resource_actions = "mock"
95
+ assert_equal "mock", resource_actions
96
+ end
97
+
98
+ end
99
+
100
+ context "table_belongs_to_field" do
101
+
102
+ should "work without associated model" do
103
+ comment = Factory(:comment, :post => nil)
104
+ assert_equal "&mdash;", table_belongs_to_field("post", comment)
105
+ end
106
+
107
+ should "work with associated model when user has access" do
108
+ admin_user.expects(:can?).returns(true)
109
+ comment = Factory(:comment)
110
+ post = comment.post
111
+ assert_equal %(<a href="/admin/posts/edit/#{post.id}">#{post.to_label}</a>), table_belongs_to_field("post", comment)
112
+ end
113
+
114
+ should "work with associated model when user does not have access" do
115
+ admin_user.expects(:can?).returns(false)
116
+ comment = Factory(:comment)
117
+ post = comment.post
118
+ assert_equal post.to_label, table_belongs_to_field("post", comment)
119
+ end
120
+
121
+ end
122
+
123
+ should "test_table_has_and_belongs_to_many_field" do
124
+ post = Factory(:post)
125
+ post.comments << Factory(:comment, :name => "John")
126
+ post.comments << Factory(:comment, :name => "Jack")
127
+ assert_equal "John, Jack", table_has_and_belongs_to_many_field("comments", post)
128
+ end
129
+
130
+ context "table_string_field" do
131
+
132
+ should "work" do
133
+ post = Factory(:post)
134
+ assert_equal post.title, table_string_field(:title, post)
135
+ end
136
+
137
+ should "work when attribute is empty" do
138
+ post = Factory(:post)
139
+ post.title = ""
140
+ assert_equal "&mdash;", table_string_field(:title, post)
141
+ end
142
+
143
+ end
144
+
145
+ context "table_integer_field" do
146
+
147
+ should "work" do
148
+ post = Factory(:post)
149
+ assert_equal post.id, table_integer_field(:id, post)
150
+ end
151
+
152
+ should "work when attribute is empty" do
153
+ post = Factory(:post)
154
+ post.id = nil
155
+ assert_equal "&mdash;", table_integer_field(:id, post)
156
+ end
157
+
158
+ end
159
+
160
+ context "table_tree_field" do
161
+
162
+ should "work when no parent" do
163
+ page = Factory(:page)
164
+ assert_equal "&mdash;", table_tree_field("title", page)
165
+ end
166
+
167
+ should "work when parent" do
168
+ parent = Factory(:page)
169
+ page = Factory(:page, :parent => parent)
170
+ assert_equal parent.to_label, table_tree_field("title", page)
171
+ end
172
+
173
+ end
174
+
175
+ should "test_table_datetime_field" do
176
+ post = Factory(:post)
177
+ assert_equal post.created_at.strftime("%d %b %H:%M"), table_datetime_field(:created_at, post)
178
+ end
179
+
180
+ context "table_boolean_field" do
181
+
182
+ should "work when default status is true" do
183
+ post = Factory(:typus_user)
184
+ expected = %(<a href="/admin/typus_users/toggle/#{post.id}?field=status" data-confirm="Change status?">Active</a>)
185
+ assert_equal expected, table_boolean_field("status", post)
186
+ end
187
+
188
+ should "work when default status is false" do
189
+ post = Factory(:typus_user, :status => false)
190
+ expected = %(<a href="/admin/typus_users/toggle/#{post.id}?field=status" data-confirm="Change status?">Inactive</a>)
191
+ assert_equal expected, table_boolean_field("status", post)
192
+ end
193
+
194
+ should "work when default status is nil" do
195
+ post = Factory(:typus_user, :status => nil)
196
+ assert post.status.nil?
197
+ expected = %(<a href="/admin/typus_users/toggle/#{post.id}?field=status" data-confirm="Change status?">Inactive</a>)
198
+ assert_equal expected, table_boolean_field("status", post)
199
+ end
200
+
201
+ end
202
+
203
+ context "table_transversal_field" do
204
+
205
+ should "work" do
206
+ comment = Factory(:comment)
207
+ output = table_transversal_field("post.title", comment)
208
+ expected = comment.post.title
209
+ assert_equal expected, output
210
+ end
211
+
212
+ should "return a dash if the association does not exist" do
213
+ comment = Factory(:comment, :post => nil)
214
+ assert_equal "&mdash;", table_transversal_field("post.title", comment)
215
+ end
216
+
217
+ end
218
+
219
+ should "test_table_position_field" do
220
+ first_category = Factory(:category, :position => 0)
221
+ second_category = Factory(:category, :position => 1)
222
+ last_category = Factory(:category, :position => 2)
223
+
224
+ output = table_position_field(nil, first_category)
225
+ expected = <<-HTML
226
+ 1<br/><br/><a href="/admin/categories/position/#{first_category.id}?go=move_lower">Down</a> / <a href="/admin/categories/position/#{first_category.id}?go=move_to_bottom">Bottom</a>
227
+ HTML
228
+ assert_equal expected.strip, output
229
+
230
+ output = table_position_field(nil, second_category)
231
+ expected = <<-HTML
232
+ 2<br/><br/><a href="/admin/categories/position/#{second_category.id}?go=move_to_top">Top</a> / <a href="/admin/categories/position/#{second_category.id}?go=move_higher">Up</a> / <a href="/admin/categories/position/#{second_category.id}?go=move_lower">Down</a> / <a href="/admin/categories/position/#{second_category.id}?go=move_to_bottom">Bottom</a>
233
+ HTML
234
+ assert_equal expected.strip, output
235
+
236
+ output = table_position_field(nil, last_category)
237
+ expected = <<-HTML
238
+ 3<br/><br/><a href="/admin/categories/position/#{last_category.id}?go=move_to_top">Top</a> / <a href="/admin/categories/position/#{last_category.id}?go=move_higher">Up</a>
239
+ HTML
240
+ assert_equal expected.strip, output
241
+ end
242
+
243
+ =end
244
+
245
+ end