decidim 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of decidim might be problematic. Click here for more details.

Files changed (251) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE.md +23 -4
  3. data/.travis.yml +4 -1
  4. data/Gemfile.lock +56 -48
  5. data/Rakefile +1 -1
  6. data/decidim-admin/app/commands/decidim/admin/create_participatory_process_admin.rb +3 -0
  7. data/decidim-admin/app/commands/decidim/admin/update_feature_permissions.rb +46 -0
  8. data/decidim-admin/app/commands/decidim/admin/update_organization.rb +17 -2
  9. data/decidim-admin/app/commands/decidim/admin/update_participatory_process.rb +4 -2
  10. data/decidim-admin/app/controllers/decidim/admin/application_controller.rb +3 -0
  11. data/decidim-admin/app/controllers/decidim/admin/feature_permissions_controller.rb +59 -0
  12. data/decidim-admin/app/controllers/decidim/admin/features_controller.rb +20 -0
  13. data/decidim-admin/app/controllers/decidim/admin/users_controller.rb +3 -1
  14. data/decidim-admin/app/forms/decidim/admin/organization_form.rb +10 -0
  15. data/decidim-admin/app/forms/decidim/admin/participatory_process_form.rb +8 -5
  16. data/decidim-admin/app/forms/decidim/admin/permission_form.rb +31 -0
  17. data/decidim-admin/app/forms/decidim/admin/permissions_form.rb +16 -0
  18. data/decidim-admin/app/helpers/decidim/admin/application_helper.rb +1 -0
  19. data/decidim-admin/app/models/decidim/admin/participatory_process_user_role.rb +1 -1
  20. data/decidim-admin/app/views/decidim/admin/attachments/edit.html.erb +1 -1
  21. data/decidim-admin/app/views/decidim/admin/attachments/new.html.erb +1 -1
  22. data/decidim-admin/app/views/decidim/admin/categories/edit.html.erb +1 -1
  23. data/decidim-admin/app/views/decidim/admin/categories/new.html.erb +1 -1
  24. data/decidim-admin/app/views/decidim/admin/dashboard/show.html.erb +1 -1
  25. data/decidim-admin/app/views/decidim/admin/feature_permissions/edit.html.erb +27 -0
  26. data/decidim-admin/app/views/decidim/admin/features/_feature.html.erb +10 -0
  27. data/decidim-admin/app/views/decidim/admin/features/edit.html.erb +1 -1
  28. data/decidim-admin/app/views/decidim/admin/features/new.html.erb +1 -1
  29. data/decidim-admin/app/views/decidim/admin/organization/_form.html.erb +34 -0
  30. data/decidim-admin/app/views/decidim/admin/organization/edit.html.erb +2 -2
  31. data/decidim-admin/app/views/decidim/admin/participatory_process_steps/edit.html.erb +1 -1
  32. data/decidim-admin/app/views/decidim/admin/participatory_process_steps/new.html.erb +1 -1
  33. data/decidim-admin/app/views/decidim/admin/participatory_process_user_roles/index.html.erb +1 -1
  34. data/decidim-admin/app/views/decidim/admin/participatory_processes/_form.html.erb +17 -4
  35. data/decidim-admin/app/views/decidim/admin/participatory_processes/edit.html.erb +1 -1
  36. data/decidim-admin/app/views/decidim/admin/participatory_processes/index.html.erb +1 -1
  37. data/decidim-admin/app/views/decidim/admin/participatory_processes/new.html.erb +2 -2
  38. data/decidim-admin/app/views/decidim/admin/participatory_processes/show.html.erb +5 -2
  39. data/decidim-admin/app/views/decidim/admin/scopes/edit.html.erb +2 -2
  40. data/decidim-admin/app/views/decidim/admin/scopes/index.html.erb +1 -1
  41. data/decidim-admin/app/views/decidim/admin/scopes/new.html.erb +2 -2
  42. data/decidim-admin/app/views/decidim/admin/static_pages/_form.html.erb +1 -1
  43. data/decidim-admin/app/views/decidim/admin/static_pages/edit.html.erb +2 -2
  44. data/decidim-admin/app/views/decidim/admin/static_pages/index.html.erb +1 -1
  45. data/decidim-admin/app/views/decidim/admin/static_pages/new.html.erb +2 -2
  46. data/decidim-admin/app/views/decidim/admin/static_pages/show.html.erb +1 -1
  47. data/decidim-admin/app/views/decidim/admin/user_groups/index.html.erb +1 -1
  48. data/decidim-admin/app/views/decidim/admin/users/index.html.erb +1 -1
  49. data/decidim-admin/app/views/decidim/admin/users/new.html.erb +2 -2
  50. data/decidim-admin/app/views/layouts/decidim/admin/participatory_process.html.erb +1 -1
  51. data/decidim-admin/config/i18n-tasks.yml +4 -3
  52. data/decidim-admin/config/locales/ca.yml +20 -1
  53. data/decidim-admin/config/locales/en.yml +19 -0
  54. data/decidim-admin/config/locales/es.yml +19 -0
  55. data/decidim-admin/config/locales/eu.yml +5 -0
  56. data/decidim-admin/config/routes.rb +8 -1
  57. data/decidim-admin/db/seeds.rb +3 -1
  58. data/decidim-admin/spec/commands/create_participatory_process_admin_spec.rb +19 -0
  59. data/decidim-admin/spec/commands/update_organization_spec.rb +20 -0
  60. data/decidim-admin/spec/features/admin_invite_spec.rb +5 -3
  61. data/decidim-admin/spec/features/admin_manages_feature_permissions_spec.rb +44 -0
  62. data/decidim-admin/spec/features/admin_manages_features_spec.rb +38 -0
  63. data/decidim-admin/spec/features/admin_manages_participatory_process_admins_spec.rb +0 -2
  64. data/decidim-admin/spec/features/admin_manages_participatory_process_attachments_spec.rb +0 -2
  65. data/decidim-admin/spec/features/admin_manages_participatory_process_categories_spec.rb +0 -2
  66. data/decidim-admin/spec/features/admin_manages_participatory_process_steps_spec.rb +0 -2
  67. data/decidim-admin/spec/features/admin_manages_participatory_processes_spec.rb +0 -2
  68. data/decidim-admin/spec/features/admin_manages_user_groups_spec.rb +1 -3
  69. data/decidim-admin/spec/features/participatory_process_admin_manages_participatory_process_admins_spec.rb +0 -2
  70. data/decidim-admin/spec/features/participatory_process_admin_manages_participatory_process_attachments_spec.rb +0 -2
  71. data/decidim-admin/spec/features/participatory_process_admin_manages_participatory_process_steps_spec.rb +0 -2
  72. data/decidim-admin/spec/features/participatory_process_admin_manages_participatory_processes_spec.rb +0 -2
  73. data/decidim-admin/spec/features/process_admin_manages_participatory_process_categories_spec.rb +0 -2
  74. data/decidim-admin/spec/forms/organization_form_spec.rb +11 -2
  75. data/decidim-admin/spec/models/participatory_process_user_role_spec.rb +17 -0
  76. data/decidim-admin/spec/shared/manage_process_steps_examples.rb +3 -2
  77. data/decidim-budgets/app/assets/images/decidim/budgets/icon.svg +16 -4
  78. data/decidim-budgets/app/assets/javascripts/decidim/budgets/progressFixed.js.es6 +23 -0
  79. data/decidim-budgets/app/assets/javascripts/decidim/budgets/projects.js.es6 +1 -0
  80. data/decidim-budgets/app/assets/stylesheets/decidim/budgets/budget/_budget-list.scss +1 -1
  81. data/decidim-budgets/app/commands/decidim/budgets/admin/create_project.rb +0 -1
  82. data/decidim-budgets/app/commands/decidim/budgets/admin/update_project.rb +0 -1
  83. data/decidim-budgets/app/controllers/decidim/budgets/admin/application_controller.rb +9 -0
  84. data/decidim-budgets/app/controllers/decidim/budgets/admin/attachments_controller.rb +29 -0
  85. data/decidim-budgets/app/controllers/decidim/budgets/line_items_controller.rb +2 -0
  86. data/decidim-budgets/app/controllers/decidim/budgets/orders_controller.rb +2 -0
  87. data/decidim-budgets/app/forms/decidim/budgets/admin/project_form.rb +1 -2
  88. data/decidim-budgets/app/models/decidim/budgets/project.rb +1 -0
  89. data/decidim-budgets/app/services/decidim/budgets/project_search.rb +0 -1
  90. data/decidim-budgets/app/views/decidim/budgets/admin/projects/_form.html.erb +0 -4
  91. data/decidim-budgets/app/views/decidim/budgets/admin/projects/edit.html.erb +1 -1
  92. data/decidim-budgets/app/views/decidim/budgets/admin/projects/index.html.erb +1 -0
  93. data/decidim-budgets/app/views/decidim/budgets/admin/projects/new.html.erb +1 -1
  94. data/decidim-budgets/app/views/decidim/budgets/line_items/update_budget.js.erb +2 -0
  95. data/decidim-budgets/app/views/decidim/budgets/projects/_project.html.erb +2 -2
  96. data/decidim-budgets/app/views/decidim/budgets/projects/_project_budget_button.html.erb +2 -2
  97. data/decidim-budgets/app/views/decidim/budgets/projects/index.html.erb +3 -2
  98. data/decidim-budgets/app/views/decidim/budgets/projects/show.html.erb +3 -7
  99. data/decidim-budgets/config/i18n-tasks.yml +1 -0
  100. data/decidim-budgets/config/locales/ca.yml +24 -5
  101. data/decidim-budgets/config/locales/en.yml +12 -3
  102. data/decidim-budgets/config/locales/es.yml +22 -3
  103. data/decidim-budgets/config/locales/eu.yml +5 -0
  104. data/decidim-budgets/db/migrate/20170207101750_remove_short_description_from_decidim_projects.rb +5 -0
  105. data/decidim-budgets/decidim-budgets.gemspec +1 -0
  106. data/decidim-budgets/lib/decidim/budgets/admin_engine.rb +4 -1
  107. data/decidim-budgets/lib/decidim/budgets/feature.rb +15 -4
  108. data/decidim-budgets/lib/decidim/budgets/test/factories.rb +2 -3
  109. data/decidim-budgets/spec/commands/create_project_spec.rb +0 -1
  110. data/decidim-budgets/spec/commands/update_project_spec.rb +0 -1
  111. data/decidim-budgets/spec/features/admin_manages_project_attachments_spec.rb +10 -0
  112. data/decidim-budgets/spec/features/admin_manages_projects_spec.rb +0 -2
  113. data/decidim-budgets/spec/features/orders_spec.rb +43 -5
  114. data/decidim-budgets/spec/features/process_admin_manages_project_attachments_spec.rb +12 -0
  115. data/decidim-budgets/spec/features/process_admin_manages_projects_spec.rb +0 -2
  116. data/decidim-budgets/spec/forms/project_form_spec.rb +0 -10
  117. data/decidim-budgets/spec/shared/manage_attachments_examples.rb +17 -0
  118. data/decidim-budgets/spec/shared/manage_projects_examples.rb +0 -7
  119. data/decidim-comments/app/assets/javascripts/decidim/comments/bundle.js +0 -0
  120. data/decidim-comments/app/commands/decidim/comments/create_comment.rb +10 -0
  121. data/decidim-comments/app/forms/decidim/comments/comment_form.rb +1 -1
  122. data/decidim-comments/app/frontend/comments/add_comment_form.component.jsx +33 -12
  123. data/decidim-comments/app/frontend/comments/add_comment_form.component.test.jsx +6 -0
  124. data/decidim-comments/app/frontend/comments/comment.component.jsx +7 -5
  125. data/decidim-comments/app/frontend/comments/comment_order_selector.component.jsx +2 -2
  126. data/decidim-comments/app/frontend/comments/comment_thread.component.jsx +5 -0
  127. data/decidim-comments/app/frontend/comments/comments.component.jsx +11 -0
  128. data/decidim-comments/app/frontend/comments/vote_button.component.jsx +5 -0
  129. data/decidim-comments/app/frontend/comments/vote_button_component.test.jsx +1 -1
  130. data/decidim-comments/app/frontend/entry.test.js +2 -0
  131. data/decidim-comments/app/mailers/decidim/comments/comment_notification_mailer.rb +31 -0
  132. data/decidim-comments/app/models/decidim/comments/comment.rb +6 -0
  133. data/decidim-comments/app/views/decidim/comments/comment_notification_mailer/comment_created.html.erb +18 -0
  134. data/decidim-comments/app/views/decidim/comments/comment_notification_mailer/reply_created.html.erb +18 -0
  135. data/decidim-comments/config/locales/ca.yml +17 -3
  136. data/decidim-comments/config/locales/en.yml +17 -3
  137. data/decidim-comments/config/locales/es.yml +17 -3
  138. data/decidim-comments/config/locales/eu.yml +5 -0
  139. data/decidim-comments/lib/decidim/comments.rb +1 -0
  140. data/decidim-comments/{app/helpers → lib}/decidim/comments/comments_helper.rb +0 -0
  141. data/decidim-comments/spec/commands/create_comment_spec.rb +68 -1
  142. data/decidim-comments/spec/features/comments_spec.rb +27 -20
  143. data/decidim-comments/spec/features/notifications_spec.rb +45 -0
  144. data/decidim-comments/spec/forms/comment_form_spec.rb +6 -0
  145. data/decidim-comments/spec/mailers/comment_notification_mailer_spec.rb +36 -0
  146. data/decidim-comments/spec/models/comment_spec.rb +8 -0
  147. data/decidim-comments/spec/spec_helper.rb +0 -1
  148. data/decidim-comments/spec/types/mutation_type_spec.rb +8 -7
  149. data/decidim-dev/config/locales/ca.yml +5 -0
  150. data/decidim-dev/config/locales/es.yml +5 -0
  151. data/decidim-dev/config/locales/eu.yml +5 -0
  152. data/decidim-dev/decidim-dev.gemspec +2 -1
  153. data/decidim-dev/lib/decidim/dev.rb +2 -0
  154. data/decidim-dev/lib/decidim/dev/dummy_authorization_handler.rb +1 -0
  155. data/decidim-dev/lib/decidim/dev/test/base_spec_helper.rb +4 -1
  156. data/decidim-dev/lib/decidim/dev/test/rspec_support/action_mailer.rb +19 -0
  157. data/decidim-dev/lib/decidim/dev/test/rspec_support/feature.rb +26 -3
  158. data/decidim-dev/lib/decidim/dev/test/rspec_support/translation_helpers.rb +1 -1
  159. data/decidim-meetings/app/forms/decidim/meetings/admin/meeting_form.rb +2 -2
  160. data/decidim-meetings/app/views/decidim/meetings/admin/meeting_closes/edit.html.erb +1 -1
  161. data/decidim-meetings/app/views/decidim/meetings/admin/meetings/edit.html.erb +1 -1
  162. data/decidim-meetings/app/views/decidim/meetings/admin/meetings/new.html.erb +1 -1
  163. data/decidim-meetings/app/views/decidim/meetings/meetings/index.html.erb +3 -1
  164. data/decidim-meetings/app/views/decidim/meetings/meetings/show.html.erb +11 -1
  165. data/decidim-meetings/config/locales/ca.yml +3 -3
  166. data/decidim-meetings/config/locales/en.yml +1 -1
  167. data/decidim-meetings/config/locales/es.yml +1 -1
  168. data/decidim-meetings/config/locales/eu.yml +5 -0
  169. data/decidim-meetings/decidim-meetings.gemspec +1 -1
  170. data/decidim-meetings/lib/decidim/meetings/feature.rb +1 -0
  171. data/decidim-meetings/spec/features/admin_manages_meetings_attachments_spec.rb +0 -2
  172. data/decidim-meetings/spec/features/admin_manages_meetings_spec.rb +0 -2
  173. data/decidim-meetings/spec/features/process_admin_manages_meetings_attachments_spec.rb +0 -2
  174. data/decidim-meetings/spec/features/process_admin_manages_meetings_spec.rb +0 -2
  175. data/decidim-pages/app/assets/images/decidim/pages/icon.svg +1 -3
  176. data/decidim-pages/app/views/decidim/pages/admin/pages/edit.html.erb +1 -1
  177. data/decidim-pages/app/views/decidim/pages/application/show.html.erb +4 -1
  178. data/decidim-pages/config/locales/eu.yml +7 -0
  179. data/decidim-pages/lib/decidim/pages/feature.rb +1 -0
  180. data/decidim-proposals/app/controllers/decidim/proposals/proposals_controller.rb +42 -5
  181. data/decidim-proposals/app/forms/decidim/proposals/proposal_form.rb +3 -1
  182. data/decidim-proposals/app/helpers/decidim/proposals/proposal_votes_helper.rb +1 -1
  183. data/decidim-proposals/app/models/decidim/proposals/abilities/current_user.rb +22 -4
  184. data/decidim-proposals/app/models/decidim/proposals/proposal.rb +2 -2
  185. data/decidim-proposals/app/services/decidim/proposals/proposal_search.rb +25 -13
  186. data/decidim-proposals/app/views/decidim/proposals/admin/proposal_answers/edit.html.erb +1 -1
  187. data/decidim-proposals/app/views/decidim/proposals/admin/proposals/new.html.erb +1 -1
  188. data/decidim-proposals/app/views/decidim/proposals/proposals/_filters.html.erb +9 -1
  189. data/decidim-proposals/app/views/decidim/proposals/proposals/_proposal.html.erb +2 -6
  190. data/decidim-proposals/app/views/decidim/proposals/proposals/_proposals.html.erb +2 -1
  191. data/decidim-proposals/app/views/decidim/proposals/proposals/_tags.html.erb +10 -0
  192. data/decidim-proposals/app/views/decidim/proposals/proposals/_vote_button.html.erb +9 -9
  193. data/decidim-proposals/app/views/decidim/proposals/proposals/_votes_count.html.erb +2 -2
  194. data/decidim-proposals/app/views/decidim/proposals/proposals/index.html.erb +7 -3
  195. data/decidim-proposals/app/views/decidim/proposals/proposals/index.js.erb +6 -1
  196. data/decidim-proposals/app/views/decidim/proposals/proposals/new.html.erb +1 -1
  197. data/decidim-proposals/app/views/decidim/proposals/proposals/show.html.erb +22 -23
  198. data/decidim-proposals/config/i18n-tasks.yml +2 -0
  199. data/decidim-proposals/config/locales/ca.yml +23 -15
  200. data/decidim-proposals/config/locales/en.yml +12 -4
  201. data/decidim-proposals/config/locales/es.yml +12 -4
  202. data/decidim-proposals/config/locales/eu.yml +5 -0
  203. data/decidim-proposals/db/migrate/20170205082832_add_index_to_decidim_proposals_proposals_proposal_votes_count.rb +7 -0
  204. data/decidim-proposals/lib/decidim/proposals/feature.rb +10 -1
  205. data/decidim-proposals/lib/decidim/proposals/test/factories.rb +1 -1
  206. data/decidim-proposals/spec/commands/decidim/proposals/admin_create_proposal_spec.rb +0 -1
  207. data/decidim-proposals/spec/commands/decidim/proposals/create_proposal_spec.rb +0 -1
  208. data/decidim-proposals/spec/features/admin_manages_proposals_spec.rb +0 -2
  209. data/decidim-proposals/spec/features/process_admin_manages_proposals_spec.rb +0 -2
  210. data/decidim-proposals/spec/features/proposals_spec.rb +77 -0
  211. data/decidim-proposals/spec/features/vote_proposal_spec.rb +16 -1
  212. data/decidim-proposals/spec/forms/decidim/proposals/admin_proposal_form_spec.rb +0 -1
  213. data/decidim-proposals/spec/forms/decidim/proposals/proposal_form_spec.rb +0 -1
  214. data/decidim-proposals/spec/helpers/proposal_votes_helper_spec.rb +10 -0
  215. data/decidim-proposals/spec/services/decidim/proposals/proposal_search_spec.rb +56 -31
  216. data/decidim-proposals/spec/shared/create_proposal_examples.rb +2 -2
  217. data/decidim-results/app/views/decidim/results/admin/results/edit.html.erb +1 -1
  218. data/decidim-results/app/views/decidim/results/admin/results/new.html.erb +1 -1
  219. data/decidim-results/app/views/decidim/results/results/index.html.erb +3 -1
  220. data/decidim-results/app/views/decidim/results/results/show.html.erb +11 -1
  221. data/decidim-results/config/locales/ca.yml +2 -2
  222. data/decidim-results/config/locales/en.yml +1 -1
  223. data/decidim-results/config/locales/es.yml +1 -1
  224. data/decidim-results/config/locales/eu.yml +5 -0
  225. data/decidim-results/lib/decidim/results/feature.rb +1 -0
  226. data/decidim-results/spec/features/admin_manages_results_spec.rb +0 -2
  227. data/decidim-results/spec/features/process_admin_manages_results_spec.rb +0 -2
  228. data/decidim-system/app/assets/stylesheets/decidim/system/_foundation_and_overrides.scss +1 -1
  229. data/decidim-system/app/controllers/decidim/system/application_controller.rb +1 -0
  230. data/decidim-system/app/controllers/decidim/system/devise/sessions_controller.rb +1 -0
  231. data/decidim-system/app/views/decidim/system/admins/edit.html.erb +2 -2
  232. data/decidim-system/app/views/decidim/system/admins/index.html.erb +1 -1
  233. data/decidim-system/app/views/decidim/system/admins/new.html.erb +2 -2
  234. data/decidim-system/app/views/decidim/system/admins/show.html.erb +1 -1
  235. data/decidim-system/app/views/decidim/system/dashboard/show.html.erb +1 -1
  236. data/decidim-system/app/views/decidim/system/devise/passwords/edit.html.erb +1 -1
  237. data/decidim-system/app/views/decidim/system/devise/passwords/new.html.erb +1 -1
  238. data/decidim-system/app/views/decidim/system/devise/sessions/new.html.erb +1 -1
  239. data/decidim-system/app/views/decidim/system/organizations/edit.html.erb +1 -1
  240. data/decidim-system/app/views/decidim/system/organizations/index.html.erb +1 -1
  241. data/decidim-system/app/views/decidim/system/organizations/new.html.erb +2 -2
  242. data/decidim-system/app/views/decidim/system/organizations/show.html.erb +1 -1
  243. data/decidim-system/config/locales/eu.yml +7 -0
  244. data/decidim-system/spec/features/organizations_spec.rb +1 -2
  245. data/lib/generators/decidim/install_generator.rb +9 -0
  246. data/lib/generators/decidim/templates/initializer.rb +1 -0
  247. data/package.json +6 -6
  248. data/yarn.lock +743 -738
  249. metadata +53 -25
  250. data/decidim-comments/spec/support/dummy.rb +0 -20
  251. data/decidim-proposals/app/views/decidim/proposals/proposals/_share.html.erb +0 -33
