decidim-dev 0.27.3 → 0.27.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4adab1ecdbf7a4a0c6f468454cf32adcf66fac1206adca9758f3a08d12c0dee2
4
- data.tar.gz: 2a24af5908cb4003fe8d8fc974d2a79f9c3fd941e5bf6e692478a3d451d5f57c
3
+ metadata.gz: a8418d7ae6e85aa4a658a0c52d2e39954b7b8dec097c38b8f071fa4d51b21fa3
4
+ data.tar.gz: 96bfc08644fb6a5ab4d34eb6d37e222da103d3fb46ed0668acc321b545009ebc
5
5
  SHA512:
6
- metadata.gz: efaaff6ec51fe371673691569f4a8560dc34635c8101576a717770a342e7da3ad56c675a6ee7494ee21336d70e78a7c66b87fbcb19de1000fe77246867d71d79
7
- data.tar.gz: 0f2b37342a8b765a9c7c58161dea1ea64542ba8026873095873b777468c413cc625368c33937070ec68840e98286ffa4d7812b1f89cf1dc9338af685a18d68f2
6
+ metadata.gz: 240c26feb4ade240648b8ffb1b180d8d1011e994b82da1f470b7a272ca10cfd27627e2d8a5b5927a87f0bcdee2582089b75b8f0cf760aeb257028e2f7e3cc477
7
+ data.tar.gz: 80e4c51e2e7bbab875f8c39fad8648e4bda54252f5f0045e3eeb297ab1713b2a529f9a76ca83c706297a596797dbb68c17052bd120482c21052d5e7ce9a09b8e
@@ -0,0 +1 @@
1
+ import "src/decidim/dev/test/custom_map_factory";
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Example of a custom map controller and how to override the
3
+ * `createMapController` factory method. To use it in the ERB view, add the
4
+ * following snippet to any view:
5
+ *
6
+ * <%= dynamic_map_for type: "custom", markers: [{ title: "Test 1", latitude: 41.385063, longitude: 2.173404 }], popup_template_id: "custom-popup" do %>
7
+ * <% javascript_pack_tag("decidim_dev_test_custom_map") %>
8
+ * <template id="custom-popup">
9
+ * <div>
10
+ * <h3>${title}</h3>
11
+ * </div>
12
+ * </template>
13
+ * <% end %>
14
+ */
15
+
16
+ import MapMarkersController from "src/decidim/map/controller/markers";
17
+
18
+ const appendToBody = (content) => {
19
+ const p = document.createElement("p");
20
+ p.innerHTML = content;
21
+ document.body.appendChild(p);
22
+ }
23
+
24
+ class CustomMapController extends MapMarkersController {
25
+ start() {
26
+ this.markerClusters = null;
27
+ this.addMarkers(this.config.markers);
28
+
29
+ appendToBody("Custom map started");
30
+ }
31
+ }
32
+
33
+ const origCreateMapController = window.Decidim.createMapController;
34
+
35
+ const createMapController = (mapId, config) => {
36
+ if (config.type === "custom") {
37
+ return new CustomMapController(mapId, config);
38
+ }
39
+
40
+ return origCreateMapController(mapId, config);
41
+ }
42
+
43
+ window.Decidim.createMapController = createMapController;
44
+
45
+ // Prevent external requests to the Here URLs during tests
46
+ if (L.TileLayer.HERE) {
47
+ L.TileLayer.HERE.prototype.onAdd = function(map) {};
48
+ }
49
+
50
+ // Test that the map events are working correctly
51
+ $("[data-decidim-map]").on("ready.decidim", (ev, _map, mapConfig) => {
52
+ appendToBody("Custom map ready");
53
+ });
54
+
55
+ appendToBody("LOADED");
data/config/assets.rb CHANGED
@@ -4,5 +4,6 @@ base_path = File.expand_path("..", __dir__)
4
4
 
5
5
  Decidim::Webpacker.register_path("#{base_path}/app/packs")
