decidim-dev 0.30.1 → 0.31.0.rc1

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.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/decidim/dev/dummy_resource.rb +8 -2
  3. data/app/packs/entrypoints/decidim_dev.scss +1 -1
  4. data/app/packs/src/decidim/dev/accessibility.js +2 -2
  5. data/app/packs/stylesheets/decidim/dev.scss +4 -4
  6. data/app/presenters/decidim/dev/dummy_resource_presenter.rb +2 -2
  7. data/config/assets.rb +2 -2
  8. data/config/locales/ar.yml +0 -2
  9. data/config/locales/bg.yml +0 -2
  10. data/config/locales/bs-BA.yml +0 -8
  11. data/config/locales/ca-IT.yml +2 -2
  12. data/config/locales/ca.yml +2 -2
  13. data/config/locales/cs.yml +2 -2
  14. data/config/locales/de.yml +2 -2
  15. data/config/locales/el.yml +0 -2
  16. data/config/locales/en.yml +2 -2
  17. data/config/locales/es-MX.yml +2 -2
  18. data/config/locales/es-PY.yml +2 -2
  19. data/config/locales/es.yml +2 -2
  20. data/config/locales/eu.yml +4 -4
  21. data/config/locales/fi-plain.yml +2 -2
  22. data/config/locales/fi.yml +2 -2
  23. data/config/locales/fr-CA.yml +0 -2
  24. data/config/locales/fr.yml +0 -2
  25. data/config/locales/gl.yml +0 -2
  26. data/config/locales/hu.yml +0 -2
  27. data/config/locales/it.yml +0 -2
  28. data/config/locales/ja.yml +2 -2
  29. data/config/locales/lt.yml +0 -2
  30. data/config/locales/lv.yml +0 -2
  31. data/config/locales/nl.yml +0 -2
  32. data/config/locales/no.yml +0 -2
  33. data/config/locales/pl.yml +0 -2
  34. data/config/locales/pt-BR.yml +0 -2
  35. data/config/locales/pt.yml +0 -2
  36. data/config/locales/ro-RO.yml +0 -2
  37. data/config/locales/sk.yml +0 -2
  38. data/config/locales/sr-CS.yml +0 -8
  39. data/config/locales/sv.yml +2 -2
  40. data/config/locales/tr-TR.yml +0 -2
  41. data/config/locales/zh-CN.yml +0 -2
  42. data/config/locales/zh-TW.yml +0 -2
  43. data/config/rubocop/capybara/configuration.yml +1 -0
  44. data/config/rubocop/capybara/disabled.yml +7 -0
  45. data/config/rubocop/disabled.yml +1 -41
  46. data/config/rubocop/factory_bot/configuration.yml +1 -0
  47. data/config/rubocop/factory_bot/disabled.yml +10 -0
  48. data/config/rubocop/{faker.yml → faker/configuration.yml} +1 -1
  49. data/config/rubocop/faker/disabled.yml +3 -0
  50. data/config/rubocop/{graphql.yml → graphql/configuration.yml} +2 -1
  51. data/config/rubocop/graphql/disabled.yml +4 -0
  52. data/config/rubocop/performance/configuration.yml +1 -0
  53. data/config/rubocop/{performance.yml → performance/disabled.yml} +1 -1
  54. data/config/rubocop/{rails.yml → rails/configuration.yml} +1 -24
  55. data/config/rubocop/rails/disabled.yml +46 -0
  56. data/config/rubocop/{rspec.yml → rspec/configuration.yml} +2 -29
  57. data/config/rubocop/rspec/disabled.yml +49 -0
  58. data/config/rubocop/{ruby.yml → ruby/configuration.yml} +3 -38
  59. data/config/rubocop/ruby/disabled.yml +106 -0
  60. data/decidim-dev.gemspec +10 -10
  61. data/lib/decidim/dev/assets/assemblies.json +6 -11
  62. data/lib/decidim/dev/assets/assemblies_with_null.json +0 -1
  63. data/lib/decidim/dev/assets/census_all_invalid.csv +4 -0
  64. data/lib/decidim/dev/assets/census_duplicate_emails.csv +4 -0
  65. data/lib/decidim/dev/assets/census_no_header.csv +2 -0
  66. data/lib/decidim/dev/assets/census_with_missing_email.csv +3 -0
  67. data/lib/decidim/dev/assets/census_with_missing_token.csv +3 -0
  68. data/lib/decidim/dev/assets/empty_file.csv +0 -0
  69. data/lib/decidim/dev/assets/participatory_processes.json +0 -1
  70. data/lib/decidim/dev/assets/participatory_processes_with_null.json +0 -1
  71. data/lib/decidim/dev/assets/valid_election_census.csv +3 -0
  72. data/lib/decidim/dev/assets/valid_emails.csv +27 -0
  73. data/lib/decidim/dev/common_rake.rb +0 -1
  74. data/lib/decidim/dev/component.rb +2 -2
  75. data/lib/decidim/dev/engine.rb +1 -1
  76. data/lib/decidim/dev/test/base_spec_helper.rb +9 -0
  77. data/lib/decidim/dev/test/factories.rb +5 -12
  78. data/lib/decidim/dev/test/rspec_support/active_job.rb +12 -0
  79. data/lib/decidim/dev/test/rspec_support/activestorage_matchers.rb +1 -1
  80. data/lib/decidim/dev/test/rspec_support/capybara.rb +11 -18
  81. data/lib/decidim/dev/test/rspec_support/comments.rb +1 -1
  82. data/lib/decidim/dev/test/rspec_support/component.rb +2 -2
  83. data/lib/decidim/dev/test/rspec_support/editor_context.rb +1 -13
  84. data/lib/decidim/dev/test/rspec_support/gamification.rb +1 -1
  85. data/lib/decidim/dev/test/rspec_support/helpers.rb +16 -0
  86. data/lib/decidim/dev/test/rspec_support/rake_tasks.rb +0 -16
  87. data/lib/decidim/dev/test/rspec_support/screenshot_helper.rb +2 -2
  88. data/lib/decidim/dev/test/rspec_support/{webpacker.rb → shakapacker.rb} +2 -2
  89. data/lib/decidim/dev/test/spec_helper.rb +1 -1
  90. data/lib/decidim/dev/version.rb +1 -1
  91. data/rubocop-decidim.yml +17 -9
  92. metadata +91 -37
