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
@@ -26,7 +26,7 @@ module Decidim
26
26
  end
27
27
 
28
28
  field :comments do
29
- type !types[CommentType]
29
+ type !types[!CommentType]
30
30
 
31
31
  argument :orderBy, types.String, "Order the comments"
32
32
 
@@ -19,4 +19,5 @@ Gem::Specification.new do |s|
19
19
  s.add_dependency "jquery-rails", "~> 4.0"
20
20
 
21
21
  s.add_development_dependency "decidim-dev", Decidim.version
22
+ s.add_development_dependency "decidim-admin", Decidim.version
22
23
  end
@@ -8,11 +8,11 @@ module Decidim
8
8
 
9
9
  field :id, !types.ID, "The Comment's unique ID"
10
10
 
11
- field :upVote, Decidim::Comments::CommentType do
11
+ field :upVote, !Decidim::Comments::CommentType do
12
12
  resolve VoteCommentResolver.new(weight: 1)
13
13
  end
14
14
 
15
- field :downVote, Decidim::Comments::CommentType do
15
+ field :downVote, !Decidim::Comments::CommentType do
16
16
  resolve VoteCommentResolver.new(weight: -1)
17
17
  end
18
18
  end
@@ -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(:dummy_resource, feature: feature, author: author) }
9
9
 
10
- let(:resource_path) { decidim_dummy.dummy_resource_path(commentable, feature_id: commentable.feature, participatory_process_id: commentable.feature.participatory_process) }
10
+ let(:resource_path) { resource_locator(commentable).path }
11
11
  include_examples "comments"
12
12
  end
@@ -15,7 +15,7 @@ describe "Comment notifications", type: :feature do
15
15
  end
16
16
 
17
17
  it "commentable author receives an email with a link to the comment", perform_enqueued: true do
18
- visit decidim_dummy.dummy_resource_path(commentable, feature_id: commentable.feature, participatory_process_id: commentable.feature.participatory_process)
18
+ visit resource_locator(commentable).path
19
19
  expect(page).to have_selector(".add-comment form")
20
20
 
21
21
  within ".add-comment form" do
@@ -9,7 +9,7 @@ describe "Report Comment", type: :feature do
9
9
  let(:manifest_name) { "dummy" }
10
10
  let!(:commentable) { create(:dummy_resource, feature: feature) }
11
11
  let!(:reportable) { create(:comment, commentable: commentable) }
12
- let(:reportable_path) { decidim_dummy.dummy_resource_path(commentable, feature_id: commentable.feature, participatory_process_id: commentable.feature.participatory_process) }
12
+ let(:reportable_path) { resource_locator(commentable).path }
13
13
 
14
14
  let!(:user) { create :user, :confirmed, organization: organization }
15
15
 
@@ -26,7 +26,7 @@ module Decidim
26
26
  expect(subject.commentable).to eq(commentable)
27
27
  end
28
28
 
29
- it "has an associated commentable" do
29
+ it "has an associated root commentable" do
30
30
  expect(subject.root_commentable).to eq(commentable)
31
31
  end
32
32
 
@@ -33,7 +33,8 @@ require "rails"
33
33
  require "active_support/core_ext/string"
34
34
  require "decidim/core"
35
35
  require "decidim/core/test"
36
- require "#{__dir__}/rspec_support/feature.rb"
36
+
37
+ require_relative "rspec_support/feature.rb"
37
38
 
38
39
  begin
39
40
  require "#{Decidim::Dev.dummy_app_path}/config/environment"
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RSpec.shared_context "feature" do
4
- include Decidim::FeaturePathHelper
5
-
6
4
  let(:manifest) { Decidim.find_feature_manifest(manifest_name) }
7
5
 
8
6
  let(:user) { create :user, :confirmed, organization: organization }
@@ -28,7 +26,7 @@ RSpec.shared_context "feature" do
28
26
  end
29
27
 
30
28
  def visit_feature
31
- page.visit feature_path(feature)
29
+ page.visit main_feature_path(feature)
32
30
  end
33
31
  end
