decidim 0.0.1 → 0.0.2

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 (313) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +4 -5
  3. data/.eslintignore +2 -0
  4. data/.eslintrc.json +2 -0
  5. data/.gitignore +1 -0
  6. data/.inch.yml +5 -0
  7. data/.mention-bot +8 -0
  8. data/.rubocop.yml +8 -31
  9. data/.ruby-version +1 -1
  10. data/.travis.yml +24 -14
  11. data/Dockerfile +1 -3
  12. data/Gemfile +1 -3
  13. data/Gemfile.lock +175 -138
  14. data/README.md +63 -5
  15. data/Rakefile +1 -1
  16. data/codecov.yml +1 -0
  17. data/decidim-admin/Rakefile +1 -1
  18. data/decidim-admin/app/assets/javascripts/decidim/admin/application.js.es6 +0 -1
  19. data/decidim-admin/app/assets/stylesheets/decidim/admin/_foundation_and_overrides.scss +1 -0
  20. data/decidim-admin/app/assets/stylesheets/decidim/admin/_icons.scss +9 -0
  21. data/decidim-admin/app/assets/stylesheets/decidim/admin/application.scss +1 -0
  22. data/decidim-admin/app/commands/decidim/admin/create_feature.rb +3 -1
  23. data/decidim-admin/app/commands/decidim/admin/create_participatory_process.rb +26 -14
  24. data/decidim-admin/app/commands/decidim/admin/destroy_feature.rb +5 -0
  25. data/decidim-admin/app/commands/decidim/admin/destroy_participatory_process_step.rb +29 -0
  26. data/decidim-admin/app/commands/decidim/admin/update_feature.rb +47 -0
  27. data/decidim-admin/app/commands/decidim/admin/update_organization.rb +3 -1
  28. data/decidim-admin/app/controllers/decidim/admin/features_controller.rb +37 -2
  29. data/decidim-admin/app/controllers/decidim/admin/participatory_process_step_activations_controller.rb +0 -16
  30. data/decidim-admin/app/controllers/decidim/admin/participatory_process_steps_controller.rb +10 -3
  31. data/decidim-admin/app/controllers/decidim/admin/static_pages_controller.rb +4 -4
  32. data/decidim-admin/app/controllers/decidim/admin/user_groups_controller.rb +32 -0
  33. data/decidim-admin/app/controllers/decidim/admin/users_controller.rb +87 -0
  34. data/decidim-admin/app/forms/decidim/admin/category_form.rb +1 -7
  35. data/decidim-admin/app/forms/decidim/admin/feature_form.rb +26 -0
  36. data/decidim-admin/app/forms/decidim/admin/organization_form.rb +2 -0
  37. data/decidim-admin/app/forms/decidim/admin/participatory_process_step_form.rb +1 -1
  38. data/decidim-admin/app/forms/decidim/admin/static_page_form.rb +2 -3
  39. data/decidim-admin/app/models/decidim/admin/abilities/admin_user.rb +6 -0
  40. data/decidim-admin/app/views/decidim/admin/features/_feature.html.erb +4 -1
  41. data/decidim-admin/app/views/decidim/admin/features/_form.html.erb +49 -0
  42. data/decidim-admin/app/views/decidim/admin/features/_settings_fields.html.erb +5 -0
  43. data/decidim-admin/app/views/decidim/admin/features/edit.html.erb +9 -0
  44. data/decidim-admin/app/views/decidim/admin/features/index.html.erb +6 -0
  45. data/decidim-admin/app/views/decidim/admin/features/new.html.erb +1 -1
  46. data/decidim-admin/app/views/decidim/admin/organization/_form.html.erb +8 -0
  47. data/decidim-admin/app/views/decidim/admin/participatory_process_attachments/_form.html.erb +1 -1
  48. data/decidim-admin/app/views/decidim/admin/participatory_process_steps/index.html.erb +2 -6
  49. data/decidim-admin/app/views/decidim/admin/user_groups/index.html.erb +32 -0
  50. data/decidim-admin/app/views/decidim/admin/users/_form.html.erb +6 -0
  51. data/decidim-admin/app/views/decidim/admin/users/index.html.erb +54 -0
  52. data/decidim-admin/app/views/decidim/admin/users/new.html.erb +11 -0
  53. data/decidim-admin/app/views/layouts/decidim/admin/_sidebar.html.erb +2 -0
  54. data/decidim-admin/app/views/layouts/decidim/admin/participatory_process.html.erb +1 -1
  55. data/decidim-admin/config/i18n-tasks.yml +1 -0
  56. data/decidim-admin/config/locales/ca.yml +103 -5
  57. data/decidim-admin/config/locales/en.yml +57 -4
  58. data/decidim-admin/config/locales/es.yml +103 -5
  59. data/decidim-admin/config/routes.rb +11 -0
  60. data/decidim-admin/decidim-admin.gemspec +2 -3
  61. data/decidim-admin/lib/decidim/admin/features/base_controller.rb +7 -3
  62. data/decidim-admin/lib/decidim/admin/test/factories.rb +8 -0
  63. data/decidim-admin/spec/commands/create_category_spec.rb +2 -1
  64. data/decidim-admin/spec/commands/create_feature_spec.rb +21 -2
  65. data/decidim-admin/spec/commands/create_participatory_process_spec.rb +13 -1
  66. data/decidim-admin/spec/commands/create_static_page_spec.rb +1 -1
  67. data/decidim-admin/spec/commands/destroy_participatory_process_step_spec.rb +45 -0
  68. data/decidim-admin/spec/commands/update_category_spec.rb +2 -1
  69. data/decidim-admin/spec/commands/update_feature_spec.rb +79 -0
  70. data/decidim-admin/spec/commands/update_organization_spec.rb +3 -2
  71. data/decidim-admin/spec/commands/update_static_page_spec.rb +3 -2
  72. data/decidim-admin/spec/factories.rb +2 -9
  73. data/decidim-admin/spec/features/admin_manages_features_spec.rb +84 -2
  74. data/decidim-admin/spec/features/admin_manages_organization_admins_spec.rb +71 -0
  75. data/decidim-admin/spec/features/admin_manages_user_groups_spec.rb +24 -0
  76. data/decidim-admin/spec/forms/category_form_spec.rb +3 -7
  77. data/decidim-admin/spec/forms/organization_form_spec.rb +8 -2
  78. data/decidim-admin/spec/forms/participatory_process_form_spec.rb +2 -1
  79. data/decidim-admin/spec/forms/participatory_process_step_form_spec.rb +2 -21
  80. data/decidim-admin/spec/forms/scope_form_spec.rb +1 -1
  81. data/decidim-admin/spec/forms/static_page_form_spec.rb +2 -7
  82. data/decidim-admin/spec/models/abilities/admin_user_spec.rb +22 -0
  83. data/decidim-admin/spec/shared/manage_process_attachments_examples.rb +2 -1
  84. data/decidim-admin/spec/shared/manage_process_steps_examples.rb +2 -15
  85. data/decidim-admin/spec/spec_helper.rb +3 -1
  86. data/decidim-api/Rakefile +1 -1
  87. data/decidim-api/decidim-api.gemspec +3 -3
  88. data/decidim-api/spec/factories.rb +2 -2
  89. data/decidim-api/spec/spec_helper.rb +3 -1
  90. data/decidim-comments/Rakefile +1 -1
  91. data/decidim-comments/app/assets/javascripts/decidim/comments/bundle.js +0 -0
  92. data/decidim-comments/app/commands/decidim/comments/vote_comment.rb +38 -0
  93. data/decidim-comments/app/frontend/application/icon.component.jsx +9 -4
  94. data/decidim-comments/app/frontend/application/icon.component.test.jsx +12 -2
  95. data/decidim-comments/app/frontend/comments/add_comment_form.component.jsx +43 -11
  96. data/decidim-comments/app/frontend/comments/add_comment_form.mutation.graphql +1 -4
  97. data/decidim-comments/app/frontend/comments/comment.component.jsx +67 -7
  98. data/decidim-comments/app/frontend/comments/comment.component.test.jsx +49 -1
  99. data/decidim-comments/app/frontend/comments/comment_data.fragment.graphql +3 -0
  100. data/decidim-comments/app/frontend/comments/comment_order_selector.component.jsx +51 -6
  101. data/decidim-comments/app/frontend/comments/comment_order_selector.component.test.jsx +12 -1
  102. data/decidim-comments/app/frontend/comments/comment_thread.component.jsx +11 -5
  103. data/decidim-comments/app/frontend/comments/comment_thread.component.test.jsx +13 -3
  104. data/decidim-comments/app/frontend/comments/comment_thread.fragment.graphql +1 -3
  105. data/decidim-comments/app/frontend/comments/comments.component.jsx +37 -11
  106. data/decidim-comments/app/frontend/comments/comments.component.test.jsx +44 -7
  107. data/decidim-comments/app/frontend/comments/comments.query.graphql +2 -2
  108. data/decidim-comments/app/frontend/comments/down_vote.fragment.graphql +6 -0
  109. data/decidim-comments/app/frontend/comments/down_vote.mutation.graphql +7 -0
  110. data/decidim-comments/app/frontend/comments/down_vote_button.component.jsx +84 -0
  111. data/decidim-comments/app/frontend/comments/down_vote_button.component.test.jsx +48 -0
  112. data/decidim-comments/app/frontend/comments/up_vote.fragment.graphql +6 -0
  113. data/decidim-comments/app/frontend/comments/up_vote.mutation.graphql +7 -0
  114. data/decidim-comments/app/frontend/comments/up_vote_button.component.jsx +84 -0
  115. data/decidim-comments/app/frontend/comments/up_vote_button.component.test.jsx +48 -0
  116. data/decidim-comments/app/frontend/comments/vote_button.component.jsx +19 -0
  117. data/decidim-comments/app/frontend/comments/vote_button_component.test.jsx +38 -0
  118. data/decidim-comments/app/frontend/support/generate_comments_data.js +7 -2
  119. data/decidim-comments/app/helpers/decidim/comments/comments_helper.rb +1 -1
  120. data/decidim-comments/app/models/decidim/comments/application_record.rb +9 -0
  121. data/decidim-comments/app/models/decidim/comments/comment.rb +19 -4
  122. data/decidim-comments/app/models/decidim/comments/comment_vote.rb +22 -0
  123. data/decidim-comments/app/models/decidim/comments/seed.rb +27 -0
  124. data/decidim-comments/app/queries/decidim/comments/comments_with_replies.rb +88 -0
  125. data/decidim-comments/app/resolvers/decidim/comments/vote_comment_resolver.rb +20 -0
  126. data/decidim-comments/app/types/decidim/comments/comment_mutation_type.rb +19 -0
  127. data/decidim-comments/app/types/decidim/comments/comment_type.rb +38 -2
  128. data/decidim-comments/config/locales/en.yml +1 -0
  129. data/decidim-comments/db/migrate/20161130143508_create_comments.rb +4 -2
  130. data/decidim-comments/db/migrate/20161219150806_create_comment_votes.rb +13 -0
  131. data/decidim-comments/decidim-comments.gemspec +0 -3
  132. data/decidim-comments/lib/decidim/comments/mutation_extensions.rb +9 -0
  133. data/decidim-comments/lib/decidim/comments/query_extensions.rb +3 -5
  134. data/decidim-comments/lib/decidim/comments/test/factories.rb +22 -0
  135. data/decidim-comments/spec/commands/vote_comment_spec.rb +124 -0
  136. data/decidim-comments/spec/factories.rb +2 -9
  137. data/decidim-comments/spec/features/comments_spec.rb +37 -0
  138. data/decidim-comments/spec/models/comment_spec.rb +34 -0
  139. data/decidim-comments/spec/models/comment_vote_spec.rb +44 -0
  140. data/decidim-comments/spec/models/seed_spec.rb +19 -0
  141. data/decidim-comments/spec/queries/comments_with_replies_spec.rb +86 -0
  142. data/decidim-comments/spec/spec_helper.rb +3 -1
  143. data/decidim-comments/spec/support/dummy.rb +1 -1
  144. data/decidim-comments/spec/types/comment_mutation_type_spec.rb +46 -0
  145. data/decidim-comments/spec/types/comment_type_spec.rb +57 -3
  146. data/{decidim-api → decidim-comments}/spec/types/mutation_type_spec.rb +11 -0
  147. data/decidim-dev/README.md +7 -11
  148. data/decidim-dev/decidim-dev.gemspec +5 -4
  149. data/decidim-dev/lib/decidim/dev.rb +20 -0
  150. data/decidim-dev/lib/decidim/dev/assets/Exampledocument.docx +0 -0
  151. data/decidim-dev/lib/decidim/dev/assets/Exampledocument.odt +0 -0
  152. data/decidim-dev/lib/decidim/dev/assets/Exampledocument.pdf +0 -0
  153. data/decidim-dev/lib/decidim/dev/assets/avatar.svg +14 -0
  154. data/decidim-dev/lib/decidim/dev/assets/city.jpeg +0 -0
  155. data/decidim-dev/lib/decidim/dev/assets/city2.jpeg +0 -0
  156. data/decidim-dev/lib/decidim/dev/assets/city3.jpeg +0 -0
  157. data/decidim-dev/lib/decidim/dev/assets/malicious.jpg +0 -0
  158. data/decidim-dev/lib/decidim/{common_rake.rb → dev/common_rake.rb} +1 -1
  159. data/decidim-dev/lib/decidim/{dummy_authorization_handler.rb → dev/dummy_authorization_handler.rb} +4 -4
  160. data/decidim-dev/lib/decidim/{test → dev/test}/authorization_shared_examples.rb +0 -8
  161. data/decidim-dev/lib/decidim/{test → dev/test}/base_spec_helper.rb +4 -1
  162. data/decidim-dev/lib/decidim/{test → dev/test}/i18n_spec.rb +1 -1
  163. data/decidim-dev/lib/decidim/{test → dev/test}/rspec_support/action_mailer.rb +0 -0
  164. data/decidim-dev/lib/decidim/{test → dev/test}/rspec_support/active_job.rb +0 -0
  165. data/decidim-dev/lib/decidim/{test → dev/test}/rspec_support/authenticated_controller_context.rb +0 -0
  166. data/decidim-dev/lib/decidim/{test → dev/test}/rspec_support/authorization_handlers.rb +1 -1
  167. data/decidim-dev/lib/decidim/{test → dev/test}/rspec_support/capybara.rb +3 -10
  168. data/decidim-dev/lib/decidim/{test → dev/test}/rspec_support/database_cleaner.rb +0 -0
  169. data/decidim-dev/lib/decidim/{test → dev/test}/rspec_support/engine_routes.rb +0 -0
  170. data/decidim-dev/lib/decidim/{test → dev/test}/rspec_support/factory_girl.rb +0 -0
  171. data/decidim-dev/lib/decidim/{test → dev/test}/rspec_support/feature.rb +10 -0
  172. data/decidim-dev/lib/decidim/{test → dev/test}/rspec_support/feature_context.rb +2 -2
  173. data/decidim-dev/lib/decidim/{test → dev/test}/rspec_support/helpers.rb +4 -0
  174. data/decidim-dev/lib/decidim/{test → dev/test}/rspec_support/i18n.rb +1 -0
  175. data/decidim-dev/lib/decidim/dev/test/rspec_support/phantomjs_polyfills/bind-polyfill.js +18 -0
  176. data/decidim-dev/lib/decidim/dev/test/rspec_support/phantomjs_polyfills/object-assign-polyfill.js +24 -0
  177. data/decidim-dev/lib/decidim/dev/test/rspec_support/phantomjs_polyfills/promise.js +233 -0
  178. data/decidim-dev/lib/decidim/{test → dev/test}/rspec_support/translation_helpers.rb +0 -0
  179. data/decidim-dev/lib/decidim/{test → dev/test}/rspec_support/warden.rb +0 -0
  180. data/decidim-dev/lib/decidim/{test → dev/test}/rspec_support/wisper.rb +0 -0
  181. data/decidim-dev/lib/generators/decidim/dummy_generator.rb +2 -2
  182. data/decidim-dev/lib/generators/decidim/templates/decidim_dev.rb +2 -0
  183. data/decidim-meetings/Rakefile +1 -1
  184. data/decidim-meetings/app/assets/images/decidim/meetings/icon.svg +1 -0
  185. data/decidim-meetings/app/commands/decidim/meetings/admin/create_meeting.rb +2 -0
  186. data/decidim-meetings/app/commands/decidim/meetings/admin/update_meeting.rb +2 -0
  187. data/decidim-meetings/app/controllers/decidim/meetings/meetings_controller.rb +30 -6
  188. data/decidim-meetings/app/forms/decidim/meetings/admin/meeting_form.rb +14 -0
  189. data/decidim-meetings/app/helpers/decidim/meetings/application_helper.rb +10 -0
  190. data/decidim-meetings/app/models/decidim/meetings/meeting.rb +18 -1
  191. data/decidim-meetings/app/services/decidim/meetings/meeting_search.rb +48 -0
  192. data/decidim-meetings/app/views/decidim/meetings/admin/meetings/_form.html.erb +9 -2
  193. data/decidim-meetings/app/views/decidim/meetings/meetings/_filters.html.erb +24 -0
  194. data/decidim-meetings/app/views/decidim/meetings/meetings/_meetings.html.erb +30 -0
  195. data/decidim-meetings/app/views/decidim/meetings/meetings/_tags.html.erb +10 -0
  196. data/decidim-meetings/app/views/decidim/meetings/meetings/index.html.erb +8 -26
  197. data/decidim-meetings/app/views/decidim/meetings/meetings/index.js.erb +2 -0
  198. data/decidim-meetings/app/views/decidim/meetings/meetings/show.html.erb +1 -0
  199. data/decidim-meetings/config/locales/ca.yml +7 -0
  200. data/decidim-meetings/config/locales/en.yml +7 -0
  201. data/decidim-meetings/config/locales/es.yml +7 -0
  202. data/decidim-meetings/db/migrate/20161130121354_create_meetings.rb +2 -0
  203. data/decidim-meetings/decidim-meetings.gemspec +2 -0
  204. data/decidim-meetings/lib/decidim/meetings/feature.rb +7 -2
  205. data/decidim-meetings/lib/decidim/meetings/list_engine.rb +3 -0
  206. data/decidim-meetings/spec/commands/create_meeting_spec.rb +21 -0
  207. data/decidim-meetings/spec/commands/update_meeting_spec.rb +17 -2
  208. data/decidim-meetings/spec/factories.rb +3 -3
  209. data/decidim-meetings/spec/features/explore_meetings_spec.rb +53 -0
  210. data/decidim-meetings/spec/forms/meeting_form_spec.rb +19 -1
  211. data/decidim-meetings/spec/models/meeting_spec.rb +20 -0
  212. data/decidim-meetings/spec/services/meeting_search_spec.rb +146 -0
  213. data/decidim-meetings/spec/shared/admin_shared_context.rb +4 -2
  214. data/decidim-meetings/spec/shared/manage_meetings_examples.rb +5 -2
  215. data/decidim-meetings/spec/spec_helper.rb +1 -1
  216. data/decidim-pages/Rakefile +1 -1
  217. data/decidim-pages/app/assets/images/decidim/pages/icon.svg +3 -0
  218. data/decidim-pages/app/commands/decidim/pages/admin/update_page.rb +1 -2
  219. data/decidim-pages/app/forms/decidim/pages/admin/page_form.rb +0 -1
  220. data/decidim-pages/app/views/decidim/pages/admin/pages/_form.html.erb +0 -1
  221. data/decidim-pages/app/views/decidim/pages/application/show.html.erb +3 -3
  222. data/decidim-pages/config/i18n-tasks.yml +1 -0
  223. data/decidim-pages/config/locales/ca.yml +5 -1
  224. data/decidim-pages/config/locales/en.yml +5 -1
  225. data/decidim-pages/config/locales/es.yml +5 -1
  226. data/decidim-pages/db/migrate/20170110145040_remove_commentable_flag_from_pages.rb +5 -0
  227. data/decidim-pages/lib/decidim/pages/feature.rb +13 -3
  228. data/decidim-pages/spec/commands/update_page_spec.rb +2 -1
  229. data/decidim-pages/spec/factories.rb +2 -2
  230. data/decidim-pages/spec/features/admin_spec.rb +0 -11
  231. data/decidim-pages/spec/features/page_show_spec.rb +13 -10
  232. data/decidim-pages/spec/forms/page_form_spec.rb +4 -4
  233. data/decidim-pages/spec/spec_helper.rb +3 -1
  234. data/decidim-proposals/Rakefile +1 -1
  235. data/decidim-proposals/app/assets/config/decidim_proposals_manifest.css +1 -0
  236. data/decidim-proposals/app/assets/config/decidim_proposals_manifest.js +1 -0
  237. data/decidim-proposals/app/assets/images/decidim/proposals/icon.svg +1 -0
  238. data/decidim-proposals/app/assets/javascripts/decidim/proposals/social_share.js +2 -0
  239. data/decidim-proposals/app/assets/stylesheets/decidim/proposals/social_share.css.scss +14 -0
  240. data/decidim-proposals/app/commands/decidim/proposals/create_proposal.rb +5 -3
  241. data/decidim-proposals/app/controllers/decidim/proposals/admin/proposals_controller.rb +3 -3
  242. data/decidim-proposals/app/controllers/decidim/proposals/proposal_votes_controller.rb +25 -0
  243. data/decidim-proposals/app/controllers/decidim/proposals/proposals_controller.rb +33 -6
  244. data/decidim-proposals/app/forms/decidim/proposals/admin/proposal_form.rb +7 -6
  245. data/decidim-proposals/app/forms/decidim/proposals/proposal_form.rb +6 -6
  246. data/decidim-proposals/app/helpers/decidim/proposals/application_helper.rb +3 -1
  247. data/decidim-proposals/app/helpers/decidim/proposals/proposal_votes_helper.rb +27 -0
  248. data/decidim-proposals/app/models/decidim/proposals/proposal.rb +8 -0
  249. data/decidim-proposals/app/models/decidim/proposals/proposal_vote.rb +20 -0
  250. data/decidim-proposals/app/services/decidim/proposals/proposal_search.rb +39 -11
  251. data/decidim-proposals/app/views/decidim/proposals/admin/proposals/_form.html.erb +2 -2
  252. data/decidim-proposals/app/views/decidim/proposals/proposal_votes/create.js.erb +5 -0
  253. data/decidim-proposals/app/views/decidim/proposals/proposals/_count.html.erb +1 -0
  254. data/decidim-proposals/app/views/decidim/proposals/proposals/_filters.html.erb +26 -0
  255. data/decidim-proposals/app/views/decidim/proposals/proposals/_proposal.html.erb +11 -2
  256. data/decidim-proposals/app/views/decidim/proposals/proposals/_proposals.html.erb +4 -0
  257. data/decidim-proposals/app/views/decidim/proposals/proposals/_share.html.erb +33 -0
  258. data/decidim-proposals/app/views/decidim/proposals/proposals/_vote_button.html.erb +13 -0
  259. data/decidim-proposals/app/views/decidim/proposals/proposals/_votes_count.html.erb +6 -0
  260. data/decidim-proposals/app/views/decidim/proposals/proposals/index.html.erb +11 -11
  261. data/decidim-proposals/app/views/decidim/proposals/proposals/index.js.erb +5 -0
  262. data/decidim-proposals/app/views/decidim/proposals/proposals/show.html.erb +31 -4
  263. data/decidim-proposals/config/i18n-tasks.yml +1 -0
  264. data/decidim-proposals/config/initializers/social_share_button.rb +4 -0
  265. data/decidim-proposals/config/locales/ca.yml +28 -2
  266. data/decidim-proposals/config/locales/en.yml +27 -1
  267. data/decidim-proposals/config/locales/es.yml +28 -2
  268. data/decidim-proposals/db/migrate/20170112115253_create_proposal_votes.rb +12 -0
  269. data/decidim-proposals/db/migrate/20170113114245_add_text_search_indexes.rb +6 -0
  270. data/decidim-proposals/db/migrate/20170118120151_add_counter_cache_votes_to_proposals.rb +5 -0
  271. data/decidim-proposals/decidim-proposals.gemspec +2 -1
  272. data/decidim-proposals/lib/decidim/proposals/engine.rb +8 -1
  273. data/decidim-proposals/lib/decidim/proposals/feature.rb +30 -4
  274. data/decidim-proposals/spec/commands/decidim/proposals/create_proposal_spec.rb +10 -3
  275. data/decidim-proposals/spec/factories.rb +9 -4
  276. data/decidim-proposals/spec/features/admin_manages_proposals_spec.rb +2 -0
  277. data/decidim-proposals/spec/features/process_admin_manages_proposals_spec.rb +2 -0
  278. data/decidim-proposals/spec/features/proposals_spec.rb +41 -31
  279. data/decidim-proposals/spec/features/vote_proposal_spec.rb +78 -0
  280. data/decidim-proposals/spec/forms/decidim/proposals/proposal_form_spec.rb +11 -10
  281. data/decidim-proposals/spec/helpers/proposal_votes_helper_spec.rb +28 -0
  282. data/decidim-proposals/spec/lib/decidim/proposals/feature_spec.rb +1 -1
  283. data/decidim-proposals/spec/models/decidim/proposals/proposal_spec.rb +20 -3
  284. data/decidim-proposals/spec/models/decidim/proposals/proposal_vote_spec.rb +43 -0
  285. data/decidim-proposals/spec/services/decidim/proposals/proposal_search_spec.rb +50 -4
  286. data/decidim-proposals/spec/shared/manage_proposals_examples.rb +1 -1
  287. data/decidim-proposals/spec/spec_helper.rb +1 -1
  288. data/decidim-system/Rakefile +1 -1
  289. data/decidim-system/app/commands/decidim/system/register_organization.rb +13 -12
  290. data/decidim-system/decidim-system.gemspec +2 -3
  291. data/decidim-system/spec/factories.rb +1 -1
  292. data/decidim-system/spec/spec_helper.rb +3 -1
  293. data/docs/social_providers.md +41 -0
  294. data/karma.conf.js +4 -2
  295. data/lib/generators/decidim/app_generator.rb +6 -0
  296. data/lib/generators/decidim/demo_generator.rb +2 -2
  297. data/lib/generators/decidim/install_generator.rb +5 -4
  298. data/lib/generators/decidim/templates/Gemfile.erb +3 -5
  299. data/lib/generators/decidim/templates/initializer.rb +1 -1
  300. data/lib/generators/decidim/templates/secrets.yml.erb +26 -0
  301. data/lib/generators/decidim/templates/social_share_button.rb +7 -0
  302. data/package.json +16 -6
  303. data/webpack.config.js +23 -8
  304. data/yarn.lock +401 -345
  305. metadata +130 -48
  306. data/Gemfile.common +0 -1
  307. data/decidim-admin/Gemfile +0 -6
  308. data/decidim-comments/Gemfile +0 -6
  309. data/decidim-comments/package.json +0 -21
  310. data/decidim-dev/Gemfile +0 -6
  311. data/decidim-dev/lib/decidim/test/rspec_support/bullet.rb +0 -15
  312. data/decidim-dev/lib/generators/decidim/templates/bullet.rb +0 -6
  313. data/decidim-system/Gemfile +0 -6
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+ FactoryGirl.define do
3
+ factory :comment, class: Decidim::Comments::Comment do
4
+ author { build(:user, organization: commentable.organization) }
5
+ commentable { build(:participatory_process) }
6
+ body { Faker::Lorem.paragraph }
7
+ end
8
+
9
+ factory :comment_vote, class: Decidim::Comments::CommentVote do
10
+ comment { build(:comment) }
11
+ author { build(:user, organization: comment.organization) }
12
+ weight { [-1, 1].sample }
13
+
14
+ trait :up_vote do
15
+ weight 1
16
+ end
17
+
18
+ trait :down_vote do
19
+ weight(-1)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,124 @@
1
+ # frozen_string_literal: true
2
+ require "spec_helper"
3
+
4
+ module Decidim
5
+ module Comments
6
+ describe VoteComment, :db do
7
+ describe "call" do
8
+ let(:organization) { create :organization }
9
+ let(:participatory_process) { create(:participatory_process, organization: organization) }
10
+ let(:author) { create(:user, organization: organization) }
11
+ let(:comment) { create(:comment, commentable: participatory_process) }
12
+ let(:command) { described_class.new(comment, author) }
13
+
14
+ describe "when the vote is not created" do
15
+ before do
16
+ expect(comment.up_votes).to receive(:create!).and_raise(ActiveRecord::RecordInvalid)
17
+ end
18
+
19
+ it "broadcasts invalid" do
20
+ expect { command.call }.to broadcast(:invalid)
21
+ end
22
+
23
+ it "doesn't create a comment vote" do
24
+ expect do
25
+ command.call
26
+ end.to_not change { CommentVote.count }
27
+ end
28
+ end
29
+
30
+ describe "when the vote is already created for this user" do
31
+ before do
32
+ expect(comment.up_votes).to receive(:create!).and_raise(ActiveRecord::RecordNotUnique)
33
+ end
34
+
35
+ it "broadcasts invalid" do
36
+ expect { command.call }.to broadcast(:invalid)
37
+ end
38
+
39
+ it "doesn't create a comment vote" do
40
+ expect do
41
+ command.call
42
+ end.to_not change { CommentVote.count }
43
+ end
44
+ end
45
+
46
+ describe "when the vote is created" do
47
+ it "broadcasts ok" do
48
+ expect { command.call }.to broadcast(:ok)
49
+ end
50
+
51
+ it "creates a new comment vote" do
52
+ expect(comment.up_votes).to receive(:create!).with({
53
+ author: author
54
+ }).and_call_original
55
+ expect do
56
+ command.call
57
+ end.to change { CommentVote.count }.by(1)
58
+ end
59
+ end
60
+
61
+ describe "when weight value is not the default" do
62
+ describe "and it is equal to -1" do
63
+ let(:command) { described_class.new(comment, author, weight: -1) }
64
+
65
+ describe "when the vote is not created" do
66
+ before do
67
+ expect(comment.down_votes).to receive(:create!).and_raise(ActiveRecord::RecordInvalid)
68
+ end
69
+
70
+ it "broadcasts invalid" do
71
+ expect { command.call }.to broadcast(:invalid)
72
+ end
73
+
74
+ it "doesn't create a comment vote" do
75
+ expect do
76
+ command.call
77
+ end.to_not change { CommentVote.count }
78
+ end
79
+ end
80
+
81
+ describe "when the vote is already created for this user" do
82
+ before do
83
+ expect(comment.down_votes).to receive(:create!).and_raise(ActiveRecord::RecordNotUnique)
84
+ end
85
+
86
+ it "broadcasts invalid" do
87
+ expect { command.call }.to broadcast(:invalid)
88
+ end
89
+
90
+ it "doesn't create a comment vote" do
91
+ expect do
92
+ command.call
93
+ end.to_not change { CommentVote.count }
94
+ end
95
+ end
96
+
97
+ describe "when the vote is created" do
98
+ it "broadcasts ok" do
99
+ expect { command.call }.to broadcast(:ok)
100
+ end
101
+
102
+ it "creates a new comment vote" do
103
+ expect(comment.down_votes).to receive(:create!).with({
104
+ author: author
105
+ }).and_call_original
106
+ expect do
107
+ command.call
108
+ end.to change { CommentVote.count }.by(1)
109
+ end
110
+ end
111
+ end
112
+
113
+ describe "and it has a invalid value" do
114
+ let(:command) { described_class.new(comment, author, weight: 2) }
115
+
116
+ it "broadcasts invalid" do
117
+ expect { command.call }.to broadcast(:invalid)
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
123
+ end
124
+ end
@@ -1,9 +1,2 @@
1
- require_relative "../../decidim-core/spec/factories"
2
-
3
- FactoryGirl.define do
4
- factory :comment, class: Decidim::Comments::Comment do
5
- author { build(:user, organization: commentable.organization) }
6
- commentable { build(:participatory_process) }
7
- body { Faker::Lorem.paragraph }
8
- end
9
- end
1
+ require "decidim/core/test/factories"
2
+ require "decidim/comments/test/factories"
@@ -28,6 +28,21 @@ describe "Comments", type: :feature do
28
28
  end