6
6
  Decidim::Webpacker.register_entrypoints(
7
- decidim_dev: "#{base_path}/app/packs/entrypoints/decidim_dev.js"
7
+ decidim_dev: "#{base_path}/app/packs/entrypoints/decidim_dev.js",
8
+ decidim_dev_test_custom_map: "#{base_path}/app/packs/entrypoints/decidim_dev_test_custom_map.js"
8
9
  )
File without changes
@@ -15,6 +15,12 @@ de:
15
15
  dummy:
16
16
  settings:
17
17
  global:
18
+ guided: Geführte Eingabe
19
+ guided_help: Hilfetext
20
+ guided_readonly: Deaktivierte Eingabe
21
+ guided_rich: Geführte reiche Eingabe
22
+ guided_rich_help_html: HTML <strong>Hilfe</strong> Text
23
+ guided_rich_readonly_html: HTML <strong>Hilfe</strong> Text für deaktivierte Eingabe
18
24
  readonly_attribute: Attribut schreibgeschützt
19
25
  test: Test A
20
26
  test_choices:
@@ -23,6 +29,7 @@ de:
23
29
  c: Wahl C
24
30
  test_options:
25
31
  bar: Bar
32
+ baz: Baz
26
33
  foo: Foo
27
34
  step:
28
35
  endorsements_blocked: Befürwortungen blockiert
@@ -30,6 +37,7 @@ de:
30
37
  readonly_step_attribute: Schritt-Attribut schreibgeschützt
31
38
  test_options:
32
39
  bar: Bar
40
+ baz: Baz
33
41
  foo: Foo
34
42
  dummy:
35
43
  admin:
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RSpec::Core
4
+ module Notifications
5
+ class SummaryNotification
6
+ # Override the original method to add the full path to the spec file and the correct rspec command to rerun the failed spec
7
+ # The goal is to be able to copy-paste the command to rerun the failed spec without having to manually add the full path to the spec file
8
+ #
9
+ # So, instead of:
10
+ # > rspec ./spec/system/registration_spec.rb:27
11
+ #
12
+ # We get:
13
+ # > bin/rspec ./decidim-core/spec/system/registration_spec.rb:27
14
+ #
15
+ # Original code in rspec-core: https://github.com/rspec/rspec-core/blob/8caecca0b9b299ccbaa5c7ea5dd885ab42cd57d3/lib/rspec/core/notifications.rb#L365
16
+ def colorized_rerun_commands(colorizer=::RSpec::Core::Formatters::ConsoleCodes)
17
+ rspec_command = running_with_rspec_wrapper? ? "bin/rspec" : "rspec"
18
+ "\nFailed examples:\n\n" +
19
+ failed_examples.map do |example|
20
+ colorizer.wrap("#{rspec_command} #{rerun_argument_for(example)}", RSpec.configuration.failure_color) + " " +
21
+ colorizer.wrap("# #{example.full_description}", RSpec.configuration.detail_color)
22
+ end.join("\n")
23
+ end
24
+
25
+ private
26
+
27
+ def running_with_rspec_wrapper?
28
+ $0 == "bin/rspec"
29
+ end
30
+
31
+ def rerun_argument_for(example)
32
+ if running_with_rspec_wrapper?
33
+ location = location_rerun_argument_for_decidim(example)
34
+ else
35
+ location = example.location_rerun_argument
36
+ end
37
+ return location unless duplicate_rerun_locations.include?(location)
38
+
39
+ conditionally_quote(example.id)
40
+ end
41
+
42
+ def location_rerun_argument_for_decidim(example)
43
+ absolute_file_path = example.metadata[:absolute_file_path]
44
+ file_path = example.metadata[:file_path][1..-1]
45
+ module_dir = absolute_file_path.gsub(file_path, "").split("/")[-1]
46
+
47
+ "./#{module_dir}#{file_path}:#{example.metadata[:line_number]}"
48
+ end
49
+ end
50
+ end
51
+ end
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-dev version.
5
5
  module Dev
6
6
  def self.version
7
- "0.27.3"
7
+ "0.27.4"
8
8
  end
9
9
  end
10
10
  end
