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
@@ -75,7 +75,7 @@ el:
75
75
  "You can't change your role": "Δεν έχετε την δυνατότητα να αλλάξετε τον ρόλο σας"
76
76
  "You can't toggle your status": "Δεν επιτρέπεται η αλλαγή της κατάστασής σας"
77
77
 
78
- "%{errors} errors prohibited this page from being saved:":
78
+ "%{errors} prohibited this page from being saved:":
79
79
  "%{model} successfully created": "Το μοντέλο %{model} δημιουργήθηκε επιτυχώς"
80
80
  "%{model} successfully removed": "Το μοντέλο %{model} απομακρύνθηκε επιτυχώς"
81
81
  "%{model} successfully updated": "Το μοντέλο %{model} ανανεώθηκε επιτυχώς"
@@ -76,7 +76,7 @@ es:
76
76
  "View all %{attribute}":
77
77
  "View site": "Ver web"
78
78
 
79
- "%{errors} errors prohibited this page from being saved:":
79
+ "%{errors} prohibited this page from being saved:":
80
80
  "%{model} successfully created": "%{model} satisfactoriamente creado."
81
81
  "%{model} successfully removed": "%{model} satisfactoriamente eliminado."
82
82
  "%{model} successfully updated": "%{model} satisfactoriamente actualizado."
@@ -22,7 +22,6 @@ fr:
22
22
  "Edit": "Éditer"
23
23
  "Edit %{resource}": "Éditer %{resource}"
24
24
  "Enter your email below to create the first user": "Entrez votre adresse email pour créer le premier utilisateur"
25
- "Export as %{mime}": "Exporter en %{mime}"
26
25
 
27
26
  "False": "Faux"
28
27
  "Filter": "Filtrer"
@@ -81,7 +80,7 @@ fr:
81
80
  "You can't change your role": "Vous ne pouvez pas changer votre propre rôle."
82
81
  "You can't toggle your status": "Vous ne pouvez pas basculer votre statut"
83
82
 
84
- "%{errors} errors prohibited this page from being saved:":
83
+ "%{errors} prohibited this page from being saved:":
85
84
  "%{model} successfully created": "%{model} correctement créé(e)."
86
85
  "%{model} successfully removed": "%{model} correctement supprimé(e)."
87
86
  "%{model} successfully updated": "%{model} correctement mis(e)-à-jour."
@@ -74,7 +74,7 @@ hu:
74
74
  "You can't change your role": "Nincsen jogod megváltoztatni a jogosultsági szintedet"
75
75
  "You can't toggle your status": "Nincs jogod változtatni a státuszodat"
76
76
 
77
- "%{errors} errors prohibited this page from being saved:":
77
+ "%{errors} prohibited this page from being saved:":
78
78
  "%{model} successfully created": "%{model} sikeresen létrehozva"
79
79
  "%{model} successfully removed": "%{model} sikeresen törölve"
80
80
  "%{model} successfully updated": "%{model} sikereseb frissítve"
@@ -75,7 +75,7 @@
75
75
  "You can't change your role":
76
76
  "You can't toggle your status":
77
77
 
78
- "%{errors} errors prohibited this page from being saved:":
78
+ "%{errors} prohibited this page from being saved:":
79
79
  "%{model} successfully created":
80
80
  "%{model} successfully removed":
81
81
  "%{model} successfully updated":
@@ -74,7 +74,7 @@ pt-BR:
74
74
  "You can update your password at": "Você pode atualizar sua senha em"
75
75
  "You can't change your role": "Você não pode mudar sua própria função no sistema."
76
76
 
77
- "%{errors} errors prohibited this page from being saved:":
77
+ "%{errors} prohibited this page from being saved:":
78
78
  "%{model} successfully created": "%{model} criado com sucesso."
79
79
  "%{model} successfully removed": "%{model} removido com sucesso."
80
80
  "%{model} successfully updated": "%{model} atualizado com sucesso."
@@ -74,7 +74,7 @@ ru:
74
74
  "You can't change your role": "Вы не можете менять свою собственную роль"
75
75
  "You can't toggle your status": "Вы не можете менять свой статус"
76
76
 
77
- "%{errors} errors prohibited this page from being saved:":
77
+ "%{errors} prohibited this page from being saved:":
78
78
  "%{model} successfully created": "%{model} создан"
79
79
  "%{model} successfully removed": "%{model} удален"