@@ -15,8 +15,6 @@ FactoryBot.define do
15
15
  transient do
16
16
  skip_injection { false }
17
17
  users { nil }
18
- # user_groups correspondence to users is by sorting order
19
- user_groups { [] }
20
18
  end
21
19
  title { generate_localized_title(:dummy_resource_title, skip_injection:) }
22
20
  component { create(:dummy_component, skip_injection:) }
@@ -27,11 +25,11 @@ FactoryBot.define do
27
25
  published_at { Time.current }
28
26
  end
29
27
 
30
- trait :with_endorsements do
28
+ trait :with_likes do
31
29
  after :create do |resource, evaluator|
32
30
  5.times.collect do
33
- create(:endorsement, resource:, skip_injection: evaluator.skip_injection,
34
- author: build(:user, organization: resource.component.organization, skip_injection: evaluator.skip_injection))
31
+ create(:like, resource:, skip_injection: evaluator.skip_injection,
32
+ author: build(:user, organization: resource.component.organization, skip_injection: evaluator.skip_injection))
35
33
  end
36
34
  end
37
35
  end
@@ -61,13 +59,8 @@ FactoryBot.define do
61
59
 
62
60
  after :build do |resource, evaluator|
63
61
  evaluator.authors_list.each do |coauthor|
64
- resource.coauthorships << if coauthor.is_a?(Decidim::UserGroup)
65
- build(:coauthorship, author: coauthor.users.first, user_group: coauthor, coauthorable: resource,
66
- organization: evaluator.component.organization, skip_injection: evaluator.skip_injection)
67
- else
68
- build(:coauthorship, author: coauthor, coauthorable: resource, organization: evaluator.component.organization,
69
- skip_injection: evaluator.skip_injection)
70
- end
62
+ resource.coauthorships << build(:coauthorship, author: coauthor, coauthorable: resource, organization: evaluator.component.organization,
63
+ skip_injection: evaluator.skip_injection)
71
64
  end