34
32
 
@@ -3,14 +3,7 @@
3
3
  RSpec.configure do |config|
4
4
  config.before(:suite) do
5
5
  I18n.config.enforce_available_locales = false
6
- end
7
-
8
- config.around(:each) do |example|
9
6
  I18n.available_locales = %w(en ca es)
10
7
  Decidim.available_locales = %w(en ca es)
11
-
12
- previous_locale = I18n.locale
13
- example.run
14
- I18n.locale = previous_locale
15
8
  end
16
9
  end
@@ -5,7 +5,7 @@
5
5
  var setTimeoutFunc = setTimeout;
6
6
 
7
7
  function noop() {}
8
-
8
+
9
9
  // Polyfill for Function.prototype.bind
10
10
  function bind(fn, thisArg) {
11
11
  return function () {
@@ -223,7 +223,7 @@
223
223
  Promise._setUnhandledRejectionFn = function _setUnhandledRejectionFn(fn) {
224
224
  Promise._unhandledRejectionFn = fn;
225
225
  };
226
-
226
+
227
227
  if (typeof module !== 'undefined' && module.exports) {
228
228
  module.exports = Promise;
229
229
  } else if (!root.Promise) {
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ RSpec.configure do |config|
4
+ config.include Decidim::FeaturePathHelper
5
+ config.include Decidim::ResourceHelper
6
+ end
@@ -48,8 +48,6 @@ module Decidim
48
48
  end
49
49
 
50
50
  def decidim_dev
51
- template "decidim_dev.rb", "#{dummy_app_path}/config/initializers/decidim_dev.rb"
52
-
53
51
  # TODO: Remove these after PhantomJS updates WebKit version (see YML and
54
52
  # initializer comments)
55
53
  template "autoprefixer.yml", "#{dummy_app_path}/config/autoprefixer.yml"
@@ -31,6 +31,12 @@ module Decidim
31
31
  validates :scope, presence: true, if: ->(form) { form.decidim_scope_id.present? }
32
32
  validates :category, presence: true, if: ->(form) { form.decidim_category_id.present? }
33
33
 
34
+ def map_model(model)
35
+ return unless model.categorization
36
+
37
+ self.decidim_category_id = model.categorization.decidim_category_id
38
+ end
39
+
34
40
  def process_scope
35
41
  current_feature.participatory_process.scope
36
42
  end
@@ -6,6 +6,7 @@ module Decidim
6
6
  module MeetingsHelper
7
7
  include Decidim::ApplicationHelper
8
8
  include Decidim::TranslationsHelper
9
+ include Decidim::ResourceHelper
9
10
 
10
11
  # Public: truncates the meeting description
11
12
  #
@@ -14,7 +15,7 @@ module Decidim
14
15
  #
15
16
  # Returns the meeting's description truncated.
16
17
  def meeting_description(meeting, max_length = 120)
17
- link = decidim_meetings.meeting_path(meeting, feature_id: meeting.feature, participatory_process_id: meeting.feature.participatory_process)
18
+ link = resource_locator(meeting).path
18
19
  description = translated_attribute(meeting.description)
19
20
  tail = "... #{link_to(t("read_more", scope: "decidim.meetings"), link)}".html_safe
20
21
  CGI.unescapeHTML html_truncate(description, max_length: max_length, tail: tail)
@@ -24,9 +24,9 @@ module Decidim
24
24
  # Handle the date filter
25
25
  def search_date
26
26
  if options[:date] == "upcoming"
27
- query.where("start_time >= ? ", Time.current).order("start_time ASC")
27
+ query.where("start_time >= ? ", Time.current).order(start_time: :asc)
28
28
  elsif options[:date] == "past"
29
- query.where("start_time <= ? ", Time.current).order("start_time DESC")
29
+ query.where("start_time <= ? ", Time.current).order(start_time: :desc)
30
30
  end
31
31
  end
32
32
 
@@ -24,11 +24,11 @@
24
24
  <div class="row column">
25
25
  <% if @form.proposals %>
26
26
  <%= form.select :proposal_ids,
27
- @form.proposals.order("title ASC").pluck(:title, :id),
27
+ @form.proposals.order(title: :asc).pluck(:title, :id),
28
28
  { include_blank: true },
29
29
  { multiple: true, class: "chosen-select" }
30
30
  %>
31
31
  <% end %>
32
32
  </div>
33
33
  </div>
34
- </div>
34
+ </div>
@@ -46,7 +46,7 @@
46
46
  </td>
47
47
  <% end %>
48
48
  <td class="table-list__actions">
49
- <%= icon_link_to "eye", decidim_meetings.meeting_path(id: meeting, feature_id: current_feature, participatory_process_id: current_participatory_process), t("actions.preview", scope: "decidim.meetings"), class: "action-icon--preview", target: :blank %>
49
+ <%= icon_link_to "eye", resource_locator(meeting).path, t("actions.preview", scope: "decidim.meetings"), class: "action-icon--preview", target: :blank %>
50
50
 
51
51
  <% if can? :update, current_feature %>
52
52
  <%= icon_link_to "pencil", edit_meeting_path(meeting), t("actions.edit", scope: "decidim.meetings"), class: "action-icon--edit" %>
@@ -1,10 +1,10 @@
1
1
  <% if meeting.category.present? || meeting.scope.present? %>
2
2
  <ul class="tags tags--meeting" >
3
3
  <% if meeting.category.present? %>
4
- <li><%= link_to translated_attribute(meeting.category.name), decidim_meetings.meetings_path(filter: { category_id: meeting.category.id }) %></li>
4
+ <li><%= link_to translated_attribute(meeting.category.name), resource_locator(meeting).index(filter: { category_id: meeting.category.id }) %></li>
5
5
  <% end %>
6
6
  <% if !current_participatory_process.scope && meeting.scope.present? %>
7
- <li><%= link_to meeting.scope.name, decidim_meetings.meetings_path(filter: { scope_id: [meeting.scope.id] }) %></li>
7
+ <li><%= link_to meeting.scope.name, resource_locator(meeting).index(filter: { scope_id: [meeting.scope.id] }) %></li>
8
8
  <% end %>
9
9
  </ul>
10
10
  <% end %>
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.add_dependency "jquery-tmpl-rails", "~> 1.1.0"
25
25
 
26
26
  s.add_development_dependency "decidim-dev", Decidim.version
27
- s.add_development_dependency "decidim-proposals", Decidim.version
28
27
  s.add_development_dependency "decidim-admin", Decidim.version
28
+ s.add_development_dependency "decidim-proposals", Decidim.version
29
29
  s.add_development_dependency "decidim-results", Decidim.version
30
30
  end
@@ -23,47 +23,43 @@ Decidim.register_feature(:meetings) do |feature|
23
23
  meetings.count
24
24
  end
25
25
 
26
- feature.seeds do
27
- Decidim::ParticipatoryProcess.find_each do |process|
28
- next unless process.steps.any?
26
+ feature.seeds do |process|
27
+ feature = Decidim::Feature.create!(
28
+ name: Decidim::Features::Namer.new(process.organization.available_locales, :meetings).i18n_name,
29
+ published_at: Time.current,
30
+ manifest_name: :meetings,
31
+ participatory_process: process
32
+ )
29
33
 
30
- feature = Decidim::Feature.create!(
31
- name: Decidim::Features::Namer.new(process.organization.available_locales, :meetings).i18n_name,
32
- published_at: Time.current,
33
- manifest_name: :meetings,
34
- participatory_process: process
34
+ 3.times do
35
+ meeting = Decidim::Meetings::Meeting.create!(
36
+ feature: feature,
37
+ scope: process.organization.scopes.sample,
38
+ category: process.categories.sample,
39
+ title: Decidim::Faker::Localized.sentence(2),
40
+ description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
41
+ Decidim::Faker::Localized.paragraph(3)
42
+ end,
43
+ location: Decidim::Faker::Localized.sentence,
44
+ location_hints: Decidim::Faker::Localized.sentence,
45
+ start_time: 3.weeks.from_now,
46
+ end_time: 3.weeks.from_now + 4.hours,
47
+ address: "#{Faker::Address.street_address} #{Faker::Address.zip} #{Faker::Address.city}",
48
+ latitude: Faker::Address.latitude,
49
+ longitude: Faker::Address.longitude
50
+ )
51
+ Decidim::Attachment.create!(
52
+ title: Decidim::Faker::Localized.sentence(2),
53
+ description: Decidim::Faker::Localized.sentence(5),
54
+ file: File.new(File.join(__dir__, "seeds", "city.jpeg")),
55
+ attached_to: meeting
56
+ )
57
+ Decidim::Attachment.create!(
58
+ title: Decidim::Faker::Localized.sentence(2),
59
+ description: Decidim::Faker::Localized.sentence(5),
60
+ file: File.new(File.join(__dir__, "seeds", "Exampledocument.pdf")),
61
+ attached_to: meeting
35
62
  )
36
-
37
- 3.times do
38
- meeting = Decidim::Meetings::Meeting.create!(
39
- feature: feature,
40
- scope: process.organization.scopes.sample,
41
- category: process.categories.sample,
42
- title: Decidim::Faker::Localized.sentence(2),
43
- description: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
44
- Decidim::Faker::Localized.paragraph(3)
45
- end,
46
- location: Decidim::Faker::Localized.sentence,
47
- location_hints: Decidim::Faker::Localized.sentence,
48
- start_time: 3.weeks.from_now,
49
- end_time: 3.weeks.from_now + 4.hours,
50
- address: "#{Faker::Address.street_address} #{Faker::Address.zip} #{Faker::Address.city}",
51
- latitude: Faker::Address.latitude,
52
- longitude: Faker::Address.longitude
53
- )
54
- Decidim::Attachment.create!(
55
- title: Decidim::Faker::Localized.sentence(2),
56
- description: Decidim::Faker::Localized.sentence(5),
57
- file: File.new(File.join(__dir__, "seeds", "city.jpeg")),
58
- attached_to: meeting
59
- )
60
- Decidim::Attachment.create!(
61
- title: Decidim::Faker::Localized.sentence(2),
62
- description: Decidim::Faker::Localized.sentence(5),
63
- file: File.new(File.join(__dir__, "seeds", "Exampledocument.pdf")),
64
- attached_to: meeting
65
- )
66
- end
67
63
  end
68
64
  end
69
65
  end
@@ -123,7 +123,7 @@ describe "Explore meetings", type: :feature do
123
123
  end_time: date.end_of_day
124
124
  )
125
125
 
126
- visit decidim_meetings.meeting_path(participatory_process_id: participatory_process.id, feature_id: feature.id, id: meeting.id)
126
+ visit resource_locator(meeting).path
127
127
  end
128
128
 
129
129
  it "shows all meeting info" do
@@ -141,4 +141,10 @@ describe Decidim::Meetings::Admin::MeetingForm do
141
141
  expect(subject.latitude).to eq(latitude)
142
142
  expect(subject.longitude).to eq(longitude)
143
143
  end
144
+
145
+ it "properly maps category id from model" do
146
+ meeting = create(:meeting, feature: current_feature, category: category)
147
+
148
+ expect(described_class.from_model(meeting).decidim_category_id).to eq(category_id)
149
+ end
144
150
  end
@@ -47,7 +47,7 @@ RSpec.shared_examples "manage meetings" do
47
47
  end
48
48
 
49
49
  within_window @new_window do
50
- expect(current_path).to eq decidim_meetings.meeting_path(id: meeting.id, participatory_process_id: participatory_process.id, feature_id: current_feature.id)
50
+ expect(current_path).to eq resource_locator(meeting).path
51
51
  expect(page).to have_content(translated(meeting.title))
52
52
  end
53
53
  end
@@ -51,25 +51,21 @@ Decidim.register_feature(:pages) do |feature|
51
51
  resource.model_class_name = "Decidim::Pages::Page"
52
52
  end
53
53
 
54
- feature.seeds do
55
- Decidim::ParticipatoryProcess.find_each do |process|
56
- next unless process.steps.any?
54
+ feature.seeds do |process|
55
+ feature = Decidim::Feature.create!(
56
+ name: Decidim::Features::Namer.new(process.organization.available_locales, :pages).i18n_name,
57
+ manifest_name: :pages,
58
+ published_at: Time.current,
59
+ participatory_process: process
60
+ )
57
61
 
58
- feature = Decidim::Feature.create!(
59
- name: Decidim::Features::Namer.new(process.organization.available_locales, :pages).i18n_name,
60
- manifest_name: :pages,
61
- published_at: Time.current,
62
- participatory_process: process
63
- )
62
+ page = Decidim::Pages::Page.create!(
63
+ feature: feature,
64
+ body: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
65
+ Decidim::Faker::Localized.paragraph(3)
66
+ end
67
+ )
64
68
 
65
- page = Decidim::Pages::Page.create!(
66
- feature: feature,
67
- body: Decidim::Faker::Localized.wrapped("<p>", "</p>") do
68
- Decidim::Faker::Localized.paragraph(3)
69
- end
70
- )
71
-
72
- Decidim::Comments::Seed.comments_for(page)
73
- end
69
+ Decidim::Comments::Seed.comments_for(page)
74
70
  end
75
71
  end
@@ -6,6 +6,6 @@ describe "Comments", type: :feature, perform_enqueued: true do
6
6
  let!(:feature) { create(:page_feature, organization: organization) }
7
7
  let!(:commentable) { create(:page, feature: feature) }
8
8
 
9
- let(:resource_path) { decidim_pages.page_path(commentable, feature_id: feature, participatory_process_id: feature.participatory_process) }
9
+ let(:resource_path) { resource_locator(commentable).path }
10
10
  include_examples "comments"
11
11
  end
@@ -22,6 +22,12 @@ module Decidim
22
22
 
23
23
  delegate :categories, to: :current_feature, prefix: false
24
24
 
25
+ def map_model(model)
26
+ return unless model.categorization
27
+
28
+ self.category_id = model.categorization.decidim_category_id
29
+ end
30
+
25
31
  def organization_scopes
26
32
  current_organization.scopes
27
33
  end
@@ -26,6 +26,12 @@ module Decidim
26
26
 
27
27
  delegate :categories, to: :current_feature
28
28
 
29
+ def map_model(model)
30
+ return unless model.categorization
31
+
32
+ self.category_id = model.categorization.decidim_category_id
33
+ end
34
+
29
35
  def organization_scopes
30
36
  current_organization.scopes
31
37
  end
@@ -33,7 +33,8 @@ module Decidim
33
33
  end
34
34
 
35
35
  def author_name
36
- user_group&.name || author&.name || I18n.t("decidim.proposals.models.proposal.fields.official_proposal")
36
+ return I18n.t("decidim.proposals.models.proposal.fields.official_proposal") if official?
37
+ user_group&.name || author.name
37
38
  end
38
39
 
39
40
  def author_avatar_url
@@ -100,15 +101,22 @@ module Decidim
100
101
  ResourceLocatorPresenter.new(self).url
101
102
  end
102
103
 
104
+ # Public: Whether the proposal is official or not.
105
+ def official?
106
+ author.nil?
107
+ end
108
+
103
109
  # Public: Overrides the `notifiable?` Notifiable concern method.
104
110
  # When a proposal is commented the proposal's author is notified if it is not the same
105
111
  # who has commented the proposal and if the proposal's author has comment notifications enabled.
106
112
  def notifiable?(context)
113
+ return true if official?
107
114
  context[:author] != author && author.comments_notifications?
108
115
  end
109
116
 
110
117
  # Public: Overrides the `users_to_notify` Notifiable concern method.
111
118
  def users_to_notify
119
+ return Decidim::Admin::ProcessAdmins.for(feature.participatory_process) if official?
112
120
  [author]
113
121
  end
114
122
  end