decidim-dev 0.25.1 → 0.26.0
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 +4 -4
- data/config/locales/ar.yml +11 -0
- data/config/locales/bg.yml +6 -0
- data/config/locales/ca.yml +8 -0
- data/config/locales/cs.yml +8 -0
- data/config/locales/de.yml +6 -0
- data/config/locales/el.yml +6 -0
- data/config/locales/en.yml +8 -0
- data/config/locales/es-MX.yml +8 -0
- data/config/locales/es-PY.yml +8 -0
- data/config/locales/es.yml +8 -0
- data/config/locales/eu.yml +8 -0
- data/config/locales/fi-plain.yml +8 -0
- data/config/locales/fi.yml +8 -0
- data/config/locales/fr-CA.yml +8 -0
- data/config/locales/fr.yml +8 -0
- data/config/locales/ga-IE.yml +7 -0
- data/config/locales/gl.yml +8 -0
- data/config/locales/hu.yml +6 -0
- data/config/locales/id-ID.yml +11 -0
- data/config/locales/it.yml +8 -0
- data/config/locales/ja.yml +10 -2
- data/config/locales/nl.yml +8 -0
- data/config/locales/no.yml +23 -0
- data/config/locales/pl.yml +6 -0
- data/config/locales/pt-BR.yml +7 -1
- data/config/locales/pt.yml +8 -0
- data/config/locales/ro-RO.yml +12 -4
- data/config/locales/ru.yml +11 -0
- data/config/locales/sk.yml +7 -0
- data/config/locales/sv.yml +8 -0
- data/config/locales/tr-TR.yml +6 -0
- data/config/locales/uk.yml +11 -0
- data/config/locales/val-ES.yml +1 -0
- data/config/locales/zh-CN.yml +6 -0
- data/lib/decidim/dev/assets/base64_content.html +1 -0
- data/lib/decidim/dev/assets/dummy-dummies-example.csv +2 -0
- data/lib/decidim/dev/assets/dummy-dummies-example.json +18 -0
- data/lib/decidim/dev/assets/dummy-dummies-example.xlsx +0 -0
- data/lib/decidim/dev/assets/import_voting_census.csv +1 -0
- data/lib/decidim/dev/assets/import_voting_census_without_headers.csv +4 -0
- data/lib/decidim/dev/assets/private_key3.jwk +1 -0
- data/lib/decidim/dev/assets/public_key3.jwk +1 -0
- data/lib/decidim/dev/assets/test_excel.xlsx +0 -0
- data/lib/decidim/dev/test/promoted_participatory_processes_shared_examples.rb +5 -0
- data/lib/decidim/dev/test/rspec_support/accessibility_examples.rb +0 -3
- data/lib/decidim/dev/test/rspec_support/capybara.rb +1 -1
- data/lib/decidim/dev/test/rspec_support/component.rb +46 -2
- data/lib/decidim/dev/test/rspec_support/imports_controller_shared_examples.rb +146 -0
- data/lib/decidim/dev/test/spec_helper.rb +1 -0
- data/lib/decidim/dev/test/w3c_rspec_validators_overrides.rb +34 -0
- data/lib/decidim/dev/version.rb +1 -1
- metadata +21 -16
@@ -35,6 +35,11 @@ shared_examples "with promoted participatory processes and groups" do
|
|
35
35
|
organization: organization
|
36
36
|
)
|
37
37
|
|
38
|
+
_external_promoted_group = create(
|
39
|
+
:participatory_process_group,
|
40
|
+
:promoted
|
41
|
+
)
|
42
|
+
|
38
43
|
expect(controller.helpers.promoted_collection).to(
|
39
44
|
match_array([promoted_group, promoted_process])
|
40
45
|
)
|
@@ -11,9 +11,6 @@ shared_examples_for "accessible page" do
|
|
11
11
|
html = page.source
|
12
12
|
html = "<!DOCTYPE html>\n#{html}" unless html.strip.match?(/^<!DOCTYPE/i)
|
13
13
|
|
14
|
-
# This would cause a CSS validation error (added by EmojiPicker). Bug reported in https://github.com/validator/validator/issues/1223.
|
15
|
-
html = html.gsub("outline: 1px dotted var(--focus-indicator-color)", "outline: 1px dotted red")
|
16
|
-
|
17
14
|
expect(html).to be_valid_html
|
18
15
|
end
|
19
16
|
end
|
@@ -45,6 +45,32 @@ module Decidim
|
|
45
45
|
|
46
46
|
root to: proc { [200, {}, ["DUMMY ADMIN ENGINE"]] }
|
47
47
|
end
|
48
|
+
|
49
|
+
initializer "dummy_admin.imports" do
|
50
|
+
class ::DummyCreator < Decidim::Admin::Import::Creator
|
51
|
+
def self.resource_klass
|
52
|
+
Decidim::DummyResources::DummyResource
|
53
|
+
end
|
54
|
+
|
55
|
+
def produce
|
56
|
+
resource
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def resource
|
62
|
+
@resource ||= Decidim::DummyResources::DummyResource.new(
|
63
|
+
title: { en: "Dummy" },
|
64
|
+
author: context[:current_user],
|
65
|
+
component: component
|
66
|
+
)
|
67
|
+
end
|
68
|
+
|
69
|
+
def component
|
70
|
+
context[:current_component]
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
48
74
|
end
|
49
75
|
|
50
76
|
class ApplicationRecord < ActiveRecord::Base
|
@@ -162,14 +188,14 @@ module Decidim
|
|
162
188
|
false
|
163
189
|
end
|
164
190
|
|
165
|
-
def respond_to_missing?
|
191
|
+
def respond_to_missing?(*)
|
166
192
|
true
|
167
193
|
end
|
168
194
|
|
169
195
|
def method_missing(method, *args)
|
170
196
|
if method.to_s.ends_with?("?")
|
171
197
|
false
|
172
|
-
elsif [:avatar_url, :profile_path, :badge, :followers_count].include?(method)
|
198
|
+
elsif [:avatar_url, :profile_path, :badge, :followers_count, :cache_key_with_version].include?(method)
|
173
199
|
""
|
174
200
|
else
|
175
201
|
super
|
@@ -268,6 +294,24 @@ Decidim.register_component(:dummy) do |component|
|
|
268
294
|
|
269
295
|
exports.serializer DummySerializer
|
270
296
|
end
|
297
|
+
|
298
|
+
component.imports :dummies do |imports|
|
299
|
+
imports.messages do |msg|
|
300
|
+
msg.set(:resource_name) { |count: 1| count == 1 ? "Dummy" : "Dummies" }
|
301
|
+
msg.set(:title) { "Import dummies" }
|
302
|
+
msg.set(:label) { "Import dummies from a file" }
|
303
|
+
end
|
304
|
+
|
305
|
+
imports.creator DummyCreator
|
306
|
+
imports.example do |import_component|
|
307
|
+
locales = import_component.organization.available_locales
|
308
|
+
translated = ->(name) { locales.map { |l| "#{name}/#{l}" } }
|
309
|
+
[
|
310
|
+
translated.call("title") + %w(body) + translated.call("translatable_text") + %w(address latitude longitude),
|
311
|
+
locales.map { "Title text" } + ["Body text"] + locales.map { "Translatable text" } + ["Fake street 1", 1.0, 1.0]
|
312
|
+
]
|
313
|
+
end
|
314
|
+
end
|
271
315
|
end
|
272
316
|
|
273
317
|
RSpec.configure do |config|
|
@@ -0,0 +1,146 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
shared_examples "admin imports controller" do
|
4
|
+
let!(:organization) { create(:organization) }
|
5
|
+
let!(:user) { create(:user, :admin, :confirmed, organization: organization) }
|
6
|
+
let!(:component) { create(:component, participatory_space: participatory_space, manifest_name: "dummy") }
|
7
|
+
|
8
|
+
let(:default_params) do
|
9
|
+
{
|
10
|
+
component_id: component.id,
|
11
|
+
name: "dummies"
|
12
|
+
}
|
13
|
+
end
|
14
|
+
let(:extra_params) { {} }
|
15
|
+
|
16
|
+
before do
|
17
|
+
request.env["decidim.current_organization"] = organization
|
18
|
+
sign_in user, scope: :user
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "POST create" do
|
22
|
+
let(:file) do
|
23
|
+
# The file does not really matter for the dummies creator because it
|
24
|
+
# will always create a record for each data row regardless of the data.
|
25
|
+
Rack::Test::UploadedFile.new(
|
26
|
+
Decidim::Dev.test_file("import_proposals.csv", "text/csv"),
|
27
|
+
"text/csv"
|
28
|
+
)
|
29
|
+
end
|
30
|
+
let(:params) do
|
31
|
+
default_params.merge(extra_params).merge(file: file)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "imports dummies" do
|
35
|
+
post(:create, params: params)
|
36
|
+
expect(response).to have_http_status(:found)
|
37
|
+
expect(flash[:notice]).not_to be_empty
|
38
|
+
|
39
|
+
expect(Decidim::DummyResources::DummyResource.count).to eq(3)
|
40
|
+
Decidim::DummyResources::DummyResource.find_each do |dummy|
|
41
|
+
expect(dummy.title).to eq("en" => "Dummy")
|
42
|
+
expect(dummy.author).to eq(user)
|
43
|
+
expect(dummy.component).to eq(component)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
describe "GET example" do
|
49
|
+
let(:params) do
|
50
|
+
default_params.merge(extra_params).merge(format: format)
|
51
|
+
end
|
52
|
+
|
53
|
+
context "with CSV format" do
|
54
|
+
let(:format) { "csv" }
|
55
|
+
|
56
|
+
it "creates a correct CSV example file" do
|
57
|
+
get(:example, params: params)
|
58
|
+
|
59
|
+
expect(response).to have_http_status(:ok)
|
60
|
+
expect(response.content_type).to eq("text/csv")
|
61
|
+
expect(response.headers["Content-Disposition"]).to eq(
|
62
|
+
"attachment; filename=\"dummy-dummies-example.csv\"; filename*=UTF-8''dummy-dummies-example.csv"
|
63
|
+
)
|
64
|
+
expect(response.body).to eq(
|
65
|
+
File.read(Decidim::Dev.asset("dummy-dummies-example.csv"))
|
66
|
+
)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "with JSON format" do
|
71
|
+
let(:format) { "json" }
|
72
|
+
|
73
|
+
it "creates a correct JSON example file" do
|
74
|
+
get(:example, params: params)
|
75
|
+
|
76
|
+
expect(response).to have_http_status(:ok)
|
77
|
+
expect(response.content_type).to eq("application/json")
|
78
|
+
expect(response.headers["Content-Disposition"]).to eq(
|
79
|
+
"attachment; filename=\"dummy-dummies-example.json\"; filename*=UTF-8''dummy-dummies-example.json"
|
80
|
+
)
|
81
|
+
expect(response.body).to eq(
|
82
|
+
File.read(Decidim::Dev.asset("dummy-dummies-example.json"))
|
83
|
+
)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context "with XLSX format" do
|
88
|
+
let(:format) { "xlsx" }
|
89
|
+
|
90
|
+
it "creates a correct XLSX example file" do
|
91
|
+
get(:example, params: params)
|
92
|
+
|
93
|
+
expect(response).to have_http_status(:ok)
|
94
|
+
expect(response.content_type).to eq(
|
95
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
96
|
+
)
|
97
|
+
expect(response.headers["Content-Disposition"]).to eq(
|
98
|
+
"attachment; filename=\"dummy-dummies-example.xlsx\"; filename*=UTF-8''dummy-dummies-example.xlsx"
|
99
|
+
)
|
100
|
+
|
101
|
+
# The generated XLSX can have some byte differences which is why we need
|
102
|
+
# to read the values from both files and compare them instead.
|
103
|
+
workbook = RubyXL::Parser.parse_buffer(response.body)
|
104
|
+
actual = workbook.worksheets[0].map { |row| row.cells.map(&:value) }
|
105
|
+
|
106
|
+
workbook = RubyXL::Parser.parse(Decidim::Dev.asset("dummy-dummies-example.xlsx"))
|
107
|
+
expected = workbook.worksheets[0].map { |row| row.cells.map(&:value) }
|
108
|
+
|
109
|
+
expect(actual).to eq(expected)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context "with unknown format" do
|
114
|
+
let(:format) { "foo" }
|
115
|
+
|
116
|
+
it "raises ActionController::UnknownFormat" do
|
117
|
+
expect { get(:example, params: params) }.to raise_error(
|
118
|
+
ActionController::UnknownFormat
|
119
|
+
)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
context "with abstract creator" do
|
125
|
+
let(:creator) { Decidim::Admin::Import::Creator.new({ id: 1, "title/en": "My title for abstract creator" }) }
|
126
|
+
let(:params) do
|
127
|
+
default_params.merge(extra_params).merge(name: "abstract")
|
128
|
+
end
|
129
|
+
|
130
|
+
describe "POST create" do
|
131
|
+
it "raises ActionController::RoutingError" do
|
132
|
+
expect { post(:create, params: params) }.to raise_error(
|
133
|
+
ActionController::RoutingError
|
134
|
+
)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe "GET example" do
|
139
|
+
it "raises ActionController::RoutingError" do
|
140
|
+
expect { get(:example, params: params) }.to raise_error(
|
141
|
+
ActionController::RoutingError
|
142
|
+
)
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -10,6 +10,7 @@ require "db-query-matchers"
|
|
10
10
|
require "action_view/helpers/sanitize_helper"
|
11
11
|
require "axe-rspec"
|
12
12
|
require "w3c_rspec_validators"
|
13
|
+
require "decidim/dev/test/w3c_rspec_validators_overrides"
|
13
14
|
|
14
15
|
# Requires supporting files with custom matchers and macros, etc,
|
15
16
|
# in ./rspec_support/ and its subdirectories.
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# This is a temporary fix to ignore some HTML/CSS validation issues with the
|
4
|
+
# Decidim HTML validation process.
|
5
|
+
#
|
6
|
+
# See: https://github.com/decidim/decidim/issues/8596
|
7
|
+
# Related: https://github.com/w3c/css-validator/issues/355
|
8
|
+
module W3CValidators
|
9
|
+
class NuValidator
|
10
|
+
protected
|
11
|
+
|
12
|
+
alias validate_nu validate unless method_defined?(:validate_nu)
|
13
|
+
|
14
|
+
def validate(options) # :nodoc:
|
15
|
+
filter_results(validate_nu(options))
|
16
|
+
end
|
17
|
+
|
18
|
+
def ignore_errors
|
19
|
+
@ignore_errors ||= [
|
20
|
+
"CSS: “--content-height”: One operand must be a number."
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
def filter_results(results)
|
25
|
+
messages = results.instance_variable_get(:@messages)
|
26
|
+
messages.delete_if do |msg|
|
27
|
+
msg.is_error? && ignore_errors.include?(msg.message)
|
28
|
+
end
|
29
|
+
results.instance_variable_set(:@validity, messages.none?(&:is_error?))
|
30
|
+
|
31
|
+
results
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/decidim/dev/version.rb
CHANGED
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.
|
4
|
+
version: 0.26.0
|
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:
|
13
|
+
date: 2022-02-22 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.
|
35
|
+
version: 0.26.0
|
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.
|
42
|
+
version: 0.26.0
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: factory_bot_rails
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,20 +144,14 @@ dependencies:
|
|
144
144
|
requirements:
|
145
145
|
- - "~>"
|
146
146
|
- !ruby/object:Gem::Version
|
147
|
-
version: '1.
|
148
|
-
- - ">="
|
149
|
-
- !ruby/object:Gem::Version
|
150
|
-
version: 1.11.4
|
147
|
+
version: '1.12'
|
151
148
|
type: :runtime
|
152
149
|
prerelease: false
|
153
150
|
version_requirements: !ruby/object:Gem::Requirement
|
154
151
|
requirements:
|
155
152
|
- - "~>"
|
156
153
|
- !ruby/object:Gem::Version
|
157
|
-
version: '1.
|
158
|
-
- - ">="
|
159
|
-
- !ruby/object:Gem::Version
|
160
|
-
version: 1.11.4
|
154
|
+
version: '1.12'
|
161
155
|
- !ruby/object:Gem::Dependency
|
162
156
|
name: puma
|
163
157
|
requirement: !ruby/object:Gem::Requirement
|
@@ -489,6 +483,7 @@ files:
|
|
489
483
|
- config/locales/ti-ER.yml
|
490
484
|
- config/locales/tr-TR.yml
|
491
485
|
- config/locales/uk.yml
|
486
|
+
- config/locales/val-ES.yml
|
492
487
|
- config/locales/vi-VN.yml
|
493
488
|
- config/locales/vi.yml
|
494
489
|
- config/locales/zh-CN.yml
|
@@ -500,10 +495,14 @@ files:
|
|
500
495
|
- lib/decidim/dev/assets/assemblies.json
|
501
496
|
- lib/decidim/dev/assets/assemblies_with_null.json
|
502
497
|
- lib/decidim/dev/assets/avatar.jpg
|
498
|
+
- lib/decidim/dev/assets/base64_content.html
|
503
499
|
- lib/decidim/dev/assets/city.jpeg
|
504
500
|
- lib/decidim/dev/assets/city2.jpeg
|
505
501
|
- lib/decidim/dev/assets/city3.jpeg
|
506
502
|
- lib/decidim/dev/assets/dni.jpg
|
503
|
+
- lib/decidim/dev/assets/dummy-dummies-example.csv
|
504
|
+
- lib/decidim/dev/assets/dummy-dummies-example.json
|
505
|
+
- lib/decidim/dev/assets/dummy-dummies-example.xlsx
|
507
506
|
- lib/decidim/dev/assets/geocoder_result_here.json
|
508
507
|
- lib/decidim/dev/assets/geocoder_result_osm.json
|
509
508
|
- lib/decidim/dev/assets/icon.png
|
@@ -517,6 +516,7 @@ files:
|
|
517
516
|
- lib/decidim/dev/assets/import_proposals_broken.csv
|
518
517
|
- lib/decidim/dev/assets/import_voting_census.csv
|
519
518
|
- lib/decidim/dev/assets/import_voting_census_with_ballot_styles.csv
|
519
|
+
- lib/decidim/dev/assets/import_voting_census_without_headers.csv
|
520
520
|
- lib/decidim/dev/assets/invalid.jpeg
|
521
521
|
- lib/decidim/dev/assets/iso-8859-15.md
|
522
522
|
- lib/decidim/dev/assets/malicious.jpg
|
@@ -527,8 +527,11 @@ files:
|
|
527
527
|
- lib/decidim/dev/assets/participatory_text_wrong.odt
|
528
528
|
- lib/decidim/dev/assets/private_key.jwk
|
529
529
|
- lib/decidim/dev/assets/private_key2.jwk
|
530
|
+
- lib/decidim/dev/assets/private_key3.jwk
|
530
531
|
- lib/decidim/dev/assets/public_key.jwk
|
531
532
|
- lib/decidim/dev/assets/public_key2.jwk
|
533
|
+
- lib/decidim/dev/assets/public_key3.jwk
|
534
|
+
- lib/decidim/dev/assets/test_excel.xlsx
|
532
535
|
- lib/decidim/dev/assets/verify_user_groups.csv
|
533
536
|
- lib/decidim/dev/common_rake.rb
|
534
537
|
- lib/decidim/dev/dummy_translator.rb
|
@@ -560,6 +563,7 @@ files:
|
|
560
563
|
- lib/decidim/dev/test/rspec_support/geocoder.rb
|
561
564
|
- lib/decidim/dev/test/rspec_support/helpers.rb
|
562
565
|
- lib/decidim/dev/test/rspec_support/html_matchers.rb
|
566
|
+
- lib/decidim/dev/test/rspec_support/imports_controller_shared_examples.rb
|
563
567
|
- lib/decidim/dev/test/rspec_support/migration.rb
|
564
568
|
- lib/decidim/dev/test/rspec_support/orderly_matchers.rb
|
565
569
|
- lib/decidim/dev/test/rspec_support/organization.rb
|
@@ -576,6 +580,7 @@ files:
|
|
576
580
|
- lib/decidim/dev/test/rspec_support/wisper.rb
|
577
581
|
- lib/decidim/dev/test/rspec_support/z_download_helper.rb
|
578
582
|
- lib/decidim/dev/test/spec_helper.rb
|
583
|
+
- lib/decidim/dev/test/w3c_rspec_validators_overrides.rb
|
579
584
|
- lib/decidim/dev/version.rb
|
580
585
|
- lib/tasks/generators.rake
|
581
586
|
- lib/tasks/locale_checker.rake
|
@@ -583,7 +588,7 @@ homepage: https://github.com/decidim/decidim
|
|
583
588
|
licenses:
|
584
589
|
- AGPL-3.0
|
585
590
|
metadata: {}
|
586
|
-
post_install_message:
|
591
|
+
post_install_message:
|
587
592
|
rdoc_options: []
|
588
593
|
require_paths:
|
589
594
|
- lib
|
@@ -598,8 +603,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
598
603
|
- !ruby/object:Gem::Version
|
599
604
|
version: '0'
|
600
605
|
requirements: []
|
601
|
-
rubygems_version: 3.1.
|
602
|
-
signing_key:
|
606
|
+
rubygems_version: 3.1.6
|
607
|
+
signing_key:
|
603
608
|
specification_version: 4
|
604
609
|
summary: Decidim dev tools
|
605
610
|
test_files: []
|