decidim-generators 0.27.9 → 0.28.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +6 -5
- data/Gemfile.lock +346 -403
- data/README.md +2 -2
- data/lib/decidim/generators/app_generator.rb +83 -8
- data/lib/decidim/generators/app_templates/.node-version +1 -0
- data/lib/decidim/generators/app_templates/.rubocop.yml +2 -0
- data/lib/decidim/generators/app_templates/.ruby-version +1 -0
- data/lib/decidim/generators/app_templates/README.md.erb +7 -12
- data/lib/decidim/generators/app_templates/another_dummy_authorization_handler.rb +1 -1
- data/lib/decidim/generators/app_templates/budgets_workflow_random.rb +1 -1
- data/lib/decidim/generators/app_templates/bullet_initializer.rb +1 -1
- data/lib/decidim/generators/app_templates/database.yml.erb +1 -1
- data/lib/decidim/generators/app_templates/decidim_application.scss +2 -1
- data/lib/decidim/generators/app_templates/dummy_authorization_handler.rb +5 -5
- data/lib/decidim/generators/app_templates/initializer.rb +16 -8
- data/lib/decidim/generators/app_templates/rack_profiler_initializer.rb +2 -1
- data/lib/decidim/generators/app_templates/secrets.yml.erb +14 -10
- data/lib/decidim/generators/component_generator.rb +37 -2
- data/lib/decidim/generators/component_templates/.eslintrc.json +3 -0
- data/lib/decidim/generators/component_templates/.node-version +1 -0
- data/lib/decidim/generators/component_templates/.rubocop.yml +2 -0
- data/lib/decidim/generators/component_templates/.ruby-version +1 -0
- data/lib/decidim/generators/component_templates/.stylelintrc.json +3 -0
- data/lib/decidim/generators/component_templates/Gemfile.erb +5 -6
- data/lib/decidim/generators/component_templates/README.md.erb +7 -1
- data/lib/decidim/generators/component_templates/app/controllers/decidim/component/admin/application_controller.rb.erb +11 -0
- data/lib/decidim/generators/component_templates/app/permissions/decidim/component/admin/permissions.rb.erb +23 -0
- data/lib/decidim/generators/component_templates/decidim-component.gemspec.erb +10 -8
- data/lib/decidim/generators/component_templates/github/ci.yml.erb +77 -0
- data/lib/decidim/generators/component_templates/gitignore +5 -0
- data/lib/decidim/generators/component_templates/lib/decidim/component/test/factories.rb.erb +1 -0
- data/lib/decidim/generators/component_templates/package.json.erb +21 -0
- data/lib/decidim/generators/component_templates/spec/lib/version_spec.rb.erb +13 -0
- data/lib/decidim/generators/component_templates/spec/permissions/admin/permissions_spec.rb.erb +40 -0
- data/lib/decidim/generators/install_generator.rb +12 -7
- data/lib/decidim/generators/test/generator_examples.rb +72 -40
- data/lib/decidim/generators/version.rb +1 -1
- metadata +29 -15
- data/decidim-generators.gemspec +0 -35
- data/lib/decidim/generators/app_templates/_decidim-settings.scss +0 -7
- data/lib/decidim/generators/app_templates/social_share_button.rb +0 -8
- data/lib/decidim/generators/component_templates/circleci/config.yml +0 -47
@@ -9,6 +9,17 @@ module Decidim
|
|
9
9
|
# Note that it inherits from `Decidim::Admin::Components::BaseController`, which
|
10
10
|
# override its layout and provide all kinds of useful methods.
|
11
11
|
class ApplicationController < Decidim::Admin::Components::BaseController
|
12
|
+
def permission_class_chain
|
13
|
+
[::Decidim::<%= component_module_name %>::Admin::Permissions] + super
|
14
|
+
end
|
15
|
+
|
16
|
+
def user_not_authorized_path
|
17
|
+
decidim.root_path
|
18
|
+
end
|
19
|
+
|
20
|
+
def user_has_no_permission_path
|
21
|
+
decidim.root_path
|
22
|
+
end
|
12
23
|
end
|
13
24
|
end
|
14
25
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module <%= component_module_name %>
|
5
|
+
module Admin
|
6
|
+
class Permissions < Decidim::DefaultPermissions
|
7
|
+
def permissions
|
8
|
+
return permission_action if permission_action.scope != :admin
|
9
|
+
return permission_action unless user&.admin?
|
10
|
+
|
11
|
+
allow! if can_access?
|
12
|
+
|
13
|
+
permission_action
|
14
|
+
end
|
15
|
+
|
16
|
+
def can_access?
|
17
|
+
permission_action.subject == :<%= component_name.to_sym %> &&
|
18
|
+
permission_action.action == :read
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -9,19 +9,21 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.authors = ["<%= %x[git config user.name].chomp %>"]
|
10
10
|
s.email = ["<%= %x[git config user.email].chomp %>"]
|
11
11
|
s.license = "AGPL-3.0"
|
12
|
-
s.homepage = "https://
|
13
|
-
s.
|
12
|
+
s.homepage = "https://decidim.org"
|
13
|
+
s.metadata = {
|
14
|
+
"bug_tracker_uri" => "https://github.com/decidim/decidim/issues",
|
15
|
+
"documentation_uri" => "https://docs.decidim.org/",
|
16
|
+
"funding_uri" => "https://opencollective.com/decidim",
|
17
|
+
"homepage_uri" => "https://decidim.org",
|
18
|
+
"source_code_uri" => "https://github.com/decidim/decidim"
|
19
|
+
}
|
20
|
+
s.required_ruby_version = ">= <%= required_ruby_version %>"
|
14
21
|
|
15
22
|
s.name = "decidim-<%= component_name %>"
|
16
23
|
s.summary = "A decidim <%= component_name %> module"
|
17
24
|
s.description = "<%= component_description %>."
|
18
25
|
|
19
|
-
s.files = Dir.
|
20
|
-
`git ls-files -z`.split("\x0").select do |f|
|
21
|
-
(File.expand_path(f) == __FILE__) ||
|
22
|
-
f.start_with?(*%w(app/ config/ db/ lib/ LICENSE-AGPLv3.txt Rakefile README.md))
|
23
|
-
end
|
24
|
-
end
|
26
|
+
s.files = Dir["{app,config,lib}/**/*", "LICENSE-AGPLv3.txt", "Rakefile", "README.md"]
|
25
27
|
|
26
28
|
s.add_dependency "decidim-core", Decidim::<%= component_module_name %>.version
|
27
29
|
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
name: "[CI] <%= component_module_name %>"
|
2
|
+
on:
|
3
|
+
push:
|
4
|
+
branches:
|
5
|
+
- develop
|
6
|
+
- release/*
|
7
|
+
- "*-stable"
|
8
|
+
pull_request:
|
9
|
+
branches-ignore:
|
10
|
+
- "chore/l10n*"
|
11
|
+
|
12
|
+
env:
|
13
|
+
CI: "true"
|
14
|
+
RUBY_VERSION: <%= RUBY_VERSION %>
|
15
|
+
NODE_VERSION: 18.17.1
|
16
|
+
|
17
|
+
concurrency:
|
18
|
+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
19
|
+
cancel-in-progress: true
|
20
|
+
|
21
|
+
jobs:
|
22
|
+
main:
|
23
|
+
name: Tests
|
24
|
+
runs-on: ubuntu-latest
|
25
|
+
timeout-minutes: 30
|
26
|
+
services:
|
27
|
+
postgres:
|
28
|
+
image: postgres:14
|
29
|
+
ports: ["5432:5432"]
|
30
|
+
options: >-
|
31
|
+
--health-cmd pg_isready
|
32
|
+
--health-interval 10s
|
33
|
+
--health-timeout 5s
|
34
|
+
--health-retries 5
|
35
|
+
env:
|
36
|
+
POSTGRES_PASSWORD: postgres
|
37
|
+
env:
|
38
|
+
DATABASE_USERNAME: postgres
|
39
|
+
DATABASE_PASSWORD: postgres
|
40
|
+
DATABASE_HOST: localhost
|
41
|
+
steps:
|
42
|
+
- uses: actions/checkout@v3
|
43
|
+
with:
|
44
|
+
fetch-depth: 1
|
45
|
+
- uses: ruby/setup-ruby@v1
|
46
|
+
with:
|
47
|
+
bundler-cache: true
|
48
|
+
- uses: actions/setup-node@v3
|
49
|
+
with:
|
50
|
+
node-version: ${{ env.NODE_VERSION }}
|
51
|
+
- name: Get npm cache directory path
|
52
|
+
id: npm-cache-dir-path
|
53
|
+
run: echo "dir=$(npm get cache)-<%= component_name %>" >> $GITHUB_OUTPUT
|
54
|
+
- uses: actions/cache@v3
|
55
|
+
id: npm-cache
|
56
|
+
with:
|
57
|
+
path: ${{ steps.npm-cache-dir-path.outputs.dir }}
|
58
|
+
key: npm-${{ hashFiles('**/package-lock.json') }}
|
59
|
+
restore-keys: |
|
60
|
+
npm-
|
61
|
+
- run: bundle exec rake test_app
|
62
|
+
name: Create test app
|
63
|
+
- run: mkdir -p ./spec/decidim_dummy_app/tmp/screenshots
|
64
|
+
name: Create the screenshots folder
|
65
|
+
- uses: nanasess/setup-chromedriver@v2
|
66
|
+
- run: RAILS_ENV=test bundle exec rails assets:precompile
|
67
|
+
name: Precompile assets
|
68
|
+
working-directory: ./spec/decidim_dummy_app/
|
69
|
+
- run: bundle exec rspec
|
70
|
+
name: RSpec
|
71
|
+
- uses: codecov/codecov-action@v3
|
72
|
+
- uses: actions/upload-artifact@v3
|
73
|
+
if: always()
|
74
|
+
with:
|
75
|
+
name: screenshots
|
76
|
+
path: ./spec/decidim_dummy_app/tmp/screenshots
|
77
|
+
if-no-files-found: ignore
|
@@ -0,0 +1,21 @@
|
|
1
|
+
{
|
2
|
+
"name": "decidim-<%= component_name %>",
|
3
|
+
"version": "0.0.1",
|
4
|
+
"description": <%= JSON.generate(component_description || "") %>,
|
5
|
+
"private": true,
|
6
|
+
"license": "AGPL-3.0",
|
7
|
+
"scripts": {
|
8
|
+
"lint": "eslint -c .eslintrc.json --no-error-on-unmatched-pattern --ignore-pattern app/packs/vendor --ext .js app/packs",
|
9
|
+
"stylelint": "stylelint app/packs/**/*.scss"
|
10
|
+
},
|
11
|
+
"dependencies": {
|
12
|
+
"@decidim/browserslist-config": "<%= npm_package_version %>",
|
13
|
+
"@decidim/webpacker": "<%= npm_package_version %>"
|
14
|
+
},
|
15
|
+
"devDependencies": {
|
16
|
+
"@decidim/dev": "<%= npm_package_version %>",
|
17
|
+
"@decidim/eslint-config": "<%= npm_package_version %>",
|
18
|
+
"@decidim/stylelint-config": "<%= npm_package_version %>"
|
19
|
+
},
|
20
|
+
"browserslist": ["extends @decidim/browserslist-config"]
|
21
|
+
}
|
data/lib/decidim/generators/component_templates/spec/permissions/admin/permissions_spec.rb.erb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
module Decidim::<%= component_module_name %>::Admin
|
6
|
+
describe Permissions do
|
7
|
+
subject { described_class.new(user, permission_action, context).permissions.allowed? }
|
8
|
+
|
9
|
+
let(:organization) { create :organization }
|
10
|
+
let(:context) do
|
11
|
+
{
|
12
|
+
current_organization: organization
|
13
|
+
}
|
14
|
+
end
|
15
|
+
let(:action) do
|
16
|
+
{ scope: :admin, action: :read, subject: :<%= component_name.to_sym %> }
|
17
|
+
end
|
18
|
+
let(:permission_action) { Decidim::PermissionAction.new(**action) }
|
19
|
+
|
20
|
+
context "when user is admin" do
|
21
|
+
let(:user) { create :user, :admin, organization: organization }
|
22
|
+
|
23
|
+
it { is_expected.to be_truthy }
|
24
|
+
|
25
|
+
context "when scope is not admin" do
|
26
|
+
let(:action) do
|
27
|
+
{ scope: :foo, action: :read, subject: :<%= component_name.to_sym %> }
|
28
|
+
end
|
29
|
+
|
30
|
+
it_behaves_like "permission is not set"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "when user is not admin" do
|
35
|
+
let(:user) { create :user, organization: organization }
|
36
|
+
|
37
|
+
it_behaves_like "permission is not set"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -28,7 +28,7 @@ module Decidim
|
|
28
28
|
|
29
29
|
class_option :skip_gemfile, type: :boolean,
|
30
30
|
default: false,
|
31
|
-
desc: "
|
31
|
+
desc: "Do not generate a Gemfile for the application"
|
32
32
|
|
33
33
|
class_option :profiling, type: :boolean,
|
34
34
|
default: false,
|
@@ -40,14 +40,13 @@ module Decidim
|
|
40
40
|
|
41
41
|
def add_seeds
|
42
42
|
append_file "db/seeds.rb", <<~RUBY
|
43
|
-
# You can remove the 'faker' gem if you
|
43
|
+
# You can remove the 'faker' gem if you do not want Decidim seeds.
|
44
44
|
Decidim.seed!
|
45
45
|
RUBY
|
46
46
|
end
|
47
47
|
|
48
48
|
def copy_initializer
|
49
49
|
copy_file "carrierwave.rb", "config/initializers/carrierwave.rb"
|
50
|
-
copy_file "social_share_button.rb", "config/initializers/social_share_button.rb"
|
51
50
|
end
|
52
51
|
|
53
52
|
def secrets
|
@@ -79,9 +78,8 @@ module Decidim
|
|
79
78
|
end
|
80
79
|
|
81
80
|
def install_decidim_webpacker
|
82
|
-
# Copy CSS
|
81
|
+
# Copy CSS file
|
83
82
|
copy_file "decidim_application.scss", "app/packs/stylesheets/decidim/decidim_application.scss"
|
84
|
-
copy_file "_decidim-settings.scss", "app/packs/stylesheets/decidim/_decidim-settings.scss"
|
85
83
|
|
86
84
|
# Copy JS application file
|
87
85
|
copy_file "decidim_application.js", "app/packs/src/decidim/decidim_application.js"
|
@@ -94,10 +92,17 @@ module Decidim
|
|
94
92
|
# Regenerate webpacker binstubs
|
95
93
|
remove_file "bin/yarn"
|
96
94
|
bundle_install
|
97
|
-
rails "
|
95
|
+
rails "shakapacker:binstubs"
|
98
96
|
|
99
97
|
# Run Decidim custom webpacker installation
|
100
98
|
rails "decidim:webpacker:install"
|
99
|
+
|
100
|
+
# Run Decidim custom procfile installation
|
101
|
+
rails "decidim:procfile:install"
|
102
|
+
|
103
|
+
# Replace robots.txt
|
104
|
+
remove_file "public/robots.txt"
|
105
|
+
rails "decidim:robots:replace"
|
101
106
|
end
|
102
107
|
|
103
108
|
def build_api_docs
|
@@ -185,7 +190,7 @@ module Decidim
|
|
185
190
|
rails "db:test:prepare"
|
186
191
|
end
|
187
192
|
|
188
|
-
# Runs rails commands in a subprocess, and aborts if it
|
193
|
+
# Runs rails commands in a subprocess, and aborts if it does not suceeed
|
189
194
|
def rails(*args)
|
190
195
|
abort unless system("bin/rails", *args)
|
191
196
|
end
|
@@ -1,12 +1,47 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
shared_context "when generating a new application" do
|
4
|
+
let(:env) do |example|
|
5
|
+
#
|
6
|
+
# When tracking coverage, make sure the ruby environment points to the
|
7
|
+
# local version, so we get the benefits of running `decidim` directly
|
8
|
+
# without `bundler` (more realistic test), but also get code coverage
|
9
|
+
# properly measured (we track coverage on the local version and not on the
|
10
|
+
# installed version).
|
11
|
+
#
|
12
|
+
if ENV["SIMPLECOV"]
|
13
|
+
{
|
14
|
+
"RUBYOPT" => "-rsimplecov #{ENV.fetch("RUBYOPT", nil)}",
|
15
|
+
"RUBYLIB" => "#{repo_root}/decidim-generators/lib:#{ENV.fetch("RUBYLIB", nil)}",
|
16
|
+
"PATH" => "#{repo_root}/decidim-generators/exe:#{ENV.fetch("PATH", nil)}",
|
17
|
+
"COMMAND_NAME" => example.full_description.tr(" ", "_")
|
18
|
+
}
|
19
|
+
else
|
20
|
+
{}
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
let(:result) do
|
25
|
+
Bundler.with_original_env { Decidim::GemManager.capture(command, env:) }
|
26
|
+
end
|
27
|
+
|
28
|
+
# rubocop:disable RSpec/BeforeAfterAll
|
29
|
+
before(:all) do
|
30
|
+
Bundler.with_original_env { Decidim::GemManager.install_all(out: File::NULL) }
|
31
|
+
end
|
32
|
+
|
33
|
+
after(:all) do
|
34
|
+
Bundler.with_original_env { Decidim::GemManager.uninstall_all(out: File::NULL) }
|
35
|
+
end
|
36
|
+
# rubocop:enable RSpec/BeforeAfterAll
|
37
|
+
end
|
38
|
+
|
3
39
|
shared_examples_for "a new production application" do
|
4
40
|
it "includes optional plugins commented out in Gemfile" do
|
5
41
|
expect(result[1]).to be_success, result[0]
|
6
42
|
|
7
43
|
expect(File.read("#{test_app}/Gemfile"))
|
8
44
|
.to match(/^# gem "decidim-initiatives"/)
|
9
|
-
.and match(/^# gem "decidim-consultations"/)
|
10
45
|
.and match(/^# gem "decidim-elections"/)
|
11
46
|
.and match(/^# gem "decidim-conferences"/)
|
12
47
|
.and match(/^# gem "decidim-templates"/)
|
@@ -19,7 +54,6 @@ shared_examples_for "a new development application" do
|
|
19
54
|
|
20
55
|
expect(File.read("#{test_app}/Gemfile"))
|
21
56
|
.to match(/^gem "decidim-initiatives"/)
|
22
|
-
.and match(/^gem "decidim-consultations"/)
|
23
57
|
.and match(/^gem "decidim-elections"/)
|
24
58
|
.and match(/^gem "decidim-conferences"/)
|
25
59
|
.and match(/^gem "decidim-templates"/)
|
@@ -44,7 +78,7 @@ shared_examples_for "a new development application" do
|
|
44
78
|
end
|
45
79
|
|
46
80
|
# Check that important node modules were installed
|
47
|
-
expect(Pathname.new("#{test_app}/node_modules
|
81
|
+
expect(Pathname.new("#{test_app}/node_modules/shakapacker")).to be_directory
|
48
82
|
|
49
83
|
# Check that the configuration tweaks are applied properly
|
50
84
|
expect(File.read("#{test_app}/config/spring.rb")).to match(%r{^require "decidim/spring"})
|
@@ -166,7 +200,8 @@ shared_context "with application env vars" do
|
|
166
200
|
"DECIDIM_SESSION_TIMEOUT_INTERVAL" => "33",
|
167
201
|
"DECIDIM_FOLLOW_HTTP_X_FORWARDED_HOST" => "true",
|
168
202
|
"DECIDIM_MAXIMUM_CONVERSATION_MESSAGE_LENGTH" => "1234",
|
169
|
-
"
|
203
|
+
"DECIDIM_PASSWORD_SIMILARITY_LENGTH" => "4",
|
204
|
+
"DECIDIM_DENIED_PASSWORDS" => "i-do-not-like-this-password, i-do-not,like,this,one,either, password123456",
|
170
205
|
"DECIDIM_ALLOW_OPEN_REDIRECTS" => "true",
|
171
206
|
"DECIDIM_ADMIN_PASSWORD_EXPIRATION_DAYS" => "93",
|
172
207
|
"DECIDIM_ADMIN_PASSWORD_MIN_LENGTH" => "18",
|
@@ -195,7 +230,6 @@ shared_context "with application env vars" do
|
|
195
230
|
"MEETINGS_EMBEDDABLE_SERVICES" => "www.youtube.com www.twitch.tv meet.jit.si 8x8.vc",
|
196
231
|
"BUDGETS_ENABLE_PROPOSAL_LINKING" => "false",
|
197
232
|
"ACCOUNTABILITY_ENABLE_PROPOSAL_LINKING" => "false",
|
198
|
-
"CONSULTATIONS_STATS_CACHE_EXPIRATION_TIME" => "7",
|
199
233
|
"INITIATIVES_CREATION_ENABLED" => "false",
|
200
234
|
"INITIATIVES_SIMILARITY_THRESHOLD" => "0.99",
|
201
235
|
"INITIATIVES_SIMILARITY_LIMIT" => "10",
|
@@ -288,7 +322,8 @@ shared_examples_for "an application with configurable env vars" do
|
|
288
322
|
%w(decidim session_timeout_interval) => 10,
|
289
323
|
%w(decidim follow_http_x_forwarded_host) => false,
|
290
324
|
%w(decidim maximum_conversation_message_length) => 1000,
|
291
|
-
%w(decidim
|
325
|
+
%w(decidim password_similarity_length) => 4,
|
326
|
+
%w(decidim denied_passwords) => [],
|
292
327
|
%w(decidim allow_open_redirects) => false,
|
293
328
|
%w(decidim admin_password expiration_days) => 90,
|
294
329
|
%w(decidim admin_password min_length) => 15,
|
@@ -323,7 +358,6 @@ shared_examples_for "an application with configurable env vars" do
|
|
323
358
|
%w(decidim meetings embeddable_services) => [],
|
324
359
|
%w(decidim budgets enable_proposal_linking) => "auto",
|
325
360
|
%w(decidim accountability enable_proposal_linking) => "auto",
|
326
|
-
%w(decidim consultations stats_cache_expiration_time) => 5,
|
327
361
|
%w(decidim initiatives creation_enabled) => "auto",
|
328
362
|
%w(decidim initiatives similarity_threshold) => 0.25,
|
329
363
|
%w(decidim initiatives similarity_limit) => 5,
|
@@ -336,7 +370,7 @@ shared_examples_for "an application with configurable env vars" do
|
|
336
370
|
%w(decidim initiatives max_time_in_validating_state) => 60,
|
337
371
|
%w(decidim initiatives print_enabled) => "auto",
|
338
372
|
%w(decidim initiatives do_not_require_authorization) => false,
|
339
|
-
%w(elections setup_minimum_hours_before_start) =>
|
373
|
+
%w(elections setup_minimum_hours_before_start) => 1,
|
340
374
|
%w(elections start_vote_maximum_hours_before_start) => 6,
|
341
375
|
%w(elections voter_token_expiration_minutes) => 120,
|
342
376
|
%w(elections votings check_census_max_requests) => 5,
|
@@ -392,7 +426,8 @@ shared_examples_for "an application with configurable env vars" do
|
|
392
426
|
%w(decidim session_timeout_interval) => 33,
|
393
427
|
%w(decidim follow_http_x_forwarded_host) => true,
|
394
428
|
%w(decidim maximum_conversation_message_length) => 1234,
|
395
|
-
%w(decidim
|
429
|
+
%w(decidim password_similarity_length) => 4,
|
430
|
+
%w(decidim denied_passwords) => ["i-do-not-like-this-password", "i-do-not,like,this,one,either", "password123456"],
|
396
431
|
%w(decidim allow_open_redirects) => true,
|
397
432
|
%w(decidim admin_password expiration_days) => 93,
|
398
433
|
%w(decidim admin_password min_length) => 18,
|
@@ -427,7 +462,6 @@ shared_examples_for "an application with configurable env vars" do
|
|
427
462
|
%w(decidim meetings embeddable_services) => %w(www.youtube.com www.twitch.tv meet.jit.si 8x8.vc),
|
428
463
|
%w(decidim budgets enable_proposal_linking) => false,
|
429
464
|
%w(decidim accountability enable_proposal_linking) => false,
|
430
|
-
%w(decidim consultations stats_cache_expiration_time) => 7,
|
431
465
|
%w(decidim initiatives creation_enabled) => false,
|
432
466
|
%w(decidim initiatives similarity_threshold) => 0.99,
|
433
467
|
%w(decidim initiatives similarity_limit) => 10,
|
@@ -486,7 +520,8 @@ shared_examples_for "an application with configurable env vars" do
|
|
486
520
|
"session_timeout_interval" => 10,
|
487
521
|
"follow_http_x_forwarded_host" => false,
|
488
522
|
"maximum_conversation_message_length" => 1000,
|
489
|
-
"
|
523
|
+
"password_similarity_length" => 4,
|
524
|
+
"denied_passwords" => [],
|
490
525
|
"allow_open_redirects" => false,
|
491
526
|
"etherpad" => nil,
|
492
527
|
"maps" => nil
|
@@ -522,7 +557,8 @@ shared_examples_for "an application with configurable env vars" do
|
|
522
557
|
"session_timeout_interval" => 33,
|
523
558
|
"follow_http_x_forwarded_host" => true,
|
524
559
|
"maximum_conversation_message_length" => 1234,
|
525
|
-
"
|
560
|
+
"password_similarity_length" => 4,
|
561
|
+
"denied_passwords" => ["i-do-not-like-this-password", "i-do-not,like,this,one,either", "password123456"],
|
526
562
|
"allow_open_redirects" => true,
|
527
563
|
"etherpad" => {
|
528
564
|
"server" => "http://a-etherpad-server.com",
|
@@ -833,18 +869,6 @@ end
|
|
833
869
|
shared_examples_for "an application with extra configurable env vars" do
|
834
870
|
include_context "with application env vars"
|
835
871
|
|
836
|
-
let(:consultations_initializer_off) do
|
837
|
-
{
|
838
|
-
"stats_cache_expiration_time" => 300 # 5.minutes
|
839
|
-
}
|
840
|
-
end
|
841
|
-
|
842
|
-
let(:consultations_initializer_on) do
|
843
|
-
{
|
844
|
-
"stats_cache_expiration_time" => 420 # 7.minutes
|
845
|
-
}
|
846
|
-
end
|
847
|
-
|
848
872
|
let(:initiatives_initializer_off) do
|
849
873
|
{
|
850
874
|
"creation_enabled" => true,
|
@@ -857,7 +881,7 @@ shared_examples_for "an application with extra configurable env vars" do
|
|
857
881
|
"second_notification_percentage" => 66,
|
858
882
|
"stats_cache_expiration_time" => 300, # 5.minutes
|
859
883
|
"max_time_in_validating_state" => 5_184_000, # 60.days
|
860
|
-
"print_enabled" =>
|
884
|
+
"print_enabled" => false,
|
861
885
|
"do_not_require_authorization" => false
|
862
886
|
}
|
863
887
|
end
|
@@ -881,7 +905,7 @@ shared_examples_for "an application with extra configurable env vars" do
|
|
881
905
|
|
882
906
|
let(:elections_initializer_off) do
|
883
907
|
{
|
884
|
-
"setup_minimum_hours_before_start" =>
|
908
|
+
"setup_minimum_hours_before_start" => 1,
|
885
909
|
"start_vote_maximum_hours_before_start" => 6,
|
886
910
|
"voter_token_expiration_minutes" => 120
|
887
911
|
}
|
@@ -924,20 +948,6 @@ shared_examples_for "an application with extra configurable env vars" do
|
|
924
948
|
it "env vars generate secrets application" do
|
925
949
|
expect(result[1]).to be_success, result[0]
|
926
950
|
|
927
|
-
# Test onto the initializer with ENV vars OFF for the Consultations module
|
928
|
-
json_off = initializer_config_for(test_app, env_off, "Decidim::Consultations")
|
929
|
-
consultations_initializer_off.each do |key, value|
|
930
|
-
current = json_off[key]
|
931
|
-
expect(current).to eq(value), "Consultations Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
932
|
-
end
|
933
|
-
|
934
|
-
# Test onto the initializer with ENV vars ON for the Consultations module
|
935
|
-
json_on = initializer_config_for(test_app, env_on, "Decidim::Consultations")
|
936
|
-
consultations_initializer_on.each do |key, value|
|
937
|
-
current = json_on[key]
|
938
|
-
expect(current).to eq(value), "Consultations Initializer (#{key}) = (#{current}) expected to match Env (#{value})"
|
939
|
-
end
|
940
|
-
|
941
951
|
# Test onto the initializer with ENV vars OFF for the Initiatives module
|
942
952
|
json_off = initializer_config_for(test_app, env_off, "Decidim::Initiatives")
|
943
953
|
initiatives_initializer_off.each do |key, value|
|
@@ -1072,3 +1082,25 @@ shared_examples_for "an application with storage and queue gems" do
|
|
1072
1082
|
expect(current["queues"].flatten).to include(*queues), "sidekiq queues (#{current["queues"].flatten}) expected to eq containt (#{queues})"
|
1073
1083
|
end
|
1074
1084
|
end
|
1085
|
+
|
1086
|
+
def json_secrets_for(path, env)
|
1087
|
+
JSON.parse cmd_capture(path, "bin/rails runner 'puts Rails.application.secrets.to_json'", env:)
|
1088
|
+
end
|
1089
|
+
|
1090
|
+
def initializer_config_for(path, env, mod = "Decidim")
|
1091
|
+
JSON.parse cmd_capture(path, "bin/rails runner 'puts #{mod}.config.to_json'", env:)
|
1092
|
+
end
|
1093
|
+
|
1094
|
+
def rails_value(value, path, env)
|
1095
|
+
JSON.parse cmd_capture(path, "bin/rails runner 'puts #{value}.to_json'", env:)
|
1096
|
+
end
|
1097
|
+
|
1098
|
+
def repo_root
|
1099
|
+
File.expand_path(File.join("..", "..", "..", "..", ".."), __dir__)
|
1100
|
+
end
|
1101
|
+
|
1102
|
+
def cmd_capture(path, cmd, env: {})
|
1103
|
+
Bundler.with_unbundled_env do
|
1104
|
+
Decidim::GemManager.new(path).capture(cmd, env:, with_stderr: false)[0]
|
1105
|
+
end
|
1106
|
+
end
|