zen 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (303) hide show
  1. data/.gitignore +15 -0
  2. data/.mailmap +2 -0
  3. data/.rvmrc +2 -0
  4. data/.travis.yml +8 -3
  5. data/AUTHORS +1 -2
  6. data/CHANGELOG.md +48 -17
  7. data/README.md +44 -39
  8. data/Rakefile +4 -0
  9. data/bin/zen +5 -30
  10. data/lib/zen.rb +13 -19
  11. data/lib/zen/asset.rb +99 -64
  12. data/lib/zen/bin/create.rb +94 -0
  13. data/lib/zen/bin/runner.rb +118 -0
  14. data/lib/zen/controller/admin_controller.rb +52 -36
  15. data/lib/zen/controller/base_controller.rb +5 -5
  16. data/lib/zen/controller/frontend_controller.rb +7 -7
  17. data/lib/zen/controller/main_controller.rb +12 -10
  18. data/lib/zen/controller/preview.rb +15 -11
  19. data/lib/zen/helper/acl.rb +73 -53
  20. data/lib/zen/helper/blue_form_vendor.rb +689 -0
  21. data/lib/zen/helper/breadcrumb.rb +23 -19
  22. data/lib/zen/helper/message.rb +3 -3
  23. data/lib/zen/helper/theme.rb +18 -13
  24. data/lib/zen/language.rb +62 -58
  25. data/lib/zen/language/en/zen_general.yml +2 -4
  26. data/lib/zen/language/nl/zen_general.yml +2 -4
  27. data/lib/zen/layout/admin.xhtml +3 -12
  28. data/lib/zen/layout/login.xhtml +1 -6
  29. data/lib/zen/model/methods.rb +6 -6
  30. data/lib/zen/model/settings.rb +5 -4
  31. data/lib/zen/package.rb +47 -38
  32. data/lib/zen/package/all.rb +3 -5
  33. data/lib/zen/package/base.rb +7 -7
  34. data/lib/zen/package/categories/lib/categories.rb +8 -3
  35. data/lib/zen/package/categories/lib/categories/controller/categories.rb +81 -55
  36. data/lib/zen/package/categories/lib/categories/controller/category_groups.rb +45 -44
  37. data/lib/zen/package/categories/lib/categories/helper/category.rb +88 -0
  38. data/lib/zen/package/categories/lib/categories/language/en/categories.yml +5 -4
  39. data/lib/zen/package/categories/lib/categories/language/en/category_groups.yml +5 -4
  40. data/lib/zen/package/categories/lib/categories/language/nl/categories.yml +5 -4
  41. data/lib/zen/package/categories/lib/categories/language/nl/category_groups.yml +5 -4
  42. data/lib/zen/package/categories/lib/categories/model/category.rb +15 -13
  43. data/lib/zen/package/categories/lib/categories/model/category_group.rb +3 -3
  44. data/lib/zen/package/categories/lib/categories/plugin/categories.rb +36 -25
  45. data/lib/zen/package/categories/lib/categories/view/admin/categories/form.xhtml +49 -56
  46. data/lib/zen/package/categories/lib/categories/view/admin/categories/index.xhtml +48 -35
  47. data/lib/zen/package/categories/lib/categories/view/admin/category-groups/form.xhtml +36 -29
  48. data/lib/zen/package/categories/lib/categories/view/admin/category-groups/index.xhtml +42 -37
  49. data/lib/zen/package/comments/lib/comments.rb +4 -1
  50. data/lib/zen/package/comments/lib/comments/controller/comments.rb +39 -32
  51. data/lib/zen/package/comments/lib/comments/controller/comments_form.rb +45 -26
  52. data/lib/zen/package/comments/lib/comments/helper/comment.rb +35 -0
  53. data/lib/zen/package/comments/lib/comments/language/en/comments.yml +9 -7
  54. data/lib/zen/package/comments/lib/comments/language/nl/comments.yml +10 -8
  55. data/lib/zen/package/comments/lib/comments/model/comment.rb +31 -17
  56. data/lib/zen/package/comments/lib/comments/model/comment_status.rb +15 -0
  57. data/lib/zen/package/comments/lib/comments/plugin/anti_spam.rb +27 -18
  58. data/lib/zen/package/comments/lib/comments/plugin/comments.rb +25 -20
  59. data/lib/zen/package/comments/lib/comments/view/admin/comments/form.xhtml +61 -54
  60. data/lib/zen/package/comments/lib/comments/view/admin/comments/index.xhtml +38 -23
  61. data/lib/zen/package/comments/migrations/1308774099_comment_status.rb +60 -0
  62. data/lib/zen/package/custom_fields/lib/custom_fields.rb +33 -7
  63. data/lib/zen/package/custom_fields/lib/custom_fields/blue_form_parameters.rb +209 -0
  64. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_groups.rb +50 -47
  65. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_field_types.rb +215 -0
  66. data/lib/zen/package/custom_fields/lib/custom_fields/controller/custom_fields.rb +111 -73
  67. data/lib/zen/package/custom_fields/lib/custom_fields/helper/custom_field.rb +79 -0
  68. data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_field_groups.yml +20 -19
  69. data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_field_types.yml +40 -0
  70. data/lib/zen/package/custom_fields/lib/custom_fields/language/en/custom_fields.yml +34 -32
  71. data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_field_groups.yml +5 -4
  72. data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_field_types.yml +40 -0
  73. data/lib/zen/package/custom_fields/lib/custom_fields/language/nl/custom_fields.yml +18 -16
  74. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field.rb +31 -11
  75. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_method.rb +15 -0
  76. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_type.rb +50 -0
  77. data/lib/zen/package/custom_fields/lib/custom_fields/model/custom_field_value.rb +28 -7
  78. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/form.xhtml +33 -28
  79. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/index.xhtml +48 -46
  80. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-types/form.xhtml +61 -0
  81. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-types/index.xhtml +93 -0
  82. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/form.xhtml +105 -99
  83. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/index.xhtml +43 -39
  84. data/lib/zen/package/custom_fields/migrations/1295255665_create_schema.rb +47 -16
  85. data/lib/zen/package/custom_fields/migrations/1310659580_custom_field_types.rb +148 -0
  86. data/lib/zen/package/custom_fields/migrations/1311694920_rename_css_class.rb +11 -0
  87. data/lib/zen/package/menus/lib/menus/controller/menu_items.rb +40 -35
  88. data/lib/zen/package/menus/lib/menus/controller/menus.rb +47 -43
  89. data/lib/zen/package/menus/lib/menus/helper/{menu_item.rb → menu.rb} +42 -15
  90. data/lib/zen/package/menus/lib/menus/language/en/menu_items.yml +5 -5
  91. data/lib/zen/package/menus/lib/menus/language/en/menus.yml +9 -8
  92. data/lib/zen/package/menus/lib/menus/language/nl/menu_items.yml +8 -8
  93. data/lib/zen/package/menus/lib/menus/language/nl/menus.yml +11 -10
  94. data/lib/zen/package/menus/lib/menus/model/menu.rb +5 -5
  95. data/lib/zen/package/menus/lib/menus/model/menu_item.rb +6 -5
  96. data/lib/zen/package/menus/lib/menus/plugin/menus.rb +41 -43
  97. data/lib/zen/package/menus/lib/menus/view/admin/menu-items/form.xhtml +59 -63
  98. data/lib/zen/package/menus/lib/menus/view/admin/menu-items/index.xhtml +35 -30
  99. data/lib/zen/package/menus/lib/menus/view/admin/menus/form.xhtml +46 -37
  100. data/lib/zen/package/menus/lib/menus/view/admin/menus/index.xhtml +37 -37
  101. data/lib/zen/package/menus/migrations/1297184342_create_schema.rb +5 -5
  102. data/lib/zen/package/menus/migrations/1308671733_rename_order_column.rb +11 -0
  103. data/lib/zen/package/menus/migrations/1311695030_rename_css_class.rb +17 -0
  104. data/lib/zen/package/sections/lib/sections.rb +18 -11
  105. data/lib/zen/package/sections/lib/sections/controller/section_entries.rb +115 -109
  106. data/lib/zen/package/sections/lib/sections/controller/sections.rb +72 -50
  107. data/lib/zen/package/sections/lib/sections/helper/section.rb +53 -0
  108. data/lib/zen/package/sections/lib/sections/language/en/section_entries.yml +5 -4
  109. data/lib/zen/package/sections/lib/sections/language/en/sections.yml +5 -4
  110. data/lib/zen/package/sections/lib/sections/language/nl/section_entries.yml +5 -4
  111. data/lib/zen/package/sections/lib/sections/language/nl/sections.yml +5 -4
  112. data/lib/zen/package/sections/lib/sections/model/section.rb +17 -9
  113. data/lib/zen/package/sections/lib/sections/model/section_entry.rb +192 -13
  114. data/lib/zen/package/sections/lib/sections/model/section_entry_status.rb +13 -0
  115. data/lib/zen/package/sections/lib/sections/plugin/section_entries.rb +60 -39
  116. data/lib/zen/package/sections/lib/sections/plugin/sections.rb +14 -11
  117. data/lib/zen/package/sections/lib/sections/view/admin/form.xhtml +100 -97
  118. data/lib/zen/package/sections/lib/sections/view/admin/index.xhtml +41 -39
  119. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/form.xhtml +95 -215
  120. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/index.xhtml +48 -40
  121. data/lib/zen/package/sections/migrations/1308672298_use_id_for_default_section.rb +40 -0
  122. data/lib/zen/package/sections/migrations/1308813320_section_entry_statuses.rb +58 -0
  123. data/lib/zen/package/settings/lib/settings/controller/settings.rb +5 -8
  124. data/lib/zen/package/settings/lib/settings/model/setting.rb +2 -37
  125. data/lib/zen/package/settings/lib/settings/plugin/setting_base.rb +18 -1
  126. data/lib/zen/package/settings/lib/settings/plugin/settings.rb +13 -7
  127. data/lib/zen/package/settings/lib/settings/view/admin/settings/index.xhtml +2 -1
  128. data/lib/zen/package/users/lib/users.rb +3 -1
  129. data/lib/zen/package/users/lib/users/controller/access_rules.rb +77 -60
  130. data/lib/zen/package/users/lib/users/controller/user_groups.rb +41 -36
  131. data/lib/zen/package/users/lib/users/controller/users.rb +48 -42
  132. data/lib/zen/package/users/lib/users/helper/users.rb +72 -0
  133. data/lib/zen/package/users/lib/users/language/en/access_rules.yml +6 -5
  134. data/lib/zen/package/users/lib/users/language/en/user_groups.yml +5 -4
  135. data/lib/zen/package/users/lib/users/language/en/users.yml +1 -0
  136. data/lib/zen/package/users/lib/users/language/nl/access_rules.yml +5 -4
  137. data/lib/zen/package/users/lib/users/language/nl/user_groups.yml +5 -4
  138. data/lib/zen/package/users/lib/users/language/nl/users.yml +1 -0
  139. data/lib/zen/package/users/lib/users/model/access_rule.rb +5 -1
  140. data/lib/zen/package/users/lib/users/model/user.rb +17 -10
  141. data/lib/zen/package/users/lib/users/public/admin/js/users/access_rules.js +10 -37
  142. data/lib/zen/package/users/lib/users/public/admin/js/users/lib/access_rules.js +49 -0
  143. data/lib/zen/package/users/lib/users/view/admin/access-rules/form.xhtml +105 -96
  144. data/lib/zen/package/users/lib/users/view/admin/access-rules/index.xhtml +48 -41
  145. data/lib/zen/package/users/lib/users/view/admin/user-groups/form.xhtml +42 -32
  146. data/lib/zen/package/users/lib/users/view/admin/user-groups/index.xhtml +43 -38
  147. data/lib/zen/package/users/lib/users/view/admin/users/form.xhtml +76 -67
  148. data/lib/zen/package/users/lib/users/view/admin/users/index.xhtml +43 -41
  149. data/lib/zen/package/users/lib/users/view/admin/users/login.xhtml +12 -9
  150. data/lib/zen/package/users/migrations/1295281013_create_schema.rb +2 -2
  151. data/lib/zen/plugin.rb +56 -50
  152. data/lib/zen/plugin/markup/lib/markup/markup.rb +33 -21
  153. data/lib/zen/public/admin/css/zen/buttons.css +11 -7
  154. data/lib/zen/public/admin/css/zen/datepicker.css +6 -6
  155. data/lib/zen/public/admin/css/zen/forms.css +2 -1
  156. data/lib/zen/public/admin/css/zen/general.css +15 -10
  157. data/lib/zen/public/admin/css/zen/layout.css +51 -20
  158. data/lib/zen/public/admin/css/zen/tables.css +39 -11
  159. data/lib/zen/public/admin/css/zen/tabs.css +6 -4
  160. data/lib/zen/public/admin/css/zen/window.css +11 -11
  161. data/lib/zen/public/{favicon.ico → admin/favicon.ico} +0 -0
  162. data/lib/zen/public/admin/images/zen/icons/asc.png +0 -0
  163. data/lib/zen/public/admin/images/zen/icons/desc.png +0 -0
  164. data/lib/zen/public/admin/js/vendor/datepicker.js +0 -11
  165. data/lib/zen/public/admin/js/{mootools → vendor/mootools}/core.js +0 -1
  166. data/lib/zen/public/admin/js/{mootools → vendor/mootools}/more.js +100 -29
  167. data/lib/zen/public/admin/js/zen/index.js +48 -0
  168. data/lib/zen/public/admin/js/zen/lib/asset.js +111 -0
  169. data/lib/zen/public/admin/js/zen/{editor.js → lib/editor.js} +107 -127
  170. data/lib/zen/public/admin/js/zen/{editor → lib/editor}/markdown.js +7 -9
  171. data/lib/zen/public/admin/js/zen/{editor → lib/editor}/textile.js +7 -9
  172. data/lib/zen/public/admin/js/zen/lib/html_table.js +143 -0
  173. data/lib/zen/public/admin/js/zen/{tabs.js → lib/tabs.js} +40 -37
  174. data/lib/zen/public/admin/js/zen/{window.js → lib/window.js} +24 -20
  175. data/lib/zen/spec/bacon/color_output.rb +39 -0
  176. data/lib/zen/spec/helper.rb +152 -0
  177. data/lib/zen/spec/simplecov.rb +22 -0
  178. data/lib/zen/task/build.rake +20 -43
  179. data/lib/zen/task/clean.rake +2 -6
  180. data/lib/zen/task/db.rake +8 -12
  181. data/lib/zen/task/package.rake +4 -10
  182. data/lib/zen/task/plugin.rake +3 -9
  183. data/lib/zen/task/proto.rake +0 -62
  184. data/lib/zen/task/test.rake +6 -3
  185. data/lib/zen/task/theme.rake +4 -11
  186. data/lib/zen/theme.rb +22 -24
  187. data/lib/zen/validation.rb +34 -27
  188. data/lib/zen/version.rb +2 -8
  189. data/lib/zen/view/head.xhtml +7 -0
  190. data/lib/zen/view/main.xhtml +7 -22
  191. data/{proto/package/migrations → pkg}/.gitkeep +0 -0
  192. data/proto/app/app.rb +1 -0
  193. data/proto/app/config/config.rb +5 -4
  194. data/proto/app/config/database.rb +19 -41
  195. data/proto/app/config/middlewares.rb +32 -29
  196. data/proto/{package/lib/package/view/admin/package/index.xhtml → app/log/database/dev/.gitkeep} +0 -0
  197. data/proto/app/log/database/live/.gitkeep +0 -0
  198. data/spec/Rakefile +26 -0
  199. data/spec/fixtures/zen/asset.rb +18 -0
  200. data/spec/fixtures/zen/helper/acl.rb +39 -0
  201. data/spec/fixtures/zen/helper/message.rb +19 -0
  202. data/spec/fixtures/zen/language/en/spec.yml +10 -0
  203. data/spec/fixtures/zen/language/nl/spec.yml +7 -0
  204. data/spec/fixtures/zen/package.rb +17 -0
  205. data/spec/fixtures/zen/package/comments/controller/comments_form.rb +27 -0
  206. data/spec/fixtures/zen/package/settings/plugin/settings.rb +20 -0
  207. data/spec/fixtures/zen/plugin.rb +7 -0
  208. data/spec/fixtures/zen/theme/404.xhtml +1 -0
  209. data/spec/fixtures/zen/theme/default-section/index.xhtml +1 -0
  210. data/spec/fixtures/zen/theme/helper/404.xhtml +1 -0
  211. data/spec/fixtures/zen/theme/helper/partial.xhtml +1 -0
  212. data/spec/fixtures/zen/theme/helper/wrong_partial.xhtml +1 -0
  213. data/spec/fixtures/zen/theme/partials/partial.xhtml +1 -0
  214. data/spec/fixtures/zen/theme/theme.rb +11 -0
  215. data/spec/fixtures/zen/validation.rb +22 -0
  216. data/spec/helper.rb +41 -0
  217. data/spec/zen/all.rb +5 -0
  218. data/spec/zen/asset.rb +97 -0
  219. data/spec/zen/bin/create.rb +89 -0
  220. data/spec/zen/bin/runner.rb +47 -0
  221. data/spec/zen/controller/admin_controller.rb +26 -0
  222. data/spec/zen/controller/main_controller.rb +81 -0
  223. data/spec/zen/controller/preview.rb +33 -0
  224. data/spec/zen/helper/acl.rb +149 -0
  225. data/spec/zen/helper/breadcrumb.rb +38 -0
  226. data/spec/zen/helper/message.rb +31 -0
  227. data/spec/zen/helper/theme.rb +58 -0
  228. data/spec/zen/language.rb +55 -0
  229. data/spec/zen/package.rb +23 -0
  230. data/spec/zen/package/categories/controller/categories.rb +123 -0
  231. data/spec/zen/package/categories/controller/category_groups.rb +108 -0
  232. data/spec/zen/package/categories/helper/category.rb +75 -0
  233. data/spec/zen/package/categories/plugin/categories.rb +92 -0
  234. data/spec/zen/package/comments/controller/comments.rb +134 -0
  235. data/spec/zen/package/comments/controller/comments_form.rb +343 -0
  236. data/spec/zen/package/comments/helper/comment.rb +47 -0
  237. data/spec/zen/package/comments/plugin/anti_spam.rb +59 -0
  238. data/spec/zen/package/comments/plugin/comments.rb +107 -0
  239. data/spec/zen/package/custom_fields/blue_form_parameters.rb +183 -0
  240. data/spec/zen/package/custom_fields/controller/custom_field_groups.rb +120 -0
  241. data/spec/zen/package/custom_fields/controller/custom_field_types.rb +169 -0
  242. data/spec/zen/package/custom_fields/controller/custom_fields.rb +158 -0
  243. data/spec/zen/package/custom_fields/helper/custom_field.rb +86 -0
  244. data/spec/zen/package/menus/controller/menu_items.rb +110 -0
  245. data/spec/zen/package/menus/controller/menus.rb +110 -0
  246. data/spec/zen/package/menus/helper/menu.rb +75 -0
  247. data/spec/zen/package/menus/plugin/menus.rb +120 -0
  248. data/spec/zen/package/sections/controller/section_entries.rb +201 -0
  249. data/spec/zen/package/sections/controller/sections.rb +116 -0
  250. data/spec/zen/package/sections/helper/section.rb +74 -0
  251. data/spec/zen/package/sections/plugin/section_entries.rb +161 -0
  252. data/spec/zen/package/sections/plugin/sections.rb +75 -0
  253. data/spec/zen/package/settings/controller/settings.rb +36 -0
  254. data/spec/zen/package/settings/plugin/settings.rb +33 -0
  255. data/spec/zen/package/users/controller/access_rules.rb +90 -0
  256. data/spec/zen/package/users/controller/user_groups.rb +101 -0
  257. data/spec/zen/package/users/controller/users.rb +130 -0
  258. data/spec/zen/package/users/helper/users.rb +97 -0
  259. data/spec/zen/plugin.rb +64 -0
  260. data/spec/zen/plugin/helper.rb +11 -0
  261. data/spec/zen/plugin/markup.rb +44 -0
  262. data/spec/zen/theme.rb +41 -0
  263. data/spec/zen/validation.rb +63 -0
  264. data/zen.gemspec +36 -0
  265. metadata +159 -113
  266. data/MANIFEST +0 -266
  267. data/lib/zen/bin/app.rb +0 -40
  268. data/lib/zen/ext/string.rb +0 -185
  269. data/lib/zen/helper/common.rb +0 -106
  270. data/lib/zen/package/categories/lib/categories/view/admin/categories/edit.xhtml +0 -7
  271. data/lib/zen/package/categories/lib/categories/view/admin/categories/new.xhtml +0 -7
  272. data/lib/zen/package/categories/lib/categories/view/admin/category-groups/edit.xhtml +0 -7
  273. data/lib/zen/package/categories/lib/categories/view/admin/category-groups/new.xhtml +0 -7
  274. data/lib/zen/package/comments/lib/comments/view/admin/comments/edit.xhtml +0 -7
  275. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/edit.xhtml +0 -7
  276. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-field-groups/new.xhtml +0 -7
  277. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/edit.xhtml +0 -7
  278. data/lib/zen/package/custom_fields/lib/custom_fields/view/admin/custom-fields/new.xhtml +0 -7
  279. data/lib/zen/package/menus/lib/menus/view/admin/menu-items/edit.xhtml +0 -7
  280. data/lib/zen/package/menus/lib/menus/view/admin/menu-items/new.xhtml +0 -7
  281. data/lib/zen/package/menus/lib/menus/view/admin/menus/edit.xhtml +0 -7
  282. data/lib/zen/package/menus/lib/menus/view/admin/menus/new.xhtml +0 -7
  283. data/lib/zen/package/sections/lib/sections/view/admin/edit.xhtml +0 -7
  284. data/lib/zen/package/sections/lib/sections/view/admin/new.xhtml +0 -7
  285. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/edit.xhtml +0 -7
  286. data/lib/zen/package/sections/lib/sections/view/admin/section-entries/new.xhtml +0 -7
  287. data/lib/zen/package/users/lib/users/view/admin/access-rules/edit.xhtml +0 -7
  288. data/lib/zen/package/users/lib/users/view/admin/access-rules/new.xhtml +0 -7
  289. data/lib/zen/package/users/lib/users/view/admin/user-groups/edit.xhtml +0 -7
  290. data/lib/zen/package/users/lib/users/view/admin/user-groups/new.xhtml +0 -7
  291. data/lib/zen/package/users/lib/users/view/admin/users/edit.xhtml +0 -7
  292. data/lib/zen/package/users/lib/users/view/admin/users/new.xhtml +0 -7
  293. data/lib/zen/plugin/controller.rb +0 -59
  294. data/lib/zen/public/admin/css/zen/notifications.css +0 -84
  295. data/lib/zen/public/admin/images/zen/icons/large/error.png +0 -0
  296. data/lib/zen/public/admin/images/zen/icons/large/notice.png +0 -0
  297. data/lib/zen/public/admin/images/zen/icons/large/success.png +0 -0
  298. data/lib/zen/public/admin/js/zen/core.js +0 -73
  299. data/lib/zen/public/admin/js/zen/init.js +0 -80
  300. data/proto/package/lib/package.rb +0 -21
  301. data/proto/package/lib/package/controller/controllers.rb +0 -50
  302. data/proto/package/lib/package/language/en/languages.yml +0 -4
  303. data/proto/package/lib/package/model/model.rb +0 -12
