decidim 0.3.2 → 0.4.0

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 (198) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/Gemfile.lock +49 -55
  4. data/README.md +2 -1
  5. data/Rakefile +4 -4
  6. data/decidim-admin/app/assets/stylesheets/decidim/admin/extra/_label-required.scss +3 -0
  7. data/decidim-admin/app/assets/stylesheets/decidim/admin/extra/_title_bar.scss +57 -1
  8. data/decidim-admin/app/commands/decidim/admin/create_participatory_process_admin.rb +28 -7
  9. data/decidim-admin/app/commands/decidim/admin/create_participatory_process_step.rb +2 -1
  10. data/decidim-admin/app/commands/decidim/admin/destroy_participatory_process_step.rb +5 -2
  11. data/decidim-admin/app/commands/decidim/admin/update_feature.rb +1 -0
  12. data/decidim-admin/app/commands/decidim/admin/update_organization.rb +10 -5
  13. data/decidim-admin/app/commands/decidim/admin/update_participatory_process.rb +4 -2
  14. data/decidim-admin/app/controllers/decidim/admin/application_controller.rb +2 -0
  15. data/decidim-admin/app/controllers/decidim/admin/concerns/has_attachments.rb +10 -1
  16. data/decidim-admin/app/controllers/decidim/admin/concerns/participatory_process_admin.rb +0 -5
  17. data/decidim-admin/app/controllers/decidim/admin/features/base_controller.rb +0 -1
  18. data/decidim-admin/app/controllers/decidim/admin/moderations_controller.rb +7 -4
  19. data/decidim-admin/app/controllers/decidim/admin/organization_controller.rb +9 -3
  20. data/decidim-admin/app/controllers/decidim/admin/participatory_process_user_roles_controller.rb +17 -0
  21. data/decidim-admin/app/controllers/decidim/admin/participatory_processes_controller.rb +11 -3
  22. data/decidim-admin/app/forms/decidim/admin/feature_form.rb +6 -0
  23. data/decidim-admin/app/forms/decidim/admin/organization_form.rb +5 -0
  24. data/decidim-admin/app/forms/decidim/admin/participatory_process_copy_form.rb +2 -3
  25. data/decidim-admin/app/forms/decidim/admin/participatory_process_form.rb +2 -0
  26. data/decidim-admin/app/forms/decidim/admin/static_page_form.rb +6 -0
  27. data/decidim-admin/app/helpers/decidim/admin/menu_helper.rb +1 -1
  28. data/decidim-admin/app/jobs/decidim/admin/newsletter_job.rb +9 -5
  29. data/decidim-admin/app/views/decidim/admin/attachments/_form.html.erb +1 -12
  30. data/decidim-admin/app/views/decidim/admin/features/_feature.html.erb +2 -2
  31. data/decidim-admin/app/views/decidim/admin/features/_form.html.erb +18 -0
  32. data/decidim-admin/app/views/decidim/admin/moderations/_report.html.erb +2 -2
  33. data/decidim-admin/app/views/decidim/admin/organization/_form.html.erb +5 -35
  34. data/decidim-admin/app/views/decidim/admin/participatory_process_groups/_form.html.erb +1 -1
  35. data/decidim-admin/app/views/decidim/admin/participatory_process_user_roles/index.html.erb +16 -0
  36. data/decidim-admin/app/views/decidim/admin/participatory_processes/_form.html.erb +2 -14
  37. data/decidim-admin/app/views/layouts/decidim/admin/_title_bar.html.erb +26 -19
  38. data/decidim-admin/app/views/layouts/decidim/admin/participatory_process.html.erb +2 -2
  39. data/decidim-admin/bin/rails +2 -2
  40. data/decidim-admin/config/i18n-tasks.yml +2 -0
  41. data/decidim-admin/config/locales/ca.yml +9 -5
  42. data/decidim-admin/config/locales/en.yml +9 -5
  43. data/decidim-admin/config/locales/es.yml +11 -5
  44. data/decidim-admin/config/locales/eu.yml +0 -5
  45. data/decidim-admin/config/locales/fr.yml +18 -23
  46. data/decidim-admin/config/locales/it.yml +0 -5
  47. data/decidim-admin/config/routes.rb +5 -3
  48. data/decidim-admin/decidim-admin.gemspec +2 -2
  49. data/decidim-admin/lib/decidim/admin/test/manage_attachments_examples.rb +1 -2
  50. data/decidim-admin/spec/commands/create_participatory_process_admin_spec.rb +42 -26
  51. data/decidim-admin/spec/commands/create_participatory_process_spec.rb +2 -1
  52. data/decidim-admin/spec/commands/create_participatory_process_step_spec.rb +56 -0
  53. data/decidim-admin/spec/commands/destroy_participatory_process_step_spec.rb +2 -2
  54. data/decidim-admin/spec/commands/update_feature_spec.rb +6 -0
  55. data/decidim-admin/spec/controllers/participatory_processes_controller_spec.rb +3 -6
  56. data/decidim-admin/spec/features/admin_copy_participatory_process_spec.rb +9 -9
  57. data/decidim-admin/spec/features/admin_manages_features_spec.rb +32 -0
  58. data/decidim-admin/spec/features/admin_manages_participatory_processes_spec.rb +3 -4
  59. data/decidim-admin/spec/forms/static_page_form_spec.rb +12 -0
  60. data/decidim-admin/spec/jobs/newsletter_job_spec.rb +3 -0
  61. data/decidim-admin/spec/shared/manage_process_admins_examples.rb +22 -0
  62. data/decidim-admin/spec/shared/manage_processes_examples.rb +6 -0
  63. data/decidim-admin/spec/spec_helper.rb +4 -0
  64. data/decidim-api/bin/rails +2 -2
  65. data/decidim-api/decidim-api.gemspec +3 -3
  66. data/decidim-api/spec/spec_helper.rb +4 -0
  67. data/decidim-api/spec/types/query_type_spec.rb +2 -2
  68. data/decidim-budgets/app/models/decidim/budgets/project.rb +5 -0
  69. data/decidim-budgets/bin/rails +2 -2
  70. data/decidim-budgets/config/locales/fr.yml +2 -2
  71. data/decidim-budgets/decidim-budgets.gemspec +2 -2
  72. data/decidim-budgets/lib/decidim/budgets/feature.rb +1 -1
  73. data/decidim-budgets/spec/spec_helper.rb +4 -0
  74. data/decidim-comments/app/assets/javascripts/decidim/comments/bundle.js +0 -0
  75. data/decidim-comments/app/commands/decidim/comments/create_comment.rb +10 -14
  76. data/decidim-comments/app/frontend/application/application.component.tsx +1 -1
  77. data/decidim-comments/app/frontend/comments/add_comment_form.component.test.tsx +33 -26
  78. data/decidim-comments/app/frontend/comments/add_comment_form.component.tsx +109 -83
  79. data/decidim-comments/app/frontend/comments/comment.component.test.tsx +29 -24
  80. data/decidim-comments/app/frontend/comments/comment.component.tsx +12 -5
  81. data/decidim-comments/app/frontend/comments/comment_thread.component.test.tsx +12 -7
  82. data/decidim-comments/app/frontend/comments/comment_thread.component.tsx +7 -2
  83. data/decidim-comments/app/frontend/comments/comments.component.tsx +26 -15
  84. data/decidim-comments/app/frontend/comments/down_vote_button.component.test.tsx +9 -4
  85. data/decidim-comments/app/frontend/comments/down_vote_button.component.tsx +56 -37
  86. data/decidim-comments/app/frontend/comments/up_vote_button.component.test.tsx +9 -4
  87. data/decidim-comments/app/frontend/comments/up_vote_button.component.tsx +31 -16
  88. data/decidim-comments/app/frontend/comments/vote_button.component.tsx +3 -0
  89. data/decidim-comments/app/mailers/decidim/comments/comment_notification_mailer.rb +8 -6
  90. data/decidim-comments/app/models/decidim/comments/comment.rb +13 -1
  91. data/decidim-comments/app/views/decidim/comments/comment_notification_mailer/comment_created.html.erb +1 -1
  92. data/decidim-comments/app/views/decidim/comments/comment_notification_mailer/reply_created.html.erb +1 -1
  93. data/decidim-comments/bin/rails +2 -2
  94. data/decidim-comments/config/locales/ca.yml +2 -0
  95. data/decidim-comments/config/locales/en.yml +2 -0
  96. data/decidim-comments/config/locales/es.yml +2 -0
  97. data/decidim-comments/config/locales/fr.yml +2 -2
  98. data/decidim-comments/decidim-comments.gemspec +3 -3
  99. data/decidim-comments/lib/decidim/comments/commentable.rb +1 -0
  100. data/decidim-comments/spec/commands/create_comment_spec.rb +22 -54
  101. data/decidim-comments/spec/features/notifications_spec.rb +2 -6
  102. data/decidim-comments/spec/mailers/comment_notification_mailer_spec.rb +5 -4
  103. data/decidim-comments/spec/models/comment_spec.rb +32 -2
  104. data/decidim-comments/spec/shared/author_localised_email.rb +2 -3
  105. data/decidim-comments/spec/spec_helper.rb +4 -0
  106. data/decidim-dev/decidim-dev.gemspec +3 -4
  107. data/decidim-dev/lib/decidim/dev.rb +23 -1
  108. data/decidim-dev/lib/decidim/dev/common_rake.rb +3 -0
  109. data/decidim-dev/lib/decidim/dev/railtie.rb +3 -3
  110. data/decidim-dev/lib/decidim/dev/test/base_spec_helper.rb +4 -3
  111. data/decidim-dev/lib/decidim/dev/test/rspec_support/capybara.rb +3 -0
  112. data/decidim-dev/lib/decidim/dev/test/rspec_support/feature.rb +8 -0
  113. data/decidim-dev/lib/decidim/dev/test/rspec_support/feature_context.rb +4 -2
  114. data/decidim-dev/lib/decidim/dev/test/rspec_support/geocoder.rb +7 -2
  115. data/decidim-dev/lib/decidim/dev/test/rspec_support/phantomjs_polyfills/phantomjs-getOwnPropertyNames.js +16 -0
  116. data/decidim-dev/lib/decidim/dev/test/rspec_support/warden.rb +17 -1
  117. data/decidim-meetings/app/helpers/decidim/meetings/application_helper.rb +1 -0
  118. data/decidim-meetings/app/helpers/decidim/meetings/meetings_helper.rb +24 -0
  119. data/decidim-meetings/app/views/decidim/meetings/meetings/_meetings.html.erb +1 -1
  120. data/decidim-meetings/bin/rails +2 -2
  121. data/decidim-meetings/config/locales/ca.yml +1 -0
  122. data/decidim-meetings/config/locales/en.yml +2 -1
  123. data/decidim-meetings/config/locales/es.yml +1 -0
  124. data/decidim-meetings/config/locales/fr.yml +5 -5
  125. data/decidim-meetings/decidim-meetings.gemspec +2 -2
  126. data/decidim-meetings/lib/decidim/meetings/feature.rb +1 -1
  127. data/decidim-meetings/spec/features/admin_manages_meetings_attachments_spec.rb +1 -1
  128. data/decidim-meetings/spec/features/admin_manages_meetings_spec.rb +1 -1
  129. data/decidim-meetings/spec/features/explore_meetings_spec.rb +1 -1
  130. data/decidim-meetings/spec/features/process_admin_manages_meetings_attachments_spec.rb +1 -1
  131. data/decidim-meetings/spec/features/process_admin_manages_meetings_spec.rb +1 -1
  132. data/decidim-meetings/spec/helpers/meetings_helper_spec.rb +16 -0
  133. data/decidim-meetings/spec/spec_helper.rb +4 -0
  134. data/decidim-pages/app/models/decidim/pages/page.rb +5 -0
  135. data/decidim-pages/bin/rails +2 -2
  136. data/decidim-pages/decidim-pages.gemspec +2 -2
  137. data/decidim-pages/lib/decidim/pages/feature.rb +1 -1
  138. data/decidim-pages/spec/commands/destroy_page_spec.rb +1 -1
  139. data/decidim-pages/spec/spec_helper.rb +4 -0
  140. data/decidim-proposals/app/assets/config/decidim_proposals_manifest.js +1 -0
  141. data/decidim-proposals/app/assets/javascripts/decidim/proposals/add_proposal.js.es6 +23 -0
  142. data/decidim-proposals/app/forms/decidim/proposals/proposal_form.rb +7 -1
  143. data/decidim-proposals/app/models/decidim/proposals/proposal.rb +14 -2
  144. data/decidim-proposals/app/views/decidim/proposals/proposals/_proposal.html.erb +1 -0
  145. data/decidim-proposals/app/views/decidim/proposals/proposals/new.html.erb +5 -0
  146. data/decidim-proposals/bin/rails +2 -2
  147. data/decidim-proposals/config/locales/fr.yml +11 -11
  148. data/decidim-proposals/db/migrate/20170307085300_migrate_proposal_reports_data_to_reports.rb +1 -1
  149. data/decidim-proposals/decidim-proposals.gemspec +2 -2
  150. data/decidim-proposals/lib/decidim/proposals/feature.rb +1 -1
  151. data/decidim-proposals/spec/features/proposals_spec.rb +8 -2
  152. data/decidim-proposals/spec/models/decidim/proposals/proposal_spec.rb +35 -0
  153. data/decidim-proposals/spec/shared/create_proposal_examples.rb +20 -14
  154. data/decidim-proposals/spec/shared/manage_proposals_examples.rb +13 -16
  155. data/decidim-proposals/spec/shared/proposal_form_examples.rb +22 -16
  156. data/decidim-proposals/spec/spec_helper.rb +4 -0
  157. data/decidim-results/app/models/decidim/results/result.rb +10 -0
  158. data/decidim-results/bin/rails +2 -2
  159. data/decidim-results/config/locales/fr.yml +2 -2
  160. data/decidim-results/decidim-results.gemspec +2 -2
  161. data/decidim-results/lib/decidim/results/feature.rb +1 -1
  162. data/decidim-results/spec/features/comments_spec.rb +10 -0
  163. data/decidim-results/spec/spec_helper.rb +4 -0
  164. data/decidim-surveys/app/models/decidim/surveys/survey_question.rb +2 -0
  165. data/decidim-surveys/bin/rails +2 -2
  166. data/decidim-surveys/decidim-surveys.gemspec +2 -2
  167. data/decidim-surveys/lib/decidim/surveys/feature.rb +3 -2
  168. data/decidim-surveys/spec/forms/decidim/surveys/admin/survey_question_form_spec.rb +1 -1
  169. data/decidim-surveys/spec/models/decidim/surveys/survey_question_spec.rb +7 -1
  170. data/decidim-surveys/spec/spec_helper.rb +5 -0
  171. data/decidim-system/app/controllers/decidim/system/application_controller.rb +1 -1
  172. data/decidim-system/app/controllers/decidim/system/devise/sessions_controller.rb +1 -0
  173. data/decidim-system/app/helpers/decidim/system/menu_helper.rb +1 -1
  174. data/decidim-system/app/views/decidim/system/shared/_notices.html.erb +11 -0
  175. data/decidim-system/app/views/layouts/decidim/system/application.html.erb +1 -1
  176. data/decidim-system/app/views/layouts/decidim/system/login.html.erb +1 -1
  177. data/decidim-system/bin/rails +2 -2
  178. data/decidim-system/config/locales/ca.yml +4 -0
  179. data/decidim-system/config/locales/en.yml +4 -0
  180. data/decidim-system/config/locales/es.yml +4 -0
  181. data/decidim-system/db/migrate/20160919105637_devise_create_decidim_admins.rb +5 -5
  182. data/decidim-system/db/seeds.rb +1 -1
  183. data/decidim-system/decidim-system.gemspec +2 -2
  184. data/decidim-system/spec/factories.rb +2 -2
  185. data/decidim-system/spec/features/manage_admins_spec.rb +3 -3
  186. data/decidim-system/spec/spec_helper.rb +4 -0
  187. data/decidim.gemspec +6 -6
  188. data/docs/how_to_create_a_plugin.md +2 -2
  189. data/lib/generators/decidim/app_generator.rb +1 -1
  190. data/lib/generators/decidim/install_generator.rb +35 -27
  191. data/lib/generators/decidim/templates/Gemfile.erb +1 -0
  192. data/lib/generators/decidim/templates/initializer.rb +7 -1
  193. data/logo.svg +62 -0
  194. data/package.json +37 -35
  195. data/tsconfig.json +3 -0
  196. data/yarn.lock +1017 -486
  197. metadata +32 -25
  198. data/decidim-admin/app/assets/stylesheets/decidim/admin/extra/_language-chooser.scss +0 -4
