decidim-dev 0.26.7 → 0.26.8

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: 119ef97add3f53531ee8847b70d8f86b6b1e4a490e4f1ccb5ee542fa3d1ae749
4
- data.tar.gz: aac00b66271bbecb6e236b42a4c3abd1da0c2e2ca660bb9e88b0354be6daac90
3
+ metadata.gz: 34e28be72e1e7f3a59d2ff86f1b9afac792207a77e77bd200e557720f094b08b
4
+ data.tar.gz: 4530c0fa9d56be4d72dc3f31bace2ed02e641998fc8b0016a379f853107f79c4
5
5
  SHA512:
6
- metadata.gz: 3c1af120c4e9e2268713424cab565f642eff90ff668926aebdb6f7a4b3ef86f898ede76e8908ab2cae11b474ac1d85f8927c24c780c8bbfbdb54900989b1a0a9
7
- data.tar.gz: 1952122960497e058aef2b6d72a4265314bafea382358cdb27f6636f931196577756b653ac7d67082ad5db4bc3e8311c4c6685b217071dd312febf2fc3d1cffa
6
+ metadata.gz: 0b2cea558c636573b7b627a7bc8f4e125b324104cdc382d5cfd7abffe26f839d5835a2b18a9b85dfcdb897d4df20774e674071a31940ef27215db99835dd4933
7
+ data.tar.gz: 627c66d6aa499d678edae2b95353dd71a920c636d548fa29199dfb315db2a264ae44fc7ccf26a2fc31e897a9c44ca48275f745bd33f98aeac379725b007c086b
@@ -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
@@ -14,6 +14,12 @@ de:
14
14
  dummy:
15
15
  settings:
16
16
  global:
17
+ guided: Geführte Eingabe
18
+ guided_help: Hilfetext
19
+ guided_readonly: Deaktivierte Eingabe
20
+ guided_rich: Geführte reiche Eingabe
21
+ guided_rich_help_html: HTML <strong>Hilfe</strong> Text
22
+ guided_rich_readonly_html: HTML <strong>Hilfe</strong> Text für deaktivierte Eingabe
17
23
  readonly_attribute: Attribut schreibgeschützt
18
24
  test: Test A
19
25
  test_choices:
@@ -22,6 +28,7 @@ de:
22
28
  c: Wahl C
23
29
  test_options:
24
30
  bar: Bar
31
+ baz: Baz
25
32
  foo: Foo
26
33
  step:
27
34
  endorsements_blocked: Befürwortungen blockiert
@@ -29,6 +36,7 @@ de:
29
36
  readonly_step_attribute: Schritt-Attribut schreibgeschützt
30
37
  test_options:
31
38
  bar: Bar
39
+ baz: Baz
32
40
  foo: Foo
33
41
  dummy:
34
42
  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.26.7"
7
+ "0.26.8"
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-dev
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.26.7
4
+ version: 0.26.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josep Jaume Rey Peroy
@@ -10,7 +10,7 @@ authors:
10
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.26.7
35
+ version: 0.26.8
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.26.7
42
+ version: 0.26.8
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
@@ -577,6 +580,7 @@ files:
577
580
  - lib/decidim/dev/test/rspec_support/rake_tasks.rb
578
581
  - lib/decidim/dev/test/rspec_support/react_select.rb
579
582
  - lib/decidim/dev/test/rspec_support/route_helpers.rb
583
+ - lib/decidim/dev/test/rspec_support/summary_notification.rb
580
584
  - lib/decidim/dev/test/rspec_support/time_helpers.rb
581
585
  - lib/decidim/dev/test/rspec_support/timezone.rb
582
586
  - lib/decidim/dev/test/rspec_support/translation_helpers.rb
@@ -588,6 +592,8 @@ files:
588
592
  - lib/decidim/dev/test/spec_helper.rb
589
593
  - lib/decidim/dev/test/w3c_rspec_validators_overrides.rb
590
594
  - lib/decidim/dev/version.rb
595
+ - lib/rubocop/cop/decidim.rb
596
+ - lib/rubocop/cop/decidim/hash_shorthand_syntax_backports.rb
591
597
  - lib/tasks/generators.rake
592
598
  - lib/tasks/locale_checker.rake
593
599
  homepage: https://github.com/decidim/decidim