decidim-dev 0.27.7 → 0.28.0.rc4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/app/commands/decidim/dummy_resources/create_dummy_resource.rb +0 -1
  3. data/app/events/decidim/dummy_resources/dummy_resource_event.rb +10 -0
  4. data/app/jobs/decidim/dummy_resources/hide_all_created_by_author_job.rb +13 -0
  5. data/app/models/decidim/dummy_resources/application_record.rb +9 -0
  6. data/app/models/decidim/dummy_resources/coauthorable_dummy_resource.rb +10 -0
  7. data/app/models/decidim/dummy_resources/dummy_resource.rb +93 -0
  8. data/app/models/decidim/dummy_resources/nested_dummy_resource.rb +10 -0
  9. data/app/packs/src/decidim/dev/accessibility.js +3 -3
  10. data/app/packs/src/decidim/dev/test/custom_map_factory.js +1 -1
  11. data/app/packs/stylesheets/decidim/dev/_accessibility.scss +24 -24
  12. data/app/packs/stylesheets/decidim/dev/_map.scss +10 -0
  13. data/app/packs/stylesheets/decidim/dev.scss +1 -0
  14. data/app/presenters/decidim/dummy_resources/official_author_presenter.rb +33 -0
  15. data/app/serializers/decidim/dummy_resources/dummy_serializer.rb +21 -0
  16. data/app/views/decidim/dummy_resources/dummy_resources/show.html.erb +22 -12
  17. data/config/locales/ar.yml +0 -1
  18. data/config/locales/bg.yml +0 -9
  19. data/config/locales/de.yml +1 -1
  20. data/config/locales/el.yml +0 -1
  21. data/config/locales/en.yml +1 -1
  22. data/config/locales/es-MX.yml +1 -1
  23. data/config/locales/es-PY.yml +1 -1
  24. data/config/locales/eu.yml +3 -3
  25. data/config/locales/gl.yml +0 -1
  26. data/config/locales/hu.yml +2 -3
  27. data/config/locales/id-ID.yml +0 -1
  28. data/config/locales/it.yml +0 -1
  29. data/config/locales/lv.yml +0 -1
  30. data/config/locales/nl.yml +0 -1
  31. data/config/locales/no.yml +0 -1
  32. data/config/locales/pl.yml +0 -9
  33. data/config/locales/pt-BR.yml +0 -9
  34. data/config/locales/pt.yml +0 -1
  35. data/config/locales/ru.yml +0 -1
  36. data/config/locales/sk.yml +0 -1
  37. data/config/locales/sv.yml +0 -1
  38. data/config/locales/tr-TR.yml +0 -1
  39. data/config/locales/zh-CN.yml +0 -1
  40. data/config/rubocop/disabled.yml +11 -0
  41. data/config/rubocop/faker.yml +480 -0
  42. data/config/rubocop/rails.yml +105 -0
  43. data/config/rubocop/rspec.yml +69 -0
  44. data/config/rubocop/ruby.yml +1207 -0
  45. data/lib/decidim/dev/assets/import_participatory_space_private_users.csv +2 -2
  46. data/lib/decidim/dev/assets/import_participatory_space_private_users_invalid_col_sep.csv +2 -0
  47. data/lib/decidim/dev/assets/import_participatory_space_private_users_nok.csv +2 -2
  48. data/lib/decidim/dev/assets/import_participatory_space_private_users_with_bom.csv +1 -1
  49. data/lib/decidim/dev/assets/iso-8859-15.md +1 -1
  50. data/lib/decidim/dev/assets/participatory_text.md +4 -2
  51. data/lib/decidim/dev/assets/verify_user_groups.csv +22 -22
  52. data/lib/decidim/dev/engine.rb +4 -3
  53. data/lib/decidim/dev/test/factories.rb +3 -5
  54. data/lib/decidim/dev/test/form_to_param_shared_examples.rb +1 -1
  55. data/lib/decidim/dev/test/promoted_participatory_processes_shared_examples.rb +9 -9
  56. data/lib/decidim/dev/test/rspec_support/accessibility_examples.rb +119 -1
  57. data/lib/decidim/dev/test/rspec_support/attachment_helpers.rb +2 -2
  58. data/lib/decidim/dev/test/rspec_support/bullet.rb +32 -0
  59. data/lib/decidim/dev/test/rspec_support/capybara.rb +26 -25
  60. data/lib/decidim/dev/test/rspec_support/cell_matchers.rb +1 -1
  61. data/lib/decidim/dev/test/rspec_support/component.rb +1 -311
  62. data/lib/decidim/dev/test/rspec_support/component_context.rb +10 -10
  63. data/lib/decidim/dev/test/rspec_support/confirmation_helpers.rb +18 -14
  64. data/lib/decidim/dev/test/rspec_support/data_consent.rb +2 -2
  65. data/lib/decidim/dev/test/rspec_support/dynamic_attach.rb +19 -4
  66. data/lib/decidim/dev/test/rspec_support/editor_context.rb +35 -0
  67. data/lib/decidim/dev/test/rspec_support/engine_examples.rb +15 -0
  68. data/lib/decidim/dev/test/rspec_support/filters.rb +11 -0
  69. data/lib/decidim/dev/test/rspec_support/forms_validations.rb +20 -0
  70. data/lib/decidim/dev/test/rspec_support/geocoder.rb +3 -3
  71. data/lib/decidim/dev/test/rspec_support/helpers.rb +187 -34
  72. data/lib/decidim/dev/test/rspec_support/imports_controller_shared_examples.rb +11 -11
  73. data/lib/decidim/dev/test/rspec_support/tom_select.rb +26 -0
  74. data/lib/decidim/dev/test/rspec_support/translation_helpers.rb +8 -8
  75. data/lib/decidim/dev/test/rspec_support/warden.rb +1 -1
  76. data/lib/decidim/dev/test/rspec_support/webmock.rb +1 -1
  77. data/lib/decidim/dev/test/rspec_support/webpacker.rb +4 -22
  78. data/lib/decidim/dev/test/spec_helper.rb +14 -3
  79. data/lib/decidim/dev/test/w3c_rspec_validators_overrides.rb +1 -5
  80. data/lib/decidim/dev/version.rb +1 -1
  81. data/lib/decidim/dev.rb +9 -0
  82. data/lib/decidim/dummy_resources/admin.rb +8 -0
  83. data/lib/decidim/dummy_resources/admin_engine.rb +43 -0
  84. data/lib/decidim/dummy_resources/component.rb +94 -0
  85. data/lib/decidim/dummy_resources/engine.rb +28 -0
  86. data/lib/decidim/dummy_resources.rb +20 -0
  87. data/lib/tasks/lighthouse_report.rake +29 -7
  88. data/rubocop-decidim.yml +13 -0
  89. metadata +119 -81
  90. data/config/locales/he-IL.yml +0 -1
  91. data/decidim-dev.gemspec +0 -57
  92. data/lib/decidim/dev/test/rspec_support/capybara_data_picker.rb +0 -36
  93. data/lib/decidim/dev/test/rspec_support/capybara_scopes_picker.rb +0 -92
  94. data/lib/decidim/dev/test/rspec_support/concurrency.rb +0 -23
  95. data/lib/decidim/dev/test/rspec_support/decidim_sanitization.rb +0 -5
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ Decidim.register_component(:dummy) do |component|
4
+ component.engine = Decidim::DummyResources::DummyEngine
5
+ component.admin_engine = Decidim::DummyResources::AdminEngine
6
+ component.icon = "media/images/decidim_dev_dummy.svg"
7
+
8
+ component.actions = %w(foo bar)
9
+
10
+ component.newsletter_participant_entities = ["Decidim::DummyResources::DummyResource"]
11
+
12
+ component.settings(:global) do |settings|
13
+ settings.attribute :scopes_enabled, type: :boolean, default: false
14
+ settings.attribute :scope_id, type: :scope
15
+ settings.attribute :comments_enabled, type: :boolean, default: true
16
+ settings.attribute :comments_max_length, type: :integer, required: false
17
+ settings.attribute :resources_permissions_enabled, type: :boolean, default: true
18
+ settings.attribute :dummy_global_attribute1, type: :boolean
19
+ settings.attribute :dummy_global_attribute2, type: :boolean, readonly: ->(_context) { false }
20
+ settings.attribute :readonly_attribute, type: :boolean, default: true, readonly: ->(_context) { true }
21
+ settings.attribute :enable_pads_creation, type: :boolean, default: false
22
+ settings.attribute :amendments_enabled, type: :boolean, default: false
23
+ settings.attribute :dummy_global_translatable_text, type: :text, translated: true, editor: true, required: true
24
+ end
25
+
26
+ component.settings(:step) do |settings|
27
+ settings.attribute :comments_blocked, type: :boolean, default: false
28
+ settings.attribute :dummy_step_attribute1, type: :boolean
29
+ settings.attribute :dummy_step_attribute2, type: :boolean, readonly: ->(_context) { false }
30
+ settings.attribute :dummy_step_translatable_text, type: :text, translated: true, editor: true, required: true
31
+ settings.attribute :readonly_step_attribute, type: :boolean, default: true, readonly: ->(_context) { true }
32
+ settings.attribute :amendment_creation_enabled, type: :boolean, default: true
33
+ settings.attribute :amendment_reaction_enabled, type: :boolean, default: true
34
+ settings.attribute :amendment_promotion_enabled, type: :boolean, default: true
35
+ settings.attribute :amendments_visibility, type: :string, default: "all"
36
+ settings.attribute :endorsements_enabled, type: :boolean, default: false
37
+ settings.attribute :endorsements_blocked, type: :boolean, default: false
38
+ end
39
+
40
+ component.register_resource(:dummy_resource) do |resource|
41
+ resource.name = :dummy
42
+ resource.model_class_name = "Decidim::DummyResources::DummyResource"
43
+ resource.template = "decidim/dummy_resource/linked_dummys"
44
+ resource.actions = %w(foo)
45
+ resource.searchable = true
46
+ end
47
+
48
+ component.register_resource(:nested_dummy_resource) do |resource|
49
+ resource.name = :nested_dummy
50
+ resource.model_class_name = "Decidim::DummyResources::NestedDummyResource"
51
+ end
52
+
53
+ component.register_resource(:coauthorable_dummy_resource) do |resource|
54
+ resource.name = :coauthorable_dummy
55
+ resource.model_class_name = "Decidim::DummyResources::CoauthorableDummyResource"
56
+ resource.template = "decidim/coauthorabledummy_resource/linked_dummys"
57
+ resource.actions = %w(foo-coauthorable)
58
+ resource.searchable = false
59
+ end
60
+
61
+ component.register_stat :dummies_count_high, primary: true, priority: Decidim::StatsRegistry::HIGH_PRIORITY do |components, _start_at, _end_at|
62
+ components.count * 10
63
+ end
64
+
65
+ component.register_stat :dummies_count_medium, primary: true, priority: Decidim::StatsRegistry::MEDIUM_PRIORITY do |components, _start_at, _end_at|
66
+ components.count * 100
67
+ end
68
+
69
+ component.exports :dummies do |exports|
70
+ exports.collection do
71
+ [1, 2, 3]
72
+ end
73
+
74
+ exports.serializer Decidim::DummyResources::DummySerializer
75
+ end
76
+
77
+ component.imports :dummies do |imports|
78
+ imports.messages do |msg|
79
+ msg.set(:resource_name) { |count: 1| count == 1 ? "Dummy" : "Dummies" }
80
+ msg.set(:title) { "Import dummies" }
81
+ msg.set(:label) { "Import dummies from a file" }
82
+ end
83
+
84
+ imports.creator DummyCreator
85
+ imports.example do |import_component|
86
+ locales = import_component.organization.available_locales
87
+ translated = ->(name) { locales.map { |l| "#{name}/#{l}" } }
88
+ [
89
+ translated.call("title") + %w(body) + translated.call("translatable_text") + %w(address latitude longitude),
90
+ locales.map { "Title text" } + ["Body text"] + locales.map { "Translatable text" } + ["Fake street 1", 1.0, 1.0]
91
+ ]
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module DummyResources
5
+ # Dummy engine to be able to test components.
6
+ class DummyEngine < Rails::Engine
7
+ engine_name "dummy"
8
+ isolate_namespace Decidim::DummyResources
9
+
10
+ routes do
11
+ root to: proc { [200, {}, ["DUMMY ENGINE"]] }
12
+
13
+ resources :dummy_resources do
14
+ resources :nested_dummy_resources
15
+ get :foo, on: :member
16
+ end
17
+ end
18
+
19
+ initializer "dummy.moderation_content" do
20
+ config.to_prepare do
21
+ ActiveSupport::Notifications.subscribe("decidim.admin.block_user:after") do |_event_name, data|
22
+ Decidim::DummyResources::HideAllCreatedByAuthorJob.perform_later(**data)
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/dummy_resources/admin"
4
+ require "decidim/dummy_resources/engine"
5
+ require "decidim/dummy_resources/admin_engine"
6
+ require "decidim/dummy_resources/component"
7
+
8
+ module Decidim
9
+ module DummyResources
10
+ include ActiveSupport::Configurable
11
+
12
+ # Settings needed to compare emendations in Decidim::SimilarEmendations
13
+ config_accessor :similarity_threshold do
14
+ 0.25
15
+ end
16
+ config_accessor :similarity_limit do
17
+ 10
18
+ end
19
+ end
20
+ end
@@ -13,17 +13,39 @@ namespace :decidim do
13
13
  # Because seeds make urls dynamic, this task updates the lighthouse configuration
