Skip to content

Commit

Permalink
Upgrade to Decidim 0.24 (#31)
Browse files Browse the repository at this point in the history
* WIP

* TEST

* TEST: Make tests succeed

* Rubocopify

* Erblint

* Refactor

* Set civi_crm authenticator required secrets

* TEST: make tests succeed
  • Loading branch information
tramuntanal authored Oct 25, 2022
1 parent 135e937 commit b466459
Show file tree
Hide file tree
Showing 20 changed files with 599 additions and 231 deletions.
47 changes: 0 additions & 47 deletions .circleci/config.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ jobs:
run: |
bundle exec rake test_app
- name: set crm authenticable configuration values
run: bundle exec rake civi_crm:configure_secrets

- name: Run RSpec
uses: nick-invision/retry@v2
with:
Expand Down
73 changes: 32 additions & 41 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ require: rubocop-rspec

# Common configuration.
AllCops:
NewCops: enable
Include:
- .simplecov
- "**/*.rb"
Expand Down Expand Up @@ -64,7 +65,7 @@ AllCops:
# If a value is specified for TargetRubyVersion then it is used.
# Else if .ruby-version exists and it contains an MRI version it is used.
# Otherwise we fallback to the oldest officially supported Ruby version (2.0).
TargetRubyVersion: 2.6
TargetRubyVersion: 2.7

RSpec:
Patterns:
Expand All @@ -88,7 +89,7 @@ Style/Alias:
- prefer_alias_method

# Align the elements of a hash literal if they span more than one line.
Layout/AlignHash:
Layout/HashAlignment:
# Alignment of entries using hash rocket as separator. Valid values are:
#
# key - left alignment of keys
Expand Down Expand Up @@ -151,7 +152,7 @@ Layout/AlignHash:
- ignore_implicit
- ignore_explicit

Layout/AlignParameters:
Layout/ParameterAlignment:
# Alignment of parameters in multi-line method calls.
#
# The `with_first_parameter` style aligns the following lines along the same
Expand Down Expand Up @@ -262,20 +263,6 @@ Style/BlockDelimiters:
- proc
- it

Style/BracesAroundHashParameters:
EnforcedStyle: no_braces
SupportedStyles:
# The `braces` style enforces braces around all method parameters that are
# hashes.
- braces
# The `no_braces` style checks that the last parameter doesn't have braces
# around it.
- no_braces
# The `context_dependent` style checks that the last parameter doesn't have
# braces around it, but requires braces if the second to last parameter is
# also a hash literal.
- context_dependent

# Indentation of `when`.
Layout/CaseIndentation:
EnforcedStyle: case
Expand Down Expand Up @@ -468,7 +455,7 @@ Naming/FileName:
# files with a shebang in the first line).
IgnoreExecutableScripts: true

Layout/IndentFirstArgument:
Layout/FirstArgumentIndentation:
EnforcedStyle: special_for_inner_method_call_in_parentheses
SupportedStyles:
# The first parameter should always be indented one step more than the
Expand Down Expand Up @@ -558,7 +545,7 @@ Layout/IndentationWidth:
Width: 2

# Checks the indentation of the first element in an array literal.
Layout/IndentFirstArrayElement:
Layout/FirstArrayElementIndentation:
# The value `special_inside_parentheses` means that array literals with
# brackets that have their opening bracket on the same line as a surrounding
# opening round parenthesis, shall have their first element indented relative
Expand All @@ -580,13 +567,13 @@ Layout/IndentFirstArrayElement:
IndentationWidth: ~

# Checks the indentation of assignment RHS, when on a different line from LHS
Layout/IndentAssignment:
Layout/AssignmentIndentation:
# By default, the indentation width from Style/IndentationWidth is used
# But it can be overridden by setting this parameter
IndentationWidth: ~

# Checks the indentation of the first key in a hash literal.
Layout/IndentFirstHashElement:
Layout/FirstHashElementIndentation:
# The value `special_inside_parentheses` means that hash literals with braces
# that have their opening brace on the same line as a surrounding opening
# round parenthesis, shall have their first key indented relative to the
Expand Down Expand Up @@ -793,12 +780,12 @@ Naming/PredicateName:
- has_
- have_
# Predicate name prefixes that should be removed.
NamePrefixBlacklist:
ForbiddenPrefixes:
- is_
- have_
# Predicate names which, despite having a blacklisted prefix, or no ?,
# should still be accepted
NameWhitelist:
AllowedMethods:
- is_a?
# Exclude Rspec specs because there is a strong convetion to write spec
# helpers in the form of `have_something` or `be_something`.
Expand Down Expand Up @@ -976,7 +963,7 @@ Style/TernaryParentheses:
- require_no_parentheses
AllowSafeAssignment: true

Layout/TrailingBlankLines:
Layout/TrailingEmptyLines:
EnforcedStyle: final_newline
SupportedStyles:
- final_newline
Expand Down Expand Up @@ -1026,7 +1013,7 @@ Style/TrivialAccessors:
# Commonly used in DSLs
AllowDSLWriters: false
IgnoreClassMethods: false
Whitelist:
AllowedMethods:
- to_ary
- to_a
- to_c
Expand Down Expand Up @@ -1100,18 +1087,6 @@ Metrics/CyclomaticComplexity:
Exclude:
- "**/*/permissions.rb"

Metrics/LineLength:
Max: 180
# To make it possible to copy or click on URIs in the code, we allow lines
# containing a URI to be longer than Max.
AllowHeredoc: true
AllowURI: true
URISchemes:
- http
- https
Exclude:
- "**/spec/**/*"

Metrics/MethodLength:
CountComments: false # count full line comments?
Max: 15
Expand Down Expand Up @@ -1168,6 +1143,18 @@ Layout/DefEndAlignment:
EnforcedStyleAlignWith: start_of_line
AutoCorrect: false

Layout/LineLength:
Max: 180
# To make it possible to copy or click on URIs in the code, we allow lines
# containing a URI to be longer than Max.
AllowHeredoc: true
AllowURI: true
URISchemes:
- http
- https
Exclude:
- "**/spec/**/*"

Lint/InheritException:
# The default base class in favour of `Exception`.
EnforcedStyle: runtime_error
Expand All @@ -1187,10 +1174,6 @@ Lint/UnusedMethodArgument:

##################### Performance ############################

Performance/RedundantMerge:
# Max number of key-value pairs to consider an offense
MaxKeyValuePairs: 2

Metrics/BlockLength:
Enabled: false

Expand Down Expand Up @@ -1236,6 +1219,14 @@ RSpec/MessageSpies:
RSpec/MultipleExpectations:
Max: 17

RSpec/MultipleMemoizedHelpers:
Exclude:
- spec/commands/decidim/create_registration_spec.rb
- spec/models/decidim/user_spec.rb
- spec/services/erc/crm_authenticable/crm_authenticable_authorization_handler_spec.rb
- spec/services/erc/crm_authenticable/user_authorizer_spec.rb
- spec/system/decidim/erc/crm_authenticable/crm_authenticable_action_authorizer_spec.rb

RSpec/NestedGroups:
Max: 7

Expand Down
85 changes: 0 additions & 85 deletions .rubocop_rails.yml
Original file line number Diff line number Diff line change
@@ -1,88 +1,3 @@
Rails:
Enabled: true

Rails/ActionFilter:
Include:
- decidim-*/app/controllers/**/*.rb

Rails/CreateTableWithTimestamps:
Enabled: false

Rails/EnumUniqueness:
Include:
- decidim-*/app/models/**/*.rb

Rails/Exit:
Include:
- decidim-*/app/**/*.rb
- decidim-*/config/**/*.rb
- decidim-*/lib/**/*.rb
Exclude:
- decidim-*/lib/**/*.rake

Rails/FindBy:
Include:
- "**/*.rb"

Rails/FindEach:
Include:
- decidim-*/app/models/**/*.rb

Rails/HasAndBelongsToMany:
Include:
- decidim-*/app/models/**/*.rb

Rails/HasManyOrHasOneDependent:
Include:
- decidim-*/app/models/**/*.rb

Rails/InverseOf:
Enabled: false

Rails/LexicallyScopedActionFilter:
Include:
- decidim-*/app/controllers/**/*.rb

Rails/NotNullColumn:
Enabled: false

Rails/Output:
Include:
- decidim-*/app/**/*.rb
- decidim-*/config/**/*.rb
- decidim-*/db/**/*.rb
- decidim-*/lib/**/*.rb
Exclude:
- decidim-core/db/seeds.rb
- decidim-core/lib/decidim/core.rb
- decidim-core/lib/decidim/component_manifest.rb
- decidim-core/lib/decidim/participatory_space_manifest.rb
- decidim-system/db/seeds.rb

Rails/OutputSafety:
Enabled: false

Rails/ReadWriteAttribute:
Include:
- decidim-*/app/models/**/*.rb

Rails/ReversibleMigration:
Enabled: false

Rails/ScopeArgs:
Include:
- decidim-*/app/models/**/*.rb

Rails/SkipsModelValidations:
Enabled: true

Rails/UnknownEnv:
Enabled: false
Environments:
- development
- test
- production
- preprod
Rails/Validation:
Include:
- decidim-*/app/models/**/*.rb
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Changelog

### Version 1.2.0
- Upgrade to Decidim 0.24

### Version 1.1.6
- Update rake tasks with csv scopes (#28)

### Version 1.1.5
- Change how the signup against CSV is enabled (#26)
- Upgrade to Ruby 2.7.2 (#26)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ gemspec

require_relative "lib/decidim/erc/crm_authenticable/version"

gem "decidim", Decidim::Erc::CrmAuthenticable.decidim_version
gem "decidim", "~>#{Decidim::Erc::CrmAuthenticable.decidim_version}"

group :development, :test do
gem "bootsnap", require: true
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,11 @@ Run the following in the gem development path to create the test app:
```bash
$ bundle
$ bundle exec rake test_app
$ bundle exec rake civi_crm:configure_secrets
```
Note that the database user has to have rights to create and drop a database in order to create the dummy test app database.

And then set the configuration values for the test app in `spec/decidim_dummy_app/config/secrets.yml`:
And the `civi_crm:configure_secrets` taks set the configuration values for the test app in `spec/decidim_dummy_app/config/secrets.yml` as:

```yaml
erc_crm_authenticable:
Expand Down
20 changes: 20 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,23 @@ task test_app: "decidim:generate_external_test_app" do
FileUtils.cp(filename, dest_folder)
end
end

namespace :civi_crm do
desc "Configure assets required by tests"
task :configure_secrets do
values = <<-EOVALUES
erc_crm_authenticable:
api_base: https://api.base/?
site_key: site_key
api_key: api_key
secret_key: secret_key
EOVALUES
values = values.gsub(/\n/, "\\\n")

cmd = "sed -i '/default: &default/a\\#{values}' spec/decidim_dummy_app/config/secrets.yml"
puts "---------------------------"
puts cmd
puts "---------------------------"
system(cmd)
end
end
Loading

0 comments on commit b466459

Please sign in to comment.