@@ -7,11 +7,7 @@ describe "Comment notifications", type: :feature do
7
7
  let!(:feature) { create(:feature, manifest_name: :dummy, organization: organization) }
8
8
  let!(:user) { create(:user, :confirmed, organization: organization) }
9
9
  let!(:commentable) { create(:dummy_resource, feature: feature) }
10
- let!(:comments) do
11
- Array.new(3) do
12
- create(:comment, commentable: commentable)
13
- end
14
- end
10
+ let!(:comments) { create_list(:comment, 3, commentable: commentable) }
15
11
 
16
12
  before do
17
13
  switch_to_host(organization.host)
@@ -34,7 +30,7 @@ describe "Comment notifications", type: :feature do
34
30
 
35
31
  wait_for_email subject: "a new comment"
36
32
 
37
- login_as commentable.author, scope: :user
33
+ relogin_as commentable.author, scope: :user
38
34
 
39
35
  visit last_email_first_link
40
36
 
@@ -11,12 +11,13 @@ module Decidim
11
11
  let(:feature) { create(:feature, participatory_process: participatory_process) }
12
12
  let(:commentable_author) { create(:user, organization: organization) }
13
13
  let(:commentable) { create(:dummy_resource, author: commentable_author, feature: feature) }
14
+ let(:user) { create(:user, organization: organization) }
14
15
  let(:author) { create(:user, organization: organization) }