14
14
  # to add dynamically the urls to check.
15
15
 
16
- host = "http://localhost:3000"
17
- urls = ["/"]
18
- urls << ::Decidim::ResourceLocatorPresenter.new(Decidim::ParticipatoryProcess.published.first).path
19
- urls << ::Decidim::ResourceLocatorPresenter.new(Decidim::Meetings::Meeting.published.not_hidden.first).path
20
- urls << ::Decidim::ResourceLocatorPresenter.new(Decidim::Proposals::Proposal.published.not_hidden.first).path
21
-
22
16
  # Update lighthouse configuration with the urls
23
17
  lighthouse_rc_path = Rails.root.join("../.lighthouserc.json")
24
18
  lighthouserc = JSON.parse(File.read(lighthouse_rc_path))
25
- lighthouserc["ci"]["collect"]["url"] = urls.map { |url| "#{host}#{url}" }
19
+ lighthouserc["ci"]["collect"]["url"] = lighthouse_urls
26
20
  File.write(lighthouse_rc_path, lighthouserc.to_json)
27
21
  end
22
+
23
+ desc "Warms up the URLs to be requested"
24
+ task warmup: :environment do
25
+ lighthouse_urls.each do |url|
26
+ uri = URI.parse(url)
27
+ connection = Net::HTTP.new(uri.host, uri.port)
28
+ connection.start do |http|
29
+ puts "Warming up #{uri.path}"
30
+ response = http.get(uri.path)
31
+ puts "--HTTP STATUS: #{response.code}"
32
+ end
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def lighthouse_urls
39
+ host = "http://localhost:3000"
40
+ lighthouse_paths.map { |path| "#{host}#{path}" }
41
+ end
42
+
43
+ def lighthouse_paths
44
+ ["/"].tap do |urls|
45
+ urls << Decidim::ResourceLocatorPresenter.new(Decidim::ParticipatoryProcess.published.first).path
46
+ urls << Decidim::ResourceLocatorPresenter.new(Decidim::Meetings::Meeting.published.first).path
47
+ urls << Decidim::ResourceLocatorPresenter.new(Decidim::Proposals::Proposal.published.first).path
48
+ end
49
+ end
28
50
  end
29
51
  end
@@ -0,0 +1,13 @@
1
+ # Note that this file's name cannot start with `.rubocop` (with the leading dot)
2
+ # because it is used externally by loading it through `inherit_gem` and that
3
+ # naming would cause the exclude/include rules to break.
4
+ #
5
+ # For further details, see:
6
+ # https://github.com/rubocop/rubocop/issues/4154#issuecomment-316004878
7
+
8
+ inherit_from:
9
+ - config/rubocop/ruby.yml
10
+ - config/rubocop/rails.yml
11
+ - config/rubocop/rspec.yml
12
+ - config/rubocop/faker.yml
13
+ - config/rubocop/disabled.yml