decidim 0.4.3 → 0.4.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 (156) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +11 -0
  3. data/CHANGELOG.md +16 -2
  4. data/Gemfile.lock +41 -42
  5. data/README.md +1 -1
  6. data/Rakefile +1 -1
  7. data/decidim-admin/app/commands/decidim/admin/publish_participatory_process.rb +1 -5
  8. data/decidim-admin/app/commands/decidim/admin/unpublish_participatory_process.rb +1 -5
  9. data/decidim-admin/app/controllers/decidim/admin/application_controller.rb +1 -1
  10. data/decidim-admin/app/controllers/decidim/admin/exports_controller.rb +2 -9
  11. data/decidim-admin/app/controllers/decidim/admin/feature_permissions_controller.rb +1 -1
  12. data/decidim-admin/app/controllers/decidim/admin/features/base_controller.rb +3 -2
  13. data/decidim-admin/app/controllers/decidim/admin/features_controller.rb +2 -2
  14. data/decidim-admin/app/controllers/decidim/admin/participatory_process_groups_controller.rb +2 -1
  15. data/decidim-admin/app/controllers/decidim/admin/participatory_processes_controller.rb +6 -2
  16. data/decidim-admin/app/forms/decidim/admin/participatory_process_copy_form.rb +1 -1
  17. data/decidim-admin/app/forms/decidim/admin/participatory_process_form.rb +1 -1
  18. data/decidim-admin/app/helpers/decidim/admin/process_groups_for_select_helper.rb +1 -1
  19. data/decidim-admin/app/helpers/decidim/admin/processes_for_select_helper.rb +1 -1
  20. data/decidim-admin/app/helpers/decidim/admin/{feature_settings_helper.rb → settings_helper.rb} +2 -2
  21. data/decidim-admin/app/models/decidim/admin/abilities/participatory_process_admin_ability.rb +2 -2
  22. data/decidim-admin/app/views/decidim/admin/attachments/index.html.erb +1 -1
  23. data/decidim-admin/app/views/decidim/admin/categories/index.html.erb +1 -1
  24. data/decidim-admin/app/views/decidim/admin/exports/_dropdown.html.erb +1 -1
  25. data/decidim-admin/app/views/decidim/admin/features/_feature.html.erb +2 -2
  26. data/decidim-admin/app/views/decidim/admin/features/edit.html.erb +1 -1
  27. data/decidim-admin/app/views/decidim/admin/features/index.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/participatory_process_groups/show.html.erb +1 -1
  30. data/decidim-admin/app/views/decidim/admin/participatory_process_steps/index.html.erb +2 -2
  31. data/decidim-admin/app/views/decidim/admin/participatory_process_steps/new.html.erb +0 -1
  32. data/decidim-admin/app/views/decidim/admin/participatory_process_user_roles/index.html.erb +1 -1
  33. data/decidim-admin/app/views/decidim/admin/participatory_process_user_roles/new.html.erb +6 -6
  34. data/decidim-admin/app/views/decidim/admin/participatory_processes/new.html.erb +0 -1
  35. data/decidim-admin/app/views/layouts/decidim/admin/participatory_process.html.erb +2 -2
  36. data/decidim-admin/config/locales/ca.yml +7 -14
  37. data/decidim-admin/config/locales/en.yml +7 -14
  38. data/decidim-admin/config/locales/es.yml +7 -14
  39. data/decidim-admin/config/locales/eu.yml +9 -15
  40. data/decidim-admin/config/locales/fi.yml +7 -12
  41. data/decidim-admin/config/locales/fr.yml +9 -15
  42. data/decidim-admin/config/locales/it.yml +9 -15
  43. data/decidim-admin/config/routes.rb +9 -7
  44. data/decidim-admin/spec/commands/copy_participatory_process_spec.rb +4 -4
  45. data/decidim-admin/spec/controllers/exports_controller_spec.rb +2 -0
  46. data/decidim-admin/spec/controllers/participatory_processes_controller_spec.rb +2 -0
  47. data/decidim-admin/spec/controllers/static_pages_controller_spec.rb +2 -0
  48. data/decidim-admin/spec/features/admin_copy_participatory_process_spec.rb +3 -2
  49. data/decidim-admin/spec/features/admin_manages_feature_permissions_spec.rb +1 -1
  50. data/decidim-admin/spec/features/admin_manages_features_spec.rb +4 -4
  51. data/decidim-admin/spec/features/admin_manages_participatory_process_admins_spec.rb +2 -1
  52. data/decidim-admin/spec/features/admin_manages_participatory_process_attachments_spec.rb +2 -1
  53. data/decidim-admin/spec/features/admin_manages_participatory_process_categories_spec.rb +1 -1
  54. data/decidim-admin/spec/features/admin_manages_participatory_process_groups_spec.rb +2 -2
  55. data/decidim-admin/spec/features/admin_manages_participatory_process_steps_spec.rb +2 -1
  56. data/decidim-admin/spec/features/admin_manages_participatory_processes_spec.rb +3 -3
  57. data/decidim-admin/spec/features/admin_manages_user_groups_spec.rb +3 -2
  58. data/decidim-admin/spec/features/participatory_process_admin_manages_participatory_process_admins_spec.rb +1 -2
  59. data/decidim-admin/spec/features/participatory_process_admin_manages_participatory_process_attachments_spec.rb +1 -3
  60. data/decidim-admin/spec/features/{process_admin_manages_participatory_process_categories_spec.rb → participatory_process_admin_manages_participatory_process_categories_spec.rb} +2 -4
  61. data/decidim-admin/spec/features/participatory_process_admin_manages_participatory_process_steps_spec.rb +1 -2
  62. data/decidim-admin/spec/features/participatory_process_admin_manages_participatory_processes_spec.rb +2 -2
  63. data/decidim-admin/spec/helpers/{feature_settings_helper_spec.rb → settings_helper_spec.rb} +1 -1
  64. data/decidim-admin/spec/shared/manage_process_admins_examples.rb +9 -1
  65. data/decidim-admin/spec/shared/participatory_process_administration_by_admin_shared_context.rb +9 -0
  66. data/decidim-admin/spec/shared/participatory_process_administration_by_process_admin_shared_context.rb +13 -0
  67. data/decidim-admin/spec/shared/{participatory_admin_shared_context.rb → participatory_process_administration_shared_context.rb} +2 -4
  68. data/decidim-api/decidim-api.gemspec +2 -0
  69. data/decidim-api/lib/decidim/api/schema.rb +1 -1
  70. data/decidim-api/lib/decidim/api/test/type_context.rb +1 -1
  71. data/decidim-api/spec/controllers/queries_controller_spec.rb +2 -0
  72. data/decidim-budgets/app/forms/decidim/budgets/admin/project_form.rb +4 -0
  73. data/decidim-budgets/app/views/decidim/budgets/admin/projects/index.html.erb +1 -1
  74. data/decidim-budgets/app/views/decidim/budgets/projects/_tags.html.erb +2 -2
  75. data/decidim-budgets/decidim-budgets.gemspec +1 -1
  76. data/decidim-budgets/lib/decidim/budgets/feature.rb +30 -34
  77. data/decidim-budgets/spec/commands/remove_line_item_spec.rb +2 -0
  78. data/decidim-budgets/spec/features/comments_spec.rb +1 -1
  79. data/decidim-budgets/spec/features/orders_spec.rb +1 -5
  80. data/decidim-budgets/spec/forms/project_form_spec.rb +6 -0
  81. data/decidim-budgets/spec/shared/manage_projects_examples.rb +1 -1
  82. data/decidim-comments/app/assets/javascripts/decidim/comments/bundle.js +0 -0
  83. data/decidim-comments/app/frontend/comments/add_comment_form.component.tsx +3 -3
  84. data/decidim-comments/app/frontend/support/schema.ts +1379 -94
  85. data/decidim-comments/app/types/decidim/comments/commentable_interface.rb +1 -1
  86. data/decidim-comments/decidim-comments.gemspec +1 -0
  87. data/decidim-comments/lib/decidim/comments/api/comment_mutation_type.rb +2 -2
  88. data/decidim-comments/spec/features/comments_spec.rb +1 -1
  89. data/decidim-comments/spec/features/notifications_spec.rb +1 -1
  90. data/decidim-comments/spec/features/report_comment_spec.rb +1 -1
  91. data/decidim-comments/spec/models/comment_spec.rb +1 -1
  92. data/decidim-dev/lib/decidim/dev/test/base_spec_helper.rb +2 -1
  93. data/decidim-dev/lib/decidim/dev/test/rspec_support/feature_context.rb +1 -3
  94. data/decidim-dev/lib/decidim/dev/test/rspec_support/i18n.rb +0 -7
  95. data/decidim-dev/lib/decidim/dev/test/rspec_support/phantomjs_polyfills/promise.js +2 -2
  96. data/decidim-dev/lib/decidim/dev/test/rspec_support/route_helpers.rb +6 -0
  97. data/decidim-dev/lib/generators/decidim/dummy_generator.rb +0 -2
  98. data/decidim-meetings/app/forms/decidim/meetings/admin/meeting_form.rb +6 -0
  99. data/decidim-meetings/app/helpers/decidim/meetings/meetings_helper.rb +2 -1
  100. data/decidim-meetings/app/services/decidim/meetings/meeting_search.rb +2 -2
  101. data/decidim-meetings/app/views/decidim/meetings/admin/meeting_closes/_form.html.erb +2 -2
  102. data/decidim-meetings/app/views/decidim/meetings/admin/meetings/index.html.erb +1 -1
  103. data/decidim-meetings/app/views/decidim/meetings/meetings/_tags.html.erb +2 -2
  104. data/decidim-meetings/decidim-meetings.gemspec +1 -1
  105. data/decidim-meetings/lib/decidim/meetings/feature.rb +35 -39
  106. data/decidim-meetings/spec/features/explore_meetings_spec.rb +1 -1
  107. data/decidim-meetings/spec/forms/meeting_form_spec.rb +6 -0
  108. data/decidim-meetings/spec/shared/manage_meetings_examples.rb +1 -1
  109. data/decidim-pages/lib/decidim/pages/feature.rb +14 -18
  110. data/decidim-pages/spec/features/comments_spec.rb +1 -1
  111. data/decidim-proposals/app/forms/decidim/proposals/admin/proposal_form.rb +6 -0
  112. data/decidim-proposals/app/forms/decidim/proposals/proposal_form.rb +6 -0
  113. data/decidim-proposals/app/models/decidim/proposals/proposal.rb +9 -1
  114. data/decidim-proposals/app/views/decidim/proposals/admin/proposals/index.html.erb +1 -1
  115. data/decidim-proposals/app/views/decidim/proposals/proposals/_tags.html.erb +2 -2
  116. data/decidim-proposals/decidim-proposals.gemspec +1 -0
  117. data/decidim-proposals/lib/decidim/proposals/feature.rb +59 -65
  118. data/decidim-proposals/lib/decidim/proposals/proposal_serializer.rb +1 -15
  119. data/decidim-proposals/spec/controllers/decidim/admin/proposal_answers_controller_spec.rb +2 -4
  120. data/decidim-proposals/spec/controllers/decidim/proposal_votes_controller_spec.rb +2 -4
  121. data/decidim-proposals/spec/controllers/decidim/proposals_controller_spec.rb +2 -4
  122. data/decidim-proposals/spec/features/comments_spec.rb +1 -1
  123. data/decidim-proposals/spec/features/report_proposal_spec.rb +1 -1
  124. data/decidim-proposals/spec/models/decidim/proposals/proposal_spec.rb +18 -0
  125. data/decidim-proposals/spec/shared/manage_proposals_examples.rb +1 -1
  126. data/decidim-proposals/spec/shared/proposal_form_examples.rb +6 -0
  127. data/decidim-results/app/controllers/decidim/results/result_widgets_controller.rb +0 -2
  128. data/decidim-results/app/forms/decidim/results/admin/result_form.rb +4 -0
  129. data/decidim-results/app/views/decidim/results/admin/results/index.html.erb +1 -1
  130. data/decidim-results/app/views/decidim/results/results/_tags.html.erb +2 -2
  131. data/decidim-results/decidim-results.gemspec +2 -1
  132. data/decidim-results/lib/decidim/results/feature.rb +18 -22
  133. data/decidim-results/spec/controllers/results_controller_spec.rb +2 -0
  134. data/decidim-results/spec/features/comments_spec.rb +1 -1
  135. data/decidim-results/spec/features/explore_results_spec.rb +1 -1
  136. data/decidim-results/spec/forms/result_form_spec.rb +6 -0
  137. data/decidim-results/spec/shared/manage_results_examples.rb +1 -1
  138. data/decidim-surveys/decidim-surveys.gemspec +1 -0
  139. data/decidim-surveys/lib/decidim/surveys/feature.rb +23 -27
  140. data/decidim-system/db/seeds.rb +1 -2
  141. data/decidim-system/spec/commands/decidim/system/create_default_pages_spec.rb +1 -1
  142. data/docs/features_and_components.md +6 -6
  143. data/docs/getting_started.md +1 -1
  144. data/docs/how_to_create_a_plugin.md +2 -2
  145. data/docs/social_providers.md +2 -2
  146. data/lib/generators/decidim/app_generator.rb +0 -6
  147. data/lib/generators/decidim/docker_generator.rb +1 -1
  148. data/lib/generators/decidim/install_generator.rb +5 -5
  149. data/lib/generators/decidim/templates/README.md.erb +1 -1
  150. data/lib/generators/decidim/templates/database.yml.erb +1 -1
  151. data/lib/generators/decidim/templates/initializer.rb +4 -1
  152. data/package-lock.json +46 -134
  153. data/package.json +9 -9
  154. metadata +31 -30
  155. data/decidim-dev/lib/decidim/dev/test/rspec_support/engine_routes.rb +0 -35
  156. data/decidim-dev/lib/generators/decidim/templates/decidim_dev.rb +0 -3