72
65
  end
73
66
  end
@@ -1,7 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ module DecidimActiveJobExtensions
4
+ def wait_enqueued_jobs(&block)
5
+ while enqueued_jobs.size.positive?
6
+ perform_enqueued_jobs
7
+ sleep(1)
8
+ end
9
+
10
+ yield block
11
+ end
12
+ end
13
+
3
14
  RSpec.configure do |config|
4
15
  config.include ActiveJob::TestHelper
16
+ config.include DecidimActiveJobExtensions
5
17
  end
6
18
 
7
19
  ActiveJob::Base.queue_adapter = :test
@@ -28,7 +28,7 @@ module ActiveStorageMatchers
28
28
  when :redirect, :representation
29
29
  ActiveStorage::Blob.find_signed(key_match)
30
30
  when :disk
31
- decoded = ActiveStorage.verifier.verified(key_match, purpose: :blob_key)
31
+ decoded = ActiveStorage.verifier.verified(key_match, purpose: :blob_key).with_indifferent_access
32
32
  ActiveStorage::Blob.find_by(key: decoded[:key]) if decoded
33
33
  end
34
34
  end
@@ -30,28 +30,21 @@ module Decidim
30
30
  end
31
31
  end
32
32
 
33
- 1.step do
34
- port = rand(5000..6999)
33
+ # Expected values: "", "2", "3", etc. (see parallel_tests documentation)
34
+ parallel_run_idx = ENV.fetch("TEST_ENV_NUMBER", "").to_i
35
+ parallel_run_idx -= 1 if parallel_run_idx.positive?
36
+ Capybara.server_port = 1.step do |num|
37
+ port = 4999 + num + (100 * parallel_run_idx)
38
+ next if port == 5432 # Reserved for PostgreSQL
35
39
  next if port == 6379 # Reserved for Redis
36
40
 
41
+ # Make sure the port is not reserved by any other application.
37
42
  begin
38
- redis = Redis.new
39
- reserved_ports = (redis.get("decidim_test_capybara_reserved_ports") || "").split(",").map(&:to_i)
40
- unless reserved_ports.include?(port)
41
- reserved_ports << port
42
- if ParallelTests.last_process?
43
- redis.del("decidim_test_capybara_reserved_ports")
44
- else
45
- redis.set("decidim_test_capybara_reserved_ports", reserved_ports.sort.join(","))
46
- end
47
- break
48
- end
49
- rescue Redis::CannotConnectError
50
- # Redis is not available
51
- break
43
+ Socket.tcp("127.0.0.1", port, connect_timeout: 5).close
44
+ warn "Port #{port} is already in use, trying another one."
45
+ rescue Errno::ECONNREFUSED
46
+ break port
52
47
  end
53
- ensure
54
- Capybara.server_port = port
55
48
  end
56
49
 
57
50
  Capybara.register_driver :headless_chrome do |app|
@@ -3,7 +3,7 @@
3
3
  module CommentsHelpers
4
4
  def have_comment_from(user, text, opts = {})
5
5
  within "#comments" do
6
- have_content(user.name, **opts) && have_content(text, **opts)
6
+ have_content(user.name, **opts).and have_content(text, **opts)
7
7
  end
8
8
  end
9
9
 
@@ -18,7 +18,7 @@ RSpec.configure do |config|
18
18
  t.datetime :published_at
19
19
  t.datetime :deleted_at
20
20
  t.integer :coauthorships_count, null: false, default: 0
21
- t.integer :endorsements_count, null: false, default: 0
21
+ t.integer :likes_count, null: false, default: 0
22
22
  t.integer :comments_count, null: false, default: 0
23
23
  t.integer :follows_count, null: false, default: 0