@@ -0,0 +1,134 @@
1
+ require File.expand_path('../../../../../helper', __FILE__)
2
+
3
+ describe("Comments::Controller::Comments") do
4
+ behaves_like :capybara
5
+
6
+ it("Create all test data") do
7
+ @section = Sections::Model::Section.create(
8
+ :name => 'Spec section',
9
+ :comment_allow => true,
10
+ :comment_require_account => false,
11
+ :comment_moderate => false,
12
+ :comment_format => 'markdown'
13
+ )
14
+
15
+ @entry = Sections::Model::SectionEntry.create(
16
+ :title => 'Spec entry',
17
+ :status => 'published',
18
+ :user_id => 1,
19
+ :section_id => @section.id
20
+ )
21
+
22
+ @section.name.should === 'Spec section'
23
+ @entry.title.should === 'Spec entry'
24
+ end
25
+
26
+ it('Submit a form without a CSRF token') do
27
+ response = page.driver.post(
28
+ Comments::Controller::Comments.r(:save).to_s
29
+ )
30
+
31
+ response.body.include?(lang('zen_general.errors.csrf')).should === true
32
+ response.status.should === 403
33
+ end
34
+
35
+ it("No comments should exist") do
36
+ index_url = Comments::Controller::Comments.r(:index).to_s
37
+ message = lang('comments.messages.no_comments')
38
+
39
+ visit(index_url)
40
+
41
+ page.has_content?(message).should === true
42
+ page.has_selector?('table tbody tr').should === false
43
+ end
44
+
45
+ it("Create a new comment") do
46
+ comment = Comments::Model::Comment.create(
47
+ :user_id => 1,
48
+ :section_entry_id => @entry.id,
49
+ :email => 'spec@domain.tld',
50
+ :comment => 'Spec comment'
51
+ )
52
+
53
+ index_url = Comments::Controller::Comments.r(:index).to_s
54
+ message = lang('comments.messages.no_comments')
55
+
56
+ visit(index_url)
57
+
58
+ page.has_content?(message).should === false
59
+ page.has_selector?('table tbody tr').should === true
60
+ end
61
+
62
+ it("Edit an existing comment") do
63
+ index_url = Comments::Controller::Comments.r(:index).to_s
64
+ edit_url = Comments::Controller::Comments.r(:edit).to_s
65
+ save_button = lang('comments.buttons.save')
66
+
67
+ visit(index_url)
68
+ click_link('Spec comment')
69
+
70
+ current_path.should =~ /#{edit_url}\/[0-9]+/
71
+
72
+ within('#comment_form') do
73
+ fill_in('comment', :with => 'Spec comment modified')
74
+ select(lang('comments.labels.open'), :from => 'comment_status_id')
75
+ click_on(save_button)
76
+ end
77
+
78
+ page.find('textarea[name="comment"]').value \
79
+ .should === 'Spec comment modified'
80
+
81
+ page.find('select[name="comment_status_id"] option[selected]').text \
82
+ .should === lang('comments.labels.open')
83
+ end
84
+
85
+ it("Edit an existing comment with invalid data") do
86
+ index_url = Comments::Controller::Comments.r(:index).to_s
87
+ edit_url = Comments::Controller::Comments.r(:edit).to_s
88
+ save_button = lang('comments.buttons.save')
89
+
90
+ visit(index_url)
91
+ click_link('Spec comment')
92
+
93
+ current_path.should =~ /#{edit_url}\/[0-9]+/
94
+
95
+ within('#comment_form') do
96
+ fill_in('comment', :with => '')
97
+ click_on(save_button)
98
+ end
99
+
100
+ page.has_selector?('span.error').should === true
101
+ end
102
+
103
+ it('Try to delete a set of comments without IDs') do
104
+ index_url = Comments::Controller::Comments.r(:index).to_s
105
+ delete_button = lang('comments.buttons.delete')
106
+
107
+ visit(index_url)
108
+ click_on(delete_button)
109
+
110
+ page.has_selector?('input[name="comment_ids[]"]').should === true
111
+ end
112
+
113
+ it("Delete an existing comment") do
114
+ index_url = Comments::Controller::Comments.r(:index).to_s
115
+ delete_button = lang('comments.buttons.delete')
116
+ message = lang('comments.messages.no_comments')
117
+
118
+ visit(index_url)
119
+ check('comment_ids[]')
120
+ click_on(delete_button)
121
+
122
+ page.has_content?(message).should === true
123
+ page.has_selector?('table tbody tr').should === false
124
+ end
125
+
126
+ it("Delete all test data") do
127
+ @entry.destroy
128
+ @section.destroy
129
+
130
+ Sections::Model::Section.filter[:name => 'Spec section'].should === nil
131
+ Sections::Model::SectionEntry.filter[:title => 'Spec entry'].should === nil
132
+ end
133
+
134
+ end
@@ -0,0 +1,343 @@
1
+ require File.expand_path('../../../../../helper', __FILE__)
2
+ require File.join(Zen::Fixtures, 'package/comments/controller/comments_form')
3
+
4
+ describe("Comments::Controller::CommentsForm") do
5
+ behaves_like :capybara
6
+
7
+ before do
8
+ plugin(:settings, :get, :defensio_key).value = 'test'
9
+ end
10
+
11
+ after do
12
+ Comments::Model::Comment.destroy
13
+ plugin(:settings, :get, :defensio_key).value = nil
14
+ end
15
+
16
+ it('Create the test data') do
17
+ user_id = Users::Model::User[:name => 'Spec'].id
18
+ entry_status = Sections::Model::SectionEntryStatus[:name => 'published'].id
19
+
20
+ @section = Sections::Model::Section.create(
21
+ :name => 'Spec section',
22
+ :comment_allow => true,
23
+ :comment_require_account => true,
24
+ :comment_moderate => false,
25
+ :comment_format => 'plain'
26
+ )
27
+
28
+ @section_entry = Sections::Model::SectionEntry.create(
29
+ :title => 'Spec entry',
30
+ :user_id => user_id,
31
+ :section_entry_status_id => entry_status,
32
+ :section_id => @section.id
33
+ )
34
+
35
+ @section.name.should === 'Spec section'
36
+ @section_entry.title.should === 'Spec entry'
37
+
38
+ Comments::Model::Comment.all.empty?.should === true
39
+ end
40
+
41
+ it('Submit a comment') do
42
+ visit(SpecCommentsForm.r(:index).to_s)
43
+
44
+ # Submit the form
45
+ within('#spec_comments_form') do
46
+ fill_in('section_entry', :with => @section_entry.id)
47
+ fill_in('name' , :with => 'Spec user')
48
+ fill_in('website' , :with => 'http://zen-cms.com/')
49
+ fill_in('email' , :with => 'spec@domain.tld')
50
+ fill_in('comment' , :with => 'Spec comment')
51
+
52
+ click_on('Submit')
53
+ end
54
+
55
+ # Let's see if the comment exists
56
+ comment = Comments::Model::Comment[:comment => 'Spec comment']
57
+
58
+ comment.name.should === 'Spec user'
59
+ comment.comment.should === 'Spec comment'
60
+ comment.website.should === 'http://zen-cms.com/'
61
+ comment.email.should === 'spec@domain.tld'
62
+ comment.section_entry_id === @section_entry.id
63
+ end
64
+
65
+ it('Submit a comment without a CSRF token') do
66
+ url = Comments::Controller::CommentsForm.r(:save).to_s
67
+ response = page.driver.post(url)
68
+
69
+ response.body.should === lang('zen_general.errors.not_authorized')
70
+ response.status.should === 403
71
+ end
72
+
73
+ it('Submit a comment with an invalid entry') do
74
+ url = SpecCommentsForm.r(:index).to_s
75
+
76
+ visit(url)
77
+
78
+ within('#spec_comments_form') do
79
+ fill_in('section_entry', :with => @section_entry.id + 1)
80
+ fill_in('name' , :with => 'Spec user')
81
+ fill_in('website' , :with => 'http://zen-cms.com/')
82
+ fill_in('email' , :with => 'spec@domain.tld')
83
+ fill_in('comment' , :with => 'Spec comment')
84
+
85
+ click_on('Submit')
86
+ end
87
+
88
+ page.body.include?(lang('comments.errors.invalid_entry')) \
89
+ .should === true
90
+
91
+ current_path.should === url
92
+ end
93
+
94
+ it('Submit a comment for an invalid section') do
95
+ old_id = @section_entry.section_id
96
+ url = SpecCommentsForm.r(:index).to_s
97
+
98
+ @section_entry.update(:section_id => nil)
99
+
100
+ visit(url)
101
+
102
+ within('#spec_comments_form') do
103
+ fill_in('section_entry', :with => @section_entry.id)
104
+ fill_in('name' , :with => 'Spec user')
105
+ fill_in('website' , :with => 'http://zen-cms.com/')
106
+ fill_in('email' , :with => 'spec@domain.tld')
107
+ fill_in('comment' , :with => 'Spec comment')
108
+
109
+ click_on('Submit')
110
+ end
111
+
112
+ page.body.include?(lang('comments.errors.invalid_entry')) \
113
+ .should === true
114
+
115
+ current_path.should === url
116
+
117
+ @section_entry.update(:section_id => old_id)
118
+ end
119
+
120
+ it('Submit a comment for a section that does not allow comments') do
121
+ url = SpecCommentsForm.r(:index).to_s
122
+
123
+ @section.update(:comment_allow => false)
124
+ visit(url)
125
+
126
+ within('#spec_comments_form') do
127
+ fill_in('section_entry', :with => @section_entry.id)
128
+ fill_in('name' , :with => 'S)ec user')
129
+ fill_in('website' , :with => 'http://zen-cms.com/')
130
+ fill_in('email' , :with => 'spec@domain.tld')
131
+ fill_in('comment' , :with => 'Spec comment')
132
+
133
+ click_on('Submit')
134
+ end
135
+
136
+ page.body.include?(lang('comments.errors.comments_not_allowed')) \
137
+ .should === true
138
+
139
+ current_path.should === url
140
+
141
+ @section.update(:comment_allow => true)
142
+ end
143
+
144
+ it('Submit a comment when not logged in') do
145
+ url = SpecCommentsForm.r(:index).to_s
146
+
147
+ visit(Users::Controller::Users.r(:logout).to_s)
148
+ visit(url)
149
+
150
+ within('#spec_comments_form') do
151
+ fill_in('section_entry', :with => @section_entry.id)
152
+ fill_in('name' , :with => 'Spec user')
153
+ fill_in('website' , :with => 'http://zen-cms.com/')
154
+ fill_in('email' , :with => 'spec@domain.tld')
155
+ fill_in('comment' , :with => 'Spec comment')
156
+
157
+ click_on('Submit')
158
+ end
159
+
160
+ page.body.include?(lang('comments.errors.comments_require_account')) \
161
+ .should === true
162
+
163
+ current_path.should === url
164
+
165
+ # Log back in
166
+ capybara_login
167
+ end
168
+
169
+ it('Submit a comment with moderation turned on') do
170
+ @section.update(:comment_moderate => true)
171
+
172
+ url = SpecCommentsForm.r(:index).to_s
173
+ closed_status = Comments::Model::CommentStatus[:name => 'closed']
174
+
175
+ visit(url)
176
+
177
+ within('#spec_comments_form') do
178
+ fill_in('section_entry', :with => @section_entry.id)
179
+ fill_in('name' , :with => 'Spec user')
180
+ fill_in('website' , :with => 'http://zen-cms.com/')
181
+ fill_in('email' , :with => 'spec@domain.tld')
182
+ fill_in('comment' , :with => 'Spec comment')
183
+
184
+ click_on('Submit')
185
+ end
186
+
187
+ page.body.include?(lang('comments.success.moderate')).should === true
188
+ current_path.should === url
189
+
190
+ Comments::Model::Comment[:comment => 'Spec comment'] \
191
+ .comment_status_id.should === closed_status.id
192
+
193
+ @section.update(:comment_moderate => false)
194
+ end
195
+
196
+ it('Submit a comment and mark it as ham') do
197
+ yaml_response = <<-YAML.strip
198
+ defensio-result:
199
+ api-version: 2.0
200
+ status: success
201
+ message:
202
+ signature: 1234abc
203
+ allow: true
204
+ classification: innocent
205
+ spaminess: 0.5
206
+ profanity-match: false
207
+ YAML
208
+
209
+ stub_request(
210
+ :post,
211
+ 'http://api.defensio.com/2.0/users/test/documents.yaml'
212
+ ).to_return(:body => yaml_response)
213
+
214
+ plugin(:settings, :get, :enable_antispam).value = '1'
215
+
216
+ url = SpecCommentsForm.r(:index).to_s
217
+ open_status = Comments::Model::CommentStatus[:name => 'open']
218
+
219
+ visit(url)
220
+
221
+ within('#spec_comments_form') do
222
+ fill_in('section_entry', :with => @section_entry.id)
223
+ fill_in('name' , :with => 'Spec alternative')
224
+ fill_in('website' , :with => 'http://zen-cms.com/')
225
+ fill_in('email' , :with => 'spec@domain.tld')
226
+ fill_in('comment' , :with => 'COMMENT')
227
+
228
+ click_on('Submit')
229
+ end
230
+
231
+ page.body.include?(lang('comments.success.new')).should === true
232
+ current_path.should === url
233
+
234
+ Comments::Model::Comment[:name => 'Spec alternative'] \
235
+ .comment_status_id.should === open_status.id
236
+
237
+ plugin(:settings, :get, :enable_antispam).value = '0'
238
+ WebMock.reset!
239
+ end
240
+
241
+ it('Submit a comment and mark it as ham with moderation turned on') do
242
+ yaml_response = <<-YAML.strip
243
+ defensio-result:
244
+ api-version: 2.0
245
+ status: success
246
+ message:
247
+ signature: 1234abc
248
+ allow: true
249
+ classification: innocent
250
+ spaminess: 0.5
251
+ profanity-match: false
252
+ YAML
253
+
254
+ stub_request(
255
+ :post,
256
+ 'http://api.defensio.com/2.0/users/test/documents.yaml'
257
+ ).to_return(:body => yaml_response)
258
+
259
+ plugin(:settings, :get, :enable_antispam).value = '1'
260
+
261
+ @section.update(:comment_moderate => true)
262
+
263
+ url = SpecCommentsForm.r(:index).to_s
264
+ closed_status = Comments::Model::CommentStatus[:name => 'closed']
265
+
266
+ visit(url)
267
+
268
+ within('#spec_comments_form') do
269
+ fill_in('section_entry', :with => @section_entry.id)
270
+ fill_in('name' , :with => 'Spec alternative')
271
+ fill_in('website' , :with => 'http://zen-cms.com/')
272
+ fill_in('email' , :with => 'spec@domain.tld')
273
+ fill_in('comment' , :with => 'COMMENT')
274
+
275
+ click_on('Submit')
276
+ end
277
+
278
+ page.body.include?(lang('comments.success.moderate')).should === true
279
+ current_path.should === url
280
+
281
+ Comments::Model::Comment[:name => 'Spec alternative'] \
282
+ .comment_status_id.should === closed_status.id
283
+
284
+ plugin(:settings, :get, :enable_antispam).value = '0'
285
+ WebMock.reset!
286
+
287
+ @section.update(:comment_moderate => false)
288
+ end
289
+
290
+ it('Submit a comment and mark it as spam') do
291
+ yaml_response = <<-YAML.strip
292
+ defensio-result:
293
+ api-version: 2.0
294
+ status: success
295
+ message:
296
+ signature: 1234abc
297
+ allow: false
298
+ classification: spam
299
+ spaminess: 0.9
300
+ profanity-match: false
301
+ YAML
302
+
303
+ stub_request(
304
+ :post,
305
+ 'http://api.defensio.com/2.0/users/test/documents.yaml'
306
+ ).to_return(:body => yaml_response)
307
+
308
+ plugin(:settings, :get, :enable_antispam).value = '1'
309
+
310
+ url = SpecCommentsForm.r(:index).to_s
311
+ spam_status = Comments::Model::CommentStatus[:name => 'spam']
312
+
313
+ visit(url)
314
+
315
+ within('#spec_comments_form') do
316
+ fill_in('section_entry', :with => @section_entry.id)
317
+ fill_in('name' , :with => 'Spec alternative')
318
+ fill_in('website' , :with => 'http://zen-cms.com/')
319
+ fill_in('email' , :with => 'spec@domain.tld')
320
+ fill_in('comment' , :with => 'COMMENT')
321
+
322
+ click_on('Submit')
323
+ end
324
+
325
+ page.body.include?(lang('comments.success.new')).should === true
326
+ current_path.should === url
327
+
328
+ Comments::Model::Comment[:name => 'Spec alternative'] \
329
+ .comment_status_id.should === spam_status.id
330
+
331
+ plugin(:settings, :get, :enable_antispam).value = '0'
332
+ WebMock.reset!
333
+ end
334
+
335
+ it('Delete the test data') do
336
+ @section_entry.destroy
337
+ @section.destroy
338
+
339
+ Sections::Model::Section[:name => 'Spec section'].should === nil
340
+ Sections::Model::SectionEntry[:title => 'Spec entry'].should === nil
341
+ end
342
+
343
+ end