29
29
  end
30
30
  end
31
+
32
+ it "user should be able to sort the comments" do
33
+ comment = create(:comment, commentable: participatory_process, body: "Most Rated Comment")
34
+ create(:comment_vote, comment: comment, author: user, weight: 1)
35
+
36
+ visit decidim.dummy_path(participatory_process)
37
+ page.find("div.order-by__dropdown.order-by__dropdown--right").hover
38
+ within "div.order-by__dropdown.order-by__dropdown--right" do
39
+ click_link "Best Rated"
40
+ end
41
+
42
+ within "#comments" do
43
+ expect(page.find('.comment', match: :first)).to have_content "Most Rated Comment"
44
+ end
45
+ end
31
46
 
32
47
  context "when not authenticated" do
33
48
  it "user should not see the form to add comments" do
@@ -93,5 +108,27 @@ describe "Comments", type: :feature do
93
108
  end
94
109
  end
95
110
  end
111
+
112
+ context "when votable option is enabled" do
113
+ before do
114
+ visit decidim.dummy_path(participatory_process, votable: true)
115
+ end
116
+
117
+ it "user can upvote a comment" do
118
+ within "#comment_#{comments[0].id}" do
119
+ expect(page).to have_selector('.comment__votes--up', text: /0/)
120
+ page.find('.comment__votes--up').click
121
+ expect(page).to have_selector('.comment__votes--up', text: /1/)
122
+ end
123
+ end
124
+
125
+ it "user can downvote a comment" do
126
+ within "#comment_#{comments[0].id}" do
127
+ expect(page).to have_selector('.comment__votes--down', text: /0/)
128
+ page.find('.comment__votes--down').click
129
+ expect(page).to have_selector('.comment__votes--down', text: /1/)
130
+ end
131
+ end
132
+ end
96
133
  end