80
80
  "%{model} successfully updated": "%{model} успешно обновлен"
@@ -73,7 +73,7 @@ zh-CN:
73
73
  "You can't change your role": "你不能修改你的角色"
74
74
  "You can't toggle your status": "你不能修改自己的状态"
75
75
 
76
- "%{errors} errors prohibited this page from being saved:":
76
+ "%{errors} prohibited this page from being saved:":
77
77
  "%{model} successfully created": "%{model} 创建成功"
78
78
  "%{model} successfully removed": "%{model} 删除成功"
79
79
  "%{model} successfully updated": "%{model} 更新成功"
@@ -19,11 +19,11 @@ Rails.application.routes.draw do
19
19
  end
20
20
 
21
21
  Typus.models.map { |i| i.to_resource }.each do |resource|
22
- match "#{resource}(/:action(/:id(.:format)))", :controller => resource
22
+ match "#{resource}(/:action(/:id))(.:format)", :controller => resource
23
23
  end
24
24
 
25
25
  Typus.resources.map { |i| i.underscore }.each do |resource|
26
- match "#{resource}(/:action(/:id(.:format)))", :controller => resource
26
+ match "#{resource}(/:action(/:id))(.:format)", :controller => resource
27
27
  end
28
28
 
29
29
  end
@@ -20,9 +20,7 @@ Typus.setup do |config|
20
20
  # config.username = "admin"
21
21
  # config.password = "columbia"
22
22
 
23
- # Pagination options:
24
- # These options are passed to `will_paginate`. You can see the available
25
- # options in the plugin source. (https://github.com/mislav/will_paginate/blob/rails3/lib/will_paginate/view_helpers.rb)
23
+ # Pagination options: These options are passed to `kaminari`.
26
24
  # config.pagination = { :previous_label => "← " + Typus::I18n.t("Previous"),
27
25
  # :next_label => Typus::I18n.t("Next") + " →" }
28
26
 
@@ -26,7 +26,6 @@ most common settings.
26
26
  index: cleanup
27
27
  edit: send_as_newsletter
28
28
  show: rebuild
29
- export: csv, xml
30
29
  order_by: created_at
31
30
  relationships:
32
31
  filters: is_published?, created_at, category_id
@@ -43,9 +43,6 @@ Examples:
43
43
  inject_into_class "app/models/#{model_filename}.rb", options[:user_class_name] do
44
44
  <<-MSG
45
45
 
46
- ROLE = Typus::Configuration.roles.keys.sort
47
- LOCALE = Typus.locales
48
-
49
46
  enable_as_typus_user
50
47
 
51
48
  MSG
@@ -25,7 +25,13 @@ class ActiveRecord::Base
25
25
  # => "Publicado"
26
26
  #++
27
27
  def mapping(attribute)
28
- values = self.class::const_get(attribute.to_s.upcase).to_a
28
+ klass = self.class
29
+ values = if klass.const_defined?(attribute.upcase)
30
+ klass::const_get(attribute.upcase)
31
+ else
32
+ klass.send(attribute)
33
+ end
34
+
29
35
  array = values.first.is_a?(Array) ? values : values.map { |i| [i, i] }
30
36
 
31
37
  value = array.rassoc(send(attribute))
@@ -40,12 +46,4 @@ class ActiveRecord::Base
40
46
  end
41
47
  end
42
48
 
43
- def self.namespaced?
44
- name.match(/::/)
45
- end
46
-
47
- def self.namespace
48
- name.split("::").first if self.namespaced?
49
- end
50
-
51
49
  end
@@ -11,8 +11,7 @@ require "typus/orm/active_record"
11
11
  require "typus/regex"
12
12
  require "typus/version"
13
13
 
14
- require "render_inheritable"
15
- require "will_paginate"
14
+ require "kaminari"
16
15
 
17
16
  autoload :FakeUser, "support/fake_user"
18
17
 
@@ -46,7 +45,7 @@ module Typus
46
45
 
47
46
  mattr_accessor :admin_sub_title
48
47
  @@admin_sub_title = <<-CODE
49
- <a href="http://core.typuscms.com/">typus</a> by <a href="http://intraducibles.com">intraducibles.com</a>
48
+ <a href="http://core.typuscms.com/">core.typuscms.com</a>
50
49
  CODE
51
50
 
52
51
  ##
@@ -66,10 +65,11 @@ module Typus
66
65
  @@username = "admin"