15
16
  let(:comment) { create(:comment, author: author, commentable: commentable) }
16
17
  let(:reply) { create(:comment, author: author, commentable: comment) }
17
18
 
18
19
  describe "comment_created" do
19
- let(:mail) { described_class.comment_created(comment, commentable) }
20
+ let(:mail) { described_class.comment_created(user, comment, commentable) }
20
21
 
21
22
  let(:subject) { "Tens un nou comentari" }
22
23
  let(:default_subject) { "You have a new comment" }
@@ -24,11 +25,11 @@ module Decidim
24
25
  let(:body) { "Hi ha un nou comentari d" }
25
26
  let(:default_body) { "There is a new comment" }
26
27
 
27
- include_examples "author localised email"
28
+ include_examples "user localised email"
28
29
  end
29
30
 
30
31
  describe "reply_created" do
31
- let(:mail) { described_class.reply_created(reply, comment, commentable) }
32
+ let(:mail) { described_class.reply_created(user, reply, comment, commentable) }
32
33
 
33
34
  let(:subject) { "Tens una nova resposta del teu comentari" }
34
35
  let(:default_subject) { "You have a new reply of your comment" }
@@ -36,7 +37,7 @@ module Decidim
36
37
  let(:body) { "Hi ha una nova resposta de" }