97
134
  end
@@ -7,6 +7,8 @@ module Decidim
7
7
  let!(:commentable) { create(:participatory_process) }
8
8
  let!(:comment) { create(:comment, commentable: commentable) }
9
9
  let!(:replies) { 3.times.map { create(:comment, commentable: comment) } }
10
+ let!(:up_vote) { create(:comment_vote, :up_vote, comment: comment) }
11
+ let!(:down_vote) { create(:comment_vote, :down_vote, comment: comment) }
10
12
 
11
13
  it "is valid" do
12
14
  expect(comment).to be_valid
@@ -24,6 +26,14 @@ module Decidim
24
26
  expect(comment.replies).to match_array(replies)
25
27
  end
26
28
 
29
+ it "has a up_votes association returning comment votes with weight 1" do
30
+ expect(comment.up_votes.count).to eq(1)
31
+ end
32
+
33
+ it "has a down_votes association returning comment votes with weight -1" do
34
+ expect(comment.down_votes.count).to eq(1)
35
+ end
36
+
27
37
  it "is not valid if its parent is a comment and cannot have replies" do
28
38
  expect(comment).to receive(:can_have_replies?).and_return false
29
39
  expect(replies[0]).not_to be_valid
@@ -59,6 +69,30 @@ module Decidim
59
69
  comment.alignment = 2