67
66
 
68
67
  ##
69
- # Pagination options
68
+ # Pagination options passed to Kaminari helper.
70
69
  #
71
70
  mattr_accessor :pagination
72
- @@pagination = { :previous_label => "&larr; " + Typus::I18n.t("Previous"),
71
+ @@pagination = { :window => 0,
72
+ :previous_label => "&larr; " + Typus::I18n.t("Previous"),
73
73
  :next_label => Typus::I18n.t("Next") + " &rarr;" }
74
74
 
75
75
  ##
@@ -137,7 +137,7 @@ module Typus
137
137
 
138
138
  # Lists modules of an application.
139
139
  def application(name)
140
- Typus::Configuration.config.map { |i| i.first if i.last["application"] == name }.compact.uniq
140
+ Typus::Configuration.config.map { |i| i.first if i.last["application"] == name }.compact.uniq.sort
141
141
  end
142
142
 
143
143
  # Lists models from the configuration file.
@@ -175,8 +175,7 @@ module Typus
175
175
  "Français" => "fr",
176
176
  "Magyar" => "hu",
177
177
  "Italiano" => "It",
178
- "Portuguese" => "pt-PT",
179
- "Brazilian Portuguese" => "pt-BR",
178
+ "Portuguese" => "pt-BR",
180
179
  "Russian" => "ru",
181
180
  "中文" => "zh-CN" }
182
181
  end
@@ -10,8 +10,9 @@ module Typus
10
10
  if session[:typus_user_id]
11
11
  admin_user
12
12
  else
13
- back_to = request.env['PATH_INFO'] unless [admin_dashboard_path, admin_path].include?(request.env['PATH_INFO'])
14
- redirect_to new_admin_session_path(:back_to => back_to)
13
+ # back_to = request.env['PATH_INFO'] unless [root_path].include?(request.env['PATH_INFO'])
14
+ # redirect_to new_session_path(:back_to => back_to)
15
+ redirect_to new_admin_session_path
15
16
  end
16
17
  end
17
18
 
@@ -62,7 +62,7 @@ module Typus
62
62
  if worked
63
63
  notice = Typus::I18n.t("%{model} successfully updated.", :model => item_class.model_name.human)
64
64
  else
65
- alert = item.errors.full_messages
65
+ alert = item.error.full_messages
66
66
  end
67
67
 
68
68
  redirect_to :back, :notice => notice, :alert => alert
@@ -126,7 +126,7 @@ module Typus
126
126
  #
127
127
  def set_belongs_to_association(item_class, options)
128
128
  association_name = item_class.model_name.tableize.to_sym
129
- foreign_key = @resource.reflect_on_association(association_name).primary_key_name
129
+ foreign_key = @resource.reflect_on_association(association_name).foreign_key
130
130
 
131
131
  if params[:resource_id]
132
132
  item = item_class.find(params[:resource_id])
@@ -1,8 +1,8 @@
1
1
  if RUBY_VERSION >= '1.9'
2
2
  require 'csv'
3
- FasterCSV = CSV
4
3
  else
5
4
  require 'fastercsv'
5
+ CSV = FasterCSV
6
6
  end
7
7
 
8
8
  module Typus
@@ -13,7 +13,7 @@ module Typus
13
13
 
14
14
  def generate_html
15
15
  items_per_page = @resource.typus_options_for(:per_page)
16
- @items = @resource.paginate(:per_page => items_per_page, :page => params[:page])
16
+ @items = @resource.page(params[:page]).per(items_per_page)
17
17
  end
18
18
 
19
19
  #--
@@ -28,7 +28,7 @@ module Typus
28
28
 
29
29
  options = { :conditions => @conditions, :batch_size => 1000 }
30
30
 
31
- ::FasterCSV.open(filename, 'w') do |csv|
31
+ ::CSV.open(filename, 'w', :col_sep => ';') do |csv|
32
32
  csv << fields.keys
33
33
  @resource.find_in_batches(options) do |records|
34
34
  records.each do |record|
@@ -1,11 +1,7 @@
1
- module Typus
1
+ module Admin
2
2
  class Engine < Rails::Engine
3
3
 
4
- initializer "static assets" do |app|
5
- if app.config.serve_static_assets
6
- app.middleware.insert_after ::ActionDispatch::Static, ::ActionDispatch::Static, "#{root}/app/assets"
7
- end
8
- end
4
+ # isolate_namespace Admin
9
5
 