37
38
  let(:default_body) { "There is a new reply of your comment" }
38
39
 
39
- include_examples "author localised email"
40
+ include_examples "user localised email"
40
41
  end
41
42
  end
42
43
  end
@@ -6,8 +6,10 @@ module Decidim
6
6
  module Comments
7
7
  describe Comment do
8
8
  let!(:commentable) { create(:dummy_resource) }
9
- let!(:comment) { create(:comment, commentable: commentable) }
10
- let!(:replies) { Array.new(3) { create(:comment, commentable: comment, root_commentable: commentable) } }
9
+ let!(:replies_notifications) { true }
10
+ let!(:author) { create(:user, organization: commentable.organization, replies_notifications: replies_notifications) }
11
+ let!(:comment) { create(:comment, commentable: commentable, author: author) }
12
+ let!(:replies) { create_list(:comment, 3, commentable: comment, root_commentable: commentable) }
11
13
  let!(:up_vote) { create(:comment_vote, :up_vote, comment: comment) }
12
14
  let!(:down_vote) { create(:comment_vote, :down_vote, comment: comment) }
13
15
 
@@ -88,6 +90,34 @@ module Decidim
88
90
  expect(subject.down_voted_by?(user)).to be_falsy
89
91
  end
90
92
  end
93
+
94
+ describe "#notifiable?" do
95
+ let(:context_author) { create(:user, organization: subject.author.organization) }
96
+
97
+ context "when the context author is the same as the comment's author" do
98
+ let(:context_author) { subject.author }
99
+
100
+ it "is not notifiable" do
101
+ expect(subject.notifiable?(author: context_author)).to be_falsy
102
+ end
103
+ end
104
+
105
+ context "when the context author is not the same as the comment's author" do
106
+ context "when the comment's author has not replies notifications enabled" do
107
+ let(:replies_notifications) { false }
108
+
109
+ it "is not notifiable" do
110
+ expect(subject.notifiable?(author: context_author)).to be_falsy
111
+ end
112
+ end
113
+
114
+ context "when the comment's author has replies notifications enabled" do
115
+ it "is not notifiable" do
116
+ expect(subject.notifiable?(author: context_author)).to be_truthy
117
+ end
118
+ end
119
+ end
120
+ end
91
121
  end