24
24
 
@@ -53,7 +53,7 @@ RSpec.configure do |config|
53
53
  t.datetime :published_at
54
54
  t.datetime :deleted_at
55
55
  t.integer :coauthorships_count, null: false, default: 0
56
- t.integer :endorsements_count, null: false, default: 0
56
+ t.integer :likes_count, null: false, default: 0
57
57
  t.integer :comments_count, null: false, default: 0
58
58
 
59
59
  t.references :decidim_component, index: false
@@ -1,32 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- shared_context "with editor content containing hashtags and mentions" do
4
- let(:hashtag) { create(:hashtag, organization:) }
5
- let(:hashtag2) { create(:hashtag, organization:) }
3
+ shared_context "with editor content containing mentions" do
6
4
  let(:user) { create(:user, :confirmed, organization:) }
7
5
  let(:user2) { create(:user, :confirmed, organization:) }
8
- let(:user_group) { create(:user_group, :confirmed, organization:) }
9
- let(:user_group2) { create(:user_group, :confirmed, organization:) }
10
6
 
11
7
  let(:html) do
12
8
  <<~HTML
13
- <p>Paragraph with a hashtag #{hashtag.to_global_id} and another hashtag #{hashtag2.to_global_id}</p>
14
9
  <p>Paragraph with a user mention #{user.to_global_id} and another user mention #{user2.to_global_id}</p>
15
- <p>Paragraph with a user group mention #{user_group.to_global_id} and another user group mention #{user_group2.to_global_id}</p>
16
10
  HTML
17
11
  end
18
12
  let(:editor_html) do
19
13
  <<~HTML
20
- <p>Paragraph with a hashtag #{html_hashtag(hashtag)} and another hashtag #{html_hashtag(hashtag2)}</p>
21
14
  <p>Paragraph with a user mention #{html_mention(user)} and another user mention #{html_mention(user2)}</p>
22
- <p>Paragraph with a user group mention #{html_mention(user_group)} and another user group mention #{html_mention(user_group2)}</p>
23
15
  HTML
24
16
  end
25
17
 
26
- def html_hashtag(hashtag)
27
- %(<span data-type="hashtag" data-label="##{hashtag.name}">##{hashtag.name}</span>)
28
- end
29
-
30
18
  def html_mention(mentionable)
31
19
  mention = "@#{mentionable.nickname}"
32
20
  label = "#{mention} (#{CGI.escapeHTML(mentionable.name)})"
@@ -4,7 +4,7 @@ RSpec.configure do |config|
4
4
  config.before(:suite) do
5
5
  Decidim::Gamification.register_badge(:test) do |badge|
6
6
  badge.levels = [1, 5, 10]
7
- badge.valid_for = [:user, :user_group]
7
+ badge.valid_for = [:user]
8
8
  badge.reset = ->(_user) { 100 }
9
9
  end
10
10
  end
@@ -134,6 +134,22 @@ module Decidim
134
134
  JS
135
135
  )
136
136
  end
137
+
138
+ def select_text(selector)
139
+ page.execute_script(
140
+ <<~JS
141
+ var selection = document.getSelection();
142
+ var range = document.createRange();
143
+ var element = document.querySelector("#{selector}");
144
+
145
+ range.selectNodeContents(element);
146
+ selection.removeAllRanges();
147
+ selection.addRange(range);
148
+ document.dispatchEvent(new MouseEvent("selectstart"));
149
+ document.dispatchEvent(new MouseEvent("mouseup"));
150
+ JS
151
+ )
152
+ end
137
153
  end
138
154
 
139
155
  module FrontEndFileTestHelpers
@@ -40,22 +40,6 @@ module RakeTaskOutputHelpers
40
40
  $stdout = original_stdout
41
41
  end
42
42
  end