60
70
  expect(comment).not_to be_valid
61
71
  end
72
+
73
+ describe "#up_voted_by?" do
74
+ let(:user) { create(:user, organization: comment.organization) }
75
+ it "should return true if the given user has upvoted the comment" do
76
+ create(:comment_vote, comment: comment, author: user, weight: 1)
77
+ expect(comment.up_voted_by?(user)).to be_truthy
78
+ end
79
+
80
+ it "should return false if the given user has not upvoted the comment" do
81
+ expect(comment.up_voted_by?(user)).to be_falsy
82
+ end
83
+ end
84
+
85
+ describe "#down_voted_by?" do
86
+ let(:user) { create(:user, organization: comment.organization) }
87
+ it "should return true if the given user has downvoted the comment" do
88
+ create(:comment_vote, comment: comment, author: user, weight: -1)
89
+ expect(comment.down_voted_by?(user)).to be_truthy
90
+ end
91
+
92
+ it "should return false if the given user has not downvoted the comment" do
93
+ expect(comment.down_voted_by?(user)).to be_falsy
94
+ end
95
+ end
62
96
  end
63
97
  end
64
98
  end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+ require "spec_helper"
3
+
4
+ module Decidim
5
+ module Comments
6
+ describe CommentVote do
7
+ let!(:organization) { create(:organization) }
8
+ let!(:participatory_process) { create(:participatory_process, organization: organization) }
9
+ let!(:author) { create(:user, organization: organization) }
10
+ let!(:comment) { create(:comment, commentable: participatory_process, author: author)}
11
+ let!(:comment_vote) { create(:comment_vote, comment: comment, author: author) }
12
+
13
+ it "is valid" do
14
+ expect(comment_vote).to be_valid
15
+ end
16
+
17
+ it "has an associated author" do
18
+ expect(comment_vote.author).to be_a(Decidim::User)
19
+ end
20
+
21
+ it "has an associated comment" do
22
+ expect(comment_vote.comment).to be_a(Decidim::Comments::Comment)
23
+ end
24
+
25
+ it "validates uniqueness for author and comment combination" do
26
+ expect {
27
+ create(:comment_vote, comment: comment, author: author)
28
+ }.to raise_error(ActiveRecord::RecordInvalid)
29
+ end
30
+
31
+ it "is invalid with a weight different from 1 and -1" do
32
+ comment_vote.weight = 2
33
+ expect(comment_vote).to be_invalid
34
+ end
35
+
36
+ it "is invalid if comment and author have different organizations" do
37
+ author = create(:user)
38
+ comment = create(:comment)
39
+ comment_vote = build(:comment_vote, comment: comment, author: author)
40
+ expect(comment_vote).to be_invalid
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+ require "spec_helper"
3
+
4
+ module Decidim
5
+ module Comments
6
+ describe Seed do
7
+ let!(:organization) { create(:organization) }
8
+ let(:subject) { Decidim::Comments::Seed }
9
+
10
+ describe "#comments_for(resource)" do
11
+ it 'creates comments for a page if one is given' do
12
+ user = create(:user, organization: organization)
13
+ subject.comments_for(user)
14
+ expect(Decidim::Comments::CommentsWithReplies.for(user).length).to be_between(1, 5).inclusive
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+ require "spec_helper"
3
+
4
+ describe Decidim::Comments::CommentsWithReplies do
5
+ let!(:organization) { create(:organization) }
6
+ let!(:author) { create(:user, organization: organization) }
7
+ let!(:commentable) { create(:participatory_process, organization: organization) }
8
+ let!(:comment) { create(:comment, commentable: commentable, author: author) }
9
+ let!(:order_by) {}
10
+
11
+ subject { described_class.new(commentable, order_by: order_by) }
12
+
13
+ it "returns the commentable's comments" do
14
+ expect(subject.query).to eq [comment]
15
+ end
16
+
17
+ it "eager loads comment's author, up_votes and down_votes" do
18
+ comment = subject.query[0]
19
+ expect {
20
+ expect(comment.author.name).to be_present
21
+ expect(comment.up_votes.size).to eq(0)
22
+ expect(comment.down_votes.size).to eq(0)
23
+ }.to_not make_database_queries
24
+ end
25
+
26
+ it "eager loads a comment tree based on the MAX_DEPTH" do
27
+ reply = comment
28
+
29
+ Decidim::Comments::Comment::MAX_DEPTH.times do
30
+ reply = create(:comment, commentable: reply)
31
+ end
32
+
33
+ comment = subject.query[0]
34
+
35
+ expect {
36
+ Decidim::Comments::Comment::MAX_DEPTH.times do
37
+ comment = comment.replies[0]
38
+ end
39
+ expect(comment.author.name).to be_present
40
+ expect(comment.up_votes.size).to eq(0)
41
+ expect(comment.down_votes.size).to eq(0)
42
+ }.to_not make_database_queries
43
+ end
44
+
45
+ it "return the comments ordered by created_at asc by default" do
46
+ previous_comment = create(:comment, commentable: commentable, author: author, created_at: 1.week.ago, updated_at: 1.week.ago)
47
+ future_comment = create(:comment, commentable: commentable, author: author, created_at: 1.week.from_now, updated_at: 1.week.from_now)
48
+ expect(subject.query).to eq [previous_comment, comment, future_comment]
49
+ end
50
+
51
+ context "When order_by is not default" do
52
+ context "When order by recent" do
53
+ let!(:order_by) {"recent"}
54
+
55
+ it "return the comments ordered by recent" do
56
+ previous_comment = create(:comment, commentable: commentable, author: author, created_at: 1.week.ago, updated_at: 1.week.ago)
57
+ future_comment = create(:comment, commentable: commentable, author: author, created_at: 1.week.from_now, updated_at: 1.week.from_now)
58
+ expect(subject.query).to eq [previous_comment, comment, future_comment].reverse
59
+ end
60
+ end
61
+
62
+ context "When order by best_rated" do
63
+ let!(:order_by) {"best_rated"}
64
+
65
+ it "return the comments ordered by best_rated" do
66
+ most_voted_comment = create(:comment, commentable: commentable, author: author, created_at: 1.week.ago, updated_at: 1.week.ago)
67
+ less_voted_comment = create(:comment, commentable: commentable, author: author, created_at: 1.week.from_now, updated_at: 1.week.from_now)
68
+ create(:comment_vote, comment: most_voted_comment, author: author, weight: 1)
69
+ create(:comment_vote, comment: less_voted_comment, author: author, weight: -1)
70
+ expect(subject.query).to eq [most_voted_comment, comment, less_voted_comment]
71
+ end
72
+ end
73
+
74
+ context "When order by most_discussed" do
75
+ let!(:order_by) {"most_discussed"}
76
+
77
+ it "return the comments ordered by most_discussed" do
78
+ most_commented = create(:comment, commentable: commentable, author: author, created_at: 1.week.ago, updated_at: 1.week.ago)
79
+ less_commented = create(:comment, commentable: commentable, author: author, created_at: 1.week.from_now, updated_at: 1.week.from_now)
80
+ create(:comment, commentable: comment)
81
+ create_list(:comment, 3, commentable: most_commented)
82
+ expect(subject.query).to eq [most_commented, comment, less_commented]
83
+ end
84
+ end
85
+ end
86
+ end
@@ -1,2 +1,4 @@
1
1
  ENV["ENGINE_NAME"] = File.dirname(File.dirname(__FILE__)).split("/").last