@@ -0,0 +1,175 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Originally copied from https://github.com/koic/rubocop/blob/master/lib/rubocop/cop/mixin/hash_shorthand_syntax.rb
5
+ # Copyright (c) 2012-22 Bozhidar Batsov
6
+ # MIT License
7
+ #
8
+
9
+ module RuboCop
10
+ module Cop
11
+ # This module checks for Ruby 3.1's hash value omission syntax.
12
+ #
13
+ # For using this on Decidim, we have added the Decidim namespace and also the Backports prefix
14
+ # to the module name
15
+ module Decidim
16
+ module HashShorthandSyntaxBackports
17
+ OMIT_HASH_VALUE_MSG = "Omit the hash value."
18
+ EXPLICIT_HASH_VALUE_MSG = "Include the hash value."
19
+ DO_NOT_MIX_MSG_PREFIX = "Do not mix explicit and implicit hash values."
20
+ DO_NOT_MIX_OMIT_VALUE_MSG = "#{DO_NOT_MIX_MSG_PREFIX} #{OMIT_HASH_VALUE_MSG}".freeze
21
+ DO_NOT_MIX_EXPLICIT_VALUE_MSG = "#{DO_NOT_MIX_MSG_PREFIX} #{EXPLICIT_HASH_VALUE_MSG}".freeze
22
+
23
+ def on_hash_for_mixed_shorthand(hash_node)
24
+ return if ignore_mixed_hash_shorthand_syntax?(hash_node)
25
+
26
+ hash_value_type_breakdown = breakdown_value_types_of_hash(hash_node)
27
+
28
+ if hash_with_mixed_shorthand_syntax?(hash_value_type_breakdown)
29
+ mixed_shorthand_syntax_check(hash_value_type_breakdown)
30
+ else
31
+ no_mixed_shorthand_syntax_check(hash_value_type_breakdown)
32
+ end
33
+ end
34
+
35
+ def on_pair(node)
36
+ return if ignore_hash_shorthand_syntax?(node)
37
+
38
+ hash_key_source = node.key.source
39
+
40
+ if enforced_shorthand_syntax == "always"
41
+ return if node.value_omission? || require_hash_value?(hash_key_source, node)
42
+
43
+ message = OMIT_HASH_VALUE_MSG
44
+ replacement = "#{hash_key_source}:"
45
+ self.config_to_allow_offenses = { "Enabled" => false }
46
+ else
47
+ return unless node.value_omission?
48
+
49
+ message = EXPLICIT_HASH_VALUE_MSG
50
+ replacement = "#{hash_key_source}: #{hash_key_source}"
51
+ end
52
+
53
+ register_offense(node, message, replacement)
54
+ end
55
+
56
+ private
57
+
58
+ def register_offense(node, message, replacement)
59
+ add_offense(node.value, message:) do |corrector|
60
+ corrector.replace(node, replacement)
61
+ end
62
+ end
63
+
64
+ def ignore_mixed_hash_shorthand_syntax?(hash_node)
65
+ target_ruby_version <= 3.0 || enforced_shorthand_syntax != "consistent" ||
66
+ !hash_node.hash_type?
67
+ end
68
+
69
+ def ignore_hash_shorthand_syntax?(pair_node)
70
+ target_ruby_version <= 3.0 || enforced_shorthand_syntax == "either" ||
71
+ enforced_shorthand_syntax == "consistent" ||
72
+ !pair_node.parent.hash_type?
73
+ end
74
+
75
+ def enforced_shorthand_syntax
76
+ cop_config.fetch("EnforcedShorthandSyntax", "always")
77
+ end
78
+
79
+ def require_hash_value?(hash_key_source, node)
80
+ return true if !node.key.sym_type? || require_hash_value_for_around_hash_literal?(node)
81
+
82
+ hash_value = node.value
83
+ return true unless hash_value.send_type? || hash_value.lvar_type?
84
+
85
+ hash_key_source != hash_value.source || hash_key_source.end_with?("!", "?")
86
+ end
87
+
88
+ def require_hash_value_for_around_hash_literal?(node)
89
+ return false unless (ancestor = node.parent.parent)
90
+ return false if ancestor.send_type? && ancestor.method?(:[])
91
+
92
+ !node.parent.braces? && !use_element_of_hash_literal_as_receiver?(ancestor, node.parent) &&
93
+ (use_modifier_form_without_parenthesized_method_call?(ancestor) ||
94
+ without_parentheses_call_expr_follows?(ancestor))
95
+ end
96
+
97
+ def use_element_of_hash_literal_as_receiver?(ancestor, parent)
98
+ # `{value:}.do_something` is a valid syntax.
99
+ ancestor.send_type? && ancestor.receiver == parent
100
+ end
101
+
102
+ def use_modifier_form_without_parenthesized_method_call?(ancestor)
103
+ return false if ancestor.respond_to?(:parenthesized?) && ancestor.parenthesized?
104
+
105
+ ancestor.ancestors.any? { |node| node.respond_to?(:modifier_form?) && node.modifier_form? }
106
+ end
107
+
108
+ def without_parentheses_call_expr_follows?(ancestor)
109
+ return false unless ancestor.respond_to?(:parenthesized?) && !ancestor.parenthesized?
110
+
111
+ right_sibling = ancestor.right_sibling
112
+ right_sibling ||= ancestor.each_ancestor.find do |node|
113
+ node.assignment? || node.send_type?
114
+ end&.right_sibling
115
+
116
+ !!right_sibling
117
+ end
118
+
119
+ def breakdown_value_types_of_hash(hash_node)
120
+ hash_node.pairs.group_by do |pair_node|
121
+ if pair_node.value_omission?
122
+ :value_omitted
123
+ elsif require_hash_value?(pair_node.key.source, pair_node)
124
+ :value_needed
125
+ else
126
+ :value_omittable
127
+ end
128
+ end
129
+ end
130
+
131
+ def hash_with_mixed_shorthand_syntax?(hash_value_type_breakdown)
132
+ hash_value_type_breakdown.keys.size > 1
133
+ end
134
+
135
+ def hash_with_values_that_cant_be_omitted?(hash_value_type_breakdown)
136
+ hash_value_type_breakdown[:value_needed]&.any?
137
+ end
138
+
139
+ def each_omitted_value_pair(hash_value_type_breakdown, &)
140
+ hash_value_type_breakdown[:value_omitted]&.each(&)
141
+ end
142
+
143
+ def each_omittable_value_pair(hash_value_type_breakdown, &)
144
+ hash_value_type_breakdown[:value_omittable]&.each(&)
145
+ end
146
+
147
+ def mixed_shorthand_syntax_check(hash_value_type_breakdown)
148
+ if hash_with_values_that_cant_be_omitted?(hash_value_type_breakdown)
149
+ each_omitted_value_pair(hash_value_type_breakdown) do |pair_node|
150
+ hash_key_source = pair_node.key.source
151
+ replacement = "#{hash_key_source}: #{hash_key_source}"
152
+ register_offense(pair_node, DO_NOT_MIX_EXPLICIT_VALUE_MSG, replacement)
153
+ end
154
+ else
155
+ each_omittable_value_pair(hash_value_type_breakdown) do |pair_node|
156
+ hash_key_source = pair_node.key.source
157
+ replacement = "#{hash_key_source}:"
158
+ register_offense(pair_node, DO_NOT_MIX_OMIT_VALUE_MSG, replacement)
159
+ end
160
+ end
161
+ end
162
+
163
+ def no_mixed_shorthand_syntax_check(hash_value_type_breakdown)
164
+ return if hash_with_values_that_cant_be_omitted?(hash_value_type_breakdown)
165
+
166
+ each_omittable_value_pair(hash_value_type_breakdown) do |pair_node|
167
+ hash_key_source = pair_node.key.source
168
+ replacement = "#{hash_key_source}:"
169
+ register_offense(pair_node, OMIT_HASH_VALUE_MSG, replacement)
170
+ end
171
+ end
172
+ end
173
+ end
174
+ end
175
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rubocop
4
+ module Cop
5
+ class Decidim < Base
6
+ include HashShortandSyntaxBacports
7
+ end
8
+ end
9
+ end
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-dev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.27.3
4
+ version: 0.27.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
8
8
  - Marc Riera Casals