@@ -9,6 +9,8 @@ import chaiEnzyme from 'chai-enzyme';
9
9
  import loadTranslations from './support/load_translations';
10
10
  import requireAll from './support/require_all';
11
11
 
12
+ require('jquery');
13
+
12
14
  //
13
15
  chai.use(sinonChai)
14
16
  chai.use(chaiAsPromised)
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+ module Decidim
3
+ module Comments
4
+ # A custom mailer for sending notifications to users when
5
+ # a comment is created.
6
+ class CommentNotificationMailer < Decidim::ApplicationMailer
7
+ helper Decidim::ResourceHelper
8
+
9
+ def comment_created(user, comment, commentable)
10
+ with_user(user) do
11
+ @comment = comment
12
+ @commentable = commentable
13
+ @organization = commentable.organization
14
+ subject = I18n.t("comment_created.subject", scope: "decidim.comments.mailer.comment_notification")
15
+ mail(to: commentable.author.email, subject: subject)
16
+ end
17
+ end
18
+
19
+ def reply_created(user, reply, comment, commentable)
20
+ with_user(user) do
21
+ @reply = reply
22
+ @comment = comment
23
+ @commentable = commentable
24
+ @organization = commentable.organization
25
+ subject = I18n.t("reply_created.subject", scope: "decidim.comments.mailer.comment_notification")
26
+ mail(to: comment.author.email, subject: subject)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -51,6 +51,12 @@ module Decidim
51
51
  down_votes.any? { |vote| vote.author == user }