92
122
  end
93
123
  end
@@ -2,9 +2,8 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- shared_examples "author localised email" do
6
- let(:author) { create(:user, locale: locale, organization: organization) }
7
- let(:commentable_author) { create(:user, locale: locale, organization: organization) }
5
+ shared_examples "user localised email" do
6
+ let(:user) { create(:user, locale: locale, organization: organization) }
8
7
 
9
8
  context "when the user has a custom locale" do
10
9
  let(:locale) { "ca" }
@@ -1,5 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "decidim/dev"
4
+
3
5
  ENV["ENGINE_NAME"] = File.dirname(__dir__).split("/").last
4
6
 
7
+ Decidim::Dev.dummy_app_path = File.expand_path(File.join("..", "spec", "decidim_dummy_app"))
8
+
5
9
  require "decidim/dev/test/base_spec_helper"
@@ -9,8 +9,8 @@ require_relative "../decidim-core/lib/decidim/core/version"
9
9
  Gem::Specification.new do |s|
10
10
  Decidim.add_default_gemspec_properties(s)
11
11
 
12
- s.name = "decidim-dev"
13
- s.summary = "Decidim Dev tools"
12
+ s.name = "decidim-dev"
13
+ s.summary = "Decidim Dev tools"
14
14
  s.description = "Utilities and tools we need to develop Decidim"