2
- require "decidim/test/base_spec_helper"
2
+
3
+ require "decidim/dev/test/base_spec_helper"
4
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
@@ -10,7 +10,7 @@ class Decidim::DummyController < Decidim::ApplicationController
10
10
 
11
11
  def show
12
12
  @participatory_process = Decidim::ParticipatoryProcess.find(params[:id])
13
- @options = params.slice(:arguable)
13
+ @options = params.slice(:arguable, :votable)
14
14
  @options.each { |key, val| @options[key] = val === 'true' }
15
15
  render inline: %{
16
16
  <%= javascript_include_tag 'application' %>
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+ require "spec_helper"
3
+ require "decidim/api/test/type_context"
4
+
5
+ module Decidim
6
+ module Comments
7
+ describe CommentMutationType do
8
+ include_context "graphql type"
9
+ let(:model) { create(:comment) }
10
+
11
+ describe "upVote" do
12
+ let(:query) {
13
+ "{ upVote { upVoted } }"
14
+ }
15
+
16
+ before do
17
+ allow(Decidim::Comments::VoteComment).to receive(:call).with(model, current_user, weight: 1).and_return (
18
+ model
19
+ )
20
+ end
21
+
22
+ it "should call UpVoteComment command" do
23
+ expect(model).to receive(:up_voted_by?).with(current_user).and_return(true)
24
+ expect(response["upVote"]).to include("upVoted" => true)
25
+ end
26
+ end
27
+
28
+ describe "downVote" do
29
+ let(:query) {
30
+ "{ downVote { downVoted } }"
31
+ }
32
+
33
+ before do
34
+ allow(Decidim::Comments::VoteComment).to receive(:call).with(model, current_user, weight: -1).and_return (
35
+ model
36
+ )
37
+ end
38
+
39
+ it "should call UpVoteComment command" do
40
+ expect(model).to receive(:down_voted_by?).with(current_user).and_return(true)
41
+ expect(response["downVote"]).to include("downVoted" => true)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end