@@ -53,7 +53,7 @@
53
53
  <% if can? :update, proposal %>
54
54
  <%= icon_link_to "chat", edit_proposal_proposal_answer_path(proposal_id: proposal.id, id: proposal.id), t("actions.answer", scope: "decidim.proposals"), class: "action-icon--edit-answer" %>
55
55
  <% end %>
56
- <%= icon_link_to "eye", decidim_proposals.proposal_path(id: proposal, feature_id: current_feature, participatory_process_id: current_participatory_process), t("actions.preview", scope: "decidim.proposals.admin"), class: "action-icon--preview", target: :blank %>
56
+ <%= icon_link_to "eye", resource_locator(proposal).path, t("actions.preview", scope: "decidim.proposals.admin"), class: "action-icon--preview", target: :blank %>
57
57
  </td>
58
58
  </tr>
59
59
  <% end %>
@@ -1,10 +1,10 @@
1
1
  <% if proposal.category.present? || proposal.scope.present? %>
2
2
  <ul class="tags tags--proposal" >
3
3
  <% if proposal.category.present? %>
4
- <li><%= link_to translated_attribute(proposal.category.name), decidim_proposals.proposals_path(filter: { category_id: proposal.category.id }) %></li>
4
+ <li><%= link_to translated_attribute(proposal.category.name), resource_locator(proposal).index(filter: { category_id: proposal.category.id }) %></li>
5
5
  <% end %>