15
15
 
16
16
  s.files = Dir["{app,config,db,lib,vendor}/**/*", "Rakefile", "README.md"]
@@ -37,8 +37,7 @@ Gem::Specification.new do |s|
37
37
  s.add_dependency "codecov", "~> 0.1.9"
38
38
  s.add_dependency "rubocop", "~> 0.48.1"
39
39
  s.add_dependency "db-query-matchers", "~> 0.9.0"
40
- s.add_dependency "letter_opener_web", "~> 1.3.0"
41
40
  s.add_dependency "rspec-html-matchers", "~> 0.9.1"
42
41
  s.add_dependency "webmock", "~> 3.0.1"
43
- s.add_dependency "puma", "~> 3.8.2"
42
+ s.add_dependency "puma", "~> 3.9.1"
44
43
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "letter_opener_web"
4
3
  require "decidim/dev/railtie"
5
4
 
6
5
  module Decidim
@@ -14,5 +13,28 @@ module Decidim
14
13
  def self.asset(name)
15
14
  File.expand_path(File.join(__dir__, "dev", "assets", name))
16
15
  end
16
+
17
+ # Public: add rake tasks
18
+ def self.install_tasks
19
+ Dir[File.join(__dir__, "../tasks/*.rake")].each do |file|
20
+ load file
21
+ end
22
+ end
23
+
24
+ # Public: Sets the dummy application path for testing.
25
+ #
26
+ # path - A string value defining the path.
27
+ def self.dummy_app_path=(path)
28
+ @dummy_app_path = path
29
+ end
30
+
31
+ # Public: Get the dummy application path and raises an error if it is not set.
32
+ def self.dummy_app_path
33
+ unless @dummy_app_path
34
+ raise StandardError, "Please, add Decidim::Dev::dummy_app_path = File.expand_path(File.join(\"..\", \"spec\", \"decidim_dummy_app\")) to\n
35
+ your spec helper with the path to the generated dummy app"
36
+ end
37
+ @dummy_app_path
38
+ end
17
39
  end
18
40
  end
@@ -2,6 +2,9 @@
2
2
 
3
3
  require "bundler/gem_tasks"
4
4
  require "rspec/core/rake_task"
5
+ require "decidim/dev"
5
6
 
6
7
  RSpec::Core::RakeTask.new(:spec)
7
8
  task default: [:spec]