9
9
  - Oriol Gual Oliva
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-05-11 00:00:00.000000000 Z
13
+ date: 2023-07-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: capybara
@@ -32,14 +32,14 @@ dependencies:
32
32
  requirements:
33
33
  - - '='
34
34
  - !ruby/object:Gem::Version
35
- version: 0.27.3
35
+ version: 0.27.4
36
36
  type: :runtime
37
37
  prerelease: false
38
38
  version_requirements: !ruby/object:Gem::Requirement
39
39
  requirements:
40
40
  - - '='
41
41
  - !ruby/object:Gem::Version
42
- version: 0.27.3
42
+ version: 0.27.4
43
43
  - !ruby/object:Gem::Dependency
44
44
  name: factory_bot_rails
45
45
  requirement: !ruby/object:Gem::Requirement
@@ -408,15 +408,18 @@ files:
408
408
  - app/mailers/decidim/dummy_resources/dummy_resource_mailer.rb
409
409
  - app/packs/entrypoints/decidim_dev.js
410
410
  - app/packs/entrypoints/decidim_dev.scss
411
+ - app/packs/entrypoints/decidim_dev_test_custom_map.js
411
412
  - app/packs/images/decidim/decidim_dev_dummy.svg
412
413
  - app/packs/images/decidim/gamification/badges/decidim_gamification_badges_test.svg