10
6
  end
11
7
  end
@@ -22,6 +22,10 @@ module Typus
22
22
  ::I18n.t(msg, options)
23
23
  end
24
24
 
25
+ def default_locale
26
+ :en
27
+ end
28
+
25
29
  end
26
30
 
27
31
  end
@@ -12,10 +12,7 @@ module Typus
12
12
  attr_accessor :password
13
13
  attr_protected :status
14
14
 
15
- validates :email,
16
- :presence => true,
17
- :uniqueness => true,
18
- :format => { :with => Typus::Regex::Email }
15
+ validates :email, :presence => true, :uniqueness => true, :format => { :with => Typus::Regex::Email }
19
16
 
20
17
  validates :password,
21
18
  :confirmation => { :if => :password_required? },
@@ -25,7 +22,7 @@ module Typus
25
22
 
26
23
  validates :role, :presence => true
27
24
 
28
- before_save :initialize_salt, :encrypt_password, :initialize_token
25
+ before_save :initialize_salt, :encrypt_password, :set_token
29
26
 
30
27
  serialize :preferences
31
28
 
@@ -36,11 +33,19 @@ module Typus
36
33
 
37
34
  def generate(*args)
38
35
  options = args.extract_options!
39
- options[:password] ||= ActiveSupport::SecureRandom.hex(4)
36
+ options[:password] ||= Typus.password
40
37
  options[:role] ||= Typus.master_role
41
38
  new :email => options[:email], :password => options[:password], :role => options[:role]
42
39
  end
43
40
 
41
+ def role
42
+ Typus::Configuration.roles.keys.sort
43
+ end
44
+
45
+ def locale
46
+ Typus.locales
47
+ end
48
+
44
49
  include InstanceMethods
45
50
  include Typus::Orm::ActiveRecord::User::InstanceMethods
46
51
 
@@ -73,12 +78,8 @@ module Typus
73
78
  self.salt = generate_hash("--#{Time.zone.now.to_s(:number)}--#{email}--") if new_record?
74
79
  end
75
80
 
76
- def initialize_token
77
- generate_token if new_record?
78
- end
79
-
80
- def generate_token
81
- self.token = encrypt("--#{Time.zone.now.to_s(:number)}--#{password}--").first(12)
81
+ def set_token
82
+ self.token = "#{ActiveSupport::SecureRandom.hex(3)}-#{ActiveSupport::SecureRandom.hex(3)}"
82
83
  end
83
84
 
84
85
  def password_required?
@@ -12,14 +12,34 @@ module Typus
12
12
 
13
13
  attr_reader :password
14
14
  attr_accessor :password_confirmation
15
+ attr_protected :status
15
16
 
16
17
  validates :email, :presence => true, :uniqueness => true, :format => { :with => Typus::Regex::Email }
17
- validates :password, :confirmation => true, :length => { :within => 6..40 }
18
+ validates :password, :confirmation => true
18
19
  validates :password_digest, :presence => true
19
20
 
21
+ validate :password_must_be_strong
22
+
20
23
  include InstanceMethodsOnActivation
21
24
  include Typus::Orm::ActiveRecord::User::InstanceMethods
22
25
 
26
+ serialize :preferences
27
+
28
+ before_save :set_token
29
+
30
+ def self.role
31
+ Typus::Configuration.roles.keys.sort
32
+ end
33
+
34
+ def self.locale
35
+ Typus.locales
36
+ end
37
+
38
+ def self.authenticate(email, password)
39
+ user = find_by_email_and_status(email, true)
40
+ user && user.authenticate(password) ? user : nil
41
+ end
42
+
23
43
  end
24
44
 
25
45
  end
@@ -41,6 +61,16 @@ module Typus
41
61
  self.password_digest = BCrypt::Password.create(unencrypted_password)
42
62
  end
43
63
 
64
+ def set_token
65
+ self.token = "#{ActiveSupport::SecureRandom.hex(6)}-#{ActiveSupport::SecureRandom.hex(6)}"
66
+ end
67
+
68
+ def password_must_be_strong
69
+ if password.present?
70
+ errors.add(:password, :too_short, :count => 7) unless password.size > 6
71
+ end
72
+ end
73
+
44
74
  end
45
75
 
46
76
  end
@@ -66,6 +66,7 @@ module Typus
66
66
  next
67
67
  end
68
68
 