9
+
10
+ Decidim::Dev.install_tasks
@@ -1,14 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "rails"
4
+
3
5
  module Decidim
4
6
  module Dev
5
7
  class Railtie < Rails::Railtie
6
8
  railtie_name :decidim_dev
7
9
 
8
10
  rake_tasks do
9
- Dir[File.join(__dir__, "../../tasks/*.rake")].each do |file|
10
- load file
11
- end
11
+ Decidim::Dev.install_tasks
12
12
  end
13
13
  end
14
14
  end
@@ -1,10 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "decidim/dev"
4
+
3
5
  ENV["RAILS_ENV"] ||= "test"
4
6
 
5
7
  root_path = File.expand_path("..", Dir.pwd)
6
8
  engine_spec_dir = File.join(Dir.pwd, "spec")
7
- dummy_app_path = File.expand_path(File.join(root_path, "spec", "decidim_dummy_app"))
8
9
 
9
10
  if ENV["SIMPLECOV"]
10
11
  require "simplecov"
@@ -35,10 +36,10 @@ require "decidim/core/test"
35
36
  require "#{__dir__}/rspec_support/feature.rb"
36
37
 
37
38
  begin
38
- require "#{dummy_app_path}/config/environment"
39
+ require "#{Decidim::Dev.dummy_app_path}/config/environment"
39
40
  rescue LoadError
40
41
  puts "Could not load dummy application. Please ensure you have run `bundle exec rake decidim:generate_test_app`"
41
- puts "Tried to load it from #{dummy_app_path}"
42
+ puts "Tried to load it from #{Decidim::Dev.dummy_app_path}"
42
43
  exit(-1)
43
44
  end
44
45
 
@@ -28,6 +28,9 @@ capybara_options = {
28
28
  ),
29
29
  File.expand_path(
30
30
  File.join(__dir__, "phantomjs_polyfills", "phantomjs-shim.js")
31
+ ),
32
+ File.expand_path(
33
+ File.join(__dir__, "phantomjs_polyfills", "phantomjs-getOwnPropertyNames.js")
31
34
  )
32
35
  ],
33
36
  js_errors: true,
@@ -35,6 +35,14 @@ module Decidim
35
35
  def reported_content_url
36
36
  ResourceLocatorPresenter.new(self).url
37
37
  end
38
+
39
+ def notifiable?(_context)
40
+ true
41
+ end
42
+
43
+ def users_to_notify
44
+ [author]
45
+ end
38
46
  end
39
47
 
40
48
  class DummyResourcesController < ActionController::Base
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RSpec.shared_context "feature" do
4
+ include Decidim::FeaturePathHelper
5
+
4
6
  let(:manifest) { Decidim.find_feature_manifest(manifest_name) }
5
7
 
6
8
  let(:user) { create :user, :confirmed, organization: organization }
@@ -26,7 +28,7 @@ RSpec.shared_context "feature" do
26
28
  end
27
29
 
28
30
  def visit_feature
29
- page.visit decidim.feature_path(participatory_process, feature)
31
+ page.visit feature_path(feature)
30
32
  end
31
33
  end
32
34
 
@@ -48,7 +50,7 @@ RSpec.shared_context "feature admin" do
48
50
  end
49
51
 
50
52
  def visit_feature_admin
51
- visit decidim_admin.manage_feature_path(participatory_process, feature)
53
+ visit manage_feature_path(feature)
52
54
  end
53
55
  end
54
56
 
@@ -1,13 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  RSpec.configure do |config|
4
- config.before(:each) do
4
+ config.before(:suite) do
5
5
  # Set geocoder configuration in test mode
6
6
  Decidim.geocoder = {
7
- static_map_url: "http://www.example.org",
7
+ static_map_url: "https://www.example.org/my_static_map",
8
8
  here_app_id: "1234",
9
9
  here_app_code: "5678"
10
10
  }
11
11
  Geocoder.configure(lookup: :test)
12
12
  end