52
52
  end
53
53
 
54
+ # Public: Returns the commentable object of the parent comment
55
+ def root_commentable
56
+ return commentable if depth == 0
57
+ commentable.root_commentable
58
+ end
59
+
54
60
  private
55
61
 
56
62
  # Private: Check if commentable can have replies and if not adds
@@ -0,0 +1,18 @@
1
+ <p><%= t("decidim.comments.comment_notification_mailer.hello", name: @commentable.author.name) %></p>
2
+
3
+ <p>
4
+ <%=
5
+ t(".new_comment_html", {
6
+ commenter: @comment.author.name,
7
+ commentable_link: link_to(@commentable.title, decidim_resource_url(@commentable))
8
+ })
9
+ %>
10
+ </p>
11
+
12
+ <blockquote>
13
+ <%= @comment.body %>
14
+ </blockquote>
15
+
16
+ <p>
17
+ <%= t("decidim.comments.comment_notification_mailer.manage_email_subscriptions_html", link: link_to(t("decidim.comments.comment_notification_mailer.notifications_settings_link"), decidim.notifications_settings_url(host: @organization.host))) %>
18
+ </p>
@@ -0,0 +1,18 @@
1
+ <p><%= t("decidim.comments.comment_notification_mailer.hello", name: @comment.author.name) %></p>
2
+
3
+ <p>
4
+ <%=
5
+ t(".new_reply_html", {
6
+ commenter: @reply.author.name,
7
+ commentable_link: link_to(@commentable.title, decidim_resource_url(@commentable))
8
+ })
9
+ %>
10
+ </p>
11
+
12
+ <blockquote>
13
+ <%= @reply.body %>
14
+ </blockquote>
15
+
16
+ <p>
17
+ <%= t("decidim.comments.comment_notification_mailer.manage_email_subscriptions_html", link: link_to(t("decidim.comments.comment_notification_mailer.notifications_settings_link"), decidim.notifications_settings_url(host: @organization.host))) %>
18
+ </p>
@@ -4,19 +4,33 @@ ca:
4
4
  messages:
5
5
  cannot_have_replies: no pot tenir respostes
6
6
  decidim:
7
+ comments:
8
+ comment_notification_mailer:
9
+ comment_created:
10
+ new_comment_html: Hi ha un nou comentari d'<b>%{commenter}</b> a <b>%{commentable_link}</b>
11
+ hello: Hola %{name},
12
+ manage_email_subscriptions_html: Pots deixar de rebre aquests correus electrònics canviant la configuració a %{link}.
13
+ notifications_settings_link: la pàgina de configuració de les notificacions
14
+ reply_created:
15
+ new_reply_html: Hi ha una nova resposta del teu comentari de l'<b>%{commenter}</b> a <b>%{commentable_link}</b>
16
+ mailer:
17
+ comment_notification:
18
+ comment_created:
19
+ subject: Tens un nou comentari
20
+ reply_created:
21
+ subject: Tens una nova resposta del teu comentari
7
22
  components:
8
23
  add_comment_form:
9
24
  form:
10
25
  body:
11
26
  label: Comentari
12
27
  placeholder: Què en penses d'això?
28
+ form_error: El text és necessari i no pot ser més llarg de %{length}
13
29
  submit: Envia
14
30
  user_group_id:
15
31
  label: Comentar com a
16
32
  opinion:
17
- against: Hi estic en contra
18
- in_favor: Hi estic a favor
19
- neutral: Sóc neutral
33
+ neutral: Neutral
20
34
  title: Deixa el teu comentari