413
414
  - app/packs/src/decidim/dev/accessibility.js
415
+ - app/packs/src/decidim/dev/test/custom_map_factory.js
414
416
  - app/packs/stylesheets/decidim/dev.scss
415
417
  - app/packs/stylesheets/decidim/dev/_accessibility.scss
416
418
  - app/views/decidim/dummy_resource/_linked_dummys.html.erb
417
419
  - app/views/decidim/dummy_resources/dummy_resources/foo.html.erb
418
420
  - app/views/decidim/dummy_resources/dummy_resources/show.html.erb
419
421
  - config/assets.rb
422
+ - config/environment.rb
420
423
  - config/locales/am-ET.yml
421
424
  - config/locales/ar-SA.yml
422
425
  - config/locales/ar.yml
@@ -588,6 +591,7 @@ files:
588
591
  - lib/decidim/dev/test/rspec_support/rake_tasks.rb
589
592
  - lib/decidim/dev/test/rspec_support/route_helpers.rb
590
593
  - lib/decidim/dev/test/rspec_support/screenshot_helper.rb
594
+ - lib/decidim/dev/test/rspec_support/summary_notification.rb
591
595
  - lib/decidim/dev/test/rspec_support/time_helpers.rb
592
596
  - lib/decidim/dev/test/rspec_support/timezone.rb
593
597
  - lib/decidim/dev/test/rspec_support/translation_helpers.rb
@@ -599,6 +603,8 @@ files:
599
603
  - lib/decidim/dev/test/spec_helper.rb
600
604
  - lib/decidim/dev/test/w3c_rspec_validators_overrides.rb
601
605
  - lib/decidim/dev/version.rb
606
+ - lib/rubocop/cop/decidim.rb
607
+ - lib/rubocop/cop/decidim/hash_shorthand_syntax_backports.rb
602
608
  - lib/tasks/generators.rake
603
609
  - lib/tasks/lighthouse_report.rake
604
610
  - lib/tasks/locale_checker.rake
@@ -606,7 +612,7 @@ homepage: https://github.com/decidim/decidim
606
612
  licenses:
607
613
  - AGPL-3.0
608
614
  metadata: {}
609
- post_install_message:
615
+ post_install_message:
610
616
  rdoc_options: []
611
617
  require_paths:
612
618
  - lib
@@ -622,7 +628,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
622
628
  version: '0'
623
629
  requirements: []
624
630
  rubygems_version: 3.2.22
625
- signing_key:
631
+ signing_key:
626
632
  specification_version: 4
627
633
  summary: Decidim dev tools
628
634
  test_files: []