43
-
44
- def check_no_errors_have_been_printed
45
- expect($stdout.string).not_to include("ERROR:")
46
- end
47
-
48
- def check_some_errors_have_been_printed
49
- expect($stdout.string).to include("ERROR:")
50
- end
51
-
52
- def check_error_printed(type)
53
- expect($stdout.string).to include("ERROR: [#{type}]")
54
- end
55
-
56
- def check_message_printed(message)
57
- expect($stdout.string).to include(message)
58
- end
59
43
  end
60
44
 
61
45
  RSpec.configure do |config|
@@ -20,9 +20,9 @@ module ActionDispatch
20
20
  end
21
21
 
22
22
  # Add the file URI scheme so terminal emulators can open one click
23
- def display_image
23
+ def display_image(html:, **)
24
24
  message = "[Screenshot Image]: file://#{image_path}\n"
25
- message << "[Screenshot HTML]: file://#{html_path}\n" if save_html?
25
+ message << "[Screenshot HTML]: file://#{html_path}\n" if html
26
26
 
27
27
  case output_type
28
28
  when "artifact"
@@ -6,12 +6,12 @@ RSpec.configure do |config|
6
6
  raise "package.json file does not exist" unless Rails.root.join("package.json").exist?
7
7
  raise "Node modules directory does not exist" unless Rails.root.join("node_modules").exist?
8
8
 
9
- Dir.chdir(Rails.root) { Webpacker.compile }
9
+ Dir.chdir(Rails.root) { Shakapacker.compile }
10
10
  rescue Errno::ENOENT
11
11
  node_modules_contents = `ls #{Rails.root.join("node_modules")}`
12
12
 
13
13
  message = <<~ERROR
14
- There was an error during the Webpacker compilation
14
+ There was an error during the Shakapacker compilation
15
15
  #{"=" * 80}
16
16
  Node version: #{`node -v`}
17
17
  #{"=" * 80}
@@ -24,7 +24,7 @@ RSpec.configure do |config|
24
24
  config.raise_errors_for_deprecations!
25
25
  config.example_status_persistence_file_path = ".rspec-failures"
26
26
  config.filter_run_when_matching :focus
27
- config.profile_examples = 10
27
+ config.profile_examples = 10 unless ENV.fetch("CI", false)
28
28
  config.default_formatter = "doc" if config.files_to_run.one?
29
29
 
30
30
  # If you are not using ActiveRecord, or you'd prefer not to run each of your
@@ -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.30.1"
7
+ "0.31.0.rc1"
8
8
  end
9
9
  end
10
10
  end
data/rubocop-decidim.yml CHANGED
@@ -5,16 +5,24 @@
5
5
  # For further details, see:
6
6
  # https://github.com/rubocop/rubocop/issues/4154#issuecomment-316004878
7
7
 
8
- require:
8
+ plugins:
9
9
  - rubocop-rubycw
10
- - rubocop-capybara
11
- - rubocop-factory_bot
12
10
 
13
11
  inherit_from:
14
- - config/rubocop/performance.yml
15
- - config/rubocop/ruby.yml
16
- - config/rubocop/rails.yml
17
- - config/rubocop/rspec.yml
18
- - config/rubocop/faker.yml
19
- - config/rubocop/graphql.yml
12
+ - config/rubocop/capybara/configuration.yml
13
+ - config/rubocop/capybara/disabled.yml
14
+ - config/rubocop/performance/configuration.yml
15
+ - config/rubocop/performance/disabled.yml
16
+ - config/rubocop/ruby/configuration.yml
17
+ - config/rubocop/ruby/disabled.yml
18
+ - config/rubocop/rails/configuration.yml
19
+ - config/rubocop/rails/disabled.yml
20
+ - config/rubocop/rspec/configuration.yml
21
+ - config/rubocop/rspec/disabled.yml
22
+ - config/rubocop/faker/configuration.yml
23
+ - config/rubocop/faker/disabled.yml
24
+ - config/rubocop/graphql/configuration.yml
25
+ - config/rubocop/graphql/disabled.yml
26
+ - config/rubocop/factory_bot/configuration.yml
27
+ - config/rubocop/factory_bot/disabled.yml
20
28
  - config/rubocop/disabled.yml