21
35
  comment:
22
36
  alignment:
@@ -5,19 +5,33 @@ en:
5
5
  messages:
6
6
  cannot_have_replies: can't have replies
7
7
  decidim:
8
+ comments:
9
+ comment_notification_mailer:
10
+ comment_created:
11
+ new_comment_html: There is a new comment from <b>%{commenter}</b> in <b>%{commentable_link}</b>
12
+ hello: Hello %{name},
13
+ manage_email_subscriptions_html: You can stop receiving these emails by changing your settings in %{link}.
14
+ notifications_settings_link: the notifications settings page
15
+ reply_created:
16
+ new_reply_html: There is a new reply of your comment from <b>%{commenter}</b> in <b>%{commentable_link}</b>
17
+ mailer:
18
+ comment_notification:
19
+ comment_created:
20
+ subject: You have a new comment
21
+ reply_created:
22
+ subject: You have a new reply of your comment
8
23
  components:
9
24
  add_comment_form:
10
25
  form:
11
26
  body:
12
27
  label: Comment
13
28
  placeholder: What do you think about this?
29
+ form_error: The text is required and it can't be longer than %{length} characters.
14
30
  submit: Send
15
31
  user_group_id:
16
32
  label: Comment as
17
33
  opinion:
18
- against: I am against
19
- in_favor: I am in favor
20
- neutral: I am neutral
34
+ neutral: Neutral
21
35
  title: Leave your comment