6
6
  <% if proposal.scope.present? && !current_participatory_process.scope %>
7
- <li><%= link_to proposal.scope.name, decidim_proposals.proposals_path(filter: { scope_id: [proposal.scope.id] }) %></li>
7
+ <li><%= link_to proposal.scope.name, resource_locator(proposal).index(filter: { scope_id: [proposal.scope.id] }) %></li>
8
8
  <% end %>
9
9
  </ul>
10
10
  <% end %>
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.add_dependency "social-share-button", "~> 0.10.0"
23
23
 
24
24
  s.add_development_dependency "decidim-dev", Decidim.version
25
+ s.add_development_dependency "decidim-admin", Decidim.version
25
26
  s.add_development_dependency "decidim-meetings", Decidim.version
26
27
  s.add_development_dependency "decidim-results", Decidim.version
27
28
  s.add_development_dependency "decidim-budgets", Decidim.version
@@ -71,75 +71,69 @@ Decidim.register_feature(:proposals) do |feature|
71
71
  exports.serializer Decidim::Comments::CommentSerializer
72
72
  end
73
73
 
74
- feature.seeds do
75
- Decidim::ParticipatoryProcess.find_each do |process|
76
- next unless process.steps.any?
77
-
78
- feature = Decidim::Feature.create!(
79
- name: Decidim::Features::Namer.new(process.organization.available_locales, :proposals).i18n_name,
80
- manifest_name: :proposals,
81
- published_at: Time.current,
82
- participatory_process: process,
83
- settings: {
84
- vote_limit: 0
85
- },
86
- step_settings: {
87
- process.active_step.id => { votes_enabled: true, votes_blocked: false, creation_enabled: true }
88
- }
74
+ feature.seeds do |process|
75
+ feature = Decidim::Feature.create!(
76
+ name: Decidim::Features::Namer.new(process.organization.available_locales, :proposals).i18n_name,
77
+ manifest_name: :proposals,
78
+ published_at: Time.current,
79
+ participatory_process: process,
80
+ settings: {
81
+ vote_limit: 0
82
+ },
83
+ step_settings: {
84
+ process.active_step.id => { votes_enabled: true, votes_blocked: false, creation_enabled: true }
85
+ }
86
+ )
87
+ # So that we have some with global scope
88
+ scopes = feature.organization.scopes + [nil]
89
+
90
+ 20.times do |n|
91
+ author = Decidim::User.where(organization: feature.organization).all.sample
92
+ user_group = [true, false].sample ? author.user_groups.verified.sample : nil
93
+ state, answer = if n > 15
94
+ ["accepted", Decidim::Faker::Localized.sentence(10)]
95
+ elsif n > 9
96
+ ["rejected", nil]
97
+ elsif n > 6
98
+ ["evaluating", nil]
99
+ else
100
+ [nil, nil]
101
+ end
102
+
103
+ proposal = Decidim::Proposals::Proposal.create!(
104
+ feature: feature,
105
+ category: process.categories.sample,
106
+ scope: scopes.sample,
107
+ title: Faker::Lorem.sentence(2),
108
+ body: Faker::Lorem.paragraphs(2).join("\n"),
109
+ author: author,
110
+ user_group: user_group,
111
+ state: state,
112
+ answer: answer,
113
+ answered_at: Time.current
89
114
  )
90
- categories = feature.participatory_process.categories
91
- # So that we have some with global scope
92
- scopes = feature.organization.scopes + [nil]
93
-
94
- 20.times do |n|
95
- author = Decidim::User.where(organization: feature.organization).all.sample
96
- user_group = [true, false].sample ? author.user_groups.verified.sample : nil
97
-
98
- proposal = Decidim::Proposals::Proposal.create!(
99
- feature: feature,
100
- category: categories.sample,
101
- scope: scopes.sample,
102
- title: Faker::Lorem.sentence(2),
103
- body: Faker::Lorem.paragraphs(2).join("\n"),
104
- author: author,
105
- user_group: user_group
115
+
116
+ rand(3).times do |m|
117
+ email = "vote-author-#{process.id}-#{n}-#{m}@example.org"
118
+ name = "#{Faker::Name.name} #{process.id} #{n} #{m}"
119
+
120
+ author = Decidim::User.find_or_initialize_by(email: email)
121
+ author.update!(
122
+ password: "password1234",
123
+ password_confirmation: "password1234",
124
+ name: name,
125
+ organization: feature.organization,
126
+ tos_agreement: "1",
127
+ confirmed_at: Time.current,
128
+ comments_notifications: true,
129
+ replies_notifications: true
106
130
  )
107
131
 
108
- if n > 15
109
- proposal.state = "accepted"
110
- proposal.answered_at = Time.current
111
- proposal.save!
112
- elsif n > 9
113
- proposal.state = "rejected"
114
- proposal.answered_at = Time.current
115
- proposal.answer = Decidim::Faker::Localized.sentence(10)
116
- proposal.save!
117
- elsif n > 6
118
- proposal.state = "evaluating"
119
- proposal.answered_at = Time.current
120
- proposal.save!
121
- end
122
-
123
- rand(3).times do |m|
124
- email = "vote-author-#{process.id}-#{n}-#{m}@example.org"
125
- name = "#{Faker::Name.name} #{process.id} #{n} #{m}"
126
-
127
- author = Decidim::User.create!(email: email,
128
- password: "password1234",
129
- password_confirmation: "password1234",
130
- name: name,
131
- organization: feature.organization,
132
- tos_agreement: "1",
133
- confirmed_at: Time.current,
134
- comments_notifications: true,
135
- replies_notifications: true)
136
-
137
- Decidim::Proposals::ProposalVote.create!(proposal: proposal,
138
- author: author)
139
- end
140
-
141
- Decidim::Comments::Seed.comments_for(proposal)
132
+ Decidim::Proposals::ProposalVote.create!(proposal: proposal,
133
+ author: author)
142
134
  end
135
+
136
+ Decidim::Comments::Seed.comments_for(proposal)
143
137
  end
144
138
  end
145
139
  end
@@ -5,7 +5,6 @@ module Decidim
5
5
  # This class serializes a Proposal so can be exported to CSV, JSON or other
6
6
  # formats.
7
7
  class ProposalSerializer < Decidim::Exporters::Serializer
8
- include Rails.application.routes.url_helpers
9
8
  include Decidim::ResourceHelper
10
9
 
11
10
  # Public: Initializes the serializer with a proposal.
@@ -44,27 +43,14 @@ module Decidim
44
43
  proposal.feature
45
44
  end
46
45
 
47
- def organization
48
- feature.organization
49
- end
50
-
51
46
  def meetings
52
47
  @proposal.linked_resources(:meetings, "proposals_from_meeting").map do |meeting|
53
48
  Decidim::ResourceLocatorPresenter.new(meeting).url
54
49
  end
55
50
  end
56
51
 
57
- def participatory_process
58
- feature.participatory_process
59
- end
60
-
61
52
  def url
62
- Decidim::Proposals::Engine.routes.url_helpers.proposal_url(
63
- proposal,
64
- feature_id: feature,
65
- participatory_process_id: participatory_process,
66
- host: organization.host
67
- )
53
+ Decidim::ResourceLocatorPresenter.new(proposal).url
68
54
  end
69
55
  end
70
56
  end
@@ -6,14 +6,12 @@ module Decidim
6
6
  module Proposals
7
7
  module Admin
8
8
  describe ProposalAnswersController, type: :controller do
9
+ routes { Decidim::Proposals::AdminEngine.routes }
10
+
9
11
  let(:feature) { proposal.feature }
10
12
  let(:proposal) { create(:proposal) }
11
13
  let(:user) { create(:user, :confirmed, :admin, organization: feature.organization) }
12
14
 
13
- routes do
14
- Decidim::Proposals::AdminEngine.routes
15
- end
16
-
17
15
  before do
18
16
  @request.env["decidim.current_organization"] = feature.organization
19
17
  @request.env["decidim.current_participatory_process"] = feature.participatory_process
@@ -5,13 +5,11 @@ require "spec_helper"
5
5
  module Decidim
6
6
  module Proposals
7
7
  describe ProposalVotesController, type: :controller do
8
+ routes { Decidim::Proposals::Engine.routes }
9
+
8
10
  let(:proposal) { create(:proposal, feature: feature) }
9
11
  let(:user) { create(:user, :confirmed, organization: feature.organization) }
10
12
 
11
- routes do
12
- Decidim::Proposals::Engine.routes
13
- end
14
-
15
13
  before do
16
14
  @request.env["decidim.current_organization"] = feature.organization
17
15
  @request.env["decidim.current_participatory_process"] = feature.participatory_process
@@ -5,11 +5,9 @@ require "spec_helper"
5
5
  module Decidim
6
6
  module Proposals
7
7
  describe ProposalsController, type: :controller do
8
- let(:user) { create(:user, :confirmed, organization: feature.organization) }
8
+ routes { Decidim::Proposals::Engine.routes }
9
9
 
10
- routes do
11
- Decidim::Proposals::Engine.routes
12
- end
10
+ let(:user) { create(:user, :confirmed, organization: feature.organization) }
13
11
 
14
12
  before do
15
13
  @request.env["decidim.current_organization"] = feature.organization
@@ -7,6 +7,6 @@ describe "Comments", type: :feature, perform_enqueued: true do
7
7
  let!(:author) { create(:user, :confirmed, organization: organization) }
8
8
  let!(:commentable) { create(:proposal, feature: feature, author: author) }
9
9
 
10
- let(:resource_path) { decidim_proposals.proposal_path(commentable, feature_id: feature, participatory_process_id: feature.participatory_process) }
10
+ let(:resource_path) { resource_locator(commentable).path }
11
11
  include_examples "comments"
12
12
  end
@@ -9,7 +9,7 @@ describe "Report Proposal", type: :feature do
9
9
  let(:manifest_name) { "proposals" }
10
10
  let!(:proposals) { create_list(:proposal, 3, feature: feature) }
11
11
  let(:reportable) { proposals.first }
12
- let(:reportable_path) { decidim_proposals.proposal_path(reportable, feature_id: feature, participatory_process_id: feature.participatory_process) }
12
+ let(:reportable_path) { resource_locator(reportable).path }
13
13
  let!(:user) { create :user, :confirmed, organization: organization }
14
14
 
15
15
  let!(:feature) do
@@ -81,6 +81,24 @@ module Decidim
81
81
  end
82
82
  end
83
83
  end
84
+
85
+ context "when the proposal is official" do
86
+ let!(:organization) { create :organization }
87
+ let!(:admin) { create :user, :admin, organization: organization }
88
+ let!(:participatory_process) { create :participatory_process, organization: organization }
89
+ let!(:process_admin) { create :user, :process_admin, organization: organization, participatory_process: participatory_process }
90
+ let!(:feature) { create :proposal_feature, participatory_process: participatory_process }
91
+ let!(:context_author) { create(:user, organization: organization) }
92
+ let!(:proposal) { build(:proposal, :official, feature: feature) }
93
+
94
+ it "is notifiable" do
95
+ expect(subject.notifiable?(author: context_author)).to be_truthy
96
+ end
97
+
98
+ it "notifies admins and process admins" do
99
+ expect(subject.users_to_notify).to match_array([admin, process_admin])
100
+ end
101
+ end
84
102
  end
85
103
  end
86
104
  end
@@ -20,7 +20,7 @@ RSpec.shared_examples "manage proposals" do
20
20
  end
21
21
 
22
22
  within_window @new_window do
23
- expect(current_path).to eq decidim_proposals.proposal_path(id: proposal.id, participatory_process_id: participatory_process.id, feature_id: current_feature.id)
23
+ expect(current_path).to eq resource_locator(proposal).path
24
24
  expect(page).to have_content(translated(proposal.title))
25
25
  end
26
26
  end
@@ -133,4 +133,10 @@ RSpec.shared_examples "a proposal form" do
133
133
  it { is_expected.to eq(nil) }
134
134
  end
135
135
  end
136
+
137
+ it "properly maps category id from model" do
138
+ proposal = create(:proposal, feature: feature, category: category)
139
+
140
+ expect(described_class.from_model(proposal).category_id).to eq(category_id)
141
+ end
136
142
  end
@@ -3,8 +3,6 @@
3
3
  module Decidim
4
4
  module Results
5
5
  class ResultWidgetsController < Decidim::WidgetsController
6
- helper_method :model
7
-
8
6
  private
9
7
 
10
8
  def model
@@ -22,6 +22,10 @@ module Decidim
22
22
 
23
23
  def map_model(model)
24
24
  self.proposal_ids = model.linked_resources(:proposals, "included_proposals").pluck(:id)
25
+
26
+ return unless model.categorization
27
+
28
+ self.decidim_category_id = model.categorization.decidim_category_id
25
29
  end
26
30
 
27
31
  def proposals
@@ -22,7 +22,7 @@
22
22
  <%= translated_attribute(result.title) %><br />
23
23
  </td>
24
24
  <td class="table-list__actions">
25
- <%= icon_link_to "eye", decidim_results.result_path(id: result, feature_id: current_feature, participatory_process_id: current_participatory_process), t("actions.preview", scope: "decidim.results"), class: "action-icon--preview", target: :blank %>
25
+ <%= icon_link_to "eye", resource_locator(result).path, t("actions.preview", scope: "decidim.results"), class: "action-icon--preview", target: :blank %>
26
26
 
27
27
  <% if can? :update, current_feature %>
28
28
  <%= icon_link_to "pencil", edit_result_path(result), t("actions.edit", scope: "decidim.results"), class: "action-icon--edit" %>
@@ -1,10 +1,10 @@
1
1
  <% if result.category.present? || result.scope.present? %>
2
2
  <ul class="tags tags--result" >
3
3
  <% if result.category.present? %>
4
- <li><%= link_to translated_attribute(result.category.name), decidim_results.results_path(filter: { category_id: result.category.id }) %></li>
4
+ <li><%= link_to translated_attribute(result.category.name), resource_locator(result).index(filter: { category_id: result.category.id }) %></li>
5
5
  <% end %>
6
6
  <% if !current_participatory_process.scope && result.scope.present? %>
7
- <li><%= link_to result.scope.name, decidim_results.results_path(filter: { scope_id: [result.scope.id] }) %></li>
7
+ <li><%= link_to result.scope.name, resource_locator(result).index(filter: { scope_id: [result.scope.id] }) %></li>
8
8
  <% end %>
9
9
  </ul>
10
10
  <% end %>
@@ -22,7 +22,8 @@ Gem::Specification.new do |s|
22
22
  s.add_dependency "kaminari", "~> 1.0.1"
23
23
 
24
24
  s.add_development_dependency "decidim-dev", Decidim.version
25
+ s.add_development_dependency "decidim-admin", Decidim.version
25
26
  s.add_development_dependency "decidim-comments", Decidim.version
26
- s.add_development_dependency "decidim-meetings", Decidim.version
27
27
  s.add_development_dependency "decidim-proposals", Decidim.version
28
+ s.add_development_dependency "decidim-meetings", Decidim.version
28
29
  end
@@ -33,30 +33,26 @@ Decidim.register_feature(:results) do |feature|
33
33
  settings.attribute :comments_blocked, type: :boolean, default: false
34
34
  end
35
35
 
36
- feature.seeds do
37
- Decidim::ParticipatoryProcess.find_each do |process|
38
- next unless process.steps.any?
39
-
40
- feature = Decidim::Feature.create!(
41
- name: Decidim::Features::Namer.new(process.organization.available_locales, :results).i18n_name,
42
- manifest_name: :results,
43
- published_at: Time.current,
44
- participatory_process: process
36
+ feature.seeds do |process|
37
+ feature = Decidim::Feature.create!(
38
+ name: Decidim::Features::Namer.new(process.organization.available_locales, :results).i18n_name,
39
+ manifest_name: :results,
40
+ published_at: Time.current,
41
+ participatory_process: process
42
+ )
43
+
44
+ 3.times do
45
+ result = Decidim::Results::Result.create!(
46
+ feature: feature,
47
+ scope: process.organization.scopes.sample,
48
+ category: process.categories.sample,
49
+ title: Decidim::Faker::Localized.sentence(2),
50
+ description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
51
+ Decidim::Faker::Localized.paragraph(3)
52
+ end
45
53
  )
46
54
 
47
- 3.times do
48
- result = Decidim::Results::Result.create!(
49
- feature: feature,
50
- scope: process.organization.scopes.sample,
51
- category: process.categories.sample,
52
- title: Decidim::Faker::Localized.sentence(2),
53
- description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
54
- Decidim::Faker::Localized.paragraph(3)
55
- end
56
- )
57
-
58
- Decidim::Comments::Seed.comments_for(result)
59
- end
55
+ Decidim::Comments::Seed.comments_for(result)
60
56
  end
61
57
  end
62
58
  end
@@ -5,6 +5,8 @@ require "spec_helper"
5
5
  module Decidim
6
6
  module Results
7
7
  describe ResultsController, type: :controller do
8
+ routes { Decidim::Results::Engine.routes }
9
+
8
10
  before do
9
11
  @request.env["decidim.current_organization"] = feature.organization
10
12
  @request.env["decidim.current_participatory_process"] = feature.participatory_process
@@ -16,6 +16,6 @@ describe "Comments", type: :feature, perform_enqueued: true do
16
16
  end
17
17
  let!(:commentable) { create(:result, feature: feature) }
18
18
 
19
- let(:resource_path) { decidim_results.result_path(commentable, feature_id: feature, participatory_process_id: feature.participatory_process) }
19
+ let(:resource_path) { resource_locator(commentable).path }
20
20
  include_examples "comments"
21
21
  end