13
+
14
+ config.before(:each, :serves_map) do
15
+ stub_request(:get, %r{https://www\.example\.org/my_static_map})
16
+ .to_return(body: "map_data")
17
+ end
13
18
  end
@@ -0,0 +1,16 @@
1
+ var hasOwnProperty = Object.hasOwnProperty
2
+ var originalGetOwnPropertyNames = Object.getOwnPropertyNames
3
+ function getOwnPropertyNames (obj) {
4
+ var result = originalGetOwnPropertyNames.call(this, obj)
5
+ if (typeof obj !== 'function' || hasOwnProperty.call(obj, 'callee')) {
6
+ return result
7
+ }
8
+ return result.filter(function filterCallee (name) {
9
+ return name !== 'callee' && name !== 'arguments' && name !== 'caller';
10
+ })
11
+ };
12
+ Object.defineProperty(Object, 'getOwnPropertyNames', {
13
+ value: getOwnPropertyNames,
14
+ configurable: true,
15
+ writable: true
16
+ })
@@ -1,7 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ module Decidim
4
+ module WardenTestHelpers
5
+ include Warden::Test::Helpers
6
+
7
+ #
8
+ # Utility method to login in the middle of a test as a different user from
9
+ # the current one.
10
+ #
11
+ def relogin_as(user, scope: :user)
12
+ logout scope
13
+
14
+ login_as user, scope: scope
15
+ end
16
+ end
17
+ end
18
+
3
19
  RSpec.configure do |config|
4
- config.include Warden::Test::Helpers, type: :feature
20
+ config.include Decidim::WardenTestHelpers, type: :feature
5
21
  config.include Devise::Test::ControllerHelpers, type: :controller
6
22
 
7
23
  config.after :each, type: :feature do
@@ -8,6 +8,7 @@ module Decidim
8
8
  include PaginateHelper
9
9
  include Decidim::MapHelper
10
10
  include Decidim::Meetings::MapHelper
11
+ include Decidim::Meetings::MeetingsHelper
11
12
  end
12
13
  end
13
14
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Meetings
5
+ # Custom helpers used in meetings views
6
+ module MeetingsHelper
7
+ include Decidim::ApplicationHelper
8
+ include Decidim::TranslationsHelper
9
+
10
+ # Public: truncates the meeting description
11
+ #
12
+ # meeting - a Decidim::Meeting instance
13
+ # max_length - a number to limit the length of the description
14
+ #
15
+ # Returns the meeting's description truncated.
16
+ 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
+ description = translated_attribute(meeting.description)
19
+ tail = "... #{link_to(t("read_more", scope: "decidim.meetings"), link)}".html_safe
20
+ CGI.unescapeHTML html_truncate(description, max_length: max_length, tail: tail)
21
+ end
22
+ end
23
+ end
24
+ end
@@ -17,7 +17,7 @@
17
17
  <h5 class="card__title"><%= translated_attribute meeting.title %></h5>
18
18
  <% end %>
19
19
  <%= render partial: "datetime", locals: { meeting: meeting } %>
20
- <%== translated_attribute meeting.description %>
20
+ <%== meeting_description(meeting) %>
21
21
  <%= render partial: "tags", locals: { meeting: meeting } %>
22
22
  <div class="address card__extra">
23
23
  <div class="address__icon">
@@ -8,8 +8,8 @@ ENGINE_ROOT = File.expand_path("..", __dir__)
8
8
  ENGINE_PATH = File.expand_path("../lib/decidim/meetings/engine", __dir__)
9
9
 
10
10
  # Set up gems listed in the Gemfile.
11
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
- require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"])
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __dir__)
12
+ require "bundler/setup"
13
13
 
14
14
  require "rails/all"
15
15
  require "rails/engine/commands"
@@ -90,6 +90,7 @@ ca:
90
90
  map: Mapa
91
91
  start_time: Data d'inici
92
92
  title: Títol
93
+ read_more: "(Llegeix més)"
93
94
  resource_links:
94
95
  meetings_through_proposals:
95
96
  meeting_results: 'Resultats relacionats:'
@@ -51,7 +51,7 @@ en:
51
51
  index:
52
52
  title: Meetings
53
53
  new:
54
- create: Create
54
+ create: Create
55
55
  title: Create meeting
56
56
  update:
57
57
  invalid: There's been a problem updating this meeting
@@ -93,6 +93,7 @@ en:
93
93
  map: Map
94
94
  start_time: Start date
95
95
  title: Title
96
+ read_more: "(read more)"
96
97
  resource_links:
97
98
  meetings_through_proposals:
98
99
  meeting_results: 'Related results:'