22
36
  comment:
23
37
  alignment:
@@ -4,19 +4,33 @@ es:
4
4
  messages:
5
5
  cannot_have_replies: no pueden tener respuestas
6
6
  decidim:
7
+ comments:
8
+ comment_notification_mailer:
9
+ comment_created:
10
+ new_comment_html: Hay un nuevo comentario de <b>%{commenter}</b> en <b>%{commentable_link}</b>
11
+ hello: Hola %{name},
12
+ manage_email_subscriptions_html: Puedes dejar de recibir estos correos electrónicos cambiando la configuración en %{link}.
13
+ notifications_settings_link: la página de configuración de las notificaciones
14
+ reply_created:
15
+ new_reply_html: Hay una nueva respuesta de tu comentario de <b>%{commenter}</b> en <b>%{commentable_link}</b>
16
+ mailer:
17
+ comment_notification:
18
+ comment_created:
19
+ subject: Tienes un nuevo comentario
20
+ reply_created:
21
+ subject: Uno de tus comentarios ha recibido respuesta
7
22
  components:
8
23
  add_comment_form:
9
24
  form:
10
25
  body:
11
26
  label: Comentario
12
27
  placeholder: '¿Qué piensas sobre esto?'
28
+ form_error: El texto es necesario y no puede ser más de caracteres %{length}.
13
29
  submit: Enviar
