diff --git a/.github/run_erblint.sh b/.github/run_erblint.sh new file mode 100755 index 0000000..9597e4a --- /dev/null +++ b/.github/run_erblint.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +shopt -s globstar + +bundle exec erblint app/{cells,views}/**/*.erb + +# Store the return code of the erblint execution +EXIT_CODE=$? + +shopt -u globstar + +exit $EXIT_CODE diff --git a/.github/upload_coverage.sh b/.github/upload_coverage.sh new file mode 100755 index 0000000..7624a57 --- /dev/null +++ b/.github/upload_coverage.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +REPORT_NAME=$1 +EVENT_PAYLOAD_FILE=$2 + +PRID=`jq ".number // .check_run.pull_requests[0].number" $EVENT_PAYLOAD_FILE` +SHA=`jq -r ".pull_request.head.sha // .check_run.head_sha // .after" $EVENT_PAYLOAD_FILE` + +if [ $PRID = "null" ] +then + bash <(curl -s https://codecov.io/bash) -n $REPORT_NAME -C $SHA +else + bash <(curl -s https://codecov.io/bash) -n $REPORT_NAME -C $SHA -P $PRID +fi diff --git a/.github/workflows/lint_code.yml b/.github/workflows/lint_code.yml new file mode 100644 index 0000000..84ee579 --- /dev/null +++ b/.github/workflows/lint_code.yml @@ -0,0 +1,51 @@ +name: "[CI] Lint" +on: + push: + branches: + - develop + - release/* + - "*-stable" + pull_request: + branches-ignore: + - "chore/l10n*" + +env: + CI: "true" + SIMPLECOV: "true" + RUBY_VERSION: 2.6.6 + +jobs: + lint: + name: Lint code + runs-on: ubuntu-latest + if: "!startsWith(github.head_ref, 'chore/l10n')" + timeout-minutes: 60 + steps: + - uses: rokroskar/workflow-run-cleanup-action@v0.3.0 + if: "github.ref != 'refs/heads/develop'" + env: + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + - uses: actions/checkout@v2.0.0 + with: + fetch-depth: 1 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ env.RUBY_VERSION }} + bundler-cache: true + - uses: actions/setup-node@v1 + with: + node-version: ${{ env.NODE_VERSION }} + - name: Get npm cache directory path + id: npm-cache-dir-path + run: echo "::set-output name=dir::$(npm get cache)-lint" + - uses: actions/cache@v2 + id: npm-cache + with: + path: ${{ steps.npm-cache-dir-path.outputs.dir }} + key: npm-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + npm- + - name: Install JS dependencies + run: npm ci + - run: bundle exec rubocop -P + name: Lint Ruby files diff --git a/.rubocop.yml b/.rubocop.yml index c0cc19f..5b53bd9 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -15,8 +15,6 @@ AllCops: - "development_app/**/*" - "spec/decidim_dummy_app/**/*" - "node_modules/**/*" - - "decidim-generators/pkg/gems/**/*" - - "pkg/gems/**/*" # Default formatter will be used if no -f/--format option is given. DefaultFormatter: progress # Cop names are not displayed in offense messages by default. Change behavior @@ -66,7 +64,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.5 + TargetRubyVersion: 2.6 RSpec: Patterns: @@ -470,7 +468,7 @@ Naming/FileName: # files with a shebang in the first line). IgnoreExecutableScripts: true -Layout/FirstParameterIndentation: +Layout/IndentFirstArgument: EnforcedStyle: special_for_inner_method_call_in_parentheses SupportedStyles: # The first parameter should always be indented one step more than the @@ -507,15 +505,13 @@ Style/FormatStringToken: EnforcedStyle: template Style/FrozenStringLiteralComment: - EnforcedStyle: when_needed + EnforcedStyle: always SupportedStyles: - # `when_needed` will add the frozen string literal comment to files - # only when the `TargetRubyVersion` is set to 2.5+. - - when_needed + - never # `always` will always add the frozen string literal comment to a file # regardless of the Ruby version or if `freeze` or `<<` are called on a # string literal. If you run code against multiple versions of Ruby, it is - # possible that this will create errors in Ruby 2.5.0+. + # possible that this will create errors in Ruby 2.3.0+. - always # Built-in global variables are allowed by default. @@ -560,7 +556,7 @@ Layout/IndentationWidth: Width: 2 # Checks the indentation of the first element in an array literal. -Layout/IndentArray: +Layout/IndentFirstArrayElement: # 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 @@ -588,7 +584,7 @@ Layout/IndentAssignment: IndentationWidth: ~ # Checks the indentation of the first key in a hash literal. -Layout/IndentHash: +Layout/IndentFirstHashElement: # 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 @@ -1116,8 +1112,6 @@ Metrics/LineLength: - https Exclude: - "**/spec/**/*" - - "decidim-generators/pkg/**/*" - - "pkg/**/*" Metrics/MethodLength: CountComments: false # count full line comments? @@ -1194,10 +1188,6 @@ Lint/UnusedMethodArgument: ##################### Performance ############################ -Performance/RedundantMerge: - # Max number of key-value pairs to consider an offense - MaxKeyValuePairs: 2 - Metrics/BlockLength: Enabled: false @@ -1241,7 +1231,7 @@ RSpec/MessageSpies: Enabled: false RSpec/MultipleExpectations: - Max: 20 + Enabled: false RSpec/NestedGroups: Max: 7 @@ -1249,7 +1239,18 @@ RSpec/NestedGroups: RSpec/NamedSubject: Enabled: false +RSpec/RepeatedExampleGroupDescription: + Enabled: false + +RSpec/RepeatedExampleGroupBody: + Enabled: false RSpec/VerifiedDoubles: Enabled: false +RSpec/LeakyConstantDeclaration: + Enabled: false + +RSpec/DescribedClass: + Enabled: false + inherit_from: .rubocop_rails.yml diff --git a/.rubocop_rails.yml b/.rubocop_rails.yml index 02d06dd..cf139e4 100644 --- a/.rubocop_rails.yml +++ b/.rubocop_rails.yml @@ -1,3 +1,5 @@ +require: rubocop-rails + Rails: Enabled: true @@ -58,6 +60,7 @@ Rails/Output: - decidim-core/lib/decidim/component_manifest.rb - decidim-core/lib/decidim/participatory_space_manifest.rb - decidim-system/db/seeds.rb + - decidim-templates/db/seeds.rb Rails/OutputSafety: Enabled: false diff --git a/.ruby-version b/.ruby-version index aedc15b..338a5b5 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.5.3 +2.6.6 diff --git a/Gemfile b/Gemfile index 661cbd6..9a88597 100644 --- a/Gemfile +++ b/Gemfile @@ -4,17 +4,26 @@ source "https://rubygems.org" ruby RUBY_VERSION -gem "decidim", git: "https://github.com/OpenSourcePolitics/decidim", branch: "0.18-merge" +# Inside the development app, the relative require has to be one level up, as +# the Gemfile is copied to the development_app folder (almost) as is. +# Source: https://github.com/mainio/decidim-module-antivirus/blob/master/Gemfile +base_path = "" +base_path = "../" if File.basename(__dir__) == "development_app" +require_relative "#{base_path}lib/decidim/socio_demographic_authorization_handler/version" + +gem "decidim", git: "https://github.com/decidim/decidim", branch: Decidim::SocioDemographicAuthorizationHandler.decidim_version gem "decidim-socio_demographic_authorization_handler", path: "." -gem "bootsnap" -gem "puma", "~> 3.0" +gem "bootsnap", "~> 1.4" + +gem "puma", "~> 4.3.7" gem "uglifier", "~> 4.1" group :development, :test do - gem "byebug", "~> 10.0", platform: :mri + gem "byebug", "~> 11.0", platform: :mri + gem "simplecov", "~> 0.19.0" - gem "decidim-dev", git: "https://github.com/OpenSourcePolitics/decidim", branch: "0.18-merge" + gem "decidim-dev", git: "https://github.com/decidim/decidim", branch: Decidim::SocioDemographicAuthorizationHandler.decidim_version end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index 4df7d3c..6288bbc 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,223 +1,233 @@ GIT - remote: https://github.com/OpenSourcePolitics/decidim - revision: b3ee86331069afa4701043d616665588618af8c3 - branch: 0.18-merge + remote: https://github.com/decidim/decidim + revision: 81a3ea3531bcd7f3fb518451aa9a2139e7c37580 + branch: release/0.23-stable specs: - decidim (0.18.0) - decidim-accountability (= 0.18.0) - decidim-admin (= 0.18.0) - decidim-api (= 0.18.0) - decidim-assemblies (= 0.18.0) - decidim-blogs (= 0.18.0) - decidim-budgets (= 0.18.0) - decidim-comments (= 0.18.0) - decidim-core (= 0.18.0) - decidim-debates (= 0.18.0) - decidim-forms (= 0.18.0) - decidim-generators (= 0.18.0) - decidim-meetings (= 0.18.0) - decidim-pages (= 0.18.0) - decidim-participatory_processes (= 0.18.0) - decidim-proposals (= 0.18.0) - decidim-sortitions (= 0.18.0) - decidim-surveys (= 0.18.0) - decidim-system (= 0.18.0) - decidim-verifications (= 0.18.0) - decidim-accountability (0.18.0) - decidim-comments (= 0.18.0) - decidim-core (= 0.18.0) - kaminari (~> 1.0) + decidim (0.23.6) + decidim-accountability (= 0.23.6) + decidim-admin (= 0.23.6) + decidim-api (= 0.23.6) + decidim-assemblies (= 0.23.6) + decidim-blogs (= 0.23.6) + decidim-budgets (= 0.23.6) + decidim-comments (= 0.23.6) + decidim-core (= 0.23.6) + decidim-debates (= 0.23.6) + decidim-forms (= 0.23.6) + decidim-generators (= 0.23.6) + decidim-meetings (= 0.23.6) + decidim-pages (= 0.23.6) + decidim-participatory_processes (= 0.23.6) + decidim-proposals (= 0.23.6) + decidim-sortitions (= 0.23.6) + decidim-surveys (= 0.23.6) + decidim-system (= 0.23.6) + decidim-verifications (= 0.23.6) + decidim-accountability (0.23.6) + decidim-comments (= 0.23.6) + decidim-core (= 0.23.6) + kaminari (~> 1.2, >= 1.2.1) searchlight (~> 4.1) - decidim-admin (0.18.0) + decidim-admin (0.23.6) active_link_to (~> 1.0) - decidim-core (= 0.18.0) - devise (~> 4.6) + decidim-core (= 0.23.6) + devise (~> 4.7) devise-i18n (~> 1.2) devise_invitable (~> 1.7) jquery-rails (~> 4.3) - sassc (~> 1.12, >= 1.12.1) - sassc-rails (~> 1.3) - decidim-api (0.18.0) + sassc (~> 2.3.0) + sassc-rails (~> 2.1.2) + decidim-api (0.23.6) graphiql-rails (~> 1.4, < 1.5) - graphql (~> 1.6, < 1.8.11) + graphql (~> 1.9) rack-cors (~> 1.0) + redcarpet (~> 3.4) sprockets-es6 (~> 0.9.2) - decidim-assemblies (0.18.0) - decidim-core (= 0.18.0) - decidim-blogs (0.18.0) - decidim-admin (= 0.18.0) - decidim-comments (= 0.18.0) - decidim-core (= 0.18.0) - httparty (~> 0.16.0) + decidim-assemblies (0.23.6) + decidim-core (= 0.23.6) + decidim-blogs (0.23.6) + decidim-admin (= 0.23.6) + decidim-comments (= 0.23.6) + decidim-core (= 0.23.6) + httparty (~> 0.17) jquery-tmpl-rails (~> 1.1) - kaminari (~> 1.0) - decidim-budgets (0.18.0) - decidim-comments (= 0.18.0) - decidim-core (= 0.18.0) - kaminari (~> 1.0) + kaminari (~> 1.2, >= 1.2.1) + decidim-budgets (0.23.6) + decidim-comments (= 0.23.6) + decidim-core (= 0.23.6) + kaminari (~> 1.2, >= 1.2.1) searchlight (~> 4.1) - decidim-comments (0.18.0) - decidim-core (= 0.18.0) - jquery-rails (~> 4.0) - decidim-core (0.18.0) + decidim-comments (0.23.6) + decidim-core (= 0.23.6) + jquery-rails (~> 4.3) + redcarpet (~> 3.4) + decidim-core (0.23.6) active_link_to (~> 1.0) + anchored (>= 1.1.0) autoprefixer-rails (~> 8.0) batch-loader (~> 1.2) - carrierwave (~> 1.1) + browser (~> 2.7) + carrierwave (~> 1.3) cells-erb (~> 0.1.0) cells-rails (~> 0.0.9) - charlock_holmes (>= 0.7.6) + charlock_holmes (~> 0.7) date_validator (~> 0.9.0) - decidim-api (= 0.18.0) - devise (~> 4.6) + decidim-api (= 0.23.6) + devise (~> 4.7) devise-i18n (~> 1.2) - doorkeeper (~> 4.4) + diffy (~> 3.3) + doorkeeper (~> 5.1) doorkeeper-i18n (~> 4.0) etherpad-lite (~> 0.3) file_validators (~> 2.1) - foundation-rails (~> 6.4, < 6.5) + foundation-rails (~> 6.6, < 6.7) foundation_rails_helper (~> 3.0) - geocoder (~> 1.6.1) - hashdiff (~> 0.3.7) - invisible_captcha (~> 0.10.0) + geocoder (>= 1.5) + hashdiff (>= 0.4.0, < 2.0.0) + invisible_captcha (~> 0.12) jquery-rails (~> 4.3) - kaminari (~> 1.0) - loofah (~> 2.0, >= 2.2.1) - mini_magick (~> 4.8) + kaminari (~> 1.2, >= 1.2.1) + loofah (~> 2.3.1) + mini_magick (~> 4.9) mustache (~> 1.1.0) nobspw (~> 0.6.0) - omniauth (~> 1.6) - omniauth-facebook (~> 4.0) - omniauth-google-oauth2 (~> 0.5.0) + omniauth (~> 1.9) + omniauth-facebook (~> 5.0) + omniauth-google-oauth2 (~> 0.7) omniauth-rails_csrf_protection (~> 0.1) omniauth-twitter (~> 1.4) - paper_trail (~> 9.0) - pg (>= 0.18, < 2) - pg_search (~> 2.1, >= 2.1.0) - premailer-rails (~> 1.9) - rack (>= 2.0.6) - rack-attack (~> 5.2) - rails (>= 5.2, < 6.0.x) + paper_trail (~> 10.3) + pg (~> 1.1.4, < 2) + pg_search (~> 2.2) + premailer-rails (~> 1.10) + rack (>= 2.2.3) + rack-attack (~> 6.0) + rails (~> 5.2.6) rails-i18n (~> 5.0) rectify (~> 0.13.0) - redis (~> 4.0) - rubyzip (~> 1.2, >= 1.2.2) - sassc (~> 1.12, >= 1.12.1) - sassc-rails (~> 1.3) - social-share-button (~> 1.2) - spreadsheet (~> 1.1) + redis (~> 4.1) + request_store (~> 1.5.0) + rubyzip (~> 2.0) + sassc (~> 2.3.0) + sassc-rails (~> 2.1.2) + seven_zip_ruby (~> 1.3) + social-share-button (~> 1.2, >= 1.2.1) + spreadsheet (~> 1.2) sprockets (~> 3.7, < 4) sprockets-es6 (~> 0.9.2) - truncato (~> 0.7.10) - uglifier (~> 4.0) + truncato (~> 0.7) + uglifier (~> 4.1) valid_email2 (~> 2.1) wisper (~> 2.0) - decidim-debates (0.18.0) - decidim-comments (= 0.18.0) - decidim-core (= 0.18.0) - kaminari (~> 1.0) + decidim-debates (0.23.6) + decidim-comments (= 0.23.6) + decidim-core (= 0.23.6) + kaminari (~> 1.2, >= 1.2.1) searchlight (~> 4.1) - decidim-dev (0.18.0) - byebug (~> 10.0) - capybara (~> 3.0) + decidim-dev (0.23.6) + byebug (~> 11.0) + capybara (~> 3.24) db-query-matchers (~> 0.9.0) - decidim (= 0.18.0) - erb_lint (~> 0.0.22) + decidim (= 0.23.6) + erb_lint (~> 0.0.28) factory_bot_rails (~> 4.8) i18n-tasks (~> 0.9.18) - mdl (~> 0.4.0) - nokogiri (~> 1.8, >= 1.8.2) - puma (~> 3.11) + mdl (~> 0.5) + nokogiri (>= 1.10.8) + puma (>= 4.3) rails-controller-testing (~> 1.0) rspec-cells (~> 0.3.4) rspec-html-matchers (~> 0.9.1) rspec-rails (~> 3.7) rspec-retry (~> 0.6.2) rspec_junit_formatter (~> 0.3.0) - rubocop (~> 0.58.0) + rubocop (~> 0.71.0) + rubocop-rails (~> 2.0) rubocop-rspec (~> 1.21) - selenium-webdriver (~> 3.7) - simplecov (~> 0.17.1) + selenium-webdriver (~> 3.142) + simplecov (~> 0.19.0) + simplecov-cobertura (~> 1.3.1) system_test_html_screenshots (~> 0.1.1) - webmock (~> 3.0) + webmock (~> 3.6) wisper-rspec (~> 1.0) - decidim-forms (0.18.0) - decidim-core (= 0.18.0) - decidim-generators (0.18.0) - decidim-core (= 0.18.0) - decidim-meetings (0.18.0) + decidim-forms (0.23.6) + decidim-core (= 0.23.6) + wicked_pdf (~> 1.4) + wkhtmltopdf-binary (~> 0.12) + decidim-generators (0.23.6) + decidim-core (= 0.23.6) + decidim-meetings (0.23.6) cells-erb (~> 0.1.0) cells-rails (~> 0.0.9) - decidim-core (= 0.18.0) - decidim-forms (= 0.18.0) - httparty (~> 0.16.0) - icalendar (~> 2.4) + decidim-core (= 0.23.6) + decidim-forms (= 0.23.6) + httparty (~> 0.17) + icalendar (~> 2.5) jquery-tmpl-rails (~> 1.1) - kaminari (~> 1.0) + kaminari (~> 1.2, >= 1.2.1) searchlight (~> 4.1) - decidim-pages (0.18.0) - decidim-core (= 0.18.0) - decidim-participatory_processes (0.18.0) - decidim-core (= 0.18.0) - decidim-proposals (0.18.0) + decidim-pages (0.23.6) + decidim-core (= 0.23.6) + decidim-participatory_processes (0.23.6) + decidim-core (= 0.23.6) + decidim-proposals (0.23.6) acts_as_list (~> 0.9) cells-erb (~> 0.1.0) cells-rails (~> 0.0.9) - decidim-comments (= 0.18.0) - decidim-core (= 0.18.0) - diffy (~> 3.3) - doc2text (~> 0.4.0) - kaminari (~> 1.1) + decidim-comments (= 0.23.6) + decidim-core (= 0.23.6) + doc2text (~> 0.4.2) + kaminari (~> 1.2, >= 1.2.1) ransack (~> 2.1.1) redcarpet (~> 3.4) - decidim-sortitions (0.18.0) - decidim-admin (= 0.18.0) - decidim-comments (= 0.18.0) - decidim-core (= 0.18.0) - decidim-proposals (= 0.18.0) - decidim-surveys (0.18.0) - decidim-core (= 0.18.0) - decidim-forms (= 0.18.0) - decidim-system (0.18.0) + decidim-sortitions (0.23.6) + decidim-admin (= 0.23.6) + decidim-comments (= 0.23.6) + decidim-core (= 0.23.6) + decidim-proposals (= 0.23.6) + decidim-surveys (0.23.6) + decidim-core (= 0.23.6) + decidim-forms (= 0.23.6) + decidim-system (0.23.6) active_link_to (~> 1.0) - decidim-core (= 0.18.0) - devise (~> 4.6) + decidim-core (= 0.23.6) + devise (~> 4.7) devise-i18n (~> 1.2) devise_invitable (~> 1.7) jquery-rails (~> 4.3) - sassc (~> 1.12, >= 1.12.1) - sassc-rails (~> 1.3) - decidim-verifications (0.18.0) - decidim-core (= 0.18.0) + sassc (~> 2.3.0) + sassc-rails (~> 2.1.2) + decidim-verifications (0.23.6) + decidim-core (= 0.23.6) PATH remote: . specs: - decidim-socio_demographic_authorization_handler (0.18.0) - decidim-core (= 0.18.0) + decidim-socio_demographic_authorization_handler (0.23.6) + decidim-core (= 0.23.6) GEM remote: https://rubygems.org/ specs: - actioncable (5.2.8) - actionpack (= 5.2.8) + actioncable (5.2.6) + actionpack (= 5.2.6) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.8) - actionpack (= 5.2.8) - actionview (= 5.2.8) - activejob (= 5.2.8) + actionmailer (5.2.6) + actionpack (= 5.2.6) + actionview (= 5.2.6) + activejob (= 5.2.6) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.8) - actionview (= 5.2.8) - activesupport (= 5.2.8) + actionpack (5.2.6) + actionview (= 5.2.6) + activesupport (= 5.2.6) rack (~> 2.0, >= 2.0.8) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.8) - activesupport (= 5.2.8) + actionview (5.2.6) + activesupport (= 5.2.6) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -225,20 +235,20 @@ GEM active_link_to (1.0.5) actionpack addressable - activejob (5.2.8) - activesupport (= 5.2.8) + activejob (5.2.6) + activesupport (= 5.2.6) globalid (>= 0.3.6) - activemodel (5.2.8) - activesupport (= 5.2.8) - activerecord (5.2.8) - activemodel (= 5.2.8) - activesupport (= 5.2.8) + activemodel (5.2.6) + activesupport (= 5.2.6) + activerecord (5.2.6) + activemodel (= 5.2.6) + activesupport (= 5.2.6) arel (>= 9.0) - activestorage (5.2.8) - actionpack (= 5.2.8) - activerecord (= 5.2.8) + activestorage (5.2.6) + actionpack (= 5.2.6) + activerecord (= 5.2.6) marcel (~> 1.0.0) - activesupport (5.2.8) + activesupport (5.2.6) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -247,6 +257,7 @@ GEM activerecord (>= 3.0) addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) + anchored (1.1.0) arel (9.0.0) ast (2.4.2) autoprefixer-rails (8.6.5) @@ -260,7 +271,7 @@ GEM babel-source (>= 4.0, < 6) execjs (~> 2.0) batch-loader (1.5.0) - bcrypt (3.1.18) + bcrypt (3.1.16) better_html (1.0.16) actionview (>= 4.0) activesupport (>= 4.0) @@ -270,10 +281,11 @@ GEM parser (>= 2.4) smart_properties bindex (0.8.1) - bootsnap (1.11.1) - msgpack (~> 1.2) + bootsnap (1.8.1) + msgpack (~> 1.0) + browser (2.7.1) builder (3.2.4) - byebug (10.0.2) + byebug (11.1.3) capybara (3.35.3) addressable mini_mime (>= 0.1.3) @@ -299,6 +311,8 @@ GEM actionpack (>= 3.0) cells (>= 4.1.6, < 5.0.0) charlock_holmes (0.7.7) + chef-utils (17.4.25) + concurrent-ruby childprocess (3.0.0) coercible (1.0.0) descendants_tracker (~> 0.0.1) @@ -309,11 +323,11 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.10) + concurrent-ruby (1.1.9) crack (0.4.5) rexml crass (1.0.6) - css_parser (1.11.0) + css_parser (1.10.0) addressable date_validator (0.9.0) activemodel @@ -326,27 +340,27 @@ GEM declarative-option (0.1.0) descendants_tracker (0.0.4) thread_safe (~> 0.3, >= 0.3.1) - devise (4.8.1) + devise (4.8.0) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) - devise-i18n (1.10.2) + devise-i18n (1.10.0) devise (>= 4.8.0) devise_invitable (1.7.5) actionmailer (>= 4.1.0) devise (>= 4.0.0) - diff-lcs (1.5.0) + diff-lcs (1.4.4) diffy (3.4.0) - doc2text (0.4.1) - nokogiri (~> 1.8, >= 1.8.2) - rubyzip (~> 1.2, >= 1.2.2) + doc2text (0.4.3) + nokogiri (~> 1.11.1) + rubyzip (~> 2.3.0) docile (1.4.0) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) - doorkeeper (4.4.3) - railties (>= 4.2) + doorkeeper (5.5.2) + railties (>= 5) doorkeeper-i18n (4.0.1) equalizer (0.0.11) erb_lint (0.0.37) @@ -360,7 +374,7 @@ GEM erbse (0.1.4) temple erubi (1.10.0) - etherpad-lite (0.3.1) + etherpad-lite (0.3.0) rest-client (>= 1.6) execjs (2.8.1) factory_bot (4.11.1) @@ -370,36 +384,32 @@ GEM railties (>= 3.0.0) faker (1.9.6) i18n (>= 0.7) - faraday (1.10.0) + faraday (1.7.0) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) - faraday-httpclient (~> 1.0) - faraday-multipart (~> 1.0) + faraday-httpclient (~> 1.0.1) faraday-net_http (~> 1.0) - faraday-net_http_persistent (~> 1.0) + faraday-net_http_persistent (~> 1.1) faraday-patron (~> 1.0) faraday-rack (~> 1.0) - faraday-retry (~> 1.0) + multipart-post (>= 1.2, < 3) ruby2_keywords (>= 0.0.4) faraday-em_http (1.0.0) faraday-em_synchrony (1.0.0) faraday-excon (1.1.0) faraday-httpclient (1.0.1) - faraday-multipart (1.0.3) - multipart-post (>= 1.2, < 3) faraday-net_http (1.0.1) faraday-net_http_persistent (1.2.0) faraday-patron (1.0.0) faraday-rack (1.0.0) - faraday-retry (1.0.3) - ffi (1.9.25) + ffi (1.15.3) file_validators (2.3.0) activemodel (>= 3.2) mime-types (>= 1.0) - foundation-rails (6.4.3.0) + foundation-rails (6.6.2.0) railties (>= 3.1.0) - sass (>= 3.3.0, < 3.5) + sass (>= 3.3.0) sprockets-es6 (>= 0.9.0) foundation_rails_helper (3.0.0) actionpack (>= 4.1, < 6.0) @@ -408,26 +418,26 @@ GEM railties (>= 4.1, < 6.0) tzinfo (~> 1.2, >= 1.2.2) geocoder (1.6.7) - globalid (1.0.0) + globalid (0.5.2) activesupport (>= 5.0) graphiql-rails (1.4.11) railties sprockets-rails - graphql (1.8.10) - hashdiff (0.3.9) - hashie (5.0.0) + graphql (1.12.15) + hashdiff (1.0.1) + hashie (4.1.0) highline (2.0.3) html_tokenizer (0.0.7) htmlentities (4.3.4) http-accept (1.7.0) http-cookie (1.0.4) domain_name (~> 0.5) - httparty (0.16.4) + httparty (0.18.1) mime-types (~> 3.0) multi_xml (>= 0.5.2) - i18n (1.10.0) + i18n (1.8.10) concurrent-ruby (~> 1.0) - i18n-tasks (0.9.36) + i18n-tasks (0.9.34) activesupport (>= 4.0.2) ast (>= 2.1.0) erubi @@ -439,9 +449,9 @@ GEM terminal-table (>= 1.5.1) icalendar (2.7.1) ice_cube (~> 0.16) - ice_cube (0.16.4) + ice_cube (0.16.3) ice_nine (0.11.2) - invisible_captcha (0.10.0) + invisible_captcha (0.13.0) rails (>= 3.2.0) jaro_winkler (1.5.4) jquery-rails (4.4.0) @@ -450,54 +460,59 @@ GEM thor (>= 0.14, < 2.0) jquery-tmpl-rails (1.1.0) rails (>= 3.1.0) - json (2.6.2) - jwt (2.3.0) - kaminari (1.2.2) + jwt (2.2.3) + kaminari (1.2.1) activesupport (>= 4.1.0) - kaminari-actionview (= 1.2.2) - kaminari-activerecord (= 1.2.2) - kaminari-core (= 1.2.2) - kaminari-actionview (1.2.2) + kaminari-actionview (= 1.2.1) + kaminari-activerecord (= 1.2.1) + kaminari-core (= 1.2.1) + kaminari-actionview (1.2.1) actionview - kaminari-core (= 1.2.2) - kaminari-activerecord (1.2.2) + kaminari-core (= 1.2.1) + kaminari-activerecord (1.2.1) activerecord - kaminari-core (= 1.2.2) - kaminari-core (1.2.2) - kramdown (1.17.0) + kaminari-core (= 1.2.1) + kaminari-core (1.2.1) + kramdown (2.3.1) + rexml + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) launchy (2.5.0) addressable (~> 2.7) - letter_opener (1.8.1) - launchy (>= 2.2, < 3) - letter_opener_web (1.4.1) + letter_opener (1.7.0) + launchy (~> 2.2) + letter_opener_web (1.4.0) actionmailer (>= 3.2) letter_opener (~> 1.0) railties (>= 3.2) - listen (3.7.1) + listen (3.7.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.18.0) + loofah (2.3.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) - marcel (1.0.2) - mdl (0.4.0) - kramdown (~> 1.12, >= 1.12.0) - mixlib-cli (~> 1.7, >= 1.7.0) - mixlib-config (~> 2.2, >= 2.2.1) + marcel (1.0.1) + mdl (0.11.0) + kramdown (~> 2.3) + kramdown-parser-gfm (~> 1.1) + mixlib-cli (~> 2.1, >= 2.1.1) + mixlib-config (>= 2.2.1, < 4) + mixlib-shellout method_source (1.0.0) - mime-types (3.4.1) + mime-types (3.3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2022.0105) + mime-types-data (3.2021.0704) mini_magick (4.11.0) - mini_mime (1.1.2) - mini_portile2 (2.6.1) - minitest (5.15.0) - mixlib-cli (1.7.0) - mixlib-config (2.2.18) + mini_mime (1.1.1) + minitest (5.14.4) + mixlib-cli (2.1.8) + mixlib-config (3.0.9) tomlrb - msgpack (1.5.1) + mixlib-shellout (3.2.5) + chef-utils + msgpack (1.4.2) multi_json (1.15.0) multi_xml (0.6.0) multipart-post (2.1.1) @@ -505,12 +520,13 @@ GEM netrc (0.11.0) nio4r (2.5.8) nobspw (0.6.2) - nokogiri (1.12.5) - mini_portile2 (~> 2.6.1) + nokogiri (1.11.7-x86_64-darwin) + racc (~> 1.4) + nokogiri (1.11.7-x86_64-linux) racc (~> 1.4) - oauth (0.5.10) - oauth2 (1.4.9) - faraday (>= 0.17.3, < 3.0) + oauth (0.5.6) + oauth2 (1.4.7) + faraday (>= 0.8, < 2.0) jwt (>= 1.0, < 3.0) multi_json (~> 1.3) multi_xml (~> 0.5) @@ -518,16 +534,17 @@ GEM omniauth (1.9.1) hashie (>= 3.4.6) rack (>= 1.6.2, < 3) - omniauth-facebook (4.0.0) + omniauth-facebook (5.0.0) omniauth-oauth2 (~> 1.2) - omniauth-google-oauth2 (0.5.4) - jwt (>= 1.5) - omniauth (>= 1.1.1) - omniauth-oauth2 (>= 1.5) + omniauth-google-oauth2 (0.8.2) + jwt (>= 2.0) + oauth2 (~> 1.1) + omniauth (~> 1.1) + omniauth-oauth2 (>= 1.6) omniauth-oauth (1.2.0) oauth omniauth (>= 1.0, < 3) - omniauth-oauth2 (1.7.2) + omniauth-oauth2 (1.7.1) oauth2 (~> 1.4) omniauth (>= 1.9, < 3) omniauth-rails_csrf_protection (0.1.2) @@ -537,19 +554,16 @@ GEM omniauth-oauth (~> 1.1) rack orm_adapter (0.5.0) - paper_trail (9.2.0) - activerecord (>= 4.2, < 5.3) - paper_trail-association_tracking (< 2) + paper_trail (10.3.1) + activerecord (>= 4.2) request_store (~> 1.1) - paper_trail-association_tracking (1.1.1) - parallel (1.22.1) - parser (3.1.2.0) + parallel (1.20.1) + parser (3.0.2.0) ast (~> 2.4.1) - pg (1.3.5) + pg (1.1.4) pg_search (2.3.5) activerecord (>= 5.2) activesupport (>= 5.2) - powerpack (0.1.3) premailer (1.15.0) addressable css_parser (>= 1.6.0) @@ -557,28 +571,29 @@ GEM premailer-rails (1.11.1) actionmailer (>= 3) premailer (~> 1.7, >= 1.7.9) - public_suffix (4.0.7) - puma (3.12.6) - racc (1.6.0) + public_suffix (4.0.6) + puma (4.3.8) + nio4r (~> 2.0) + racc (1.5.2) rack (2.2.3) - rack-attack (5.4.2) + rack-attack (6.5.0) rack (>= 1.0, < 3) rack-cors (1.1.1) rack (>= 2.0.0) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.8) - actioncable (= 5.2.8) - actionmailer (= 5.2.8) - actionpack (= 5.2.8) - actionview (= 5.2.8) - activejob (= 5.2.8) - activemodel (= 5.2.8) - activerecord (= 5.2.8) - activestorage (= 5.2.8) - activesupport (= 5.2.8) + rails (5.2.6) + actioncable (= 5.2.6) + actionmailer (= 5.2.6) + actionpack (= 5.2.6) + actionview (= 5.2.6) + activejob (= 5.2.6) + activemodel (= 5.2.6) + activerecord (= 5.2.6) + activestorage (= 5.2.6) + activesupport (= 5.2.6) bundler (>= 1.3.0) - railties (= 5.2.8) + railties (= 5.2.6) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) @@ -592,20 +607,20 @@ GEM rails-i18n (5.1.3) i18n (>= 0.7, < 2) railties (>= 5.0, < 6) - railties (5.2.8) - actionpack (= 5.2.8) - activesupport (= 5.2.8) + railties (5.2.6) + actionpack (= 5.2.6) + activesupport (= 5.2.6) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) - rainbow (3.1.1) + rainbow (3.0.0) rake (13.0.6) ransack (2.1.1) actionpack (>= 5.0) activerecord (>= 5.0) activesupport (>= 5.0) i18n - rb-fsevent (0.11.1) + rb-fsevent (0.11.0) rb-inotify (0.10.1) ffi (~> 1.0) rectify (0.13.0) @@ -615,9 +630,9 @@ GEM virtus (~> 1.0.5) wisper (>= 1.6.1) redcarpet (3.5.1) - redis (4.6.0) - regexp_parser (2.4.0) - request_store (1.5.1) + redis (4.4.0) + regexp_parser (2.1.1) + request_store (1.5.0) rack (>= 1.4) responders (3.0.1) actionpack (>= 5.0) @@ -632,7 +647,7 @@ GEM rspec-core (~> 3.9.0) rspec-expectations (~> 3.9.0) rspec-mocks (~> 3.9.0) - rspec-cells (0.3.7) + rspec-cells (0.3.6) cells (>= 4.0.0, < 6.0.0) rspec-rails (< 6.0) rspec-core (3.9.3) @@ -659,44 +674,50 @@ GEM rspec-support (3.9.4) rspec_junit_formatter (0.3.0) rspec-core (>= 2, < 4, != 2.12.0) - rubocop (0.58.2) + rubocop (0.71.0) jaro_winkler (~> 1.5.1) parallel (~> 1.10) - parser (>= 2.5, != 2.5.1.1) - powerpack (~> 0.1) + parser (>= 2.6) rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - rubocop-rspec (1.30.0) - rubocop (>= 0.58.0) + unicode-display_width (>= 1.4.0, < 1.7) + rubocop-rails (2.0.1) + rack (>= 1.1) + rubocop (>= 0.70.0) + rubocop-rspec (1.41.0) + rubocop (>= 0.68.1) ruby-ole (1.2.12.2) ruby-progressbar (1.11.0) ruby2_keywords (0.0.5) - rubyzip (1.3.0) - sass (3.4.25) - sassc (1.12.1) - ffi (~> 1.9.6) - sass (>= 3.3.0) - sassc-rails (1.3.0) + rubyzip (2.3.2) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sassc (2.3.0) + ffi (~> 1.9) + sassc-rails (2.1.2) railties (>= 4.0.0) - sass - sassc (~> 1.9) - sprockets (> 2.11) + sassc (>= 2.0) + sprockets (> 3.0) sprockets-rails tilt searchlight (4.1.0) selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) - simplecov (0.17.1) + seven_zip_ruby (1.3.0) + simplecov (0.19.1) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) - smart_properties (1.17.0) + simplecov-html (~> 0.11) + simplecov-cobertura (1.3.1) + simplecov (~> 0.8) + simplecov-html (0.12.3) + smart_properties (1.16.0) social-share-button (1.2.4) coffee-rails - spreadsheet (1.3.0) + spreadsheet (1.2.9) ruby-ole spring (2.1.1) spring-watcher-listen (2.0.1) @@ -709,17 +730,17 @@ GEM babel-source (>= 5.8.11) babel-transpiler sprockets (>= 3.0.0) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) + sprockets-rails (3.2.2) + actionpack (>= 4.0) + activesupport (>= 4.0) sprockets (>= 3.0.0) ssrf_filter (1.0.7) system_test_html_screenshots (0.1.2) actionpack (>= 5.2, < 6.0.a) temple (0.8.2) - terminal-table (3.0.2) + terminal-table (3.0.1) unicode-display_width (>= 1.1.1, < 3) - thor (1.2.1) + thor (1.1.0) thread_safe (0.3.6) tilt (2.0.10) tomlrb (2.0.1) @@ -733,8 +754,8 @@ GEM execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext - unf_ext (0.0.8.1) - unicode-display_width (1.8.0) + unf_ext (0.0.7.7) + unicode-display_width (1.6.1) valid_email2 (2.3.1) activemodel (>= 3.2) mail (~> 2.5) @@ -750,38 +771,43 @@ GEM activemodel (>= 5.0) bindex (>= 0.4.0) railties (>= 5.0) - webmock (3.5.1) - addressable (>= 2.3.6) + webmock (3.14.0) + addressable (>= 2.8.0) crack (>= 0.3.2) - hashdiff + hashdiff (>= 0.4.0, < 2.0.0) websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) + wicked_pdf (1.4.0) + activesupport wisper (2.0.1) wisper-rspec (1.1.0) + wkhtmltopdf-binary (0.12.6.5) xpath (3.2.0) nokogiri (~> 1.8) PLATFORMS - ruby + x86_64-darwin-19 + x86_64-linux DEPENDENCIES - bootsnap - byebug (~> 10.0) + bootsnap (~> 1.4) + byebug (~> 11.0) decidim! decidim-dev! decidim-socio_demographic_authorization_handler! faker (~> 1.9) letter_opener_web (~> 1.3) listen (~> 3.1) - puma (~> 3.0) + puma (~> 4.3.7) + simplecov (~> 0.19.0) spring (~> 2.0) spring-watcher-listen (~> 2.0) uglifier (~> 4.1) web-console (~> 3.5) RUBY VERSION - ruby 2.5.3p105 + ruby 2.6.6p146 BUNDLED WITH - 2.0.2 + 2.2.18 diff --git a/README.md b/README.md index 93fc4ab..4032402 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Space. Add this line to your application's Gemfile: ```ruby -gem 'decidim-socio_demographic_authorization_handler +gem "decidim-socio_demographic_authorization_handler", git: "https://github.com/OpenSourcePolitics/decidim-module-socio_demographic_authorization_handler.git", branch: "develop" ``` And then execute: @@ -21,6 +21,17 @@ And then execute: bundle ``` +Now the module should be added to your current Decidim project. + +### Override the authorization form + +You can override the current form for adding or creating specific fields according to your needs. To do so, we will have to override the form partial and the socio_demographic service + +First in your decidim project, create a new file `app/views/socio_demographic_authorization/_form.html.erb`. This file contains the form partial visible when user fill the authorization form. + +Then, manage the newly created form with the service : `app/services/socio_demographic_authorization_handler.rb`. This file contains the form validations and attributes. + + ## Contributing See [Decidim](https://github.com/decidim/decidim). diff --git a/config/i18n-tasks.yml b/config/i18n-tasks.yml index 4b968cc..c7b69b9 100644 --- a/config/i18n-tasks.yml +++ b/config/i18n-tasks.yml @@ -4,9 +4,10 @@ base_locale: en locales: [en, fr] ignore_unused: - - "decidim.components.socio_demographic_authorization_handler.name" - - "decidim.authorization_handlers.socio_demographic_authorization_handler.name" - - "decidim.authorization_handlers.socio_demographic_authorization_handler.explanation" + - decidim.components.socio_demographic_authorization_handler.name + - decidim.authorization_handlers.socio_demographic_authorization_handler.name + - decidim.authorization_handlers.socio_demographic_authorization_handler.explanation + - decidim.verifications.authorizations.first_login.actions.socio_demographic_authorization_handler ignore_missing: - decidim.participatory_processes.scopes.global diff --git a/config/locales/en.yml b/config/locales/en.yml index 4cf4d32..e9ae7ef 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -12,6 +12,10 @@ en: verifications: age_slice: blank_option: Please specify an age slice + authorizations: + first_login: + actions: + socio_demographic_authorization_handler: Verify with Additional informations genders: blank_option: Please specify a gender man: Man diff --git a/config/locales/fr.yml b/config/locales/fr.yml index 5b11861..c3cfa66 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -12,6 +12,10 @@ fr: verifications: age_slice: blank_option: Veuillez renseigner une tranche d'âge + authorizations: + first_login: + actions: + socio_demographic_authorization_handler: Vérifier avec Données personnelles genders: blank_option: Veuillez renseigner un genre man: Homme diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 1036398..849baf5 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -10,6 +10,10 @@ nl: gender: Gender scope_id: Wijk verifications: + authorizations: + first_login: + actions: + socio_demographic_authorization_handler: Verify with Additional informations age_slice: blank_option: Vul een leeftijdsgroep in genders: diff --git a/decidim-socio_demographic_authorization_handler.gemspec b/decidim-socio_demographic_authorization_handler.gemspec index 2298e4f..d4e12b6 100644 --- a/decidim-socio_demographic_authorization_handler.gemspec +++ b/decidim-socio_demographic_authorization_handler.gemspec @@ -10,7 +10,7 @@ Gem::Specification.new do |s| s.email = ["fardeauarmand@gmail.com"] s.license = "AGPL-3.0" s.homepage = "https://github.com/decidim/decidim-module-socio_demographic_authorization_handler" - s.required_ruby_version = ">= 2.5" + s.required_ruby_version = ">= 2.6" s.name = "decidim-socio_demographic_authorization_handler" s.summary = "A decidim socio_demographic_authorization_handler module" diff --git a/lib/decidim/socio_demographic_authorization_handler/version.rb b/lib/decidim/socio_demographic_authorization_handler/version.rb index 788ccbf..e436a85 100644 --- a/lib/decidim/socio_demographic_authorization_handler/version.rb +++ b/lib/decidim/socio_demographic_authorization_handler/version.rb @@ -4,7 +4,11 @@ module Decidim # This holds the decidim-meetings version. module SocioDemographicAuthorizationHandler def self.version - "0.18.0" + "0.23.6" + end + + def self.decidim_version + "release/0.23-stable" end end end diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..ebbc2b7 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "decidim-module-socio_demographic_authorization_handler", + "lockfileVersion": 2, + "requires": true, + "packages": {} +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/package.json @@ -0,0 +1 @@ +{} diff --git a/spec/i18n_spec.rb b/spec/i18n_spec.rb index 7bd32ef..4a05e6d 100644 --- a/spec/i18n_spec.rb +++ b/spec/i18n_spec.rb @@ -2,26 +2,31 @@ require "i18n/tasks" -RSpec.describe "I18n" do - let(:i18n) { I18n::Tasks::BaseTask.new } +describe "I18n sanity" do + let(:locales) do + ENV["ENFORCED_LOCALES"].presence || "en" + end + + let(:i18n) { I18n::Tasks::BaseTask.new(locales: locales.split(",")) } let(:missing_keys) { i18n.missing_keys } let(:unused_keys) { i18n.unused_keys } + let(:non_normalized_paths) { i18n.non_normalized_paths } it "does not have missing keys" do - expect(missing_keys).to be_empty, - "Missing #{missing_keys.leaves.count} i18n keys, run `i18n-tasks missing' to show them" + expect(missing_keys).to be_empty, "#{missing_keys.inspect} are missing" end it "does not have unused keys" do - expect(unused_keys).to be_empty, - "#{unused_keys.leaves.count} unused i18n keys, run `i18n-tasks unused' to show them" + expect(unused_keys).to be_empty, "#{unused_keys.inspect} are unused" end - it "files are normalized" do - non_normalized = i18n.non_normalized_paths - error_message = "The following files need to be normalized:\n" \ - "#{non_normalized.map { |path| " #{path}" }.join("\n")}\n" \ - "Please run `i18n-tasks normalize` to fix" - expect(non_normalized).to be_empty, error_message + unless ENV["SKIP_NORMALIZATION"] + it "is normalized" do + error_message = "The following files need to be normalized:\n" \ + "#{non_normalized_paths.map { |path| " #{path}" }.join("\n")}\n" \ + "Please run `bundle exec i18n-tasks normalize --locales #{locales}` to fix them" + + expect(non_normalized_paths).to be_empty, error_message + end end end diff --git a/spec/system/authentication_spec.rb b/spec/system/authentication_spec.rb index 690b2b2..6347720 100644 --- a/spec/system/authentication_spec.rb +++ b/spec/system/authentication_spec.rb @@ -17,13 +17,13 @@ find(".sign-up-link").click within ".new_user" do - fill_in :user_email, with: "user@example.org" - fill_in :user_name, with: "Responsible Citizen" - fill_in :user_nickname, with: "responsible" - fill_in :user_password, with: "DfyvHn425mYAy2HL" - fill_in :user_password_confirmation, with: "DfyvHn425mYAy2HL" - check :user_tos_agreement - check :user_newsletter + fill_in :registration_user_email, with: "user@example.org" + fill_in :registration_user_name, with: "Responsible Citizen" + fill_in :registration_user_nickname, with: "responsible" + fill_in :registration_user_password, with: "DfyvHn425mYAy2HL" + fill_in :registration_user_password_confirmation, with: "DfyvHn425mYAy2HL" + check :registration_user_tos_agreement + check :registration_user_newsletter find("*[type=submit]").click end @@ -31,19 +31,45 @@ end end + context "when using another langage" do + before do + within_language_menu do + click_link "Castellano" + end + end + + it "keeps the locale settings" do + find(".sign-up-link").click + + within ".new_user" do + fill_in :registration_user_email, with: "user@example.org" + fill_in :registration_user_name, with: "Responsible Citizen" + fill_in :registration_user_nickname, with: "responsible" + fill_in :registration_user_password, with: "DfyvHn425mYAy2HL" + fill_in :registration_user_password_confirmation, with: "DfyvHn425mYAy2HL" + check :registration_user_tos_agreement + check :registration_user_newsletter + find("*[type=submit]").click + end + + expect(page).to have_content("¡Bienvenida! Te has registrado con éxito.") + expect(last_user.locale).to eq("es") + end + end + context "when being a robot" do it "denies the sign up" do find(".sign-up-link").click within ".new_user" do page.execute_script("$($('.new_user > div > input')[0]).val('Ima robot :D')") - fill_in :user_email, with: "user@example.org" - fill_in :user_name, with: "Responsible Citizen" - fill_in :user_nickname, with: "responsible" - fill_in :user_password, with: "DfyvHn425mYAy2HL" - fill_in :user_password_confirmation, with: "DfyvHn425mYAy2HL" - check :user_tos_agreement - check :user_newsletter + fill_in :registration_user_email, with: "user@example.org" + fill_in :registration_user_name, with: "Responsible Citizen" + fill_in :registration_user_nickname, with: "responsible" + fill_in :registration_user_password, with: "DfyvHn425mYAy2HL" + fill_in :registration_user_password_confirmation, with: "DfyvHn425mYAy2HL" + check :registration_user_tos_agreement + check :registration_user_newsletter find("*[type=submit]").click end @@ -119,7 +145,7 @@ expect(page).to have_content("Please complete your profile") within ".new_user" do - fill_in :user_email, with: "user@from-twitter.com" + fill_in :registration_user_email, with: "user@from-twitter.com" find("*[type=submit]").click end end @@ -135,7 +161,7 @@ expect(page).to have_content("Please complete your profile") within ".new_user" do - fill_in :user_email, with: "user@from-twitter.com" + fill_in :registration_user_email, with: "user@from-twitter.com" find("*[type=submit]").click end @@ -247,7 +273,7 @@ visit decidim.new_user_confirmation_path within ".new_user" do - fill_in :user_email, with: user.email + fill_in :confirmation_user_email, with: user.email perform_enqueued_jobs { find("*[type=submit]").click } end @@ -264,14 +290,25 @@ find(".sign-in-link").click within ".new_user" do - fill_in :user_email, with: user.email - fill_in :user_password, with: "DfyvHn425mYAy2HL" + fill_in :session_user_email, with: user.email + fill_in :session_user_password, with: "DfyvHn425mYAy2HL" find("*[type=submit]").click end expect(page).to have_content("Signed in successfully") expect(page).to have_content(user.name) end + + it "caches the omniauth buttons correctly with different languages", :caching do + find(".sign-in-link").click + expect(page).to have_content("Sign in with Facebook") + + within_language_menu do + click_link "Català" + end + + expect(page).to have_content("Inicia sessió amb Facebook") + end end describe "Forgot password" do @@ -279,7 +316,7 @@ visit decidim.new_user_password_path within ".new_user" do - fill_in :user_email, with: user.email + fill_in :password_user_email, with: user.email perform_enqueued_jobs { find("*[type=submit]").click } end @@ -297,8 +334,8 @@ visit last_email_link within ".new_user" do - fill_in :user_password, with: "DfyvHn425mYAy2HL" - fill_in :user_password_confirmation, with: "DfyvHn425mYAy2HL" + fill_in :password_user_password, with: "DfyvHn425mYAy2HL" + fill_in :password_user_password_confirmation, with: "DfyvHn425mYAy2HL" find("*[type=submit]").click end @@ -314,8 +351,7 @@ end it "signs out the user" do - within ".topbar__user__logged" do - find("ul").hover + within_user_menu do find(".sign-out-link").click end @@ -323,6 +359,95 @@ expect(page).to have_no_content(user.name) end end + + context "with lockable account" do + Devise.maximum_attempts = 3 + let!(:maximum_attempts) { Devise.maximum_attempts } + + describe "when attempting to login with failing password" do + describe "before locking" do + before do + visit decidim.root_path + find(".sign-in-link").click + + (maximum_attempts - 2).times do + within ".new_user" do + fill_in :session_user_email, with: user.email + fill_in :session_user_password, with: "not-the-pasword" + find("*[type=submit]").click + end + end + end + + it "shows the last attempt warning before locking the account" do + within ".new_user" do + fill_in :session_user_email, with: user.email + fill_in :session_user_password, with: "not-the-pasword" + find("*[type=submit]").click + end + + expect(page).to have_content("You have one more attempt before your account is locked.") + end + end + + describe "locks the account" do + before do + visit decidim.root_path + find(".sign-in-link").click + + (maximum_attempts - 1).times do + within ".new_user" do + fill_in :session_user_email, with: user.email + fill_in :session_user_password, with: "not-the-pasword" + find("*[type=submit]").click + end + end + end + + it "when reached maximum failed attempts" do + within ".new_user" do + fill_in :session_user_email, with: user.email + fill_in :session_user_password, with: "not-the-pasword" + perform_enqueued_jobs { find("*[type=submit]").click } + end + + expect(page).to have_content("Your account is locked.") + expect(emails.count).to eq(1) + end + end + end + + describe "Resend unlock instructions email" do + before do + user.lock_access! + + visit decidim.new_user_unlock_path + end + + it "resends the unlock instructions" do + within ".new_user" do + fill_in :unlock_user_email, with: user.email + perform_enqueued_jobs { find("*[type=submit]").click } + end + + expect(page).to have_content("You will receive an email with instructions for how to unlock your account in a few minutes.") + expect(emails.count).to eq(1) + end + end + + describe "Unlock account" do + before do + user.lock_access! + perform_enqueued_jobs { user.send_unlock_instructions } + end + + it "unlocks the user account" do + visit last_email_link + + expect(page).to have_content("Your account has been successfully unlocked. Please sign in to continue") + end + end + end end context "when a user is already registered with a social provider" do @@ -405,13 +530,13 @@ find(".sign-up-link").click within ".new_user" do - fill_in :user_email, with: user.email - fill_in :user_name, with: "Responsible Citizen" - fill_in :user_nickname, with: "responsible" - fill_in :user_password, with: "DfyvHn425mYAy2HL" - fill_in :user_password_confirmation, with: "DfyvHn425mYAy2HL" - check :user_tos_agreement - check :user_newsletter + fill_in :registration_user_email, with: user.email + fill_in :registration_user_name, with: "Responsible Citizen" + fill_in :registration_user_nickname, with: "responsible" + fill_in :registration_user_password, with: "DfyvHn425mYAy2HL" + fill_in :registration_user_password_confirmation, with: "DfyvHn425mYAy2HL" + check :registration_user_tos_agreement + check :registration_user_newsletter find("*[type=submit]").click end @@ -472,8 +597,8 @@ find(".sign-in-link").click within ".new_user" do - fill_in :user_email, with: user.email - fill_in :user_password, with: "DfyvHn425mYAy2HL" + fill_in :session_user_email, with: user.email + fill_in :session_user_password, with: "DfyvHn425mYAy2HL" find("*[type=submit]").click end diff --git a/spec/system/authorizations_spec.rb b/spec/system/authorizations_spec.rb index fdf62eb..26a8dd4 100644 --- a/spec/system/authorizations_spec.rb +++ b/spec/system/authorizations_spec.rb @@ -20,8 +20,8 @@ find(".sign-in-link").click within "form.new_user" do - fill_in :user_email, with: user.email - fill_in :user_password, with: "password1234" + fill_in :session_user_email, with: user.email + fill_in :session_user_password, with: "password1234" find("*[type=submit]").click end end @@ -29,7 +29,7 @@ it "redirects the user to the authorization form after the first sign in" do fill_in "Document number", with: "123456789X" page.execute_script("$('#authorization_handler_birthday').focus()") - page.find(".datepicker-dropdown .day", text: "12").click + page.find(".datepicker-dropdown .day:not(.new)", text: "12").click click_button "Send" expect(page).to have_content("You've been successfully authorized") @@ -43,15 +43,15 @@ end context "when multiple authorizations have been configured", with_authorization_workflows: %w(dummy_authorization_handler dummy_authorization_workflow) do - let(:authorizations) { %w(dummy_authorization_handler dummy_authorization_workflow) } + let(:authorizations) { %w(dummy_authorization_handler dummy_authorization_workflow socio_demographic_authorization_handler) } before do visit decidim.root_path find(".sign-in-link").click within "form.new_user" do - fill_in :user_email, with: user.email - fill_in :user_password, with: "password1234" + fill_in :session_user_email, with: user.email + fill_in :session_user_password, with: "password1234" find("*[type=submit]").click end end @@ -84,7 +84,7 @@ fill_in "Document number", with: "123456789X" page.execute_script("$('#authorization_handler_birthday').focus()") - page.find(".datepicker-dropdown .day", text: "12").click + page.find(".datepicker-dropdown .datepicker-days", text: "12").click click_button "Send" expect(page).to have_content("You've been successfully authorized") @@ -109,7 +109,7 @@ fill_in "Document number", with: "12345678" page.execute_script("$('#authorization_handler_birthday').focus()") - page.find(".datepicker-dropdown .day", text: "12").click + page.find(".datepicker-dropdown .datepicker-days", text: "12").click click_button "Send" expect(page).to have_content("There was a problem creating the authorization.") @@ -135,6 +135,78 @@ end end + context "when the authorization is renewable" do + describe "and still not over the waiting period" do + let!(:authorization) do + create(:authorization, name: "dummy_authorization_handler", user: user, granted_at: 1.minute.ago) + end + + it "can't be renewed yet" do + within_user_menu do + click_link "My account" + end + + click_link "Authorizations" + + within ".authorizations-list" do + expect(page).to have_no_link("Example authorization") + expect(page).to have_no_css(".authorization-renewable") + end + end + end + + describe "and passed the time between renewals" do + let!(:authorization) do + create(:authorization, name: "dummy_authorization_handler", user: user, granted_at: 6.minutes.ago) + end + + it "can be renewed" do + within_user_menu do + click_link "My account" + end + + click_link "Authorizations" + + within ".authorizations-list" do + expect(page).to have_link("Example authorization") + expect(page).to have_css(".authorization-renewable") + end + end + + it "shows a modal with renew information" do + within_user_menu do + click_link "My account" + end + + click_link "Authorizations" + click_link "Example authorization" + + within "#renew-modal" do + expect(page).to have_content("Example authorization") + expect(page).to have_content("This is the data of the current verification:") + expect(page).to have_content("Continue") + expect(page).to have_content("Cancel") + end + end + + describe "and clicks on the button to renew" do + it "shows the verification form to start again" do + within_user_menu do + click_link "My account" + end + click_link "Authorizations" + click_link "Example authorization" + within "#renew-modal" do + click_link "Continue" + end + + expect(page).to have_content("Document number") + expect(page).to have_button "Send" + end + end + end + end + context "when the authorization has not expired yet" do let!(:authorization) do create(:authorization, name: "dummy_authorization_handler", user: user, granted_at: 2.seconds.ago) diff --git a/spec/system/user_manage_authorizations_spec.rb b/spec/system/user_manage_authorizations_spec.rb index 200e68c..43dfc36 100644 --- a/spec/system/user_manage_authorizations_spec.rb +++ b/spec/system/user_manage_authorizations_spec.rb @@ -11,13 +11,14 @@ available_authorizations: ["socio_demographic_authorization_handler"]) end - let(:user) { create(:user) } + let(:user) { create(:user, :confirmed) } before do switch_to_host(organization.host) login_as user, scope: :user visit decidim.root_path click_link user.name + click_link "My account" click_link "Authorizations" end