69
+ # TODO: This is not tested!
69
70
  if virtual_fields.include?(field.to_s)
70
71
  fields_with_type[field.to_s] = :virtual
71
72
  end
@@ -79,10 +79,6 @@ module Typus
79
79
  end
80
80
  end
81
81
 
82
- def typus_export_formats
83
- read_model_config['export'].try(:extract_settings) || []
84
- end
85
-
86
82
  def typus_order_by
87
83
  typus_defaults_for(:order_by).map do |field|
88
84
  field.include?('-') ? "#{table_name}.#{field.delete('-')} DESC" : "#{table_name}.#{field} ASC"
@@ -3,6 +3,8 @@ module Typus
3
3
 
4
4
  Email = /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/
5
5
 
6
+ Domain = /^(((?:[-a-z0-9]+\.)+[a-z]{2,}))/
7
+
6
8
  Url = /(^$)|(^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$)/ix
7
9
 
8
10
  end
@@ -1,3 +1,3 @@
1
1
  module Typus
2
- VERSION = "3.0.12"
2
+ VERSION = "3.1.0.rc1"
3
3
  end
@@ -0,0 +1,94 @@
1
+ require "test_helper"
2
+
3
+ =begin
4
+
5
+ What's being tested here?
6
+
7
+ - Create first user. (/admin/account/new)
8
+ - Stuff that happens when there are already users.
9
+
10
+ =end
11
+
12
+ class Admin::AccountControllerTest < ActionController::TestCase
13
+
14
+ context "No users" do
15
+
16
+ should "render new when there are not admin users" do
17
+ get :new
18
+
19
+ assert_response :success
20
+ assert_template "new"
21
+ assert_template "layouts/admin/session"
22
+ assert_equal "Enter your email below to create the first user.", flash[:notice]
23
+ end
24
+
25
+ should "verify forgot_password redirects to new when there are no admin users" do
26
+ get :forgot_password
27
+ assert_response :redirect
28
+ assert_redirected_to new_admin_account_path
29
+ end
30
+
31
+ should "verify send_password redirects to new when there are no admin users"
32
+
33
+ should "not sign_up invalid emails" do
34
+ post :create, :typus_user => { :email => "example.com" }
35
+ assert_response :redirect
36
+ assert_redirected_to :action => :new
37
+ assert flash.empty?
38
+ end
39
+
40
+ should "sign_up a valid email" do
41
+ assert_difference('TypusUser.count') { post :create, :typus_user => { :email => "john@example.com" } }
42
+ assert_response :redirect
43
+ assert_redirected_to :action => "show", :id => TypusUser.find_by_email("john@example.com").token
44
+ end
45
+
46
+ end
47
+
48
+ context "There are users" do
49
+
50
+ setup do
51
+ @typus_user = Factory(:typus_user)
52
+ end
53
+
54
+ should "new redirect new admin session when there are admin users" do
55
+ get :new
56
+ assert_response :redirect
57
+ assert_redirected_to new_admin_session_path
58
+ end
59
+
60
+ should "verify forgot_password is rendered when there are admin users" do
61
+ get :forgot_password
62
+ assert_response :success
63
+ assert_template "forgot_password"
64
+ end
65
+
66
+ should "not_send_recovery_password_link_to_unexisting_user" do
67
+ post :send_password, :typus_user => { :email => "unexisting" }
68
+ assert_response :success
69
+ assert flash.empty?
70
+ end
71
+
72
+ should "test_should_send_recovery_password_link_to_existing_user" do
73
+ post :send_password, :typus_user => { :email => @typus_user.email }
74
+ assert_response :redirect
75
+ assert_redirected_to new_admin_session_path
76
+ assert_equal "Password recovery link sent to your email.", flash[:notice]
77
+ end
78
+
79
+ should "test_should_create_admin_user_session_and_redirect_user_to_its_details" do
80
+ get :show, :id => @typus_user.token
81
+ assert_equal @typus_user.id, @request.session[:typus_user_id]
82
+ assert_response :redirect
83
+ assert_redirected_to :controller => "/admin/typus_users", :action => "edit", :id => @typus_user.id
84
+ end
85
+
86
+ should "test_should_return_404_on_reset_passsword_if_token_is_not_valid" do
87
+ assert_raises ActiveRecord::RecordNotFound do
88
+ get :show, :id => "unexisting"
89
+ end
90
+ end
91
+
92
+ end
93
+
94
+ end