14
30
  user_group_id:
15
31
  label: Comentar como
16
32
  opinion:
17
- against: Estoy en contra
18
- in_favor: Estoy a favor
19
- neutral: Soy neutral
33
+ neutral: Neutral
20
34
  title: Deje su comentario
21
35
  comment:
22
36
  alignment:
@@ -0,0 +1,5 @@
1
+ eu:
2
+ decidim:
3
+ comments:
4
+ comment_notification_mailer:
5
+ hello: Kaixo %{name},
@@ -6,5 +6,6 @@ module Decidim
6
6
  # It exposes a single entry point as a rails helper method to render
7
7
  # a React component which handle all the comments render and logic.
8
8
  module Comments
9
+ autoload :CommentsHelper, "decidim/comments/comments_helper"
9
10
  end
10
11
  end
@@ -6,8 +6,11 @@ module Decidim
6
6
  describe CreateComment, :db do
7
7
  describe "call" do
8
8
  let(:organization) { create(:organization) }
9
+ let(:participatory_process) { create(:participatory_process, organization: organization)}
10
+ let(:feature) { create(:feature, participatory_process: participatory_process)}
9
11
  let(:author) { create(:user, organization: organization) }
10
- let(:commentable) { create :participatory_process, organization: organization }
12
+ let(:dummy_resource) { create :dummy_resource, feature: feature }
13
+ let(:commentable) { dummy_resource }
11
14
  let(:body) { ::Faker::Lorem.paragraph }
12
15
  let(:alignment) { 1 }
13
16
  let(:user_group_id) { nil }
@@ -60,6 +63,70 @@ module Decidim
60
63
  command.call
61
64
  end.to change { Comment.count }.by(1)
62
65
  end
66
+
67
+ context "and the comment is a root comment" do
68
+ it "sends an email to the author of the commentable" do
69
+ expect(CommentNotificationMailer)
70
+ .to receive(:comment_created)
71
+ .with(author, an_instance_of(Comment), commentable)
72
+ .and_call_original
73
+
74
+ command.call
75
+ end
76
+
77
+ context "and I am the author of the commentable" do
78
+ let(:dummy_resource) { create :dummy_resource, feature: feature, author: author }
79
+
80
+ it "doesn't send an email" do
81
+ expect(CommentNotificationMailer).not_to receive(:comment_created)
82
+ command.call
83
+ end
84
+ end
85
+
86
+ context "and the author has comment notifications disabled" do
87
+ before do
88
+ commentable.author.update_attributes!(comments_notifications: false)
89
+ end
90
+
91
+ it "doesn't send an email" do
92
+ expect(CommentNotificationMailer).not_to receive(:comment_created)
93
+ command.call
94
+ end
95
+ end
96
+ end
97
+
98
+ context "and the comment is a reply" do
99
+ let (:commentable) { create(:comment, commentable: dummy_resource) }
100
+
101
+ it "sends an email to the author of the parent comment" do
102
+ expect(CommentNotificationMailer)
103
+ .to receive(:reply_created)
104
+ .with(author, an_instance_of(Comment), commentable, commentable.root_commentable)
105
+ .and_call_original
106
+
107
+ command.call
108
+ end
109
+
110
+ context "and I am the author of the parent comment" do
111
+ let (:commentable) { create(:comment, author: author, commentable: dummy_resource) }
112
+
113
+ it "doesn't send an email" do
114
+ expect(CommentNotificationMailer).not_to receive(:reply_created)
115
+ command.call
116
+ end
117
+ end
118
+
119
+ context "and the author has reply notifications disabled" do
120
+ before do
121
+ commentable.author.update_attribute(:replies_notifications, false)
122
+ end
123
+
124
+ it "doesn't send an email" do
125
+ expect(CommentNotificationMailer).not_to receive(:reply_created)
126
+ command.call
127
+ end
128
+ end
129
+ end
63
130
  end
64
131
  end
65
132
  end
@@ -3,21 +3,25 @@ require "spec_helper"
3
3
 
4
4
  describe "Comments", type: :feature do
5
5
  let!(:organization) { create(:organization) }
6
+ let!(:feature) { create(:feature, organization: organization) }
6
7
  let!(:user) { create(:user, :confirmed, organization: organization) }
7
- let!(:participatory_process) { create(:participatory_process, organization: organization) }
8
+ let!(:commentable) { create(:dummy_resource, feature: feature) }
8
9
  let!(:comments) {
9
10
  3.times.map do
10
- create(:comment, commentable: participatory_process)
11
+ create(:comment, commentable: commentable)
11
12
  end
12
13
  }
13
14
 
15
+ def visit_commentable_path(options = {})
16
+ visit decidim_dummy.dummy_resource_path(commentable, feature_id: commentable.feature, participatory_process_id: commentable.feature.participatory_process, arguable: options[:arguable], votable: options[:votable])
17
+ end
18
+
14
19
  before do
15
20
  switch_to_host(organization.host)
21
+ visit_commentable_path
16
22
  end
17
23
 
18
24
  it "user should see a list of comments" do
19
- visit decidim.dummy_path(participatory_process)
20
-
21
25
  expect(page).to have_selector("#comments")
22
26
  expect(page).to have_selector("article.comment", count: comments.length)
23
27
 
@@ -28,12 +32,13 @@ describe "Comments", type: :feature do
28
32
  end
29
33
  end
30
34
  end
31
-
35
+
32
36
  it "user should be able to sort the comments" do
33
- comment = create(:comment, commentable: participatory_process, body: "Most Rated Comment")
37
+ comment = create(:comment, commentable: commentable, body: "Most Rated Comment")
34
38
  create(:comment_vote, comment: comment, author: user, weight: 1)
35
39
 
36
- visit decidim.dummy_path(participatory_process)
40
+ visit_commentable_path
41
+
37
42
  page.find("div.order-by__dropdown.order-by__dropdown--right").hover
38
43
  within "div.order-by__dropdown.order-by__dropdown--right" do
39
44
  click_link "Best rated"
@@ -46,7 +51,6 @@ describe "Comments", type: :feature do
46
51
 
47
52
  context "when not authenticated" do
48
53
  it "user should not see the form to add comments" do
49
- visit decidim.dummy_path(participatory_process)
50
54
  expect(page).not_to have_selector(".add-comment form")
51
55
  end
52
56
  end
@@ -54,19 +58,18 @@ describe "Comments", type: :feature do
54
58
  context "when authenticated" do
55
59
  before do
56
60
  login_as user, scope: :user
61
+ visit_commentable_path
57
62
  end
58
63
 
59
64
  it "user should not see the form to add comments" do
60
- visit decidim.dummy_path(participatory_process)
61
65
  expect(page).to have_selector(".add-comment form")
62
66
  end
63
67
 
64
68
  it "user can add a new comment" do
65
- visit decidim.dummy_path(participatory_process)
66
69
  expect(page).to have_selector(".add-comment form")
67
70
 
68
71
  within ".add-comment form" do
69
- fill_in "add-comment-#{participatory_process.class.name}-#{participatory_process.id}", with: "This is a new comment"
72
+ fill_in "add-comment-#{commentable.class.name}-#{commentable.id}", with: "This is a new comment"
70
73
  click_button "Send"
71
74
  end
72
75
 
@@ -81,14 +84,14 @@ describe "Comments", type: :feature do
81
84
 
82
85
  before do
83
86
  create(:user_group_membership, user: user, user_group: user_group)
87
+ visit_commentable_path
84
88
  end
85
89
 
86
90
  it "user can add a new comment as a user group" do
87
- visit decidim.dummy_path(participatory_process)
88
91
  expect(page).to have_selector(".add-comment form")
89
92
 
90
93
  within ".add-comment form" do
91
- fill_in "add-comment-#{participatory_process.class.name}-#{participatory_process.id}", with: "This is a new comment"
94
+ fill_in "add-comment-#{commentable.class.name}-#{commentable.id}", with: "This is a new comment"
92
95
  select user_group.name, from: "Comment as"
93
96
  click_button "Send"
94
97
  end
@@ -101,11 +104,12 @@ describe "Comments", type: :feature do
101
104
  end
102
105
 
103
106
  it "user can reply a comment" do
104
- comment = create(:comment, commentable: participatory_process)
105
- visit decidim.dummy_path(participatory_process)
107
+ comment = create(:comment, commentable: commentable)
108
+
109
+ visit_commentable_path
106
110
 
107
111
  expect(page).to have_selector(".comment__reply")
108
-
112
+
109
113
  within "#comments #comment_#{comment.id}" do
110
114
  click_button "Reply"
111
115
  find("textarea").set("This is a reply")
@@ -116,14 +120,17 @@ describe "Comments", type: :feature do
116
120
  end
117
121
 
118
122
  context "when arguable option is enabled" do
123
+ before do
124
+ visit_commentable_path arguable: true
125
+ end
126
+
119
127
  it "user can comment in favor" do
120
- visit decidim.dummy_path(participatory_process, arguable: true)
121
128
  expect(page).to have_selector(".add-comment form")
122
129
 
123
- click_button "I am in favor"
130
+ page.find('.opinion-toggle--ok').click
124
131
 
125
132
  within ".add-comment form" do
126
- fill_in "add-comment-#{participatory_process.class.name}-#{participatory_process.id}", with: "I am in favor about this!"
133
+ fill_in "add-comment-#{commentable.class.name}-#{commentable.id}", with: "I am in favor about this!"
127
134
  click_button "Send"
128
135
  end
129
136
 
@@ -135,7 +142,7 @@ describe "Comments", type: :feature do
135
142
 
136
143
  context "when votable option is enabled" do
137
144
  before do
138
- visit decidim.dummy_path(participatory_process, votable: true)
145
+ visit_commentable_path votable: true
139
146
  end
140
147
 
141
148
  it "user can upvote a comment" do