diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c06e767725..0594a6b0e2 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -11,3 +11,8 @@ updates: - dependency-name: capistrano versions: - ">= 3.0.0" + + - package-ecosystem: gitsubmodule + directory: "/" + schedule: + interval: daily diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51486cb02c..48546fd7c9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ permissions: jobs: rspec: - name: Ruby ${{ matrix.ruby }} / PostgreSQL ${{ matrix.postgres }} / ${{ matrix.gemfile || 'Gemfile' }} + name: Ruby ${{ matrix.ruby }} / PostgreSQL ${{ matrix.postgres }} runs-on: ubuntu-20.04 permissions: @@ -24,8 +24,9 @@ jobs: fail-fast: false matrix: include: - - { ruby: 2.7, postgres: 13.5 } - - { ruby: 2.7, postgres: 13.5, gemfile: 'Gemfile.rails_next' } + - { ruby: '3.0', postgres: 13.5 } + - { ruby: '3.1', postgres: 13.5 } + - { ruby: '3.2', postgres: 13.5 } services: postgres: @@ -41,7 +42,6 @@ jobs: --health-retries 5 env: - BUNDLE_GEMFILE: ${{ matrix.gemfile || 'Gemfile' }} DATABASE_URL: postgres://postgres:postgres@localhost:5432/alaveteli_test RAILS_ENV: test diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 3a3757a775..07e47da243 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -14,12 +14,13 @@ jobs: - name: Install Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 2.7 + ruby-version: 3.0 - name: Run RuboCop linter uses: reviewdog/action-rubocop@v1 with: github_token: ${{ secrets.github_token }} + rubocop_flags: -DES rubocop_version: gemfile rubocop_extensions: rubocop-performance:gemfile rubocop-rails:gemfile level: warning diff --git a/.ruby-style.yml b/.ruby-style.yml index 598c65f829..8c25fcf7c1 100644 --- a/.ruby-style.yml +++ b/.ruby-style.yml @@ -4,7 +4,7 @@ require: - rubocop-rails AllCops: - TargetRubyVersion: 2.7 + TargetRubyVersion: 3.0 RubyInterpreters: - ruby - rake @@ -24,6 +24,10 @@ AllCops: - node_modules/**/* - vendor/**/* - ".git/**/*" + - bin/bundle + - bin/rubocop + - bin/sidekiq + - bin/sidekiqmon DisplayCopNames: false StyleGuideCopsOnly: false DisabledByDefault: true @@ -56,6 +60,9 @@ Gemspec/DependencyVersion: Gemspec/DeprecatedAttributeAssignment: Enabled: false +Gemspec/DevelopmentDependencies: + Enabled: false + Gemspec/DuplicatedAssignment: Enabled: false @@ -464,6 +471,9 @@ Lint/DuplicateHashKey: Lint/DuplicateMagicComment: Enabled: false +Lint/DuplicateMatchPattern: + Enabled: false + Lint/DuplicateMethods: Enabled: true @@ -773,6 +783,9 @@ Lint/UselessElseWithoutRescue: Lint/UselessMethodDefinition: Enabled: false +Lint/UselessRescue: + Enabled: false + Lint/UselessRuby2Keywords: Enabled: false @@ -799,6 +812,9 @@ Metrics/BlockNesting: Metrics/ClassLength: Enabled: false +Metrics/CollectionLiteralLength: + Enabled: false + Metrics/CyclomaticComplexity: Enabled: false @@ -1305,6 +1321,9 @@ Rails/RequestReferer: Rails/RequireDependency: Enabled: false +Rails/ResponseParsedBody: + Enabled: false + Rails/ReversibleMigration: Enabled: false @@ -1350,6 +1369,9 @@ Rails/StripHeredoc: Rails/TableNameAssignment: Enabled: false +Rails/ThreeStateBooleanColumn: + Enabled: false + Rails/TimeZone: Enabled: false @@ -1441,6 +1463,9 @@ Style/ArgumentsForwarding: Style/ArrayCoercion: Enabled: false +Style/ArrayIntersect: + Enabled: false + Style/ArrayJoin: Enabled: true @@ -1521,6 +1546,12 @@ Style/CommentAnnotation: Style/CommentedKeyword: Enabled: false +Style/ComparableClamp: + Enabled: false + +Style/ConcatArrayLiterals: + Enabled: false + Style/ConditionalAssignment: Enabled: false @@ -1530,6 +1561,9 @@ Style/ConstantVisibility: Style/Copyright: Enabled: false +Style/DataInheritance: + Enabled: false + Style/DateTime: Enabled: false @@ -1539,6 +1573,9 @@ Style/DefWithParentheses: Style/Dir: Enabled: false +Style/DirEmpty: + Enabled: false + Style/DisableCopsWithinSourceCodeDirective: Enabled: false @@ -1618,6 +1655,9 @@ Style/ExponentialNotation: Style/FetchEnvVar: Enabled: false +Style/FileEmpty: + Enabled: false + Style/FileRead: Enabled: false @@ -1708,6 +1748,9 @@ Style/InlineComment: Style/InverseMethods: Enabled: false +Style/InvertibleUnlessCondition: + Enabled: false + Style/IpAddresses: Enabled: false @@ -1733,6 +1776,9 @@ Style/MapCompactWithConditionalBlock: Style/MapToHash: Enabled: false +Style/MapToSet: + Enabled: false + Style/MethodCallWithArgsParentheses: Enabled: false @@ -1748,6 +1794,9 @@ Style/MethodDefParentheses: Style/MinMax: Enabled: false +Style/MinMaxComparison: + Enabled: false + Style/MissingElse: Enabled: false @@ -1842,7 +1891,7 @@ Style/NumericLiteralPrefix: Enabled: true Style/NumericLiterals: - Enabled: true + Enabled: false Style/NumericPredicate: Enabled: false @@ -1919,6 +1968,15 @@ Style/RedundantCondition: Style/RedundantConditional: Enabled: false +Style/RedundantConstantBase: + Enabled: false + +Style/RedundantDoubleSplatHashBraces: + Enabled: false + +Style/RedundantEach: + Enabled: false + Style/RedundantException: Enabled: true @@ -1931,12 +1989,18 @@ Style/RedundantFileExtensionInRequire: Style/RedundantFreeze: Enabled: true +Style/RedundantHeredocDelimiterQuotes: + Enabled: false + Style/RedundantInitialize: Enabled: false Style/RedundantInterpolation: Enabled: true +Style/RedundantLineContinuation: + Enabled: false + Style/RedundantParentheses: Enabled: true @@ -1973,6 +2037,9 @@ Style/RedundantStringEscape: Style/RegexpLiteral: Enabled: false +Style/RequireOrder: + Enabled: false + Style/RescueModifier: Enabled: true @@ -2142,5 +2209,8 @@ Style/WordArray: Style/YodaCondition: Enabled: false +Style/YodaExpression: + Enabled: false + Style/ZeroLengthPredicate: Enabled: true diff --git a/.ruby-version.example b/.ruby-version.example index a4dd9dba4f..b0f2dcb32f 100644 --- a/.ruby-version.example +++ b/.ruby-version.example @@ -1 +1 @@ -2.7.4 +3.0.4 diff --git a/Gemfile b/Gemfile index 2953114ec6..4f7a46777b 100644 --- a/Gemfile +++ b/Gemfile @@ -79,63 +79,54 @@ # the new version. It is always preferable to upgrade our code. source 'https://rubygems.org' -# See instructions in Gemfile.rails_next -def rails_upgrade? - %w[1 true].include?(ENV['RAILS_UPGRADE']) -end - -if rails_upgrade? - gem 'rails', '~> 7.0.4' -else - gem 'rails', '~> 6.1.7' -end +gem 'rails', '~> 7.0.4' -gem 'pg', '~> 1.4.4' +gem 'pg', '~> 1.4.6' # New gem releases aren't being done. master is newer and supports Rails > 3.0 -gem 'acts_as_versioned', :git => 'https://github.com/technoweenie/acts_as_versioned.git', :ref => '63b1fc8529d028' +gem 'acts_as_versioned', git: 'https://github.com/mysociety/acts_as_versioned.git', + ref: '13e928b' gem 'active_model_otp' gem 'bcrypt', '~> 3.1.18' -gem 'cancancan', '~> 3.4.0' +gem 'cancancan', '~> 3.5.0' gem 'charlock_holmes', '~> 0.7.7' -gem 'dalli', '~> 3.2.3' +gem 'dalli', '~> 3.2.4' gem 'exception_notification', '~> 4.5.0' gem 'fancybox-rails', '~> 0.3.0' gem 'gnuplot', '~> 2.6.0' gem 'htmlentities', '~> 4.3.0' gem 'icalendar', '~> 2.8.0' -gem 'jquery-rails', '~> 4.5.0' +gem 'jquery-rails', '~> 4.5.1' gem 'jquery-ui-rails', '~> 6.0.0' gem 'json', '~> 2.6.2' gem 'holidays', '~> 8.6.0' gem 'iso_country_codes', '~> 0.7.8' -gem 'mail', '~> 2.7.1' +gem 'mail', '~> 2.8.1' gem 'maxmind-db', '~> 1.0.0' gem 'mahoro', '~> 0.5' -gem 'nokogiri', '~> 1.13.10' +gem 'nokogiri', '~> 1.14.3' gem 'open4', '~> 1.3.0' -gem 'rack', '~> 2.2.4' -gem 'rack-utf8_sanitizer', '~> 1.7.0' -gem 'recaptcha', '~> 5.12.3', require: 'recaptcha/rails' -gem 'mini_magick', '~> 4.11.0' -gem 'rolify', '~> 5.3.0' -gem 'ruby-msg', '~> 1.5.0', :git => 'https://github.com/mysociety/ruby-msg.git', :branch => 'ascii-encoding' +gem 'rack', '~> 2.2.6' +gem 'rack-utf8_sanitizer', '~> 1.8.0' +gem 'recaptcha', '~> 5.14.0', require: 'recaptcha/rails' +gem 'matrix', '~> 0.4.2' +gem 'mini_magick', '~> 4.12.0' +gem 'redis', '~> 4.8.1' +gem 'rolify', '~> 6.0.1' +gem 'ruby-msg', '~> 1.5.0', git: 'https://github.com/mysociety/ruby-msg.git', branch: 'ascii-encoding' gem 'rubyzip', '~> 2.3.2' -gem 'secure_headers', '~> 6.4.0' +gem 'secure_headers', '~> 6.5.0' +gem 'sidekiq', '~> 6.5.8' gem 'statistics2', '~> 0.54' -if rails_upgrade? - gem 'strip_attributes', :git => 'https://github.com/mysociety/strip_attributes.git', :branch => 'globalize3-rails7' -else - gem 'strip_attributes', :git => 'https://github.com/mysociety/strip_attributes.git', :branch => 'globalize3-rails5.2' -end +gem 'strip_attributes', git: 'https://github.com/mysociety/strip_attributes.git', branch: 'globalize3-rails7' gem 'stripe', '~> 5.55.0' gem 'syck', '~> 1.4.1', require: false gem 'syslog_protocol', '~> 0.9.0' -gem 'thin', '~> 1.8.1' +gem 'thin', '~> 1.8.2' gem 'vpim', '~> 13.11.11' gem 'will_paginate', '~> 3.3.1' -gem 'xapian-full-alaveteli', '~> 1.4.18.1' -gem 'xml-simple', '~> 1.1.9', :require => 'xmlsimple' +gem 'xapian-full-alaveteli', '~> 1.4.22.1' +gem 'xml-simple', '~> 1.1.9', require: 'xmlsimple' gem 'zip_tricks', '~> 5.6.0' # Gems only used by the research export task @@ -144,8 +135,8 @@ gem 'gender_detector', '~> 2.0.0' # Gems related to internationalisation gem 'i18n', '~> 1.12.0' gem 'rails-i18n', '~> 7.0.5' -gem 'gettext_i18n_rails', '~> 1.9.0' - gem 'fast_gettext', '~> 2.2.0' +gem 'gettext_i18n_rails', '~> 1.10.0' + gem 'fast_gettext', '~> 2.3.0' gem 'gettext', '~> 3.4.3' gem 'globalize', '~> 6.2.1' gem 'locale', '~> 2.1.3' @@ -164,48 +155,41 @@ gem 'sass-rails', '~> 5.0.8' gem 'uglifier', '~> 4.2.0' # Feature flags -gem 'alaveteli_features', :path => 'gems/alaveteli_features' +gem 'alaveteli_features', path: 'gems/alaveteli_features' # Storage backends gem 'aws-sdk-s3', require: false gem 'azure-storage', require: false -gem 'google-cloud-storage', '~> 1.43', require: false - -if rails_upgrade? && RUBY_VERSION < '3.1' - gem 'net-http', '0.1.1' - gem 'uri', '0.10.0' -end +gem 'google-cloud-storage', '~> 1.44', require: false group :test do gem 'fivemat', '~> 1.3.7' gem 'webmock', '~> 3.18.1' - gem 'simplecov', '~> 0.17.1' + gem 'simplecov', '~> 0.22.0' gem 'simplecov-lcov', '~> 0.7.0' - gem 'capybara', '~> 3.38.0' + gem 'capybara', '~> 3.39.0' gem 'stripe-ruby-mock', git: 'https://github.com/stripe-ruby-mock/stripe-ruby-mock', - ref: '2c925fd' - gem('rails-controller-testing') + ref: '6ceea96' + gem 'rails-controller-testing' end group :test, :development do - gem 'bullet', '~> 7.0.4' + gem 'bullet', '~> 7.0.7' gem 'factory_bot_rails', '~> 6.2.0' gem 'oink', '~> 0.10.1' gem 'rspec-activemodel-mocks', '~> 1.1.0' gem 'rspec-rails', '~> 6.0.0' - gem 'pry', '~> 0.14.1' - gem 'pry-byebug', '~> 3.10.1' + gem 'pry', '~> 0.14.2' end group :development do gem 'annotate', '< 3.2.1' gem 'capistrano', '~> 2.15.0', '< 3.0.0' - gem 'net-ssh', '~> 7.0.1' + gem 'net-ssh', '~> 7.1.0' gem 'net-ssh-gateway', '>= 1.1.0', '< 3.0.0' - gem 'launchy', '< 2.5.0' - gem 'listen', '>= 3.0.5', '< 3.7.2' + gem 'launchy', '< 2.6.0' gem 'web-console', '>= 3.3.0' - gem 'rubocop', '~> 1.37.0', require: false + gem 'rubocop', '~> 1.50.2', require: false gem 'rubocop-performance', require: false gem 'rubocop-rails', require: false end diff --git a/Gemfile.lock b/Gemfile.lock index bf97a1645a..b61e4f8c4a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,11 @@ +GIT + remote: https://github.com/mysociety/acts_as_versioned.git + revision: 13e928b8227349461205c2fa22d0bc3dbe2f1135 + ref: 13e928b + specs: + acts_as_versioned (0.6.0) + activerecord (>= 3.0.9) + GIT remote: https://github.com/mysociety/ruby-msg.git revision: fae72e547299ab1f8b23239a79f5a1d353426b40 @@ -9,30 +17,22 @@ GIT GIT remote: https://github.com/mysociety/strip_attributes.git - revision: 62a5e1ee26501ad4c111b855cd73a5653091300b - branch: globalize3-rails5.2 + revision: 842a889258a897692296dff8445bb9dc12e676f8 + branch: globalize3-rails7 specs: - strip_attributes (1.11.0) - activemodel (>= 3.0, < 7.0) + strip_attributes (1.12.0) + activemodel (>= 3.0, < 8.0) GIT remote: https://github.com/stripe-ruby-mock/stripe-ruby-mock - revision: 2c925fd8cb568e3d0cfebffbe1babb490793f150 - ref: 2c925fd + revision: 6ceea9679bb573cb8bc6830f1bdf670b220a9859 + ref: 6ceea96 specs: - stripe-ruby-mock (3.0.1) + stripe-ruby-mock (3.1.0.rc3) dante (>= 0.2.0) multi_json (~> 1.0) stripe (> 5, < 6) -GIT - remote: https://github.com/technoweenie/acts_as_versioned.git - revision: 63b1fc8529d028fae632fe80ec0cb25df56cd76b - ref: 63b1fc8529d028 - specs: - acts_as_versioned (0.6.0) - activerecord (>= 3.0.9) - PATH remote: gems/alaveteli_features specs: @@ -40,45 +40,52 @@ PATH flipper (~> 0.10) flipper-active_record (~> 0.10) mime-types (< 3.0.0) - rails (~> 6.1.4) + rails (~> 7.0.4) GEM remote: https://rubygems.org/ specs: - actioncable (6.1.7) - actionpack (= 6.1.7) - activesupport (= 6.1.7) + actioncable (7.0.4.3) + actionpack (= 7.0.4.3) + activesupport (= 7.0.4.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7) - actionpack (= 6.1.7) - activejob (= 6.1.7) - activerecord (= 6.1.7) - activestorage (= 6.1.7) - activesupport (= 6.1.7) + actionmailbox (7.0.4.3) + actionpack (= 7.0.4.3) + activejob (= 7.0.4.3) + activerecord (= 7.0.4.3) + activestorage (= 7.0.4.3) + activesupport (= 7.0.4.3) mail (>= 2.7.1) - actionmailer (6.1.7) - actionpack (= 6.1.7) - actionview (= 6.1.7) - activejob (= 6.1.7) - activesupport (= 6.1.7) + net-imap + net-pop + net-smtp + actionmailer (7.0.4.3) + actionpack (= 7.0.4.3) + actionview (= 7.0.4.3) + activejob (= 7.0.4.3) + activesupport (= 7.0.4.3) mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp rails-dom-testing (~> 2.0) - actionpack (6.1.7) - actionview (= 6.1.7) - activesupport (= 6.1.7) - rack (~> 2.0, >= 2.0.9) + actionpack (7.0.4.3) + actionview (= 7.0.4.3) + activesupport (= 7.0.4.3) + rack (~> 2.0, >= 2.2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.7) - actionpack (= 6.1.7) - activerecord (= 6.1.7) - activestorage (= 6.1.7) - activesupport (= 6.1.7) + actiontext (7.0.4.3) + actionpack (= 7.0.4.3) + activerecord (= 7.0.4.3) + activestorage (= 7.0.4.3) + activesupport (= 7.0.4.3) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.1.7) - activesupport (= 6.1.7) + actionview (7.0.4.3) + activesupport (= 7.0.4.3) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -86,45 +93,44 @@ GEM active_model_otp (2.3.1) activemodel rotp (~> 6.2.0) - activejob (6.1.7) - activesupport (= 6.1.7) + activejob (7.0.4.3) + activesupport (= 7.0.4.3) globalid (>= 0.3.6) - activemodel (6.1.7) - activesupport (= 6.1.7) - activerecord (6.1.7) - activemodel (= 6.1.7) - activesupport (= 6.1.7) - activestorage (6.1.7) - actionpack (= 6.1.7) - activejob (= 6.1.7) - activerecord (= 6.1.7) - activesupport (= 6.1.7) + activemodel (7.0.4.3) + activesupport (= 7.0.4.3) + activerecord (7.0.4.3) + activemodel (= 7.0.4.3) + activesupport (= 7.0.4.3) + activestorage (7.0.4.3) + actionpack (= 7.0.4.3) + activejob (= 7.0.4.3) + activerecord (= 7.0.4.3) + activesupport (= 7.0.4.3) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.7) + activesupport (7.0.4.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.1) + addressable (2.8.2) public_suffix (>= 2.0.2, < 6.0) annotate (3.2.0) activerecord (>= 3.2, < 8.0) rake (>= 10.4, < 14.0) ast (2.4.2) aws-eventstream (1.2.0) - aws-partitions (1.649.0) - aws-sdk-core (3.164.0) + aws-partitions (1.751.0) + aws-sdk-core (3.171.0) aws-eventstream (~> 1, >= 1.0.2) - aws-partitions (~> 1, >= 1.525.0) - aws-sigv4 (~> 1.1) + aws-partitions (~> 1, >= 1.651.0) + aws-sigv4 (~> 1.5) jmespath (~> 1, >= 1.6.1) - aws-sdk-kms (1.58.0) - aws-sdk-core (~> 3, >= 3.127.0) + aws-sdk-kms (1.63.0) + aws-sdk-core (~> 3, >= 3.165.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.116.0) - aws-sdk-core (~> 3, >= 3.127.0) + aws-sdk-s3 (1.121.0) + aws-sdk-core (~> 3, >= 3.165.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.4) aws-sigv4 (1.5.2) @@ -143,18 +149,17 @@ GEM bootstrap-sass (2.3.2.2) sass (~> 3.2) builder (3.2.4) - bullet (7.0.4) + bullet (7.0.7) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) - byebug (11.1.3) - cancancan (3.4.0) + cancancan (3.5.0) capistrano (2.15.9) highline net-scp (>= 1.0.0) net-sftp (>= 2.0.0) net-ssh (>= 2.0.14) net-ssh-gateway (>= 1.1.0) - capybara (3.38.0) + capybara (3.39.0) addressable matrix mini_mime (>= 0.1.3) @@ -165,19 +170,21 @@ GEM xpath (~> 3.2) charlock_holmes (0.7.7) coderay (1.1.3) - concurrent-ruby (1.1.10) + concurrent-ruby (1.2.2) + connection_pool (2.3.0) crack (0.4.5) rexml crass (1.0.6) - daemons (1.4.0) - dalli (3.2.3) + daemons (1.4.1) + dalli (3.2.4) dante (0.2.0) + date (3.3.3) declarative (0.0.20) diff-lcs (1.5.0) digest-crc (0.6.4) rake (>= 12.0.0, < 14.0.0) - docile (1.3.5) - erubi (1.11.0) + docile (1.4.0) + erubi (1.12.0) eventmachine (1.2.7) exception_notification (4.5.0) actionmailer (>= 5.2, < 8) @@ -190,34 +197,33 @@ GEM railties (>= 5.0.0) fancybox-rails (0.3.1) railties (>= 3.1.0) - faraday (0.17.5) + faraday (0.17.6) multipart-post (>= 1.2, < 3) faraday_middleware (0.14.0) faraday (>= 0.7.4, < 1.0) - fast_gettext (2.2.0) - ffi (1.15.5) + fast_gettext (2.3.0) fivemat (1.3.7) - flipper (0.22.1) - flipper-active_record (0.22.1) - activerecord (>= 4.2, < 7) - flipper (~> 0.22.1) - forwardable (1.3.2) + flipper (0.24.1) + flipper-active_record (0.24.1) + activerecord (>= 4.2, < 8) + flipper (~> 0.24.1) + forwardable (1.3.3) gender_detector (2.0.0) gettext (3.4.3) erubi locale (>= 2.0.5) prime text (>= 1.3.0) - gettext_i18n_rails (1.9.0) + gettext_i18n_rails (1.10.0) fast_gettext (>= 0.9.0) - globalid (1.0.0) + globalid (1.1.0) activesupport (>= 5.0) globalize (6.2.1) activemodel (>= 4.2, < 7.1) activerecord (>= 4.2, < 7.1) request_store (~> 1.0) gnuplot (2.6.2) - google-apis-core (0.9.1) + google-apis-core (0.9.5) addressable (~> 2.5, >= 2.5.1) googleauth (>= 0.16.2, < 2.a) httpclient (>= 2.8.1, < 3.a) @@ -226,8 +232,8 @@ GEM retriable (>= 2.0, < 4.a) rexml webrick - google-apis-iamcredentials_v1 (0.15.0) - google-apis-core (>= 0.9.0, < 2.a) + google-apis-iamcredentials_v1 (0.16.0) + google-apis-core (>= 0.9.1, < 2.a) google-apis-storage_v1 (0.19.0) google-apis-core (>= 0.9.0, < 2.a) google-cloud-core (1.6.0) @@ -236,7 +242,7 @@ GEM google-cloud-env (1.6.0) faraday (>= 0.17.3, < 3.0) google-cloud-errors (1.3.0) - google-cloud-storage (1.43.0) + google-cloud-storage (1.44.0) addressable (~> 2.8) digest-crc (~> 0.4) google-apis-iamcredentials_v1 (~> 0.1) @@ -263,101 +269,112 @@ GEM ice_cube (~> 0.16) ice_cube (0.16.4) iso_country_codes (0.7.8) - jmespath (1.6.1) - jquery-rails (4.5.0) + jmespath (1.6.2) + jquery-rails (4.5.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) jquery-ui-rails (6.0.1) railties (>= 3.2.16) - json (2.6.2) - jwt (2.5.0) - launchy (2.4.3) - addressable (~> 2.3) + json (2.6.3) + jwt (2.6.0) + launchy (2.5.2) + addressable (~> 2.8) libv8-node (16.10.0.0) libv8-node (16.10.0.0-aarch64-linux) + libv8-node (16.10.0.0-arm64-darwin) + libv8-node (16.10.0.0-x86_64-darwin) libv8-node (16.10.0.0-x86_64-linux) - listen (3.7.1) - rb-fsevent (~> 0.10, >= 0.10.3) - rb-inotify (~> 0.9, >= 0.9.10) locale (2.1.3) loofah (2.19.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) mahoro (0.5) - mail (2.7.1) + mail (2.8.1) mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp marcel (1.0.2) matrix (0.4.2) maxmind-db (1.0.0) memoist (0.16.2) method_source (1.0.0) mime-types (2.99.3) - mini_magick (4.11.0) + mini_magick (4.12.0) mini_mime (1.1.2) mini_portile2 (2.8.1) mini_racer (0.6.3) libv8-node (~> 16.10.0.0) - minitest (5.16.3) + minitest (5.18.0) money (6.16.0) i18n (>= 0.6.4, <= 2) multi_json (1.15.0) multipart-post (2.2.3) + net-imap (0.3.4) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.1) + timeout net-scp (1.2.1) net-ssh (>= 2.6.5) net-sftp (2.1.2) net-ssh (>= 2.6.5) - net-ssh (7.0.1) + net-smtp (0.3.3) + net-protocol + net-ssh (7.1.0) net-ssh-gateway (2.0.0) net-ssh (>= 4.0.0) nio4r (2.5.8) - nokogiri (1.13.10) + nokogiri (1.14.3) mini_portile2 (~> 2.8.0) racc (~> 1.4) - nokogiri (1.13.10-aarch64-linux) + nokogiri (1.14.3-aarch64-linux) + racc (~> 1.4) + nokogiri (1.14.3-arm64-darwin) + racc (~> 1.4) + nokogiri (1.14.3-x86_64-darwin) racc (~> 1.4) - nokogiri (1.13.10-x86_64-linux) + nokogiri (1.14.3-x86_64-linux) racc (~> 1.4) oink (0.10.1) activerecord hodel_3000_compliant_logger open4 (1.3.4) os (1.1.4) - parallel (1.22.1) - parser (3.1.2.1) + parallel (1.23.0) + parser (3.2.2.0) ast (~> 2.4.1) - pg (1.4.4) + pg (1.4.6) prime (0.1.2) forwardable singleton - pry (0.14.1) + pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - pry-byebug (3.10.1) - byebug (~> 11.0) - pry (>= 0.13, < 0.15) - public_suffix (5.0.0) + public_suffix (5.0.1) racc (1.6.2) - rack (2.2.4) - rack-test (2.0.2) + rack (2.2.6.4) + rack-test (2.1.0) rack (>= 1.3) - rack-utf8_sanitizer (1.7.0) - rack (>= 1.0, < 3.0) - rails (6.1.7) - actioncable (= 6.1.7) - actionmailbox (= 6.1.7) - actionmailer (= 6.1.7) - actionpack (= 6.1.7) - actiontext (= 6.1.7) - actionview (= 6.1.7) - activejob (= 6.1.7) - activemodel (= 6.1.7) - activerecord (= 6.1.7) - activestorage (= 6.1.7) - activesupport (= 6.1.7) + rack-utf8_sanitizer (1.8.0) + rack (>= 1.0, < 4.0) + rails (7.0.4.3) + actioncable (= 7.0.4.3) + actionmailbox (= 7.0.4.3) + actionmailer (= 7.0.4.3) + actionpack (= 7.0.4.3) + actiontext (= 7.0.4.3) + actionview (= 7.0.4.3) + activejob (= 7.0.4.3) + activemodel (= 7.0.4.3) + activerecord (= 7.0.4.3) + activestorage (= 7.0.4.3) + activesupport (= 7.0.4.3) bundler (>= 1.15.0) - railties (= 6.1.7) - sprockets-rails (>= 2.0.0) + railties (= 7.0.4.3) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -365,25 +382,23 @@ GEM rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.4.4) + rails-html-sanitizer (1.5.0) loofah (~> 2.19, >= 2.19.1) rails-i18n (7.0.5) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - railties (6.1.7) - actionpack (= 6.1.7) - activesupport (= 6.1.7) + railties (7.0.4.3) + actionpack (= 7.0.4.3) + activesupport (= 7.0.4.3) method_source rake (>= 12.2) thor (~> 1.0) + zeitwerk (~> 2.5) rainbow (3.1.1) rake (13.0.6) - rb-fsevent (0.11.0) - rb-inotify (0.10.1) - ffi (~> 1.0) - recaptcha (5.12.3) - json - regexp_parser (2.6.1) + recaptcha (5.14.0) + redis (4.8.1) + regexp_parser (2.8.0) representable (3.2.0) declarative (< 0.1.0) trailblazer-option (>= 0.1.1, < 0.2.0) @@ -392,7 +407,7 @@ GEM rack (>= 1.4) retriable (3.1.2) rexml (3.2.5) - rolify (5.3.0) + rolify (6.0.1) rotp (6.2.0) routing-filter (0.7.0) actionpack (>= 6.1) @@ -418,27 +433,27 @@ GEM rspec-mocks (~> 3.11) rspec-support (~> 3.11) rspec-support (3.11.1) - rubocop (1.37.1) + rubocop (1.50.2) json (~> 2.3) parallel (~> 1.10) - parser (>= 3.1.2.1) + parser (>= 3.2.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.23.0, < 2.0) + rubocop-ast (>= 1.28.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.23.0) - parser (>= 3.1.1.0) - rubocop-performance (1.15.1) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.28.0) + parser (>= 3.2.1.0) + rubocop-performance (1.17.1) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.17.3) + rubocop-rails (2.19.1) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.33.0, < 2.0) ruby-ole (1.2.12.1) - ruby-progressbar (1.11.0) + ruby-progressbar (1.13.0) rubyzip (2.3.2) sass (3.4.25) sass-rails (5.0.8) @@ -447,18 +462,23 @@ GEM sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - secure_headers (6.4.0) + secure_headers (6.5.0) + sidekiq (6.5.8) + connection_pool (>= 2.2.5, < 3) + rack (~> 2.0) + redis (>= 4.5.0, < 5) signet (0.17.0) addressable (~> 2.8) faraday (>= 0.17.5, < 3.a) jwt (>= 1.5, < 3.0) multi_json (~> 1.10) - simplecov (0.17.1) + simplecov (0.22.0) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) simplecov-lcov (0.7.0) + simplecov_json_formatter (0.1.4) singleton (0.1.1) sprockets (3.7.2) concurrent-ruby (~> 1.0) @@ -472,20 +492,21 @@ GEM syck (1.4.1) syslog_protocol (0.9.2) text (1.3.1) - thin (1.8.1) + thin (1.8.2) daemons (~> 1.0, >= 1.0.9) eventmachine (~> 1.0, >= 1.0.4) rack (>= 1, < 3) thor (1.2.1) tilt (2.0.10) + timeout (0.3.2) trailblazer-option (0.1.2) - tzinfo (2.0.5) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) uber (0.1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) unicode (0.4.4.4) - unicode-display_width (2.3.0) + unicode-display_width (2.4.2) unidecoder (1.1.2) uniform_notifier (1.16.0) vpim (13.11.11) @@ -503,17 +524,21 @@ GEM websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) will_paginate (3.3.1) - xapian-full-alaveteli (1.4.18.1) + xapian-full-alaveteli (1.4.22.1) + mini_portile2 (~> 2.8) + rake (~> 13.0) xml-simple (1.1.9) rexml xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.6) + zeitwerk (2.6.7) zip_tricks (5.6.0) PLATFORMS aarch64-linux + arm64-darwin ruby + x86_64-darwin x86_64-linux DEPENDENCIES @@ -525,67 +550,68 @@ DEPENDENCIES azure-storage bcrypt (~> 3.1.18) bootstrap-sass (~> 2.3.2.2) - bullet (~> 7.0.4) - cancancan (~> 3.4.0) + bullet (~> 7.0.7) + cancancan (~> 3.5.0) capistrano (~> 2.15.0, < 3.0.0) - capybara (~> 3.38.0) + capybara (~> 3.39.0) charlock_holmes (~> 0.7.7) - dalli (~> 3.2.3) + dalli (~> 3.2.4) exception_notification (~> 4.5.0) factory_bot_rails (~> 6.2.0) fancybox-rails (~> 0.3.0) - fast_gettext (~> 2.2.0) + fast_gettext (~> 2.3.0) fivemat (~> 1.3.7) gender_detector (~> 2.0.0) gettext (~> 3.4.3) - gettext_i18n_rails (~> 1.9.0) + gettext_i18n_rails (~> 1.10.0) globalize (~> 6.2.1) gnuplot (~> 2.6.0) - google-cloud-storage (~> 1.43) + google-cloud-storage (~> 1.44) holidays (~> 8.6.0) htmlentities (~> 4.3.0) i18n (~> 1.12.0) icalendar (~> 2.8.0) iso_country_codes (~> 0.7.8) - jquery-rails (~> 4.5.0) + jquery-rails (~> 4.5.1) jquery-ui-rails (~> 6.0.0) json (~> 2.6.2) - launchy (< 2.5.0) - listen (>= 3.0.5, < 3.7.2) + launchy (< 2.6.0) locale (~> 2.1.3) mahoro (~> 0.5) - mail (~> 2.7.1) + mail (~> 2.8.1) + matrix (~> 0.4.2) maxmind-db (~> 1.0.0) mime-types (< 3.0.0) - mini_magick (~> 4.11.0) + mini_magick (~> 4.12.0) mini_racer (~> 0.6.3) money (~> 6.16.0) - net-ssh (~> 7.0.1) + net-ssh (~> 7.1.0) net-ssh-gateway (>= 1.1.0, < 3.0.0) - nokogiri (~> 1.13.10) + nokogiri (~> 1.14.3) oink (~> 0.10.1) open4 (~> 1.3.0) - pg (~> 1.4.4) - pry (~> 0.14.1) - pry-byebug (~> 3.10.1) - rack (~> 2.2.4) - rack-utf8_sanitizer (~> 1.7.0) - rails (~> 6.1.7) + pg (~> 1.4.6) + pry (~> 0.14.2) + rack (~> 2.2.6) + rack-utf8_sanitizer (~> 1.8.0) + rails (~> 7.0.4) rails-controller-testing rails-i18n (~> 7.0.5) - recaptcha (~> 5.12.3) - rolify (~> 5.3.0) + recaptcha (~> 5.14.0) + redis (~> 4.8.1) + rolify (~> 6.0.1) routing-filter (~> 0.7.0) rspec-activemodel-mocks (~> 1.1.0) rspec-rails (~> 6.0.0) - rubocop (~> 1.37.0) + rubocop (~> 1.50.2) rubocop-performance rubocop-rails ruby-msg (~> 1.5.0)! rubyzip (~> 2.3.2) sass-rails (~> 5.0.8) - secure_headers (~> 6.4.0) - simplecov (~> 0.17.1) + secure_headers (~> 6.5.0) + sidekiq (~> 6.5.8) + simplecov (~> 0.22.0) simplecov-lcov (~> 0.7.0) statistics2 (~> 0.54) strip_attributes! @@ -593,7 +619,7 @@ DEPENDENCIES stripe-ruby-mock! syck (~> 1.4.1) syslog_protocol (~> 0.9.0) - thin (~> 1.8.1) + thin (~> 1.8.2) uglifier (~> 4.2.0) unicode (~> 0.4.4) unidecoder (~> 1.1.0) @@ -601,6 +627,6 @@ DEPENDENCIES web-console (>= 3.3.0) webmock (~> 3.18.1) will_paginate (~> 3.3.1) - xapian-full-alaveteli (~> 1.4.18.1) + xapian-full-alaveteli (~> 1.4.22.1) xml-simple (~> 1.1.9) zip_tricks (~> 5.6.0) diff --git a/Gemfile.rails_next b/Gemfile.rails_next deleted file mode 100644 index 83fddc1692..0000000000 --- a/Gemfile.rails_next +++ /dev/null @@ -1,6 +0,0 @@ -# BUNDLE_GEMFILE=Gemfile.rails_next bundle install -# BUNDLE_GEMFILE=Gemfile.rails_next be rails s -b 0.0.0.0 - -ENV["RAILS_UPGRADE"] = 'true' - -eval_gemfile File.expand_path('../Gemfile', __FILE__) diff --git a/Gemfile.rails_next.lock b/Gemfile.rails_next.lock deleted file mode 100644 index da6137ffaa..0000000000 --- a/Gemfile.rails_next.lock +++ /dev/null @@ -1,635 +0,0 @@ -GIT - remote: https://github.com/mysociety/ruby-msg.git - revision: fae72e547299ab1f8b23239a79f5a1d353426b40 - branch: ascii-encoding - specs: - ruby-msg (1.5.2) - ruby-ole (>= 1.2.8) - vpim (>= 0.360) - -GIT - remote: https://github.com/mysociety/strip_attributes.git - revision: 842a889258a897692296dff8445bb9dc12e676f8 - branch: globalize3-rails7 - specs: - strip_attributes (1.12.0) - activemodel (>= 3.0, < 8.0) - -GIT - remote: https://github.com/stripe-ruby-mock/stripe-ruby-mock - revision: 2c925fd8cb568e3d0cfebffbe1babb490793f150 - ref: 2c925fd - specs: - stripe-ruby-mock (3.0.1) - dante (>= 0.2.0) - multi_json (~> 1.0) - stripe (> 5, < 6) - -GIT - remote: https://github.com/technoweenie/acts_as_versioned.git - revision: 63b1fc8529d028fae632fe80ec0cb25df56cd76b - ref: 63b1fc8529d028 - specs: - acts_as_versioned (0.6.0) - activerecord (>= 3.0.9) - -PATH - remote: gems/alaveteli_features - specs: - alaveteli_features (0.0.1) - flipper (~> 0.10) - flipper-active_record (~> 0.10) - mime-types (< 3.0.0) - rails (~> 7.0.2) - -GEM - remote: https://rubygems.org/ - specs: - actioncable (7.0.4) - actionpack (= 7.0.4) - activesupport (= 7.0.4) - nio4r (~> 2.0) - websocket-driver (>= 0.6.1) - actionmailbox (7.0.4) - actionpack (= 7.0.4) - activejob (= 7.0.4) - activerecord (= 7.0.4) - activestorage (= 7.0.4) - activesupport (= 7.0.4) - mail (>= 2.7.1) - net-imap - net-pop - net-smtp - actionmailer (7.0.4) - actionpack (= 7.0.4) - actionview (= 7.0.4) - activejob (= 7.0.4) - activesupport (= 7.0.4) - mail (~> 2.5, >= 2.5.4) - net-imap - net-pop - net-smtp - rails-dom-testing (~> 2.0) - actionpack (7.0.4) - actionview (= 7.0.4) - activesupport (= 7.0.4) - rack (~> 2.0, >= 2.2.0) - rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.4) - actionpack (= 7.0.4) - activerecord (= 7.0.4) - activestorage (= 7.0.4) - activesupport (= 7.0.4) - globalid (>= 0.6.0) - nokogiri (>= 1.8.5) - actionview (7.0.4) - activesupport (= 7.0.4) - builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - active_model_otp (2.3.1) - activemodel - rotp (~> 6.2.0) - activejob (7.0.4) - activesupport (= 7.0.4) - globalid (>= 0.3.6) - activemodel (7.0.4) - activesupport (= 7.0.4) - activerecord (7.0.4) - activemodel (= 7.0.4) - activesupport (= 7.0.4) - activestorage (7.0.4) - actionpack (= 7.0.4) - activejob (= 7.0.4) - activerecord (= 7.0.4) - activesupport (= 7.0.4) - marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (7.0.4) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - addressable (2.8.1) - public_suffix (>= 2.0.2, < 6.0) - annotate (3.2.0) - activerecord (>= 3.2, < 8.0) - rake (>= 10.4, < 14.0) - ast (2.4.2) - aws-eventstream (1.2.0) - aws-partitions (1.649.0) - aws-sdk-core (3.164.0) - aws-eventstream (~> 1, >= 1.0.2) - aws-partitions (~> 1, >= 1.525.0) - aws-sigv4 (~> 1.1) - jmespath (~> 1, >= 1.6.1) - aws-sdk-kms (1.58.0) - aws-sdk-core (~> 3, >= 3.127.0) - aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.116.0) - aws-sdk-core (~> 3, >= 3.127.0) - aws-sdk-kms (~> 1) - aws-sigv4 (~> 1.4) - aws-sigv4 (1.5.2) - aws-eventstream (~> 1, >= 1.0.2) - azure-core (0.1.15) - faraday (~> 0.9) - faraday_middleware (~> 0.10) - nokogiri (~> 1.6) - azure-storage (0.15.0.preview) - azure-core (~> 0.1) - faraday (~> 0.9) - faraday_middleware (~> 0.10) - nokogiri (~> 1.6, >= 1.6.8) - bcrypt (3.1.18) - bindex (0.8.1) - bootstrap-sass (2.3.2.2) - sass (~> 3.2) - builder (3.2.4) - bullet (7.0.4) - activesupport (>= 3.0.0) - uniform_notifier (~> 1.11) - byebug (11.1.3) - cancancan (3.4.0) - capistrano (2.15.9) - highline - net-scp (>= 1.0.0) - net-sftp (>= 2.0.0) - net-ssh (>= 2.0.14) - net-ssh-gateway (>= 1.1.0) - capybara (3.38.0) - addressable - matrix - mini_mime (>= 0.1.3) - nokogiri (~> 1.8) - rack (>= 1.6.0) - rack-test (>= 0.6.3) - regexp_parser (>= 1.5, < 3.0) - xpath (~> 3.2) - charlock_holmes (0.7.7) - coderay (1.1.3) - concurrent-ruby (1.1.10) - crack (0.4.5) - rexml - crass (1.0.6) - daemons (1.4.0) - dalli (3.2.3) - dante (0.2.0) - declarative (0.0.20) - diff-lcs (1.5.0) - digest (3.1.0) - digest-crc (0.6.4) - rake (>= 12.0.0, < 14.0.0) - docile (1.3.5) - erubi (1.11.0) - eventmachine (1.2.7) - exception_notification (4.5.0) - actionmailer (>= 5.2, < 8) - activesupport (>= 5.2, < 8) - execjs (2.7.0) - factory_bot (6.2.0) - activesupport (>= 5.0.0) - factory_bot_rails (6.2.0) - factory_bot (~> 6.2.0) - railties (>= 5.0.0) - fancybox-rails (0.3.1) - railties (>= 3.1.0) - faraday (0.17.5) - multipart-post (>= 1.2, < 3) - faraday_middleware (0.14.0) - faraday (>= 0.7.4, < 1.0) - fast_gettext (2.2.0) - ffi (1.15.5) - fivemat (1.3.7) - flipper (0.24.1) - flipper-active_record (0.24.1) - activerecord (>= 4.2, < 8) - flipper (~> 0.24.1) - forwardable (1.3.2) - gender_detector (2.0.0) - gettext (3.4.3) - erubi - locale (>= 2.0.5) - prime - text (>= 1.3.0) - gettext_i18n_rails (1.9.0) - fast_gettext (>= 0.9.0) - globalid (1.0.0) - activesupport (>= 5.0) - globalize (6.2.1) - activemodel (>= 4.2, < 7.1) - activerecord (>= 4.2, < 7.1) - request_store (~> 1.0) - gnuplot (2.6.2) - google-apis-core (0.9.1) - addressable (~> 2.5, >= 2.5.1) - googleauth (>= 0.16.2, < 2.a) - httpclient (>= 2.8.1, < 3.a) - mini_mime (~> 1.0) - representable (~> 3.0) - retriable (>= 2.0, < 4.a) - rexml - webrick - google-apis-iamcredentials_v1 (0.15.0) - google-apis-core (>= 0.9.0, < 2.a) - google-apis-storage_v1 (0.19.0) - google-apis-core (>= 0.9.0, < 2.a) - google-cloud-core (1.6.0) - google-cloud-env (~> 1.0) - google-cloud-errors (~> 1.0) - google-cloud-env (1.6.0) - faraday (>= 0.17.3, < 3.0) - google-cloud-errors (1.3.0) - google-cloud-storage (1.43.0) - addressable (~> 2.8) - digest-crc (~> 0.4) - google-apis-iamcredentials_v1 (~> 0.1) - google-apis-storage_v1 (~> 0.19.0) - google-cloud-core (~> 1.6) - googleauth (>= 0.16.2, < 2.a) - mini_mime (~> 1.0) - googleauth (1.3.0) - faraday (>= 0.17.3, < 3.a) - jwt (>= 1.4, < 3.0) - memoist (~> 0.16) - multi_json (~> 1.11) - os (>= 0.9, < 2.0) - signet (>= 0.16, < 2.a) - hashdiff (1.0.1) - highline (2.0.0) - hodel_3000_compliant_logger (0.1.1) - holidays (8.6.0) - htmlentities (4.3.4) - httpclient (2.8.3) - i18n (1.12.0) - concurrent-ruby (~> 1.0) - icalendar (2.8.0) - ice_cube (~> 0.16) - ice_cube (0.16.4) - iso_country_codes (0.7.8) - jmespath (1.6.1) - jquery-rails (4.5.0) - rails-dom-testing (>= 1, < 3) - railties (>= 4.2.0) - thor (>= 0.14, < 2.0) - jquery-ui-rails (6.0.1) - railties (>= 3.2.16) - json (2.6.3) - jwt (2.5.0) - launchy (2.4.3) - addressable (~> 2.3) - libv8-node (16.10.0.0) - libv8-node (16.10.0.0-aarch64-linux) - libv8-node (16.10.0.0-x86_64-linux) - listen (3.7.1) - rb-fsevent (~> 0.10, >= 0.10.3) - rb-inotify (~> 0.9, >= 0.9.10) - locale (2.1.3) - loofah (2.19.1) - crass (~> 1.0.2) - nokogiri (>= 1.5.9) - mahoro (0.5) - mail (2.7.1) - mini_mime (>= 0.1.1) - marcel (1.0.2) - matrix (0.4.2) - maxmind-db (1.0.0) - memoist (0.16.2) - method_source (1.0.0) - mime-types (2.99.3) - mini_magick (4.11.0) - mini_mime (1.1.2) - mini_portile2 (2.8.1) - mini_racer (0.6.3) - libv8-node (~> 16.10.0.0) - minitest (5.16.3) - money (6.16.0) - i18n (>= 0.6.4, <= 2) - multi_json (1.15.0) - multipart-post (2.2.3) - net-http (0.1.1) - net-protocol - uri - net-imap (0.2.3) - digest - net-protocol - strscan - net-pop (0.1.1) - digest - net-protocol - timeout - net-protocol (0.1.3) - timeout - net-scp (1.2.1) - net-ssh (>= 2.6.5) - net-sftp (2.1.2) - net-ssh (>= 2.6.5) - net-smtp (0.3.1) - digest - net-protocol - timeout - net-ssh (7.0.1) - net-ssh-gateway (2.0.0) - net-ssh (>= 4.0.0) - nio4r (2.5.8) - nokogiri (1.13.10) - mini_portile2 (~> 2.8.0) - racc (~> 1.4) - nokogiri (1.13.10-aarch64-linux) - racc (~> 1.4) - nokogiri (1.13.10-x86_64-linux) - racc (~> 1.4) - oink (0.10.1) - activerecord - hodel_3000_compliant_logger - open4 (1.3.4) - os (1.1.4) - parallel (1.22.1) - parser (3.1.3.0) - ast (~> 2.4.1) - pg (1.4.4) - prime (0.1.2) - forwardable - singleton - pry (0.14.1) - coderay (~> 1.1) - method_source (~> 1.0) - pry-byebug (3.10.1) - byebug (~> 11.0) - pry (>= 0.13, < 0.15) - public_suffix (5.0.0) - racc (1.6.2) - rack (2.2.4) - rack-test (2.0.2) - rack (>= 1.3) - rack-utf8_sanitizer (1.7.0) - rack (>= 1.0, < 3.0) - rails (7.0.4) - actioncable (= 7.0.4) - actionmailbox (= 7.0.4) - actionmailer (= 7.0.4) - actionpack (= 7.0.4) - actiontext (= 7.0.4) - actionview (= 7.0.4) - activejob (= 7.0.4) - activemodel (= 7.0.4) - activerecord (= 7.0.4) - activestorage (= 7.0.4) - activesupport (= 7.0.4) - bundler (>= 1.15.0) - railties (= 7.0.4) - rails-controller-testing (1.0.5) - actionpack (>= 5.0.1.rc1) - actionview (>= 5.0.1.rc1) - activesupport (>= 5.0.1.rc1) - rails-dom-testing (2.0.3) - activesupport (>= 4.2.0) - nokogiri (>= 1.6) - rails-html-sanitizer (1.4.4) - loofah (~> 2.19, >= 2.19.1) - rails-i18n (7.0.5) - i18n (>= 0.7, < 2) - railties (>= 6.0.0, < 8) - railties (7.0.4) - actionpack (= 7.0.4) - activesupport (= 7.0.4) - method_source - rake (>= 12.2) - thor (~> 1.0) - zeitwerk (~> 2.5) - rainbow (3.1.1) - rake (13.0.6) - rb-fsevent (0.11.0) - rb-inotify (0.10.1) - ffi (~> 1.0) - recaptcha (5.12.3) - json - regexp_parser (2.6.1) - representable (3.2.0) - declarative (< 0.1.0) - trailblazer-option (>= 0.1.1, < 0.2.0) - uber (< 0.2.0) - request_store (1.5.1) - rack (>= 1.4) - retriable (3.1.2) - rexml (3.2.5) - rolify (5.3.0) - rotp (6.2.0) - routing-filter (0.7.0) - actionpack (>= 6.1) - activesupport (>= 6.1) - rspec-activemodel-mocks (1.1.0) - activemodel (>= 3.0) - activesupport (>= 3.0) - rspec-mocks (>= 2.99, < 4.0) - rspec-core (3.11.0) - rspec-support (~> 3.11.0) - rspec-expectations (3.11.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-mocks (3.11.1) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-rails (6.0.1) - actionpack (>= 6.1) - activesupport (>= 6.1) - railties (>= 6.1) - rspec-core (~> 3.11) - rspec-expectations (~> 3.11) - rspec-mocks (~> 3.11) - rspec-support (~> 3.11) - rspec-support (3.11.1) - rubocop (1.37.1) - json (~> 2.3) - parallel (~> 1.10) - parser (>= 3.1.2.1) - rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.23.0, < 2.0) - ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.24.0) - parser (>= 3.1.1.0) - rubocop-performance (1.15.1) - rubocop (>= 1.7.0, < 2.0) - rubocop-ast (>= 0.4.0) - rubocop-rails (2.17.3) - activesupport (>= 4.2.0) - rack (>= 1.1) - rubocop (>= 1.33.0, < 2.0) - ruby-ole (1.2.12.1) - ruby-progressbar (1.11.0) - rubyzip (2.3.2) - sass (3.4.25) - sass-rails (5.0.8) - railties (>= 5.2.0) - sass (~> 3.1) - sprockets (>= 2.8, < 4.0) - sprockets-rails (>= 2.0, < 4.0) - tilt (>= 1.1, < 3) - secure_headers (6.4.0) - signet (0.17.0) - addressable (~> 2.8) - faraday (>= 0.17.5, < 3.a) - jwt (>= 1.5, < 3.0) - multi_json (~> 1.10) - simplecov (0.17.1) - docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) - simplecov-lcov (0.7.0) - singleton (0.1.1) - sprockets (3.7.2) - concurrent-ruby (~> 1.0) - rack (> 1, < 3) - sprockets-rails (3.4.2) - actionpack (>= 5.2) - activesupport (>= 5.2) - sprockets (>= 3.0.0) - statistics2 (0.54) - stripe (5.55.0) - strscan (3.0.4) - syck (1.4.1) - syslog_protocol (0.9.2) - text (1.3.1) - thin (1.8.1) - daemons (~> 1.0, >= 1.0.9) - eventmachine (~> 1.0, >= 1.0.4) - rack (>= 1, < 3) - thor (1.2.1) - tilt (2.0.10) - timeout (0.3.0) - trailblazer-option (0.1.2) - tzinfo (2.0.5) - concurrent-ruby (~> 1.0) - uber (0.1.0) - uglifier (4.2.0) - execjs (>= 0.3.0, < 3) - unicode (0.4.4.4) - unicode-display_width (2.3.0) - unidecoder (1.1.2) - uniform_notifier (1.16.0) - uri (0.10.0) - vpim (13.11.11) - web-console (4.2.0) - actionview (>= 6.0.0) - activemodel (>= 6.0.0) - bindex (>= 0.4.0) - railties (>= 6.0.0) - webmock (3.18.1) - addressable (>= 2.8.0) - crack (>= 0.3.2) - hashdiff (>= 0.4.0, < 2.0.0) - webrick (1.7.0) - websocket-driver (0.7.5) - websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.5) - will_paginate (3.3.1) - xapian-full-alaveteli (1.4.18.1) - xml-simple (1.1.9) - rexml - xpath (3.2.0) - nokogiri (~> 1.8) - zeitwerk (2.6.1) - zip_tricks (5.6.0) - -PLATFORMS - aarch64-linux - ruby - x86_64-linux - -DEPENDENCIES - active_model_otp - acts_as_versioned! - alaveteli_features! - annotate (< 3.2.1) - aws-sdk-s3 - azure-storage - bcrypt (~> 3.1.18) - bootstrap-sass (~> 2.3.2.2) - bullet (~> 7.0.4) - cancancan (~> 3.4.0) - capistrano (~> 2.15.0, < 3.0.0) - capybara (~> 3.38.0) - charlock_holmes (~> 0.7.7) - dalli (~> 3.2.3) - exception_notification (~> 4.5.0) - factory_bot_rails (~> 6.2.0) - fancybox-rails (~> 0.3.0) - fast_gettext (~> 2.2.0) - fivemat (~> 1.3.7) - gender_detector (~> 2.0.0) - gettext (~> 3.4.3) - gettext_i18n_rails (~> 1.9.0) - globalize (~> 6.2.1) - gnuplot (~> 2.6.0) - google-cloud-storage (~> 1.43) - holidays (~> 8.6.0) - htmlentities (~> 4.3.0) - i18n (~> 1.12.0) - icalendar (~> 2.8.0) - iso_country_codes (~> 0.7.8) - jquery-rails (~> 4.5.0) - jquery-ui-rails (~> 6.0.0) - json (~> 2.6.2) - launchy (< 2.5.0) - listen (>= 3.0.5, < 3.7.2) - locale (~> 2.1.3) - mahoro (~> 0.5) - mail (~> 2.7.1) - maxmind-db (~> 1.0.0) - mime-types (< 3.0.0) - mini_magick (~> 4.11.0) - mini_racer (~> 0.6.3) - money (~> 6.16.0) - net-http (= 0.1.1) - net-ssh (~> 7.0.1) - net-ssh-gateway (>= 1.1.0, < 3.0.0) - nokogiri (~> 1.13.10) - oink (~> 0.10.1) - open4 (~> 1.3.0) - pg (~> 1.4.4) - pry (~> 0.14.1) - pry-byebug (~> 3.10.1) - rack (~> 2.2.4) - rack-utf8_sanitizer (~> 1.7.0) - rails (~> 7.0.4) - rails-controller-testing - rails-i18n (~> 7.0.5) - recaptcha (~> 5.12.3) - rolify (~> 5.3.0) - routing-filter (~> 0.7.0) - rspec-activemodel-mocks (~> 1.1.0) - rspec-rails (~> 6.0.0) - rubocop (~> 1.37.0) - rubocop-performance - rubocop-rails - ruby-msg (~> 1.5.0)! - rubyzip (~> 2.3.2) - sass-rails (~> 5.0.8) - secure_headers (~> 6.4.0) - simplecov (~> 0.17.1) - simplecov-lcov (~> 0.7.0) - statistics2 (~> 0.54) - strip_attributes! - stripe (~> 5.55.0) - stripe-ruby-mock! - syck (~> 1.4.1) - syslog_protocol (~> 0.9.0) - thin (~> 1.8.1) - uglifier (~> 4.2.0) - unicode (~> 0.4.4) - unidecoder (~> 1.1.0) - uri (= 0.10.0) - vpim (~> 13.11.11) - web-console (>= 3.3.0) - webmock (~> 3.18.1) - will_paginate (~> 3.3.1) - xapian-full-alaveteli (~> 1.4.18.1) - xml-simple (~> 1.1.9) - zip_tricks (~> 5.6.0) diff --git a/README.md b/README.md index b66a287c39..455a6b5088 100644 --- a/README.md +++ b/README.md @@ -35,11 +35,13 @@ see [the project website](http://alaveteli.org) for instructions on installing A ## Compatibility -Every Alaveteli commit is tested by GitHub Actions on the [following Ruby platforms](https://github.com/mysociety/alaveteli/blob/develop/.github/workflows/ci.yml#L15) +Every Alaveteli commit is tested by GitHub Actions on the [following Ruby platforms](https://github.com/mysociety/alaveteli/blob/develop/.github/workflows/ci.yml#L27-L29) -* ruby-2.7 +* ruby-3.0 +* ruby-3.1 +* ruby-3.2 -If you use a ruby version management tool (such as RVM or .rbenv) and want to use the default development version used by the Alaveteli team (currently 2.7.4), you can create a `.ruby-version` symlink with a target of `.ruby-version.example` to switch to that automatically in the project directory. +If you use a ruby version management tool (such as RVM or .rbenv) and want to use the default development version used by the Alaveteli team (currently 3.0.4), you can create a `.ruby-version` symlink with a target of `.ruby-version.example` to switch to that automatically in the project directory. ## How to contribute diff --git a/Vagrantfile b/Vagrantfile index 401d8ec794..f08833608d 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -159,9 +159,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box_url = os[:box_url] config.vm.hostname = "alaveteli-#{ SETTINGS['os'] }" - if SETTINGS['public_network'] - config.vm.network :public_network - end + config.vm.network :public_network if SETTINGS['public_network'] config.vm.network :private_network, ip: SETTINGS['ip'] diff --git a/app/assets/javascripts/admin.js b/app/assets/javascripts/admin.js index f8e6a2fad4..b40ef6990a 100644 --- a/app/assets/javascripts/admin.js +++ b/app/assets/javascripts/admin.js @@ -9,5 +9,6 @@ //= require bootstrap-tooltip //= require admin/admin //= require admin/category-order +//= require admin/censor-rules //= require admin/holidays //= require jquery_ujs diff --git a/app/assets/javascripts/admin/censor-rules.js b/app/assets/javascripts/admin/censor-rules.js new file mode 100644 index 0000000000..d90a205f22 --- /dev/null +++ b/app/assets/javascripts/admin/censor-rules.js @@ -0,0 +1,8 @@ +$(function () { + $('#js-use-previous-comment').click(function (e) { + var textArea = $($(this).data('target')); + var lastEditComment = textArea.data('last-edit-comment'); + textArea.val(lastEditComment); + e.preventDefault(); + }) +}); diff --git a/app/assets/stylesheets/responsive/_lists_style.scss b/app/assets/stylesheets/responsive/_lists_style.scss index 0e59a74eb6..1ca93ae848 100644 --- a/app/assets/stylesheets/responsive/_lists_style.scss +++ b/app/assets/stylesheets/responsive/_lists_style.scss @@ -15,6 +15,14 @@ } } +.body_listing.tag--defunct { + color: grey; + + a { + color: grey; + } +} + .request_listing{ .bottomline { background-position:top left; diff --git a/app/assets/stylesheets/responsive/_new_request_layout.scss b/app/assets/stylesheets/responsive/_new_request_layout.scss index 5d98bf6320..95c840afed 100644 --- a/app/assets/stylesheets/responsive/_new_request_layout.scss +++ b/app/assets/stylesheets/responsive/_new_request_layout.scss @@ -44,7 +44,8 @@ } } -span#to_public_body { +.to_public_body, +.from_user { display:block; margin-bottom:15px; } diff --git a/app/assets/stylesheets/responsive/_new_request_style.scss b/app/assets/stylesheets/responsive/_new_request_style.scss index 607a6cd8d3..a799525d9f 100644 --- a/app/assets/stylesheets/responsive/_new_request_style.scss +++ b/app/assets/stylesheets/responsive/_new_request_style.scss @@ -33,13 +33,15 @@ } -#to_public_body { +.to_public_body, +.from_user { font-weight: bold; font-size: 1.3em; margin-bottom: 0.5em; } -.to_public_body_label { +.to_public_body_label, +.from_user_label { color: #777; font-weight: normal; } @@ -50,21 +52,13 @@ margin-bottom: 2em; } -#request_header_text { - overflow: hidden; - font-size: 0.875em; - h3 { - font-size: 1em; - } - -} - #request_advice { margin-bottom: 1.5em; font-size: 0.875em; @include respond-min( $main_menu-mobile_menu_cutoff ){ font-size: 1em; } + .advice-panel { margin-top: 1.5em; } @@ -85,6 +79,12 @@ } } +.advice-panel.advice-panel--warning { + background: #fff08a; + border: 1px solid #baad1d; + padding: 0.1em 0.5em; +} + #request_search_ahead_results { background-color: #f4f4f4; padding: 1.5em; diff --git a/app/assets/stylesheets/responsive/_request_style.scss b/app/assets/stylesheets/responsive/_request_style.scss index c6d97c18ff..7ccc08efb8 100644 --- a/app/assets/stylesheets/responsive/_request_style.scss +++ b/app/assets/stylesheets/responsive/_request_style.scss @@ -192,7 +192,8 @@ a.cplink__button { } .preview_subject, -.preview_to { +.preview_to, +.preview_from { font-weight: bold; strong { font-weight: normal; diff --git a/app/assets/stylesheets/responsive/_sidebar_style.scss b/app/assets/stylesheets/responsive/_sidebar_style.scss index e550ee40de..094a85d0df 100644 --- a/app/assets/stylesheets/responsive/_sidebar_style.scss +++ b/app/assets/stylesheets/responsive/_sidebar_style.scss @@ -101,6 +101,13 @@ background-position: -128px 0; } +.sidebar__section.blog-posts { + .blog-posts-list { + list-style: none; + padding: 0; + } +} + .sidebar__section.citations { .citations-list { list-style: none; diff --git a/app/assets/stylesheets/responsive/alaveteli_pro/_new_request_layout.scss b/app/assets/stylesheets/responsive/alaveteli_pro/_new_request_layout.scss index 8248b493db..db8c1cb234 100644 --- a/app/assets/stylesheets/responsive/alaveteli_pro/_new_request_layout.scss +++ b/app/assets/stylesheets/responsive/alaveteli_pro/_new_request_layout.scss @@ -6,15 +6,6 @@ padding-right: 0.9375em; } } -.to_public_body { - padding: 1em; - @include respond-min($main_menu-mobile_menu_cutoff) { - padding: 1.5em 1.5em 2em; - } - background-color: #F3F1EB; - border-radius: 3px; - margin: 1em 0 1.5em !important; -} .request_embargo { margin-top: 2em; diff --git a/app/assets/stylesheets/responsive/alaveteli_pro/_new_request_style.scss b/app/assets/stylesheets/responsive/alaveteli_pro/_new_request_style.scss index c8b4d8a921..cc24f3448b 100644 --- a/app/assets/stylesheets/responsive/alaveteli_pro/_new_request_style.scss +++ b/app/assets/stylesheets/responsive/alaveteli_pro/_new_request_style.scss @@ -9,13 +9,24 @@ } } -#to_public_body { - font-size: 1em; +.alaveteli-pro .request-to-header { + border-bottom: 1px solid #ccc; + border-color: rgba(0, 0, 0, 0.1); + margin-bottom: 2em; +} + +.alaveteli-pro .public-body-query { + font-size: 0.85em; font-weight: normal; } -.to_public_body_label { - color: #333; +.alaveteli-pro .request-to-header form.new_info_request { + margin-bottom: 1.25em +} + +.request-to-header .pro_batch_link { + font-size: 0.85em; + font-weight: normal; } // Overrides for selectize plugin diff --git a/app/controllers/admin/blog_posts_controller.rb b/app/controllers/admin/blog_posts_controller.rb new file mode 100644 index 0000000000..87a8f1732a --- /dev/null +++ b/app/controllers/admin/blog_posts_controller.rb @@ -0,0 +1,37 @@ +## +# Controller to manage tags for Blog::Post objects +# +class Admin::BlogPostsController < AdminController + before_action :find_blog_post, only: [:edit, :update] + + def index + @blog_posts = Blog::Post.order(id: :desc).paginate( + page: params[:page], + per_page: 25 + ) + end + + def edit + end + + def update + if @blog_post.update(blog_post_params) + notice = 'Blog Post successfully updated.' + redirect_to admin_blog_posts_path, notice: notice + else + render :edit + end + end + + private + + def find_blog_post + @blog_post = Blog::Post.find(params[:id]) + end + + def blog_post_params + params.require(:blog_post).permit( + :tag_string + ) + end +end diff --git a/app/controllers/admin_censor_rule_controller.rb b/app/controllers/admin_censor_rule_controller.rb index e7072019c2..99c9415c63 100644 --- a/app/controllers/admin_censor_rule_controller.rb +++ b/app/controllers/admin_censor_rule_controller.rb @@ -6,9 +6,9 @@ class AdminCensorRuleController < AdminController - before_action :set_editor, :only => [:create, :update] - before_action :set_censor_rule, :only => [:edit, :update, :destroy] - before_action :set_subject_and_censor_rule_and_form_url, :only => [:new, :create] + before_action :set_editor, only: [:create, :update] + before_action :set_censor_rule, only: [:edit, :update, :destroy] + before_action :set_subject_and_censor_rule_and_form_url, only: [:new, :create] def index @censor_rules = CensorRule.global @@ -22,7 +22,7 @@ def create flash[:notice] = 'Censor rule was successfully created.' expire_requests_and_redirect else - render :action => 'new' + render action: 'new' end end @@ -34,7 +34,7 @@ def update flash[:notice] = 'Censor rule was successfully updated.' expire_requests_and_redirect else - render :action => 'edit' + render action: 'edit' end end diff --git a/app/controllers/admin_comment_controller.rb b/app/controllers/admin_comment_controller.rb index 50792aff40..7f0655b58b 100644 --- a/app/controllers/admin_comment_controller.rb +++ b/app/controllers/admin_comment_controller.rb @@ -6,7 +6,7 @@ class AdminCommentController < AdminController - before_action :set_comment, :only => [:edit, :update] + before_action :set_comment, only: [:edit, :update] def index @title = 'Listing comments' @@ -19,23 +19,17 @@ def index Comment.order(created_at: :desc) end - if cannot? :admin, AlaveteliPro::Embargo - comments = comments.not_embargoed - end + comments = comments.not_embargoed if cannot? :admin, AlaveteliPro::Embargo - @comments = comments.paginate :page => params[:page], :per_page => 100 + @comments = comments.paginate page: params[:page], per_page: 100 end def edit - if cannot? :admin, @comment - raise ActiveRecord::RecordNotFound - end + raise ActiveRecord::RecordNotFound if cannot? :admin, @comment end def update - if cannot? :admin, @comment - raise ActiveRecord::RecordNotFound - end + raise ActiveRecord::RecordNotFound if cannot? :admin, @comment old_body = @comment.body.dup old_visible = @comment.visible old_attention = @comment.attention_requested @@ -60,7 +54,7 @@ def update flash[:notice] = 'Comment successfully updated.' redirect_to admin_request_url(@comment.info_request) else - render :action => 'edit' + render action: 'edit' end end diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index f0201bf022..ba1eeab5c4 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -15,7 +15,7 @@ def handle_unverified_request # For administration interface, return display name of authenticated user def admin_current_user - if AlaveteliConfiguration::skip_admin_auth + if AlaveteliConfiguration.skip_admin_auth admin_http_auth_user else session[:admin_name] @@ -29,47 +29,43 @@ def admin_http_auth_user # Hence the second clause which reads X-Forwarded-User header if available. # See the rewrite rules in conf/httpd.conf which set X-Forwarded-User if request.env["REMOTE_USER"] - return request.env["REMOTE_USER"] + request.env["REMOTE_USER"] elsif request.env["HTTP_X_FORWARDED_USER"] - return request.env["HTTP_X_FORWARDED_USER"] + request.env["HTTP_X_FORWARDED_USER"] else - return "*unknown*"; + "*unknown*" end end def authenticate - if AlaveteliConfiguration::skip_admin_auth + if AlaveteliConfiguration.skip_admin_auth session[:using_admin] = 1 - return - else - if session[:using_admin].nil? || session[:admin_name].nil? - if params[:emergency].nil? || AlaveteliConfiguration::disable_emergency_user - if !authenticated? - ask_to_login( - web: _('To log into the administrative interface'), - email: _('Then you can log into the administrative interface'), - email_subject: _('Log into the admin interface'), - user_name: 'a superuser' - ) - else - if !@user.nil? && @user.is_admin? - session[:using_admin] = 1 - session[:admin_name] = @user.url_name - else - session[:using_admin] = nil - session[:user_id] = nil - session[:admin_name] = nil - self.authenticate - end - end + nil + elsif session[:using_admin].nil? || session[:admin_name].nil? + if params[:emergency].nil? || AlaveteliConfiguration.disable_emergency_user + if !authenticated? + ask_to_login( + web: _('To log into the administrative interface'), + email: _('Then you can log into the administrative interface'), + email_subject: _('Log into the admin interface'), + user_name: 'a superuser' + ) + elsif !@user.nil? && @user.is_admin? + session[:using_admin] = 1 + session[:admin_name] = @user.url_name else - authenticate_or_request_with_http_basic do |user_name, password| - if user_name == AlaveteliConfiguration::admin_username && password == AlaveteliConfiguration::admin_password - session[:using_admin] = 1 - session[:admin_name] = user_name - else - request_http_basic_authentication - end + session[:using_admin] = nil + session[:user_id] = nil + session[:admin_name] = nil + authenticate + end + else + authenticate_or_request_with_http_basic do |user_name, password| + if user_name == AlaveteliConfiguration.admin_username && password == AlaveteliConfiguration.admin_password + session[:using_admin] = 1 + session[:admin_name] = user_name + else + request_http_basic_authentication end end end diff --git a/app/controllers/admin_general_controller.rb b/app/controllers/admin_general_controller.rb index 60cb83a4be..ba9a506f79 100644 --- a/app/controllers/admin_general_controller.rb +++ b/app/controllers/admin_general_controller.rb @@ -25,7 +25,7 @@ def index limit(20). is_searchable @holding_pen_messages = InfoRequest. - includes(:incoming_messages => :raw_email). + includes(incoming_messages: :raw_email). holding_pen_request. incoming_messages @public_request_tasks = [ @holding_pen_messages, @@ -81,11 +81,11 @@ def index @embargoed_request_tasks = [ @embargoed_requires_admin_requests, @embargoed_error_message_requests, - @embargoed_attention_requests, + @embargoed_attention_requests ].any? { |to_do_list| ! to_do_list.empty? } @embargoed_attention_comments = Comment. - where(:attention_requested => true). + where(attention_requested: true). embargoed @embargoed_comment_tasks = [ @@ -119,7 +119,7 @@ def timeline end # get all the models in the slice, eagerly loading the associations we use in the view public_body_versions = PublicBody.versioned_class. - includes(:public_body => :translations). + includes(public_body: :translations). find(public_body_version_ids.keys) info_request_events = InfoRequestEvent. includes(:info_request). diff --git a/app/controllers/admin_holiday_imports_controller.rb b/app/controllers/admin_holiday_imports_controller.rb index 02c08211e9..118c3d2456 100644 --- a/app/controllers/admin_holiday_imports_controller.rb +++ b/app/controllers/admin_holiday_imports_controller.rb @@ -9,7 +9,7 @@ def create @holiday_import = HolidayImport.new(holiday_import_params) if @holiday_import.save notice = "Holidays successfully imported" - redirect_to admin_holidays_path, :notice => notice + redirect_to admin_holidays_path, notice: notice else render :new end diff --git a/app/controllers/admin_holidays_controller.rb b/app/controllers/admin_holidays_controller.rb index 1e6baab53c..86dd2f4e02 100644 --- a/app/controllers/admin_holidays_controller.rb +++ b/app/controllers/admin_holidays_controller.rb @@ -1,6 +1,6 @@ class AdminHolidaysController < AdminController - before_action :set_holiday, :only => [:edit, :update, :destroy] + before_action :set_holiday, only: [:edit, :update, :destroy] def index get_all_holidays @@ -9,9 +9,9 @@ def index def new @holiday = Holiday.new if request.xhr? - render :partial => 'new_form', :locals => { :holiday => @holiday } + render partial: 'new_form', locals: { holiday: @holiday } else - render :action => 'new' + render action: 'new' end end @@ -19,7 +19,7 @@ def create @holiday = Holiday.new(holiday_params) if @holiday.save notice = "Holiday successfully created." - redirect_to admin_holidays_path, :notice => notice + redirect_to admin_holidays_path, notice: notice else render :new end @@ -27,9 +27,9 @@ def create def edit if request.xhr? - render :partial => 'edit_form' + render partial: 'edit_form' else - render :action => 'edit' + render action: 'edit' end end @@ -45,7 +45,7 @@ def update def destroy @holiday.destroy notice = "Holiday successfully destroyed" - redirect_to admin_holidays_path, :notice => notice + redirect_to admin_holidays_path, notice: notice end private diff --git a/app/controllers/admin_incoming_message_controller.rb b/app/controllers/admin_incoming_message_controller.rb index aa3d3ac555..e70d3f9990 100644 --- a/app/controllers/admin_incoming_message_controller.rb +++ b/app/controllers/admin_incoming_message_controller.rb @@ -1,6 +1,6 @@ class AdminIncomingMessageController < AdminController - before_action :set_incoming_message, :only => [:edit, :update, :destroy, :redeliver] + before_action :set_incoming_message, only: [:edit, :update, :destroy, :redeliver] before_action :set_info_request, :check_info_request def edit @@ -26,7 +26,7 @@ def update flash[:notice] = 'Incoming message successfully updated.' redirect_to admin_request_url(@incoming_message.info_request) else - render :action => 'edit' + render action: 'edit' end end @@ -38,7 +38,7 @@ def destroy deleted_incoming_message_id: @incoming_message.id ) # expire cached files - @incoming_message.info_request.expire(:preserve_database_cache => true) + @incoming_message.info_request.expire(preserve_database_cache: true) flash[:notice] = 'Incoming message successfully destroyed.' redirect_to admin_request_url(@incoming_message.info_request) end @@ -49,23 +49,21 @@ def bulk_destroy end @incoming_messages = IncomingMessage. - where(:id => params[:ids].split(",").flatten) + where(id: params[:ids].split(",").flatten) if params[:commit] == "Yes" errors = [] info_request = InfoRequest.find(params[:request_id]) @incoming_messages.each do |message| - begin - message.destroy - info_request.log_event( - 'destroy_incoming', - editor: admin_current_user, - deleted_incoming_message_id: message.id - ) - rescue - errors << message.id - end + message.destroy + info_request.log_event( + 'destroy_incoming', + editor: admin_current_user, + deleted_incoming_message_id: message.id + ) + rescue + errors << message.id end - info_request.expire(:preserve_database_cache => true) + info_request.expire(preserve_database_cache: true) if errors.empty? flash[:notice] = "Incoming messages successfully destroyed." else @@ -81,7 +79,7 @@ def bulk_destroy def redeliver - message_ids = params[:url_title].split(",").each { |x| x.strip } + message_ids = params[:url_title].split(",").each(&:strip) previous_request = @incoming_message.info_request destination_request = nil @@ -91,7 +89,7 @@ def redeliver end ActiveRecord::Base.transaction do - for m in message_ids + message_ids.each do |m| if m.match(/^[0-9]+$/) destination_request = InfoRequest.find_by_id(m.to_i) else @@ -107,7 +105,7 @@ def redeliver destination_request. receive(mail, raw_email_data, - { :override_stop_new_responses => true }) + { override_stop_new_responses: true }) @incoming_message.info_request.log_event( 'redeliver_incoming', diff --git a/app/controllers/admin_info_request_event_controller.rb b/app/controllers/admin_info_request_event_controller.rb index 5be80ef800..4f71e83191 100644 --- a/app/controllers/admin_info_request_event_controller.rb +++ b/app/controllers/admin_info_request_event_controller.rb @@ -6,7 +6,7 @@ class AdminInfoRequestEventController < AdminController - before_action :set_info_request_event, :only => [:update] + before_action :set_info_request_event, only: [:update] # used so due dates get fixed def update diff --git a/app/controllers/admin_outgoing_message_controller.rb b/app/controllers/admin_outgoing_message_controller.rb index c728a04011..370d5c31fe 100644 --- a/app/controllers/admin_outgoing_message_controller.rb +++ b/app/controllers/admin_outgoing_message_controller.rb @@ -1,8 +1,8 @@ class AdminOutgoingMessageController < AdminController - before_action :set_outgoing_message, :only => [:edit, :destroy, :update, :resend] + before_action :set_outgoing_message, only: [:edit, :destroy, :update, :resend] before_action :set_info_request, :check_info_request - before_action :set_is_initial_message, :only => [:edit, :destroy] + before_action :set_is_initial_message, only: [:edit, :destroy] def edit end @@ -46,7 +46,7 @@ def update @outgoing_message.info_request.expire redirect_to admin_request_url(@outgoing_message.info_request) else - render :action => 'edit' + render action: 'edit' end end diff --git a/app/controllers/admin_public_body_categories_controller.rb b/app/controllers/admin_public_body_categories_controller.rb index 752ebb0cae..1ebf8f3471 100644 --- a/app/controllers/admin_public_body_categories_controller.rb +++ b/app/controllers/admin_public_body_categories_controller.rb @@ -2,7 +2,7 @@ class AdminPublicBodyCategoriesController < AdminController include TranslatableParams - before_action :set_public_body_category, :only => [:edit, :update, :destroy] + before_action :set_public_body_category, only: [:edit, :update, :destroy] def index @locale = AlaveteliLocalization.locale @@ -30,7 +30,7 @@ def create redirect_to admin_categories_path else @public_body_category.build_all_translations - render :action => 'new' + render action: 'new' end end end @@ -48,7 +48,7 @@ def update AlaveteliLocalization.with_locale(AlaveteliLocalization.default_locale) do if params[:public_body_category][:category_tag] && PublicBody.find_by_tag(@public_body_category.category_tag).count > 0 && @public_body_category.category_tag != params[:public_body_category][:category_tag] flash[:error] = "There are authorities associated with this category, so the tag can't be renamed" - render :action => 'edit' + render action: 'edit' else if params[:headings] heading_ids = params[:headings].values @@ -58,8 +58,8 @@ def update unless removed_headings.empty? # remove the link objects deleted_links = PublicBodyCategoryLink.where( - :public_body_category_id => @public_body_category.id, - :public_body_heading_id => [removed_headings].flatten + public_body_category_id: @public_body_category.id, + public_body_heading_id: [removed_headings].flatten ) deleted_links.delete_all @@ -79,7 +79,7 @@ def update redirect_to edit_admin_category_path(@public_body_category) else @public_body_category.build_all_translations - render :action => 'edit' + render action: 'edit' end end end diff --git a/app/controllers/admin_public_body_controller.rb b/app/controllers/admin_public_body_controller.rb index e82a37c0bd..ff59aec23c 100644 --- a/app/controllers/admin_public_body_controller.rb +++ b/app/controllers/admin_public_body_controller.rb @@ -8,7 +8,7 @@ class AdminPublicBodyController < AdminController include TranslatableParams - before_action :set_public_body, :only => [:edit, :update, :destroy] + before_action :set_public_body, only: [:edit, :update, :destroy] def index lookup_query @@ -22,8 +22,8 @@ def show if cannot? :admin, AlaveteliPro::Embargo info_requests = info_requests.not_embargoed end - @info_requests = info_requests.paginate(:page => params[:page], - :per_page => 100) + @info_requests = info_requests.paginate(page: params[:page], + per_page: 100) @versions = @public_body.versions.order(version: :desc) render end @@ -37,13 +37,13 @@ def new @change_request = PublicBodyChangeRequest.find(params[:change_request_id]) end if @change_request - @change_request_user_response = render_to_string(:template => "admin_public_body_change_requests/add_accepted", - :formats => [:text]) + @change_request_user_response = render_to_string(template: "admin_public_body_change_requests/add_accepted", + formats: [:text]) @public_body.name = @change_request.public_body_name @public_body.request_email = @change_request.public_body_email @public_body.last_edit_comment = @change_request.comment_for_public_body end - render :formats => [:html] + render formats: [:html] end def create @@ -56,7 +56,7 @@ def create if @public_body.save if @change_request response_text = params[:response].gsub(_("[Authority URL will be inserted here]"), - public_body_url(@public_body, :only_path => false)) + public_body_url(@public_body, only_path: false)) @change_request.close! @change_request.send_response(params[:subject], response_text) end @@ -64,7 +64,7 @@ def create redirect_to admin_body_url(@public_body) else @public_body.build_all_translations - render :action => 'new' + render action: 'new' end end end @@ -106,7 +106,7 @@ def update redirect_to admin_body_url(@public_body) else @public_body.build_all_translations - render :action => 'edit' + render action: 'edit' end end end @@ -127,7 +127,7 @@ def destroy def mass_tag lookup_query - if params[:tag] and params[:tag] != "" + if params[:tag] && (params[:tag] != "") if params[:table_name] == 'exact' bodies = @public_bodies_by_tag elsif params[:table_name] == 'substring' @@ -145,7 +145,7 @@ def mass_tag end end - redirect_to admin_bodies_url(:query => @query, :page => @page) + redirect_to admin_bodies_url(query: @query, page: @page) end def import_csv @@ -165,7 +165,7 @@ def import_csv csv_contents = retrieve_csv_data(params[:temporary_csv_file]) @original_csv_file = params[:original_csv_file] end - if !csv_contents.nil? + unless csv_contents.nil? # Try with dry run first errors, notes = PublicBody. import_csv(csv_contents, @@ -175,7 +175,7 @@ def import_csv admin_current_user, AlaveteliLocalization.available_locales) - if errors.size == 0 + if errors.empty? if dry_run_only notes.push("Dry run was successful, real run would do as above.") # Store the csv file for ease of performing the real run @@ -190,9 +190,7 @@ def import_csv admin_current_user, AlaveteliLocalization. available_locales) - if errors.size != 0 - raise "dry run mismatched real run" - end + raise "dry run mismatched real run" if !errors.empty? notes.push("Import was successful.") end end @@ -207,40 +205,36 @@ def import_csv # Save the contents to a temporary file - not using Tempfile as we need # the file to persist between requests. Return the name of the file. def store_csv_data(csv_contents) - tempfile_name = "csv_upload-#{Time.zone.now.strftime("%Y%m%d")}-#{SecureRandom.random_number(10000)}" - tempfile = File.new(File.join(Dir::tmpdir, tempfile_name), 'w') + tempfile_name = "csv_upload-#{Time.zone.now.strftime("%Y%m%d")}-#{SecureRandom.random_number(10_000)}" + tempfile = File.new(File.join(Dir.tmpdir, tempfile_name), 'w') tempfile.write(csv_contents) tempfile.close - return tempfile_name + tempfile_name end # Get csv contents from the file whose name is passed, as long as the # name is of the expected form. # Delete the file, return the contents. def retrieve_csv_data(tempfile_name) - if not /csv_upload-\d{8}-\d{1,5}/.match(tempfile_name) + unless /csv_upload-\d{8}-\d{1,5}/.match(tempfile_name) raise "Invalid filename in upload_csv: #{tempfile_name}" end tempfile_path = File.join(Dir.tmpdir, tempfile_name) - if !File.exist?(tempfile_path) + unless File.exist?(tempfile_path) raise "Missing file in upload_csv: #{tempfile_name}" end csv_contents = File.read(tempfile_path) File.delete(tempfile_path) - return csv_contents + csv_contents end def lookup_query @locale = AlaveteliLocalization.locale AlaveteliLocalization.with_locale(@locale) do @query = params[:query] - if @query == "" - @query = nil - end + @query = nil if @query == "" @page = params[:page] - if @page == "" - @page = nil - end + @page = nil if @page == "" query = if @query query_str = <<-EOF.strip_heredoc @@ -265,7 +259,7 @@ def lookup_query joins(:translations). where(query). merge(PublicBody::Translation.order(:name)). - paginate(:page => @page, :per_page => 100) + paginate(page: @page, per_page: 100) end @public_bodies_by_tag = PublicBody.find_by_tag(@query) diff --git a/app/controllers/admin_public_body_headings_controller.rb b/app/controllers/admin_public_body_headings_controller.rb index 8d3a5bde7c..36c28ddb1c 100644 --- a/app/controllers/admin_public_body_headings_controller.rb +++ b/app/controllers/admin_public_body_headings_controller.rb @@ -2,7 +2,7 @@ class AdminPublicBodyHeadingsController < AdminController include TranslatableParams - before_action :set_public_body_heading, :only => [:edit, :update, :destroy] + before_action :set_public_body_heading, only: [:edit, :update, :destroy] def new @public_body_heading = PublicBodyHeading.new @@ -17,7 +17,7 @@ def create redirect_to admin_categories_url else @public_body_heading.build_all_translations - render :action => 'new' + render action: 'new' end end end @@ -33,7 +33,7 @@ def update redirect_to edit_admin_heading_path(@public_body_heading) else @public_body_heading.build_all_translations - render :action => 'edit' + render action: 'edit' end end end @@ -49,7 +49,7 @@ def reorder if transaction[:success] head :ok else - render :plain => transaction[:error], :status => :unprocessable_entity + render plain: transaction[:error], status: :unprocessable_entity end end @@ -57,9 +57,9 @@ def reorder_categories transaction = reorder_categories_for_heading(params[:id], params[:categories]) if transaction[:success] head :ok - return + nil else - render :plain => transaction[:error], :status => :unprocessable_entity + render plain: transaction[:error], status: :unprocessable_entity end end @@ -82,15 +82,15 @@ def reorder_headings(headings) end end end - { :success => error.nil?, :error => error } + { success: error.nil?, error: error } end def reorder_categories_for_heading(heading_id, categories) error = nil ActiveRecord::Base.transaction do categories.each_with_index do |category_id, index| - conditions = { :public_body_category_id => category_id, - :public_body_heading_id => heading_id } + conditions = { public_body_category_id: category_id, + public_body_heading_id: heading_id } link = PublicBodyCategoryLink.where(conditions).first unless link error = "Couldn't find PublicBodyCategoryLink for category #{category_id}, heading #{heading_id}" @@ -103,7 +103,7 @@ def reorder_categories_for_heading(heading_id, categories) end end end - { :success => error.nil?, :error => error } + { success: error.nil?, error: error } end private diff --git a/app/controllers/admin_request_controller.rb b/app/controllers/admin_request_controller.rb index 63aedfc923..309c09dee3 100644 --- a/app/controllers/admin_request_controller.rb +++ b/app/controllers/admin_request_controller.rb @@ -23,8 +23,8 @@ def index end @info_requests = info_requests.order(created_at: :desc).paginate( - :page => params[:page], - :per_page => 100) + page: params[:page], + per_page: 100) end def show @@ -76,7 +76,7 @@ def update flash[:notice] = 'Request successfully updated.' redirect_to admin_request_url(@info_request) else - render :action => 'edit' + render action: 'edit' end end @@ -104,7 +104,6 @@ def move flash[:error] = "Couldn't find user '#{params[:user_url_name]}'" end - redirect_to admin_request_url(@info_request) elsif params[:commit] == 'Move request to authority' && !params[:public_body_url_name].blank? destination_body = PublicBody.find_by_url_name( params[:public_body_url_name] @@ -116,11 +115,10 @@ def move flash[:error] = "Couldn't find public body '#{ params[:public_body_url_name] }'" end - redirect_to admin_request_url(@info_request) else flash[:error] = "Please enter the user or authority to move the request to" - redirect_to admin_request_url(@info_request) end + redirect_to admin_request_url(@info_request) end def generate_upload_url @@ -134,12 +132,12 @@ def generate_upload_url end user = User.find_user_by_email(email) - if not user - user = User.new(:name => name, :email => email, :password => PostRedirect.generate_random_token) + unless user + user = User.new(name: name, email: email, password: PostRedirect.generate_random_token) user.save! end - if !@info_request.public_body.is_foi_officer?(user) + unless @info_request.public_body.is_foi_officer?(user) flash[:notice] = user.email + " is not an email at the domain @" + @info_request.public_body.foi_officer_domain_required + ", so won't be able to upload." redirect_to admin_request_url(@info_request) return @@ -148,16 +146,16 @@ def generate_upload_url # Bejeeps, look, sometimes a URL is something that belongs in a controller, jesus. # TODO: hammer this square peg into the round MVC hole post_redirect = PostRedirect.new( - :uri => upload_response_url(:url_title => @info_request.url_title), - :user_id => user.id) + uri: upload_response_url(url_title: @info_request.url_title), + user_id: user.id) post_redirect.save! flash[:notice] = { - :partial => "upload_email_message", - :locals => { - :name => name, - :email => email, - :url => confirm_url(:email_token => post_redirect.email_token) + partial: "upload_email_message", + locals: { + name: name, + email: email, + url: confirm_url(email_token: post_redirect.email_token) } } redirect_to admin_request_url(@info_request) @@ -197,7 +195,7 @@ def hide ).deliver_now flash[:notice] = _("Your message to {{recipient_user_name}} has " \ "been sent", - :recipient_user_name => @info_request.user. + recipient_user_name: @info_request.user. name.html_safe) else flash[:notice] = _("This external request has been hidden") diff --git a/app/controllers/admin_spam_addresses_controller.rb b/app/controllers/admin_spam_addresses_controller.rb index 53e2e8c45c..92830fdc88 100644 --- a/app/controllers/admin_spam_addresses_controller.rb +++ b/app/controllers/admin_spam_addresses_controller.rb @@ -1,6 +1,6 @@ class AdminSpamAddressesController < AdminController - before_action :set_spam_address, :only => [:destroy] + before_action :set_spam_address, only: [:destroy] def index @spam_addresses = SpamAddress.all @@ -11,7 +11,7 @@ def create @spam_address = SpamAddress.new(spam_address_params) if @spam_address.save notice = "#{ @spam_address.email } has been added to the spam addresses list" - redirect_to admin_spam_addresses_path, :notice => notice + redirect_to admin_spam_addresses_path, notice: notice else @spam_addresses = SpamAddress.all render :index @@ -21,7 +21,7 @@ def create def destroy @spam_address.destroy notice = "#{ @spam_address.email } has been removed from the spam addresses list" - redirect_to admin_spam_addresses_path, :notice => notice + redirect_to admin_spam_addresses_path, notice: notice end private diff --git a/app/controllers/admin_track_controller.rb b/app/controllers/admin_track_controller.rb index d146388d1e..dbfe29ba88 100644 --- a/app/controllers/admin_track_controller.rb +++ b/app/controllers/admin_track_controller.rb @@ -6,7 +6,7 @@ class AdminTrackController < AdminController - before_action :set_track_thing, :only => [:destroy] + before_action :set_track_thing, only: [:destroy] def index @query = params[:query] @@ -17,7 +17,7 @@ def index end @admin_tracks = track_things.order(created_at: :desc). - paginate(:page => params[:page], :per_page => 100) + paginate(page: params[:page], per_page: 100) @popular = ActiveRecord::Base.connection.select_all("select count(*) as count, title, info_request_id from track_things join info_requests on info_request_id = info_requests.id where info_request_id is not null group by info_request_id, title order by count desc limit 10;") end diff --git a/app/controllers/admin_user_controller.rb b/app/controllers/admin_user_controller.rb index 5d6df278ab..4c43fbd704 100644 --- a/app/controllers/admin_user_controller.rb +++ b/app/controllers/admin_user_controller.rb @@ -34,27 +34,30 @@ def index # with_all_roles returns an array as it takes multiple queries # so we need to requery in order to paginate - if !@roles.empty? + unless @roles.empty? users = users.with_any_role(*@roles) - users = User.where(:id => users.map { |user| user.id }) + users = User.where(id: users.map(&:id)) end @admin_users = users.order(@sort_options[@sort_order]). - paginate(:page => params[:page], :per_page => 100) + paginate(page: params[:page], per_page: 100) render action: :index end def show @info_requests = @admin_user.info_requests + @info_request_batches = @admin_user.info_request_batches @comments = @admin_user.comments + if cannot? :admin, AlaveteliPro::Embargo @info_requests = @info_requests.not_embargoed + @info_request_batches = @info_request_batches.not_embargoed @comments = @admin_user.comments.not_embargoed end - @info_requests = @info_requests.paginate(:page => params[:page], - :per_page => 100) + + @info_requests = @info_requests.paginate(page: params[:page], per_page: 100) end def edit @@ -78,7 +81,7 @@ def update redirect_to admin_user_url(@admin_user) end else - render :action => 'edit' + render action: 'edit' end end @@ -111,9 +114,7 @@ def clear_bounce end def clear_profile_photo - if @admin_user.profile_photo - @admin_user.profile_photo.destroy - end + @admin_user.profile_photo.destroy if @admin_user.profile_photo flash[:notice] = "Profile photo cleared" redirect_to admin_user_url(@admin_user) @@ -162,25 +163,25 @@ def clear_features # and requirements are met def check_role_authorisation all_allowed = changed_role_ids.all? do |role_id| - role = Role.where(:id => role_id).first + role = Role.where(id: role_id).first role && @user.can_admin_role?(role.name.to_sym) end unless all_allowed flash[:error] = "Not permitted to change roles" - render :action => 'edit' and return false + render action: 'edit' and return false end end def changed_role_ids - params[:admin_user][:role_ids].map! { |role_id| role_id.to_i } + params[:admin_user][:role_ids].map!(&:to_i) (params[:admin_user][:role_ids] - @admin_user.role_ids) | (@admin_user.role_ids - params[:admin_user][:role_ids]) end def check_role_requirements role_names = Role. - where(:id => params[:admin_user][:role_ids]). - pluck(:name).map { |role| role.to_sym } + where(id: params[:admin_user][:role_ids]). + pluck(:name).map(&:to_sym) missing_required = Hash.new { |h, k| h[k] = [] } role_names.each do |role_name| Role.requires(role_name).each do |required_role_name| @@ -194,7 +195,7 @@ def check_role_requirements missing_required.each do |key, value| flash[:error] += " #{key} requires #{value.to_sentence}" end - render :action => 'edit' and return false + render action: 'edit' and return false end end diff --git a/app/controllers/alaveteli_pro/base_controller.rb b/app/controllers/alaveteli_pro/base_controller.rb index 65f47cb652..e4c47ba883 100644 --- a/app/controllers/alaveteli_pro/base_controller.rb +++ b/app/controllers/alaveteli_pro/base_controller.rb @@ -21,7 +21,7 @@ def pro_user_authenticated?(reason_params = nil) } end if !authenticated? - ask_to_login(reason_params) + ask_to_login(**reason_params) else unless current_user.is_pro? redirect_to( @@ -35,7 +35,7 @@ def pro_user_authenticated?(reason_params = nil) end return true end - return false + false end # An override of set_in_pro_area from ApplicationController, because we are diff --git a/app/controllers/alaveteli_pro/batch_request_authority_searches_controller.rb b/app/controllers/alaveteli_pro/batch_request_authority_searches_controller.rb index 43bce6874a..4067f92e75 100644 --- a/app/controllers/alaveteli_pro/batch_request_authority_searches_controller.rb +++ b/app/controllers/alaveteli_pro/batch_request_authority_searches_controller.rb @@ -65,7 +65,7 @@ def calculate_result_limit(search) def check_page_limit!(page, per_page) # Later pages are very expensive to load if page > MAX_RESULTS / per_page - raise ActiveRecord::RecordNotFound.new("Sorry. No pages after #{MAX_RESULTS / per_page}.") + raise ActiveRecord::RecordNotFound, "Sorry. No pages after #{MAX_RESULTS / per_page}." end end diff --git a/app/controllers/alaveteli_pro/draft_info_request_batches_controller.rb b/app/controllers/alaveteli_pro/draft_info_request_batches_controller.rb index ec6fd9795e..5a6a36419c 100644 --- a/app/controllers/alaveteli_pro/draft_info_request_batches_controller.rb +++ b/app/controllers/alaveteli_pro/draft_info_request_batches_controller.rb @@ -40,7 +40,7 @@ def update_bodies private - def respond_or_redirect(draft) + def respond_or_redirect(_draft) @query = params[:authority_query] @page = params[:page] if request.xhr? @@ -85,12 +85,12 @@ def respond_with_partial(draft, query, page) # different params. def draft_params params.require(:alaveteli_pro_draft_info_request_batch). - permit(:title, :body, :embargo_duration, :public_body_ids, ) + permit(:title, :body, :embargo_duration, :public_body_ids ) end def draft_params_multiple_bodies params.require(:alaveteli_pro_draft_info_request_batch). - permit(:title, :body, :embargo_duration, :public_body_ids => []) + permit(:title, :body, :embargo_duration, public_body_ids: []) end def update_bodies_params diff --git a/app/controllers/alaveteli_pro/embargo_extensions_controller.rb b/app/controllers/alaveteli_pro/embargo_extensions_controller.rb index 0771c3d265..d00ad8c16a 100644 --- a/app/controllers/alaveteli_pro/embargo_extensions_controller.rb +++ b/app/controllers/alaveteli_pro/embargo_extensions_controller.rb @@ -13,13 +13,9 @@ def create @info_request = @embargo.info_request # Embargoes cannot be updated individually on batch requests - if @info_request.info_request_batch_id - raise PermissionDenied - end + raise PermissionDenied if @info_request.info_request_batch_id - unless @embargo.expiring_soon? - raise PermissionDenied - end + raise PermissionDenied unless @embargo.expiring_soon? @embargo_extension = AlaveteliPro::EmbargoExtension.new(embargo_extension_params) diff --git a/app/controllers/alaveteli_pro/embargoes_controller.rb b/app/controllers/alaveteli_pro/embargoes_controller.rb index 1855b50fe2..656a3a6b87 100644 --- a/app/controllers/alaveteli_pro/embargoes_controller.rb +++ b/app/controllers/alaveteli_pro/embargoes_controller.rb @@ -36,9 +36,7 @@ def destroy authorize! :destroy, @embargo @info_request = @embargo.info_request # Embargoes cannot be updated individually on batch requests - if @info_request.info_request_batch_id - raise PermissionDenied - end + raise PermissionDenied if @info_request.info_request_batch_id if @embargo.destroy @info_request.log_event('expire_embargo', {}) flash[:notice] = _("Your request is now public!") @@ -46,7 +44,7 @@ def destroy flash[:error] = _("Sorry, something went wrong publishing your " \ "request, please try again.") end - return redirect_to request_url(@info_request) + redirect_to request_url(@info_request) end def destroy_batch diff --git a/app/controllers/alaveteli_pro/info_requests_controller.rb b/app/controllers/alaveteli_pro/info_requests_controller.rb index c3b51d4cfe..d751e985b4 100644 --- a/app/controllers/alaveteli_pro/info_requests_controller.rb +++ b/app/controllers/alaveteli_pro/info_requests_controller.rb @@ -18,8 +18,8 @@ def index request_summaries = @request_filter.results(current_user) @page = params[:page] || 1 @per_page = 10 - @request_summaries = request_summaries.paginate :page => @page, - :per_page => @per_page + @request_summaries = request_summaries.paginate page: @page, + per_page: @per_page end @@ -30,7 +30,8 @@ def new else create_initial_objects end - check_public_body_is_requestable; return if performed? + check_public_body_is_requestable + return if performed? end def preview diff --git a/app/controllers/alaveteli_pro/payment_methods_controller.rb b/app/controllers/alaveteli_pro/payment_methods_controller.rb index 0a53765565..770bd3cf75 100644 --- a/app/controllers/alaveteli_pro/payment_methods_controller.rb +++ b/app/controllers/alaveteli_pro/payment_methods_controller.rb @@ -21,7 +21,7 @@ def update Stripe::StripeError => e if send_exception_notifications? - ExceptionNotifier.notify_exception(e, :env => request.env) + ExceptionNotifier.notify_exception(e, env: request.env) end flash[:error] = _('There was a problem updating your payment details. ' \ diff --git a/app/controllers/alaveteli_pro/public_bodies_controller.rb b/app/controllers/alaveteli_pro/public_bodies_controller.rb index 417d74800b..36966dc339 100644 --- a/app/controllers/alaveteli_pro/public_bodies_controller.rb +++ b/app/controllers/alaveteli_pro/public_bodies_controller.rb @@ -5,9 +5,8 @@ class AlaveteliPro::PublicBodiesController < AlaveteliPro::BaseController def index query = params[:query] || "" - xapian_results = typeahead_search(query, :model => PublicBody, - :exclude_tags => [ 'defunct', - 'not_apply' ]) + xapian_results = typeahead_search(query, model: PublicBody, + exclude_tags: %w[defunct not_apply]) results = xapian_results.present? ? xapian_results.results : [] # Exclude any bodies we can't make a request to (in addition to the ones # we've already filtered out by the excluded tags above) diff --git a/app/controllers/alaveteli_pro/stripe_webhooks_controller.rb b/app/controllers/alaveteli_pro/stripe_webhooks_controller.rb index b10267da86..4bb9f98187 100644 --- a/app/controllers/alaveteli_pro/stripe_webhooks_controller.rb +++ b/app/controllers/alaveteli_pro/stripe_webhooks_controller.rb @@ -17,7 +17,7 @@ class UnknownPlanStripeWebhookError < StandardError; end render json: { error: exception.message }, status: 401 end - rescue_from UnknownPlanStripeWebhookError do |exception| + rescue_from UnknownPlanStripeWebhookError do |_exception| # accept it so it doesn't get resent but don't process it # (and don't generate an exception email for it) render json: { message: 'Does not appear to be one of our plans' }, @@ -97,7 +97,7 @@ def pro_account_from_stripe_event(event) def check_for_event_type unless @stripe_event.respond_to?(:type) msg = "undefined method `type' for #{ @stripe_event.inspect }" - raise MissingTypeStripeWebhookError.new(msg) + raise MissingTypeStripeWebhookError, msg end end diff --git a/app/controllers/alaveteli_pro/subscriptions_controller.rb b/app/controllers/alaveteli_pro/subscriptions_controller.rb index ab24d066de..927f527318 100644 --- a/app/controllers/alaveteli_pro/subscriptions_controller.rb +++ b/app/controllers/alaveteli_pro/subscriptions_controller.rb @@ -77,7 +77,7 @@ def create _('Coupon code has expired.') else if send_exception_notifications? - ExceptionNotifier.notify_exception(e, :env => request.env) + ExceptionNotifier.notify_exception(e, env: request.env) end _('There was a problem submitting your payment. You ' \ @@ -93,59 +93,57 @@ def create end def authorise - begin - @subscription = current_user.pro_account.subscriptions. - retrieve(params.require(:id)) - - if !@subscription - head :not_found - - elsif @subscription.require_authorisation? - respond_to do |format| - format.json do - render json: { - payment_intent: @subscription.payment_intent.client_secret, - callback_url: authorise_subscription_path(@subscription.id) - } - end + @subscription = current_user.pro_account.subscriptions. + retrieve(params.require(:id)) + + if !@subscription + head :not_found + + elsif @subscription.require_authorisation? + respond_to do |format| + format.json do + render json: { + payment_intent: @subscription.payment_intent.client_secret, + callback_url: authorise_subscription_path(@subscription.id) + } end + end - elsif @subscription.invoice_open? - flash[:error] = _('There was a problem authorising your payment. You ' \ - 'have not been charged. Please try again.') + elsif @subscription.invoice_open? + flash[:error] = _('There was a problem authorising your payment. You ' \ + 'have not been charged. Please try again.') - json_redirect_to plan_path( - remove_stripe_namespace(@subscription.plan.id) - ) + json_redirect_to plan_path( + remove_stripe_namespace(@subscription.plan.id) + ) - elsif @subscription.active? - current_user.add_role(:pro) + elsif @subscription.active? + current_user.add_role(:pro) - flash[:notice] = { - partial: 'alaveteli_pro/subscriptions/signup_message' - } - flash[:new_pro_user] = true + flash[:notice] = { + partial: 'alaveteli_pro/subscriptions/signup_message' + } + flash[:new_pro_user] = true - json_redirect_to alaveteli_pro_dashboard_path + json_redirect_to alaveteli_pro_dashboard_path - else - head :ok - end + else + head :ok + end - rescue Stripe::RateLimitError, - Stripe::InvalidRequestError, - Stripe::AuthenticationError, - Stripe::APIConnectionError, - Stripe::StripeError => e - if send_exception_notifications? - ExceptionNotifier.notify_exception(e, env: request.env) - end + rescue Stripe::RateLimitError, + Stripe::InvalidRequestError, + Stripe::AuthenticationError, + Stripe::APIConnectionError, + Stripe::StripeError => e + if send_exception_notifications? + ExceptionNotifier.notify_exception(e, env: request.env) + end - flash[:error] = _('There was a problem submitting your payment. You ' \ - 'have not been charged. Please try again later.') + flash[:error] = _('There was a problem submitting your payment. You ' \ + 'have not been charged. Please try again later.') - json_redirect_to plan_path('pro') - end + json_redirect_to plan_path('pro') end def destroy @@ -171,7 +169,7 @@ def destroy Stripe::APIConnectionError, Stripe::StripeError => e if send_exception_notifications? - ExceptionNotifier.notify_exception(e, :env => request.env) + ExceptionNotifier.notify_exception(e, env: request.env) end flash[:error] = _('There was a problem cancelling your account. Please ' \ diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb index 2b1c7f8aca..6dd05e2365 100644 --- a/app/controllers/api_controller.rb +++ b/app/controllers/api_controller.rb @@ -3,56 +3,56 @@ class ApiController < ApplicationController before_action :check_api_key before_action :check_external_request, - :only => [:add_correspondence, :update_state] + only: [:add_correspondence, :update_state] before_action :check_request_ownership, - :only => [:add_correspondence, :update_state] + only: [:add_correspondence, :update_state] def show_request @request = InfoRequest.find(params[:id]) raise PermissionDenied if @request.public_body_id != @public_body.id @request_data = { - :id => @request.id, - :url => make_url("request", @request.url_title), - :title => @request.title, - :created_at => @request.created_at, - :updated_at => @request.updated_at, - :status => @request.calculate_status, - :public_body_url => make_url("body", @request.public_body.url_name), - :request_email => @request.incoming_email, - :request_text => @request.last_event_forming_initial_request.outgoing_message.body, + id: @request.id, + url: make_url("request", @request.url_title), + title: @request.title, + created_at: @request.created_at, + updated_at: @request.updated_at, + status: @request.calculate_status, + public_body_url: make_url("body", @request.public_body.url_name), + request_email: @request.incoming_email, + request_text: @request.last_event_forming_initial_request.outgoing_message.body } if @request.user @request_data[:requestor_url] = make_url("user", @request.user.url_name) end - render :json => @request_data + render json: @request_data end def create_request json = ActiveSupport::JSON.decode(params[:request_json]) request = InfoRequest.new( - :title => json["title"], - :public_body_id => @public_body.id, - :described_state => "waiting_response", - :external_user_name => json["external_user_name"], - :external_url => json["external_url"] + title: json["title"], + public_body_id: @public_body.id, + described_state: "waiting_response", + external_user_name: json["external_user_name"], + external_url: json["external_url"] ) outgoing_message = OutgoingMessage.new( - :status => 'ready', - :message_type => 'initial_request', - :body => json["body"], - :last_sent_at => Time.zone.now, - :what_doing => 'normal_sort', - :info_request => request + status: 'ready', + message_type: 'initial_request', + body: json["body"], + last_sent_at: Time.zone.now, + what_doing: 'normal_sort', + info_request: request ) request.outgoing_messages << outgoing_message # Return an error if the request is invalid # (Can this ever happen?) - if !request.valid? - render :json => { + unless request.valid? + render json: { 'errors' => request.errors.full_messages } return @@ -71,7 +71,7 @@ def create_request request.set_described_state('waiting_response') # Return the URL and ID number. - render :json => { + render json: { 'url' => make_url("request", request.url_title), 'id' => request.id } @@ -88,7 +88,7 @@ def add_correspondence errors = [] - if !["request", "response"].include?(direction) + unless %w[request response].include?(direction) errors << "The direction parameter must be 'request' or 'response'" end @@ -106,8 +106,8 @@ def add_correspondence errors << "'#{new_state}' is not a valid request state" end - if !errors.empty? - render :json => { "errors" => errors }, :status => 500 + unless errors.empty? + render json: { "errors" => errors }, status: 500 return end @@ -115,12 +115,12 @@ def add_correspondence # In the 'request' direction, i.e. what we (Alaveteli) regard as outgoing outgoing_message = OutgoingMessage.new( - :info_request => @request, - :status => 'ready', - :message_type => 'followup', - :body => body, - :last_sent_at => sent_at, - :what_doing => 'normal_sort' + info_request: @request, + status: 'ready', + message_type: 'followup', + body: body, + last_sent_at: sent_at, + what_doing: 'normal_sort' ) @request.outgoing_messages << outgoing_message @request.save! @@ -134,14 +134,14 @@ def add_correspondence else # In the 'response' direction, i.e. what we (Alaveteli) regard as incoming attachment_hashes = [] - (attachments || []).each_with_index do |attachment, i| + (attachments || []).each_with_index do |attachment, _i| filename = File.basename(attachment.original_filename) attachment_body = attachment.read content_type = AlaveteliFileTypes.filename_and_content_to_mimetype(filename, attachment_body) || 'application/octet-stream' attachment_hashes.push( - :content_type => content_type, - :body => attachment_body, - :filename => filename + content_type: content_type, + body: attachment_body, + filename: filename ) end @@ -149,7 +149,7 @@ def add_correspondence @request.receive(mail, mail.encoded, - { :override_stop_new_responses => true }) + { override_stop_new_responses: true }) if new_state # we've already checked above that the status is valid @@ -163,8 +163,8 @@ def add_correspondence @request.set_described_state(new_state) end end - render :json => { - 'url' => make_url("request", @request.url_title), + render json: { + 'url' => make_url("request", @request.url_title) } end @@ -182,21 +182,23 @@ def update_state @request.set_described_state(new_state) end else - render :json => { + render json: { "errors" => ["'#{new_state}' is not a valid request state" ] }, - :status => 500 + status: 500 return end - render :json => { - 'url' => make_url("request", @request.url_title), + render json: { + 'url' => make_url("request", @request.url_title) } end def body_request_events feed_type = params[:feed_type] - raise PermissionDenied.new("#{@public_body.id} != #{params[:id]}") if @public_body.id != params[:id].to_i + if @public_body.id != params[:id].to_i + raise PermissionDenied, "#{@public_body.id} != #{params[:id]}" + end since_date_str = params[:since_date] since_event_id = params[:since_event_id] @@ -206,17 +208,17 @@ def body_request_events @events = InfoRequestEvent.where(event_type_clause). joins(:info_request). where("public_body_id = ?", @public_body.id). - includes([{:info_request => :user}, :outgoing_message]). + includes([{info_request: :user}, :outgoing_message]). order(created_at: :desc) if since_date_str begin since_date = Date.strptime(since_date_str, "%Y-%m-%d") rescue ArgumentError - render :json => {"errors" => [ + render json: {"errors" => [ "Parameter since_date must be in format yyyy-mm-dd (not '#{since_date_str}')" ] }, - :status => 500 + status: 500 return end @events = @events.where("info_request_events.created_at >= ?", since_date) @@ -228,10 +230,10 @@ def body_request_events begin event = InfoRequestEvent.find(since_event_id) rescue ActiveRecord::RecordNotFound - render :json => {"errors" => [ + render json: {"errors" => [ "Event ID #{since_event_id} not found" ] }, - :status => 500 + status: 500 return end @events = @events.where("info_request_events.created_at > ?", event.created_at) @@ -239,38 +241,36 @@ def body_request_events if feed_type == "atom" - render :template => "api/request_events", :formats => [:atom], :layout => false + render template: "api/request_events", formats: [:atom], layout: false elsif feed_type == "json" @event_data = [] - @events.each do |event| + @events.each do |json_event| - request = event.info_request + request = json_event.info_request this_event = { - :request_id => request.id, - :event_id => event.id, - :created_at => event.created_at.iso8601, - :event_type => event.event_type, - :request_url => request_url(request), - :request_email => request.incoming_email, - :title => request.title, - :body => event.outgoing_message.body, - :user_name => request.user_name, + request_id: request.id, + event_id: json_event.id, + created_at: json_event.created_at.iso8601, + event_type: json_event.event_type, + request_url: request_url(request), + request_email: request.incoming_email, + title: request.title, + body: json_event.outgoing_message.body, + user_name: request.user_name } - if request.user - this_event[:user_url] = user_url(request.user) - end + this_event[:user_url] = user_url(request.user) if request.user @event_data.push(this_event) end - render :json => @event_data + render json: @event_data else - raise ActiveRecord::RecordNotFound.new("Unrecognised feed type: #{feed_type}") + raise ActiveRecord::RecordNotFound, "Unrecognised feed type: #{feed_type}" end end protected def check_api_key - raise PermissionDenied.new("Missing required parameter 'k'") if params[:k].nil? + raise PermissionDenied, "Missing required parameter 'k'" if params[:k].nil? @public_body = PublicBody.find_by_api_key(params[:k].gsub(' ', '+')) raise PermissionDenied if @public_body.nil? end @@ -278,20 +278,20 @@ def check_api_key def check_external_request @request = InfoRequest.find_by_id(params[:id]) if @request.nil? - render :json => { "errors" => ["Could not find request #{params[:id]}"] }, :status => 404 + render json: { "errors" => ["Could not find request #{params[:id]}"] }, status: 404 elsif !@request.is_external? - render :json => { "errors" => ["Request #{params[:id]} cannot be updated using the API"] }, :status => 403 + render json: { "errors" => ["Request #{params[:id]} cannot be updated using the API"] }, status: 403 end end def check_request_ownership if @request.public_body_id != @public_body.id - render :json => { "errors" => ["You do not own request #{params[:id]}"] }, :status => 403 + render json: { "errors" => ["You do not own request #{params[:id]}"] }, status: 403 end end private def make_url(*args) - "http://" + AlaveteliConfiguration::domain + "/" + args.join("/") + "http://" + AlaveteliConfiguration.domain + "/" + args.join("/") end end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2548c0dca1..24f422e993 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -19,12 +19,12 @@ class RouteNotFound < StandardError skip_before_action :verify_authenticity_token, unless: :authenticated? # Deal with access denied errors from CanCan - rescue_from CanCan::AccessDenied do |exception| + rescue_from CanCan::AccessDenied do |_exception| raise PermissionDenied end # assign our own handler method for non-local exceptions - rescue_from Exception, :with => :render_exception + rescue_from Exception, with: :render_exception # Standard headers, footers and navigation for whole site layout "default" @@ -32,7 +32,7 @@ class RouteNotFound < StandardError include FastGettext::Translation # make functions like _, n_, N_ etc available) include AlaveteliPro::PostRedirectHandler - # Note: a filter stops the chain if it redirects or renders something + # NOTE: a filter stops the chain if it redirects or renders something before_action :html_response before_action :authentication_check before_action :check_in_post_redirect @@ -103,7 +103,7 @@ def set_gettext_locale # egrep "CONSUME MEMORY: [0-9]{7} KB" production.log around_action :record_memory def record_memory - record_memory = AlaveteliConfiguration::debug_record_memory + record_memory = AlaveteliConfiguration.debug_record_memory if record_memory logger.info "Processing request for #{request.url} with Rails process #{Process.pid}" File.read("/proc/#{Process.pid}/status").match(/VmRSS:\s+(\d+)/) @@ -172,9 +172,7 @@ def clear_session_credentials def render_exception(exception) # In development let Rails handle the exception with its stack trace # templates. - if Rails.application.config.consider_all_requests_local - raise exception - end + raise exception if Rails.application.config.consider_all_requests_local @exception_backtrace = exception.backtrace.join("\n") @exception_class = exception.class.to_s @@ -193,12 +191,12 @@ def render_exception(exception) message << " " << backtrace.join("\n ") Rails.logger.fatal("#{message}\n\n") if send_exception_notifications? - ExceptionNotifier.notify_exception(exception, :env => request.env) + ExceptionNotifier.notify_exception(exception, env: request.env) end @status = 500 end respond_to do |format| - format.html { render :template => "general/exception_caught", :status => @status } + format.html { render template: "general/exception_caught", status: @status } format.any { head @status } end end @@ -209,7 +207,7 @@ def render_hidden(template='request/hidden', opts = {}) raise ActiveRecord::RecordNotFound if @info_request && @info_request.embargo response_code = opts.delete(:response_code) { 403 } # forbidden - options = { :template => template, :status => response_code }.merge(opts) + options = { template: template, status: response_code }.merge(opts) respond_to do |format| format.html { render(options) } @@ -231,7 +229,7 @@ def set_in_pro_area # Override the Rails method to only set the CSRF form token if there is a # logged in user - def form_authenticity_token(*args) + def form_authenticity_token(**args) super if authenticated? end @@ -287,7 +285,7 @@ def authenticated_user end # For CanCanCan and other libs which need a Devise-like current_user method - alias_method :current_user, :authenticated_user + alias current_user authenticated_user helper_method :current_user # Do a POST redirect. This is a nasty hack - we store the posted values in @@ -320,14 +318,12 @@ def add_post_redirect_param_to_uri(uri) else uri += "&post_redirect=1" end + elsif uri.include?("#") + uri.sub!("#", "?post_redirect=1#") else - if uri.include?("#") - uri.sub!("#", "?post_redirect=1#") - else - uri += "?post_redirect=1" - end + uri += "?post_redirect=1" end - return uri + uri end # If we are in a faked redirect to POST request, then set post params. @@ -362,21 +358,21 @@ def authentication_check # def check_read_only - if !AlaveteliConfiguration::read_only.empty? + unless AlaveteliConfiguration.read_only.empty? if feature_enabled?(:annotations) flash[:notice] = { - :partial => "general/read_only_annotations", - :locals => { - :site_name => site_name, - :read_only => AlaveteliConfiguration.read_only + partial: "general/read_only_annotations", + locals: { + site_name: site_name, + read_only: AlaveteliConfiguration.read_only } } else flash[:notice] = { - :partial => "general/read_only", - :locals => { - :site_name => site_name, - :read_only => AlaveteliConfiguration.read_only + partial: "general/read_only", + locals: { + site_name: site_name, + read_only: AlaveteliConfiguration.read_only } } end @@ -388,13 +384,13 @@ def check_read_only # Convert URL name for sort by order, to Xapian query def order_to_sort_by(sortby) if sortby.nil? - return [nil, nil] + [nil, nil] elsif sortby == 'newest' - return ['created_at', true] + ['created_at', true] elsif sortby == 'described' - return ['described_at', true] # use this for some RSS + ['described_at', true] # use this for some RSS elsif sortby == 'relevant' - return [nil, nil] + [nil, nil] else raise "Unknown sort order " + @sortby end @@ -413,28 +409,28 @@ def perform_search(models, query, sortby, collapse, per_page = 25, this_page = n @page = this_page || get_search_page_from_params result = ActsAsXapian::Search.new(models, @query, - :offset => (@page - 1) * @per_page, - :limit => @per_page, - :sort_by_prefix => order, - :sort_by_ascending => ascending, - :collapse_by_prefix => collapse + offset: (@page - 1) * @per_page, + limit: @per_page, + sort_by_prefix: order, + sort_by_ascending: ascending, + collapse_by_prefix: collapse ) result.results # Touch the results to load them, otherwise accessing them from the view # might fail later if the database has subsequently been reopened. - return result + result end def get_search_page_from_params page = (params[:page] || "1").to_i page = 1 if page < 1 - return page + page end def typeahead_search(query, options) @page = get_search_page_from_params @per_page = options[:per_page] || 25 - options.merge!( :page => @page, - :per_page => @per_page ) + options.merge!( page: @page, + per_page: @per_page ) typeahead_search = TypeaheadSearch.new(query, options) typeahead_search.xapian_search end @@ -456,15 +452,13 @@ def set_last_body(public_body) def country_from_ip return AlaveteliGeoIP.country_code_from_ip(user_ip) if user_ip - AlaveteliConfiguration::iso_country_code + AlaveteliConfiguration.iso_country_code end def user_ip - begin - request.remote_ip - rescue ActionDispatch::RemoteIp::IpSpoofAttackError - nil - end + request.remote_ip + rescue ActionDispatch::RemoteIp::IpSpoofAttackError + nil end # URL Encode the path parameter for use in render_exception @@ -473,14 +467,14 @@ def user_ip # # Returns a Hash def sanitize_path(params) - params.merge!(:path => Rack::Utils.escape(params[:path])) if params.key?(:path) + params.merge!(path: Rack::Utils.escape(params[:path])) if params.key?(:path) end # Collect the current and available locales for the locale switcher # # Returns a Hash def collect_locales - @locales = { :current => AlaveteliLocalization.locale, :available => [] } + @locales = { current: AlaveteliLocalization.locale, available: [] } AlaveteliLocalization.available_locales.each do |possible_locale| if possible_locale == AlaveteliLocalization.locale @locales[:current] = possible_locale diff --git a/app/controllers/comment_controller.rb b/app/controllers/comment_controller.rb index 533ee8a589..1d96061325 100644 --- a/app/controllers/comment_controller.rb +++ b/app/controllers/comment_controller.rb @@ -6,12 +6,12 @@ class CommentController < ApplicationController before_action :build_comment, only: [:new] - before_action :check_read_only, :only => [ :new ] - before_action :find_info_request, :only => [ :new ] - before_action :create_track_thing, :only => [ :new ] - before_action :reject_unless_comments_allowed, :only => [ :new ] - before_action :reject_if_user_banned, :only => [ :new ] - before_action :set_in_pro_area, :only => [ :new ] + before_action :check_read_only, only: [ :new ] + before_action :find_info_request, only: [ :new ] + before_action :create_track_thing, only: [ :new ] + before_action :reject_unless_comments_allowed, only: [ :new ] + before_action :reject_if_user_banned, only: [ :new ] + before_action :set_in_pro_area, only: [ :new ] def new if params[:comment] @@ -25,13 +25,13 @@ def new # See if values were valid or not if !params[:comment] || !@existing_comment.nil? || !@comment.valid? || params[:reedit] @comment ||= @info_request.comments.new - render :action => 'new' + render action: 'new' return end # Show preview page, if it is a preview if params[:preview].to_i == 1 - render :action => 'preview' + render action: 'preview' return end @@ -111,19 +111,19 @@ def create_track_thing # comment block. def reject_unless_comments_allowed unless feature_enabled?(:annotations) && @info_request.comments_allowed? - redirect_to request_url(@info_request), :notice => "Comments are not allowed on this request" + redirect_to request_url(@info_request), notice: "Comments are not allowed on this request" end end # Banned from adding comments? def reject_if_user_banned - return unless authenticated? && !authenticated_user.can_make_comments? + return if !authenticated? || authenticated_user.can_make_comments? - if authenticated_user.exceeded_limit?(:comments) - render template: 'comment/rate_limited' - else + if authenticated_user.banned? @details = authenticated_user.can_fail_html render template: 'user/banned' + else + render template: 'comment/rate_limited' end end @@ -148,13 +148,13 @@ def block_spam_comments? def handle_spam_comment(user) if send_exception_notifications? e = Exception.new("Possible spam annotation from user #{ user.id }") - ExceptionNotifier.notify_exception(e, :env => request.env) + ExceptionNotifier.notify_exception(e, env: request.env) end if block_spam_comments? flash.now[:error] = _("Sorry, we're currently unable to add your " \ "annotation. Please try again later.") - render :action => 'new' + render action: 'new' true end end diff --git a/app/controllers/concerns/fragment_cachable.rb b/app/controllers/concerns/fragment_cachable.rb index 742c8ec53d..fd68aed6bb 100644 --- a/app/controllers/concerns/fragment_cachable.rb +++ b/app/controllers/concerns/fragment_cachable.rb @@ -11,7 +11,7 @@ def foi_fragment_cache_part_path(param) id = param['id'] || param[:id] first_three_digits = id.to_s[0..2] path = path.sub("/request/", "/request/" + first_three_digits + "/") - return path + path end def foi_fragment_cache_path(param) @@ -19,16 +19,16 @@ def foi_fragment_cache_path(param) max_file_length = 255 - 35 # we subtract 35 because tempfile # adds on a variable number of # characters - return File.join(File.split(path).map { |x| x[0...max_file_length] }) + File.join(File.split(path).map { |x| x[0...max_file_length] }) end def foi_fragment_cache_exists?(key_path) - return File.exist?(key_path) + File.exist?(key_path) end def foi_fragment_cache_read(key_path) logger.info "Reading from fragment cache #{key_path}" - return File.read(key_path) + File.read(key_path) end def foi_fragment_cache_write(key_path, content) diff --git a/app/controllers/concerns/translatable_params.rb b/app/controllers/concerns/translatable_params.rb index a1c4d79630..add0f7f0e4 100644 --- a/app/controllers/concerns/translatable_params.rb +++ b/app/controllers/concerns/translatable_params.rb @@ -44,7 +44,7 @@ def translation_keys end def slice_translations_params(sliced_params) - if translation_params = sliced_params[:translations_attributes] + if (translation_params = sliced_params[:translations_attributes]) translation_params.each do |locale, attributes| translation_params[locale] = attributes.slice(*translation_keys) end diff --git a/app/controllers/concerns/user_spam_check.rb b/app/controllers/concerns/user_spam_check.rb index 8dd3eadfd0..cbadf9c83f 100644 --- a/app/controllers/concerns/user_spam_check.rb +++ b/app/controllers/concerns/user_spam_check.rb @@ -24,7 +24,7 @@ def handle_spam_user(user, &block) true elsif send_exception_notifications? e = Exception.new(msg) - ExceptionNotifier.notify_exception(e, :env => request.env) + ExceptionNotifier.notify_exception(e, env: request.env) false end diff --git a/app/controllers/followups_controller.rb b/app/controllers/followups_controller.rb index f558eb7fc0..e5278ae283 100644 --- a/app/controllers/followups_controller.rb +++ b/app/controllers/followups_controller.rb @@ -12,9 +12,9 @@ class FollowupsController < ApplicationController :set_refusal_advice, :set_in_pro_area - before_action :check_reedit, :only => [:preview, :create] + before_action :check_reedit, only: [:preview, :create] - before_action :check_responses_allowed, :only => [:create] + before_action :check_responses_allowed, only: [:create] def new end @@ -28,17 +28,15 @@ def create send_followup redirect_to request_url(@info_request) and return end - render :action => 'new' + render action: 'new' end def preview @outgoing_message.info_request = @info_request - if @outgoing_message.what_doing == 'internal_review' - @internal_review = true - end + @internal_review = true if @outgoing_message.what_doing == 'internal_review' unless @outgoing_message.valid? - render :action => 'new' - return + render action: 'new' + nil end end @@ -47,40 +45,37 @@ def preview def check_can_followup unless @info_request.is_followupable?(@incoming_message) @reason = @info_request.followup_bad_reason - render :action => 'followup_bad' - return + render action: 'followup_bad' + nil end end def set_internal_review @internal_review = false - if params[:internal_review] - @internal_review = true - end + @internal_review = true if params[:internal_review] end def check_reedit if params[:reedit] - render :action => 'new' - return + render action: 'new' + nil end end def check_request_matches_incoming_message - if @incoming_message and @info_request != @incoming_message.info_request - raise ActiveRecord::RecordNotFound. - new("Incoming message #{@incoming_message.id} does not belong " \ - "to request #{@info_request.id}") + if @incoming_message && (@info_request != @incoming_message.info_request) + raise ActiveRecord::RecordNotFound, "Incoming message #{@incoming_message.id} does not belong " \ + "to request #{@info_request.id}" end end def check_responses_allowed if @info_request.allow_new_responses_from == "nobody" - flash.now[:error] = { :partial => "followup_not_sent", - :locals => { - :help_contact_path => help_contact_path } } - render :action => 'new' - return + flash.now[:error] = { partial: "followup_not_sent", + locals: { + help_contact_path: help_contact_path } } + render action: 'new' + nil end end @@ -94,7 +89,7 @@ def check_user_credentials end if authenticated? && !authenticated_user.can_make_followup? @details = authenticated_user.can_fail_html - render :template => 'user/banned' + render template: 'user/banned' return end render_hidden if authenticated? && cannot?(:read, @info_request) @@ -102,19 +97,19 @@ def check_user_credentials def get_login_params(is_incoming, info_request) if is_incoming - { :web => _("To send a follow up message to {{authority_name}}", - :authority_name => info_request.public_body.name), - :email => _("Then you can write follow up message to {{authority_name}}.", - :authority_name => info_request.public_body.name), - :email_subject => _("Write your FOI follow up message to {{authority_name}}", - :authority_name => info_request.public_body.name) } + { web: _("To send a follow up message to {{authority_name}}", + authority_name: info_request.public_body.name), + email: _("Then you can write follow up message to {{authority_name}}.", + authority_name: info_request.public_body.name), + email_subject: _("Write your FOI follow up message to {{authority_name}}", + authority_name: info_request.public_body.name) } else - { :web => _("To reply to {{authority_name}}.", - :authority_name => info_request.public_body.name), - :email => _("Then you can write your reply to {{authority_name}}.", - :authority_name => info_request.public_body.name), - :email_subject => _("Write a reply to {{authority_name}}", - :authority_name => info_request.public_body.name) } + { web: _("To reply to {{authority_name}}.", + authority_name: info_request.public_body.name), + email: _("Then you can write your reply to {{authority_name}}.", + authority_name: info_request.public_body.name), + email_subject: _("Write a reply to {{authority_name}}", + authority_name: info_request.public_body.name) } end end @@ -193,10 +188,11 @@ def set_incoming_message end def set_info_request - if current_user && current_user.is_pro? + if current_user @info_request = current_user.info_requests.find_by(id: params[:request_id].to_i) end + @info_request ||= InfoRequest.not_embargoed.find(params[:request_id].to_i) end @@ -220,7 +216,7 @@ def set_refusal_advice def set_params @is_owning_user = @info_request.is_owning_user?(authenticated_user) @gone_postal = params[:gone_postal] - @gone_postal = false if !@is_owning_user + @gone_postal = false unless @is_owning_user set_postal_addresses if @gone_postal @collapse_quotes = !params[:unfold] end diff --git a/app/controllers/general_controller.rb b/app/controllers/general_controller.rb index dfa30f67ea..f641ef151e 100644 --- a/app/controllers/general_controller.rb +++ b/app/controllers/general_controller.rb @@ -17,50 +17,25 @@ class GeneralController < ApplicationController def frontpage medium_cache @locale = AlaveteliLocalization.locale - successful_query = InfoRequestEvent.make_query_from_params( :latest_status => ['successful'] ) + successful_query = InfoRequestEvent.make_query_from_params( latest_status: ['successful'] ) @request_events, @request_events_all_successful = InfoRequest.recent_requests @track_thing = TrackThing.create_track_for_search_query(successful_query) @number_of_requests = InfoRequest.is_searchable.count @number_of_authorities = PublicBody.visible.count - @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), - :title => _('Successful requests'), - :has_json => true } ] + @feed_autodetect = [ { url: do_track_url(@track_thing, 'feed'), + title: _('Successful requests'), + has_json: true } ] end # Display blog entries def blog - if AlaveteliConfiguration::blog_feed.empty? - raise ActiveRecord::RecordNotFound.new("Page not enabled") - end + raise(ActiveRecord::RecordNotFound, "Page not enabled") unless Blog.enabled? medium_cache - - get_blog_content - end - - def get_blog_content - @feed_autodetect = [] - @feed_url = AlaveteliConfiguration::blog_feed - separator = @feed_url.include?('?') ? '&' : '?' - @feed_url = "#{ @feed_url }#{ separator }lang=" \ - "#{ AlaveteliLocalization.html_lang }" - @blog_items = [] - if not @feed_url.empty? - timeout = if AlaveteliConfiguration.blog_timeout.blank? - 60 - else - AlaveteliConfiguration.blog_timeout - end - content = quietly_try_to_open(@feed_url, timeout) - if !content.empty? - @data = XmlSimple.xml_in(content) - @channel = @data['channel'][0] - @blog_items = @channel.fetch('item') { [] } - @feed_autodetect = [{:url => @feed_url, :title => "#{site_name} blog"}] - end - end + @blog = Blog.new @twitter_user = AlaveteliConfiguration.twitter_username @facebook_user = AlaveteliConfiguration.facebook_username + @feed_autodetect = @blog.feeds end # Just does a redirect from ?query= search to /query @@ -70,10 +45,10 @@ def search_redirect @query = nil @page = 1 @advanced = !params[:advanced].nil? - render :action => "search" + render action: "search" else query_parts = @query.split("/") - if !['bodies', 'requests', 'users', 'all'].include?(query_parts[-1]) + if !%w[bodies requests users all].include?(query_parts[-1]) redirect_to search_url([@query, "all"], params) else redirect_to search_url(@query, params) @@ -89,7 +64,7 @@ def search combined = params[:combined].split("/") @sortby = nil @bodies = @requests = @users = true - if combined.size > 0 && (['advanced'].include?(combined[-1])) + if combined.size > 0 && ['advanced'].include?(combined[-1]) combined.pop @advanced = true else @@ -97,14 +72,12 @@ def search end # TODO: currently /described isn't linked to anywhere, just used in RSS and for /list/successful # This is because it's confusingly different from /newest - but still useful for power users. - if combined.size > 0 && (['newest', 'described', 'relevant'].include?(combined[-1])) + if combined.size > 0 && %w[newest described relevant].include?(combined[-1]) @sort_postfix = combined.pop @sortby = @sort_postfix end - if !params[:view].nil? - combined += [params[:view]] - end - if combined.size > 0 && (['bodies', 'requests', 'users', 'all'].include?(combined[-1])) + combined += [params[:view]] unless params[:view].nil? + if combined.size > 0 && %w[bodies requests users all].include?(combined[-1]) @variety_postfix = combined.pop case @variety_postfix when 'bodies' @@ -124,9 +97,7 @@ def search end end @query = combined.join("/") - if params[:query].nil? - params[:query] = @query - end + params[:query] = @query if params[:query].nil? if @variety_postfix != "all" && @requests @query = InfoRequestEvent.make_query_from_params(params) end @@ -136,7 +107,7 @@ def search # structured query which should show newest first, rather than a free text search # where we want most relevant as default. begin - dummy_query = ActsAsXapian::Search.new([InfoRequestEvent], @query, :limit => 1) + dummy_query = ActsAsXapian::Search.new([InfoRequestEvent], @query, limit: 1) rescue => e flash[:error] = "Your query was not quite right. #{e.message}" redirect_to search_url("") @@ -158,7 +129,7 @@ def search # Later pages are very expensive to load if @page > MAX_RESULTS / requests_per_page - raise ActiveRecord::RecordNotFound.new("Sorry. No pages after #{MAX_RESULTS / requests_per_page}.") + raise ActiveRecord::RecordNotFound, "Sorry. No pages after #{MAX_RESULTS / requests_per_page}." end @total_hits = @xapian_requests_hits = @xapian_bodies_hits = @xapian_users_hits = 0 @@ -191,13 +162,13 @@ def search end # Spelling and highight words are same for all three queries - @highlight_words = @request_for_spelling.words_to_highlight(:regex => true, :include_original => true) - if !(@request_for_spelling.spelling_correction =~ /[a-z]+:/) + @highlight_words = @request_for_spelling.words_to_highlight(regex: true, include_original: true) + unless @request_for_spelling.spelling_correction =~ /[a-z]+:/ @spelling_correction = @request_for_spelling.spelling_correction end @track_thing = TrackThing.create_track_for_search_query(@query, @variety_postfix) - @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss], :has_json => true } ] + @feed_autodetect = [ { url: do_track_url(@track_thing, 'feed'), title: @track_thing.params[:title_in_rss], has_json: true } ] end # Handle requests for non-existent URLs - will be handled by ApplicationController::render_exception diff --git a/app/controllers/health/checks_controller.rb b/app/controllers/health/checks_controller.rb new file mode 100644 index 0000000000..9abe3254db --- /dev/null +++ b/app/controllers/health/checks_controller.rb @@ -0,0 +1,19 @@ +module Health + ## + # This controller is responsible for running health checks and returning + # either a 200 or 500 response for internal monitoring alerting + # + # See checks configured in config/initializers/health_checks.rb + # + class ChecksController < ApplicationController + def index + @health_checks = HealthChecks.all + + if HealthChecks.ok? + render action: :index, layout: false + else + render action: :index, layout: false , status: 500 + end + end + end +end diff --git a/app/controllers/health/metrics_controller.rb b/app/controllers/health/metrics_controller.rb new file mode 100644 index 0000000000..ab1a30d12e --- /dev/null +++ b/app/controllers/health/metrics_controller.rb @@ -0,0 +1,16 @@ +module Health + ## + # This controller is responsible for providing an overview of system metrics + # for internal monitoring checks + # + class MetricsController < ApplicationController + skip_before_action :html_response + + layout false + + def index + @sidekiq_stats = Sidekiq::Stats.new + @xapian_queued_jobs = ActsAsXapian::ActsAsXapianJob.count + end + end +end diff --git a/app/controllers/health_checks_controller.rb b/app/controllers/health_checks_controller.rb deleted file mode 100644 index 87a39ea59d..0000000000 --- a/app/controllers/health_checks_controller.rb +++ /dev/null @@ -1,13 +0,0 @@ -class HealthChecksController < ApplicationController - - def index - @health_checks = HealthChecks.all - - if HealthChecks.ok? - render :action => :index, :layout => false - else - render :action => :index, :layout => false , :status => 500 - end - end - -end diff --git a/app/controllers/holiday_controller.rb b/app/controllers/holiday_controller.rb index d2031ba77f..5dc229c904 100644 --- a/app/controllers/holiday_controller.rb +++ b/app/controllers/holiday_controller.rb @@ -12,12 +12,12 @@ class HolidayController < ApplicationController def due_date if params[:holiday] @request_date = Date.strptime(params[:holiday]) or raise "Invalid date" - @due_date = Holiday.due_date_from(@request_date, AlaveteliConfiguration::reply_late_after_days, AlaveteliConfiguration::working_or_calendar_days) + @due_date = Holiday.due_date_from(@request_date, AlaveteliConfiguration.reply_late_after_days, AlaveteliConfiguration.working_or_calendar_days) @skipped = Holiday. where(['day >= ? AND day <= ?', @request_date.strftime("%F"), - @due_date.strftime("%F")]).to_a.collect { |h| h.day }.sort + @due_date.strftime("%F")]).to_a.collect(&:day).sort end end diff --git a/app/controllers/info_request_batch_controller.rb b/app/controllers/info_request_batch_controller.rb index e68396fe55..d553bf9111 100644 --- a/app/controllers/info_request_batch_controller.rb +++ b/app/controllers/info_request_batch_controller.rb @@ -1,8 +1,8 @@ class InfoRequestBatchController < ApplicationController - before_action :set_in_pro_area, :only => [:show] - before_action :load_and_authorise_resource, :only => [:show] - before_action :redirect_embargoed_requests_for_pro_users, :only => [:show] - before_action :redirect_public_requests_from_pro_context, :only => [:show] + before_action :set_in_pro_area, only: [:show] + before_action :load_and_authorise_resource, only: [:show] + before_action :redirect_embargoed_requests_for_pro_users, only: [:show] + before_action :redirect_public_requests_from_pro_context, only: [:show] def show @per_page = 25 @@ -20,9 +20,7 @@ def show def load_and_authorise_resource @info_request_batch = InfoRequestBatch.find(params[:id]) - if cannot?(:read, @info_request_batch) - raise ActiveRecord::RecordNotFound - end + raise ActiveRecord::RecordNotFound if cannot?(:read, @info_request_batch) end def redirect_embargoed_requests_for_pro_users diff --git a/app/controllers/one_time_passwords_controller.rb b/app/controllers/one_time_passwords_controller.rb index 1993ad3650..bba4187685 100644 --- a/app/controllers/one_time_passwords_controller.rb +++ b/app/controllers/one_time_passwords_controller.rb @@ -14,7 +14,7 @@ def create if @user.save redirect_to one_time_password_path, - :notice => _('Two factor authentication enabled') + notice: _('Two factor authentication enabled') else flash.now[:error] = _('Two factor authentication could not be enabled') render :show @@ -24,7 +24,7 @@ def create def update if @user.increment!(:otp_counter) redirect_to one_time_password_path, - :notice => _('Two factor one time passcode updated') + notice: _('Two factor one time passcode updated') else flash.now[:error] = _('Could not update your two factor one time passcode') render :show @@ -36,7 +36,7 @@ def destroy if @user.save redirect_to one_time_password_path, - :notice => _('Two factor authentication disabled') + notice: _('Two factor authentication disabled') else flash.now[:error] = _('Two factor authentication could not be disabled') render :show @@ -47,7 +47,7 @@ def destroy def check_two_factor_config unless AlaveteliConfiguration.enable_two_factor_auth - raise ActiveRecord::RecordNotFound.new('Page not enabled') + raise ActiveRecord::RecordNotFound, 'Page not enabled' end end diff --git a/app/controllers/outgoing_messages/delivery_statuses_controller.rb b/app/controllers/outgoing_messages/delivery_statuses_controller.rb index 597ee55469..0068879053 100644 --- a/app/controllers/outgoing_messages/delivery_statuses_controller.rb +++ b/app/controllers/outgoing_messages/delivery_statuses_controller.rb @@ -3,7 +3,7 @@ class OutgoingMessages::DeliveryStatusesController < ApplicationController def show @title = _('Delivery Status for Outgoing Message #{{id}}', - :id => @outgoing_message.id) + id: @outgoing_message.id) @delivery_status = @outgoing_message.delivery_status @@ -11,7 +11,7 @@ def show if @show_mail_server_logs @mail_server_logs = @outgoing_message.mail_server_logs.map do |log| - log.line(:redact => !@user.is_admin?) + log.line(redact: !@user.is_admin?) end end end @@ -25,8 +25,8 @@ def set_outgoing_message def check_prominence unless can?(:read, @outgoing_message) && \ can?(:read, @outgoing_message.info_request) - return render_hidden('request/_prominence', - locals: { prominenceable: @outgoing_message }) + render_hidden('request/_prominence', + locals: { prominenceable: @outgoing_message }) end end end diff --git a/app/controllers/password_changes_controller.rb b/app/controllers/password_changes_controller.rb index 1e3f1b3e6a..2aa2878148 100644 --- a/app/controllers/password_changes_controller.rb +++ b/app/controllers/password_changes_controller.rb @@ -7,11 +7,11 @@ class PasswordChangesController < ApplicationController before_action :set_pretoken before_action :set_pretoken_hash - before_action :set_user_from_token, :only => [:edit, :update] + before_action :set_user_from_token, only: [:edit, :update] def new @email_field_options = - @user ? { :disabled => true, :value => @user.email } : {} + @user ? { disabled: true, value: @user.email } : {} end def create @@ -27,7 +27,7 @@ def create flash[:error] = _("That doesn't look like a valid email address. " \ "Please check you have typed it correctly.") @email_field_options = - @user ? { :disabled => true, :value => email } : {} + @user ? { disabled: true, value: email } : {} render :new return end @@ -36,21 +36,20 @@ def create if @password_change_user post_redirect_attrs = - { :post_params => {}, - :reason_params => - { :web => '', - :email => _('Then you can change your password on {{site_name}}', - :site_name => site_name), - :email_subject => _('Change your password on {{site_name}}', - :site_name => site_name) }, - :circumstance => 'change_password', - :user => @password_change_user } + { post_params: {}, + reason_params: { web: '', + email: _('Then you can change your password on {{site_name}}', + site_name: site_name), + email_subject: _('Change your password on {{site_name}}', + site_name: site_name) }, + circumstance: 'change_password', + user: @password_change_user } post_redirect = PostRedirect.new(post_redirect_attrs) post_redirect.uri = edit_password_change_url(post_redirect.token, @pretoken_hash) post_redirect.save! - url = confirm_url(:email_token => post_redirect.email_token) + url = confirm_url(email_token: post_redirect.email_token) UserMailer. confirm_login(@password_change_user, post_redirect.reason_params, url). deliver_now @@ -69,9 +68,7 @@ def edit end def update - if @pretoken - @pretoken_redirect = PostRedirect.find_by(:token => @pretoken) - end + @pretoken_redirect = PostRedirect.find_by(token: @pretoken) if @pretoken if @password_change_user @password_change_user.password = params[:password_change_user][:password] @@ -92,22 +89,20 @@ def update msg = _("Your password has been changed. " \ "You also have a new one time passcode which you'll " \ "need next time you want to change your password") - redirect_to one_time_password_path, :notice => msg + redirect_to one_time_password_path, notice: msg else redirect_to SafeRedirect.new(@pretoken_redirect.uri).path, notice: _('Your password has been changed.') end - else - if otp_enabled?(@password_change_user) - msg = _("Your password has been changed. " \ + elsif otp_enabled?(@password_change_user) + msg = _("Your password has been changed. " \ "You also have a new one time passcode which you'll " \ "need next time you want to change your password") - redirect_to one_time_password_path, :notice => msg - else - msg = _('Your password has been changed.') - redirect_to show_user_profile_path(@password_change_user.url_name), - :notice => msg - end + redirect_to one_time_password_path, notice: msg + else + msg = _('Your password has been changed.') + redirect_to show_user_profile_path(@password_change_user.url_name), + notice: msg end else render :edit @@ -124,7 +119,7 @@ def set_pretoken end def set_pretoken_hash - @pretoken_hash = @pretoken ? { :pretoken => @pretoken } : {} + @pretoken_hash = @pretoken ? { pretoken: @pretoken } : {} end def set_user_from_token diff --git a/app/controllers/projects/classifications_controller.rb b/app/controllers/projects/classifications_controller.rb index 3dc3112ea4..a70ded220d 100644 --- a/app/controllers/projects/classifications_controller.rb +++ b/app/controllers/projects/classifications_controller.rb @@ -7,7 +7,7 @@ class Projects::ClassificationsController < Projects::BaseController include Classifiable def create - @project.submissions.create(submission_params) + @project.submissions.create(**submission_params) flash[:notice] = _('Thank you for updating this request!') redirect_to project_classify_path(@project) diff --git a/app/controllers/projects/extracts_controller.rb b/app/controllers/projects/extracts_controller.rb index 3b3bd24d1e..9cc041ab24 100644 --- a/app/controllers/projects/extracts_controller.rb +++ b/app/controllers/projects/extracts_controller.rb @@ -37,7 +37,7 @@ def create authorize! :read, @project @value_set = Dataset::ValueSet.new(extract_params) - submission = @project.submissions.new(submission_params) + submission = @project.submissions.new(**submission_params) if submission.save redirect_to project_extract_path diff --git a/app/controllers/projects/leaderboards_controller.rb b/app/controllers/projects/leaderboards_controller.rb new file mode 100644 index 0000000000..eb42822689 --- /dev/null +++ b/app/controllers/projects/leaderboards_controller.rb @@ -0,0 +1,16 @@ +# View and manage Project Leaderboards +class Projects::LeaderboardsController < Projects::BaseController + skip_before_action :html_response + + def show + authorize! :download, @project + + respond_to do |format| + format.csv do + leaderboard = Project::Leaderboard.new(@project) + send_data leaderboard.to_csv, filename: leaderboard.name, + type: 'text/csv' + end + end + end +end diff --git a/app/controllers/projects/projects_controller.rb b/app/controllers/projects/projects_controller.rb index 883e094016..2e6cb5e89b 100644 --- a/app/controllers/projects/projects_controller.rb +++ b/app/controllers/projects/projects_controller.rb @@ -4,6 +4,7 @@ class Projects::ProjectsController < Projects::BaseController def show authorize! :read, @project + @leaderboard = Project::Leaderboard.new(@project) end private diff --git a/app/controllers/public_body_change_requests_controller.rb b/app/controllers/public_body_change_requests_controller.rb index 523e97e992..64788ef137 100644 --- a/app/controllers/public_body_change_requests_controller.rb +++ b/app/controllers/public_body_change_requests_controller.rb @@ -1,5 +1,5 @@ class PublicBodyChangeRequestsController < ApplicationController - before_action :catch_spam, :only => [:create] + before_action :catch_spam, only: [:create] before_action :set_render_recaptcha def new @@ -14,7 +14,7 @@ def new @title = if @change_request.public_body _('Ask us to update the email address for {{public_body_name}}', - :public_body_name => @change_request.public_body.name) + public_body_name: @change_request.public_body.name) else _('Ask us to add an authority') end @@ -28,8 +28,8 @@ def create verified = if @render_recaptcha recaptcha_args = { - :model => @change_request, - :message => _('There was an error with the reCAPTCHA. ' \ + model: @change_request, + message: _('There was an error with the reCAPTCHA. ' \ 'Please try again.') } @@ -40,9 +40,9 @@ def create if verified && @change_request.save @change_request.send_message - redirect_to frontpage_url, :notice => @change_request.thanks_notice + redirect_to frontpage_url, notice: @change_request.thanks_notice else - render :action => 'new' + render action: 'new' end end diff --git a/app/controllers/public_body_controller.rb b/app/controllers/public_body_controller.rb index c51a55aa68..f116ee780d 100644 --- a/app/controllers/public_body_controller.rb +++ b/app/controllers/public_body_controller.rb @@ -18,11 +18,11 @@ def show # Later pages are very expensive to load if @page > MAX_RESULTS / requests_per_page - raise ActiveRecord::RecordNotFound.new("Sorry. No pages after #{MAX_RESULTS / requests_per_page}.") + raise ActiveRecord::RecordNotFound, "Sorry. No pages after #{MAX_RESULTS / requests_per_page}." end if MySociety::Format.simplify_url_part(params[:url_name], 'body') != params[:url_name] - redirect_to :url_name => MySociety::Format.simplify_url_part(params[:url_name], 'body'), :status => :moved_permanently + redirect_to url_name: MySociety::Format.simplify_url_part(params[:url_name], 'body'), status: :moved_permanently return end @@ -30,7 +30,7 @@ def show AlaveteliLocalization.with_locale(@locale) do @public_body = PublicBody.find_by_url_name_with_historic(params[:url_name]) - raise ActiveRecord::RecordNotFound.new("None found") if @public_body.nil? + raise ActiveRecord::RecordNotFound, "None found" if @public_body.nil? if @public_body.url_name.nil? redirect_back(fallback_location: root_path) @@ -39,7 +39,7 @@ def show # If found by historic name, or alternate locale name, redirect to new name if @public_body.url_name != params[:url_name] - redirect_to :url_name => @public_body.url_name + redirect_to url_name: @public_body.url_name return end @@ -56,7 +56,7 @@ def show @view = params[:view] - query = InfoRequestEvent.make_query_from_params(params.merge(:latest_status => @view)) + query = InfoRequestEvent.make_query_from_params(params.merge(latest_status: @view)) query += " requested_from:#{@public_body.url_name}" # Use search query for this so can collapse and paginate easily @@ -64,7 +64,7 @@ def show sortby = "described" begin @xapian_requests = perform_search([InfoRequestEvent], query, sortby, 'request_collapse', requests_per_page) - if (@page > 1) + if @page > 1 @page_desc = " (page #{ @page })" else @page_desc = "" @@ -77,19 +77,20 @@ def show @track_thing = TrackThing.create_track_for_public_body(@public_body) - if @user - @existing_track = TrackThing.find_existing(@user, @track_thing) - end + @existing_track = TrackThing.find_existing(@user, @track_thing) if @user - @follower_count = TrackThing.where(:public_body_id => @public_body.id).count + @follower_count = TrackThing.where(public_body_id: @public_body.id).count - @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), - :title => @track_thing.params[:title_in_rss], - :has_json => true } ] + @feed_autodetect = [ { url: do_track_url(@track_thing, 'feed'), + title: @track_thing.params[:title_in_rss], + has_json: true } ] respond_to do |format| - format.html { @has_json = true; render :template => "public_body/show" } - format.json { render :json => @public_body.json_for_api } + format.html do + @has_json = true + render template: "public_body/show" + end + format.json { render json: @public_body.json_for_api } end end @@ -97,19 +98,19 @@ def show def view_email @public_body = PublicBody.find_by_url_name_with_historic(params[:url_name]) - raise ActiveRecord::RecordNotFound.new("None found") if @public_body.nil? + raise ActiveRecord::RecordNotFound, "None found" if @public_body.nil? AlaveteliLocalization.with_locale(AlaveteliLocalization.locale) do if params[:submitted_view_email] if verify_recaptcha flash.discard(:error) - render :template => "public_body/view_email" + render template: "public_body/view_email" return end flash.now[:error] = _('There was an error with the reCAPTCHA. ' \ 'Please try again.') end - render :template => "public_body/view_email_captcha" + render template: "public_body/view_email_captcha" end end @@ -133,15 +134,15 @@ def list n_('Found {{count}} public authority', 'Found {{count}} public authorities', @public_bodies.total_entries, - :count => @public_bodies.total_entries) + count: @public_bodies.total_entries) elsif @tag.size == 1 n_('Found {{count}} public authority beginning with ' \ '‘{{first_letter}}’', 'Found {{count}} public authorities beginning with ' \ '‘{{first_letter}}’', @public_bodies.total_entries, - :count => @public_bodies.total_entries, - :first_letter => @tag) + count: @public_bodies.total_entries, + first_letter: @tag) else category_name = PublicBodyCategory.get.by_tag[@tag] if category_name.nil? @@ -150,27 +151,27 @@ def list 'Found {{count}} public authorities matching the tag ' \ '‘{{tag_name}}’', @public_bodies.total_entries, - :count => @public_bodies.total_entries, - :tag_name => @tag) + count: @public_bodies.total_entries, + tag_name: @tag) else n_('Found {{count}} public authority in the category ' \ '‘{{category_name}}’', 'Found {{count}} public authorities in the category ' \ '‘{{category_name}}’', @public_bodies.total_entries, - :count => @public_bodies.total_entries, - :category_name => category_name) + count: @public_bodies.total_entries, + category_name: category_name) end end - render :template => 'public_body/list' + render template: 'public_body/list' end end # Used so URLs like /local/islington work, for use e.g. writing to a local paper. def list_redirect @tag = params[:tag] - redirect_to list_public_bodies_url(:tag => @tag) + redirect_to list_public_bodies_url(tag: @tag) end # GET /body/all-authorities.csv @@ -193,8 +194,8 @@ def search_typeahead query = params[:query] return head :bad_request unless query flash[:search_params] = params.slice(:query, :bodies, :page) - @xapian_requests = typeahead_search(query, :model => PublicBody) - render :partial => "public_body/search_ahead" + @xapian_requests = typeahead_search(query, model: PublicBody) + render partial: "public_body/search_ahead" end end diff --git a/app/controllers/refusal_advice_controller.rb b/app/controllers/refusal_advice_controller.rb index fcd74bec8c..0d28b2333c 100644 --- a/app/controllers/refusal_advice_controller.rb +++ b/app/controllers/refusal_advice_controller.rb @@ -29,7 +29,7 @@ def log_event info_request.log_event( 'refusal_advice', - parsed_refusal_advice_params.merge(user_id: current_user.id).to_h + **parsed_refusal_advice_params.merge(user_id: current_user.id) ) end @@ -84,11 +84,15 @@ def refusal_advice_params end def parsed_refusal_advice_params - refusal_advice_params.merge( + parsed_params = refusal_advice_params.merge( actions: refusal_advice_params.fetch(:actions). each_pair do |_, suggestions| suggestions.transform_values! { |v| v == 'true' } end - ) + ).to_h + + return parsed_params.deep_symbolize_keys if RUBY_VERSION < '3.0' + + parsed_params end end diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 166639a82d..9913f6f721 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -30,9 +30,9 @@ def create def new @title = if @comment _("Report annotation on request: {{title}}", - :title => @info_request.title) + title: @info_request.title) else - _("Report request: {{title}}", :title => @info_request.title) + _("Report request: {{title}}", title: @info_request.title) end return if authenticated? @@ -56,7 +56,7 @@ def set_info_request def set_comment @comment = unless params[:comment_id].blank? - @info_request.comments.where(:id => params[:comment_id]).first! + @info_request.comments.where(id: params[:comment_id]).first! end end diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index a7808eec1f..e4692be147 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -10,13 +10,13 @@ class RequestController < ApplicationController skip_before_action :html_response, only: [:show, :select_authorities] before_action :check_read_only, only: [:new, :upload_response] - before_action :set_render_recaptcha, :only => [ :new ] - before_action :redirect_numeric_id_to_url_title, :only => [:show] + before_action :set_render_recaptcha, only: [ :new ] + before_action :redirect_numeric_id_to_url_title, only: [:show] before_action :set_info_request, only: [:show] - before_action :redirect_embargoed_requests_for_pro_users, :only => [:show] - before_action :redirect_public_requests_from_pro_context, :only => [:show] - before_action :redirect_new_form_to_pro_version, :only => [:select_authority, :new] - before_action :set_in_pro_area, :only => [:select_authority, :show] + before_action :redirect_embargoed_requests_for_pro_users, only: [:show] + before_action :redirect_public_requests_from_pro_context, only: [:show] + before_action :redirect_new_form_to_pro_version, only: [:select_authority, :new] + before_action :set_in_pro_area, only: [:select_authority, :show] helper_method :state_transitions_empty? @@ -37,10 +37,10 @@ def select_authority ) return end - if !params[:query].nil? + unless params[:query].nil? query = params[:query] flash[:search_params] = params.slice(:query, :bodies, :page) - @xapian_requests = typeahead_search(query, :model => PublicBody) + @xapian_requests = typeahead_search(query, model: PublicBody) end medium_cache end @@ -49,9 +49,7 @@ def show medium_cache AlaveteliLocalization.with_locale(locale) do # Test for whole request being hidden - if cannot?(:read, @info_request) - return render_hidden - end + return render_hidden if cannot?(:read, @info_request) # Always show the pro livery if a request is embargoed. This makes it # clear to admins and ex-pro users that the `InfoRequest` is still @@ -94,11 +92,14 @@ def show # Track corresponding to this page @track_thing = TrackThing.create_track_for_request(@info_request) - @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss], :has_json => true } ] + @feed_autodetect = [ { url: do_track_url(@track_thing, 'feed'), title: @track_thing.params[:title_in_rss], has_json: true } ] respond_to do |format| - format.html { @has_json = true; render :template => 'request/show' } - format.json { render :json => @info_request.json_for_api(true) } + format.html do + @has_json = true + render template: 'request/show' + end + format.json { render json: @info_request.json_for_api(true) } end end end @@ -107,15 +108,11 @@ def show def details long_cache @info_request = InfoRequest.find_by_url_title!(params[:url_title]) - if cannot?(:read, @info_request) - return render_hidden - end - @columns = ['id', - 'event_type', - 'created_at', - 'described_state', - 'last_described_at', - 'calculated_state' ] + return render_hidden if cannot?(:read, @info_request) + @columns = %w[ + id event_type created_at described_state last_described_at + calculated_state + ] end # Requests similar to this one @@ -126,18 +123,16 @@ def similar # Later pages are very expensive to load if @page > MAX_RESULTS / PER_PAGE - raise ActiveRecord::RecordNotFound.new("Sorry. No pages after #{MAX_RESULTS / PER_PAGE}.") + raise ActiveRecord::RecordNotFound, "Sorry. No pages after #{MAX_RESULTS / PER_PAGE}." end @info_request = InfoRequest.find_by_url_title!(params[:url_title]) - if cannot?(:read, @info_request) - return render_hidden - end + return render_hidden if cannot?(:read, @info_request) @xapian_object = ActsAsXapian::Similar.new([InfoRequestEvent], @info_request.info_request_events, - :offset => (@page - 1) * @per_page, - :limit => @per_page, - :collapse_by_prefix => 'request_collapse') + offset: (@page - 1) * @per_page, + limit: @per_page, + collapse_by_prefix: 'request_collapse') @matches_estimated = @xapian_object.matches_estimated @show_no_more_than = (@matches_estimated > MAX_RESULTS) ? MAX_RESULTS : @matches_estimated end @@ -145,39 +140,39 @@ def similar def list medium_cache @view = params[:view] - @page = get_search_page_from_params if !@page # used in cache case, as perform_search sets @page as side effect + unless @page # used in cache case, as perform_search sets @page as side effect + @page = get_search_page_from_params + end @per_page = PER_PAGE @max_results = MAX_RESULTS if @view == "recent" - return redirect_to request_list_all_url(:action => "list", :view => "all", :page => @page), :status => :moved_permanently + return redirect_to request_list_all_url(action: "list", view: "all", page: @page), status: :moved_permanently end # Later pages are very expensive to load if @page > MAX_RESULTS / PER_PAGE - raise ActiveRecord::RecordNotFound.new("Sorry. No pages after #{MAX_RESULTS / PER_PAGE}.") + raise ActiveRecord::RecordNotFound, "Sorry. No pages after #{MAX_RESULTS / PER_PAGE}." end - @filters = params.merge(:latest_status => @view) + @filters = params.merge(latest_status: @view) - if (@page > 1) - @title = _("Browse and search requests (page {{count}})", :count => @page) + if @page > 1 + @title = _("Browse and search requests (page {{count}})", count: @page) else @title = _('Browse and search requests') end @track_thing = TrackThing.create_track_for_search_query(InfoRequestEvent.make_query_from_params(@filters)) - @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss], :has_json => true } ] + @feed_autodetect = [ { url: do_track_url(@track_thing, 'feed'), title: @track_thing.params[:title_in_rss], has_json: true } ] # Don't let robots go more than 20 pages in - if @page > 20 - @no_crawl = true - end + @no_crawl = true if @page > 20 end # Page new form posts to def new # All new requests are of normal_sort - if !params[:outgoing_message].nil? + unless params[:outgoing_message].nil? params[:outgoing_message][:what_doing] = 'normal_sort' end @@ -189,7 +184,7 @@ def new if !@user.nil? && params[:submitted_new_request].nil? @undescribed_requests = @user.get_undescribed_requests if @undescribed_requests.size > 1 - render :action => 'new_please_describe' + render action: 'new_please_describe' return end end @@ -203,9 +198,9 @@ def new # can squirrel it away for tomorrow, so we detect this later after # we have constructed the InfoRequest. user_exceeded_limit = authenticated_user.exceeded_limit?(:info_requests) - if !user_exceeded_limit + unless user_exceeded_limit @details = authenticated_user.can_fail_html - render :template => 'user/banned' + render template: 'user/banned' return end # User did exceed limit @@ -215,7 +210,7 @@ def new # First time we get to the page, just display it if params[:submitted_new_request].nil? || params[:reedit] if user_exceeded_limit - render :template => 'user/rate_limited' + render template: 'user/rate_limited' return end return render_new_compose @@ -242,7 +237,7 @@ def new # Maybe we lost the address while they're writing it unless @info_request.public_body.is_requestable? - render :action => "new_#{ @info_request.public_body.not_requestable_reason }" + render action: "new_#{ @info_request.public_body.not_requestable_reason }" return end @@ -253,17 +248,15 @@ def new # describing the reason it is invalid. @info_request.errors.delete(:outgoing_messages) - render :action => 'new' + render action: 'new' return end # Show preview page, if it is a preview - if params[:preview].to_i == 1 - return render_new_preview - end + return render_new_preview if params[:preview].to_i == 1 if user_exceeded_limit - render :template => 'user/rate_limited' + render template: 'user/rate_limited' return end @@ -296,10 +289,10 @@ def new if send_exception_notifications? e = Exception.new("Possible blocked non-spam (recaptcha) from #{@info_request.user_id}: #{@info_request.title}") - ExceptionNotifier.notify_exception(e, :env => request.env) + ExceptionNotifier.notify_exception(e, env: request.env) end - render :action => 'new' + render action: 'new' return end end @@ -339,7 +332,7 @@ def new end end - redirect_to show_request_path(:url_title => @info_request.url_title) + redirect_to show_request_path(url_title: @info_request.url_title) end # Used for links from polymorphic URLs e.g. in Atom feeds - just redirect to @@ -350,12 +343,12 @@ def show_request_event raise ActiveRecord::RecordNotFound end if @info_request_event.is_incoming_message? - redirect_to incoming_message_url(@info_request_event.incoming_message), :status => :moved_permanently + redirect_to incoming_message_url(@info_request_event.incoming_message), status: :moved_permanently elsif @info_request_event.is_outgoing_message? - redirect_to outgoing_message_url(@info_request_event.outgoing_message), :status => :moved_permanently + redirect_to outgoing_message_url(@info_request_event.outgoing_message), status: :moved_permanently else # TODO: maybe there are better URLs for some events than this - redirect_to request_url(@info_request_event.info_request), :status => :moved_permanently + redirect_to request_url(@info_request_event.info_request), status: :moved_permanently end end @@ -378,21 +371,21 @@ def upload_response return false end - if !@info_request.public_body.is_foi_officer?(@user) + unless @info_request.public_body.is_foi_officer?(@user) domain_required = @info_request.public_body.foi_officer_domain_required if domain_required.nil? - render :template => 'user/wrong_user_unknown_email' + render template: 'user/wrong_user_unknown_email' return end @reason_params[:user_name] = "an email @" + domain_required - render :template => 'user/wrong_user' + render template: 'user/wrong_user' return end end if params[:submitted_upload_response] file_name = nil file_content = nil - if !params[:file_1].nil? + unless params[:file_1].nil? file_name = params[:file_1].original_filename file_content = params[:file_1].read end @@ -409,13 +402,13 @@ def upload_response @info_request. receive(mail, mail.encoded, - :override_stop_new_responses => true) + override_stop_new_responses: true) flash[:notice] = _("Thank you for responding to this FOI request! " \ "Your response has been published below, and a " \ "link to your response has been emailed to {{user_name}}.", - :user_name => @info_request.user.name.html_safe) + user_name: @info_request.user.name.html_safe) redirect_to request_url(@info_request) - return + nil end end @@ -433,9 +426,9 @@ def search_typeahead @query << params[:q].to_s @xapian_requests = typeahead_search(@query, - { :model => InfoRequestEvent, - :per_page => @per_page }) - render :partial => "request/search_ahead" + { model: InfoRequestEvent, + per_page: @per_page }) + render partial: "request/search_ahead" end def download_entire_request @@ -443,9 +436,7 @@ def download_entire_request @info_request = InfoRequest.find_by_url_title!(params[:url_title]) # Check for access and hide emargoed requests immediately, so that we # don't leak any info to people who can't access them - if @info_request.embargo && cannot?(:read, @info_request) - render_hidden - end + render_hidden if @info_request.embargo && cannot?(:read, @info_request) if !authenticated? ask_to_login( web: _('To download the zip file'), @@ -458,16 +449,14 @@ def download_entire_request ) else # Test for whole request being hidden or requester-only - if cannot?(:read, @info_request) - return render_hidden - end + return render_hidden if cannot?(:read, @info_request) cache_file_path = @info_request.make_zip_cache_path(@user) - if !File.exist?(cache_file_path) + unless File.exist?(cache_file_path) FileUtils.mkdir_p(File.dirname(cache_file_path)) make_request_zip(@info_request, cache_file_path) File.chmod(0644, cache_file_path) end - send_file(cache_file_path, :filename => "#{@info_request.url_title}.zip") + send_file(cache_file_path, filename: "#{@info_request.url_title}.zip") end end end @@ -585,7 +574,7 @@ def make_request_summary_file(info_request) @render_to_file = true assign_variables_for_show_template(info_request) if HTMLtoPDFConverter.exist? - html_output = render_to_string(:template => 'request/show') + html_output = render_to_string(template: 'request/show') tmp_input = Tempfile.new(['foihtml2pdf-input', '.html']) tmp_input.write(html_output) tmp_input.close @@ -593,8 +582,8 @@ def make_request_summary_file(info_request) command = HTMLtoPDFConverter.new(tmp_input, tmp_output) output = command.run if !output.nil? - file_info = { :filename => 'correspondence.pdf', - :data => File.open(tmp_output.path).read } + file_info = { filename: 'correspondence.pdf', + data: File.open(tmp_output.path).read } done = true else logger.error("Could not convert info request #{info_request.id} to PDF with command '#{command}'") @@ -605,17 +594,17 @@ def make_request_summary_file(info_request) else logger.warn("No HTML -> PDF converter found") end - if !done - file_info = { :filename => 'correspondence.txt', - :data => render_to_string(:template => 'request/show', - :layout => false, - :formats => [:text]) } + unless done + file_info = { filename: 'correspondence.txt', + data: render_to_string(template: 'request/show', + layout: false, + formats: [:text]) } end file_info end def render_new_compose - params[:info_request] = { } if !params[:info_request] + params[:info_request] = { } unless params[:info_request] # Reconstruct the params # first the public body (by URL name or id) @@ -625,14 +614,16 @@ def render_new_compose PublicBody.find(params[:url_name]).id else public_body = PublicBody.find_by_url_name_with_historic(params[:url_name]) - raise ActiveRecord::RecordNotFound.new("None found") if public_body.nil? # TODO: proper 404 + if public_body.nil? # TODO: proper 404 + raise ActiveRecord::RecordNotFound, "None found" + end public_body.id end elsif params[:public_body_id] params[:public_body_id] end - if !params[:info_request][:public_body_id] + unless params[:info_request][:public_body_id] # compulsory to have a body by here, or go to front page which is start # of process redirect_to frontpage_url @@ -651,19 +642,21 @@ def render_new_compose # non-standard arrangement. message_params = if params[:outgoing_message] - { :outgoing_message => params[:outgoing_message] } + { outgoing_message: params[:outgoing_message] } else - { :outgoing_message => {} } + { outgoing_message: {} } end message_params[:outgoing_message][:body] ||= params[:body] if params[:body] - message_params[:outgoing_message][:default_letter] ||= params[:default_letter] if params[:default_letter] + if params[:default_letter] + message_params[:outgoing_message][:default_letter] ||= params[:default_letter] + end message_params = ActionController::Parameters.new(message_params) permitted = message_params. - permit(:outgoing_message => [:body, :default_letter, :what_doing]) + permit(outgoing_message: [:body, :default_letter, :what_doing]) - @outgoing_message = OutgoingMessage.new(:info_request => @info_request) + @outgoing_message = OutgoingMessage.new(info_request: @info_request) if permitted[:outgoing_message][:body] @outgoing_message.body = permitted[:outgoing_message][:body] @@ -674,36 +667,34 @@ def render_new_compose if permitted[:outgoing_message][:what_doing] @outgoing_message.what_doing = permitted[:outgoing_message][:what_doing] end - @outgoing_message.set_signature_name(@user.name) if !@user.nil? + @outgoing_message.set_signature_name(@user.name) unless @user.nil? if @info_request.public_body.is_requestable? - render :action => 'new' + render action: 'new' + elsif @info_request.public_body.not_requestable_reason == 'bad_contact' + render action: 'new_bad_contact' else - if @info_request.public_body.not_requestable_reason == 'bad_contact' - render :action => 'new_bad_contact' - else - # if not requestable because defunct or not_apply, redirect to main page - # (which doesn't link to the /new/ URL) - redirect_to public_body_url(@info_request.public_body) - end + # if not requestable because defunct or not_apply, redirect to main page + # (which doesn't link to the /new/ URL) + redirect_to public_body_url(@info_request.public_body) end - return + nil end def render_new_preview if @outgoing_message.contains_email? || @outgoing_message.contains_postcode? flash.now[:error] = { - :partial => "preview_errors", - :locals => { - :contains_email => @outgoing_message.contains_email?, - :contains_postcode => @outgoing_message.contains_postcode?, - :help_link => help_privacy_path(:anchor => "email_address"), - :user => @user + partial: "preview_errors", + locals: { + contains_email: @outgoing_message.contains_email?, + contains_postcode: @outgoing_message.contains_postcode?, + help_link: help_privacy_path(anchor: "email_address"), + user: @user } } end - render :action => 'preview' + render action: 'preview' end def set_render_recaptcha @@ -717,10 +708,8 @@ def redirect_numeric_id_to_url_title @info_request = InfoRequest.find(params[:url_title].to_i) # We don't want to leak the title of embargoed or hidden requests, so # don't even redirect on if the user can't access the request - if cannot?(:read, @info_request) - return render_hidden - end - redirect_to request_url(@info_request, :format => params[:format]) + return render_hidden if cannot?(:read, @info_request) + redirect_to request_url(@info_request, format: params[:format]) end end @@ -732,7 +721,7 @@ def redirect_embargoed_requests_for_pro_users @info_request = InfoRequest.find_by_url_title!(params[:url_title]) if @info_request.is_actual_owning_user?(current_user) && @info_request.embargo redirect_to show_alaveteli_pro_request_url( - :url_title => @info_request.url_title) + url_title: @info_request.url_title) end end end @@ -742,9 +731,7 @@ def redirect_public_requests_from_pro_context # page, so that pro's seem them in that context after they publish them if feature_enabled?(:alaveteli_pro) && params[:pro] == "1" @info_request = InfoRequest.find_by_url_title!(params[:url_title]) - unless @info_request.embargo - redirect_to request_url(@info_request) - end + redirect_to request_url(@info_request) unless @info_request.embargo end end @@ -787,13 +774,13 @@ def block_spam_subject? def handle_spam_subject(user) if send_exception_notifications? e = Exception.new("Spam request from user #{ user.id }") - ExceptionNotifier.notify_exception(e, :env => request.env) + ExceptionNotifier.notify_exception(e, env: request.env) end if block_spam_subject? flash.now[:error] = _("Sorry, we're currently unable to send your " \ "request. Please try again later.") - render :action => 'new' + render action: 'new' true end end @@ -819,7 +806,7 @@ def handle_blocked_ip(info_request) if block_restricted_country_ips? flash.now[:error] = _("Sorry, we're currently unable to send your " \ "request. Please try again later.") - render :action => 'new' + render action: 'new' true end end diff --git a/app/controllers/request_game_controller.rb b/app/controllers/request_game_controller.rb index c3c0acf704..0af3622dff 100644 --- a/app/controllers/request_game_controller.rb +++ b/app/controllers/request_game_controller.rb @@ -16,7 +16,7 @@ def play @total = InfoRequest.is_searchable.count @done = @total - @missing @percentage = if @total > 0 - (@done.to_f / @total.to_f * 10000).round / 100.0 + (@done.to_f / @total.to_f * 10_000).round / 100.0 else 100.0 end @@ -29,10 +29,10 @@ def play if @missing == 0 flash.now[:notice] = { - :partial => "request_game/game_over", - :locals => { - :helpus_url => help_credits_path(:anchor => "helpus"), - :site_name => site_name + partial: "request_game/game_over", + locals: { + helpus_url: help_credits_path(anchor: "helpus"), + site_name: site_name } } end @@ -53,7 +53,7 @@ def show ) return end - redirect_to show_request_url(:url_title => url_title) + redirect_to show_request_url(url_title: url_title) end def stop diff --git a/app/controllers/services_controller.rb b/app/controllers/services_controller.rb index a19531e855..3e5fad9a09 100644 --- a/app/controllers/services_controller.rb +++ b/app/controllers/services_controller.rb @@ -53,7 +53,7 @@ def other_country_message end # TODO: workaround the HTML validation in test suite - render :plain => text + render plain: text end def hidden_user_explanation @@ -95,26 +95,26 @@ def user_site_and_eu_site_msg(country_name, country_link) _("Hello! You can make Freedom of Information requests within " \ "{{country_name}} at {{link_to_website}} and to EU " \ "institutions at {{link_to_asktheeu}}", - :country_name => country_name, - :link_to_website => country_link.html_safe, - :link_to_asktheeu => ask_the_eu_link.html_safe) + country_name: country_name, + link_to_website: country_link.html_safe, + link_to_asktheeu: ask_the_eu_link.html_safe) end def user_site_msg(country_name, country_link) _("Hello! You can make Freedom of Information requests within " \ "{{country_name}} at {{link_to_website}}", - :country_name => country_name, - :link_to_website => country_link.html_safe) + country_name: country_name, + link_to_website: country_link.html_safe) end def no_user_site_msg(country_name = nil) if country_name _("Hello! We have an important message for visitors outside {{country_name}}", - :country_name => country_name, - :url => "/help/alaveteli?country_name=#{CGI.escape(country_name)}") + country_name: country_name, + url: "/help/alaveteli?country_name=#{CGI.escape(country_name)}") else _("Hello! We have an important message for visitors in other countries", - :url => "/help/alaveteli") + url: "/help/alaveteli") end end @@ -123,15 +123,15 @@ def no_user_site_eu_msg(country_name = nil) _("Hello! We have an important message for " \ "visitors outside {{country_name}}. You can also make Freedom of " \ "Information requests to EU institutions at {{link_to_asktheeu}}", - :country_name => country_name, - :url => "/help/alaveteli?country_name=#{CGI.escape(country_name)}", - :link_to_asktheeu => ask_the_eu_link.html_safe) + country_name: country_name, + url: "/help/alaveteli?country_name=#{CGI.escape(country_name)}", + link_to_asktheeu: ask_the_eu_link.html_safe) else _("Hello! We have an important message for " \ "visitors in other countries. You can also make Freedom of " \ "Information requests to EU institutions at {{link_to_asktheeu}}", - :url => "/help/alaveteli", - :link_to_asktheeu => ask_the_eu_link.html_safe) + url: "/help/alaveteli", + link_to_asktheeu: ask_the_eu_link.html_safe) end end diff --git a/app/controllers/statistics_controller.rb b/app/controllers/statistics_controller.rb index d4ca107398..5f1b6562b1 100644 --- a/app/controllers/statistics_controller.rb +++ b/app/controllers/statistics_controller.rb @@ -2,8 +2,8 @@ class StatisticsController < ApplicationController skip_before_action :html_response def index - unless AlaveteliConfiguration::public_body_statistics_page - raise ActiveRecord::RecordNotFound.new("Page not enabled") + unless AlaveteliConfiguration.public_body_statistics_page + raise ActiveRecord::RecordNotFound, "Page not enabled" end @public_bodies = Statistics.public_bodies diff --git a/app/controllers/track_controller.rb b/app/controllers/track_controller.rb index 65fdbf5165..61dddb443a 100644 --- a/app/controllers/track_controller.rb +++ b/app/controllers/track_controller.rb @@ -19,11 +19,11 @@ def track_request return atom_feed_internal if params[:feed] == 'feed' - if self.track_set + if track_set if AlaveteliConfiguration.enable_widgets && cookies[:widget_vote] @info_request. widget_votes. - where(:cookie => cookies[:widget_vote]). + where(cookie: cookies[:widget_vote]). destroy_all end @@ -45,18 +45,18 @@ def track_list return atom_feed_internal if params[:feed] == 'feed' - if self.track_set || @track_thing.errors.any? - redirect_to request_list_url(:view => @view) + if track_set || @track_thing.errors.any? + redirect_to request_list_url(view: @view) end end # Track all updates to a particular public body def track_public_body @public_body = PublicBody.find_by_url_name_with_historic(params[:url_name]) - raise ActiveRecord::RecordNotFound.new("None found") if @public_body.nil? + raise ActiveRecord::RecordNotFound, "None found" if @public_body.nil? # If found by historic name, or alternate locale name, redirect to new name if @public_body.url_name != params[:url_name] - redirect_to track_public_body_url(:url_name => @public_body.url_name, :feed => params[:feed], :event_type => params[:event_type]) + redirect_to track_public_body_url(url_name: @public_body.url_name, feed: params[:feed], event_type: params[:event_type]) return end @@ -68,7 +68,7 @@ def track_public_body return atom_feed_internal if params[:feed] == 'feed' - if self.track_set || @track_thing.errors.any? + if track_set || @track_thing.errors.any? redirect_to public_body_url(@public_body) end end @@ -76,14 +76,12 @@ def track_public_body # Track a user def track_user @track_user = User.find_by_url_name(params[:url_name]) - raise ActiveRecord::RecordNotFound.new("No such user") if @track_user.nil? + raise ActiveRecord::RecordNotFound, "No such user" if @track_user.nil? @track_thing = TrackThing.create_track_for_user(@track_user) return atom_feed_internal if params[:feed] == 'feed' - if self.track_set || @track_thing.errors.any? - redirect_to user_url(@track_user) - end + redirect_to user_url(@track_user) if track_set || @track_thing.errors.any? end # Track a search term @@ -100,7 +98,7 @@ def track_search_query return atom_feed_internal if params[:feed] == 'feed' - if self.track_set || @track_thing.errors.any? + if track_set || @track_thing.errors.any? if @query.scan("variety").length == 1 # we're making a track for a simple filter, for which # there's an expression in the UI (rather than relying @@ -127,8 +125,8 @@ def track_set @existing_track = TrackThing.find_existing(@user, @track_thing) if @existing_track flash[:notice] = - { :partial => 'track/already_tracking', - :locals => { :track_thing_id => @existing_track.id } } + { partial: 'track/already_tracking', + locals: { track_thing_id: @existing_track.id } } return true end end @@ -142,16 +140,16 @@ def track_set @track_thing.tracking_user_id = @user.id if @track_thing.save flash[:notice] = - { :partial => 'track/track_set', - :locals => { - :user_receive_email_alerts => @user.receive_email_alerts, - :user_url_name => @user.url_name, - :track_thing_id => @track_thing.id } } - return true + { partial: 'track/track_set', + locals: { + user_receive_email_alerts: @user.receive_email_alerts, + user_url_name: @user.url_name, + track_thing_id: @track_thing.id } } + true else # this will most likely be tripped by a single error - probably track_query length flash[:error] = @track_thing.errors.map(&:message).join(", ") - return false + false end end @@ -165,7 +163,7 @@ def atom_feed if @track_thing.track_medium != 'feed' raise "can only view feeds for feed tracks, not email ones" end - redirect_to do_track_url(@track_thing, 'feed'), :status => :moved_permanently + redirect_to do_track_url(@track_thing, 'feed'), status: :moved_permanently end def atom_feed_internal @@ -177,21 +175,21 @@ def atom_feed_internal # so set that as the default, regardless of content negotiation request.format = params[:format] || 'xml' respond_to do |format| - format.json { render :json => @xapian_object.results.map { |r| r[:model].json_for_api(true, - lambda do |t| + format.json { render json: @xapian_object.results.map { |r| r[:model].json_for_api(true, + ->(t) do view_context.highlight_and_excerpt( t, @xapian_object.words_to_highlight( - :regex => true, - :include_original => true), + regex: true, + include_original: true), 150 ) end ) } } - format.any { render :template => 'track/atom_feed', - :formats => [:atom], - :layout => false, - :content_type => 'application/atom+xml' } + format.any { render template: 'track/atom_feed', + formats: [:atom], + layout: false, + content_type: 'application/atom+xml' } end end @@ -245,7 +243,7 @@ def delete_all_type flash[:notice] = _("You will no longer be emailed updates for those alerts") TrackThing. - where(:track_type => track_type, :tracking_user_id => user_id). + where(track_type: track_type, tracking_user_id: user_id). destroy_all redirect_to SafeRedirect.new(params[:r]).path end diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index a78de197f7..f64373a247 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -14,10 +14,10 @@ class UserController < ApplicationController ] layout :select_layout - before_action :normalize_url_name, :only => :show - before_action :work_out_post_redirect, :only => [ :signup ] - before_action :set_request_from_foreign_country, :only => [ :signup ] - before_action :set_in_pro_area, :only => [ :signup ] + before_action :normalize_url_name, only: :show + before_action :work_out_post_redirect, only: [ :signup ] + before_action :set_request_from_foreign_country, only: [ :signup ] + before_action :set_in_pro_area, only: [ :signup ] # Normally we wouldn't be verifying the authenticity token on these actions # anyway as there shouldn't be a user_id in the session when the before @@ -25,7 +25,7 @@ class UserController < ApplicationController # tries to sign in or sign up. There's little CSRF potential here as # these actions only sign in or up users with valid credentials. The # user_id in the session is not expected, and gives no extra privilege - skip_before_action :verify_authenticity_token, :only => [:signin, :signup] + skip_before_action :verify_authenticity_token, only: [:signin, :signup] # Show page about a user def show @@ -62,7 +62,7 @@ def show # All tracks for the user @track_things = TrackThing. - where(:tracking_user_id => @display_user, :track_medium => 'email_daily'). + where(tracking_user_id: @display_user, track_medium: 'email_daily'). order(created_at: :desc) @track_things_grouped = @track_things.group_by(&:track_type) # Requests you need to describe @@ -71,7 +71,7 @@ def show respond_to do |format| format.html { @has_json = true } - format.json { render :json => @display_user.json_for_api } + format.json { render json: @display_user.json_for_api } end end @@ -94,22 +94,26 @@ def wall @xapian_comments = nil end - feed_results += @xapian_requests.results.map { |x| x[:model] } if @xapian_requests - feed_results += @xapian_comments.results.map { |x| x[:model] } if @xapian_comments + if @xapian_requests + feed_results += @xapian_requests.results.map { |x| x[:model] } + end + if @xapian_comments + feed_results += @xapian_comments.results.map { |x| x[:model] } + end # All tracks for the user if @is_you @track_things = TrackThing. - where(:tracking_user_id => @display_user.id, - :track_medium => 'email_daily'). + where(tracking_user_id: @display_user.id, + track_medium: 'email_daily'). order(created_at: :desc) @track_things.each do |track_thing| # TODO: factor out of track_mailer.rb xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], track_thing.track_query, - :sort_by_prefix => 'described_at', - :sort_by_ascending => true, - :collapse_by_prefix => nil, - :limit => 20) + sort_by_prefix: 'described_at', + sort_by_ascending: true, + collapse_by_prefix: nil, + limit: 20) feed_results += xapian_object.results.map { |x| x[:model] } end end @@ -120,7 +124,7 @@ def wall respond_to do |format| format.html { @has_json = true } - format.json { render :json => @display_user.json_for_api } + format.json { render json: @display_user.json_for_api } end end @@ -144,40 +148,39 @@ def signup end if error || !@user_signup.errors.empty? # Show the form - render :action => 'sign' + render action: 'sign' else if user_alreadyexists already_registered_mail user_alreadyexists - return else # New unconfirmed user - # Block signups from suspicious countries - # TODO: Add specs (see RequestController#create) - # TODO: Extract to UserSpamScorer? - if blocked_ip?(country_from_ip, @user_signup) - handle_blocked_ip(@user_signup) && return - end + # Block signups from suspicious countries + # TODO: Add specs (see RequestController#create) + # TODO: Extract to UserSpamScorer? + if blocked_ip?(country_from_ip, @user_signup) + handle_blocked_ip(@user_signup) && return + end - # Rate limit signups - ip_rate_limiter.record(user_ip) + # Rate limit signups + ip_rate_limiter.record(user_ip) - if ip_rate_limiter.limit?(user_ip) - handle_rate_limited_signup(user_ip, @user_signup.email) && return - end + if ip_rate_limiter.limit?(user_ip) + handle_rate_limited_signup(user_ip, @user_signup.email) && return + end - # Prevent signups from potential spammers - if spam_user?(@user_signup) - handle_spam_user(@user_signup) do - render action: 'sign' - end && return - end + # Prevent signups from potential spammers + if spam_user?(@user_signup) + handle_spam_user(@user_signup) do + render action: 'sign' + end && return + end @user_signup.email_confirmed = false @user_signup.save! send_confirmation_mail @user_signup - return end + nil end rescue ActionController::ParameterMissing flash[:error] = _('Invalid form submission') @@ -212,7 +215,7 @@ def signchangeemail ) unless params[:submitted_signchangeemail_do] - render :action => 'signchangeemail' + render action: 'signchangeemail' return end @@ -223,7 +226,7 @@ def signchangeemail @signchangeemail.logged_in_user = @user unless @signchangeemail.valid? - render :action => 'signchangeemail' + render action: 'signchangeemail' return end @@ -238,13 +241,13 @@ def signchangeemail # it is important this screen looks the same as the one below, so # you can't change to someone's email in order to tell if they are # registered with that email on the site - render :action => 'signchangeemail_confirm' + render action: 'signchangeemail_confirm' return end # if not already, send a confirmation link to the new email address which logs # them into the old email's user account, but with special user_circumstance - if (not session[:user_circumstance]) or (session[:user_circumstance] != "change_email") + if !session[:user_circumstance] || (session[:user_circumstance] != "change_email") # don't store the password in the db params[:signchangeemail].delete(:password) @@ -255,7 +258,7 @@ def signchangeemail circumstance: 'change_email' ) - url = confirm_url(:email_token => post_redirect.email_token) + url = confirm_url(email_token: post_redirect.email_token) UserMailer. changeemail_confirm( @user, @@ -264,7 +267,7 @@ def signchangeemail # it is important this screen looks the same as the one above, so # you can't change to someone's email in order to tell if they are # registered with that email on the site - render :action => 'signchangeemail_confirm' + render action: 'signchangeemail_confirm' return end @@ -276,15 +279,22 @@ def signchangeemail # Now clear the circumstance session[:user_circumstance] = nil - flash[:notice] = _("You have now changed your email address used on {{site_name}}",:site_name=>site_name) + flash[:notice] = _("You have now changed your email address used on {{site_name}}",site_name: site_name) redirect_to user_url(@user) end # River of News: What's happening with your tracked things def river - @results = @user.nil? ? [] : @user.track_things.collect { |thing| - perform_search([InfoRequestEvent], thing.track_query, thing.params[:feed_sortby], nil).results - }.flatten.sort { |a,b| b[:model].created_at <=> a[:model].created_at }.first(20) + @results = if @user.nil? + [] + else + @user. + track_things. + collect { |thing| perform_search([InfoRequestEvent], thing.track_query, thing.params[:feed_sortby], nil).results }. + flatten. + sort { |a,b| b[:model].created_at <=> a[:model].created_at }. + first(20) + end end def set_profile_photo @@ -310,17 +320,17 @@ def set_profile_photo end # validate it - @draft_profile_photo = ProfilePhoto.new(:data => file_content, :draft => true) + @draft_profile_photo = ProfilePhoto.new(data: file_content, draft: true) unless @draft_profile_photo.valid? # error page (uses @profile_photo's error fields in view to show errors) - render :template => 'user/set_draft_profile_photo' + render template: 'user/set_draft_profile_photo' return end @draft_profile_photo.save! if params[:automatically_crop] # no javascript, crop automatically - @profile_photo = ProfilePhoto.new(:data => @draft_profile_photo.data, :draft => false) + @profile_photo = ProfilePhoto.new(data: @draft_profile_photo.data, draft: false) @user.set_profile_photo(@profile_photo) @draft_profile_photo.destroy flash[:notice] = _("Thank you for updating your profile photo") @@ -328,26 +338,26 @@ def set_profile_photo return end - render :template => 'user/set_crop_profile_photo' - return + render template: 'user/set_crop_profile_photo' + nil elsif params[:submitted_crop_profile_photo].present? # crop the draft photo according to jquery parameters and set it as the users photo draft_profile_photo = ProfilePhoto.find(params[:draft_profile_photo_id]) - @profile_photo = ProfilePhoto.new(:data => draft_profile_photo.data, :draft => false, - :x => params[:x], :y => params[:y], :w => params[:w], :h => params[:h]) + @profile_photo = ProfilePhoto.new(data: draft_profile_photo.data, draft: false, + x: params[:x], y: params[:y], w: params[:w], h: params[:h]) @user.set_profile_photo(@profile_photo) draft_profile_photo.destroy if @user.get_about_me_for_html_display.empty? - flash[:notice] = { :partial => "user/update_profile_photo" } + flash[:notice] = { partial: "user/update_profile_photo" } redirect_to edit_profile_about_me_url else flash[:notice] = _("Thank you for updating your profile photo") redirect_to user_url(@user) end else - render :template => 'user/set_draft_profile_photo' + render template: 'user/set_draft_profile_photo' end end @@ -360,9 +370,7 @@ def clear_profile_photo return end - if @user.profile_photo - @user.profile_photo.destroy - end + @user.profile_photo.destroy if @user.profile_photo flash[:notice] = _("You've now cleared your profile photo") redirect_to user_url(@user) @@ -371,8 +379,8 @@ def clear_profile_photo # before they've cropped it def get_draft_profile_photo profile_photo = ProfilePhoto.find(params[:id]) - render :body => profile_photo.data, - :content_type => 'image/png' + render body: profile_photo.data, + content_type: 'image/png' end # actual profile photo of a user @@ -380,11 +388,11 @@ def get_profile_photo long_cache @display_user = set_display_user unless @display_user.profile_photo - raise ActiveRecord::RecordNotFound.new("user has no profile photo, url_name=" + params[:url_name]) + raise ActiveRecord::RecordNotFound, "user has no profile photo, url_name=" + params[:url_name] end - render :body => @display_user.profile_photo.data, - :content_type => 'image/png' + render body: @display_user.profile_photo.data, + content_type: 'image/png' end # Change about me text on your profile page @@ -406,7 +414,7 @@ def block_restricted_country_ips? AlaveteliConfiguration.enable_anti_spam end - def blocked_ip?(country, user) + def blocked_ip?(country, _user) AlaveteliConfiguration.restricted_countries.include?(country) && country != AlaveteliConfiguration.iso_country_code end @@ -437,7 +445,7 @@ def set_in_pro_area def normalize_url_name unless MySociety::Format.simplify_url_part(params[:url_name], 'user') == params[:url_name] - redirect_to :url_name => MySociety::Format.simplify_url_part(params[:url_name], 'user'), :status => :moved_permanently + redirect_to url_name: MySociety::Format.simplify_url_part(params[:url_name], 'user'), status: :moved_permanently end end @@ -498,14 +506,14 @@ def send_confirmation_mail(user) post_redirect.user = user post_redirect.save! - url = confirm_url(:email_token => post_redirect.email_token) + url = confirm_url(email_token: post_redirect.email_token) UserMailer. confirm_login( user, post_redirect.reason_params, url ).deliver_now - render :action => 'confirm' + render action: 'confirm' end # If they register again @@ -515,14 +523,14 @@ def already_registered_mail(user) post_redirect.user = user post_redirect.save! - url = confirm_url(:email_token => post_redirect.email_token) + url = confirm_url(email_token: post_redirect.email_token) UserMailer. already_registered( user, post_redirect.reason_params, url ).deliver_now - render :action => 'confirm' # must be same as for send_confirmation_mail above to avoid leak of presence of email in db + render action: 'confirm' # must be same as for send_confirmation_mail above to avoid leak of presence of email in db end def assign_request_states(display_user) @@ -548,12 +556,12 @@ def set_show_requests if params[:user_query] requests_query += " " + params[:user_query] comments_query += " " + params[:user_query] - @match_phrase = _("{{search_results}} matching '{{query}}'", :search_results => "", :query => params[:user_query]) + @match_phrase = _("{{search_results}} matching '{{query}}'", search_results: "", query: params[:user_query]) unless params[:request_latest_status].blank? requests_query << ' latest_status:' << params[:request_latest_status] comments_query << ' latest_status:' << params[:request_latest_status] - @match_phrase << _(" filtered by status: '{{status}}'", :status => params[:request_latest_status]) + @match_phrase << _(" filtered by status: '{{status}}'", status: params[:request_latest_status]) end end @@ -570,7 +578,7 @@ def set_show_requests # Track corresponding to this page @track_thing = TrackThing.create_track_for_user(@display_user) - @feed_autodetect = [ { :url => do_track_url(@track_thing, 'feed'), :title => @track_thing.params[:title_in_rss], :has_json => true } ] + @feed_autodetect = [ { url: do_track_url(@track_thing, 'feed'), title: @track_thing.params[:title_in_rss], has_json: true } ] end def current_user_is_display_user @@ -589,12 +597,12 @@ def show_about_me? # Redirects to front page later if nothing else specified def generate_post_redirect_for_signup(redirect_to="/") redirect_to = "/" if redirect_to.nil? - PostRedirect.new(:uri => redirect_to, - :post_params => {}, - :reason_params => { - :web => "", - :email => _("Then you can sign in to {{site_name}}", :site_name => site_name), - :email_subject => _("Confirm your account on {{site_name}}", :site_name => site_name) + PostRedirect.new(uri: redirect_to, + post_params: {}, + reason_params: { + web: "", + email: _("Then you can sign in to {{site_name}}", site_name: site_name), + email_subject: _("Confirm your account on {{site_name}}", site_name: site_name) }) end @@ -608,7 +616,7 @@ def handle_rate_limited_signup(user_ip, email_address) msg = "Rate limited signup from #{ user_ip } email: " \ " #{ email_address }" e = Exception.new(msg) - ExceptionNotifier.notify_exception(e, :env => request.env) + ExceptionNotifier.notify_exception(e, env: request.env) end if block_rate_limited_ips? @@ -616,7 +624,7 @@ def handle_rate_limited_signup(user_ip, email_address) _("Sorry, we're currently unable to sign up new users, " \ "please try again later") error = true - render :action => 'sign' + render action: 'sign' true end end diff --git a/app/controllers/user_profile/about_me_controller.rb b/app/controllers/user_profile/about_me_controller.rb index 981faaaeaa..a1987c9836 100644 --- a/app/controllers/user_profile/about_me_controller.rb +++ b/app/controllers/user_profile/about_me_controller.rb @@ -32,7 +32,7 @@ def update flash[:notice] = _("You have now changed the text about you on your profile.") redirect_to user_url(@user) else - flash[:notice] = { :partial => "update_profile_text" } + flash[:notice] = { partial: "update_profile_text" } redirect_to set_profile_photo_url end else @@ -52,7 +52,7 @@ def check_user_logged_in def set_title @title = _('Change the text about you on your profile at {{site_name}}', - :site_name => site_name) + site_name: site_name) end def spam_about_me_text?(text, user) @@ -68,7 +68,7 @@ def block_spam_about_me_text? def handle_spam_about_me_text(user) if send_exception_notifications? e = Exception.new("Spam about me text from user #{ user.id }") - ExceptionNotifier.notify_exception(e, :env => request.env) + ExceptionNotifier.notify_exception(e, env: request.env) end if block_spam_about_me_text? diff --git a/app/controllers/users/confirmations_controller.rb b/app/controllers/users/confirmations_controller.rb index 850080334a..8584347fac 100644 --- a/app/controllers/users/confirmations_controller.rb +++ b/app/controllers/users/confirmations_controller.rb @@ -4,7 +4,7 @@ def confirm post_redirect = PostRedirect.find_by_email_token(params[:email_token]) if post_redirect.nil? || !post_redirect.email_token_valid? - render :template => 'user/bad_token' + render template: 'user/bad_token' return end diff --git a/app/controllers/users/messages_controller.rb b/app/controllers/users/messages_controller.rb index 2990766c17..93a66ffdfd 100644 --- a/app/controllers/users/messages_controller.rb +++ b/app/controllers/users/messages_controller.rb @@ -1,8 +1,12 @@ # Allowing users to send user-to-user messages class Users::MessagesController < UserController - before_action :set_recipient, :check_can_send_messages, :check_logged_in, - :set_contact, :set_recaptcha_required + before_action :set_recipient, + :check_recipient_accepts_messages, + :check_can_send_messages, + :check_logged_in, + :set_contact, + :set_recaptcha_required # Send a message to another user def contact @@ -11,14 +15,18 @@ def contact if @recaptcha_required && !verify_recaptcha flash.now[:error] = _('There was an error with the reCAPTCHA. ' \ 'Please try again.') - else - if @contact.valid? - send_message(@user, @recipient_user) - flash[:notice] = _('Your message to {{recipient_user_name}} has ' \ - 'been sent!', - recipient_user_name: @recipient_user.name.html_safe) - redirect_to user_url(@recipient_user) + elsif @contact.valid? + if spam_user_message?(params[:contact][:message], @user) + handle_spam_user_message(@user) && return end + + send_message(@user, @recipient_user) + @user.user_messages.create + + flash[:notice] = _('Your message to {{recipient_user_name}} has ' \ + 'been sent!', + recipient_user_name: @recipient_user.name.html_safe) + redirect_to user_url(@recipient_user) end end @@ -28,12 +36,22 @@ def set_recipient @recipient_user = User.find_by!(url_name: params[:url_name]) end + def check_recipient_accepts_messages + return if @recipient_user.receive_user_messages? + + render template: 'users/messages/opted_out' + end + def check_can_send_messages - # Banned from messaging users? return unless authenticated? && !authenticated_user.can_contact_other_users? - @details = authenticated_user.can_fail_html - render template: 'user/banned' + if authenticated_user.exceeded_limit?(:user_messages) + render template: 'users/messages/rate_limited' + else + # Banned user + @details = authenticated_user.can_fail_html + render template: 'user/banned' + end end def check_logged_in @@ -79,4 +97,28 @@ def send_message(sender, recipient) ).deliver_now end + def spam_user_message?(message_body, user) + !user.confirmed_not_spam? && + AlaveteliSpamTermChecker.new.spam?(message_body) + end + + def block_spam_user_messages? + AlaveteliConfiguration.block_spam_user_messages || + AlaveteliConfiguration.enable_anti_spam + end + + # Sends an exception and blocks the message depending on configuration. + def handle_spam_user_message(user) + if send_exception_notifications? + e = Exception.new("Possible spam user message from user #{ user.id }") + ExceptionNotifier.notify_exception(e, env: request.env) + end + + if block_spam_user_messages? + flash.now[:error] = _("Sorry, we're currently unable to send your " \ + "message. Please try again later.") + render action: 'contact' + true + end + end end diff --git a/app/controllers/users/sessions_controller.rb b/app/controllers/users/sessions_controller.rb index de26072db2..fa1cf15dd8 100644 --- a/app/controllers/users/sessions_controller.rb +++ b/app/controllers/users/sessions_controller.rb @@ -1,9 +1,9 @@ class Users::SessionsController < UserController include UserSpamCheck - before_action :work_out_post_redirect, :only => [ :new, :create ] - before_action :set_request_from_foreign_country, :only => [ :new, :create ] - before_action :set_in_pro_area, :only => [ :new, :create ] + before_action :work_out_post_redirect, only: [ :new, :create ] + before_action :set_request_from_foreign_country, only: [ :new, :create ] + before_action :set_in_pro_area, only: [ :new, :create ] # Normally we wouldn't be verifying the authenticity token on these actions # anyway as there shouldn't be a user_id in the session when the before @@ -11,7 +11,7 @@ class Users::SessionsController < UserController # tries to sign in or sign up. There's little CSRF potential here as # these actions only sign in or up users with valid credentials. The # user_id in the session is not expected, and gives no extra privilege - skip_before_action :verify_authenticity_token, :only => [:new, :create] + skip_before_action :verify_authenticity_token, only: [:new, :create] def new if @user @@ -20,7 +20,7 @@ def new return end - render :template => 'user/sign' + render template: 'user/sign' end def create @@ -29,31 +29,28 @@ def create User.authenticate_from_form(user_signin_params, @post_redirect.reason_params[:user_name]) end - if @post_redirect.nil? || @user_signin.errors.size > 0 + if @post_redirect.nil? || !@user_signin.errors.empty? # Failed to authenticate clear_session_credentials - render :template => 'user/sign' - else + render template: 'user/sign' + elsif @user_signin.email_confirmed # Successful login - if @user_signin.email_confirmed - + if spam_user?(@user_signin) # Prevent signins from potential spammers - if spam_user?(@user_signin) - handle_spam_user(@user_signin) do - render template: 'user/sign' - end && return - end + handle_spam_user(@user_signin) do + render template: 'user/sign' + end && return + end - sign_in(@user_signin, remember_me: params[:remember_me].present?) + sign_in(@user_signin, remember_me: params[:remember_me].present?) - if is_modal_dialog - render :template => 'users/sessions/show' - else - do_post_redirect @post_redirect, @user_signin - end + if is_modal_dialog + render template: 'users/sessions/show' else - send_confirmation_mail @user_signin + do_post_redirect @post_redirect, @user_signin end + else + send_confirmation_mail @user_signin end rescue ActionController::ParameterMissing flash[:error] = _('Invalid form submission') diff --git a/app/controllers/widget_votes_controller.rb b/app/controllers/widget_votes_controller.rb index 3ec63de86d..cf04d0f63c 100644 --- a/app/controllers/widget_votes_controller.rb +++ b/app/controllers/widget_votes_controller.rb @@ -21,7 +21,7 @@ def create end @info_request.widget_votes. - where(:cookie => cookie). + where(cookie: cookie). first_or_create end @@ -32,8 +32,8 @@ def create private def check_widget_config - unless AlaveteliConfiguration::enable_widgets - raise ActiveRecord::RecordNotFound.new("Page not enabled") + unless AlaveteliConfiguration.enable_widgets + raise ActiveRecord::RecordNotFound, "Page not enabled" end end @@ -42,7 +42,7 @@ def find_info_request end def check_prominence - unless @info_request.prominence(:decorate => true).is_searchable? + unless @info_request.prominence(decorate: true).is_searchable? head :forbidden end end diff --git a/app/controllers/widgets_controller.rb b/app/controllers/widgets_controller.rb index 0ecf035e5d..b2c801b475 100644 --- a/app/controllers/widgets_controller.rb +++ b/app/controllers/widgets_controller.rb @@ -17,19 +17,17 @@ def show @user_owns_request = @info_request.user && @info_request.user == @user @existing_track = - if @user - TrackThing.find_existing(@user, @track_thing) - end + (TrackThing.find_existing(@user, @track_thing) if @user) @existing_vote = unless @existing_track @info_request. widget_votes. - where(:cookie => cookies[:widget_vote]). + where(cookie: cookies[:widget_vote]). any? end - render :action => 'show', :layout => false + render action: 'show', layout: false end def new @@ -39,8 +37,8 @@ def new private def check_widget_config - unless AlaveteliConfiguration::enable_widgets - raise ActiveRecord::RecordNotFound.new("Page not enabled") + unless AlaveteliConfiguration.enable_widgets + raise ActiveRecord::RecordNotFound, "Page not enabled" end end @@ -49,7 +47,7 @@ def find_info_request end def check_prominence - unless @info_request.prominence(:decorate => true).is_searchable? + unless @info_request.prominence(decorate: true).is_searchable? head :forbidden end end diff --git a/app/helpers/admin/link_helper.rb b/app/helpers/admin/link_helper.rb index bd4480413d..5bbd39f6bd 100644 --- a/app/helpers/admin/link_helper.rb +++ b/app/helpers/admin/link_helper.rb @@ -1,8 +1,8 @@ # Helpers for rendering record links in the admin interface module Admin::LinkHelper def both_links(record) - method = "#{record.class.to_s.underscore}_both_links" - send(method, record) + type = record.class.to_s.underscore.parameterize(separator: '_') + send("#{type}_both_links", record) end private @@ -81,7 +81,16 @@ def comment_both_links(comment) icon = prominence_icon(comment) link_to(icon, comment_path(comment), title: title) + ' ' + - link_to(truncate(comment.body), edit_admin_comment_path(comment), + link_to(truncate(comment.body, length: 60), edit_admin_comment_path(comment), + title: admin_title) + end + + def blog_post_both_links(blog_post) + title = 'View blog post' + icon = eye + + link_to(icon, blog_post.url, title: title) + ' ' + + link_to(blog_post.title, edit_admin_blog_post_path(blog_post), title: admin_title) end diff --git a/app/helpers/admin_comments_helper.rb b/app/helpers/admin_comments_helper.rb index 7c4d0bafb2..959a5330b6 100644 --- a/app/helpers/admin_comments_helper.rb +++ b/app/helpers/admin_comments_helper.rb @@ -9,6 +9,6 @@ def comment_labels(comment) private def hidden_label - content_tag(:span, 'hidden', :class => 'label label-warning') + content_tag(:span, 'hidden', class: 'label label-warning') end end diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index 2b0fed840a..b8fe71a8a3 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -5,7 +5,7 @@ module AdminHelper include Admin::ProminenceHelper def icon(name) - content_tag(:i, "", :class => "icon-#{name}") + content_tag(:i, "", class: "icon-#{name}") end def eye @@ -50,7 +50,7 @@ def event_params_description(event) if can?(:admin, AlaveteliPro::Embargo) || !event.info_request.embargo diff = event.params_diff significant_event_params(event).each do |key| - if diff[:new].has_key? key + if diff[:new].key? key text += "Changed #{key} from '#{diff[:old][key]}' to '#{diff[:new][key]}'. " end end diff --git a/app/helpers/admin_users_helper.rb b/app/helpers/admin_users_helper.rb index df0f19dbcc..5625f62aa9 100644 --- a/app/helpers/admin_users_helper.rb +++ b/app/helpers/admin_users_helper.rb @@ -12,15 +12,15 @@ def user_labels(user) private def banned_label - content_tag(:span, 'banned', :class => 'label label-warning') + content_tag(:span, 'banned', class: 'label label-warning') end def closed_label - content_tag(:span, 'closed', :class => 'label label-warning') + content_tag(:span, 'closed', class: 'label label-warning') end def role_label(role) - content_tag(:span, role.name, :class => 'label') + content_tag(:span, role.name, class: 'label') end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 04f6019936..327427227a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -60,7 +60,7 @@ def foi_error_messages_for(*params) end def locale_name(locale) - return LanguageNames::get_language_name(locale) + LanguageNames.get_language_name(locale) end def admin_value(v) @@ -74,10 +74,10 @@ def admin_value(v) end def admin_date(date, ago: true, ago_only: false) - ago_text = _('{{length_of_time}} ago', :length_of_time => time_ago_in_words(date)) + ago_text = _('{{length_of_time}} ago', length_of_time: time_ago_in_words(date)) text = ago_text if ago_only - exact_date = I18n.l(date, :format => "%e %B %Y %H:%M:%S") + exact_date = I18n.l(date, format: "%e %B %Y %H:%M:%S") text ||= "#{exact_date} (#{ago_text})" if ago time_tag(date, text || exact_date, title: date) @@ -123,11 +123,11 @@ def theme_asset_exists?(asset_path) # rely on a sesssion being shared between the front end and admin interface, # so need to check the status of the user. def is_admin? - return !session[:using_admin].nil? || (!@user.nil? && @user.is_admin?) + !session[:using_admin].nil? || (!@user.nil? && @user.is_admin?) end - def cache_if_caching_fragments(*args, &block) - if AlaveteliConfiguration::cache_fragments + def cache_if_caching_fragments(*args) + if AlaveteliConfiguration.cache_fragments cache(*args) { yield } else yield @@ -148,11 +148,9 @@ def render_flash(message) # or anything except the first page of results, just the first page of the default # views def request_list_cache_key - cacheable_param_list = ['controller', 'action', 'locale', 'view'] + cacheable_param_list = %w[controller action locale view] if params.keys.all? { |key| cacheable_param_list.include?(key) } "request-list-#{@view}-#{@locale}" - else - nil end end @@ -163,38 +161,38 @@ def event_description(event) case event.event_type when 'sent' _('Request sent to {{public_body_name}} by {{info_request_user}} on {{date}}.', - :public_body_name => body_link, - :info_request_user => user_link, - :date => date) + public_body_name: body_link, + info_request_user: user_link, + date: date) when 'followup_sent' case event.calculated_state when 'internal_review' _('Internal review request sent to {{public_body_name}} by {{info_request_user}} on {{date}}.', - :public_body_name => body_link, - :info_request_user => user_link, - :date => date) + public_body_name: body_link, + info_request_user: user_link, + date: date) when 'waiting_response' _('Clarification sent to {{public_body_name}} by {{info_request_user}} on {{date}}.', - :public_body_name => body_link, - :info_request_user => user_link, - :date => date) + public_body_name: body_link, + info_request_user: user_link, + date: date) else _('Follow up sent to {{public_body_name}} by {{info_request_user}} on {{date}}.', - :public_body_name => body_link, - :info_request_user => user_link, - :date => date) + public_body_name: body_link, + info_request_user: user_link, + date: date) end when 'response' _('Response by {{public_body_name}} to {{info_request_user}} on {{date}}.', - :public_body_name => body_link, - :info_request_user => user_link, - :date => date) + public_body_name: body_link, + info_request_user: user_link, + date: date) when 'comment' _('Request to {{public_body_name}} by {{info_request_user}}. Annotated by {{event_comment_user}} on {{date}}.', - :public_body_name => body_link, - :info_request_user => user_link, - :event_comment_user => user_link_absolute(event.comment.user), - :date => date) + public_body_name: body_link, + info_request_user: user_link, + event_comment_user: user_link_absolute(event.comment.user), + date: date) end end diff --git a/app/helpers/blog_helper.rb b/app/helpers/blog_helper.rb new file mode 100644 index 0000000000..d504fac7f8 --- /dev/null +++ b/app/helpers/blog_helper.rb @@ -0,0 +1,16 @@ +## +# Helper methods for returning blog posts to be rendered +# +module BlogHelper + def blog_posts_for_frontpage + Blog::Post.order(id: :desc).limit(4) + end + + def blog_posts_for_taggable(taggable:, limit: 3) + return [] unless Blog.enabled? + + scope = Blog::Post.none + taggable.tags.each { |t| scope = scope.or(Blog::Post.with_tag(t.name)) } + scope.order(id: :desc).limit(limit) + end +end diff --git a/app/helpers/date_time_helper.rb b/app/helpers/date_time_helper.rb index 22d437ecf1..e1c3c8fbab 100644 --- a/app/helpers/date_time_helper.rb +++ b/app/helpers/date_time_helper.rb @@ -18,7 +18,7 @@ module DateTimeHelper # Returns a String # Raises ArgumentError if the format is unrecognized def simple_date(date, opts = {}) - opts = { :format => :html }.merge(opts) + opts = { format: :html }.merge(opts) date_formatter = "simple_date_#{ opts[:format] }" if respond_to?(date_formatter) @@ -36,7 +36,7 @@ def simple_date(date, opts = {}) # Returns a String def simple_date_html(date) date = date.in_time_zone unless date.is_a?(Date) - time_tag date, simple_date_text(date), :title => date.to_s + time_tag date, simple_date_text(date), title: date.to_s end # Usually-correct plain text formatting of a DateTime-ish object @@ -50,7 +50,7 @@ def simple_date_text(date) date_format = _('simple_date_format') date_format = :long if date_format == 'simple_date_format' - I18n.l(date, :format => date_format) + I18n.l(date, format: date_format) end # Strips the date from a DateTime diff --git a/app/helpers/health_checks_helper.rb b/app/helpers/health_checks_helper.rb index 5c9b02959e..297e2e702b 100644 --- a/app/helpers/health_checks_helper.rb +++ b/app/helpers/health_checks_helper.rb @@ -2,7 +2,7 @@ module HealthChecksHelper def check_status(check) style = check.ok? ? '' : 'color: red' - content_tag(:b, check.message, :style => style) + content_tag(:b, check.message, style: style) end end diff --git a/app/helpers/highlight_helper.rb b/app/helpers/highlight_helper.rb index fbaabbbb2a..8258337f30 100644 --- a/app/helpers/highlight_helper.rb +++ b/app/helpers/highlight_helper.rb @@ -5,13 +5,15 @@ module HighlightHelper # the phrases parameter. # https://github.com/rails/rails/pull/11793 def highlight_matches(text, phrases, options = {}) - text = ActionController::Base.helpers.sanitize(text).try(:html_safe) if options.fetch(:sanitize, true) + if options.fetch(:sanitize, true) + text = ActionController::Base.helpers.sanitize(text).try(:html_safe) + end if text.blank? || phrases.blank? text else match = Array(phrases).map do |p| - Regexp === p ? p.to_s : Regexp.escape(p) + p.is_a?(Regexp) ? p.to_s : Regexp.escape(p) end.join('|') if block_given? @@ -26,20 +28,16 @@ def highlight_matches(text, phrases, options = {}) # Highlight words, also escapes HTML (other than spans that we add) def highlight_words(t, words, html = true) if html - highlight_matches(h(t), words, :highlighter => '\1').html_safe + highlight_matches(h(t), words, highlighter: '\1').html_safe else - highlight_matches(t, words, :highlighter => '*\1*') + highlight_matches(t, words, highlighter: '*\1*') end end def highlight_and_excerpt(t, words, excount, html = true) - newt = excerpt(t, words[0], :radius => excount) - if not newt - newt = excerpt(t, '', :radius => excount) - end - t = newt - t = highlight_words(t, words, html) - return t + newt = excerpt(t, words[0], radius: excount) + newt = excerpt(t, '', radius: excount) unless newt + highlight_words(newt, words, html) end def excerpt(text, phrase, options = {}) @@ -53,7 +51,7 @@ def excerpt(text, phrase, options = {}) regex = /#{Regexp.escape(phrase)}/i end - return unless matches = text.match(regex) + return unless (matches = text.match(regex)) phrase = matches[0] unless separator.empty? @@ -93,6 +91,6 @@ def cut_excerpt_part(part_position, part, separator, options) part.first(radius) end - return affix, part.join(separator) + [affix, part.join(separator)] end end diff --git a/app/helpers/info_request_helper.rb b/app/helpers/info_request_helper.rb index 08b92451df..3954b2814b 100644 --- a/app/helpers/info_request_helper.rb +++ b/app/helpers/info_request_helper.rb @@ -40,23 +40,21 @@ def status_text_awaiting_description(info_request, opts = {}) old_unclassified = opts.fetch(:old_unclassified, false) if is_owning_user && !info_request.is_external? && !render_to_file - return status_text_awaiting_description_owner_please_answer( + status_text_awaiting_description_owner_please_answer( + new_responses_count) + elsif old_unclassified + status_text_awaiting_description_old_unclassified( new_responses_count) else - if old_unclassified - return status_text_awaiting_description_old_unclassified( - new_responses_count) - else - return status_text_awaiting_description_other(info_request, - new_responses_count) - end + status_text_awaiting_description_other(info_request, + new_responses_count) end end - def status_text_waiting_response(info_request, opts = {}) + def status_text_waiting_response(info_request, _opts = {}) str = _('Currently waiting for a response from ' \ '{{public_body_link}}, they should respond promptly and', - :public_body_link => public_body_link(info_request.public_body)) + public_body_link: public_body_link(info_request.public_body)) str += ' ' str += _('normally') str += ' ' @@ -70,17 +68,17 @@ def status_text_waiting_response(info_request, opts = {}) str += ")." end - def status_text_waiting_response_overdue(info_request, opts = {}) + def status_text_waiting_response_overdue(info_request, _opts = {}) str = _('Response to this request is delayed.') str += ' ' if info_request.public_body.not_subject_to_law? str += _('Although not legally required to do so, we would have ' \ 'expected {{public_body_link}} to have responded by ', - :public_body_link => public_body_link(info_request.public_body)) + public_body_link: public_body_link(info_request.public_body)) else str += _('By law, {{public_body_link}} should normally have responded ' \ 'promptly and', - :public_body_link => public_body_link(info_request.public_body)) + public_body_link: public_body_link(info_request.public_body)) str += ' ' str += _('by') str += ' ' @@ -93,17 +91,17 @@ def status_text_waiting_response_overdue(info_request, opts = {}) str += ")" end - def status_text_waiting_response_very_overdue(info_request, opts = {}) + def status_text_waiting_response_very_overdue(info_request, _opts = {}) str = _('Response to this request is long overdue.') str += ' ' if info_request.public_body.not_subject_to_law? str += _('Although not legally required to do so, we would have ' \ 'expected {{public_body_link}} to have responded by now', - :public_body_link => public_body_link(info_request.public_body)) + public_body_link: public_body_link(info_request.public_body)) else str += _('By law, under all circumstances, {{public_body_link}} should ' \ 'have responded by now', - :public_body_link => public_body_link(info_request.public_body)) + public_body_link: public_body_link(info_request.public_body)) end str += ' ' str += "(" @@ -115,7 +113,7 @@ def status_text_waiting_response_very_overdue(info_request, opts = {}) str += _('You can complain by') str += ' ' str += link_to _('requesting an internal review'), - new_request_followup_path(:request_id => info_request.id) + + new_request_followup_path(request_id: info_request.id) + '?internal_review=1' str += '.' end @@ -123,22 +121,22 @@ def status_text_waiting_response_very_overdue(info_request, opts = {}) str end - def status_text_not_held(info_request, opts = {}) + def status_text_not_held(info_request, _opts = {}) _('{{authority_name}} did not have the information ' \ 'requested.', - :authority_name => public_body_link(info_request.public_body)) + authority_name: public_body_link(info_request.public_body)) end - def status_text_rejected(info_request, opts = {}) + def status_text_rejected(info_request, _opts = {}) _('The request was refused by {{authority_name}}.', - :authority_name => public_body_link(info_request.public_body)) + authority_name: public_body_link(info_request.public_body)) end - def status_text_successful(info_request, opts = {}) + def status_text_successful(_info_request, _opts = {}) _('The request was successful.') end - def status_text_partially_successful(info_request, opts = {}) + def status_text_partially_successful(_info_request, _opts = {}) _('The request was partially successful.') end @@ -150,7 +148,7 @@ def status_text_waiting_clarification(info_request, opts = {}) if is_owning_user && !info_request.is_external? str += _('{{authority_name}} is waiting for your clarification' \ '.', - :authority_name => info_request.public_body.name) + authority_name: info_request.public_body.name) str += ' ' str += _('Please') str += ' ' @@ -165,9 +163,9 @@ def status_text_waiting_clarification(info_request, opts = {}) str += ' ' str += _('If you are {{user_link}}, please', - :user_link => user_link_for_request(info_request)) + user_link: user_link_for_request(info_request)) str += ' ' - str += link_to _("sign in"), signin_path(:r => redirect_to) + str += link_to _("sign in"), signin_path(r: redirect_to) str += ' ' str += _('to send a follow up message.') end @@ -176,52 +174,52 @@ def status_text_waiting_clarification(info_request, opts = {}) str end - def status_text_gone_postal(info_request, opts = {}) + def status_text_gone_postal(_info_request, _opts = {}) _('The authority would like to / has responded by ' \ 'postal mail to this request.') end - def status_text_internal_review(info_request, opts = {}) + def status_text_internal_review(info_request, _opts = {}) _('Waiting for an internal review by ' \ '{{public_body_link}} of their handling of this request.', - :public_body_link => public_body_link(info_request.public_body)) + public_body_link: public_body_link(info_request.public_body)) end - def status_text_error_message(info_request, opts = {}) + def status_text_error_message(_info_request, _opts = {}) _('There was a delivery error or similar, which ' \ 'needs fixing by the {{site_name}} team.', - :site_name => site_name) + site_name: site_name) end - def status_text_requires_admin(info_request, opts = {}) + def status_text_requires_admin(_info_request, _opts = {}) _('This request has had an unusual response, and requires ' \ 'attention from the {{site_name}} team.', - :site_name => site_name) + site_name: site_name) end - def status_text_user_withdrawn(info_request, opts = {}) + def status_text_user_withdrawn(_info_request, _opts = {}) _('This request has been withdrawn by the person ' \ 'who made it. There may be an explanation in the correspondence below.') end - def status_text_attention_requested(info_request, opts = {}) + def status_text_attention_requested(_info_request, _opts = {}) _('This request has been reported as needing ' \ 'administrator attention.') end - def status_text_vexatious(info_request, opts = {}) + def status_text_vexatious(_info_request, _opts = {}) _('This request has been reviewed by an administrator and is ' \ 'considered to be vexatious') end - def status_text_not_foi(info_request, opts = {}) + def status_text_not_foi(_info_request, _opts = {}) _('This request has been reviewed by an administrator and is ' \ 'considered not to be an FOI request') end - def custom_state_description(info_request, opts = {}) - render :partial => 'general/custom_state_descriptions', - :locals => { :status => info_request.calculate_status } + def custom_state_description(info_request, _opts = {}) + render partial: 'general/custom_state_descriptions', + locals: { status: info_request.calculate_status } end def status_text_awaiting_description_owner_please_answer(new_responses_count) @@ -258,7 +256,7 @@ def status_text_awaiting_description_other(info_request, new_responses_count) user: user_link_for_request(info_request)) end - def attachment_link(incoming_message, attachment) + def attachment_link(_incoming_message, attachment) img_filename = "icon_#{attachment.content_type.sub('/', '_')}_large.png" full_filename = File.expand_path(Rails.root.join('app', 'assets', @@ -271,8 +269,8 @@ def attachment_link(incoming_message, attachment) "content_type/icon_unknown.png" end - link_to image_tag(image, :class => "attachment__image", - :alt => "Attachment"), + link_to image_tag(image, class: "attachment__image", + alt: "Attachment"), attachment_path(attachment) end @@ -297,11 +295,9 @@ def attachment_url(attachment, options = {}) def details_help_link(public_body) anchor = public_body.not_subject_to_law? ? 'authorities' : 'quickly_response' - link_to _('details'), help_requesting_path(:anchor => anchor) + link_to _('details'), help_requesting_path(anchor: anchor) end - private - def attachment_params(attachment, options = {}) attach_params = { incoming_message_id: attachment.incoming_message_id, diff --git a/app/helpers/link_to_helper.rb b/app/helpers/link_to_helper.rb index 4c1c1cb08b..522e4c33a1 100755 --- a/app/helpers/link_to_helper.rb +++ b/app/helpers/link_to_helper.rb @@ -11,19 +11,19 @@ module LinkToHelper # Requests def request_url(info_request, options = {}) - show_request_url({:url_title => info_request.url_title}.merge(options)) + show_request_url({url_title: info_request.url_title}.merge(options)) end def request_path(info_request, options = {}) - request_url(info_request, options.merge(:only_path => true)) + request_url(info_request, options.merge(only_path: true)) end - def request_link(info_request, cls=nil) - link_to info_request.title, request_path(info_request), :class => cls + def request_link(info_request) + link_to info_request.title, request_path(info_request) end def request_details_path(info_request) - details_request_path(:url_title => info_request.url_title) + details_request_path(url_title: info_request.url_title) end # Incoming / outgoing messages @@ -55,11 +55,11 @@ def foi_attachment_path(foi_attachment, options = {}) end def comment_url(comment, options = {}) - request_url(comment.info_request, options.merge(:anchor => "comment-#{comment.id}")) + request_url(comment.info_request, options.merge(anchor: "comment-#{comment.id}")) end def comment_path(comment, options = {}) - comment_url(comment, options.merge(:only_path => true)) + comment_url(comment, options.merge(only_path: true)) end # Used in mailers where we want to give a link to a new response @@ -67,13 +67,13 @@ def new_response_url(info_request, incoming_message) if info_request.user.is_pro? # Pro users will always need to log in, so we have to give them a link # which forces that - message_url = incoming_message_url(incoming_message, :cachebust => true) - signin_url(:r => message_url) + message_url = incoming_message_url(incoming_message, cachebust: true) + signin_url(r: message_url) else # For normal users, we try not to use a login link here, just the # actual URL. This is because people tend to forward these emails # amongst themselves. - incoming_message_url(incoming_message, :cachebust => true) + incoming_message_url(incoming_message, cachebust: true) end end @@ -81,31 +81,31 @@ def new_response_url(info_request, incoming_message) def respond_to_last_url(info_request, options = {}) last_response = info_request.get_last_public_response if last_response.nil? - new_request_followup_url(options.merge(:request_id => info_request.id)) + new_request_followup_url(options.merge(request_id: info_request.id)) else - new_request_incoming_followup_url(options.merge(:request_id => info_request.id, :incoming_message_id => last_response.id)) + new_request_incoming_followup_url(options.merge(request_id: info_request.id, incoming_message_id: last_response.id)) end end def respond_to_last_path(info_request, options = {}) - respond_to_last_url(info_request, options.merge(:only_path => true)) + respond_to_last_url(info_request, options.merge(only_path: true)) end # Public bodies def public_body_url(public_body, options = {}) - public_body.url_name.nil? ? '' : show_public_body_url(options.merge(:url_name => public_body.url_name)) + public_body.url_name.nil? ? '' : show_public_body_url(options.merge(url_name: public_body.url_name)) end def public_body_path(public_body, options = {}) - public_body_url(public_body, options.merge(:only_path => true)) + public_body_url(public_body, options.merge(only_path: true)) end def public_body_link_short(public_body) link_to public_body.short_or_long_name, public_body_path(public_body) end - def public_body_link(public_body, cls=nil) - link_to public_body.name, public_body_path(public_body), :class => cls + def public_body_link(public_body) + link_to public_body.name, public_body_path(public_body) end def public_body_link_absolute(public_body) # e.g. for in RSS @@ -114,18 +114,22 @@ def public_body_link_absolute(public_body) # e.g. for in RSS # Users def user_url(user, options = {}) - show_user_url(options.merge(:url_name => user.url_name)) + show_user_url(options.merge(url_name: user.url_name)) end def user_path(user, options = {}) - user_url(user, options.merge(:only_path => true)) + user_url(user, options.merge(only_path: true)) end - def user_link(user, cls=nil) - link_to user.name, user_path(user), :class => cls + def user_link_absolute(user) + link_to user.name, user_url(user) + end + + def user_link(user) + link_to user.name, user_path(user) end - def user_link_for_request(request, cls=nil) + def user_link_for_request(request) if request.is_external? user_name = request.external_user_name || _("Anonymous user") if !request.external_url.nil? @@ -134,7 +138,7 @@ def user_link_for_request(request, cls=nil) user_name end else - link_to request.user.name, user_path(request.user), :class => cls + link_to request.user.name, user_path(request.user) end end @@ -146,38 +150,35 @@ def user_admin_link_for_request(request, external_text=nil, internal_text=nil) end end - def user_link_absolute(user) - link_to user.name, user_url(user) - end - - def user_link(user) - link_to user.name, user_path(user) + def external_user_link(request, text = nil) + if request.external_user_name + request.external_user_name + else + text ||= _("Anonymous user") + link_to(text, help_privacy_path(anchor: 'anonymous')) + end end - def external_user_link(request, absolute, text) + def external_user_link_absolute(request, text = nil) if request.external_user_name request.external_user_name else - if absolute - url = help_privacy_url(:anchor => 'anonymous') - else - url = help_privacy_path(:anchor => 'anonymous') - end - link_to(text, url) + text ||= _("Anonymous user") + link_to(text, help_privacy_url(anchor: 'anonymous')) end end - def request_user_link_absolute(request, anonymous_text=_("Anonymous user")) + def request_user_link_absolute(request, anonymous_text = nil) if request.is_external? - external_user_link(request, absolute=true, anonymous_text) + external_user_link_absolute(request, anonymous_text) else user_link_absolute(request.user) end end - def request_user_link(request, anonymous_text=_("Anonymous user")) + def request_user_link(request, anonymous_text = nil) if request.is_external? - external_user_link(request, absolute=false, anonymous_text) + external_user_link(request, anonymous_text) else user_link(request.user) end @@ -193,9 +194,9 @@ def user_or_you_link(user) def user_or_you_capital(user) if @user && user == @user - return h("You") + h("You") else - return h(user.name) + h(user.name) end end @@ -203,48 +204,46 @@ def user_or_you_capital_link(user) link_to user_or_you_capital(user), user_path(user) end - def user_admin_link(user, name="admin", cls=nil) - link_to name, admin_user_url(user), :class => cls + def user_admin_link(user, name="admin") + link_to name, admin_user_url(user) end # Tracks. feed can be 'track' or 'feed' def do_track_url(track_thing, feed = 'track', options = {}) if track_thing.track_type == 'request_updates' - track_request_url(options.merge(:url_title => track_thing.info_request.url_title, :feed => feed)) + track_request_url(options.merge(url_title: track_thing.info_request.url_title, feed: feed)) elsif track_thing.track_type == 'all_new_requests' - track_list_url(options.merge(:view => 'recent', :feed => feed)) + track_list_url(options.merge(view: 'recent', feed: feed)) elsif track_thing.track_type == 'all_successful_requests' - track_list_url(options.merge(:view => 'successful', :feed => feed)) + track_list_url(options.merge(view: 'successful', feed: feed)) elsif track_thing.track_type == 'public_body_updates' - track_public_body_url(options.merge(:url_name => track_thing.public_body.url_name, :feed => feed)) + track_public_body_url(options.merge(url_name: track_thing.public_body.url_name, feed: feed)) elsif track_thing.track_type == 'user_updates' - track_user_url(options.merge(:url_name => track_thing.tracked_user.url_name, :feed => feed)) + track_user_url(options.merge(url_name: track_thing.tracked_user.url_name, feed: feed)) elsif track_thing.track_type == 'search_query' - track_search_url(options.merge(:query_array => track_thing.track_query, :feed => feed)) + track_search_url(options.merge(query_array: track_thing.track_query, feed: feed)) else raise "unknown tracking type " + track_thing.track_type end end def do_track_path(track_thing, feed = 'track', options = {}) - do_track_url(track_thing, feed, options.merge(:only_path => true)) + do_track_url(track_thing, feed, options.merge(only_path: true)) end # General pages. def search_url(query, options = nil) - if query.kind_of?(Array) - query = query - ["", nil] + if query.is_a?(Array) + query -= ["", nil] query = query.join("/") end - routing_info = {:controller => 'general', - :action => 'search', - :combined => query, - :view => nil} - if !options.nil? - routing_info = options.merge(routing_info) - end + routing_info = {controller: 'general', + action: 'search', + combined: query, + view: nil} + routing_info = options.merge(routing_info) unless options.nil? - if routing_info.kind_of?(Hash) + if routing_info.is_a?(Hash) routing_info = ActionController::Parameters.new(routing_info) end @@ -263,13 +262,11 @@ def search_url(query, options = nil) # and also 3.3 of http://www.ietf.org/rfc/rfc2396.txt # It turns out this is a regression in Rails 2.1, caused by this bug fix: # http://rails.lighthouseapp.com/projects/8994/tickets/144-patch-bug-in-rails-route-globbing - url = url.gsub("%2F", "/") - - return url + url.gsub("%2F", "/") end def search_path(query, options = {}) - search_url(query, options.merge(:only_path => true)) + search_url(query, options.merge(only_path: true)) end def search_link(query) @@ -283,9 +280,9 @@ def about_url(options = {}) def unhappy_url(info_request = nil, options = {}) if info_request.nil? - return help_general_url(options.merge(template: 'unhappy')) + help_general_url(options.merge(template: 'unhappy')) else - return help_unhappy_url(options.merge(url_title: info_request.url_title)) + help_unhappy_url(options.merge(url_title: info_request.url_title)) end end @@ -322,7 +319,7 @@ def message_url(message, options = {}) end def message_path(message, options = {}) - message_url(message, options.merge(:only_path => true)) + message_url(message, options.merge(only_path: true)) end def dom_id(record, prefix = nil) diff --git a/app/helpers/mailer_helper.rb b/app/helpers/mailer_helper.rb index c96bcef542..ed19974b69 100644 --- a/app/helpers/mailer_helper.rb +++ b/app/helpers/mailer_helper.rb @@ -1,9 +1,9 @@ module MailerHelper def contact_from_name_and_email - "#{AlaveteliConfiguration::contact_name} <#{AlaveteliConfiguration::contact_email}>" + "#{AlaveteliConfiguration.contact_name} <#{AlaveteliConfiguration.contact_email}>" end def pro_contact_from_name_and_email - "#{AlaveteliConfiguration::pro_contact_name} <#{AlaveteliConfiguration::pro_contact_email}>" + "#{AlaveteliConfiguration.pro_contact_name} <#{AlaveteliConfiguration.pro_contact_email}>" end end diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index 46bb6af3d0..0ae51ccd91 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -4,7 +4,7 @@ def render_notes(notes, batch: false, **options) allowed_tags = batch ? batch_notes_allowed_tags : notes_allowed_tags - tag.aside options.merge(id: 'notes') do + tag.aside(**options.merge(id: 'notes')) do notes.each do |note| note_classes = ['note'] note_classes << "tag-#{note.notable_tag}" if note.notable_tag diff --git a/app/helpers/public_body_helper.rb b/app/helpers/public_body_helper.rb index cbb8817350..8f278130b9 100644 --- a/app/helpers/public_body_helper.rb +++ b/app/helpers/public_body_helper.rb @@ -23,8 +23,8 @@ def public_body_not_requestable_reasons(public_body) # Make the authority appear requestable to encourage users to help find # the authority's email address msg = link_to _("Make a request to this authority"), - new_request_to_body_path(:url_name => public_body.url_name), - :class => "link_button_green" + new_request_to_body_path(url_name: public_body.url_name), + class: "link_button_green" reasons.push(msg) end @@ -43,12 +43,12 @@ def type_of_authority(public_body) types = categories.each_with_index.map do |category, index| desc = category.description - desc = desc.sub(/\S/) { |m| m.upcase } if index.zero? + desc = desc.sub(/\S/, &:upcase) if index.zero? link_to(desc, list_public_bodies_by_tag_path(category.category_tag)) end if types.any? - types.to_sentence(:last_word_connector => ' and ').html_safe + types.to_sentence(last_word_connector: ' and ').html_safe else _("A public authority") end diff --git a/app/helpers/taggable_helper.rb b/app/helpers/taggable_helper.rb new file mode 100644 index 0000000000..3ab8a75a63 --- /dev/null +++ b/app/helpers/taggable_helper.rb @@ -0,0 +1,7 @@ +# Helpers for Taggable records +module TaggableHelper + # Generate CSS classes for each tag of a given Taggable + def tags_css(taggable) + taggable.tags.map { |tag| "tag--#{tag.name}" }.join(' ') + end +end diff --git a/app/helpers/track_helper.rb b/app/helpers/track_helper.rb index 40f9297fb7..c054ebeb83 100644 --- a/app/helpers/track_helper.rb +++ b/app/helpers/track_helper.rb @@ -4,22 +4,22 @@ def already_subscribed_notice(track_thing) case track_thing.track_type when 'request_updates' _("You are already subscribed to '{{link_to_request}}', a request.", - :link_to_request => request_link(track_thing.info_request)) + link_to_request: request_link(track_thing.info_request)) when 'all_new_requests' _('You are already subscribed to any new requests.', - :new_requests_url => request_list_path) + new_requests_url: request_list_path) when 'all_successful_requests' _('You are already subscribed to any successful requests.', - :successful_requests_url => request_list_successful_path ) + successful_requests_url: request_list_successful_path ) when 'public_body_updates' _("You are already subscribed to '{{link_to_authority}}', a public authority.", - :link_to_authority => public_body_link(track_thing.public_body)) + link_to_authority: public_body_link(track_thing.public_body)) when 'user_updates' _("You are already subscribed to '{{link_to_user}}', a person.", - :link_to_user => user_link(track_thing.tracked_user)) + link_to_user: user_link(track_thing.tracked_user)) when 'search_query' _('You are already subscribed to this search.', - :search_url => search_path([track_thing.track_query, 'newest', 'advanced'])) + search_url: search_path([track_thing.track_query, 'newest', 'advanced'])) end end @@ -27,52 +27,52 @@ def subscribe_email_notice(track_thing) case track_thing.track_type when 'request_updates' _("You will now be emailed updates about '{{link_to_request}}', a request.", - :link_to_request => request_link(track_thing.info_request)) + link_to_request: request_link(track_thing.info_request)) when 'all_new_requests' _('You will now be emailed updates about any new requests.', - :new_requests_url => request_list_path) + new_requests_url: request_list_path) when 'all_successful_requests' _('You will now be emailed updates about successful requests.', - :successful_requests_url => request_list_successful_path ) + successful_requests_url: request_list_successful_path ) when 'public_body_updates' _("You will now be emailed updates about '{{link_to_authority}}', a public authority.", - :link_to_authority => public_body_link(track_thing.public_body)) + link_to_authority: public_body_link(track_thing.public_body)) when 'user_updates' _("You will now be emailed updates about '{{link_to_user}}', a person.", - :link_to_user => user_link(track_thing.tracked_user)) + link_to_user: user_link(track_thing.tracked_user)) when 'search_query' _("You will now be emailed updates about this search.", - :search_url => search_path([track_thing.track_query, 'newest', 'advanced'])) + search_url: search_path([track_thing.track_query, 'newest', 'advanced'])) end end def subscribe_follow_notice(track_thing) - wall_url_user = show_user_wall_path(:url_name => track_thing.tracking_user.url_name) + wall_url_user = show_user_wall_path(url_name: track_thing.tracking_user.url_name) case track_thing.track_type when 'request_updates' _('You are now following updates about \'{{link_to_request}}\', a request.', - :link_to_request => request_link(track_thing.info_request), - :wall_url_user => wall_url_user) + link_to_request: request_link(track_thing.info_request), + wall_url_user: wall_url_user) when 'all_new_requests' _('You are now following updates about new requests.', - :new_requests_url => request_list_path, - :wall_url_user => wall_url_user) + new_requests_url: request_list_path, + wall_url_user: wall_url_user) when 'all_successful_requests' _('You are now following updates about successful requests.', - :successful_requests_url => request_list_successful_path, - :wall_url_user => wall_url_user) + successful_requests_url: request_list_successful_path, + wall_url_user: wall_url_user) when 'public_body_updates' _('You are now following updates about \'{{link_to_authority}}\', a public authority.', - :wall_url_user => wall_url_user, - :link_to_authority => public_body_link(track_thing.public_body)) + wall_url_user: wall_url_user, + link_to_authority: public_body_link(track_thing.public_body)) when 'user_updates' _('You are now following updates about \'{{link_to_user}}\', a person.', - :wall_url_user => wall_url_user, - :link_to_user => user_link(track_thing.tracked_user)) + wall_url_user: wall_url_user, + link_to_user: user_link(track_thing.tracked_user)) when 'search_query' _('You are now following updates about this search.', - :wall_url_user => wall_url_user, - :search_url => search_path([track_thing.track_query, 'newest', 'advanced'])) + wall_url_user: wall_url_user, + search_url: search_path([track_thing.track_query, 'newest', 'advanced'])) end end @@ -80,22 +80,22 @@ def unsubscribe_notice(track_thing) case track_thing.track_type when 'request_updates' _("You are no longer following '{{link_to_request}}', a request.", - :link_to_request => request_link(track_thing.info_request)) + link_to_request: request_link(track_thing.info_request)) when 'all_new_requests' _('You are no longer following new requests.', - :new_requests_url => request_list_path) + new_requests_url: request_list_path) when 'all_successful_requests' _('You are no longer following successful requests.', - :successful_requests_url => request_list_successful_path ) + successful_requests_url: request_list_successful_path ) when 'public_body_updates' _("You are no longer following '{{link_to_authority}}', a public authority.", - :link_to_authority => public_body_link(track_thing.public_body)) + link_to_authority: public_body_link(track_thing.public_body)) when 'user_updates' _("You are no longer following '{{link_to_user}}', a person.", - :link_to_user => user_link(track_thing.tracked_user)) + link_to_user: user_link(track_thing.tracked_user)) when 'search_query' _('You are no longer following this search.', - :search_url => search_path([track_thing.track_query, 'newest', 'advanced'])) + search_url: search_path([track_thing.track_query, 'newest', 'advanced'])) end end @@ -103,17 +103,17 @@ def track_description(track_thing) case track_thing.track_type when 'request_updates' _("'{{link_to_request}}', a request", - :link_to_request => request_link(track_thing.info_request)) + link_to_request: request_link(track_thing.info_request)) when 'all_new_requests' link_to(_('new requests'), request_list_path) when 'all_successful_requests' link_to(_('successful requests'), request_list_successful_path) when 'public_body_updates' _("'{{link_to_authority}}', a public authority", - :link_to_authority => public_body_link(track_thing.public_body)) + link_to_authority: public_body_link(track_thing.public_body)) when 'user_updates' _("'{{link_to_user}}', a person", - :link_to_user => user_link(track_thing.tracked_user)) + link_to_user: user_link(track_thing.tracked_user)) when 'search_query' link_to(track_thing.track_query_description, search_path([track_thing.track_query, 'newest', 'advanced'])) diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb new file mode 100644 index 0000000000..7a81d6b20f --- /dev/null +++ b/app/jobs/application_job.rb @@ -0,0 +1,13 @@ +class ApplicationJob < ActiveJob::Base # :nodoc: + # Automatically retry jobs that encountered a deadlock + retry_on ActiveRecord::Deadlocked + + # Most jobs are safe to ignore if the underlying records are no longer + # available + discard_on ActiveJob::DeserializationError + + def self.perform_later(*args) + return super unless AlaveteliConfiguration.background_jobs == 'inline' + perform_now(*args) + end +end diff --git a/app/jobs/info_request_expire_job.rb b/app/jobs/info_request_expire_job.rb new file mode 100644 index 0000000000..394d21bf1f --- /dev/null +++ b/app/jobs/info_request_expire_job.rb @@ -0,0 +1,25 @@ +## +# Job to expire InfoRequest objects. Can expire single requests, all requests or +# a collection of requests through an model associations. +# +# Examples: +# InfoRequestExpireJob.perform(InfoRequest.first) +# InfoRequestExpireJob.perform(InfoRequest, :all) +# InfoRequestExpireJob.perform(PublicBody.first, :info_requests) +# +class InfoRequestExpireJob < ApplicationJob + queue_as :default + + def perform(object, method = nil) + return object.expire if object.is_a?(InfoRequest) + + if object == InfoRequest && method == :all + enumerator = InfoRequest.all + else + association = object.association(method) + enumerator = association.reader if association.klass == InfoRequest + end + + enumerator.find_each { |request| perform(request) } + end +end diff --git a/app/mailers/alaveteli_pro/account_mailer.rb b/app/mailers/alaveteli_pro/account_mailer.rb index af4ea2e789..b33d9f0c18 100644 --- a/app/mailers/alaveteli_pro/account_mailer.rb +++ b/app/mailers/alaveteli_pro/account_mailer.rb @@ -10,9 +10,9 @@ def account_request(account_request) set_reply_to_headers(nil, 'Reply-To' => @account_request.email) # From is an address we control so that strict DMARC senders don't get refused - mail(:from => blackhole_email, - :to => pro_contact_from_name_and_email, - :subject => _("{{pro_site_name}} account request", + mail(from: blackhole_email, + to: pro_contact_from_name_and_email, + subject: _("{{pro_site_name}} account request", pro_site_name: pro_site_name) ) end diff --git a/app/mailers/alaveteli_pro/embargo_mailer.rb b/app/mailers/alaveteli_pro/embargo_mailer.rb index 8d8bc2b53e..403c1793f0 100644 --- a/app/mailers/alaveteli_pro/embargo_mailer.rb +++ b/app/mailers/alaveteli_pro/embargo_mailer.rb @@ -100,15 +100,15 @@ def auto_generated_headers 'Return-Path' => blackhole_email, 'Reply-To' => pro_contact_from_name_and_email, # not much we can do if the user's email is broken 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 - 'X-Auto-Response-Suppress' => 'OOF', + 'X-Auto-Response-Suppress' => 'OOF' }) end def mail_user(user, subject) mail({ - :from => pro_contact_from_name_and_email, - :to => user.name_and_email, - :subject => subject, + from: pro_contact_from_name_and_email, + to: user.name_and_email, + subject: subject }) end end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb index e5e80adeb2..b89fee8b6e 100644 --- a/app/mailers/application_mailer.rb +++ b/app/mailers/application_mailer.rb @@ -25,21 +25,21 @@ class ApplicationMailer < ActionMailer::Base self.raise_delivery_errors = true def blackhole_email - AlaveteliConfiguration::blackhole_prefix+"@"+AlaveteliConfiguration::incoming_email_domain + AlaveteliConfiguration.blackhole_prefix+"@"+AlaveteliConfiguration.incoming_email_domain end def mail_user(user, subject, opts = {}) default_opts = { - :from => contact_for_user(user), - :to => user.name_and_email, - :subject => subject, + from: contact_for_user(user), + to: user.name_and_email, + subject: subject } default_opts.merge!(opts) mail(default_opts) end def contact_for_user(user = nil) - if feature_enabled?(:alaveteli_pro) and user and user.is_pro? + if feature_enabled?(:alaveteli_pro) && user && user.is_pro? pro_contact_from_name_and_email else contact_from_name_and_email @@ -48,10 +48,10 @@ def contact_for_user(user = nil) # Set headers that mark an email as being auto-generated and suppress out of # office responses to them - def set_auto_generated_headers(opts = {}) + def set_auto_generated_headers(_opts = {}) headers({ 'Auto-Submitted' => 'auto-generated', # http://tools.ietf.org/html/rfc3834 - 'X-Auto-Response-Suppress' => 'OOF', + 'X-Auto-Response-Suppress' => 'OOF' }) end diff --git a/app/mailers/contact_mailer.rb b/app/mailers/contact_mailer.rb index 45936ad0d1..a5d3042288 100644 --- a/app/mailers/contact_mailer.rb +++ b/app/mailers/contact_mailer.rb @@ -9,39 +9,46 @@ class ContactMailer < ApplicationMailer # Send message to administrator def to_admin_message(name, email, subject, message, logged_in_user, last_request, last_body) - @message, @logged_in_user, @last_request, @last_body = message, logged_in_user, last_request, last_body + @message = message + @logged_in_user = logged_in_user + @last_request = last_request + @last_body = last_body reply_to_address = MailHandler.address_from_name_and_email(name, email) set_reply_to_headers(nil, 'Reply-To' => reply_to_address) # From is an address we control so that strict DMARC senders don't get refused - mail(:from => MailHandler.address_from_name_and_email(name, blackhole_email), - :to => contact_for_user(@logged_in_user), - :subject => subject) + mail(from: MailHandler.address_from_name_and_email(name, blackhole_email), + to: contact_for_user(@logged_in_user), + subject: subject) end # Send message to another user def user_message(from_user, recipient_user, from_user_url, subject, message) - @message, @from_user, @recipient_user, @from_user_url = message, from_user, recipient_user, from_user_url + @message = message + @from_user = from_user + @recipient_user = recipient_user + @from_user_url = from_user_url set_reply_to_headers(nil, 'Reply-To' => from_user.name_and_email) # From is an address we control so that strict DMARC senders don't get refused - mail(:from => MailHandler.address_from_name_and_email(from_user.name, blackhole_email), - :to => recipient_user.name_and_email, - :subject => subject) + mail(from: MailHandler.address_from_name_and_email(from_user.name, blackhole_email), + to: recipient_user.name_and_email, + subject: subject) end # Send message to a user from the administrator def from_admin_message(recipient_name, recipient_email, subject, message) @message = message - @recipient_name, @recipient_email = recipient_name, recipient_email + @recipient_name = recipient_name + @recipient_email = recipient_email recipient_user = User.find_by_email(recipient_email) - mail(:from => contact_for_user(recipient_user), - :to => MailHandler.address_from_name_and_email(@recipient_name, @recipient_email), - :bcc => AlaveteliConfiguration::contact_email, - :subject => subject) + mail(from: contact_for_user(recipient_user), + to: MailHandler.address_from_name_and_email(@recipient_name, @recipient_email), + bcc: AlaveteliConfiguration.contact_email, + subject: subject) end end diff --git a/app/mailers/info_request_batch_mailer.rb b/app/mailers/info_request_batch_mailer.rb index ffc55ad7ed..774e3303c4 100644 --- a/app/mailers/info_request_batch_mailer.rb +++ b/app/mailers/info_request_batch_mailer.rb @@ -7,7 +7,8 @@ class InfoRequestBatchMailer < ApplicationMailer def batch_sent(info_request_batch, unrequestable, user) - @info_request_batch, @unrequestable = info_request_batch, unrequestable + @info_request_batch = info_request_batch + @unrequestable = unrequestable @url = info_request_batch_url(@info_request_batch) set_reply_to_headers(user) @@ -15,7 +16,7 @@ def batch_sent(info_request_batch, unrequestable, user) mail_user( user, _("Your batch request \"{{title}}\" has been sent", - :title => info_request_batch.title.html_safe) + title: info_request_batch.title.html_safe) ) end end diff --git a/app/mailers/notification_mailer.rb b/app/mailers/notification_mailer.rb index 101909e6e2..f4c61a33fc 100644 --- a/app/mailers/notification_mailer.rb +++ b/app/mailers/notification_mailer.rb @@ -53,17 +53,17 @@ def self.send_instant_notifications end def self.send_notifications - sent_instant_notifications = self.send_instant_notifications - sent_daily_notifications = self.send_daily_notifications + sent_instant_notifications = send_instant_notifications + sent_daily_notifications = send_daily_notifications sent_instant_notifications || sent_daily_notifications end def self.send_notifications_loop # Run send_notifications in an endless loop, sleeping when there is # nothing to do - while true + loop do sleep_seconds = 1 - while !send_notifications + until send_notifications sleep sleep_seconds sleep_seconds *= 2 sleep_seconds = 300 if sleep_seconds > 300 @@ -95,7 +95,7 @@ def daily_summary(user, notifications) def instant_notification(notification) event_type = notification.info_request_event.event_type method = "#{event_type}_notification".to_sym - self.send(method, notification) + send(method, notification) end def response_notification(notification) @@ -106,7 +106,7 @@ def response_notification(notification) set_auto_generated_headers subject = _("New response to your FOI request - {{request_title}}", - :request_title => @info_request.title.html_safe) + request_title: @info_request.title.html_safe) mail_user(@info_request.user, subject, template_name: 'response_notification') @@ -156,7 +156,7 @@ def overdue_notification(notification) set_auto_generated_headers subject = _("Delayed response to your FOI request - {{request_title}}", - :request_title => @info_request.title.html_safe) + request_title: @info_request.title.html_safe) mail_user(@info_request.user, subject, @@ -172,7 +172,7 @@ def very_overdue_notification(notification) subject = _("You're long overdue a response to your FOI request " \ "- {{request_title}}", - :request_title => @info_request.title.html_safe) + request_title: @info_request.title.html_safe) mail_user(@info_request.user, subject, diff --git a/app/mailers/outgoing_mailer.rb b/app/mailers/outgoing_mailer.rb index bf11b55dbf..1c256fbffd 100644 --- a/app/mailers/outgoing_mailer.rb +++ b/app/mailers/outgoing_mailer.rb @@ -4,7 +4,7 @@ # Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. # Email: hello@mysociety.org; WWW: http://www.mysociety.org/ -# Note: The layout for this wraps messages by lines rather than (blank line +# NOTE: The layout for this wraps messages by lines rather than (blank line # separated) paragraphs, as is the convention for all the other mailers. This # turned out to fit better with user exepectations when formatting messages. # @@ -20,9 +20,9 @@ def initial_request(info_request, outgoing_message) @contact_email = AlaveteliConfiguration.contact_email headers["message-id"] = OutgoingMailer.id_for_message(@outgoing_message) - mail(:from => @outgoing_message.from, - :to => @outgoing_message.to, - :subject => @outgoing_message.subject) + mail(from: @outgoing_message.from, + to: @outgoing_message.to, + subject: @outgoing_message.subject) end # Later message to public body regarding existing request @@ -33,9 +33,9 @@ def followup(info_request, outgoing_message, incoming_message_followup) @contact_email = AlaveteliConfiguration.contact_email headers["message-id"] = OutgoingMailer.id_for_message(@outgoing_message) - mail(:from => @outgoing_message.from, - :to => @outgoing_message.to, - :subject => @outgoing_message.subject) + mail(from: @outgoing_message.from, + to: @outgoing_message.to, + subject: @outgoing_message.subject) end # TODO: the condition checking valid_to_reply_to? also appears in views/request/_followup.html.erb, @@ -45,55 +45,55 @@ def followup(info_request, outgoing_message, incoming_message_followup) # need to work even when IncomingMessage is nil def self.name_and_email_for_followup(info_request, incoming_message_followup) if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to? - return info_request.recipient_name_and_email + info_request.recipient_name_and_email else # calling safe_from_name from so censor rules are run - return MailHandler.address_from_name_and_email(incoming_message_followup.safe_from_name, + MailHandler.address_from_name_and_email(incoming_message_followup.safe_from_name, incoming_message_followup.from_email) end end # Used in the preview of followup def self.name_for_followup(info_request, incoming_message_followup) if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to? - return info_request.public_body.name + info_request.public_body.name else # calling safe_from_name from so censor rules are run - return incoming_message_followup.safe_from_name || info_request.public_body.name + incoming_message_followup.safe_from_name || info_request.public_body.name end end # Used when making list of followup places to remove duplicates def self.email_for_followup(info_request, incoming_message_followup) if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to? - return info_request.recipient_email + info_request.recipient_email else - return incoming_message_followup.from_email + incoming_message_followup.from_email end end # Subject to use for followup def self.subject_for_followup(info_request, outgoing_message, options = {}) if outgoing_message.what_doing == 'internal_review' - return _("Internal review of {{email_subject}}", :email_subject => info_request.email_subject_request(:html => options[:html])) + _("Internal review of {{email_subject}}", email_subject: info_request.email_subject_request(html: options[:html])) else - return info_request.email_subject_followup(:incoming_message => outgoing_message.incoming_message_followup, - :html => options[:html]) + info_request.email_subject_followup(incoming_message: outgoing_message.incoming_message_followup, + html: options[:html]) end end # Whether we have a valid email address for a followup def self.is_followupable?(info_request, incoming_message_followup) if incoming_message_followup.nil? || !incoming_message_followup.valid_to_reply_to? - return info_request.recipient_email_valid_for_followup? + info_request.recipient_email_valid_for_followup? else # email has been checked in incoming_message_followup.valid_to_reply_to? above - return true + true end end # Message-ID to use def self.id_for_message(outgoing_message) message_id = "ogm-" + outgoing_message.id.to_s t = Time.zone.now - message_id += "+" + '%08x%05x-%04x' % [t.to_i, t.tv_usec, rand(0xffff)] - message_id += "@" + AlaveteliConfiguration::incoming_email_domain - return "<" + message_id + ">" + message_id += "+" + format('%08x%05x-%04x', t.to_i, t.tv_usec, rand(0xffff)) + message_id += "@" + AlaveteliConfiguration.incoming_email_domain + "<" + message_id + ">" end end diff --git a/app/mailers/reminder_mailer.rb b/app/mailers/reminder_mailer.rb index 9a33e1c56c..78b91e4e7b 100644 --- a/app/mailers/reminder_mailer.rb +++ b/app/mailers/reminder_mailer.rb @@ -8,8 +8,8 @@ def public_holidays(name, email, subject) 'Reply-To' => MailHandler.address_from_name_and_email(name, email) ) - mail(:from => MailHandler.address_from_name_and_email(name, email), - :to => MailHandler.address_from_name_and_email(name, email), - :subject => subject) + mail(from: MailHandler.address_from_name_and_email(name, email), + to: MailHandler.address_from_name_and_email(name, email), + subject: subject) end end diff --git a/app/mailers/request_mailer.rb b/app/mailers/request_mailer.rb index 3e88f50bb7..a256c71e52 100644 --- a/app/mailers/request_mailer.rb +++ b/app/mailers/request_mailer.rb @@ -8,7 +8,7 @@ class RequestMailer < ApplicationMailer include AlaveteliFeatures::Helpers before_action :set_footer_template, - :only => [ + only: [ :new_response, :overdue_alert, :very_overdue_alert, :new_response_reminder_alert, :old_unclassified_updated, :not_clarified_alert, :comment_on_alert, @@ -24,13 +24,13 @@ def fake_response(info_request, from_user, message_body, attachment_name, attach if !attachment_name.nil? && !attachment_content.nil? content_type = AlaveteliFileTypes.filename_to_mimetype(attachment_name) || 'application/octet-stream' - attachments[attachment_name] = {:content => attachment_content, - :content_type => content_type} + attachments[attachment_name] = {content: attachment_content, + content_type: content_type} end - mail(:from => from_user.name_and_email, - :to => info_request.incoming_name_and_email, - :subject => info_request.email_subject_followup(:html => false)) + mail(from: from_user.name_and_email, + to: info_request.incoming_name_and_email, + subject: info_request.email_subject_followup(html: false)) end # Used when a response is uploaded using the API @@ -38,27 +38,27 @@ def external_response(info_request, message_body, sent_at, attachment_hashes) @message_body = message_body attachment_hashes.each do |attachment_hash| - attachments[attachment_hash[:filename]] = {:content => attachment_hash[:body], - :content_type => attachment_hash[:content_type]} + attachments[attachment_hash[:filename]] = {content: attachment_hash[:body], + content_type: attachment_hash[:content_type]} end - mail(:from => blackhole_email, - :to => info_request.incoming_name_and_email, - :date => sent_at) + mail(from: blackhole_email, + to: info_request.incoming_name_and_email, + date: sent_at) end # Incoming message arrived for a request, but new responses have been stopped. - def stopped_responses(info_request, email, raw_email_data) + def stopped_responses(info_request, email, _raw_email_data) headers('Return-Path' => blackhole_email, # we don't care about bounces, likely from spammers 'Auto-Submitted' => 'auto-replied') # http://tools.ietf.org/html/rfc3834 @info_request = info_request - @contact_email = AlaveteliConfiguration::contact_email + @contact_email = AlaveteliConfiguration.contact_email - mail(:to => email.from_addrs[0].to_s, - :from => contact_from_name_and_email, - :reply_to => contact_from_name_and_email, - :subject => _("Your response to an FOI request was not delivered")) + mail(to: email.from_addrs[0].to_s, + from: contact_from_name_and_email, + reply_to: contact_from_name_and_email, + subject: _("Your response to an FOI request was not delivered")) end # An FOI response is outside the scope of the system, and needs admin attention @@ -72,30 +72,31 @@ def requires_admin(info_request, set_by = nil, message = "") set_reply_to_headers(nil, 'Reply-To' => user.name_and_email) # From is an address we control so that strict DMARC senders don't get refused - mail(:from => MailHandler.address_from_name_and_email( + mail(from: MailHandler.address_from_name_and_email( user.name, blackhole_email ), - :to => contact_for_user(user), - :subject => _("FOI response requires admin ({{reason}}) - " \ + to: contact_for_user(user), + subject: _("FOI response requires admin ({{reason}}) - " \ "{{request_title}}", - :reason => info_request.described_state, - :request_title => info_request.title.html_safe)) + reason: info_request.described_state, + request_title: info_request.title.html_safe)) end # Tell the requester that a new response has arrived def new_response(info_request, incoming_message) - @incoming_message, @info_request = incoming_message, info_request + @incoming_message = incoming_message + @info_request = info_request set_reply_to_headers(info_request.user) set_auto_generated_headers mail( - :from => contact_for_user(info_request.user), - :to => info_request.user.name_and_email, - :subject => _("New response to your FOI request - {{request_title}}", - :request_title => info_request.title.html_safe), - :charset => "UTF-8" + from: contact_for_user(info_request.user), + to: info_request.user.name_and_email, + subject: _("New response to your FOI request - {{request_title}}", + request_title: info_request.title.html_safe), + charset: "UTF-8" ) end @@ -110,7 +111,7 @@ def overdue_alert(info_request, user) mail_user( user, _("Delayed response to your FOI request - {{request_title}}", - :request_title => info_request.title.html_safe) + request_title: info_request.title.html_safe) ) end @@ -125,7 +126,7 @@ def very_overdue_alert(info_request, user) mail_user( user, _("You're long overdue a response to your FOI request - {{request_title}}", - :request_title => info_request.title.html_safe) + request_title: info_request.title.html_safe) ) end @@ -161,9 +162,9 @@ def old_unclassified_updated(info_request) # Tell the requester that they need to clarify their request def not_clarified_alert(info_request, incoming_message) - respond_url = new_request_incoming_followup_url(:request_id => info_request.id, - :incoming_message_id => incoming_message.id, - :anchor => 'followup') + respond_url = new_request_incoming_followup_url(request_id: info_request.id, + incoming_message_id: incoming_message.id, + anchor: 'followup') @url = respond_url @incoming_message = incoming_message @info_request = info_request @@ -173,13 +174,14 @@ def not_clarified_alert(info_request, incoming_message) mail_user( info_request.user, _("Clarify your FOI request - {{request_title}}", - :request_title => info_request.title.html_safe) + request_title: info_request.title.html_safe) ) end # Tell requester that somebody add an annotation to their request def comment_on_alert(info_request, comment) - @comment, @info_request = comment, info_request + @comment = comment + @info_request = info_request @url = comment_url(comment) set_reply_to_headers(info_request.user) @@ -187,14 +189,15 @@ def comment_on_alert(info_request, comment) mail_user( info_request.user, _("Somebody added a note to your FOI request - {{request_title}}", - :request_title => info_request.title.html_safe) + request_title: info_request.title.html_safe) ) end # Tell requester that somebody added annotations to more than one of # their requests def comment_on_alert_plural(info_request, count, earliest_unalerted_comment) - @count, @info_request = count, info_request + @count = count + @info_request = info_request @url = comment_url(earliest_unalerted_comment) set_reply_to_headers(info_request.user) @@ -202,7 +205,7 @@ def comment_on_alert_plural(info_request, count, earliest_unalerted_comment) mail_user( info_request.user, _("Some notes have been added to your FOI request - {{request_title}}", - :request_title => info_request.title.html_safe) + request_title: info_request.title.html_safe) ) end @@ -236,20 +239,18 @@ def requests_matching_email(email) # Member function, called on the new class made in self.receive above def receive(email, raw_email, source = :mailin) - opts = { :source => source } + opts = { source: source } # Find which info requests the email is for - reply_info_requests = self.requests_matching_email(email) + reply_info_requests = requests_matching_email(email) # Nothing found, so save in holding pen - if reply_info_requests.size == 0 + if reply_info_requests.empty? opts[:rejected_reason] = _("Could not identify the request from the email address") request = InfoRequest.holding_pen_request - unless SpamAddress.spam?(email.to) - request.receive(email, raw_email, opts) - end + request.receive(email, raw_email, opts) unless SpamAddress.spam?(email.to) return end @@ -287,11 +288,11 @@ def self.alert_overdue_requests AND info_request_id = info_requests.id) ) IS NULL", false, false).includes(:user) - for info_request in info_requests + info_requests.each do |info_request| alert_event_id = info_request.last_event_forming_initial_request.id # Only overdue requests calculated_status = info_request.calculate_status - if ['waiting_response_overdue', 'waiting_response_very_overdue'].include?(calculated_status) + if %w[waiting_response_overdue waiting_response_very_overdue].include?(calculated_status) if calculated_status == 'waiting_response_overdue' alert_type = 'overdue_1' elsif calculated_status == 'waiting_response_very_overdue' @@ -346,8 +347,8 @@ def self.alert_overdue_requests # Send email alerts for new responses which haven't been classified. By default, # it goes out 3 days after last update of event, then after 10, then after 24. def self.alert_new_response_reminders - AlaveteliConfiguration::new_response_reminder_after_days.each_with_index do |days, i| - self.alert_new_response_reminders_internal(days, "new_response_reminder_#{i+1}") + AlaveteliConfiguration.new_response_reminder_after_days.each_with_index do |days, i| + alert_new_response_reminders_internal(days, "new_response_reminder_#{i+1}") end end def self.alert_new_response_reminders_internal(days_since, type_code) @@ -406,7 +407,7 @@ def self.alert_not_clarified_request false ). includes(:user).order(:id) - for info_request in info_requests + info_requests.each do |info_request| alert_event_id = info_request.get_last_public_response_event_id last_response_message = info_request.get_last_public_response next if alert_event_id.nil? @@ -466,7 +467,7 @@ def self.alert_comment_on_request info_requests = InfoRequest. - includes(:info_request_events => :user_info_request_sent_alerts). + includes(info_request_events: :user_info_request_sent_alerts). where(conditions). order(:id).merge(InfoRequestEvent.order(:created_at)). references(:info_request_events) @@ -478,7 +479,7 @@ def self.alert_comment_on_request earliest_unalerted_comment_event = nil last_comment_event = nil count = 0 - for e in info_request.info_request_events.reverse + info_request.info_request_events.reverse.each do |e| # alert on comments, which were not made by the user who originally made the request if e.event_type == 'comment' && e.comment.user_id != info_request.user_id last_comment_event = e if last_comment_event.nil? @@ -489,7 +490,7 @@ def self.alert_comment_on_request info_request.user_id). first if alerted_for.nil? - count = count + 1 + count += 1 earliest_unalerted_comment_event = e else break diff --git a/app/mailers/track_mailer.rb b/app/mailers/track_mailer.rb index af29c144b2..72dc5b891c 100644 --- a/app/mailers/track_mailer.rb +++ b/app/mailers/track_mailer.rb @@ -7,16 +7,17 @@ class TrackMailer < ApplicationMailer helper UnsubscribeHelper - before_action :set_footer_template, :only => :event_digest + before_action :set_footer_template, only: :event_digest # Note that this is different from all the other mailers, as tracks are # sent from a different email address and have different bounce handling. def contact_from_name_and_email - "#{AlaveteliConfiguration::track_sender_name} <#{AlaveteliConfiguration::track_sender_email}>" + "#{AlaveteliConfiguration.track_sender_name} <#{AlaveteliConfiguration.track_sender_email}>" end def event_digest(user, email_about_things) - @user, @email_about_things = user, email_about_things + @user = user + @email_about_things = email_about_things headers( # http://tools.ietf.org/html/rfc3834 @@ -30,10 +31,10 @@ def event_digest(user, email_about_things) # (We let it return bounces for now, so we can manually kill the tracks that bounce so Yahoo # etc. don't decide we are spammers.) - mail(:from => contact_from_name_and_email, - :to => user.name_and_email, - :subject => _("Your {{site_name}} email alert", - :site_name => site_name.html_safe)) + mail(from: contact_from_name_and_email, + to: user.name_and_email, + subject: _("Your {{site_name}} email alert", + site_name: site_name.html_safe)) end # Send email alerts for tracked things. Never more than one email @@ -51,9 +52,9 @@ def self.alert_tracks next unless user.should_be_emailed? email_about_things = [] - track_things = TrackThing.where(:tracking_user_id => user.id, - :track_medium => 'email_daily') - for track_thing in track_things + track_things = TrackThing.where(tracking_user_id: user.id, + track_medium: 'email_daily') + track_things.each do |track_thing| # What have we alerted on already? # # We only use track_things_sent_emails records which are less than 14 days old. @@ -63,8 +64,8 @@ def self.alert_tracks # for a whole week, then they will miss some items. Tough. done_info_request_events = {} tt_sent = track_thing.track_things_sent_emails.where('created_at > ?', now - 14.days) - for t in tt_sent - if not t.info_request_event_id.nil? + tt_sent.each do |t| + unless t.info_request_event_id.nil? done_info_request_events[t.info_request_event_id] = 1 end end @@ -73,32 +74,38 @@ def self.alert_tracks # ordering, so we catch anything new (before described), or # anything whose new status has been described. xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], track_thing.track_query, - :sort_by_prefix => 'described_at', - :sort_by_ascending => true, - :collapse_by_prefix => nil, - :limit => 100) + sort_by_prefix: 'described_at', + sort_by_ascending: true, + collapse_by_prefix: nil, + limit: 100) # Go through looking for unalerted things alert_results = [] - for result in xapian_object.results + xapian_object.results.each do |result| if result[:model].class.to_s != "InfoRequestEvent" raise "need to add other types to TrackMailer.alert_tracks (unalerted)" end - next if track_thing.created_at >= result[:model].described_at # made before the track was created - next if result[:model].described_at < one_week_ago # older than 1 week (see 14 days / 7 days in comment above) - next if done_info_request_events.include?(result[:model].id) # definitely already done + if track_thing.created_at >= result[:model].described_at # made before the track was created + next + end + if result[:model].described_at < one_week_ago # older than 1 week (see 14 days / 7 days in comment above) + next + end + if done_info_request_events.include?(result[:model].id) # definitely already done + next + end # OK alert this one alert_results.push(result) end # If there were more alerts for this track, then store them - if alert_results.size > 0 + if !alert_results.empty? email_about_things.push([track_thing, alert_results, xapian_object]) end end # If we have anything to send, then send everything for the user in one mail - if email_about_things.size > 0 + if !email_about_things.empty? # Send the email AlaveteliLocalization.with_locale(user.locale) do @@ -107,8 +114,8 @@ def self.alert_tracks end # Record that we've now sent those alerts to that user - for track_thing, alert_results in email_about_things - for result in alert_results + email_about_things.each do |track_thing, alert_results| + alert_results.each do |result| track_things_sent_email = TrackThingsSentEmail.new track_things_sent_email.track_thing_id = track_thing.id if result[:model].class.to_s == "InfoRequestEvent" @@ -124,14 +131,14 @@ def self.alert_tracks user.save!(touch: false) done_something = true end - return done_something + done_something end def self.alert_tracks_loop # Run alert_tracks in an endless loop, sleeping when there is nothing to do - while true + loop do sleep_seconds = 1 - while !alert_tracks + until alert_tracks sleep sleep_seconds sleep_seconds *= 2 sleep_seconds = 300 if sleep_seconds > 300 diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index bc08e7171f..56aeb3fef8 100644 --- a/app/mailers/user_mailer.rb +++ b/app/mailers/user_mailer.rb @@ -6,35 +6,43 @@ class UserMailer < ApplicationMailer def confirm_login(user, reasons, url) - @reasons, @name, @url = reasons, user.name, url + @reasons = reasons + @name = user.name + @url = url set_reply_to_headers(user) mail_user(user, reasons[:email_subject]) end def already_registered(user, reasons, url) - @reasons, @name, @url = reasons, user.name, url + @reasons = reasons + @name = user.name + @url = url set_reply_to_headers(user) mail_user(user, reasons[:email_subject]) end def changeemail_confirm(user, new_email, url) - @name, @url, @old_email, @new_email = user.name, url, user.email, new_email + @name = user.name + @url = url + @old_email = user.email + @new_email = new_email set_reply_to_headers(user) - mail(:from => contact_for_user(user), - :to => new_email, - :subject => _("Confirm your new email address on {{site_name}}", :site_name => site_name)) + mail(from: contact_for_user(user), + to: new_email, + subject: _("Confirm your new email address on {{site_name}}", site_name: site_name)) end def changeemail_already_used(old_email, new_email) - @old_email, @new_email = old_email, new_email + @old_email = old_email + @new_email = new_email user = User.find_by_email(@old_email) set_reply_to_headers(user) - mail(:from => contact_for_user(user), - :to => new_email, - :subject => _("Unable to change email address on {{site_name}}", :site_name=>site_name)) + mail(from: contact_for_user(user), + to: new_email, + subject: _("Unable to change email address on {{site_name}}", site_name: site_name)) end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 8ffd05d8fc..03422dea5c 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -4,8 +4,8 @@ class Ability attr_reader :user, :project, :public_token - def self.guest(*args) - new(nil, *args) + def self.guest(**args) + new(nil, **args) end def initialize(user, project: nil, public_token: false) @@ -106,7 +106,7 @@ def initialize(user, project: nil, public_token: false) public_token end - can :manage, OutgoingMessage::Snippet do |request| + can :manage, OutgoingMessage::Snippet do |_request| user && user.is_admin? end @@ -208,13 +208,9 @@ def initialize(user, project: nil, public_token: false) end if feature_enabled? :alaveteli_pro - if user && user.is_pro_admin? - can :read, :api_key - end - else - if user && user.is_admin? - can :read, :api_key - end + can :read, :api_key if user && user.is_pro_admin? + elsif user && user.is_admin? + can :read, :api_key end if feature_enabled? :projects diff --git a/app/models/alaveteli_pro/account_request.rb b/app/models/alaveteli_pro/account_request.rb index 402fd9e148..05ed9c88d9 100644 --- a/app/models/alaveteli_pro/account_request.rb +++ b/app/models/alaveteli_pro/account_request.rb @@ -12,10 +12,10 @@ class AlaveteliPro::AccountRequest :marketing_emails, :training_emails - validates_presence_of :email, :message => N_("Please enter your email address") - validates_presence_of :reason, :message => N_("Please enter the reason why you want access") - validates_presence_of :marketing_emails, :message => N_("Please tell us if you want to get updates") - validates_presence_of :training_emails, :message => N_("Please tell us if you're interested in training and seminars") + validates_presence_of :email, message: N_("Please enter your email address") + validates_presence_of :reason, message: N_("Please enter the reason why you want access") + validates_presence_of :marketing_emails, message: N_("Please tell us if you want to get updates") + validates_presence_of :training_emails, message: N_("Please tell us if you're interested in training and seminars") validate :email_format diff --git a/app/models/alaveteli_pro/activity_list/comment.rb b/app/models/alaveteli_pro/activity_list/comment.rb index ffc5caede6..4780614d36 100644 --- a/app/models/alaveteli_pro/activity_list/comment.rb +++ b/app/models/alaveteli_pro/activity_list/comment.rb @@ -13,9 +13,9 @@ def description end def description_urls - { :public_body_name => { :text => body_name, :url => body_path }, - :info_request_title => { :text => info_request_title, :url => info_request_path }, - :commenter_name => { :text => event.comment.user.name, :url => user_path(event.comment.user) } } + { public_body_name: { text: body_name, url: body_path }, + info_request_title: { text: info_request_title, url: info_request_path }, + commenter_name: { text: event.comment.user.name, url: user_path(event.comment.user) } } end def call_to_action_url diff --git a/app/models/alaveteli_pro/activity_list/item.rb b/app/models/alaveteli_pro/activity_list/item.rb index a943f0e76f..5956f0b085 100644 --- a/app/models/alaveteli_pro/activity_list/item.rb +++ b/app/models/alaveteli_pro/activity_list/item.rb @@ -33,8 +33,8 @@ def call_to_action end def description_urls - { :public_body_name => { :text => body_name, :url => body_path }, - :info_request_title => { :text => info_request_title, :url => info_request_path } } + { public_body_name: { text: body_name, url: body_path }, + info_request_title: { text: info_request_title, url: info_request_path } } end def event_time diff --git a/app/models/alaveteli_pro/activity_list/list.rb b/app/models/alaveteli_pro/activity_list/list.rb index 8a64c803a9..aa33ffa934 100644 --- a/app/models/alaveteli_pro/activity_list/list.rb +++ b/app/models/alaveteli_pro/activity_list/list.rb @@ -15,12 +15,12 @@ def event_types end def events - user.info_request_events.where(:event_type => event_types) + user.info_request_events.where(event_type: event_types) end def current_items - current_events = events.paginate :page => page, - :per_page => per_page + current_events = events.paginate page: page, + per_page: per_page current_events.map { |event| activity_types[event.event_type].new(event) } end diff --git a/app/models/alaveteli_pro/activity_list/overdue.rb b/app/models/alaveteli_pro/activity_list/overdue.rb index 5c6aaea3fe..2603c64c18 100644 --- a/app/models/alaveteli_pro/activity_list/overdue.rb +++ b/app/models/alaveteli_pro/activity_list/overdue.rb @@ -11,7 +11,7 @@ def call_to_action end def call_to_action_url - new_request_followup_path(:request_id => event.info_request.id, :anchor => 'followup') + new_request_followup_path(request_id: event.info_request.id, anchor: 'followup') end end diff --git a/app/models/alaveteli_pro/activity_list/very_overdue.rb b/app/models/alaveteli_pro/activity_list/very_overdue.rb index a5175b661b..385d57db9a 100644 --- a/app/models/alaveteli_pro/activity_list/very_overdue.rb +++ b/app/models/alaveteli_pro/activity_list/very_overdue.rb @@ -11,9 +11,9 @@ def call_to_action end def call_to_action_url - new_request_followup_path(:request_id => event.info_request.id, - :anchor => 'followup', - :internal_review => 1) + new_request_followup_path(request_id: event.info_request.id, + anchor: 'followup', + internal_review: 1) end end diff --git a/app/models/alaveteli_pro/draft_info_request_batch.rb b/app/models/alaveteli_pro/draft_info_request_batch.rb index 2943fc7819..9b5f7c7e03 100644 --- a/app/models/alaveteli_pro/draft_info_request_batch.rb +++ b/app/models/alaveteli_pro/draft_info_request_batch.rb @@ -17,13 +17,13 @@ class AlaveteliPro::DraftInfoRequestBatch < ApplicationRecord include InfoRequest::DraftTitleValidation belongs_to :user, - :inverse_of => :draft_info_request_batches + inverse_of: :draft_info_request_batches has_and_belongs_to_many :public_bodies, -> { AlaveteliLocalization.with_locale(AlaveteliLocalization.locale) do includes(:translations). reorder('public_body_translations.name asc') end - }, :inverse_of => :draft_info_request_batches + }, inverse_of: :draft_info_request_batches validates_presence_of :user @@ -37,9 +37,7 @@ def set_default_body template_options = {} template_options[:info_request_title] = title if title self.body = template.body(template_options) - if self.user - self.body += self.user.name - end + self.body += user.name if user end end @@ -50,7 +48,7 @@ def request_summary_body # @see RequestSummaries#request_summary_public_body_names def request_summary_public_body_names - self.public_bodies.pluck(:name).join(" ") + public_bodies.pluck(:name).join(" ") end # @see RequestSummaries#request_summary_categories diff --git a/app/models/alaveteli_pro/embargo.rb b/app/models/alaveteli_pro/embargo.rb index 2bad2bc23b..6e06e65715 100644 --- a/app/models/alaveteli_pro/embargo.rb +++ b/app/models/alaveteli_pro/embargo.rb @@ -15,17 +15,17 @@ module AlaveteliPro class Embargo < ApplicationRecord belongs_to :info_request, - :inverse_of => :embargo + inverse_of: :embargo has_many :embargo_extensions, - :inverse_of => :embargo + inverse_of: :embargo has_one :user, - :inverse_of => :embargoes, - :through => :info_request + inverse_of: :embargoes, + through: :info_request validates_presence_of :info_request validates_presence_of :publish_at validates_inclusion_of :embargo_duration, - in: lambda { |e| e.allowed_durations }, + in: ->(e) { e.allowed_durations }, allow_nil: true after_initialize :set_default_duration, :set_publish_at_from_duration, @@ -43,9 +43,9 @@ class Embargo < ApplicationRecord TWELVE_MONTHS = 364.days DURATIONS = { - "3_months" => Proc.new { THREE_MONTHS }, - "6_months" => Proc.new { SIX_MONTHS }, - "12_months" => Proc.new { TWELVE_MONTHS } + "3_months" => proc { THREE_MONTHS }, + "6_months" => proc { SIX_MONTHS }, + "12_months" => proc { TWELVE_MONTHS } }.freeze scope :expiring, -> { where("publish_at <= ?", expiring_soon_time) } @@ -131,22 +131,18 @@ def self.log_expiring_events { event_created_at: Time.zone.now }, created_at: embargo.expiring_notification_at ) - if info_request.use_notifications? - info_request.user.notify(event) - end + info_request.user.notify(event) if info_request.use_notifications? end end private def add_set_embargo_event - publish_at_changed = self.publish_at_changed? + publish_at_changed = publish_at_changed? yield if publish_at_changed - params = { :embargo_id => self.id } - if extension - params[:embargo_extension_id] = extension.id - end + params = { embargo_id: id } + params[:embargo_extension_id] = extension.id if extension info_request.log_event('set_embargo', params) end end @@ -158,14 +154,14 @@ def set_publish_at_from_duration end def set_expiring_notification_at - unless self.expiring_notification_at.present? + unless expiring_notification_at.present? self.expiring_notification_at = calculate_expiring_notification_at end end def notify_expiration if info_request.use_notifications? - if event = info_request.last_embargo_expire_event + if (event = info_request.last_embargo_expire_event) info_request.user.notify(event) end end diff --git a/app/models/alaveteli_pro/embargo_extension.rb b/app/models/alaveteli_pro/embargo_extension.rb index 3b2e7ae15e..bff61e5f15 100644 --- a/app/models/alaveteli_pro/embargo_extension.rb +++ b/app/models/alaveteli_pro/embargo_extension.rb @@ -13,10 +13,10 @@ module AlaveteliPro class EmbargoExtension < ApplicationRecord belongs_to :embargo, - :inverse_of => :embargo_extensions + inverse_of: :embargo_extensions validates_presence_of :embargo validates_presence_of :extension_duration validates_inclusion_of :extension_duration, - in: lambda { |e| AlaveteliPro::Embargo.new.allowed_durations } + in: lambda { |_e| AlaveteliPro::Embargo.new.allowed_durations } end end diff --git a/app/models/alaveteli_pro/request_filter.rb b/app/models/alaveteli_pro/request_filter.rb index 7f9f4b3f33..ef26664775 100644 --- a/app/models/alaveteli_pro/request_filter.rb +++ b/app/models/alaveteli_pro/request_filter.rb @@ -67,18 +67,18 @@ def default_order def order_attributes [ - { :param => 'updated_at_desc', - :value => 'request_updated_at DESC', - :label => _('last updated'), - :capital_label => _('Last updated') }, - { :param => 'created_at_asc', - :value => 'request_created_at ASC', - :label => _('first created'), - :capital_label => _('First created') }, - { :param => 'title_asc', - :value => 'title ASC', - :label => _('title (A-Z)'), - :capital_label => _('Title (A-Z)') } + { param: 'updated_at_desc', + value: 'request_updated_at DESC', + label: _('last updated'), + capital_label: _('Last updated') }, + { param: 'created_at_asc', + value: 'request_created_at ASC', + label: _('first created'), + capital_label: _('First created') }, + { param: 'title_asc', + value: 'title ASC', + label: _('title (A-Z)'), + capital_label: _('Title (A-Z)') } ] end @@ -104,27 +104,27 @@ def order_value def default_filters [ - { :param => nil, - :value => nil, - :label => _('all requests'), - :capital_label => _('All requests') }, - { :param => 'draft', - :value => :draft, - :label => _('drafts'), - :capital_label => _('Drafts') }, - { :param => 'embargoes_expiring', - :value => :embargo_expiring, - :label => _('requests that will be made public soon'), - :capital_label => _('Requests that will be made public soon') + { param: nil, + value: nil, + label: _('all requests'), + capital_label: _('All requests') }, + { param: 'draft', + value: :draft, + label: _('drafts'), + capital_label: _('Drafts') }, + { param: 'embargoes_expiring', + value: :embargo_expiring, + label: _('requests that will be made public soon'), + capital_label: _('Requests that will be made public soon') } ] end def phase_filters - InfoRequest::State.phases.map { |phase| { :param => phase[:scope].to_s, - :value => phase[:scope], - :label => phase[:label], - :capital_label => phase[:capital_label] } } + InfoRequest::State.phases.map { |phase| { param: phase[:scope].to_s, + value: phase[:scope], + label: phase[:label], + capital_label: phase[:capital_label] } } end def filter_attributes diff --git a/app/models/alaveteli_pro/request_summary.rb b/app/models/alaveteli_pro/request_summary.rb index 0c7ed441ef..1ac859fe76 100644 --- a/app/models/alaveteli_pro/request_summary.rb +++ b/app/models/alaveteli_pro/request_summary.rb @@ -19,10 +19,10 @@ class AlaveteliPro::RequestSummary < ApplicationRecord belongs_to :summarisable, polymorphic: true belongs_to :user, - :inverse_of => :request_summaries + inverse_of: :request_summaries has_and_belongs_to_many :request_summary_categories, - :class_name => "AlaveteliPro::RequestSummaryCategory", - :inverse_of => :request_summaries + class_name: "AlaveteliPro::RequestSummaryCategory", + inverse_of: :request_summaries validates_presence_of :summarisable, :request_created_at, @@ -41,7 +41,7 @@ def self.category(category_slug) end def self.not_category(category_slug) - summary_ids_to_exclude = self.category(category_slug).pluck(:id) + summary_ids_to_exclude = category(category_slug).pluck(:id) results = includes(:request_summary_categories) unless summary_ids_to_exclude.blank? results = results. @@ -52,16 +52,16 @@ def self.not_category(category_slug) def self.create_or_update_from(request) unless ALLOWED_REQUEST_CLASSES.include?(request.class.name) - raise ArgumentError.new("Can't create a RequestSummary from " \ + raise ArgumentError, "Can't create a RequestSummary from " \ "#{request.class.name} instances. Only " \ - "#{ALLOWED_REQUEST_CLASSES} are allowed.") + "#{ALLOWED_REQUEST_CLASSES} are allowed." end request.reload if request.request_summary request.request_summary.update_from(request) request.request_summary else - self.create_from(request) + create_from(request) end end @@ -69,10 +69,8 @@ def update_from(request) update(self.class.attributes_from_request(request)) end - private - def self.create_from(request) - self.create(attributes_from_request(request)) + create(attributes_from_request(request)) end def self.attributes_from_request(request) @@ -84,7 +82,7 @@ def self.attributes_from_request(request) user: request.user, request_summary_categories: request.request_summary_categories, request_created_at: request.created_at, - request_updated_at: request.updated_at, + request_updated_at: request.updated_at } end end diff --git a/app/models/alaveteli_pro/request_summary_category.rb b/app/models/alaveteli_pro/request_summary_category.rb index 980921d8d4..0ae0ef3f4a 100644 --- a/app/models/alaveteli_pro/request_summary_category.rb +++ b/app/models/alaveteli_pro/request_summary_category.rb @@ -11,42 +11,42 @@ class AlaveteliPro::RequestSummaryCategory < ApplicationRecord has_and_belongs_to_many :request_summaries, - :class_name => "AlaveteliPro::RequestSummary", - :inverse_of => :request_summary_categories + class_name: "AlaveteliPro::RequestSummary", + inverse_of: :request_summary_categories def self.draft - return find_by(slug: "draft") + find_by(slug: "draft") end def self.complete - return find_by(slug: 'complete') + find_by(slug: 'complete') end def self.clarification_needed - return find_by(slug: 'clarification_needed') + find_by(slug: 'clarification_needed') end def self.awaiting_response - return find_by(slug: 'awaiting_response') + find_by(slug: 'awaiting_response') end def self.response_received - return find_by(slug: 'response_received') + find_by(slug: 'response_received') end def self.overdue - return find_by(slug: 'overdue') + find_by(slug: 'overdue') end def self.very_overdue - return find_by(slug: 'very_overdue') + find_by(slug: 'very_overdue') end def self.other - return find_by(slug: 'other') + find_by(slug: 'other') end def self.embargo_expiring - return find_by(slug: 'embargo_expiring') + find_by(slug: 'embargo_expiring') end end diff --git a/app/models/alaveteli_pro/subscription_collection.rb b/app/models/alaveteli_pro/subscription_collection.rb index e21ad89b0d..011037b58a 100644 --- a/app/models/alaveteli_pro/subscription_collection.rb +++ b/app/models/alaveteli_pro/subscription_collection.rb @@ -18,7 +18,8 @@ def initialize(customer) def build AlaveteliPro::Subscription.new( Stripe::Subscription.new.tap do |subscription| - subscription.update_attributes(customer: @customer) + params = { customer: @customer } + subscription.update_attributes(params) end ) end diff --git a/app/models/alaveteli_pro/subscription_with_discount.rb b/app/models/alaveteli_pro/subscription_with_discount.rb index 456508a63a..b257c2d33d 100644 --- a/app/models/alaveteli_pro/subscription_with_discount.rb +++ b/app/models/alaveteli_pro/subscription_with_discount.rb @@ -27,7 +27,7 @@ def initialize(subscription) def amount net = BigDecimal((original_amount * 0.01), 0).round(2) - net = net - reduction(net) + net -= reduction(net) (net * 100).floor end diff --git a/app/models/alaveteli_pro/to_do_list/expiring_embargo.rb b/app/models/alaveteli_pro/to_do_list/expiring_embargo.rb index ee93b7eaad..5f6815a78c 100644 --- a/app/models/alaveteli_pro/to_do_list/expiring_embargo.rb +++ b/app/models/alaveteli_pro/to_do_list/expiring_embargo.rb @@ -6,7 +6,7 @@ def description n_("{{count}} request will be made public this week.", "{{count}} requests will be made public this week.", count, - :count => count) + count: count) end def items diff --git a/app/models/alaveteli_pro/to_do_list/list.rb b/app/models/alaveteli_pro/to_do_list/list.rb index 506f6cbb10..4d56d0a196 100644 --- a/app/models/alaveteli_pro/to_do_list/list.rb +++ b/app/models/alaveteli_pro/to_do_list/list.rb @@ -16,8 +16,6 @@ def active_items items.select { |item| item.count > 0 } end - private - def self.item_types [ ToDoList::NewResponse, ToDoList::ExpiringEmbargo, diff --git a/app/models/alaveteli_pro/to_do_list/new_response.rb b/app/models/alaveteli_pro/to_do_list/new_response.rb index af929f2944..8bef8e6d80 100644 --- a/app/models/alaveteli_pro/to_do_list/new_response.rb +++ b/app/models/alaveteli_pro/to_do_list/new_response.rb @@ -6,7 +6,7 @@ def description n_("{{count}} request has received a response.", "{{count}} requests have received a response.", count, - :count => count) + count: count) end def items diff --git a/app/models/alaveteli_pro/to_do_list/overdue_request.rb b/app/models/alaveteli_pro/to_do_list/overdue_request.rb index 0811b3c3ed..9586da3c46 100644 --- a/app/models/alaveteli_pro/to_do_list/overdue_request.rb +++ b/app/models/alaveteli_pro/to_do_list/overdue_request.rb @@ -6,7 +6,7 @@ def description n_("{{count}} request is delayed.", "{{count}} requests are delayed.", count, - :count => count) + count: count) end def items diff --git a/app/models/alaveteli_pro/to_do_list/very_overdue_request.rb b/app/models/alaveteli_pro/to_do_list/very_overdue_request.rb index 1bef1bbfa6..0c0655c5e8 100644 --- a/app/models/alaveteli_pro/to_do_list/very_overdue_request.rb +++ b/app/models/alaveteli_pro/to_do_list/very_overdue_request.rb @@ -6,7 +6,7 @@ def description n_("{{count}} request is long overdue.", "{{count}} requests are long overdue.", count, - :count => count) + count: count) end def items diff --git a/app/models/blog.rb b/app/models/blog.rb new file mode 100644 index 0000000000..6148ab0fc0 --- /dev/null +++ b/app/models/blog.rb @@ -0,0 +1,52 @@ +## +# Class responsible for loading external blog content +# +# Requires `BLOG_FEED` to be configured in config/general.yml +# +# Currently WordPress is the only "officially supported" external blog feed, +# but other feeds may work if they use the same data format. +# +class Blog + include ConfigHelper + + def self.enabled? + AlaveteliConfiguration.blog_feed.present? + end + + def self.table_name_prefix + 'blog_' + end + + def posts + return [] if content.empty? + + posts = XmlSimple.xml_in(content)['channel'][0].fetch('item', []).reverse + posts.map do |data| + Blog::Post.find_or_initialize_by(url: data['link'][0]).tap do |post| + post.update(title: data['title'][0], data: data) + end + end.reverse + end + + def feeds + [{ url: feed_url, title: "#{site_name} blog" }] + end + + def feed_url + uri = URI(AlaveteliConfiguration.blog_feed) + uri.query = URI.decode_www_form(uri.query || '').to_h.merge( + lang: AlaveteliLocalization.html_lang.to_s + ).to_param + uri.to_s + end + + private + + def content + @content ||= quietly_try_to_open(feed_url, timeout) + end + + def timeout + AlaveteliConfiguration.blog_timeout.presence || 60 + end +end diff --git a/app/models/blog/post.rb b/app/models/blog/post.rb new file mode 100644 index 0000000000..7651ef8e49 --- /dev/null +++ b/app/models/blog/post.rb @@ -0,0 +1,26 @@ +# == Schema Information +# Schema version: 20230314171033 +# +# Table name: blog_posts +# +# id :bigint not null, primary key +# title :string +# url :string +# data :jsonb +# created_at :datetime not null +# updated_at :datetime not null +# +class Blog::Post < ApplicationRecord + include Taggable + + def self.admin_title + 'Blog Post' + end + + validates_presence_of :title, :url + validates_uniqueness_of :url + + def description + CGI.unescapeHTML(data['description'][0].to_s) + end +end diff --git a/app/models/censor_rule.rb b/app/models/censor_rule.rb index 1e05173989..a3704e9b6c 100644 --- a/app/models/censor_rule.rb +++ b/app/models/censor_rule.rb @@ -32,13 +32,13 @@ class CensorRule < ApplicationRecord ].freeze belongs_to :info_request, - :inverse_of => :censor_rules + inverse_of: :censor_rules belongs_to :user, - :inverse_of => :censor_rules + inverse_of: :censor_rules belongs_to :public_body, - :inverse_of => :censor_rules + inverse_of: :censor_rules - validate :require_valid_regexp, :if => proc { |rule| rule.regexp? == true } + validate :require_valid_regexp, if: proc { |rule| rule.regexp? == true } validates_presence_of :text, :replacement, @@ -74,15 +74,13 @@ def is_global? def expire_requests if info_request - info_request.expire + InfoRequestExpireJob.perform_later(info_request) elsif user - user.expire_requests + InfoRequestExpireJob.perform_later(user, :info_requests) elsif public_body - public_body.expire_requests + InfoRequestExpireJob.perform_later(public_body, :info_requests) else # global rule - InfoRequest.find_in_batches do |group| - group.each { |request| request.expire } - end + InfoRequestExpireJob.perform_later(InfoRequest, :all) end end @@ -111,11 +109,9 @@ def single_char_regexp end def require_valid_regexp - begin - make_regexp('UTF-8') - rescue RegexpError => e - errors.add(:text, e.message) - end + make_regexp('UTF-8') + rescue RegexpError => e + errors.add(:text, e.message) end def to_replace(encoding) diff --git a/app/models/comment.rb b/app/models/comment.rb index adc73e8d02..07b295d271 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -24,6 +24,19 @@ class Comment < ApplicationRecord include Rails.application.routes.url_helpers include LinkToHelper + DEFAULT_CREATION_RATE_LIMITS = { + 1 => 2.seconds, + 2 => 5.minutes, + 4 => 30.minutes, + 6 => 1.hour + }.freeze + + cattr_accessor :creation_rate_limits, + instance_reader: false, + instance_writer: false, + instance_accessor: false, + default: DEFAULT_CREATION_RATE_LIMITS + strip_attributes allow_empty: true belongs_to :user, @@ -41,19 +54,19 @@ class Comment < ApplicationRecord validate :check_body_has_content, :check_body_uses_mixed_capitals - scope :visible, lambda { + scope :visible, -> { joins(:info_request). merge(InfoRequest.is_searchable.except(:select)). where(visible: true) } - scope :embargoed, lambda { + scope :embargoed, -> { joins(info_request: :embargo). where('embargoes.id IS NOT NULL'). references(:embargoes) } - scope :not_embargoed, lambda { + scope :not_embargoed, -> { joins(:info_request). select('comments.*'). joins('LEFT OUTER JOIN embargoes @@ -87,6 +100,14 @@ def self.find_existing(info_request_id, body) end end + def self.exceeded_creation_rate?(comments) + comments = comments.reorder(created_at: :desc) + + creation_rate_limits.any? do |limit, duration| + comments.where(created_at: duration.ago..).size >= limit + end + end + def body ret = read_attribute(:body) return ret if ret.nil? @@ -108,12 +129,6 @@ def reindex_request_events info_request_events.find_each(&:xapian_mark_needs_index) end - def event_xapian_update - warn 'DEPRECATION: Comment#event_xapian_update will be removed in 0.42. ' \ - 'It has been replaced with Comment#reindex_request_events' - reindex_request_events - end - # Return body for display as HTML def get_body_for_html_display text = body.strip diff --git a/app/models/concerns/alaveteli_pro/request_summaries.rb b/app/models/concerns/alaveteli_pro/request_summaries.rb index 74c74ad33f..5ee8da0506 100644 --- a/app/models/concerns/alaveteli_pro/request_summaries.rb +++ b/app/models/concerns/alaveteli_pro/request_summaries.rb @@ -4,21 +4,21 @@ module RequestSummaries extend ActiveSupport::Concern included do - has_one :request_summary, :as => :summarisable, - :class_name => "AlaveteliPro::RequestSummary", - :dependent => :destroy + has_one :request_summary, as: :summarisable, + class_name: "AlaveteliPro::RequestSummary", + dependent: :destroy after_commit :create_or_update_request_summary, - :on => [:create, :update] + on: [:create, :update] end # Creates a RequestSummary item for this model on first save, or updates # the existing one otherwise. def create_or_update_request_summary - if self.should_summarise? + if should_summarise? self.request_summary = AlaveteliPro::RequestSummary.create_or_update_from(self) - elsif self.should_update_parent_summary? - parent = self.request_summary_parent + elsif should_update_parent_summary? + parent = request_summary_parent parent.create_or_update_request_summary unless parent.blank? end end diff --git a/app/models/concerns/message_prominence.rb b/app/models/concerns/message_prominence.rb index b54f8a53cf..bdca038d8d 100644 --- a/app/models/concerns/message_prominence.rb +++ b/app/models/concerns/message_prominence.rb @@ -3,7 +3,7 @@ module MessageProminence included do strip_attributes only: [:prominence_reason] - validates_inclusion_of :prominence, in: self.prominence_states + validates_inclusion_of :prominence, in: prominence_states end def indexed_by_search? diff --git a/app/models/concerns/public_body_derived_fields.rb b/app/models/concerns/public_body_derived_fields.rb index 0566c0da62..a24bc147aa 100644 --- a/app/models/concerns/public_body_derived_fields.rb +++ b/app/models/concerns/public_body_derived_fields.rb @@ -32,9 +32,7 @@ def set_first_letter unless name.blank? # we use a regex to ensure it works with utf-8/multi-byte new_first_letter = name.scan(/^./mu)[0]&.upcase - if new_first_letter != first_letter - self.first_letter = new_first_letter - end + self.first_letter = new_first_letter if new_first_letter != first_letter end end diff --git a/app/models/concerns/translatable.rb b/app/models/concerns/translatable.rb index 8278fe892a..6bd303e2d2 100644 --- a/app/models/concerns/translatable.rb +++ b/app/models/concerns/translatable.rb @@ -2,7 +2,7 @@ module Translatable extend ActiveSupport::Concern included do - accepts_nested_attributes_for :translations, :reject_if => :empty_translation_in_params? + accepts_nested_attributes_for :translations, reject_if: :empty_translation_in_params? end def find_translation_by_locale(locale) @@ -14,17 +14,15 @@ def translated_versions end def ordered_translations - translations.select do |translation| - AlaveteliLocalization.available_locales.include?(translation.locale.to_s) - end.sort_by do |translation| - AlaveteliLocalization.available_locales.index(translation.locale.to_s) - end + translations. + select { |translation| AlaveteliLocalization.available_locales.include?(translation.locale.to_s) }. + sort_by { |translation| AlaveteliLocalization.available_locales.index(translation.locale.to_s) } end def build_all_translations AlaveteliLocalization.available_locales.each do |locale| if translations.none? { |translation| translation.locale.to_s == locale } - translations.build(:locale => locale) + translations.build(locale: locale) end end end diff --git a/app/models/draft_info_request.rb b/app/models/draft_info_request.rb index bc67e78342..b5f718c3ca 100644 --- a/app/models/draft_info_request.rb +++ b/app/models/draft_info_request.rb @@ -20,19 +20,19 @@ class DraftInfoRequest < ApplicationRecord validates_presence_of :user belongs_to :user, - :inverse_of => :draft_info_requests - belongs_to :public_body, :inverse_of => :draft_info_requests + inverse_of: :draft_info_requests + belongs_to :public_body, inverse_of: :draft_info_requests strip_attributes # @see RequestSummaries#request_summary_body def request_summary_body - self.body + body end # @see RequestSummaries#request_summary_public_body_names def request_summary_public_body_names - self.public_body.name unless self.public_body.blank? + public_body.name unless public_body.blank? end # @see RequestSummaries#request_summary_categories diff --git a/app/models/foi_attachment.rb b/app/models/foi_attachment.rb index aa8edfaa7e..f67986eed4 100644 --- a/app/models/foi_attachment.rb +++ b/app/models/foi_attachment.rb @@ -31,7 +31,7 @@ class FoiAttachment < ApplicationRecord include MessageProminence belongs_to :incoming_message, - :inverse_of => :foi_attachments + inverse_of: :foi_attachments has_one_attached :file, service: :attachments @@ -39,7 +39,7 @@ class FoiAttachment < ApplicationRecord validates_presence_of :filename validates_presence_of :display_size - before_validation :ensure_filename!, :only => [:filename] + before_validation :ensure_filename!, only: [:filename] before_destroy :delete_cached_file! scope :binary, -> { where.not(content_type: AlaveteliTextMasker::TextMask) } @@ -79,7 +79,7 @@ def body(tries: 0, delay: 1) raise if tries > BODY_MAX_TRIES sleep [delay, BODY_MAX_DELAY].min - self.incoming_message.parse_raw_email!(true) + incoming_message.parse_raw_email!(true) reload body(tries: tries + 1, delay: delay * 2) @@ -158,9 +158,7 @@ def extra_note # For delivery status notification attachments, extract the status and # look up what it means in the DSN table. if @content_type == 'message/delivery-status' - if !@body.match(/Status:\s+([0-9]+\.([0-9]+\.[0-9]+))\s+/) - return "" - end + return "" unless @body.match(/Status:\s+([0-9]+\.([0-9]+\.[0-9]+))\s+/) dsn = $1 dsn_part = 'X.' + $2 @@ -171,7 +169,7 @@ def extra_note return "
DSN: " + dsn + dsn_message + "" end - return "" + "" end # Called by controller so old filenames still work @@ -181,16 +179,14 @@ def old_display_filename # Convert weird spaces (e.g. \n) to normal ones filename = filename.gsub(/\s/, " ") # Remove slashes, they mess with URLs - filename = filename.gsub(/\//, "-") - - return filename + filename.gsub(/\//, "-") end # TODO: changing this will break existing URLs, so have a care - maybe # make another old_display_filename see above def display_filename filename = self.filename - if !self.incoming_message.nil? + unless incoming_message.nil? filename = incoming_message.info_request.apply_censor_rules_to_text(filename) end # Sometimes filenames have e.g. %20 in - no point butchering that @@ -205,20 +201,16 @@ def display_filename filename = filename.gsub(/\s*\.\s*/, ".") # Compress adjacent spaces down to a single one filename = filename.gsub(/\s+/, " ") - filename = filename.strip - - return filename + filename.strip end def ensure_filename! - if self.filename.blank? - calc_ext = AlaveteliFileTypes.mimetype_to_extension(self.content_type) - if !calc_ext - calc_ext = "bin" - end - if !self.within_rfc822_subject.nil? - computed = self.within_rfc822_subject + "." + calc_ext + if filename.blank? + calc_ext = AlaveteliFileTypes.mimetype_to_extension(content_type) + calc_ext = "bin" unless calc_ext + if !within_rfc822_subject.nil? + computed = within_rfc822_subject + "." + calc_ext else computed = "attachment." + calc_ext end @@ -228,7 +220,7 @@ def ensure_filename! def filename=(filename) filename.try(:delete!, "\0") - calc_ext = AlaveteliFileTypes.mimetype_to_extension(self.content_type) + calc_ext = AlaveteliFileTypes.mimetype_to_extension(content_type) # Put right extension on if missing if !filename.nil? && !filename.match(/\.#{calc_ext}$/) && calc_ext computed = filename + "." + calc_ext @@ -240,10 +232,10 @@ def filename=(filename) # Size to show next to the download link for the attachment def update_display_size! - s = self.body.size + s = body.size if s > 1024 * 1024 - self.display_size = sprintf("%.1f", s.to_f / 1024 / 1024) + 'M' + self.display_size = format("%.1f", s.to_f / 1024 / 1024) + 'M' else self.display_size = (s / 1024).to_s + 'K' end @@ -264,7 +256,7 @@ def has_google_docs_viewer? "application/vnd.openxmlformats-officedocument.presentationml.presentation", # .pptx "application/vnd.ms-excel", # .xls - "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", # .xlsx + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" # .xlsx ].include?(content_type) end @@ -272,7 +264,7 @@ def has_google_docs_viewer? def has_body_as_html? [ "text/plain", - "application/rtf", + "application/rtf" ].include?(content_type) || has_google_docs_viewer? end @@ -292,14 +284,14 @@ def name_of_content_type 'application/vnd.openxmlformats-officedocument.presentationml.presentation' => "PowerPoint presentation", 'application/vnd.ms-excel' => "Excel spreadsheet", - 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => "Excel spreadsheet", - }[self.content_type] + 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => "Excel spreadsheet" + }[content_type] end # For "View as HTML" of attachment def body_as_html(dir, opts = {}) attachment_url = opts.fetch(:attachment_url, nil) - to_html_opts = opts.merge(:tmpdir => dir, :attachment_url => attachment_url) + to_html_opts = opts.merge(tmpdir: dir, attachment_url: attachment_url) AttachmentToHTML.to_html(self, to_html_opts) end diff --git a/app/models/holiday.rb b/app/models/holiday.rb index 964cd2f302..b1fbcd33e3 100644 --- a/app/models/holiday.rb +++ b/app/models/holiday.rb @@ -82,9 +82,7 @@ def self.due_date_from_calendar_days(start_date, days) start_date = start_date.to_date response_required_by = start_date + days - while weekend_or_holiday?(response_required_by) - response_required_by += 1 - end + response_required_by += 1 while weekend_or_holiday?(response_required_by) response_required_by end end diff --git a/app/models/holiday_import.rb b/app/models/holiday_import.rb index 3e2d739f66..782c949d01 100644 --- a/app/models/holiday_import.rb +++ b/app/models/holiday_import.rb @@ -12,9 +12,9 @@ class HolidayImport :populated validate :all_holidays_valid - validates_inclusion_of :source, :in => %w( suggestions feed ) + validates_inclusion_of :source, in: %w( suggestions feed ) validates_presence_of :ical_feed_url, - :if => proc { |holiday_import| holiday_import.source == 'feed' } + if: proc { |holiday_import| holiday_import.source == 'feed' } def initialize(opts = {}) @populated = false @@ -24,7 +24,7 @@ def initialize(opts = {}) @end_date = Date.civil(end_year, 12, 31) @source = opts.fetch(:source, 'suggestions') @ical_feed_url = opts.fetch(:ical_feed_url, nil) - @country_code = AlaveteliConfiguration::iso_country_code.downcase + @country_code = AlaveteliConfiguration.iso_country_code.downcase self.holidays_attributes = opts.fetch(:holidays_attributes, []) end @@ -38,7 +38,7 @@ def suggestions_country_name end def period - start_year == end_year ? "#{start_year}" : "#{start_year}-#{end_year}" + start_year == end_year ? start_year.to_s : "#{start_year}-#{end_year}" end def save @@ -50,7 +50,7 @@ def save! end def holidays_attributes=(incoming_data) - incoming_data.each { |offset, incoming| self.holidays << Holiday.new(incoming) } + incoming_data.each { |_offset, incoming| holidays << Holiday.new(incoming) } end def holidays @@ -60,47 +60,45 @@ def holidays private def all_holidays_valid - errors.add(:base, 'These holidays could not be imported') unless holidays.all?(&:valid?) + unless holidays.all?(&:valid?) + errors.add(:base, 'These holidays could not be imported') + end end def populate_from_ical_feed - begin - cal_file = open(ical_feed_url) - cal_parser = Icalendar::Parser.new(cal_file) - cals = cal_parser.parse - cal = cals.first - unless cal - errors.add(:ical_feed_url, "Sorry, there's a problem with the format of that feed.") - return - end - cal.events.each { |cal_event| populate_from_ical_event(cal_event) } - rescue Errno::ENOENT, Exception => e - if e.message == 'Invalid line in calendar string!' - errors.add(:ical_feed_url, "Sorry, there's a problem with the format of that feed.") - elsif e.message =~ /^No such file or directory/ - errors.add(:ical_feed_url, "Sorry we couldn't find that feed.") - else - raise e - end + cal_file = open(ical_feed_url) + cal_parser = Icalendar::Parser.new(cal_file) + cals = cal_parser.parse + cal = cals.first + unless cal + errors.add(:ical_feed_url, "Sorry, there's a problem with the format of that feed.") + return + end + cal.events.each { |cal_event| populate_from_ical_event(cal_event) } + rescue Errno::ENOENT, Exception => e + if e.message == 'Invalid line in calendar string!' + errors.add(:ical_feed_url, "Sorry, there's a problem with the format of that feed.") + elsif e.message =~ /^No such file or directory/ + errors.add(:ical_feed_url, "Sorry we couldn't find that feed.") + else + raise e end end def populate_from_ical_event(cal_event) - if cal_event.dtstart >= start_date and cal_event.dtstart <= end_date - holidays << Holiday.new(:description => cal_event.summary, - :day => cal_event.dtstart) + if (cal_event.dtstart >= start_date) && (cal_event.dtstart <= end_date) + holidays << Holiday.new(description: cal_event.summary, + day: cal_event.dtstart) end end def populate_from_suggestions - begin - holiday_info = Holidays.between(start_date, end_date, @country_code.to_sym, :observed) - holiday_info.each do |holiday_info_hash| - holidays << Holiday.new(:description => holiday_info_hash[:name], - :day => holiday_info_hash[:date]) - end - rescue Holidays::InvalidRegion - [] + holiday_info = Holidays.between(start_date, end_date, @country_code.to_sym, :observed) + holiday_info.each do |holiday_info_hash| + holidays << Holiday.new(description: holiday_info_hash[:name], + day: holiday_info_hash[:date]) end + rescue Holidays::InvalidRegion + [] end end diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 096213af00..d15d8bb950 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -41,7 +41,7 @@ class IncomingMessage < ApplicationRecord include CacheAttributesFromRawEmail include Taggable - MAX_ATTACHMENT_TEXT_CLIPPED = 1000000 # 1Mb ish + MAX_ATTACHMENT_TEXT_CLIPPED = 1_000_000 # 1Mb ish belongs_to :info_request, inverse_of: :incoming_messages, @@ -52,10 +52,10 @@ class IncomingMessage < ApplicationRecord validates_presence_of :raw_email has_many :outgoing_message_followups, - :inverse_of => :incoming_message_followup, - :foreign_key => 'incoming_message_followup_id', - :class_name => 'OutgoingMessage', - :dependent => :nullify + inverse_of: :incoming_message_followup, + foreign_key: 'incoming_message_followup_id', + class_name: 'OutgoingMessage', + dependent: :nullify has_many :foi_attachments, -> { order(:id) }, inverse_of: :incoming_message, @@ -63,12 +63,12 @@ class IncomingMessage < ApplicationRecord autosave: true # never really has many info_request_events, but could in theory has_many :info_request_events, - :dependent => :destroy, - :inverse_of => :incoming_message + dependent: :destroy, + inverse_of: :incoming_message belongs_to :raw_email, - :inverse_of => :incoming_message, - :dependent => :destroy + inverse_of: :incoming_message, + dependent: :destroy after_destroy :update_request after_update :update_request @@ -95,10 +95,8 @@ def parse_raw_email!(force = nil) # The following fields may be absent; we treat them as cached # values in case we want to regenerate them (due to mail # parsing bugs, etc). - if self.raw_email.nil? - raise "Incoming message id=#{id} has no raw_email" - end - if (!force.nil? || self.last_parsed.nil?) + raise "Incoming message id=#{id} has no raw_email" if raw_email.nil? + if !force.nil? || last_parsed.nil? ActiveRecord::Base.transaction do extract_attachments self.sent_at = raw_email.date || created_at @@ -108,18 +106,12 @@ def parse_raw_email!(force = nil) self.from_email_domain = raw_email.from_email_domain || '' self.valid_to_reply_to = raw_email.valid_to_reply_to? self.last_parsed = Time.zone.now - self.save! + save! end end end - alias_method :valid_to_reply_to?, :valid_to_reply_to - - def mail_from - warn %q([DEPRECATION] IncomingMessage#mail_from will be removed in 0.42. It - has been replaced by IncomingMessage#from_name).squish - from_name - end + alias valid_to_reply_to? valid_to_reply_to # Public: The display name of the email sender with the associated # InfoRequest's censor rules applied. @@ -135,23 +127,10 @@ def mail_from # # => FOI [REDACTED] # # Returns a String - def safe_mail_from - warn %q([DEPRECATION] IncomingMessage#safe_mail_from will be removed in - 0.42. It has been replaced by IncomingMessage#safe_from_name).squish - safe_from_name - end - def safe_from_name info_request.apply_censor_rules_to_text(from_name) if from_name end - def mail_from_domain - warn %q([DEPRECATION] IncomingMessage#mail_from_domain will be removed in - 0.42. It has been replaced by - IncomingMessage#from_email_domain).squish - from_email_domain - end - def specific_from_name? !safe_from_name.nil? && safe_from_name.strip != info_request.public_body.name.strip end @@ -188,11 +167,7 @@ def self.get_attachment_by_url_part_number_and_filename(attachments, found_url_p attachments_by_filename = attachments.select { |a| a.display_filename == display_filename } - if attachments_by_filename.length == 1 - attachments_by_filename[0] - else - nil - end + attachments_by_filename[0] if attachments_by_filename.length == 1 end end @@ -222,16 +197,16 @@ def self.get_attachment_by_url_part_number_and_filename!( end def apply_masks(text, content_type) - mask_options = { :censor_rules => info_request.applicable_censor_rules, - :masks => info_request.masks } + mask_options = { censor_rules: info_request.applicable_censor_rules, + masks: info_request.masks } AlaveteliTextMasker.apply_masks(text, content_type, mask_options) end # Lotus notes quoting yeuch! def remove_lotus_quoting(text, replacement = "FOLDED_QUOTED_SECTION") text = text.dup - return text if self.info_request.user_name.nil? - name = Regexp.escape(self.info_request.user_name) + return text if info_request.user_name.nil? + name = Regexp.escape(info_request.user_name) # To end of message sections text.gsub!(/^\s?#{name}[^\n]+\n([^\n]+\n)?\s?Sent by:[^\n]+\n.*/im, "\n\n" + replacement) @@ -241,11 +216,7 @@ def remove_lotus_quoting(text, replacement = "FOLDED_QUOTED_SECTION") # http://www.whatdotheyknow.com/request/229/response/809 - text.gsub!(/^\s?From: [^\n]+\n\s?Sent: [^\n]+\n\s?To:\s+['"]?#{name}['"]?\n\s?Subject:.*/im, "\n\n" + replacement) - - - return text - + text.gsub(/^\s?From: [^\n]+\n\s?Sent: [^\n]+\n\s?To:\s+['"]?#{name}['"]?\n\s?Subject:.*/im, "\n\n" + replacement) end @@ -264,7 +235,7 @@ def self.remove_quoted_sections(text, replacement = "FOLDED_QUOTED_SECTION") # http://www.whatdotheyknow.com/request/71/response/108 # http://www.whatdotheyknow.com/request/police_powers_to_inform_car_insu # http://www.whatdotheyknow.com/request/secured_convictions_aided_by_cct - multiline_original_message = '(' + '''>>>.* \d\d/\d\d/\d\d\d\d\s+\d\d:\d\d(?::\d\d)?\s*>>>''' + ')' + multiline_original_message = '(>>>.* \d\d/\d\d/\d\d\d\d\s+\d\d:\d\d(?::\d\d)?\s*>>>)' text.gsub!(/^(#{multiline_original_message}\n.*)$/m, replacement) # On Thu, Nov 28, 2013 at 9:08 AM, A User @@ -307,12 +278,13 @@ def self.remove_quoted_sections(text, replacement = "FOLDED_QUOTED_SECTION") # http://www.whatdotheyknow.com/request/123/response/192 # http://www.whatdotheyknow.com/request/235/response/513 # http://www.whatdotheyknow.com/request/445/response/743 - original_message = - '(' + '''----* This is a copy of the message, including all the headers. ----*''' + - '|' + '''----*\s*Original Message\s*----*''' + - '|' + '''----*\s*Forwarded message.+----*''' + - '|' + '''----*\s*Forwarded by.+----*''' + - ')' + message_section_strings = [ + '----* This is a copy of the message, including all the headers. ----*', + '----*\s*Original Message\s*----*', + '----*\s*Forwarded message.+----*', + '----*\s*Forwarded by.+----*' + ] + original_message = "(#{message_section_strings.join('|')})" # Could have a ^ at start here, but see messed up formatting here: # http://www.whatdotheyknow.com/request/refuse_and_recycling_collection#incoming-842 text.gsub!(/(#{original_message}\n.*)$/mi, replacement) @@ -321,9 +293,7 @@ def self.remove_quoted_sections(text, replacement = "FOLDED_QUOTED_SECTION") # Some silly Microsoft XML gets into parts marked as plain text. # e.g. http://www.whatdotheyknow.com/request/are_traffic_wardens_paid_commiss#incoming-401 # Don't replace with "replacement" as it's pretty messy - text.gsub!(/<\?xml:namespace[^>]*\/>/, " ") - - return text + text.gsub(/<\?xml:namespace[^>]*\/>/, " ") end # Removes anything cached about the object in the database, and saves @@ -331,19 +301,19 @@ def clear_in_database_caches! self.cached_attachment_text_clipped = nil self.cached_main_body_text_unfolded = nil self.cached_main_body_text_folded = nil - self.save! + save! end # Internal function to cache two sorts of main body text. # Cached as loading raw_email can be quite huge, and need this for just # search results def _cache_main_body_text - text = self.get_main_body_text_internal + text = get_main_body_text_internal # Strip the uudecode parts from main text # - this also effectively does a .dup as well, so text mods don't alter original text = text.split(/^begin.+^`\n^end\n/m).join(" ") - if text.size > 1000000 # 1 MB ish + if text.size > 1_000_000 # 1 MB ish raise "main body text more than 1 MB, need to implement clipping like for attachment text, or there is some other MIME decoding problem or similar" end @@ -351,34 +321,30 @@ def _cache_main_body_text text = apply_masks(text, 'text/html') # Remove existing quoted sections - folded_quoted_text = self.remove_lotus_quoting(text, 'FOLDED_QUOTED_SECTION') + folded_quoted_text = remove_lotus_quoting(text, 'FOLDED_QUOTED_SECTION') folded_quoted_text = IncomingMessage.remove_quoted_sections(folded_quoted_text, "FOLDED_QUOTED_SECTION") self.cached_main_body_text_unfolded = text.delete("\0") self.cached_main_body_text_folded = folded_quoted_text.delete("\0") - self.save! + save! end # Returns body text from main text part of email, converted to UTF-8, with uudecode removed, # emails and privacy sensitive things remove, censored, and folded to remove excess quoted text # (marked with FOLDED_QUOTED_SECTION) # TODO: returns a .dup of the text, so calling functions can in place modify it def get_main_body_text_folded - if self.cached_main_body_text_folded.nil? - self._cache_main_body_text - end - return self.cached_main_body_text_folded + _cache_main_body_text if cached_main_body_text_folded.nil? + cached_main_body_text_folded end def get_main_body_text_unfolded - if self.cached_main_body_text_unfolded.nil? - self._cache_main_body_text - end - return self.cached_main_body_text_unfolded + _cache_main_body_text if cached_main_body_text_unfolded.nil? + cached_main_body_text_unfolded end # Returns body text from main text part of email, converted to UTF-8 def get_main_body_text_internal parse_raw_email! main_part = get_main_body_text_part - return _convert_part_body_to_text(main_part) + _convert_part_body_to_text(main_part) end # Given a main text part, converts it to text @@ -408,16 +374,14 @@ def _convert_part_body_to_text(part) # Compress extra spaces down to save space, and to stop regular expressions # breaking in strange extreme cases. e.g. for # http://www.whatdotheyknow.com/request/spending_on_consultants - text = text.gsub(/ +/, " ") - - return text + text.gsub(/ +/, " ") end # Returns part which contains main body text, or nil if there isn't one, # from a set of foi_attachments. If the leaves parameter is empty or not # supplied, uses its own foi_attachments. def get_main_body_text_part(leaves=[]) - leaves = self.foi_attachments if leaves.empty? + leaves = foi_attachments if leaves.empty? # Find first part which is text/plain or text/html # (We have to include HTML, as increasingly there are mail clients that @@ -425,16 +389,14 @@ def get_main_body_text_part(leaves=[]) # instead use the first text attachment # e.g. http://www.whatdotheyknow.com/request/list_of_public_authorties) leaves.each do |p| - if p.content_type == 'text/plain' or p.content_type == 'text/html' + if (p.content_type == 'text/plain') || (p.content_type == 'text/html') return p end end # Otherwise first part which is any sort of text leaves.each do |p| - if p.content_type.match(/^text/) - return p - end + return p if p.content_type.match(/^text/) end # ... or if none, consider first part @@ -449,7 +411,7 @@ def get_main_body_text_part(leaves=[]) # like binary/octet-stream, or the like, which are really text - TODO: if # you find an example, put URL here - perhaps we should be always returning # nil in this case) - return p + p end # Returns attachments that are uuencoded in main body part @@ -485,10 +447,10 @@ def get_attachments_for_display # return what user would consider attachments, i.e. not the main body main_part = get_main_body_text_part attachments = [] - for attachment in self.foi_attachments + foi_attachments.each do |attachment| attachments << attachment if attachment != main_part end - return attachments + attachments end def extract_attachments! @@ -540,12 +502,10 @@ def get_body_for_html_display(collapse_quoted_sections = true) # links, without escaping them. Rather than using some proper parser # making a tree structure (I don't know of one that is to hand, that # works well in this kind of situation, such as with regexps). - if collapse_quoted_sections - text = folded_quoted_text - end + text = folded_quoted_text if collapse_quoted_sections text = MySociety::Format.simplify_angle_bracketed_urls(text) text = CGI.escapeHTML(text) - text = MySociety::Format.make_clickable(text, :contract => 1) + text = MySociety::Format.make_clickable(text, contract: 1) # add a helpful link to email addresses and mobile numbers removed # by apply_masks @@ -559,14 +519,12 @@ def get_body_for_html_display(collapse_quoted_sections = true) text.strip! # if there is nothing but quoted stuff, then show the subject if text == "FOLDED_QUOTED_SECTION" - text = "[Subject only] " + CGI.escapeHTML(self.subject || '') + text + text = "[Subject only] " + CGI.escapeHTML(subject || '') + text end # and display link for quoted stuff - text = text.gsub(/FOLDED_QUOTED_SECTION/, "\n\n" + ''+_("show quoted sections")+'' + "\n\n") - else - if folded_quoted_text.include?('FOLDED_QUOTED_SECTION') - text = text + "\n\n" + ''+_("hide quoted sections")+'' - end + text = text.gsub(/FOLDED_QUOTED_SECTION/, "\n\n" + ''+_("show quoted sections")+'' + "\n\n") + elsif folded_quoted_text.include?('FOLDED_QUOTED_SECTION') + text = text + "\n\n" + ''+_("hide quoted sections")+'' end text.strip! @@ -586,41 +544,41 @@ def get_body_for_quoting text.gsub!("FOLDED_QUOTED_SECTION", " ") text.strip! raise "internal error" if text.nil? - return text + text end # Returns text version of attachment text def get_attachment_text_full - text = self._get_attachment_text_internal + text = _get_attachment_text_internal text = apply_masks(text, 'text/html') # This can be useful for memory debugging #STDOUT.puts 'xxx '+ MySociety::DebugHelpers::allocated_string_size_around_gc # Save clipped version for snippets - if self.cached_attachment_text_clipped.nil? + if cached_attachment_text_clipped.nil? clipped = text.mb_chars[0..MAX_ATTACHMENT_TEXT_CLIPPED].delete("\0") self.cached_attachment_text_clipped = clipped save! end - return text + text end # Returns a version reduced to a sensible maximum size - this # is for performance reasons when showing snippets in search results. def get_attachment_text_clipped - if self.cached_attachment_text_clipped.nil? + if cached_attachment_text_clipped.nil? # As side effect, get_attachment_text_full makes snippet text - attachment_text = self.get_attachment_text_full - raise "internal error" if self.cached_attachment_text_clipped.nil? + attachment_text = get_attachment_text_full + raise "internal error" if cached_attachment_text_clipped.nil? end - return self.cached_attachment_text_clipped + cached_attachment_text_clipped end def _extract_text # Extract text from each attachment - self.get_attachments_for_display.reduce('') { |memo, attachment| + get_attachments_for_display.reduce('') { |memo, attachment| return memo if Ability.guest.cannot?(:read, attachment) memo += MailHandler.get_attachment_text_one_file(attachment.content_type, @@ -635,23 +593,25 @@ def _get_attachment_text_internal # Returns text for indexing def get_text_for_indexing_full - return get_body_for_indexing + "\n\n" + get_attachment_text_full + get_body_for_indexing + "\n\n" + get_attachment_text_full end # Used for excerpts in search results, when loading full text would be too slow def get_text_for_indexing_clipped - return get_body_for_indexing + "\n\n" + get_attachment_text_clipped + get_body_for_indexing + "\n\n" + get_attachment_text_clipped end # Has message arrived "recently"? def recently_arrived - (Time.zone.now - self.created_at) <= 3.days + (Time.zone.now - created_at) <= 3.days end # Search all info requests for def self.find_all_unknown_mime_types IncomingMessage.find_each do |incoming_message| - for attachment in incoming_message.get_attachments_for_display - raise "internal error incoming_message " + incoming_message.id.to_s if attachment.content_type.nil? + incoming_message.get_attachments_for_display.each do |attachment| + if attachment.content_type.nil? + raise "internal error incoming_message " + incoming_message.id.to_s + end if AlaveteliFileTypes.mimetype_to_extension(attachment.content_type).nil? $stderr.puts "Unknown type for /request/" + incoming_message.info_request.id.to_s + "#incoming-"+incoming_message.id.to_s $stderr.puts " " + attachment.filename.to_s + " " + attachment.content_type.to_s @@ -659,19 +619,21 @@ def self.find_all_unknown_mime_types end end - return nil + nil end # Returns space separated list of file extensions of attachments to this message. Defaults to # the normal extension for known mime type, otherwise uses other extensions. def get_present_file_extensions ret = {} - for attachment in self.get_attachments_for_display + get_attachments_for_display.each do |attachment| ext = AlaveteliFileTypes.mimetype_to_extension(attachment.content_type) - ext = File.extname(attachment.filename).gsub(/^[.]/, "") if ext.nil? && !attachment.filename.nil? - ret[ext] = 1 if !ext.nil? + if ext.nil? && !attachment.filename.nil? + ext = File.extname(attachment.filename).gsub(/^[.]/, "") + end + ret[ext] = 1 unless ext.nil? end - return ret.keys.join(" ") + ret.keys.join(" ") end def refusals diff --git a/app/models/info_request.rb b/app/models/info_request.rb index d54b029f82..b64c356986 100644 --- a/app/models/info_request.rb +++ b/app/models/info_request.rb @@ -46,6 +46,7 @@ class InfoRequest < ApplicationRecord include Rails.application.routes.url_helpers include AlaveteliPro::RequestSummaries include AlaveteliFeatures::Helpers + include InfoRequest::BatchPagination include InfoRequest::PublicToken include InfoRequest::Sluggable include InfoRequest::TitleValidation @@ -59,46 +60,46 @@ def self.admin_title 'Request' end - strip_attributes :allow_empty => true - strip_attributes :only => [:title], - :replace_newlines => true, :collapse_spaces => true + strip_attributes allow_empty: true + strip_attributes only: [:title], + replace_newlines: true, collapse_spaces: true belongs_to :user, - :inverse_of => :info_requests, - :counter_cache => true + inverse_of: :info_requests, + counter_cache: true validate :must_be_internal_or_external belongs_to :public_body, - :inverse_of => :info_requests, - :counter_cache => true + inverse_of: :info_requests, + counter_cache: true belongs_to :info_request_batch, - :inverse_of => :info_requests + inverse_of: :info_requests validates_presence_of :public_body, message: N_("Please select an authority") has_many :info_request_events, -> { order(:created_at, :id) }, - :inverse_of => :info_request, - :dependent => :destroy + inverse_of: :info_request, + dependent: :destroy has_many :outgoing_messages, -> { order(:created_at) }, - :inverse_of => :info_request, - :dependent => :destroy + inverse_of: :info_request, + dependent: :destroy has_many :incoming_messages, -> { order(:created_at) }, - :inverse_of => :info_request, - :dependent => :destroy + inverse_of: :info_request, + dependent: :destroy has_many :user_info_request_sent_alerts, - :inverse_of => :info_request, - :dependent => :destroy + inverse_of: :info_request, + dependent: :destroy has_many :track_things, -> { order(created_at: :desc) }, - :inverse_of => :info_request, - :dependent => :destroy + inverse_of: :info_request, + dependent: :destroy has_many :widget_votes, - :inverse_of => :info_request, - :dependent => :destroy + inverse_of: :info_request, + dependent: :destroy has_many :citations, -> (info_request) { unscope(:where).for_request(info_request) }, as: :citable, @@ -106,20 +107,20 @@ def self.admin_title dependent: :destroy has_many :comments, -> { order(:created_at) }, - :inverse_of => :info_request, - :dependent => :destroy + inverse_of: :info_request, + dependent: :destroy has_many :censor_rules, -> { order(created_at: :desc) }, - :inverse_of => :info_request, - :dependent => :destroy + inverse_of: :info_request, + dependent: :destroy has_many :mail_server_logs, -> { order(:mail_server_log_done_id, :order) }, - :inverse_of => :info_request, - :dependent => :destroy + inverse_of: :info_request, + dependent: :destroy has_one :embargo, - :inverse_of => :info_request, - :class_name => 'AlaveteliPro::Embargo', - :dependent => :destroy + inverse_of: :info_request, + class_name: 'AlaveteliPro::Embargo', + dependent: :destroy has_many :foi_attachments, through: :incoming_messages @@ -159,25 +160,25 @@ def self.admin_title scope :surveyable, Survey::InfoRequestQuery.new class << self - alias_method :in_progress, :awaiting_response + alias in_progress awaiting_response end scope :action_needed, State::ActionNeededQuery.new scope :updated_before, ->(ts) { where('"info_requests"."updated_at" < ?', ts) } # user described state (also update in info_request_event, admin_request/edit.rhtml) validate :must_be_valid_state - validates_inclusion_of :prominence, :in => Prominence::VALUES + validates_inclusion_of :prominence, in: Prominence::VALUES validates_inclusion_of :law_used, in: Legislation.keys # who can send new responses - validates_inclusion_of :allow_new_responses_from, :in => [ + validates_inclusion_of :allow_new_responses_from, in: [ 'anybody', # anyone who knows the request email address 'authority_only', # only people from authority domains 'nobody' ] # what to do with refused new responses - validates_inclusion_of :handle_rejected_responses, :in => [ + validates_inclusion_of :handle_rejected_responses, in: [ 'bounce', # return them to sender 'holding_pen', # put them in the holding pen 'blackhole' # just dump them @@ -221,11 +222,11 @@ def self.matching_incoming_email(emails) # Subset of states accepted via the API def self.allowed_incoming_states - [ - 'waiting_response', - 'rejected', - 'successful', - 'partially_successful' + %w[ + waiting_response + rejected + successful + partially_successful ] end @@ -242,9 +243,7 @@ def self.custom_states_loaded def self.guess_by_incoming_email(*emails) guesses = emails.flatten.reduce([]) do |memo, email| id, idhash = _extract_id_hash_from_email(email) - if idhash.nil? || id.nil? - id, idhash = _guess_idhash_from_email(email) - end + id, idhash = _guess_idhash_from_email(email) if idhash.nil? || id.nil? memo << Guess.new(find_by_id(id), email, :id) memo << Guess.new(find_by_idhash(idhash), email, :idhash) end @@ -265,9 +264,7 @@ def self._guess_idhash_from_email(incoming_email) # try to grab the last 8 chars of the local part of the address instead local_part = incoming_email[0..incoming_email.index('@')-1] id_hash = - if local_part.length >= 8 - _clean_idhash(local_part[-8..-1]) - end + (_clean_idhash(local_part[-8..-1]) if local_part.length >= 8) end [id, id_hash] @@ -362,19 +359,19 @@ def self.holding_pen_request ir = InfoRequest.find_by_url_title("holding_pen") if ir.nil? ir = InfoRequest.new( - :user => User.internal_admin_user, - :public_body => PublicBody.internal_admin_body, - :title => 'Holding pen', - :described_state => 'waiting_response', - :awaiting_description => false, - :prominence => 'hidden' + user: User.internal_admin_user, + public_body: PublicBody.internal_admin_body, + title: 'Holding pen', + described_state: 'waiting_response', + awaiting_description: false, + prominence: 'hidden' ) om = OutgoingMessage.new({ - :status => 'ready', - :message_type => 'initial_request', - :body => 'This is the holding pen request. It shows responses that were sent to invalid addresses, and need moving to the correct request by an adminstrator.', - :last_sent_at => Time.zone.now, - :what_doing => 'normal_sort' + status: 'ready', + message_type: 'initial_request', + body: 'This is the holding pen request. It shows responses that were sent to invalid addresses, and need moving to the correct request by an adminstrator.', + last_sent_at: Time.zone.now, + what_doing: 'normal_sort' }) ir.outgoing_messages << om @@ -416,31 +413,31 @@ def self.get_status_description(status) 'vexatious' => _("Considered by administrators as " \ "vexatious."), 'not_foi' => _("Considered by administrators as " \ - "not an FOI request."), + "not an FOI request.") } if descriptions[status] descriptions[status] elsif respond_to?(:theme_display_status) theme_display_status(status) else - raise _("unknown status {{status}}", :status => status) + raise _("unknown status {{status}}", status: status) end end def self.magic_email_for_id(prefix_part, id) - magic_email = AlaveteliConfiguration::incoming_email_prefix + magic_email = AlaveteliConfiguration.incoming_email_prefix magic_email += prefix_part + id.to_s magic_email += "-" + InfoRequest.hash_from_id(id) - magic_email += "@" + AlaveteliConfiguration::incoming_email_domain + magic_email += "@" + AlaveteliConfiguration.incoming_email_domain magic_email end def self.build_from_attributes(info_request_atts, outgoing_message_atts, user=nil) info_request = new(info_request_atts) default_message_params = { - :status => 'ready', - :message_type => 'initial_request', - :what_doing => 'normal_sort' + status: 'ready', + message_type: 'initial_request', + what_doing: 'normal_sort' } attrs = outgoing_message_atts.merge(default_message_params) @@ -457,31 +454,33 @@ def self.build_from_attributes(info_request_atts, outgoing_message_atts, user=ni end def self.from_draft(draft) - info_request = new(:title => draft.title, - :user => draft.user, - :public_body => draft.public_body) - info_request.outgoing_messages.new(:body => draft.body, - :status => 'ready', - :message_type => 'initial_request', - :what_doing => 'normal_sort', - :info_request => info_request) + info_request = new(title: draft.title, + user: draft.user, + public_body: draft.public_body) + info_request.outgoing_messages.new(body: draft.body, + status: 'ready', + message_type: 'initial_request', + what_doing: 'normal_sort', + info_request: info_request) if draft.embargo_duration info_request.embargo = AlaveteliPro::Embargo.new( - :embargo_duration => draft.embargo_duration, - :info_request => info_request + embargo_duration: draft.embargo_duration, + info_request: info_request ) end info_request end def self.hash_from_id(id) - Digest::SHA1.hexdigest(id.to_s + AlaveteliConfiguration::incoming_email_secret)[0,8] + Digest::SHA1.hexdigest(id.to_s + AlaveteliConfiguration.incoming_email_secret)[0,8] end # Used to find when event last changed def self.last_event_time_clause(event_type=nil, join_table=nil, join_clause=nil) event_type_clause = '' - event_type_clause = " AND info_request_events.event_type = '#{event_type}'" if event_type + if event_type + event_type_clause = " AND info_request_events.event_type = '#{event_type}'" + end tables = ['info_request_events'] tables << join_table if join_table join_clause = "AND #{join_clause}" if join_clause @@ -510,7 +509,7 @@ def self.where_old_unclassified(age_in_days=nil) end def self.download_zip_dir - File.join(Rails.root, "cache", "zips", "#{Rails.env}") + File.join(Rails.root, "cache", "zips", Rails.env) end def self.reject_incoming_at_mta(options) @@ -527,22 +526,27 @@ def self.reject_incoming_at_mta(options) if options[:dryrun] 0 else - query.update_all(:reject_incoming_at_mta => true) + query.update_all(reject_incoming_at_mta: true) end end + def self.requests_old_after_months + AlaveteliConfiguration.restrict_new_responses_on_old_requests_after_months + end + + def self.requests_very_old_after_months + requests_old_after_months * 4 + end + # This is called from cron regularly. def self.stop_new_responses_on_old_requests - old = AlaveteliConfiguration.restrict_new_responses_on_old_requests_after_months - very_old = old * 4 - # 'old' months since last change to request, only allow new incoming # messages from authority domains InfoRequest .been_published .where(allow_new_responses_from: 'anybody') .where.not(url_title: 'holding_pen') - .updated_before(old.months.ago.to_date) + .updated_before(requests_old_after_months.months.ago.to_date) .find_in_batches do |batch| batch.each do |info_request| old_allow_new_responses_from = info_request.allow_new_responses_from @@ -565,7 +569,7 @@ def self.stop_new_responses_on_old_requests .been_published .where(allow_new_responses_from: %w[anybody authority_only]) .where.not(url_title: 'holding_pen') - .updated_before(very_old.months.ago.to_date) + .updated_before(requests_very_old_after_months.months.ago.to_date) .find_in_batches do |batch| batch.each do |info_request| old_allow_new_responses_from = info_request.allow_new_responses_from @@ -586,17 +590,17 @@ def self.stop_new_responses_on_old_requests def self.request_list(filters, page, per_page, max_results) query = InfoRequestEvent.make_query_from_params(filters) search_options = { - :limit => 25, - :offset => (page - 1) * per_page, - :collapse_by_prefix => 'request_collapse' } + limit: 25, + offset: (page - 1) * per_page, + collapse_by_prefix: 'request_collapse' } xapian_object = search_events(query, search_options) list_results = xapian_object.results.map { |r| r[:model] } matches_estimated = xapian_object.matches_estimated show_no_more_than = [matches_estimated, max_results].min - return { :results => list_results, - :matches_estimated => matches_estimated, - :show_no_more_than => show_no_more_than } + { results: list_results, + matches_estimated: matches_estimated, + show_no_more_than: show_no_more_than } end def self.recent_requests @@ -607,8 +611,8 @@ def self.recent_requests query = 'variety:response (status:successful OR status:partially_successful)' max_count = 5 search_options = { - :limit => max_count, - :collapse_by_prefix => 'request_title_collapse' } + limit: max_count, + collapse_by_prefix: 'request_title_collapse' } xapian_object = search_events(query, search_options) xapian_object.results @@ -636,7 +640,7 @@ def self.recent_requests end def self.find_in_state(state) - where(:described_state => state). + where(described_state: state). order(:last_event_time) end @@ -673,7 +677,7 @@ def self.log_overdue_event_type(event_type) Time.zone.today, event_type]) - query.find_each(:batch_size => 100) do |info_request| + query.find_each(batch_size: 100) do |info_request| # Date to DateTime representing beginning of day created_at = info_request.send(date_field).beginning_of_day + 1.day event = info_request.log_event( @@ -681,9 +685,7 @@ def self.log_overdue_event_type(event_type) { event_created_at: Time.zone.now }, created_at: created_at ) - if info_request.use_notifications? - info_request.user.notify(event) - end + info_request.user.notify(event) if info_request.use_notifications? end end @@ -720,12 +722,12 @@ def prominence(opts = {}) # opts = Hash of options (default: {}) # Returns a StateCalculator - def state(opts = {}) + def state(_opts = {}) State::Calculator.new(self) end def indexed_by_search? - prominence(:decorate => true).is_searchable? + prominence(decorate: true).is_searchable? end # The request must either be internal, in which case it has @@ -739,8 +741,12 @@ def must_be_internal_or_external # We must permit user_id and external_user_name both to be nil, because the system # allows a request to be created by a non-logged-in user. if user_id - errors.add(:external_user_name, "must be null for an internal request") unless external_user_name.nil? - errors.add(:external_url, "must be null for an internal request") unless external_url.nil? + unless external_user_name.nil? + errors.add(:external_user_name, "must be null for an internal request") + end + unless external_url.nil? + errors.add(:external_url, "must be null for an internal request") + end end end @@ -766,7 +772,7 @@ def user_name_slug end def user_json_for_api - is_external? ? { :name => user_name || _("Anonymous user") } : user.json_for_api + is_external? ? { name: user_name || _("Anonymous user") } : user.json_for_api end @@custom_states_loaded = false @@ -782,7 +788,7 @@ def reindex_request_events end # Force reindex when tag string changes - alias_method :orig_tag_string=, :tag_string= + alias orig_tag_string= tag_string= def tag_string=(tag_string) ret = self.orig_tag_string=(tag_string) reindex_request_events @@ -807,9 +813,7 @@ def expire(options={}) # Removes anything cached about the object in the database, and saves def clear_in_database_caches! - for incoming_message in incoming_messages - incoming_message.clear_in_database_caches! - end + incoming_messages.each(&:clear_in_database_caches!) end def update_last_public_response_at @@ -826,9 +830,7 @@ def update_last_public_response_at # Needed for legacy reasons, even though we call strip_attributes now def title _title = read_attribute(:title) - if _title - _title.strip! - end + _title.strip! if _title _title end @@ -855,13 +857,11 @@ def email_subject_followup(opts = {}) incoming_message = opts.fetch(:incoming_message, nil) html = opts.fetch(:html, true) if incoming_message.nil? || !incoming_message.valid_to_reply_to? || !incoming_message.subject - 'Re: ' + email_subject_request(:html => html) + 'Re: ' + email_subject_request(html: html) + elsif incoming_message.subject.match(/^Re:/i) + incoming_message.subject else - if incoming_message.subject.match(/^Re:/i) - incoming_message.subject - else - 'Re: ' + incoming_message.subject - end + 'Re: ' + incoming_message.subject end end @@ -875,25 +875,21 @@ def find_existing_outgoing_message(body) end # Has this email already been received here? Based just on message id. - def already_received?(email, raw_email_data) + def already_received?(email, _raw_email_data) message_id = email.message_id - if message_id.nil? - raise "No message id for this message" - end + raise "No message id for this message" if message_id.nil? - for im in incoming_messages - if message_id == im.message_id - return true - end + incoming_messages.each do |im| + return true if message_id == im.message_id end false end def receive(email, raw_email_data, *args) - defaults = { :override_stop_new_responses => false, - :rejected_reason => nil, - :source => :internal } + defaults = { override_stop_new_responses: false, + rejected_reason: nil, + source: :internal } opts = if args.first.is_a?(Hash) defaults.merge(args.shift) @@ -1028,7 +1024,7 @@ def base_calculate_status Time.zone.now.strftime("%Y-%m-%d") > date_very_overdue_after.strftime("%Y-%m-%d") return 'waiting_response_overdue' if Time.zone.now.strftime("%Y-%m-%d") > date_response_required_by.strftime("%Y-%m-%d") - return 'waiting_response' + 'waiting_response' end # 'described_state' can be populated on any info_request_event but is only @@ -1048,12 +1044,10 @@ def base_calculate_status # of the info_request. def calculate_event_states curr_state = nil - for event in info_request_events.reverse + info_request_events.reverse.each do |event| event.xapian_mark_needs_index # we need to reindex all events in order to update their latest_* terms if curr_state.nil? - if event.described_state - curr_state = event.described_state - end + curr_state = event.described_state if event.described_state end if curr_state && event.event_type == 'response' @@ -1076,7 +1070,7 @@ def calculate_event_states # as that might already be set to waiting_clarification / a # success status, which we want to know about. curr_state = nil - elsif curr_state && (['edit', 'status_update'].include? event.event_type) + elsif curr_state && (%w[edit status_update].include? event.event_type) # A status update or edit event should get the same calculated state as described state # so that the described state is always indexed (and will be the latest_status # for the request immediately after it has been described, regardless of what @@ -1142,7 +1136,7 @@ def calculate_last_event_forming_initial_request # Log an event to the history of some things that have happened to this request def log_event(type, params, options = {}) - event = info_request_events.create!(:event_type => type, :params => params) + event = info_request_events.create!(event_type: type, params: params) set_due_dates(event) if event.resets_due_dates? if options[:created_at] event.update_column(:created_at, options[:created_at]) @@ -1211,14 +1205,14 @@ def calculate_date_very_overdue_after def last_embargo_set_event info_request_events. - where(:event_type => 'set_embargo'). + where(event_type: 'set_embargo'). reorder(created_at: :desc). first end def last_embargo_expire_event info_request_events. - where(:event_type => 'expire_embargo'). + where(event_type: 'expire_embargo'). reorder(created_at: :desc). first end @@ -1264,7 +1258,9 @@ def get_last_public_response_event end def get_last_public_response - get_last_public_response_event.incoming_message if get_last_public_response_event + if get_last_public_response_event + get_last_public_response_event.incoming_message + end end def public_outgoing_events @@ -1279,7 +1275,7 @@ def get_last_public_outgoing_event # Text from the the initial request, for use in summary display def initial_request_text return '' if outgoing_messages.empty? - body_opts = { :censor_rules => applicable_censor_rules } + body_opts = { censor_rules: applicable_censor_rules } first_message = outgoing_messages.first first_message.is_public? ? first_message.get_text_for_indexing(true, body_opts) : '' end @@ -1314,11 +1310,9 @@ def last_update_hash # Get previous email sent to def get_previous_email_sent_to(info_request_event) last_email = nil - for e in info_request_events + info_request_events.each do |e| if ((info_request_event.is_sent_sort? && e.is_sent_sort?) || (info_request_event.is_followup_sort? && e.is_followup_sort?)) && e.outgoing_message_id == info_request_event.outgoing_message_id - if e.id == info_request_event.id - break - end + break if e.id == info_request_event.id last_email = e.params[:email] end end @@ -1332,7 +1326,7 @@ def display_status(cached_value_ok=false) # Called by incoming_email - and used to be called to generate separate # envelope from address until we abandoned it. def magic_email(prefix_part) - raise "id required to create a magic email" if not id + raise "id required to create a magic email" unless id InfoRequest.magic_email_for_id(prefix_part, id) end @@ -1371,7 +1365,7 @@ def is_followupable?(incoming_message) end def postal_email - if who_can_followup_to.size == 0 + if who_can_followup_to.empty? public_body.request_email else who_can_followup_to[-1][1] @@ -1379,7 +1373,7 @@ def postal_email end def postal_email_name - if who_can_followup_to.size == 0 + if who_can_followup_to.empty? public_body.name else who_can_followup_to[-1][0] @@ -1444,29 +1438,27 @@ def who_can_followup_to(skip_message = nil) ret = [] done = {} if skip_message - if email = OutgoingMailer.email_for_followup(self, skip_message) + if (email = OutgoingMailer.email_for_followup(self, skip_message)) done[email.downcase] = 1 end end - for incoming_message in incoming_messages.reverse - if incoming_message == skip_message - next - end + incoming_messages.reverse.each do |incoming_message| + next if incoming_message == skip_message incoming_message.safe_from_name - next if ! incoming_message.is_public? + next unless incoming_message.is_public? email = OutgoingMailer.email_for_followup(self, incoming_message) name = OutgoingMailer.name_for_followup(self, incoming_message) - if !done.include?(email.downcase) - ret = ret + [[name, email, incoming_message.id]] + unless done.include?(email.downcase) + ret += [[name, email, incoming_message.id]] end done[email.downcase] = 1 end - if !done.include?(public_body.request_email.downcase) - ret = ret + [[public_body.name, public_body.request_email, nil]] + unless done.include?(public_body.request_email.downcase) + ret += [[public_body.name, public_body.request_email, nil]] end done[public_body.request_email.downcase] = 1 @@ -1476,26 +1468,24 @@ def who_can_followup_to(skip_message = nil) # Get the list of censor rules that apply to this request def applicable_censor_rules applicable_rules = [censor_rules, CensorRule.global] - unless public_body.blank? - applicable_rules << public_body.censor_rules - end + applicable_rules << public_body.censor_rules unless public_body.blank? applicable_rules << user.censor_rules if user applicable_rules.flatten end def apply_censor_rules_to_text(text) applicable_censor_rules. - reduce(text) { |text, rule| rule.apply_to_text(text) } + reduce(text) { |t, rule| rule.apply_to_text(t) } end def apply_censor_rules_to_binary(text) applicable_censor_rules. - reduce(text) { |text, rule| rule.apply_to_binary(text) } + reduce(text) { |t, rule| rule.apply_to_binary(t) } end def apply_masks(text, content_type) - mask_options = { :censor_rules => applicable_censor_rules, - :masks => masks } + mask_options = { censor_rules: applicable_censor_rules, + masks: masks } AlaveteliTextMasker.apply_masks(text, content_type, mask_options) end @@ -1508,9 +1498,9 @@ def masks replacement: _("[{{site_name}} contact email]", site_name: site_name) }] if public_body.is_followupable? - masks << { :to_replace => public_body.request_email, - :replacement => _("[{{public_body}} request email]", - :public_body => public_body.short_or_long_name) } + masks << { to_replace: public_body.request_email, + replacement: _("[{{public_body}} request email]", + public_body: public_body.short_or_long_name) } end end @@ -1525,24 +1515,24 @@ def is_actual_owning_user?(user) end def all_correspondence_is_public? - prominence(:decorate => true).is_public? && - incoming_messages.all? { |message| message.is_public? } && - outgoing_messages.all? { |message| message.is_public? } + prominence(decorate: true).is_public? && + incoming_messages.all?(&:is_public?) && + outgoing_messages.all?(&:is_public?) end def json_for_api(deep) ret = { - :id => id, - :url_title => url_title, - :title => title, - :created_at => created_at, - :updated_at => updated_at, - :described_state => described_state, - :display_status => display_status, - :awaiting_description => awaiting_description, - :prominence => prominence, - :law_used => law_used, - :tags => tag_array, + id: id, + url_title: url_title, + title: title, + created_at: created_at, + updated_at: updated_at, + described_state: described_state, + display_status: display_status, + awaiting_description: awaiting_description, + prominence: prominence, + law_used: law_used, + tags: tag_array # not sure we need to make these, mainly anti-spam, admin params public # allow_new_responses_from @@ -1588,8 +1578,8 @@ def similar_ids(limit=10) xapian_similar = ActsAsXapian::Similar.new([InfoRequestEvent], info_request_events, - :limit => limit, - :collapse_by_prefix => 'request_collapse') + limit: limit, + collapse_by_prefix: 'request_collapse') xapian_similar_more = (xapian_similar.matches_estimated > limit) ids = xapian_similar.results.map do |result| result[:model].info_request_id @@ -1605,7 +1595,7 @@ def move_to_public_body(destination_public_body, opts = {}) old_body = public_body editor = opts.fetch(:editor) - attrs = { :public_body => destination_public_body } + attrs = { public_body: destination_public_body } if destination_public_body attrs[:law_used] = destination_public_body.legislation.key @@ -1638,7 +1628,7 @@ def move_to_user(destination_user, opts = {}) old_user = user editor = opts.fetch(:editor) - return_val = if update(:user => destination_user) + return_val = if update(user: destination_user) log_event( 'move_request', editor: editor, @@ -1762,10 +1752,10 @@ def self.add_conditions_from_extra_params(params, extra_params) def self.search_events(query, opts = {}) defaults = { - :offset => 0, - :limit => 20, - :sort_by_prefix => 'created_at', - :sort_by_ascending => true + offset: 0, + limit: 20, + sort_by_prefix: 'created_at', + sort_by_ascending: true } ActsAsXapian::Search.new([InfoRequestEvent], query, defaults.merge(opts)) end @@ -1819,7 +1809,7 @@ def accept_incoming?(email, raw_email_data) end end - def create_response!(email, raw_email_data, rejected_reason = nil) + def create_response!(_email, raw_email_data, rejected_reason = nil) incoming_message = incoming_messages.build # To avoid a deadlock when simultaneously dealing with two @@ -1837,7 +1827,7 @@ def create_response!(email, raw_email_data, rejected_reason = nil) self.awaiting_description = true end - params = { :incoming_message_id => incoming_message.id } + params = { incoming_message_id: incoming_message.id } params[:rejected_reason] = rejected_reason.to_s if rejected_reason log_event('response', params) @@ -1862,14 +1852,10 @@ def index_of_last_described_event end def set_defaults - begin - if described_state.nil? - self.described_state = 'waiting_response' - end - rescue ActiveModel::MissingAttributeError - # this should only happen on Model.exists? call. It can be safely ignored. - # See http://www.tatvartha.com/2011/03/activerecordmissingattributeerror-missing-attribute-a-bug-or-a-features/ - end + self.described_state = 'waiting_response' if described_state.nil? + rescue ActiveModel::MissingAttributeError + # this should only happen on Model.exists? call. It can be safely ignored. + # See http://www.tatvartha.com/2011/03/activerecordmissingattributeerror-missing-attribute-a-bug-or-a-features/ end def set_law_used @@ -1883,7 +1869,7 @@ def set_use_notifications user.features.enabled?(:notifications) && \ info_request_batch_id.present? end - return true + true end def must_be_valid_state diff --git a/app/models/info_request/batch_pagination.rb b/app/models/info_request/batch_pagination.rb new file mode 100644 index 0000000000..91ec018ea7 --- /dev/null +++ b/app/models/info_request/batch_pagination.rb @@ -0,0 +1,26 @@ +# Methods to handle pagination within an associated InfoRequestBatch +module InfoRequest::BatchPagination + def next_in_batch + return nil unless info_request_batch + batch_sibling_requests_ordered_by_id[index_in_batch + 1] || first_in_batch + end + + def prev_in_batch + return nil unless info_request_batch + batch_sibling_requests_ordered_by_id[index_in_batch - 1] + end + + private + + def first_in_batch + batch_sibling_requests_ordered_by_id.first + end + + def index_in_batch + batch_sibling_requests_ordered_by_id.pluck(:id).index(id) + end + + def batch_sibling_requests_ordered_by_id + info_request_batch.info_requests.reorder(id: :asc) + end +end diff --git a/app/models/info_request/pro_query.rb b/app/models/info_request/pro_query.rb index bc29ab032a..4cab5280b8 100644 --- a/app/models/info_request/pro_query.rb +++ b/app/models/info_request/pro_query.rb @@ -6,8 +6,8 @@ def initialize(relation = InfoRequest) def call @relation - .includes(:user => :roles) - .where(:roles => {:name => 'pro'}) + .includes(user: :roles) + .where(roles: {name: 'pro'}) .references(:roles) end end diff --git a/app/models/info_request/prominence/been_published_query.rb b/app/models/info_request/prominence/been_published_query.rb index 81edbd2833..aef67c27c1 100644 --- a/app/models/info_request/prominence/been_published_query.rb +++ b/app/models/info_request/prominence/been_published_query.rb @@ -7,13 +7,13 @@ def initialize(relation = InfoRequest) def call @relation.joins( - 'LEFT JOIN "embargoes" ' + + 'LEFT JOIN "embargoes" ' \ 'ON "embargoes"."info_request_id" = "info_requests"."id"' ).joins( - 'LEFT JOIN "info_request_events" ' + + 'LEFT JOIN "info_request_events" ' \ 'ON "info_request_events"."info_request_id" = "info_requests"."id"' ).where( - '"embargoes"."id" IS NULL ' + + '"embargoes"."id" IS NULL ' \ 'OR "info_request_events"."event_type" = ?', 'expire_embargo' ) end diff --git a/app/models/info_request/prominence/calculator.rb b/app/models/info_request/prominence/calculator.rb index 550d5ac413..9194df3ae4 100644 --- a/app/models/info_request/prominence/calculator.rb +++ b/app/models/info_request/prominence/calculator.rb @@ -17,7 +17,7 @@ def is_searchable? # Is this request hidden from some people? def is_private? - return %w(hidden requester_only).include?(to_s) || @info_request.embargo.present? + %w(hidden requester_only).include?(to_s) || @info_request.embargo.present? end # Is this request visible only to admins and the requester? diff --git a/app/models/info_request/prominence/public_query.rb b/app/models/info_request/prominence/public_query.rb index 4d5bd5c484..8c3fe53fb7 100644 --- a/app/models/info_request/prominence/public_query.rb +++ b/app/models/info_request/prominence/public_query.rb @@ -6,7 +6,7 @@ def initialize(relation = InfoRequest) end def call - @relation.where(prominence: ['normal', 'backpage']).not_embargoed + @relation.where(prominence: %w[normal backpage]).not_embargoed end end end diff --git a/app/models/info_request/response_gatekeeper/base.rb b/app/models/info_request/response_gatekeeper/base.rb index f147c00fb6..3ceb1d2c64 100644 --- a/app/models/info_request/response_gatekeeper/base.rb +++ b/app/models/info_request/response_gatekeeper/base.rb @@ -9,7 +9,7 @@ def initialize(info_request) @reason = nil end - def allow?(email) + def allow?(_email) allow end diff --git a/app/models/info_request/response_gatekeeper/spam_checker.rb b/app/models/info_request/response_gatekeeper/spam_checker.rb index cc2ab527c9..69168dad05 100644 --- a/app/models/info_request/response_gatekeeper/spam_checker.rb +++ b/app/models/info_request/response_gatekeeper/spam_checker.rb @@ -2,13 +2,13 @@ class InfoRequest module ResponseGatekeeper class SpamChecker DEFAULT_CONFIGURATION = { - :spam_action => ::AlaveteliConfiguration.incoming_email_spam_action, - :spam_header => ::AlaveteliConfiguration.incoming_email_spam_header, - :spam_threshold => ::AlaveteliConfiguration.incoming_email_spam_threshold + spam_action: ::AlaveteliConfiguration.incoming_email_spam_action, + spam_header: ::AlaveteliConfiguration.incoming_email_spam_header, + spam_threshold: ::AlaveteliConfiguration.incoming_email_spam_threshold } attr_reader :spam_action, :spam_header, :spam_threshold - alias_method :rejection_action, :spam_action + alias rejection_action spam_action def initialize(opts = {}) @spam_action = opts[:spam_action] || DEFAULT_CONFIGURATION[:spam_action] @@ -22,7 +22,7 @@ def allow?(email) def reason _('Incoming message has a spam score above the configured threshold ' \ - '({{spam_threshold}}).', :spam_threshold => spam_threshold) + '({{spam_threshold}}).', spam_threshold: spam_threshold) end def spam?(email) diff --git a/app/models/info_request/response_rejection/base.rb b/app/models/info_request/response_rejection/base.rb index edffed23e0..b6ec406c0f 100644 --- a/app/models/info_request/response_rejection/base.rb +++ b/app/models/info_request/response_rejection/base.rb @@ -9,7 +9,7 @@ def initialize(info_request, email, raw_email_data) @raw_email_data = raw_email_data end - def reject(reason = nil) + def reject(_reason = nil) true end end diff --git a/app/models/info_request/response_rejection/bounce.rb b/app/models/info_request/response_rejection/bounce.rb index e8996a2a43..0649d91452 100644 --- a/app/models/info_request/response_rejection/bounce.rb +++ b/app/models/info_request/response_rejection/bounce.rb @@ -1,21 +1,19 @@ class InfoRequest module ResponseRejection class Bounce < Base - def reject(reason = nil) + def reject(_reason = nil) from_address = MailHandler.get_from_address(email) if from_address.nil? || from_address.downcase == info_request.incoming_email.downcase # do nothing – can't bounce the mail as there's no address to send it # to, or the mail is spoofing the request address, and we'll end up # in a loop if we bounce it. true + elsif info_request.is_external? + true else - if info_request.is_external? - true - else - RequestMailer. - stopped_responses(info_request, email, raw_email_data). - deliver_now - end + RequestMailer. + stopped_responses(info_request, email, raw_email_data). + deliver_now end end end diff --git a/app/models/info_request/response_rejection/holding_pen.rb b/app/models/info_request/response_rejection/holding_pen.rb index 771f675a05..6c8d74f8cb 100644 --- a/app/models/info_request/response_rejection/holding_pen.rb +++ b/app/models/info_request/response_rejection/holding_pen.rb @@ -14,7 +14,7 @@ def reject(reason = nil) else holding_pen.receive(email, raw_email_data, - { :rejected_reason => reason }) + { rejected_reason: reason }) end end end diff --git a/app/models/info_request/state.rb b/app/models/info_request/state.rb index 36bbe2aa68..0c4d51d73a 100644 --- a/app/models/info_request/state.rb +++ b/app/models/info_request/state.rb @@ -50,14 +50,14 @@ def self.short_description(state) 'attention_requested' => _("Reported"), 'user_withdrawn' => _("Withdrawn"), 'vexatious' => _("Vexatious"), - 'not_foi' => _("Not an FOI request"), + 'not_foi' => _("Not an FOI request") } if descriptions[state] descriptions[state] elsif InfoRequest.respond_to?(:theme_short_description) InfoRequest.theme_short_description(state) else - raise _("unknown status {{state}}", :state => state) + raise _("unknown status {{state}}", state: state) end end diff --git a/app/models/info_request/state/calculator.rb b/app/models/info_request/state/calculator.rb index b8aa4c9061..b4109f120d 100644 --- a/app/models/info_request/state/calculator.rb +++ b/app/models/info_request/state/calculator.rb @@ -130,12 +130,12 @@ def build_transitions_hash(opts) def pending_states(opts) # Which pending states can we transition into if opts.fetch(:in_internal_review, false) - states = ['internal_review', 'gone_postal'] + states = %w[internal_review gone_postal] else - states = [ - 'waiting_response', - 'waiting_clarification', - 'gone_postal' + states = %w[ + waiting_response + waiting_clarification + gone_postal ] if opts.fetch(:user_asked_to_update_status, false) states += ['internal_review'] @@ -144,20 +144,20 @@ def pending_states(opts) states end - def complete_states(opts = {}) + def complete_states(_opts = {}) # States from which a request can go no further, because it's complete - [ - 'not_held', - 'partially_successful', - 'successful', - 'rejected' + %w[ + not_held + partially_successful + successful + rejected ] end - def admin_states(opts = {}) + def admin_states(_opts = {}) # States which only an admin can put a request into, and from which # a normal user can't get the request out again - ['not_foi', 'vexatious'] + %w[not_foi vexatious] end def other_states(opts = {}) @@ -165,7 +165,7 @@ def other_states(opts = {}) user_asked_to_update_status = opts.fetch(:user_asked_to_update_status, false) states = ['error_message'] if user_asked_to_update_status && is_owning_user - states += ['requires_admin', 'user_withdrawn'] + states += %w[requires_admin user_withdrawn] end states end diff --git a/app/models/info_request/state/complete_query.rb b/app/models/info_request/state/complete_query.rb index 5bd33c6ae5..def340cb4e 100644 --- a/app/models/info_request/state/complete_query.rb +++ b/app/models/info_request/state/complete_query.rb @@ -6,12 +6,12 @@ def initialize(relation = InfoRequest) end def call - @relation.where(described_state: ['not_held', - 'rejected', - 'successful', - 'partially_successful', - 'user_withdrawn'], - awaiting_description: false) + @relation.where( + described_state: %w[ + not_held rejected successful partially_successful user_withdrawn + ], + awaiting_description: false + ) end end end diff --git a/app/models/info_request/state/other_query.rb b/app/models/info_request/state/other_query.rb index 9981827202..48180487f1 100644 --- a/app/models/info_request/state/other_query.rb +++ b/app/models/info_request/state/other_query.rb @@ -6,14 +6,13 @@ def initialize(relation = InfoRequest) end def call - @relation.where(described_state: ['gone_postal', - 'internal_review', - 'error_message', - 'requires_admin', - 'attention_requested', - 'vexatious', - 'not_foi'], - awaiting_description: false) + @relation.where( + described_state: %w[ + gone_postal internal_review error_message requires_admin + attention_requested vexatious not_foi + ], + awaiting_description: false + ) end end end diff --git a/app/models/info_request/state/transitions.rb b/app/models/info_request/state/transitions.rb index e49a9fef83..149719910a 100644 --- a/app/models/info_request/state/transitions.rb +++ b/app/models/info_request/state/transitions.rb @@ -52,38 +52,36 @@ def self.transition_label(to_state, opts = {}) def self.labelled_hash(states, opts = {}) hash = {} states.each do |state| - hash[state] = self.transition_label(state, opts) + hash[state] = transition_label(state, opts) end hash end - private - - def self.owner_waiting_response_transition_label(opts = {}) + def self.owner_waiting_response_transition_label(_opts = {}) _("I'm still waiting for my information (maybe you got an acknowledgement)") end - def self.owner_not_held_transition_label(opts = {}) + def self.owner_not_held_transition_label(_opts = {}) _("They do not have the information (maybe they say who does)") end - def self.owner_rejected_transition_label(opts = {}) + def self.owner_rejected_transition_label(_opts = {}) _("My request has been refused") end - def self.owner_partially_successful_transition_label(opts = {}) + def self.owner_partially_successful_transition_label(_opts = {}) _("I've received some of the information") end - def self.owner_successful_transition_label(opts = {}) + def self.owner_successful_transition_label(_opts = {}) _("I've received all the information") end - def self.owner_waiting_clarification_transition_label(opts = {}) + def self.owner_waiting_clarification_transition_label(_opts = {}) _("I've been asked to clarify my request") end - def self.owner_gone_postal_transition_label(opts = {}) + def self.owner_gone_postal_transition_label(_opts = {}) _("They are going to reply by postal mail") end @@ -95,48 +93,48 @@ def self.owner_internal_review_transition_label(opts = {}) end end - def self.owner_error_message_transition_label(opts = {}) + def self.owner_error_message_transition_label(_opts = {}) _("I've received an error message") end - def self.owner_requires_admin_transition_label(opts = {}) + def self.owner_requires_admin_transition_label(_opts = {}) _("This request requires administrator attention") end - def self.owner_user_withdrawn_transition_label(opts = {}) + def self.owner_user_withdrawn_transition_label(_opts = {}) _("I would like to withdraw this request") end - def self.other_user_waiting_response_transition_label(opts = {}) + def self.other_user_waiting_response_transition_label(_opts = {}) _("No response has been received (maybe " \ "there's just an acknowledgement)") end - def self.other_user_not_held_transition_label(opts = {}) + def self.other_user_not_held_transition_label(_opts = {}) _("The authority do not have the information " \ "(maybe they say who does)") end - def self.other_user_rejected_transition_label(opts = {}) + def self.other_user_rejected_transition_label(_opts = {}) _("The request has been refused") end - def self.other_user_partially_successful_transition_label(opts = {}) + def self.other_user_partially_successful_transition_label(_opts = {}) # TODO: - trailing space copied from # views/request/_other_describe_state.html.erb, will it break # translations if I fix it? _("Some of the information has been sent ") end - def self.other_user_successful_transition_label(opts = {}) + def self.other_user_successful_transition_label(_opts = {}) _("All the information has been sent") end - def self.other_user_waiting_clarification_transition_label(opts = {}) + def self.other_user_waiting_clarification_transition_label(_opts = {}) _("Clarification has been requested") end - def self.other_user_gone_postal_transition_label(opts = {}) + def self.other_user_gone_postal_transition_label(_opts = {}) _("A response will be sent by postal mail") end @@ -150,51 +148,51 @@ def self.other_user_internal_review_transition_label(opts = {}) end end - def self.other_user_error_message_transition_label(opts = {}) + def self.other_user_error_message_transition_label(_opts = {}) _("An error message has been received") end - def self.pro_waiting_response_transition_label(opts = {}) + def self.pro_waiting_response_transition_label(_opts = {}) State.short_description('waiting_response') end - def self.pro_not_held_transition_label(opts = {}) + def self.pro_not_held_transition_label(_opts = {}) State.short_description('not_held') end - def self.pro_rejected_transition_label(opts = {}) + def self.pro_rejected_transition_label(_opts = {}) State.short_description('rejected') end - def self.pro_partially_successful_transition_label(opts = {}) + def self.pro_partially_successful_transition_label(_opts = {}) State.short_description('partially_successful') end - def self.pro_successful_transition_label(opts = {}) + def self.pro_successful_transition_label(_opts = {}) State.short_description('successful') end - def self.pro_waiting_clarification_transition_label(opts = {}) + def self.pro_waiting_clarification_transition_label(_opts = {}) State.short_description('waiting_clarification') end - def self.pro_gone_postal_transition_label(opts = {}) + def self.pro_gone_postal_transition_label(_opts = {}) State.short_description('gone_postal') end - def self.pro_internal_review_transition_label(opts = {}) + def self.pro_internal_review_transition_label(_opts = {}) State.short_description('internal_review') end - def self.pro_error_message_transition_label(opts = {}) + def self.pro_error_message_transition_label(_opts = {}) State.short_description('error_message') end - def self.pro_requires_admin_transition_label(opts = {}) + def self.pro_requires_admin_transition_label(_opts = {}) State.short_description('requires_admin') end - def self.pro_user_withdrawn_transition_label(opts = {}) + def self.pro_user_withdrawn_transition_label(_opts = {}) State.short_description('user_withdrawn') end end diff --git a/app/models/info_request_batch.rb b/app/models/info_request_batch.rb index 528be63668..9e2451d9a8 100644 --- a/app/models/info_request_batch.rb +++ b/app/models/info_request_batch.rb @@ -19,10 +19,10 @@ class InfoRequestBatch < ApplicationRecord include InfoRequest::TitleValidation has_many :info_requests, - :inverse_of => :info_request_batch + inverse_of: :info_request_batch belongs_to :user, - :inverse_of => :info_request_batches, - :counter_cache => true + inverse_of: :info_request_batches, + counter_cache: true has_many :citations, -> (batch) { unscope(:where).for_batch(batch) }, as: :citable, @@ -34,7 +34,7 @@ class InfoRequestBatch < ApplicationRecord includes(:translations). reorder('public_body_translations.name asc') end - }, :inverse_of => :info_request_batches + }, inverse_of: :info_request_batches attr_accessor :ignore_existing_batch @@ -46,6 +46,8 @@ class InfoRequestBatch < ApplicationRecord strip_attributes only: %i[embargo_duration] + scope :not_embargoed, -> { where(embargo_duration: nil) } + def self.send_batches where(sent_at: nil).find_each do |info_request_batch| AlaveteliLocalization.with_locale(info_request_batch.user.locale) do @@ -91,11 +93,11 @@ def self.find_existing(user, title, body, public_body_ids, id: nil) # Create a new batch from the supplied draft version def self.from_draft(draft) - self.new(:user => draft.user, - :public_bodies => draft.public_bodies, - :title => draft.title, - :body => draft.body, - :embargo_duration => draft.embargo_duration) + new(user: draft.user, + public_bodies: draft.public_bodies, + title: draft.title, + body: draft.body, + embargo_duration: draft.embargo_duration) end def existing_batch @@ -162,17 +164,17 @@ def sent? # Build an InfoRequest object which is an example of this batch. def example_request - public_body = self.public_bodies.first + public_body = public_bodies.first body = OutgoingMessage.fill_in_salutation(self.body, public_body) info_request = InfoRequest.build_from_attributes( - { :title => self.title, :public_body => public_body }, - { :body => body }, - self.user + { title: title, public_body: public_body }, + { body: body }, + user ) - unless self.embargo_duration.blank? + unless embargo_duration.blank? info_request.embargo = AlaveteliPro::Embargo.new( - :info_request => info_request, - :embargo_duration => self.embargo_duration + info_request: info_request, + embargo_duration: embargo_duration ) end info_request @@ -221,43 +223,43 @@ def request_phases # Returns hash of string group names mapped to an integer def request_phases_summary { - :in_progress => { - :label => _('In progress'), - :count => self.info_requests.in_progress.count + in_progress: { + label: _('In progress'), + count: info_requests.in_progress.count }, - :action_needed => { - :label => _('Action needed'), - :count => self.info_requests.action_needed.count + action_needed: { + label: _('Action needed'), + count: info_requests.action_needed.count }, - :complete => { - :label => _('Complete'), - :count => self.info_requests.complete.count + complete: { + label: _('Complete'), + count: info_requests.complete.count }, - :other => { - :label => _('Other'), - :count => self.info_requests.other.count + other: { + label: _('Other'), + count: info_requests.other.count } } end # @see RequestSummaries#request_summary_body def request_summary_body - self.body + body end # @see RequestSummaries#request_summary_public_body_names def request_summary_public_body_names - self.public_bodies.pluck(:name).join(" ") + public_bodies.pluck(:name).join(" ") end # @see RequestSummaries#request_summary_categories def request_summary_categories categories = [] - if self.embargo_expiring? + if embargo_expiring? categories << AlaveteliPro::RequestSummaryCategory.embargo_expiring end - if self.sent_at - phase_slugs = self.request_phases.map(&:to_s).uniq + if sent_at + phase_slugs = request_phases.map(&:to_s).uniq phases = AlaveteliPro::RequestSummaryCategory.where(slug: phase_slugs) categories.concat phases else diff --git a/app/models/info_request_event.rb b/app/models/info_request_event.rb index 9f383c087d..3892b1a0a9 100644 --- a/app/models/info_request_event.rb +++ b/app/models/info_request_event.rb @@ -1,12 +1,11 @@ # == Schema Information -# Schema version: 20220408125559 +# Schema version: 20230127132719 # # Table name: info_request_events # # id :integer not null, primary key # info_request_id :integer not null # event_type :text not null -# params_yaml :text not null # created_at :datetime not null # described_state :string # calculated_state :string @@ -23,8 +22,6 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: hello@mysociety.org; WWW: http://www.mysociety.org/ -require 'yaml_compatibility' - class InfoRequestEvent < ApplicationRecord extend XapianQueries @@ -61,130 +58,97 @@ class InfoRequestEvent < ApplicationRecord ].freeze belongs_to :info_request, - :inverse_of => :info_request_events + inverse_of: :info_request_events validates_presence_of :info_request belongs_to :outgoing_message, - :inverse_of => :info_request_events + inverse_of: :info_request_events belongs_to :incoming_message, - :inverse_of => :info_request_events + inverse_of: :info_request_events belongs_to :comment, - :inverse_of => :info_request_events + inverse_of: :info_request_events has_one :request_classification, - :inverse_of => :info_request_event + inverse_of: :info_request_event has_many :user_info_request_sent_alerts, - :inverse_of => :info_request_event, - :dependent => :destroy + inverse_of: :info_request_event, + dependent: :destroy has_many :track_things_sent_emails, - :inverse_of => :info_request_event, - :dependent => :destroy + inverse_of: :info_request_event, + dependent: :destroy has_many :notifications, - :inverse_of => :info_request_event, - :dependent => :destroy + inverse_of: :info_request_event, + dependent: :destroy validates_presence_of :event_type - before_save(:if => :only_editing_prominence_to_hide?) do + before_save(if: :only_editing_prominence_to_hide?) do self.event_type = "hide" end - after_create :update_request, :if => :response? + after_create :update_request, if: :response? - after_commit -> { self.info_request.create_or_update_request_summary }, - :on => [:create] + after_commit -> { info_request.create_or_update_request_summary }, + on: [:create] - validates_inclusion_of :event_type, :in => EVENT_TYPES + validates_inclusion_of :event_type, in: EVENT_TYPES # user described state (also update in info_request) validate :must_be_valid_state - def must_be_valid_state - if described_state and !InfoRequest::State.all.include?(described_state) - errors.add(:described_state, "is not a valid state") - end + EVENT_TYPES.each do |event_type| + scope "#{event_type}_events", -> { where(event_type: event_type) } end attr_accessor :no_xapian_reindex # Full text search indexing - acts_as_xapian :texts => [ :search_text_main, :title ], - :values => [ - [ :created_at, 0, "range_search", :date ], # for QueryParser range searches e.g. 01/01/2008..14/01/2008 - [ :created_at_numeric, 1, "created_at", :number ], # for sorting - [ :described_at_numeric, 2, "described_at", :number ], # TODO: using :number for lack of :datetime support in Xapian values - [ :request, 3, "request_collapse", :string ], - [ :request_title_collapse, 4, "request_title_collapse", :string ], - ], - :terms => [ [ :calculated_state, 'S', "status" ], - [ :requested_by, 'B', "requested_by" ], - [ :requested_from, 'F', "requested_from" ], - [ :commented_by, 'C', "commented_by" ], - [ :request, 'R', "request" ], - [ :variety, 'V', "variety" ], - [ :latest_variety, 'K', "latest_variety" ], - [ :latest_status, 'L', "latest_status" ], - [ :waiting_classification, 'W', "waiting_classification" ], - [ :filetype, 'T', "filetype" ], - [ :tags, 'U', "tag" ], - [ :request_public_body_tags, 'X', "request_public_body_tag" ] ], - :if => :indexed_by_search?, - :eager_load => [ :outgoing_message, :comment, { :info_request => [ :user, :public_body, :censor_rules ] } ] + acts_as_xapian \ + texts: [ + :search_text_main, + :title + ], + values: [ + # for QueryParser range searches e.g. 01/01/2008..14/01/2008: + [:created_at, 0, 'range_search', :date], + # for sorting: + [:created_at_numeric, 1, 'created_at', :number], + # TODO: using :number for lack of :datetime support in Xapian values: + [:described_at_numeric, 2, 'described_at', :number], + [:request, 3, 'request_collapse', :string], + [:request_title_collapse, 4, 'request_title_collapse', :string] + ], + terms: [ + [:calculated_state, 'S', 'status'], + [:requested_by, 'B', 'requested_by'], + [:requested_from, 'F', 'requested_from'], + [:commented_by, 'C', 'commented_by'], + [:request, 'R', 'request'], + [:variety, 'V', 'variety'], + [:latest_variety, 'K', 'latest_variety'], + [:latest_status, 'L', 'latest_status'], + [:waiting_classification, 'W', 'waiting_classification'], + [:filetype, 'T', 'filetype'], + [:tags, 'U', 'tag'], + [:request_public_body_tags, 'X', 'request_public_body_tag'] + ], + eager_load: [ + :outgoing_message, + :comment, + { info_request: [:user, :public_body, :censor_rules] } + ], + if: :indexed_by_search? def self.count_of_hides_by_week where(event_type: "hide").group("date(date_trunc('week', created_at))").count.sort end - def requested_by - info_request.user_name_slug - end - - def requested_from - # acts_as_xapian will detect translated fields via Globalize and add all the - # available locales to the index. But 'requested_from' is not translated directly, - # although it relies on a translated field in PublicBody. Hence, we need to - # manually add all the localized values to the index (Xapian can handle a list - # of values in a term, btw) - info_request.public_body.translations.map { |t| t.url_name } - end - - def commented_by - if event_type == 'comment' - comment.user.url_name - else - '' - end - end - + # TODO: Can possibly be made private def request info_request.url_title end - def latest_variety - sibling_events(:reverse => true).each do |event| - unless event.variety.blank? - return event.variety - end - end - end - - def latest_status - sibling_events(:reverse => true).each do |event| - unless event.calculated_state.blank? - return event.calculated_state - end - end - end - - def waiting_classification - info_request.awaiting_description == true ? "yes" : "no" - end - - def request_title_collapse - info_request.url_title(:collapse => true) - end - def described_at # For responses, people might have RSS feeds on searches for type of # response (e.g. successful) in which case we want to date sort by @@ -193,48 +157,16 @@ def described_at last_described_at || created_at end - def described_at_numeric - # format it here as no datetime support in Xapian's value ranges - described_at.strftime("%Y%m%d%H%M%S") - end - - def created_at_numeric - # format it here as no datetime support in Xapian's value ranges - created_at.strftime("%Y%m%d%H%M%S") - end - def incoming_message_selective_columns(fields) message = IncomingMessage.select("#{ fields }, incoming_messages.info_request_id"). joins('INNER JOIN info_request_events ON incoming_messages.id = incoming_message_id'). where('info_request_events.id = ?', id) message = message[0] - if message - message.info_request = InfoRequest.find(message.info_request_id) - end + message.info_request = InfoRequest.find(message.info_request_id) if message message end - def get_clipped_response_efficiently - # TODO: this ugly code is an attempt to not always load all the - # columns for an incoming message, which can be *very* large - # (due to all the cached text). We care particularly in this - # case because it's called for every search result on a page - # (to show the search snippet). Actually, we should review if we - # need all this data to be cached in the database at all, and - # then we won't need this horrid workaround. - message = incoming_message_selective_columns("cached_attachment_text_clipped, cached_main_body_text_folded") - clipped_body = message.cached_main_body_text_folded - clipped_attachment = message.cached_attachment_text_clipped - if clipped_body.nil? || clipped_attachment.nil? - # we're going to have to load it anyway - text = incoming_message.get_text_for_indexing_clipped - else - text = clipped_body.gsub("FOLDED_QUOTED_SECTION", " ").strip + "\n\n" + clipped_attachment - end - text + "\n\n" - end - # clipped = true - means return shorter text. It is used for snippets fore # performance reasons. Xapian will take the full text. def search_text_main(clipped = false) @@ -245,18 +177,17 @@ def search_text_main(clipped = false) text = text + outgoing_message.get_text_for_indexing + "\n\n" elsif event_type == 'response' if clipped - text = text + get_clipped_response_efficiently + text += get_clipped_response_efficiently else text = text + incoming_message.get_text_for_indexing_full + "\n\n" end elsif event_type == 'comment' text = text + comment.body + "\n\n" - else - # nothing end text end + # TODO: Can possibly be made private def title if event_type == 'sent' info_request.title @@ -265,50 +196,12 @@ def title end end - def filetype - if event_type == 'response' - unless incoming_message - raise "event type is 'response' but no incoming message for event id #{id}" - end - - incoming_message.get_present_file_extensions - else - '' - end - end - + # TODO: Can possibly be made private def tags # this returns an array of strings, each gets indexed as separate term by acts_as_xapian info_request.tag_array_for_search end - def request_public_body_tags - info_request.public_body.tag_array_for_search - end - - def indexed_by_search? - if ['sent', 'followup_sent', 'response', 'comment'].include?(event_type) - if !info_request.indexed_by_search? - return false - end - if event_type == 'response' && !incoming_message.indexed_by_search? - return false - end - if ['sent', 'followup_sent'].include?(event_type) && !outgoing_message.indexed_by_search? - return false - end - if event_type == 'comment' && !comment.visible - return false - end - return true - end - false - end - - def variety - event_type - end - def visible if event_type == 'comment' comment.visible @@ -319,7 +212,6 @@ def visible def params=(new_params) super(params_for_jsonb(new_params)) - self.params_yaml = params_for_yaml(new_params) # TODO: should really set these explicitly, and stop storing them in # here, but keep it for compatibility with old way for now @@ -329,9 +221,7 @@ def params=(new_params) if params[:outgoing_message] self.outgoing_message = params[:outgoing_message] end - if params[:comment] - self.comment = params[:comment] - end + self.comment = params[:comment] if params[:comment] end # A hash to lazy load Global ID reference models @@ -347,13 +237,7 @@ def [](key) def params params_jsonb = super - return Params[params_jsonb.deep_symbolize_keys] if params_jsonb - - param_hash = YAMLCompatibility.load(params_yaml) || {} - param_hash.each do |key, value| - param_hash[key] = value.force_encoding('UTF-8') if value.respond_to?(:force_encoding) - end - param_hash + Params[params_jsonb.deep_symbolize_keys] if params_jsonb end def params_diff @@ -362,7 +246,7 @@ def params_diff new_params = {} other_params = {} ignore = {} - for key, value in params + params.each do |key, value| key = key.to_s if key.match(/^old_(.*)$/) if params[$1.to_sym] == value @@ -376,8 +260,8 @@ def params_diff other_params[key.to_sym] = value end end - new_params.delete_if { |key, value| ignore.keys.include?(key) } - {:new => new_params, :old => old_params, :other => other_params} + new_params.delete_if { |key, _value| ignore.keys.include?(key) } + {new: new_params, old: old_params, other: other_params} end def is_incoming_message? @@ -397,7 +281,7 @@ def resets_due_dates? end def is_request_sending? - ['sent', 'resent'].include?(event_type) || + %w[sent resent].include?(event_type) || (event_type == 'send_error' && outgoing_message.message_type == 'initial_request') end @@ -407,14 +291,12 @@ def is_clarification? # A follow up is a clarification only if it's the first # follow up when the request is in a state of # waiting for clarification - previous_events(:reverse => true).each do |event| + previous_events(reverse: true).each do |event| if event.described_state == 'waiting_clarification' waiting_clarification = true break end - if event.event_type == 'followup_sent' - break - end + break if event.event_type == 'followup_sent' end waiting_clarification && event_type == 'followup_sent' end @@ -423,9 +305,7 @@ def is_clarification? # on the request and resets them if so def recheck_due_dates subsequent_events.each do |event| - if event.resets_due_dates? - info_request.set_due_dates(event) - end + info_request.set_due_dates(event) if event.resets_due_dates? end end @@ -439,13 +319,9 @@ def display_status if is_outgoing_message? status = calculated_state if status - if status == 'internal_review' - return _("Internal review request") - end - if status == 'waiting_response' - return _("Clarification") - end - raise _("unknown status {{status}}", :status => status) + return _("Internal review request") if status == 'internal_review' + return _("Clarification") if status == 'waiting_response' + raise _("unknown status {{status}}", status: status) end # TRANSLATORS: "Follow up" in this context means a further # message sent by the requester to the authority after @@ -457,28 +333,21 @@ def display_status end def is_sent_sort? - ['sent', 'resent'].include?(event_type) + %w[sent resent].include?(event_type) end def is_followup_sort? - ['followup_sent', 'followup_resent'].include?(event_type) + %w[followup_sent followup_resent].include?(event_type) end def outgoing? - ['sent', 'followup_sent'].include?(event_type) + %w[sent followup_sent].include?(event_type) end def response? event_type == 'response' end - def only_editing_prominence_to_hide? - event_type == 'edit' && - params_diff[:new].keys == [:prominence] && - params_diff[:old][:prominence] == "normal" && - %w(hidden requester_only backpage).include?(params_diff[:new][:prominence]) - end - # This method updates the cached column of the InfoRequest that # stores the last created_at date of relevant events # when saving or destroying an InfoRequestEvent associated with the request @@ -489,27 +358,23 @@ def update_request def same_email_as_previous_send? prev_addr = info_request.get_previous_email_sent_to(self) curr_addr = params[:email] - if prev_addr.nil? && curr_addr.nil? - return true - end - if prev_addr.nil? || curr_addr.nil? - return false - end + return true if prev_addr.nil? && curr_addr.nil? + return false if prev_addr.nil? || curr_addr.nil? MailHandler.address_from_string(prev_addr) == MailHandler.address_from_string(curr_addr) end def json_for_api(deep, snippet_highlight_proc = nil) ret = { - :id => id, - :event_type => event_type, + id: id, + event_type: event_type, # params has possibly sensitive data in it, don't include it - :created_at => created_at, - :described_state => described_state, - :calculated_state => calculated_state, - :last_described_at => last_described_at, - :incoming_message_id => incoming_message_id, - :outgoing_message_id => outgoing_message_id, - :comment_id => comment_id, + created_at: created_at, + described_state: described_state, + calculated_state: calculated_state, + last_described_at: last_described_at, + incoming_message_id: incoming_message_id, + outgoing_message_id: outgoing_message_id, + comment_id: comment_id # TODO: would be nice to add links here, but alas the # code to make them is in views only. See views/request/details.html.erb @@ -541,14 +406,20 @@ def set_calculated_state!(state) end end + protected + + def variety + event_type + end + private def previous_events(opts = {}) order = opts[:reverse] ? 'created_at DESC' : 'created_at' events = self. class. - where(:info_request_id => info_request_id). - where('created_at < ?', self.created_at). + where(info_request_id: info_request_id). + where('created_at < ?', created_at). order(order) end @@ -557,14 +428,14 @@ def subsequent_events(opts = {}) order = opts[:reverse] ? 'created_at DESC' : 'created_at' events = self. class. - where(:info_request_id => info_request_id). - where('created_at > ?', self.created_at). + where(info_request_id: info_request_id). + where('created_at > ?', created_at). order(order) end def sibling_events(opts = {}) order = opts[:reverse] ? 'created_at DESC' : 'created_at' - events = self.class.where(:info_request_id => info_request_id).order(order) + events = self.class.where(info_request_id: info_request_id).order(order) end def params_for_jsonb(params) @@ -606,7 +477,120 @@ def params_for_jsonb(params) end end - def params_for_yaml(params) - params.to_yaml + def only_editing_prominence_to_hide? + event_type == 'edit' && + params_diff[:new].keys == [:prominence] && + params_diff[:old][:prominence] == "normal" && + %w(hidden requester_only backpage).include?(params_diff[:new][:prominence]) + end + + def get_clipped_response_efficiently + # TODO: this ugly code is an attempt to not always load all the + # columns for an incoming message, which can be *very* large + # (due to all the cached text). We care particularly in this + # case because it's called for every search result on a page + # (to show the search snippet). Actually, we should review if we + # need all this data to be cached in the database at all, and + # then we won't need this horrid workaround. + message = incoming_message_selective_columns("cached_attachment_text_clipped, cached_main_body_text_folded") + clipped_body = message.cached_main_body_text_folded + clipped_attachment = message.cached_attachment_text_clipped + if clipped_body.nil? || clipped_attachment.nil? + # we're going to have to load it anyway + text = incoming_message.get_text_for_indexing_clipped + else + text = clipped_body.gsub("FOLDED_QUOTED_SECTION", " ").strip + "\n\n" + clipped_attachment + end + text + "\n\n" + end + + def must_be_valid_state + if described_state && !InfoRequest::State.all.include?(described_state) + errors.add(:described_state, "is not a valid state") + end + end + + # INDEXING HELPERS + + def indexed_by_search? + if %w[sent followup_sent response comment].include?(event_type) + return false unless info_request.indexed_by_search? + if event_type == 'response' && !incoming_message.indexed_by_search? + return false + end + if %w[sent followup_sent].include?(event_type) && !outgoing_message.indexed_by_search? + return false + end + return false if event_type == 'comment' && !comment.visible + return true + end + false + end + + def requested_by + info_request.user_name_slug + end + + def requested_from + # acts_as_xapian will detect translated fields via Globalize and add all the + # available locales to the index. But 'requested_from' is not translated directly, + # although it relies on a translated field in PublicBody. Hence, we need to + # manually add all the localized values to the index (Xapian can handle a list + # of values in a term, btw) + info_request.public_body.translations.map(&:url_name) + end + + def commented_by + if event_type == 'comment' + comment.user.url_name + else + '' + end + end + + def request_title_collapse + info_request.url_title(collapse: true) + end + + def described_at_numeric + # format it here as no datetime support in Xapian's value ranges + described_at.strftime("%Y%m%d%H%M%S") + end + + def created_at_numeric + # format it here as no datetime support in Xapian's value ranges + created_at.strftime("%Y%m%d%H%M%S") + end + + def waiting_classification + info_request.awaiting_description == true ? "yes" : "no" + end + + def latest_variety + sibling_events(reverse: true).each do |event| + return event.variety unless event.variety.blank? + end + end + + def latest_status + sibling_events(reverse: true).each do |event| + return event.calculated_state unless event.calculated_state.blank? + end + end + + def filetype + if event_type == 'response' + unless incoming_message + raise "event type is 'response' but no incoming message for event id #{id}" + end + + incoming_message.get_present_file_extensions + else + '' + end + end + + def request_public_body_tags + info_request.public_body.tag_array_for_search end end diff --git a/app/models/legislation.rb b/app/models/legislation.rb index 8665f47585..25c5a3be4b 100644 --- a/app/models/legislation.rb +++ b/app/models/legislation.rb @@ -42,7 +42,7 @@ def self.find!(key) legislation = find(key) return legislation if legislation - raise UnknownLegislation.new("Unknown legislation #{key}.") + raise UnknownLegislation, "Unknown legislation #{key}." end def self.keys @@ -76,9 +76,7 @@ def to_sym def to_s(variant = :short) @variants.fetch(variant) rescue KeyError - raise UnknownLegislationVariant.new( - "Unknown variant #{variant} in legislation #{key}." - ) + raise UnknownLegislationVariant, "Unknown variant #{variant} in legislation #{key}." end def ==(other) diff --git a/app/models/legislation/reference_collection.rb b/app/models/legislation/reference_collection.rb index 32644c34c0..d1a1ab79ac 100644 --- a/app/models/legislation/reference_collection.rb +++ b/app/models/legislation/reference_collection.rb @@ -30,13 +30,11 @@ def match(text) type = capture[0] parse_matches(capture[1]).each do |reference| - begin - references << Legislation::Reference.new( - legislation: legislation, reference: "#{type} #{reference}" - ) - rescue Legislation::InvalidReferenceType - # noop - end + references << Legislation::Reference.new( + legislation: legislation, reference: "#{type} #{reference}" + ) + rescue Legislation::InvalidReferenceType + # noop end references diff --git a/app/models/mail_server_log.rb b/app/models/mail_server_log.rb index 580b7b6915..2144d2aacf 100644 --- a/app/models/mail_server_log.rb +++ b/app/models/mail_server_log.rb @@ -24,9 +24,9 @@ class MailServerLog < ApplicationRecord serialize :delivery_status, DeliveryStatusSerializer belongs_to :info_request, - :inverse_of => :mail_server_logs + inverse_of: :mail_server_logs belongs_to :mail_server_log_done, - :inverse_of => :mail_server_logs + inverse_of: :mail_server_logs before_create :calculate_delivery_status @@ -40,7 +40,9 @@ def self.load_file(file_name) file_name_db = is_gz ? file_name.gsub(".gz", "") : file_name modified = File.stat(file_name).mtime - raise "MailServerLog.load_file: file not found " + file_name if modified.nil? + if modified.nil? + raise "MailServerLog.load_file: file not found " + file_name + end ActiveRecord::Base.transaction do # see if we already have it @@ -53,14 +55,14 @@ def self.load_file(file_name) MailServerLog.where("mail_server_log_done_id = ?", done.id).delete_all end else - done = MailServerLogDone.new(:filename => file_name_db) + done = MailServerLogDone.new(filename: file_name_db) end done.last_stat = modified # update done structure so we know when we last read this file done.save! f = is_gz ? Zlib::GzipReader.open(file_name) : File.open(file_name, 'r') - case(AlaveteliConfiguration::mta_log_type.to_sym) + case(AlaveteliConfiguration.mta_log_type.to_sym) when :exim load_exim_log_data(f, done) when :postfix @@ -76,7 +78,7 @@ def self.load_file(file_name) def self.load_exim_log_data(f, done) order = 0 f.each do |line| - order = order + 1 + order += 1 create_exim_log_line(line, done, order) end end @@ -88,9 +90,9 @@ def self.load_postfix_log_data(f, done) f.rewind f.each do |line| sanitised_line = scrub(line) - order = order + 1 + order += 1 queue_id = extract_postfix_queue_id_from_syslog_line(sanitised_line) - if emails.has_key?(queue_id) + if emails.key?(queue_id) create_mail_server_logs(emails[queue_id], sanitised_line, order, done) end end @@ -101,7 +103,7 @@ def self.scan_for_postfix_queue_ids(f) f.each do |line| emails = email_addresses_on_line(line) queue_id = extract_postfix_queue_id_from_syslog_line(line) - result[queue_id] = [] unless result.has_key?(queue_id) + result[queue_id] = [] unless result.key?(queue_id) result[queue_id] = (result[queue_id] + emails).uniq end result @@ -117,13 +119,13 @@ def self.extract_postfix_queue_id_from_syslog_line(line) # We also check the email prefix so that we could, for instance, separately handle a staging and production # instance running on the same server with different email prefixes. def self.email_addresses_on_line(line) - prefix = Regexp::quote(AlaveteliConfiguration::incoming_email_prefix) - domain = Regexp::quote(AlaveteliConfiguration::incoming_email_domain) + prefix = Regexp.quote(AlaveteliConfiguration.incoming_email_prefix) + domain = Regexp.quote(AlaveteliConfiguration.incoming_email_domain) line.scan(/#{prefix}request-[^\s]+@#{domain}/).sort.uniq end def self.request_sent?(ir) - case(AlaveteliConfiguration::mta_log_type.to_sym) + case(AlaveteliConfiguration.mta_log_type.to_sym) when :exim request_exim_sent?(ir) when :postfix @@ -230,37 +232,35 @@ def line(opts = {}) end def delivery_status - begin - unless attributes['delivery_status'].present? - # attempt to parse the status from the log line and store if successful - set_delivery_status - end - - DeliveryStatusSerializer.load(read_attribute(:delivery_status)) - # TODO: This rescue can be removed when there are no more cached - # MTA-specific statuses - rescue ArgumentError - warn %q(MailServerLog#delivery_status rescuing from invalid delivery - status. Run bundle exec rake temp:cache_delivery_status to update - cached values. This error handling will be removed soon.). - squish unless Rails.env.test? - - # re-try setting the delivery status, forcing the write by avoiding the - # Rails 4.2 call to old_attribute_value hidden inside write_attribute as - # that will re-raise the 'Invalid delivery status' ArgumentError we're - # attempting to rescue - # https://apidock.com/rails/v4.2.7/ActiveRecord/AttributeMethods/Dirty/write_attribute - set_delivery_status(true) - save! - DeliveryStatusSerializer.load(read_attribute(:delivery_status)) + unless attributes['delivery_status'].present? + # attempt to parse the status from the log line and store if successful + set_delivery_status end + + DeliveryStatusSerializer.load(read_attribute(:delivery_status)) + # TODO: This rescue can be removed when there are no more cached + # MTA-specific statuses + rescue ArgumentError + warn %q(MailServerLog#delivery_status rescuing from invalid delivery + status. Run bundle exec rake temp:cache_delivery_status to update + cached values. This error handling will be removed soon.). + squish unless Rails.env.test? + + # re-try setting the delivery status, forcing the write by avoiding the + # Rails 4.2 call to old_attribute_value hidden inside write_attribute as + # that will re-raise the 'Invalid delivery status' ArgumentError we're + # attempting to rescue + # https://apidock.com/rails/v4.2.7/ActiveRecord/AttributeMethods/Dirty/write_attribute + set_delivery_status(true) + save! + DeliveryStatusSerializer.load(read_attribute(:delivery_status)) end private # attempt to parse the status from the log line and store if successful def set_delivery_status(force = false) - decorated = line(:decorate => true) + decorated = line(decorate: true) if decorated && decorated.delivery_status if force force_delivery_status(decorated.delivery_status) @@ -291,10 +291,11 @@ def self.create_mail_server_logs(emails, line, order, done) if info_request info_request. mail_server_logs. - create!(:line => line, :order => order, :mail_server_log_done => done) + create!(line: line, order: order, mail_server_log_done: done) end end end + private_class_method :create_mail_server_logs def line_decorator mta = AlaveteliConfiguration.mta_log_type.to_sym diff --git a/app/models/mail_server_log/delivery_status.rb b/app/models/mail_server_log/delivery_status.rb index 3da8638d4d..b3ac1ed8fe 100644 --- a/app/models/mail_server_log/delivery_status.rb +++ b/app/models/mail_server_log/delivery_status.rb @@ -58,7 +58,7 @@ def capitalize end def inspect - obj_id = "0x00%x" % (object_id << 1) + obj_id = format("0x00%x", (object_id << 1)) %Q(#<#{self.class}:#{obj_id} @status=:#{ status }>) end diff --git a/app/models/mail_server_log/delivery_status/translated_constants.rb b/app/models/mail_server_log/delivery_status/translated_constants.rb index c0d9bca1e2..c0b21fcb9c 100644 --- a/app/models/mail_server_log/delivery_status/translated_constants.rb +++ b/app/models/mail_server_log/delivery_status/translated_constants.rb @@ -4,18 +4,18 @@ module TranslatedConstants def self.humanized # The order of these is important as we use the keys for sorting in #<=> { - :unknown => _("We don't know the delivery status for this message."), - :failed => _('This message could not be delivered.'), - :sent => _('This message has been sent.'), - :delivered => _('This message has been delivered.') + unknown: _("We don't know the delivery status for this message."), + failed: _('This message could not be delivered.'), + sent: _('This message has been sent.'), + delivered: _('This message has been delivered.') }.freeze end def self.to_s! - { :unknown => _('unknown'), - :failed => _('failed'), - :sent => _('sent'), - :delivered => _('delivered') }.freeze + { unknown: _('unknown'), + failed: _('failed'), + sent: _('sent'), + delivered: _('delivered') }.freeze end end diff --git a/app/models/mail_server_log/exim_line.rb b/app/models/mail_server_log/exim_line.rb index 46d8e93b21..bf54e23a01 100644 --- a/app/models/mail_server_log/exim_line.rb +++ b/app/models/mail_server_log/exim_line.rb @@ -68,7 +68,7 @@ def to_s end def inspect - %Q(#<#{self.class}:#{"0x00%x" % (object_id << 1)} @line="#{ line }">) + %Q(#<#{self.class}:#{format("0x00%x", (object_id << 1))} @line="#{ line }">) end private diff --git a/app/models/mail_server_log/postfix_line.rb b/app/models/mail_server_log/postfix_line.rb index 9aa0beb4c2..3c4d0625f7 100644 --- a/app/models/mail_server_log/postfix_line.rb +++ b/app/models/mail_server_log/postfix_line.rb @@ -55,7 +55,7 @@ def to_s end def inspect - %Q(#<#{self.class}:#{"0x00%x" % (object_id << 1)} @line="#{ line }">) + %Q(#<#{self.class}:#{format("0x00%x", (object_id << 1))} @line="#{ line }">) end private diff --git a/app/models/mail_server_log_done.rb b/app/models/mail_server_log_done.rb index 5982c5462e..cc65bcf376 100644 --- a/app/models/mail_server_log_done.rb +++ b/app/models/mail_server_log_done.rb @@ -17,5 +17,5 @@ class MailServerLogDone < ApplicationRecord has_many :mail_server_logs, - :inverse_of => :mail_server_log_done + inverse_of: :mail_server_log_done end diff --git a/app/models/notification.rb b/app/models/notification.rb index dc3cc7d024..e240251913 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -16,9 +16,9 @@ class Notification < ApplicationRecord belongs_to :info_request_event, - :inverse_of => :notifications + inverse_of: :notifications belongs_to :user, - :inverse_of => :notifications + inverse_of: :notifications INSTANTLY = :instantly DAILY = :daily @@ -32,9 +32,9 @@ class Notification < ApplicationRecord # Set the send_at timestamp based on the chosen frequency def calculate_send_after - unless self.persisted? || self.send_after.present? - if self.daily? - self.send_after = self.user.next_daily_summary_time + unless persisted? || send_after.present? + if daily? + self.send_after = user.next_daily_summary_time else self.send_after = Time.zone.now end @@ -46,10 +46,10 @@ def calculate_send_after def self.reject_and_mark_expired(notifications) expired_ids = notifications.select(&:expired).map(&:id) if expired_ids.empty? - return notifications + notifications else Notification.where(id: expired_ids).update_all(expired: true) - return notifications.reject { |n| expired_ids.include?(n.id) } + notifications.reject { |n| expired_ids.include?(n.id) } end end @@ -73,8 +73,8 @@ def response_expired def embargo_expiring_expired # If someone has changed the embargo date on the request, or published it, # they might not need this notification any more. - if (info_request_event.info_request.embargo_expiring? || - info_request_event.info_request.embargo_pending_expiry?) + if info_request_event.info_request.embargo_expiring? || + info_request_event.info_request.embargo_pending_expiry? false else true @@ -88,14 +88,14 @@ def expire_embargo_expired end def overdue_expired - info_request = self.info_request_event.info_request + info_request = info_request_event.info_request user = info_request.user status = info_request.calculate_status !(user.can_make_followup? && status == 'waiting_response_overdue') end def very_overdue_expired - info_request = self.info_request_event.info_request + info_request = info_request_event.info_request user = info_request.user status = info_request.calculate_status !(user.can_make_followup? && status == 'waiting_response_very_overdue') diff --git a/app/models/outgoing_message.rb b/app/models/outgoing_message.rb index 9bae5237e5..434384deb4 100644 --- a/app/models/outgoing_message.rb +++ b/app/models/outgoing_message.rb @@ -41,25 +41,25 @@ class OutgoingMessage < ApplicationRecord attr_accessor :default_letter validates_presence_of :info_request - validates_inclusion_of :status, :in => STATUS_TYPES - validates_inclusion_of :message_type, :in => MESSAGE_TYPES + validates_inclusion_of :status, in: STATUS_TYPES + validates_inclusion_of :message_type, in: MESSAGE_TYPES validate :template_changed validate :body_uses_mixed_capitals validate :body_has_signature validate :what_doing_value belongs_to :info_request, - :inverse_of => :outgoing_messages + inverse_of: :outgoing_messages belongs_to :incoming_message_followup, - :inverse_of => :outgoing_message_followups, - :foreign_key => 'incoming_message_followup_id', - :class_name => 'IncomingMessage' + inverse_of: :outgoing_message_followups, + foreign_key: 'incoming_message_followup_id', + class_name: 'IncomingMessage' # can have many events, for items which were resent by site admin e.g. if # contact address changed has_many :info_request_events, - :inverse_of => :outgoing_message, - :dependent => :destroy + inverse_of: :outgoing_message, + dependent: :destroy delegate :public_body, to: :info_request, private: true, allow_nil: true @@ -67,11 +67,11 @@ class OutgoingMessage < ApplicationRecord # reindex if body text is edited (e.g. by admin interface) after_update :xapian_reindex_after_update - strip_attributes :allow_empty => true + strip_attributes allow_empty: true admin_columns include: [:to, :from, :subject] - self.default_url_options[:host] = AlaveteliConfiguration.domain + default_url_options[:host] = AlaveteliConfiguration.domain scope :followup, -> { where(message_type: 'followup') } scope :is_searchable, -> { where(prominence: 'normal') } @@ -96,7 +96,7 @@ def self.additional_send_errors end def self.default_salutation(public_body) - _("Dear {{public_body_name}},", :public_body_name => public_body.name) + _("Dear {{public_body_name}},", public_body_name: public_body.name) end def self.fill_in_salutation(text, public_body) @@ -127,9 +127,7 @@ def get_default_message def set_signature_name(name) # We compare against raw_body as body strips linebreaks and applies # censor rules - if raw_body == get_default_message - self.body = get_default_message + name - end + self.body = get_default_message + name if raw_body == get_default_message end # Public: The value to be used in the From: header of an OutgoingMailer @@ -161,14 +159,14 @@ def subject if message_type == 'followup' if what_doing == 'internal_review' _("Internal review of {{email_subject}}", - :email_subject => info_request.email_subject_request(:html => false)) + email_subject: info_request.email_subject_request(html: false)) else info_request. - email_subject_followup(:incoming_message => incoming_message_followup, - :html => false) + email_subject_followup(incoming_message: incoming_message_followup, + html: false) end else - info_request.email_subject_request(:html => false) + info_request.email_subject_request(html: false) end end @@ -193,7 +191,7 @@ def body(options = {}) info_request.try(:applicable_censor_rules) or [] end - censor_rules.reduce(text) { |text, rule| rule.apply_to_text(text) } + censor_rules.reduce(text) { |t, rule| rule.apply_to_text(t) } end def raw_body @@ -237,7 +235,9 @@ def record_email_delivery(to_addrs, message_id, log_event_type = 'sent') self.status = 'sent' save! - log_event_type = "followup_#{ log_event_type }" if message_type == 'followup' + if message_type == 'followup' + log_event_type = "followup_#{ log_event_type }" + end info_request.log_event( log_event_type, @@ -251,9 +251,9 @@ def record_email_delivery(to_addrs, message_id, log_event_type = 'sent') def sendable? if status == 'ready' if message_type == 'initial_request' - return true + true elsif message_type == 'followup' - return true + true else raise "Message id #{id} has type '#{message_type}' which cannot be sent" end @@ -358,7 +358,7 @@ def get_text_for_indexing(strip_salutation = true, opts = {}) end # Remove email addresses from display/index etc. - self.remove_privacy_sensitive_things!(text) + remove_privacy_sensitive_things!(text) text end @@ -366,9 +366,9 @@ def get_text_for_indexing(strip_salutation = true, opts = {}) # Return body for display as HTML def get_body_for_html_display text = body.strip - self.remove_privacy_sensitive_things!(text) + remove_privacy_sensitive_things!(text) text = CGI.escapeHTML(text) - text = MySociety::Format.make_clickable(text, { :contract => 1, :nofollow => true }) + text = MySociety::Format.make_clickable(text, { contract: 1, nofollow: true }) text.gsub!(/\[(email address|mobile number)\]/, '[\1]') text = ActionController::Base.helpers.simple_format(text) text.html_safe @@ -382,7 +382,7 @@ def get_body_for_text_display def xapian_reindex_after_update return unless saved_change_to_attribute?(:body) - info_request_events.find_each { |event| event.xapian_mark_needs_index } + info_request_events.find_each(&:xapian_mark_needs_index) end def default_letter=(text) @@ -480,7 +480,7 @@ def template_regex(template_text) def body_has_signature if raw_body =~ /#{template_regex(letter_template.signoff(default_message_replacements))}\s*\Z/m - errors.add(:body, _("Please sign at the bottom with your name, or alter the \"{{signoff}}\" signature", :signoff => letter_template.signoff(default_message_replacements))) + errors.add(:body, _("Please sign at the bottom with your name, or alter the \"{{signoff}}\" signature", signoff: letter_template.signoff(default_message_replacements))) end end @@ -517,7 +517,7 @@ def exim_mail_server_logs end smarthost_mta_ids = logs.flat_map do |log| - line = log.line(:decorate => true) + line = log.line(decorate: true) if line.delivery_status.try(:delivered?) match = line.to_s.match(/C=".*?id=(?\w+-\w+-\w+).*"/) match[:message_id] if match diff --git a/app/models/outgoing_message/snippet.rb b/app/models/outgoing_message/snippet.rb index 7b7bc68b83..51dabd3fbe 100644 --- a/app/models/outgoing_message/snippet.rb +++ b/app/models/outgoing_message/snippet.rb @@ -29,7 +29,7 @@ def self.admin_title end OutgoingMessage::Snippet::Translation.class_eval do - with_options if: lambda { |t| !t.default_locale? && t.required_attribute_submitted? } do |required| + with_options if: ->(t) { !t.default_locale? && t.required_attribute_submitted? } do |required| required.validates :name, :body, presence: true end diff --git a/app/models/outgoing_message/template/batch_request.rb b/app/models/outgoing_message/template/batch_request.rb index bfaab7962d..223f890190 100644 --- a/app/models/outgoing_message/template/batch_request.rb +++ b/app/models/outgoing_message/template/batch_request.rb @@ -9,7 +9,7 @@ def body(opts = {}) template_string(opts) end - def salutation(replacements = {}) + def salutation(_replacements = {}) self.class.placeholder_salutation end diff --git a/app/models/outgoing_message/template/incoming_message_followup.rb b/app/models/outgoing_message/template/incoming_message_followup.rb index 20f37b946e..7a66eac326 100644 --- a/app/models/outgoing_message/template/incoming_message_followup.rb +++ b/app/models/outgoing_message/template/incoming_message_followup.rb @@ -34,7 +34,7 @@ def template_string(replacements) def assert_required_keys(hash, *required_keys) required_keys.each do |required_key| - unless hash.has_key?(required_key) + unless hash.key?(required_key) raise ArgumentError, "Missing required key: #{required_key}" end end diff --git a/app/models/outgoing_message/template/initial_request.rb b/app/models/outgoing_message/template/initial_request.rb index 48380f0a0d..fbc9d44ba4 100644 --- a/app/models/outgoing_message/template/initial_request.rb +++ b/app/models/outgoing_message/template/initial_request.rb @@ -8,7 +8,7 @@ def body(opts = {}) def self.placeholder_salutation _('Dear {{placeholder_body_name}},', - placeholder_body_name: self.placeholder_body_name) + placeholder_body_name: placeholder_body_name) end # Separate so that it can be referred to directly elsewhere (e.g. to @@ -49,7 +49,7 @@ def template_string(replacements) def assert_required_keys(hash, *required_keys) required_keys.each do |required_key| - unless hash.has_key?(required_key) + unless hash.key?(required_key) raise ArgumentError, "Missing required key: #{required_key}" end end diff --git a/app/models/outgoing_message/template/internal_review.rb b/app/models/outgoing_message/template/internal_review.rb index 83f4d11948..b0d9f140e5 100644 --- a/app/models/outgoing_message/template/internal_review.rb +++ b/app/models/outgoing_message/template/internal_review.rb @@ -56,7 +56,7 @@ def template_string(replacements) def assert_required_keys(hash, *required_keys) required_keys.each do |required_key| - unless hash.has_key?(required_key) + unless hash.key?(required_key) raise ArgumentError, "Missing required key: #{required_key}" end end diff --git a/app/models/post_redirect.rb b/app/models/post_redirect.rb index ac7e8fe863..42fafa59bc 100644 --- a/app/models/post_redirect.rb +++ b/app/models/post_redirect.rb @@ -34,9 +34,9 @@ class PostRedirect < ApplicationRecord # Optional, does a login confirm before redirect for use in email links. belongs_to :user, - :inverse_of => :post_redirects + inverse_of: :post_redirects - validates :circumstance, :inclusion => CIRCUMSTANCES + validates :circumstance, inclusion: CIRCUMSTANCES after_initialize :generate_token after_initialize :generate_email_token @@ -70,7 +70,19 @@ def post_params=(params) def post_params return {} if post_params_yaml.nil? - YAML.load(post_params_yaml) + + if RUBY_VERSION < "3.1" + YAML.load(post_params_yaml) + else + YAML.load( + post_params_yaml, + permitted_classes: [ + ActionController::Parameters, + ActiveSupport::HashWithIndifferentAccess, + Symbol + ] + ) + end end # We store YAML version of textual "reason for redirect" parameters @@ -81,7 +93,9 @@ def reason_params=(reason_params) def reason_params param_hash = YAML.load(reason_params_yaml) param_hash.each do |key, value| - param_hash[key] = value.force_encoding('UTF-8') if value.respond_to?(:force_encoding) + if value.respond_to?(:force_encoding) + param_hash[key] = value.force_encoding('UTF-8') + end end param_hash end diff --git a/app/models/pro_account.rb b/app/models/pro_account.rb index aabe7974de..32633e6440 100644 --- a/app/models/pro_account.rb +++ b/app/models/pro_account.rb @@ -17,7 +17,7 @@ class ProAccount < ApplicationRecord attr_writer :source belongs_to :user, - :inverse_of => :pro_account + inverse_of: :pro_account validates :user, presence: true diff --git a/app/models/profile_photo.rb b/app/models/profile_photo.rb index 65559da8c7..0f70ad2578 100644 --- a/app/models/profile_photo.rb +++ b/app/models/profile_photo.rb @@ -25,14 +25,14 @@ class ProfilePhoto < ApplicationRecord MAX_DRAFT = 500 # keep even pre-cropped images reasonably small belongs_to :user, - :inverse_of => :profile_photo + inverse_of: :profile_photo validate :data_and_draft_checks attr_accessor :x, :y, :w, :h attr_accessor :image - after_initialize :convert_data_to_image + before_validation :convert_data_to_image # make image valid format and size def convert_image @@ -42,16 +42,14 @@ def convert_image # convert to PNG if it isn't, and to right size altered = false if image.type != 'PNG' - self.image.format('PNG') + image.format('PNG') altered = true end # draft images are before the user has cropped them if !draft && (image.width != WIDTH || image.height != HEIGHT) # do any exact cropping (taken from Jcrop interface) - if w && h - image.crop("#{ w }x#{ h }+#{ x }+#{ y }") - end + image.crop("#{ w }x#{ h }+#{ x }+#{ y }") if w && h # do any further cropping # resize_to_fill! image.combine_options do |c| @@ -69,9 +67,7 @@ def convert_image altered = true end - if altered - self.data = image.to_blob - end + self.data = image.to_blob if altered end private @@ -93,19 +89,17 @@ def data_and_draft_checks if !draft && (image.width != WIDTH || image.height != HEIGHT) errors.add(:data, _("Failed to convert image to the correct size: at {{cols}}x{{rows}}, need {{width}}x{{height}}", - :cols => image.width, - :rows => image.height, - :width => WIDTH, - :height => HEIGHT)) + cols: image.width, + rows: image.height, + width: WIDTH, + height: HEIGHT)) end if draft && user_id raise "Internal error, draft pictures must not have a user" end - if !draft && !user_id - raise "Internal error, real pictures must have a user" - end + raise "Internal error, real pictures must have a user" if !draft && !user_id end # Convert binary data blob into ImageMagick image when assigned diff --git a/app/models/project/export.rb b/app/models/project/export.rb index dcbfc50107..22cbed4cc4 100644 --- a/app/models/project/export.rb +++ b/app/models/project/export.rb @@ -14,7 +14,7 @@ def initialize(project) end def data - @data ||= project.info_requests.extracted.map do |info_request| + @data ||= project.info_requests.map do |info_request| Project::Export::InfoRequest.new(project, info_request).data end end diff --git a/app/models/project/info_request_extension.rb b/app/models/project/info_request_extension.rb index 42dba46a63..750801ec1c 100644 --- a/app/models/project/info_request_extension.rb +++ b/app/models/project/info_request_extension.rb @@ -16,13 +16,28 @@ def classified def extractable where(described_state: EXTRACTABLE_STATES). - left_joins(:extraction_project_submissions). + joins( + <<~SQL.squish + LEFT OUTER JOIN "project_submissions" ON + "project_submissions"."resource_type" = 'Dataset::ValueSet' AND + "project_submissions"."info_request_id" = "info_requests"."id" AND + "project_submissions"."project_id" = #{project.id} + SQL + ). where(project_submissions: { id: nil }). classified end def extracted - joins(:extraction_project_submissions).distinct + joins(:extraction_project_submissions). + where(project_submissions: { project: project }). + distinct + end + + private + + def project + proxy_association.owner end end end diff --git a/app/models/project/leaderboard.rb b/app/models/project/leaderboard.rb new file mode 100644 index 0000000000..afa5a2a5f4 --- /dev/null +++ b/app/models/project/leaderboard.rb @@ -0,0 +1,58 @@ +## +# Export a project's leaderboard of classifications and data extractions to CSV. +# +class Project::Leaderboard + include DownloadHelper + + attr_reader :project + protected :project + + def initialize(project) + @project = project + end + + def all_time + @leaderboard_all_time ||= data.first(5) + end + + def twenty_eight_days + @leaderboard_28_days ||= data( + project.submissions.where(created_at: 28.days.ago..) + ).first(5) + end + + def name + generate_download_filename( + resource: 'project-leaderboard', + id: project.id, + title: project.title, + ext: 'csv' + ) + end + + def to_csv + CSV.generate do |csv| + header = data.first + csv << header.keys.map(&:to_s) if header + data.each do |row| + row[:user] = row[:user].name + csv << row.values + end + end + end + + private + + def data(scope = project.submissions) + leaderboard = project.members.map do |user| + user_scope = scope.where(user_id: user.id) + { + user: user, + classifications: user_scope.classification.size, + extractions: user_scope.extraction.size, + total_contributions: user_scope.size + } + end + leaderboard.sort_by { |row| row[:total_contributions] }.reverse + end +end diff --git a/app/models/public_body.rb b/app/models/public_body.rb index a8bd7c005d..8ec9dd5bcf 100644 --- a/app/models/public_body.rb +++ b/app/models/public_body.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 20220210114052 +# Schema version: 20230209094128 # # Table name: public_bodies # @@ -22,7 +22,6 @@ # short_name :text # request_email :text # url_name :text -# notes :text # first_letter :string # publication_scheme :text # disclosure_log :text @@ -57,52 +56,52 @@ def self.admin_title ['publication_scheme', '(i18n)'], ['disclosure_log', '(i18n)'], ['home_page', ''], - ['tag_string', '(tags separated by spaces)'], + ['tag_string', '(tags separated by spaces)'] ] end has_many :info_requests, -> { order(created_at: :desc) }, - :inverse_of => :public_body + inverse_of: :public_body has_many :track_things, -> { order(created_at: :desc) }, - :inverse_of => :public_body, - :dependent => :destroy + inverse_of: :public_body, + dependent: :destroy has_many :censor_rules, -> { order(created_at: :desc) }, - :inverse_of => :public_body, - :dependent => :destroy + inverse_of: :public_body, + dependent: :destroy has_many :track_things_sent_emails, -> { order(created_at: :desc) }, - :inverse_of => :public_body, - :dependent => :destroy + inverse_of: :public_body, + dependent: :destroy has_many :public_body_change_requests, -> { order(created_at: :desc) }, - :inverse_of => :public_body, - :dependent => :destroy + inverse_of: :public_body, + dependent: :destroy has_many :draft_info_requests, -> { order(created_at: :desc) }, - :inverse_of => :public_body + inverse_of: :public_body has_and_belongs_to_many :info_request_batches, - :inverse_of => :public_bodies + inverse_of: :public_bodies has_and_belongs_to_many :draft_info_request_batches, - :class_name => 'AlaveteliPro::DraftInfoRequestBatch', - :inverse_of => :public_bodies + class_name: 'AlaveteliPro::DraftInfoRequestBatch', + inverse_of: :public_bodies - validates_presence_of :name, :message => N_("Name can't be blank") - validates_presence_of :url_name, :message => N_("URL name can't be blank") + validates_presence_of :name, message: N_("Name can't be blank") + validates_presence_of :url_name, message: N_("URL name can't be blank") validates_presence_of :last_edit_editor, - :message => N_("Last edit editor can't be blank") + message: N_("Last edit editor can't be blank") validates :request_email, not_nil: { message: N_("Request email can't be nil") } validates_uniqueness_of :short_name, - :message => N_("Short name is already taken"), - :allow_blank => true - validates_uniqueness_of :url_name, :message => N_("URL name is already taken") - validates_uniqueness_of :name, :message => N_("Name is already taken") + message: N_("Short name is already taken"), + allow_blank: true + validates_uniqueness_of :url_name, message: N_("URL name is already taken") + validates_uniqueness_of :name, message: N_("Name is already taken") validates :last_edit_editor, length: { maximum: 255, @@ -111,7 +110,7 @@ def self.admin_title validate :request_email_if_requestable - before_save :set_api_key!, :unless => :api_key + before_save :set_api_key!, unless: :api_key after_save :update_missing_email_tag @@ -121,22 +120,23 @@ def self.admin_title scope :visible, -> { where("public_bodies.id <> #{ PublicBody.internal_admin_body.id }") } acts_as_versioned - acts_as_xapian :texts => [:name, :short_name, :notes_as_string], - :values => [ + acts_as_xapian texts: [:name, :short_name, :notes_as_string], + values: [ # for sorting [:created_at_numeric, 1, "created_at", :number] ], - :terms => [ + terms: [ [:name_for_search, 'N', 'name'], [:variety, 'V', "variety"], [:tag_array_for_search, 'U', "tag"] ], - :eager_load => [:translations] + eager_load: [:translations] strip_attributes allow_empty: false, except: %i[request_email] strip_attributes allow_empty: true, only: %i[request_email] - translates :name, :short_name, :request_email, :url_name, :notes, :first_letter, :publication_scheme + translates :name, :short_name, :request_email, :url_name, :first_letter, + :publication_scheme # Cannot be grouped at top as it depends on the `translates` macro include Translatable @@ -151,11 +151,11 @@ class Translation strip_attributes allow_empty: true, only: %i[request_email] end - self.non_versioned_columns << 'created_at' << 'updated_at' << 'first_letter' << 'api_key' - self.non_versioned_columns << 'info_requests_count' << 'info_requests_successful_count' - self.non_versioned_columns << 'info_requests_count' << 'info_requests_visible_classified_count' - self.non_versioned_columns << 'info_requests_not_held_count' << 'info_requests_overdue' - self.non_versioned_columns << 'info_requests_overdue_count' << 'info_requests_visible_count' + non_versioned_columns << 'created_at' << 'updated_at' << 'first_letter' << 'api_key' + non_versioned_columns << 'info_requests_count' << 'info_requests_successful_count' + non_versioned_columns << 'info_requests_count' << 'info_requests_visible_classified_count' + non_versioned_columns << 'info_requests_not_held_count' << 'info_requests_overdue' + non_versioned_columns << 'info_requests_overdue_count' << 'info_requests_visible_count' # Cannot be defined directly under `include` statements as this is opening # the PublicBody::Version class dynamically defined by the @@ -187,14 +187,13 @@ def copy_translated_attributes end def last_edit_comment_for_html_display - text = self.last_edit_comment.strip + text = last_edit_comment.strip text = CGI.escapeHTML(text) text = MySociety::Format.make_clickable(text) - text = text.gsub(/\n/, '
') - return text + text.gsub(/\n/, '
') end - def compare(previous = nil, &block) + def compare(previous = nil) if previous.nil? changes = [] else @@ -206,10 +205,10 @@ def compare(previous = nil, &block) created_at updated_at).include?(c.name) from = previous.send(c.name) - to = self.send(c.name) - memo << { :name => c.name.humanize, - :from => from, - :to => to } if from != to + to = send(c.name) + memo << { name: c.name.humanize, + from: from, + to: to } if from != to end memo } @@ -292,13 +291,15 @@ def self.find_by_url_name_with_historic(name) # If none found, then search the history of short names and find unique # public bodies in it old = PublicBody::Version. - where(:url_name => name). + where(url_name: name). distinct. pluck(:public_body_id) # Maybe return the first one, so we show something relevant, # rather than throwing an error? - raise "Two bodies with the same historical URL name: #{name}" if old.size > 1 + if old.size > 1 + raise "Two bodies with the same historical URL name: #{name}" + end return unless old.size == 1 # does acts_as_versioned provide a method that returns the current version? PublicBody.find(old.first) @@ -406,7 +407,7 @@ def legislation # in an instance variable def calculated_home_page if home_page && !home_page.empty? - home_page[URI::regexp(%w(http https))] ? home_page : "http://#{home_page}" + home_page[URI.regexp(%w(http https))] ? home_page : "http://#{home_page}" elsif request_email_domain "http://www.#{request_email_domain}" end @@ -421,8 +422,8 @@ def self.internal_admin_body if matching_pbs.empty? # "internal admin" exists but has the wrong default locale - fix & return - if invalid_locale = PublicBody::Translation. - find_by_url_name('internal_admin_authority') + if (invalid_locale = PublicBody::Translation. + find_by_url_name('internal_admin_authority')) found_pb = PublicBody.find(invalid_locale.public_body_id) AlaveteliLocalization. with_locale(AlaveteliLocalization.default_locale) do @@ -435,15 +436,13 @@ def self.internal_admin_body AlaveteliLocalization. with_locale(AlaveteliLocalization.default_locale) do default_scoped. - create!(:name => 'Internal admin authority', - :short_name => "", - :request_email => AlaveteliConfiguration.contact_email, - :home_page => nil, - :notes => nil, - :publication_scheme => nil, - :last_edit_editor => "internal_admin", - :last_edit_comment => - "Made by PublicBody.internal_admin_body") + create!(name: 'Internal admin authority', + short_name: "", + request_email: AlaveteliConfiguration.contact_email, + home_page: nil, + publication_scheme: nil, + last_edit_editor: "internal_admin", + last_edit_comment: "Made by PublicBody.internal_admin_body") end end elsif matching_pbs.length == 1 @@ -484,7 +483,7 @@ def self.import_csv_from_file(csv_filename, tag, tag_behaviour, dry_run, editor, AlaveteliLocalization. with_locale(AlaveteliLocalization.default_locale) do bodies = (tag.nil? || tag.empty?) ? PublicBody.includes(:translations) : PublicBody.find_by_tag(tag) - for existing_body in bodies + bodies.each do |existing_body| # Hide InternalAdminBody from import notes next if existing_body.id == internal_admin_body_id @@ -498,19 +497,19 @@ def self.import_csv_from_file(csv_filename, tag, tag_behaviour, dry_run, editor, field_names = { 'name' => 1, 'request_email' => 2 } line = 0 - import_options = {:field_names => field_names, - :available_locales => available_locales, - :tag => tag, - :tag_behaviour => tag_behaviour, - :editor => editor, - :notes => notes, - :errors => errors } + import_options = {field_names: field_names, + available_locales: available_locales, + tag: tag, + tag_behaviour: tag_behaviour, + editor: editor, + notes: notes, + errors: errors } CSV.foreach(csv_filename) do |row| - line = line + 1 + line += 1 # Parse the first line as a field list if it starts with '#' - if line==1 and row.first.to_s =~ /^#(.*)$/ + if (line==1) && row.first.to_s =~(/^#(.*)$/) row[0] = row[0][1..-1] # Remove the # sign on first field row.each_with_index { |field, i| field_names[field] = i } next @@ -529,13 +528,13 @@ def self.import_csv_from_file(csv_filename, tag, tag_behaviour, dry_run, editor, email.strip! unless email.nil? if !email.nil? && !email.empty? && !MySociety::Validate.is_valid_email(email) - errors.push "error: line #{line.to_s}: invalid email '#{email}' for authority '#{name}'" + errors.push "error: line #{line}: invalid email '#{email}' for authority '#{name}'" next end - public_body = bodies_by_name[name] || PublicBody.new(:name => "", - :short_name => "", - :request_email => "") + public_body = bodies_by_name[name] || PublicBody.new(name: "", + short_name: "", + request_email: "") public_body.import_values_from_csv_row(row, line, name, import_options) set_of_importing.add(name) @@ -543,20 +542,18 @@ def self.import_csv_from_file(csv_filename, tag, tag_behaviour, dry_run, editor, # Give an error listing ones that are to be deleted deleted_ones = set_of_existing - set_of_importing - if deleted_ones.size > 0 + if !deleted_ones.empty? notes.push "Notes: Some " + tag + " bodies are in database, but not in CSV file:\n " + Array(deleted_ones).sort.join("\n ") + "\nYou may want to delete them manually.\n" end # Rollback if a dry run, or we had errors - if dry_run or errors.size > 0 - raise ImportCSVDryRun - end + raise ImportCSVDryRun if dry_run || (!errors.empty?) end rescue ImportCSVDryRun # Ignore end - return [errors, notes] + [errors, notes] end def self.localized_csv_field_name(locale, field_name) @@ -571,11 +568,11 @@ def self.localized_csv_field_name(locale, field_name) def import_values_from_csv_row(row, line, name, options) is_new = new_record? edit_info = if is_new - { :action => "creating new authority", - :comment => 'Created from spreadsheet' } + { action: "creating new authority", + comment: 'Created from spreadsheet' } else - { :action => "updating authority", - :comment => 'Updated from spreadsheet' } + { action: "updating authority", + comment: 'Updated from spreadsheet' } end locales = options[:available_locales] locales = [AlaveteliLocalization.default_locale] if locales.empty? @@ -606,7 +603,7 @@ def import_values_from_csv_row(row, line, name, options) def set_locale_fields_from_csv_row(is_new, locale, row, options) changed = ActiveSupport::OrderedHash.new csv_field_names = options[:field_names] - csv_import_fields.each do |field_name, field_notes| + csv_import_fields.each do |field_name, _field_notes| localized_field_name = self.class.localized_csv_field_name(locale, field_name) column = csv_field_names[localized_field_name] value = column && row[column] @@ -658,7 +655,7 @@ def request_email_domain PublicBody.extract_domain_from_email(request_email) end - alias_method :foi_officer_domain_required, :request_email_domain + alias foi_officer_domain_required request_email_domain # Return the canonicalised domain part of an email address # @@ -669,59 +666,46 @@ def self.extract_domain_from_email(email) end def notes - [legacy_note].compact + all_notes + all_notes end def notes_as_string notes.map(&:body).join(' ') end - def legacy_note - return unless read_attribute(:notes).present? - - Note.new(notable: self) do |note| - AlaveteliLocalization.available_locales.each do |locale| - AlaveteliLocalization.with_locale(locale) do - note.body = read_attribute(:notes) - end - end - end - end - def has_notes? notes.present? end def json_for_api { - :id => id, - :url_name => url_name, - :name => name, - :short_name => short_name, + id: id, + url_name: url_name, + name: name, + short_name: short_name, # :request_email # we hide this behind a captcha, to stop people # doing bulk requests easily - :created_at => created_at, - :updated_at => updated_at, + created_at: created_at, + updated_at: updated_at, # don't add the history as some edit comments contain sensitive # information # :version, :last_edit_editor, :last_edit_comment - :home_page => calculated_home_page, - :notes => notes_as_string, - :publication_scheme => publication_scheme.to_s, - :tags => tag_array, - :info => { - :requests_count => info_requests_count, - :requests_successful_count => info_requests_successful_count, - :requests_not_held_count => info_requests_not_held_count, - :requests_overdue_count => info_requests_overdue_count, - :requests_visible_classified_count => - info_requests_visible_classified_count - }, + home_page: calculated_home_page, + notes: notes_as_string, + publication_scheme: publication_scheme.to_s, + tags: tag_array, + info: { + requests_count: info_requests_count, + requests_successful_count: info_requests_successful_count, + requests_not_held_count: info_requests_not_held_count, + requests_overdue_count: info_requests_overdue_count, + requests_visible_classified_count: info_requests_visible_classified_count + } } end def expire_requests - info_requests.find_each(&:expire) + InfoRequestExpireJob.perform_later(self, :info_requests) end def self.where_clause_for_stats(minimum_requests, total_column) @@ -747,8 +731,8 @@ def self.get_request_totals(n, highest, minimum_requests) limit(n). to_a public_bodies.reverse! if highest - y_values = public_bodies.map { |pb| pb.info_requests_visible_count } - return { + y_values = public_bodies.map(&:info_requests_visible_count) + { 'public_bodies' => public_bodies, 'y_values' => y_values, 'y_max' => y_values.max, @@ -795,7 +779,7 @@ def self.get_request_percentages(column, n, highest, minimum_requests) [y_values, cis_below, cis_above].each { |l| l.map! { |v| 100 * v } } - return { + { 'public_bodies' => public_bodies, 'y_values' => y_values, 'cis_below' => cis_below, @@ -828,7 +812,7 @@ def self.popular_bodies(locale) joins(:translations) end end - return bodies + bodies end class << self @@ -858,7 +842,7 @@ def self.with_query(query, tag) first_letter: tag } - if AlaveteliConfiguration::public_body_list_fallback_to_default_locale + if AlaveteliConfiguration.public_body_list_fallback_to_default_locale # Unfortunately, when we might fall back to the # default locale, this is a rather complex query: if DatabaseCollation.supports?(underscore_locale) @@ -951,8 +935,8 @@ def read_attribute_value(name, locale) def request_email_if_requestable # Request_email can be blank, meaning we don't have details - if self.is_requestable? - unless MySociety::Validate.is_valid_email(self.request_email) + if is_requestable? + unless MySociety::Validate.is_valid_email(request_email) errors.add(:request_email, "Request email doesn't look like a valid email address") end @@ -966,16 +950,12 @@ def name_for_search def self.get_public_body_list_translated_condition(table, has_first_letter=false, locale=nil) result = "(upper(#{table}.name) LIKE upper(:query)" \ - " OR upper(#{table}.notes) LIKE upper(:query)" \ - " OR upper(#{table}.short_name) LIKE upper(:query))" - if has_first_letter - result += " AND #{table}.first_letter = :first_letter" - end - if locale - result += " AND #{table}.locale = :locale" - end + " OR upper(#{table}.short_name) LIKE upper(:query))" + result += " AND #{table}.first_letter = :first_letter" if has_first_letter + result += " AND #{table}.locale = :locale" if locale result end + private_class_method :get_public_body_list_translated_condition def update_missing_email_tag if missing_email? && !defunct? diff --git a/app/models/public_body_category/category_collection.rb b/app/models/public_body_category/category_collection.rb index c8b36a96f7..31adbd82ca 100644 --- a/app/models/public_body_category/category_collection.rb +++ b/app/models/public_body_category/category_collection.rb @@ -47,9 +47,7 @@ def by_heading def headings output = [] @categories.each do |row| - unless row.is_a?(Array) - output << row - end + output << row unless row.is_a?(Array) end output end diff --git a/app/models/public_body_change_request.rb b/app/models/public_body_change_request.rb index ff652a104a..16bd3f87dc 100644 --- a/app/models/public_body_change_request.rb +++ b/app/models/public_body_change_request.rb @@ -19,22 +19,22 @@ class PublicBodyChangeRequest < ApplicationRecord belongs_to :user, - :inverse_of => :public_body_change_requests, - :counter_cache => true + inverse_of: :public_body_change_requests, + counter_cache: true belongs_to :public_body, - :inverse_of => :public_body_change_requests + inverse_of: :public_body_change_requests validates_presence_of :public_body_name, - :message => N_("Please enter the name of the authority"), - :unless => proc { |change_request| change_request.public_body } + message: N_("Please enter the name of the authority"), + unless: proc { |change_request| change_request.public_body } validates_presence_of :user_name, - :message => N_("Please enter your name"), - :unless => proc { |change_request| change_request.user } + message: N_("Please enter your name"), + unless: proc { |change_request| change_request.user } validates_presence_of :user_email, - :message => N_("Please enter your email address"), - :unless => proc { |change_request| change_request.user } - validate :user_email_format, :unless => proc { |change_request| change_request.user_email.blank? } - validate :body_email_format, :unless => proc { |change_request| change_request.public_body_email.blank? } + message: N_("Please enter your email address"), + unless: proc { |change_request| change_request.user } + validate :user_email_format, unless: proc { |change_request| change_request.user_email.blank? } + validate :body_email_format, unless: proc { |change_request| change_request.public_body_email.blank? } scope :new_body_requests, -> { where(public_body_id: nil).order(:created_at) @@ -105,7 +105,7 @@ def thanks_notice _("Your request to update the address for {{public_body_name}} has " \ "been sent. Thank you for getting in touch! We'll get back to you " \ "soon.", - :public_body_name => get_public_body_name) + public_body_name: get_public_body_name) end end @@ -118,22 +118,18 @@ def send_response(subject, response) def comment_for_public_body comments = ["Requested by: #{get_user_name} (#{get_user_email})"] - if !source_url.blank? - comments << "Source URL: #{source_url}" - end - if !notes.blank? - comments << "Notes: #{notes}" - end + comments << "Source URL: #{source_url}" unless source_url.blank? + comments << "Notes: #{notes}" unless notes.blank? comments.join("\n") end def request_subject if add_body_request? _("Add authority - {{public_body_name}}", - :public_body_name => public_body_name.html_safe).to_str + public_body_name: public_body_name.html_safe).to_str else _("Update email address - {{public_body_name}}", - :public_body_name => public_body.name.html_safe).to_str + public_body_name: public_body.name.html_safe).to_str end end @@ -143,19 +139,19 @@ def default_response_subject def close! self.is_open = false - self.save! + save! end private def body_email_format - unless MySociety::Validate.is_valid_email(self.public_body_email) + unless MySociety::Validate.is_valid_email(public_body_email) errors.add(:public_body_email, _("The authority email doesn't look like a valid address")) end end def user_email_format - unless MySociety::Validate.is_valid_email(self.user_email) + unless MySociety::Validate.is_valid_email(user_email) errors.add(:user_email, _("Your email doesn't look like a valid address")) end end diff --git a/app/models/public_body_heading.rb b/app/models/public_body_heading.rb index 2ba476523b..95b9d0d73a 100644 --- a/app/models/public_body_heading.rb +++ b/app/models/public_body_heading.rb @@ -45,7 +45,7 @@ def add_category(category) end def self.next_display_order - if max = maximum(:display_order) + if (max = maximum(:display_order)) max + 1 else 0 diff --git a/app/models/raw_email.rb b/app/models/raw_email.rb index b181804024..e428acb02c 100644 --- a/app/models/raw_email.rb +++ b/app/models/raw_email.rb @@ -18,12 +18,10 @@ class RawEmail < ApplicationRecord # deliberately don't strip_attributes, so keeps raw email properly has_one :incoming_message, - :inverse_of => :raw_email + inverse_of: :raw_email has_one_attached :file, service: :raw_emails - before_destroy :destroy_file_representation! - delegate :date, to: :mail delegate :message_id, to: :mail delegate :multipart?, to: :mail @@ -66,7 +64,7 @@ def valid_to_reply_to? end def empty_from_field? - mail.from_addrs.nil? || mail.from_addrs.size == 0 + mail.from_addrs.nil? || mail.from_addrs.empty? end def mail @@ -91,9 +89,9 @@ def data end def data_as_text - data.encode("UTF-8", :invalid => :replace, - :undef => :replace, - :replace => "") + data.encode("UTF-8", invalid: :replace, + undef: :replace, + replace: "") end def from_name @@ -129,8 +127,4 @@ def request_id def incoming_message_id incoming_message.id.to_s end - - def destroy_file_representation! - file.purge if file.attached? - end end diff --git a/app/models/request_classification.rb b/app/models/request_classification.rb index bfce22be80..32b3b07173 100644 --- a/app/models/request_classification.rb +++ b/app/models/request_classification.rb @@ -12,15 +12,15 @@ class RequestClassification < ApplicationRecord MILESTONES = [ - 100, 250, 500, 1000, 2500, 5000, 10000, 25000, 50000, 75000, 100000, - 250000, 500000, 750000, 1000000 + 100, 250, 500, 1000, 2500, 5000, 10_000, 25_000, 50_000, 75_000, 100_000, + 250_000, 500_000, 750_000, 1_000_000 ].freeze belongs_to :user, - :inverse_of => :request_classifications, - :counter_cache => true + inverse_of: :request_classifications, + counter_cache: true belongs_to :info_request_event, - :inverse_of => :request_classification + inverse_of: :request_classification # return classification instances representing the top n # users, with a 'cnt' attribute representing the number diff --git a/app/models/track_thing.rb b/app/models/track_thing.rb index eae54f40b0..4c1aa88755 100644 --- a/app/models/track_thing.rb +++ b/app/models/track_thing.rb @@ -30,34 +30,34 @@ class TrackThing < ApplicationRecord TRACK_MEDIUMS = %w(email_daily feed) belongs_to :info_request, - :inverse_of => :track_things + inverse_of: :track_things belongs_to :public_body, - :inverse_of => :track_things + inverse_of: :track_things belongs_to :tracking_user, - :class_name => 'User', - :inverse_of => :track_things, - :counter_cache => true + class_name: 'User', + inverse_of: :track_things, + counter_cache: true belongs_to :tracked_user, - :class_name => 'User', - :inverse_of => :track_things + class_name: 'User', + inverse_of: :track_things has_many :track_things_sent_emails, - :inverse_of => :track_thing, - :dependent => :destroy + inverse_of: :track_thing, + dependent: :destroy - validates_presence_of :track_query, :message => _("Query can't be blank") + validates_presence_of :track_query, message: _("Query can't be blank") validates_presence_of :track_type validates_inclusion_of :track_type, - :in => TranslatedConstants.track_types.keys - validates_inclusion_of :track_medium, :in => TRACK_MEDIUMS - validates_length_of :track_query, :maximum => 500, :message => _("Query is too long") + in: TranslatedConstants.track_types.keys + validates_inclusion_of :track_medium, in: TRACK_MEDIUMS + validates_length_of :track_query, maximum: 500, message: _("Query is too long") # When constructing a new track, use this to avoid duplicates / double # posting def self.find_existing(tracking_user, track) return nil if tracking_user.nil? - where(:tracking_user_id => tracking_user.id, - :track_query => track.track_query, - :track_type => track.track_type).first + where(tracking_user_id: tracking_user.id, + track_query: track.track_query, + track_type: track.track_type).first end def self.track_type_description(track_type) @@ -66,19 +66,19 @@ def self.track_type_description(track_type) end def self.create_track_for_request(info_request) - new(:track_type => 'request_updates', - :info_request => info_request, - :track_query => "request:#{ info_request.url_title }") + new(track_type: 'request_updates', + info_request: info_request, + track_query: "request:#{ info_request.url_title }") end def self.create_track_for_all_new_requests - new(:track_type => 'all_new_requests', - :track_query => 'variety:sent') + new(track_type: 'all_new_requests', + track_query: 'variety:sent') end def self.create_track_for_all_successful_requests - new(:track_type => 'all_successful_requests', - :track_query => 'variety:response ' \ + new(track_type: 'all_successful_requests', + track_query: 'variety:response ' \ '(status:successful OR status:partially_successful)') end @@ -87,15 +87,15 @@ def self.create_track_for_public_body(public_body, event_type = nil) if InfoRequestEvent::EVENT_TYPES.include?(event_type) query += " variety:#{ event_type }" end - new(:track_type => 'public_body_updates', - :public_body => public_body, - :track_query => query) + new(track_type: 'public_body_updates', + public_body: public_body, + track_query: query) end def self.create_track_for_user(user) - new(:track_type => 'user_updates', - :tracked_user => user, - :track_query => "requested_by:#{ user.url_name }" \ + new(track_type: 'user_updates', + tracked_user: user, + track_query: "requested_by:#{ user.url_name }" \ " OR commented_by: #{ user.url_name }") end @@ -115,8 +115,8 @@ def self.create_track_for_search_query(query, variety_postfix = nil) query += " variety:authority" end end - new(:track_type => 'search_query', - :track_query => query) + new(track_type: 'search_query', + track_query: query) end def track_type_description @@ -125,16 +125,16 @@ def track_type_description def track_query_description filter_description = query_filter_description('(variety:sent OR variety:followup_sent OR variety:response OR variety:comment)', - :no_query => N_("all requests or comments"), - :query => N_("all requests or comments matching text '{{query}}'")) + no_query: N_("all requests or comments"), + query: N_("all requests or comments matching text '{{query}}'")) return filter_description if filter_description filter_description = query_filter_description('(latest_status:successful OR latest_status:partially_successful)', - :no_query => N_("requests which are successful"), - :query => N_("requests which are successful matching text '{{query}}'")) + no_query: N_("requests which are successful"), + query: N_("requests which are successful matching text '{{query}}'")) return filter_description if filter_description - _("anything matching text '{{query}}'", :query => track_query) + _("anything matching text '{{query}}'", query: track_query) end # Return a readable query description for queries involving commonly used @@ -146,7 +146,7 @@ def query_filter_description(string, options) if parsed_query.empty? _(options[:no_query]) else - _(options[:query], :query => parsed_query) + _(options[:query], query: parsed_query) end end end @@ -169,57 +169,57 @@ def params_for(track_type) def request_updates_params { # Website - :verb_on_page => _("Follow this request"), - :verb_on_page_already => _("You are already following this request"), + verb_on_page: _("Follow this request"), + verb_on_page_already: _("You are already following this request"), # Email - :title_in_email => _("New updates for the request '{{request_title}}'", - :request_title => info_request.title.html_safe), - :title_in_rss => _("New updates for the request '{{request_title}}'", - :request_title => info_request.title), + title_in_email: _("New updates for the request '{{request_title}}'", + request_title: info_request.title.html_safe), + title_in_rss: _("New updates for the request '{{request_title}}'", + request_title: info_request.title), # Authentication - :web => _("To follow the request '{{request_title}}'", - :request_title => info_request.title.html_safe), - :email => _("Then you will be updated whenever the request '{{request_title}}' is updated.", - :request_title => info_request.title), - :email_subject => _("Confirm you want to follow the request '{{request_title}}'", - :request_title => info_request.title), + web: _("To follow the request '{{request_title}}'", + request_title: info_request.title.html_safe), + email: _("Then you will be updated whenever the request '{{request_title}}' is updated.", + request_title: info_request.title), + email_subject: _("Confirm you want to follow the request '{{request_title}}'", + request_title: info_request.title), # RSS sorting - :feed_sortby => 'newest' + feed_sortby: 'newest' } end def all_new_requests_params { # Website - :verb_on_page => _("Follow all new requests"), - :verb_on_page_already => _("You are already following new requests"), + verb_on_page: _("Follow all new requests"), + verb_on_page_already: _("You are already following new requests"), # Email - :title_in_email => _("New Freedom of Information requests"), - :title_in_rss => _("New Freedom of Information requests"), + title_in_email: _("New Freedom of Information requests"), + title_in_rss: _("New Freedom of Information requests"), # Authentication - :web => _("To follow new requests"), - :email => _("Then you will be following all new FOI requests."), - :email_subject => _("Confirm you want to follow new requests"), + web: _("To follow new requests"), + email: _("Then you will be following all new FOI requests."), + email_subject: _("Confirm you want to follow new requests"), # RSS sorting - :feed_sortby => 'newest' + feed_sortby: 'newest' } end def all_successful_requests_params { # Website - :verb_on_page => _("Follow new successful responses"), - :verb_on_page_already => _("You are following all new successful responses"), + verb_on_page: _("Follow new successful responses"), + verb_on_page_already: _("You are following all new successful responses"), # Email - :title_in_email => _("Successful Freedom of Information requests"), - :title_in_rss => _("Successful Freedom of Information requests"), + title_in_email: _("Successful Freedom of Information requests"), + title_in_rss: _("Successful Freedom of Information requests"), # Authentication - :web => _("To follow all successful requests"), - :email => _("Then you will be notified whenever an FOI request succeeds."), - :email_subject => _("Confirm you want to follow all successful FOI requests"), + web: _("To follow all successful requests"), + email: _("Then you will be notified whenever an FOI request succeeds."), + email_subject: _("Confirm you want to follow all successful FOI requests"), # RSS sorting - used described date, as newest would give a # date for responses possibly days before description, so # wouldn't appear at top of list when description (known # success) causes match. - :feed_sortby => 'described' + feed_sortby: 'described' } end @@ -253,36 +253,36 @@ def public_body_updates_params def user_updates_params { # Website - :verb_on_page => _("Follow this person"), - :verb_on_page_already => _("You are already following this person"), + verb_on_page: _("Follow this person"), + verb_on_page_already: _("You are already following this person"), # Email - :title_in_email => _("FOI requests by '{{user_name}}'", - :user_name => tracked_user.name.html_safe), - :title_in_rss => _("FOI requests by '{{user_name}}'", - :user_name => tracked_user.name), + title_in_email: _("FOI requests by '{{user_name}}'", + user_name: tracked_user.name.html_safe), + title_in_rss: _("FOI requests by '{{user_name}}'", + user_name: tracked_user.name), # Authentication - :web => _("To follow requests by '{{user_name}}'", - :user_name => tracked_user.name.html_safe), - :email => _("Then you will be notified whenever '{{user_name}}' requests something or gets a response.", - :user_name => tracked_user.name), - :email_subject => _("Confirm you want to follow requests by '{{user_name}}'", - :user_name => tracked_user.name), + web: _("To follow requests by '{{user_name}}'", + user_name: tracked_user.name.html_safe), + email: _("Then you will be notified whenever '{{user_name}}' requests something or gets a response.", + user_name: tracked_user.name), + email_subject: _("Confirm you want to follow requests by '{{user_name}}'", + user_name: tracked_user.name), # RSS sorting - :feed_sortby => 'newest' + feed_sortby: 'newest' } end def search_query_params { # Website - :verb_on_page => _("Follow things matching this search"), - :verb_on_page_already => _("You are already following things matching this search"), + verb_on_page: _("Follow things matching this search"), + verb_on_page_already: _("You are already following things matching this search"), # Email - :title_in_email => _("Requests or responses matching your saved search"), - :title_in_rss => _("Requests or responses matching your saved search"), + title_in_email: _("Requests or responses matching your saved search"), + title_in_rss: _("Requests or responses matching your saved search"), # Authentication - :web => _("To follow requests and responses matching your search"), - :email => _("Then you will be notified whenever a new request or response matches your search."), - :email_subject => _("Confirm you want to follow new requests or responses matching your search"), + web: _("To follow requests and responses matching your search"), + email: _("Then you will be notified whenever a new request or response matches your search."), + email_subject: _("Confirm you want to follow new requests or responses matching your search"), # RSS sorting - TODO: hmmm, we don't really know which to use # here for sorting. Might be a query term (e.g. 'cctv'), in # which case newest is good, or might be something like @@ -290,7 +290,7 @@ def search_query_params # described (when we discover criteria is met). Rather # conservatively am picking described, as that will make # things appear in feed more than the should, rather than less. - :feed_sortby => 'described' + feed_sortby: 'described' } end diff --git a/app/models/track_things_sent_email.rb b/app/models/track_things_sent_email.rb index deda1c2363..4b247982e9 100644 --- a/app/models/track_things_sent_email.rb +++ b/app/models/track_things_sent_email.rb @@ -20,13 +20,13 @@ class TrackThingsSentEmail < ApplicationRecord belongs_to :info_request_event, - :inverse_of => :track_things_sent_emails + inverse_of: :track_things_sent_emails belongs_to :user, - :inverse_of => :track_things_sent_emails + inverse_of: :track_things_sent_emails belongs_to :public_body, - :inverse_of => :track_things_sent_emails + inverse_of: :track_things_sent_emails belongs_to :track_thing, - :inverse_of => :track_things_sent_emails + inverse_of: :track_things_sent_emails # Called from cron job delete-old-things def self.delete_old_track_things_sent_email diff --git a/app/models/user.rb b/app/models/user.rb index b827dac824..035fc1cc51 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 20220210114052 +# Schema version: 20230301110831 # # Table name: users # @@ -35,6 +35,8 @@ # daily_summary_minute :integer # closed_at :datetime # login_token :string +# receive_user_messages :boolean default(TRUE), not null +# user_messages_count :integer default(0), not null # class User < ApplicationRecord @@ -47,7 +49,8 @@ class User < ApplicationRecord CONTENT_LIMIT = { info_requests: AlaveteliConfiguration.max_requests_per_user_per_day, - comments: AlaveteliConfiguration.max_requests_per_user_per_day + comments: AlaveteliConfiguration.max_requests_per_user_per_day, + user_messages: AlaveteliConfiguration.max_requests_per_user_per_day }.freeze rolify before_add: :setup_pro_account, @@ -55,7 +58,8 @@ class User < ApplicationRecord after_remove: :assign_role_features strip_attributes allow_empty: true - admin_columns exclude: [:otp_secret_key] + admin_columns include: [:user_messages_count], + exclude: [:otp_secret_key] attr_accessor :no_xapian_reindex @@ -144,6 +148,11 @@ class User < ApplicationRecord inverse_of: :user, dependent: :destroy + has_many :user_messages, + -> { order(created_at: :desc) }, + inverse_of: :user, + dependent: :destroy + scope :active, -> { not_banned.not_closed } scope :banned, -> { where.not(ban_text: '') } scope :not_banned, -> { where(ban_text: '') } @@ -222,7 +231,7 @@ def self.authenticate_from_form(params, specific_user_login = false) # Case-insensitively find a user from their email def self.find_user_by_email(email) return nil if email.blank? - self.where('lower(email) = lower(?)', email.strip).first + where('lower(email) = lower(?)', email.strip).first end # The "internal admin" is a special user for internal use. @@ -319,7 +328,7 @@ def reindex_referencing_models end def expire_requests - info_requests.find_each(&:expire) + InfoRequestExpireJob.perform_later(self, :info_requests) end def expire_comments @@ -350,9 +359,9 @@ def update_url_name unique_url_name = url_name suffix_num = 2 # as there's already one without numeric suffix conditions = id ? ["id <> ?", id] : [] - while !User.where(:url_name => unique_url_name).where(conditions).first.nil? + until User.where(url_name: unique_url_name).where(conditions).first.nil? unique_url_name = url_name + "_" + suffix_num.to_s - suffix_num = suffix_num + 1 + suffix_num += 1 end self.url_name = unique_url_name end @@ -397,33 +406,61 @@ def banned? end def close - update(closed_at: Time.zone.now) + close! + rescue ActiveRecord::RecordInvalid + false + end + + def close! + update!(closed_at: Time.zone.now, receive_email_alerts: false) end def closed? closed_at.present? end - def close_and_anonymise + def erase + erase! + rescue ActiveRecord::RecordInvalid + false + end + + def erase! + raise ActiveRecord::RecordInvalid unless closed? + sha = Digest::SHA1.hexdigest(rand.to_s) transaction do - redact_name! if info_requests.any? - sign_ins.destroy_all + profile_photo&.destroy! - update( + update!( name: _('[Name Removed]'), email: "#{sha}@invalid", url_name: sha, about_me: '', - password: MySociety::Util.generate_token, - receive_email_alerts: false, - closed_at: Time.zone.now + password: MySociety::Util.generate_token ) end end + def anonymise! + return if info_requests.none? + + censor_rules.create!(text: read_attribute(:name), + replacement: _('[Name Removed]'), + last_edit_editor: 'User#anonymise!', + last_edit_comment: 'User#anonymise!') + end + + def close_and_anonymise + transaction do + close! + anonymise! + erase! + end + end + def active? !banned? && !closed? end @@ -449,11 +486,15 @@ def can_make_followup? end def can_make_comments? - active? && !exceeded_limit?(:comments) + return false unless active? + return true if is_admin? || is_pro_admin? + + !exceeded_limit?(:comments) && + !Comment.exceeded_creation_rate?(comments) end def can_contact_other_users? - active? + active? && !exceeded_limit?(:user_messages) end def exceeded_limit?(content) @@ -479,7 +520,9 @@ def next_request_permitted_at order(created_at: :desc). limit(AlaveteliConfiguration.max_requests_per_user_per_day) - return nil if n_most_recent_requests.size < AlaveteliConfiguration::max_requests_per_user_per_day + if n_most_recent_requests.size < AlaveteliConfiguration.max_requests_per_user_per_day + return nil + end nth_most_recent_request = n_most_recent_requests[-1] nth_most_recent_request.created_at + 1.day @@ -574,14 +617,14 @@ def indexed_by_search? def notify(info_request_event) Notification.create( info_request_event: info_request_event, - frequency: Notification.frequencies[self.notification_frequency], + frequency: Notification.frequencies[notification_frequency], user: self ) end # Return a timestamp for the next time a user should be sent a daily summary def next_daily_summary_time - summary_time = Time.zone.now.change(self.daily_summary_time) + summary_time = Time.zone.now.change(daily_summary_time) summary_time += 1.day if summary_time < Time.zone.now summary_time end @@ -621,13 +664,6 @@ def flipper_id private - def redact_name! - censor_rules.create!(text: name, - replacement: _('[Name Removed]'), - last_edit_editor: 'User#close_and_anonymise', - last_edit_comment: 'User#close_and_anonymise') - end - def set_defaults return unless new_record? diff --git a/app/models/user/authentication.rb b/app/models/user/authentication.rb index b58b543ecf..9554ba860d 100644 --- a/app/models/user/authentication.rb +++ b/app/models/user/authentication.rb @@ -8,7 +8,7 @@ module User::Authentication attr_reader :password attr_accessor :password_confirmation - scope :sha1, lambda { + scope :sha1, -> { where("users.salt IS NOT NULL AND users.hashed_password NOT LIKE '$2a$%'") } diff --git a/app/models/user/transaction_calculator.rb b/app/models/user/transaction_calculator.rb index 98fc229539..0f3db04cb1 100644 --- a/app/models/user/transaction_calculator.rb +++ b/app/models/user/transaction_calculator.rb @@ -94,7 +94,7 @@ def ==(other) def range_total_count(range) transaction_associations. reduce(0) do |accum, assoc| - accum += user.send(assoc).where(:created_at => range).count + accum += user.send(assoc).where(created_at: range).count end end diff --git a/app/models/user_info_request_sent_alert.rb b/app/models/user_info_request_sent_alert.rb index 6cf3af8097..0143b146c6 100644 --- a/app/models/user_info_request_sent_alert.rb +++ b/app/models/user_info_request_sent_alert.rb @@ -39,13 +39,13 @@ class UserInfoRequestSentAlert < ApplicationRecord ] belongs_to :user, - :inverse_of => :user_info_request_sent_alerts + inverse_of: :user_info_request_sent_alerts belongs_to :info_request, - :inverse_of => :user_info_request_sent_alerts + inverse_of: :user_info_request_sent_alerts belongs_to :info_request_event, - :inverse_of => :user_info_request_sent_alerts + inverse_of: :user_info_request_sent_alerts - validates_inclusion_of :alert_type, :in => ALERT_TYPES + validates_inclusion_of :alert_type, in: ALERT_TYPES scope :recent, -> { where(created_at: 1.year.ago.to_date..Float::INFINITY) } end diff --git a/app/models/user_message.rb b/app/models/user_message.rb new file mode 100644 index 0000000000..bb65c330c6 --- /dev/null +++ b/app/models/user_message.rb @@ -0,0 +1,15 @@ +# == Schema Information +# Schema version: 20230222154014 +# +# Table name: user_messages +# +# id :bigint not null, primary key +# user_id :bigint +# created_at :datetime not null +# updated_at :datetime not null +# +class UserMessage < ApplicationRecord + belongs_to :user, + inverse_of: :user_messages, + counter_cache: true +end diff --git a/app/models/widget_vote.rb b/app/models/widget_vote.rb index 8281849773..85801e3ab3 100644 --- a/app/models/widget_vote.rb +++ b/app/models/widget_vote.rb @@ -12,9 +12,9 @@ class WidgetVote < ApplicationRecord belongs_to :info_request, - :inverse_of => :widget_votes + inverse_of: :widget_votes - validates :info_request, :presence => true + validates :info_request, presence: true validates :cookie, length: { is: 20 } validates :cookie, uniqueness: { scope: :info_request_id } end diff --git a/app/validators/change_email_validator.rb b/app/validators/change_email_validator.rb index 1efdf53673..d3c51b59d0 100644 --- a/app/validators/change_email_validator.rb +++ b/app/validators/change_email_validator.rb @@ -14,14 +14,14 @@ class ChangeEmailValidator :logged_in_user validates_presence_of :old_email, - :message => N_("Please enter your old email address") + message: N_("Please enter your old email address") validates_presence_of :new_email, - :message => N_("Please enter your new email address") + message: N_("Please enter your new email address") validates_presence_of :password, - :message => N_("Please enter your password"), - :unless => :changing_email + message: N_("Please enter your password"), + unless: :changing_email validate :password_and_format_of_email @@ -32,7 +32,7 @@ def initialize(attributes = {}) end def changing_email - self.user_circumstance == 'change_email' + user_circumstance == 'change_email' end private diff --git a/app/validators/contact_validator.rb b/app/validators/contact_validator.rb index 1fdbae8aa6..c43597901a 100644 --- a/app/validators/contact_validator.rb +++ b/app/validators/contact_validator.rb @@ -9,10 +9,10 @@ class ContactValidator attr_accessor :name, :email, :subject, :message, :comment - validates_presence_of :name, :message => N_("Please enter your name") - validates_presence_of :email, :message => N_("Please enter your email address") - validates_presence_of :subject, :message => N_("Please enter a subject") - validates_presence_of :message, :message => N_("Please enter the message you want to send") + validates_presence_of :name, message: N_("Please enter your name") + validates_presence_of :email, message: N_("Please enter your email address") + validates_presence_of :subject, message: N_("Please enter a subject") + validates_presence_of :message, message: N_("Please enter the message you want to send") validate :email_format def initialize(attributes = {}) diff --git a/app/validators/reply_to_address_validator.rb b/app/validators/reply_to_address_validator.rb index d3b49fdef6..2fb2e3a40c 100644 --- a/app/validators/reply_to_address_validator.rb +++ b/app/validators/reply_to_address_validator.rb @@ -1,7 +1,7 @@ # Public: Validates that we can reply to a ReplyTo address. class ReplyToAddressValidator DEFAULT_NO_REPLY_REGEXP = - /^(postmaster|mailer-daemon|auto_reply|do.?not.?reply|no.?reply)$/.freeze + /^(postmaster|mailer-daemon|auto_reply|do.?not.?reply|no.?reply)$/ DEFAULT_INVALID_REPLY_ADDRESSES = [].freeze diff --git a/app/views/admin/blog_posts/_about.html.erb b/app/views/admin/blog_posts/_about.html.erb new file mode 100644 index 0000000000..00e8965925 --- /dev/null +++ b/app/views/admin/blog_posts/_about.html.erb @@ -0,0 +1,21 @@ +
+
+
+

About Blog Posts

+ +

+ Alaveteli automatically imports posts from the configured + + BLOG_FEED to display around the site. +

+ +

+ By default blog posts are listed by recency. When they're presented + alongside <%= link_to 'taggable content', admin_tags_path %>, Alaveteli + attempts to render relevant posts through matching tags. For example, + blog posts tagged with "climate" would be matched with records + (requests, authorities, etc) also tagged "climate". +

+
+
+
diff --git a/app/views/admin/blog_posts/_blog_post.html.erb b/app/views/admin/blog_posts/_blog_post.html.erb new file mode 100644 index 0000000000..cc23d735cf --- /dev/null +++ b/app/views/admin/blog_posts/_blog_post.html.erb @@ -0,0 +1,28 @@ +
+
+ + + <%= chevron_right %> + + <%= both_links(blog_post) %> + + + +
+ +
+ <% blog_post.for_admin_column do |name, value| %> +
+ + <%= name.humanize %> + + + + <%= admin_value(value) %> + +
+ <% end %> +
+
diff --git a/app/views/admin/blog_posts/_form.html.erb b/app/views/admin/blog_posts/_form.html.erb new file mode 100644 index 0000000000..28ee89666a --- /dev/null +++ b/app/views/admin/blog_posts/_form.html.erb @@ -0,0 +1,9 @@ +<%= foi_error_messages_for :blog_post %> + +
+ <%= f.label :tag_string, 'Tags', class: 'control-label' %> + +
+ <%= f.text_field :tag_string, class: 'span4' %> +
+
diff --git a/app/views/admin/blog_posts/_intro.html.erb b/app/views/admin/blog_posts/_intro.html.erb new file mode 100644 index 0000000000..da57bf5441 --- /dev/null +++ b/app/views/admin/blog_posts/_intro.html.erb @@ -0,0 +1,3 @@ + diff --git a/app/views/admin/blog_posts/edit.html.erb b/app/views/admin/blog_posts/edit.html.erb new file mode 100644 index 0000000000..6c783a4fd1 --- /dev/null +++ b/app/views/admin/blog_posts/edit.html.erb @@ -0,0 +1,16 @@ +
+
+ +
+
+ +<%= render partial: 'intro', locals: { blog_post: @blog_post } %> + +<%= form_for [:admin, @blog_post], class: 'form form-horizontal' do |f| %> + <%= render partial: 'form', locals: { f: f } %> +
+ <%= submit_tag 'Save', class: 'btn btn-success' %> +
+<% end %> diff --git a/app/views/admin/blog_posts/index.html.erb b/app/views/admin/blog_posts/index.html.erb new file mode 100644 index 0000000000..13507dc4e9 --- /dev/null +++ b/app/views/admin/blog_posts/index.html.erb @@ -0,0 +1,31 @@ +<% @title = 'Blog Posts' %> + +

<%= @title %>

+ +<% if Blog.enabled? %> +
+
+ <%= link_to 'View tags', admin_tags_path(model_type: Blog::Post), class: 'btn' %> +
+
+ + <% if @blog_posts.size > 0 %> + <%= render partial: 'admin/blog_posts/blog_post', collection: @blog_posts %> + <% else %> +
+

None yet.

+
+ <% end %> + + <%= will_paginate(@blog_posts) %> +<% else %> +
+

Blog Posts Disabled

+ To enable blog posts set BLOG_FEED to the URL of your external blog + feed in Alaveteli’s configuration. +
+<% end %> + +
+ +<%= render partial: 'about' %> diff --git a/app/views/admin/info_request_batches/_info_request_batch.html.erb b/app/views/admin/info_request_batches/_info_request_batch.html.erb new file mode 100644 index 0000000000..4ecb0ed6a3 --- /dev/null +++ b/app/views/admin/info_request_batches/_info_request_batch.html.erb @@ -0,0 +1,35 @@ +
+
+ + + <%= chevron_right %> + + + <%= both_links(info_request_batch) %> + + <% if info_request_batch.embargoed? %> + <%= content_tag(:span, 'embargoed', class: 'label') %> + <% end %> + + + +
+ +
+ <% info_request_batch.for_admin_column do |name, value| %> +
+ + <%= name.humanize %> + + + <%= admin_value(value) %> + +
+ <% end %> +
+
diff --git a/app/views/admin/info_request_batches/_list.html.erb b/app/views/admin/info_request_batches/_list.html.erb new file mode 100644 index 0000000000..7278ec87a5 --- /dev/null +++ b/app/views/admin/info_request_batches/_list.html.erb @@ -0,0 +1,9 @@ +
+ <% if info_request_batches.any? %> + <%= render partial: 'admin/info_request_batches/info_request_batch', + collection: info_request_batches %> + <% else %> +

None yet.

+ <% end %> +
+ diff --git a/app/views/admin/tags/_tagging.html.erb b/app/views/admin/tags/_tagging.html.erb index 3079577a5d..2db2fa89dd 100644 --- a/app/views/admin/tags/_tagging.html.erb +++ b/app/views/admin/tags/_tagging.html.erb @@ -19,6 +19,11 @@ note: tagging } %> +<% when Blog::Post %> + <%= render partial: 'admin/blog_posts/blog_post', locals: { + blog_post: tagging + } %> + <% else %>
<%= tagging.to_json %>
<% end %> diff --git a/app/views/admin/users/_sign_in_table.html.erb b/app/views/admin/users/_sign_in_table.html.erb index 7bc3185d39..c7fa11a9d6 100644 --- a/app/views/admin/users/_sign_in_table.html.erb +++ b/app/views/admin/users/_sign_in_table.html.erb @@ -10,38 +10,63 @@ <% end %> <% if sign_ins.any? %> - - <% sign_ins.each do |sign_in| %> - - +
+
+
+

+ Sign in tracking records the IP address and date of sign in, as well + as a geolocation estimation, and links this IP address to sign ins + from other user accounts using the same IP address. This can be + useful for investigating misuse, but may also reveal legitimate use + of alternative accounts. Care should be taken when revealing this + information. +

-
+

+ + Reveal Sign Ins + +

+ - +
+
+
<%= user_both_links(sign_in.user) %> - - <%= link_to sign_in.ip, admin_sign_ins_path(query: sign_in.ip) %> - - - - <% if sign_in.country %> - <%= link_to admin_sign_ins_path(query: sign_in.country) do %> - <%= sign_in.country %> - <% end %> - <% else %> - ?? - <% end %> - -
+ <% sign_ins.each do |sign_in| %> + + + + + + - + - - - <% end %> -
<%= user_both_links(sign_in.user) %> + + <%= link_to sign_in.ip, admin_sign_ins_path(query: sign_in.ip) %> + + + + <% if sign_in.country %> + <%= link_to admin_sign_ins_path(query: sign_in.country) do %> + <%= sign_in.country %> + <% end %> + <% else %> + ?? + <% end %> + + <%= admin_date(sign_in.created_at, ago_only: true) %><%= admin_date(sign_in.created_at, ago_only: true) %> - <%= sign_in.other_users.size %> others using this - IP -
+ + <%= sign_in.other_users.size %> others using this + IP + + + <% end %> + + + + + <% elsif User::SignIn.retain_signins? %>

None yet.

<% end %> diff --git a/app/views/admin_censor_rule/_form.html.erb b/app/views/admin_censor_rule/_form.html.erb index 603dfe4a8f..25314ecca0 100644 --- a/app/views/admin_censor_rule/_form.html.erb +++ b/app/views/admin_censor_rule/_form.html.erb @@ -56,7 +56,10 @@
- <%= text_area 'censor_rule', 'last_edit_comment', :value => '', :rows => 2, :class => "span6" %> + <%= text_area 'censor_rule', 'last_edit_comment', :data => { last_edit_comment: @censor_rule.last_edit_comment }, :value => '', :rows => 2, :class => "span6" %> + <% if @censor_rule.last_edit_comment %> + Use previous comment + <% end %>
put purpose of the rule, and why the change
diff --git a/app/views/admin_censor_rule/_show.html.erb b/app/views/admin_censor_rule/_list.html.erb similarity index 88% rename from app/views/admin_censor_rule/_show.html.erb rename to app/views/admin_censor_rule/_list.html.erb index 98ae703cdf..cd3c31fe4a 100644 --- a/app/views/admin_censor_rule/_show.html.erb +++ b/app/views/admin_censor_rule/_list.html.erb @@ -1,3 +1,13 @@ +
+
+

+ Each rule applies sequentially to the text after having been modified by + the previous rule, so the order may matter depending on what you are + trying to redact. +

+
+
+
<% if censor_rules.size > 0 %> diff --git a/app/views/admin_censor_rule/index.html.erb b/app/views/admin_censor_rule/index.html.erb index 6977f4752a..48d3b36066 100644 --- a/app/views/admin_censor_rule/index.html.erb +++ b/app/views/admin_censor_rule/index.html.erb @@ -22,8 +22,8 @@ -<%= render :partial => 'show', - :locals => { :censor_rules => @censor_rules } %> +<%= render partial: 'admin_censor_rule/list', + locals: { censor_rules: @censor_rules } %>
diff --git a/app/views/admin_comment/edit.html.erb b/app/views/admin_comment/edit.html.erb index 34a7d51637..24d51d3db7 100644 --- a/app/views/admin_comment/edit.html.erb +++ b/app/views/admin_comment/edit.html.erb @@ -74,7 +74,7 @@ <% info_request_event.for_admin_column( - :event_type, :params_yaml, :created_at + :event_type, :params, :created_at ) do |name, value| %>
diff --git a/app/views/admin_general/_admin_navbar.html.erb b/app/views/admin_general/_admin_navbar.html.erb index e93d8daa37..8838e892bd 100644 --- a/app/views/admin_general/_admin_navbar.html.erb +++ b/app/views/admin_general/_admin_navbar.html.erb @@ -53,6 +53,7 @@ diff --git a/app/views/admin_user/show.html.erb b/app/views/admin_user/show.html.erb index a9b104242d..ad4bb67afa 100644 --- a/app/views/admin_user/show.html.erb +++ b/app/views/admin_user/show.html.erb @@ -133,6 +133,13 @@
+

Batch Requests

+ +<%= render partial: 'admin/info_request_batches/list', + locals: { info_request_batches: @info_request_batches } %> + +
+

Annotations

<%= render partial: 'admin_request/some_annotations' , @@ -173,6 +180,6 @@

Censor rules

-<%= render partial: 'admin_censor_rule/show', +<%= render partial: 'admin_censor_rule/list', locals: { censor_rules: @admin_user.censor_rules, user: @admin_user } %> diff --git a/app/views/alaveteli_pro/general/_nav_items.html.erb b/app/views/alaveteli_pro/general/_nav_items.html.erb index 7147aca890..b2f5662b4c 100644 --- a/app/views/alaveteli_pro/general/_nav_items.html.erb +++ b/app/views/alaveteli_pro/general/_nav_items.html.erb @@ -39,7 +39,7 @@ AnalyticsEvent::Action::PRO_NAV_VIEW_AUTHORITIES) %> -<% unless AlaveteliConfiguration::blog_feed.empty? %> +<% if Blog.enabled? %>
  • <%= link_to _("Read blog"), blog_path, diff --git a/app/views/alaveteli_pro/info_request_batches/_message_preview.html.erb b/app/views/alaveteli_pro/info_request_batches/_message_preview.html.erb index 45619b4d36..5391e1d117 100644 --- a/app/views/alaveteli_pro/info_request_batches/_message_preview.html.erb +++ b/app/views/alaveteli_pro/info_request_batches/_message_preview.html.erb @@ -3,9 +3,13 @@ <%= _('To') %> <%= render partial: 'alaveteli_pro/info_request_batches/authority_list_with_link', locals: { batch: batch, draft: draft } %> +

    - +

    + <%= _('From') %> + <%= @user&.name || '…' %>

    +

    <%= _('Subject') %> <%= batch.title %>

    diff --git a/app/views/alaveteli_pro/info_requests/_batch.html.erb b/app/views/alaveteli_pro/info_requests/_batch.html.erb index 851f7841a4..593f09b17e 100644 --- a/app/views/alaveteli_pro/info_requests/_batch.html.erb +++ b/app/views/alaveteli_pro/info_requests/_batch.html.erb @@ -10,5 +10,8 @@ :count => @info_request.info_request_batch.public_bodies.count) %>

    + + <%= render partial: 'info_request_batch/pagination', + locals: { info_request: @info_request } %> <% end %> diff --git a/app/views/alaveteli_pro/info_requests/_message_preview.html.erb b/app/views/alaveteli_pro/info_requests/_message_preview.html.erb index deb5677043..bd46a14514 100644 --- a/app/views/alaveteli_pro/info_requests/_message_preview.html.erb +++ b/app/views/alaveteli_pro/info_requests/_message_preview.html.erb @@ -2,8 +2,13 @@

    <%= _('To') %> <%= @info_request.public_body.name %> +

    +

    + <%= _('From') %> + <%= @user&.name || '…' %>

    +

    <%= _('Subject') %> <%= @info_request.title %>

    diff --git a/app/views/alaveteli_pro/info_requests/_select_authority_form.html.erb b/app/views/alaveteli_pro/info_requests/_select_authority_form.html.erb index afe7da7458..dec59d2498 100644 --- a/app/views/alaveteli_pro/info_requests/_select_authority_form.html.erb +++ b/app/views/alaveteli_pro/info_requests/_select_authority_form.html.erb @@ -1,10 +1,11 @@
    -

    -

    + + -

    +
    <% if @info_request.public_body && @info_request.public_body.has_notes? %> diff --git a/app/views/alaveteli_pro/info_requests/_sidebar.html.erb b/app/views/alaveteli_pro/info_requests/_sidebar.html.erb index c637afcf98..fb30815a32 100644 --- a/app/views/alaveteli_pro/info_requests/_sidebar.html.erb +++ b/app/views/alaveteli_pro/info_requests/_sidebar.html.erb @@ -21,6 +21,9 @@ <%= render partial: 'request/share_by_link', locals: { info_request: @info_request } %> + <%= render partial: 'blog_posts/blog_posts', + locals: { taggable: info_request } %> + <% unless state_transitions_empty?(@state_transitions) %> diff --git a/app/views/alaveteli_pro/plans/_pricing_tiers.html.erb b/app/views/alaveteli_pro/plans/_pricing_tiers.html.erb index b0c5538c54..5f4c5b7452 100644 --- a/app/views/alaveteli_pro/plans/_pricing_tiers.html.erb +++ b/app/views/alaveteli_pro/plans/_pricing_tiers.html.erb @@ -22,10 +22,6 @@ no_cents_if_whole: true)) %> <% end %>

    - -

    - <%= _('Introductory Pricing') %> -

    diff --git a/app/views/blog_posts/_blog_post.html.erb b/app/views/blog_posts/_blog_post.html.erb new file mode 100644 index 0000000000..c36e6ba9b9 --- /dev/null +++ b/app/views/blog_posts/_blog_post.html.erb @@ -0,0 +1,3 @@ +
  • + <%= link_to blog_post.title, blog_post.url, rel: 'nofollow' %> +
  • diff --git a/app/views/blog_posts/_blog_posts.html.erb b/app/views/blog_posts/_blog_posts.html.erb new file mode 100644 index 0000000000..fc914eaa42 --- /dev/null +++ b/app/views/blog_posts/_blog_posts.html.erb @@ -0,0 +1,11 @@ +<% blog_posts = blog_posts_for_taggable(taggable: taggable) %> + +<% if blog_posts.any? %> + +<% end %> diff --git a/app/views/comment/rate_limited.html.erb b/app/views/comment/rate_limited.html.erb index 9e9291ec47..d9cbf08470 100644 --- a/app/views/comment/rate_limited.html.erb +++ b/app/views/comment/rate_limited.html.erb @@ -17,6 +17,12 @@ help_contact_path: help_contact_path) %>

    +

    + <%= _('There is also a limit on the speed at which you are able to create ' \ + 'annotations. Please try again later if you have not hit your daily ' \ + 'limit.') %> +

    + <% if @comment %>

    <%= _('Here is the message you wrote, in case you would like to copy ' \ diff --git a/app/views/general/_frontpage_blog.html.erb b/app/views/general/_frontpage_blog.html.erb new file mode 100644 index 0000000000..6960bf5b7b --- /dev/null +++ b/app/views/general/_frontpage_blog.html.erb @@ -0,0 +1,14 @@ +<% if blog_posts_for_frontpage.any? %> +

    +

    <%= _('Latest news and campaigns') %>

    + + <% blog_posts_for_frontpage.each do |post| %> +
    +

    <%= link_to post.title, post.url %>

    +

    <%= post.description %>

    +
    + <% end %> + + <%= link_to _('See all →'), blog_path, class: 'button-secondary' %> +
    +<% end %> diff --git a/app/views/general/_frontpage_extra.html.erb b/app/views/general/_frontpage_extra.html.erb new file mode 100644 index 0000000000..0e9a333033 --- /dev/null +++ b/app/views/general/_frontpage_extra.html.erb @@ -0,0 +1 @@ +<%# Placeholder to be overridden by theme %> diff --git a/app/views/general/_nav_items.html.erb b/app/views/general/_nav_items.html.erb index 4597d8ca2c..b9580fcff3 100644 --- a/app/views/general/_nav_items.html.erb +++ b/app/views/general/_nav_items.html.erb @@ -10,7 +10,7 @@ <%= link_to _("View authorities"), list_public_bodies_default_path %> -<% unless AlaveteliConfiguration::blog_feed.empty? %> +<% if Blog.enabled? %>
  • <%= link_to _("Read blog"), blog_path %>
  • <% end %> diff --git a/app/views/general/blog.html.erb b/app/views/general/blog.html.erb index 1e80cebc50..00ecaeb6c9 100644 --- a/app/views/general/blog.html.erb +++ b/app/views/general/blog.html.erb @@ -4,18 +4,18 @@

    <%=@title %>

    - <% @blog_items.each do |item| %> + <% @blog.posts.each do |post| %>
    - <% date = Time.zone.parse(item['pubDate'][0]) %> + <% date = Time.zone.parse(post.data['pubDate'][0]) %>

    - - <%=h item['title'][0] %> + + <%=h post.title %>

    <% author = - item['creator'] ? item['creator']&.first : item['author']&.first %> + post.data['creator'] ? post.data['creator']&.first : post.data['author']&.first %> <% if author && date %>

    @@ -30,20 +30,20 @@ <% end %>

    - <% if item['encoded'] %> - <%= sanitize(raw item['encoded'][0]) %> - <% elsif item['description'] %> - <%= sanitize(raw item['description'][0]) %> + <% if post.data['encoded'] %> + <%= sanitize(raw post.data['encoded'][0]) %> + <% elsif post.data['description'] %> + <%= sanitize(raw post.data['description'][0]) %> <% end %>

    - <% if item['comments'] %> - <%= n_( + <% if post.data['comments'] %> + <%= n_( "{{number_of_comments}} comment", "{{number_of_comments}} comments", - item['comments'][1], - :number_of_comments=>item['comments'][1]) %> + post.data['comments'][1], + :number_of_comments=>post.data['comments'][1]) %> <% end %>

    diff --git a/app/views/general/frontpage.html.erb b/app/views/general/frontpage.html.erb index 825ecd4621..1a73bed496 100644 --- a/app/views/general/frontpage.html.erb +++ b/app/views/general/frontpage.html.erb @@ -1,8 +1,11 @@ -<% cache_if_caching_fragments("frontpage-#{@locale}", :expires_in => 5.minutes) do %> - <%= render :partial => "frontpage_how_it_works" %> +<% cache_if_caching_fragments("frontpage-#{@locale}", expires_in: 5.minutes) do %> + <%= render partial: 'frontpage_how_it_works' %>
    - <%= render :partial => "frontpage_bodies_list" %> - <%= render :partial => "frontpage_requests_list" %> + <%= render partial: 'frontpage_bodies_list' %> + <%= render partial: 'frontpage_requests_list' %>
    + + <%= render partial: 'frontpage_blog' if Blog.enabled? %> + <%= render partial: 'frontpage_extra' %> <% end %> diff --git a/app/views/health_checks/index.html.erb b/app/views/health/checks/index.html.erb similarity index 100% rename from app/views/health_checks/index.html.erb rename to app/views/health/checks/index.html.erb diff --git a/app/views/health/metrics/index.text.erb b/app/views/health/metrics/index.text.erb new file mode 100644 index 0000000000..06c39b039e --- /dev/null +++ b/app/views/health/metrics/index.text.erb @@ -0,0 +1,31 @@ +# HELP sidekiq_processed_jobs The total number of processed jobs. +# TYPE sidekiq_processed_jobs gauge +sidekiq_processed_job <%= @sidekiq_stats.processed %> + +# HELP sidekiq_busy_workers The number of workers performing a job. +# TYPE sidekiq_busy_workers gauge +sidekiq_busy_workers <%= @sidekiq_stats.workers_size %> + +# HELP sidekiq_enqueued_jobs The number of enqueued jobs waiting to be processed. +# TYPE sidekiq_enqueued_jobs gauge +sidekiq_enqueued_jobs <%= @sidekiq_stats.enqueued %> + +# HELP sidekiq_retry_jobs The number of failed jobs scheduled for a retry. +# TYPE sidekiq_retry_jobs gauge +sidekiq_retry_jobs <%= @sidekiq_stats.retry_size %> + +# HELP sidekiq_scheduled_jobs The number of jobs scheduled for a future execution. +# TYPE sidekiq_scheduled_jobs gauge +sidekiq_scheduled_jobs <%= @sidekiq_stats.scheduled_size %> + +# HELP sidekiq_failed_jobs The total number of failed jobs; these will be retried automatically. +# TYPE sidekiq_failed_jobs gauge +sidekiq_failed_jobs <%= @sidekiq_stats.failed %> + +# HELP sidekiq_processed_jobs Number of jobs that need manual intervention to retry +# TYPE sidekiq_dead_jobs gauge +sidekiq_dead_jobs <%= @sidekiq_stats.dead_size %> + +# HELP xapian_queued_jobs The number of jobs in the Xapian queue +# TYPE xapian_queued_jobs gauge +xapian_queued_jobs <%= @xapian_queued_jobs %> diff --git a/app/views/info_request_batch/_pagination.html.erb b/app/views/info_request_batch/_pagination.html.erb new file mode 100644 index 0000000000..8667331515 --- /dev/null +++ b/app/views/info_request_batch/_pagination.html.erb @@ -0,0 +1,2 @@ +<%= link_to _('Prev'), request_path(info_request.prev_in_batch) %> | +<%= link_to _('Next'), request_path(info_request.next_in_batch) %> diff --git a/app/views/projects/projects/show.html.erb b/app/views/projects/projects/show.html.erb index 7b12a9d3a7..4fd810c628 100644 --- a/app/views/projects/projects/show.html.erb +++ b/app/views/projects/projects/show.html.erb @@ -124,6 +124,47 @@ class: 'button-tertiary' %>
    <% end %> + +
    +

    <%= _("Top recent contributors") %>

    + + <% @leaderboard.twenty_eight_days.each_with_index do |row, index| %> + + + + + + <% end %> +
    <%= index += 1 %>. <%= user_link(row[:user]) %> + <%= n_('{{number_of_contributions}} contribution', + '{{number_of_contributions}} contributions', + row[:total_contributions], + number_of_contributions: row[:total_contributions]) %> +
    +

    <%= _("All time best contributors") %>

    + + <% @leaderboard.all_time.each_with_index do |row, index| %> + + + + + + <% end %> +
    <%= index += 1 %>. <%= user_link(row[:user]) %> + <%= n_('{{number_of_contributions}} contribution', + '{{number_of_contributions}} contributions', + row[:total_contributions], + number_of_contributions: row[:total_contributions]) %> +
    +
    + + <% if can? :download, @project %> +
    + <%= link_to _('Download Leaderboard Data'), + project_leaderboard_path(@project, format: :csv), + class: 'button-tertiary' %> +
    + <% end %>
    diff --git a/app/views/public_body/_body_listing_single.html.erb b/app/views/public_body/_body_listing_single.html.erb index 35208b9b81..48610a8931 100644 --- a/app/views/public_body/_body_listing_single.html.erb +++ b/app/views/public_body/_body_listing_single.html.erb @@ -6,7 +6,7 @@ request_link = false unless defined?(request_link) %> -
    +
    <%= link_to highlight_words(public_body.name, @highlight_words), public_body_path(public_body) %>
    diff --git a/app/views/public_body/show.html.erb b/app/views/public_body/show.html.erb index 8d025c0b89..0f2282c68f 100644 --- a/app/views/public_body/show.html.erb +++ b/app/views/public_body/show.html.erb @@ -153,13 +153,14 @@ <% end %>
    - diff --git a/app/views/request/_batch.html.erb b/app/views/request/_batch.html.erb index efb5df451a..a2a6c77c75 100644 --- a/app/views/request/_batch.html.erb +++ b/app/views/request/_batch.html.erb @@ -8,5 +8,8 @@ url: info_request_batch_path(info_request.info_request_batch), count: info_request.info_request_batch.public_bodies.size) %>

    + + <%= render partial: 'info_request_batch/pagination', + locals: { info_request: info_request } %>
    <% end %> diff --git a/app/views/request/_resent_outgoing_correspondence.html.erb b/app/views/request/_resent_outgoing_correspondence.html.erb index 00ccd5f5df..2410819f67 100644 --- a/app/views/request/_resent_outgoing_correspondence.html.erb +++ b/app/views/request/_resent_outgoing_correspondence.html.erb @@ -4,14 +4,23 @@

    - Sent - <% if outgoing_message.message_type == 'initial_request' %> - request - <% elsif outgoing_message.message_type == 'followup' %> - a follow up + <% case [outgoing_message.message_type, info_request_event.same_email_as_previous_send?] %> + <% in ['initial_request', true] %> + <%= _('Sent request to {{public_body_link}} again.', + public_body_link: public_body_link(@info_request.public_body)) %> + <% in ['initial_request', false] %> + <%= _('Sent request to {{public_body_link}} again, using a new contact ' \ + 'address.', + public_body_link: public_body_link(@info_request.public_body)) %> + <% in ['followup', true] %> + <%= _('Sent a follow up to {{public_body_link}} again.', + public_body_link: public_body_link(@info_request.public_body)) %> + <% in ['followup', false] %> + <%= _('Sent a follow up to {{public_body_link}} again, using a new ' \ + 'contact address.', + public_body_link: public_body_link(@info_request.public_body)) %> <% else %> <% raise "unknown message_type" %> <% end %> - to <%= public_body_link(@info_request.public_body) %> again<% if not info_request_event.same_email_as_previous_send? %>, using a new contact address<% end %>.

    diff --git a/app/views/request/_resent_outgoing_correspondence.text.erb b/app/views/request/_resent_outgoing_correspondence.text.erb index d39f8395b2..d226fab559 100644 --- a/app/views/request/_resent_outgoing_correspondence.text.erb +++ b/app/views/request/_resent_outgoing_correspondence.text.erb @@ -1,2 +1,19 @@ <%= _('Date:') %> <%= simple_date(info_request_event.created_at, :format => :text) %> -Sent <% if outgoing_message.message_type == 'initial_request' %> request <% elsif outgoing_message.message_type == 'followup' %> a follow up <% else %> <% raise "unknown message_type" %><% end %> to <%= public_body_link(@info_request.public_body) %> again<% if not info_request_event.same_email_as_previous_send? %>, using a new contact address<% end %>. +<% case [outgoing_message.message_type, info_request_event.same_email_as_previous_send?] %> +<% in ['initial_request', true] %> +<%= _('Sent request to {{public_body_name}} again.', + public_body_name: @info_request.public_body.name) %> +<% in ['initial_request', false] %> +<%= _('Sent request to {{public_body_name}} again, using a new contact ' \ + 'address.', + public_body_name: @info_request.public_body.name) %> +<% in ['followup', true] %> +<%= _('Sent a follow up to {{public_body_name}} again.', + public_body_name: @info_request.public_body.name) %> +<% in ['followup', false] %> +<%= _('Sent a follow up to {{public_body_name}} again, using a new contact ' \ + 'address.', + public_body_name: @info_request.public_body.name) %> +<% else %> +<% raise "unknown message_type" %> +<% end %> diff --git a/app/views/request/_sidebar.html.erb b/app/views/request/_sidebar.html.erb index 2fe6e81ced..58e87989b3 100644 --- a/app/views/request/_sidebar.html.erb +++ b/app/views/request/_sidebar.html.erb @@ -29,6 +29,9 @@ <%= render partial: 'request/citations', locals: { citations: citations, info_request: info_request } %> + <%= render partial: 'blog_posts/blog_posts', + locals: { taggable: info_request } %> + <% if similar_requests.any? %> <%= render partial: 'request/similar', locals: { info_request: info_request, diff --git a/app/views/request/new.html.erb b/app/views/request/new.html.erb index 732ef69f6c..34fb9c3ea2 100644 --- a/app/views/request/new.html.erb +++ b/app/views/request/new.html.erb @@ -133,13 +133,16 @@ <%= _('To') %> <%= h(@info_request.public_body.name) %>

    + +

    + <%= _('From') %> + <%= @user&.name || '…' %> +

    <% end %> <% unless @batch %> <% if @info_request.public_body.has_notes? %> -
    - <%= render_notes(@info_request.public_body.notes) %> -
    + <%= render_notes(@info_request.public_body.notes) %> <% end %> <% end %> @@ -184,39 +187,34 @@
    - <% unless @batch %> -

    - <% if @info_request.public_body.info_requests.is_public.any? %> - <%= _("Browse other requests to '{{public_body_name}}' for examples of how to word your request.", :public_body_name=>h(@info_request.public_body.name), :url=>public_body_path(@info_request.public_body)) %> - <% else %> - <%= _("Browse other requests for examples of how to word your request.", :url=>request_list_successful_url) %> - <% end %> -

    - <% end %> +
    +

    <%= _('Before you start') %>

    -

    - <%= raw(_('Everything that you enter on this page, including ' \ - 'your name, will be displayed ' \ - 'publicly on this website ' \ - 'forever', - :url => help_privacy_path(:anchor => "public_request").html_safe)) %>. -

    - - <% unless @user %> -

    - <%= raw(_('Thinking of using a pseudonym?', - :url => help_privacy_path(:anchor => "real_name").html_safe)) %> -

    - <% end %> +
      +
    • <%= _('Make sure the information you are asking for is not ' \ + 'already publicly available.') %>
    • -

      - <%= raw(_("Can I request information about myself? " \ - "No!", - :url => help_requesting_path(:anchor => "data_protection").html_safe)) %> -

      + <% unless @batch %> +
    • + <% if @info_request.public_body.info_requests.is_public.any? %> + <%= _("Browse other requests to '{{public_body_name}}' for examples of how to word your request.", :public_body_name=>h(@info_request.public_body.name), :url=>public_body_path(@info_request.public_body)) %> + <% else %> + <%= _("Browse other requests for examples of how to word your request.", :url=>request_list_successful_url) %> + <% end %> +
    • + <% end %> +
    +
    +

    <%= _('Writing your request') %>

    +
      +
    • + <%= raw(_("Can I request information about myself? " \ + "No!", + :url => help_requesting_path(:anchor => "data_protection").html_safe)) %> +
    • <%= _('Write your request in simple, precise language.') %>
    • <%= _('Ask for specific documents or ' \ 'information, this site is not suitable for general ' \ @@ -228,6 +226,36 @@ 'already publicly available.') %>
    + +
    +

    <%= _('Signing your request') %>

    + +
      +
    • + <% if @user %> + <%= raw(_('Everything that you enter on this page, including ' \ + 'your name ({{user_name}}), will ' \ + 'be displayed publicly on this ' \ + 'website forever', + user_name: @user.name, + url: help_privacy_path(anchor: 'public_request').html_safe)) %>. + <% else %> + <%= raw(_('Everything that you enter on this page, including ' \ + 'your name, will be displayed ' \ + 'publicly on this website ' \ + 'forever', + :url => help_privacy_path(:anchor => "public_request").html_safe)) %>. + <% end %> +
    • + + <% unless @user %> +
    • + <%= raw(_('Thinking of using a pseudonym?', + :url => help_privacy_path(:anchor => "real_name").html_safe)) %> +
    • + <% end %> +
    +
    diff --git a/app/views/request/preview.html.erb b/app/views/request/preview.html.erb index 5ba0c770bc..3f8ea1df4f 100644 --- a/app/views/request/preview.html.erb +++ b/app/views/request/preview.html.erb @@ -35,8 +35,13 @@ <% else %> <%=h(@info_request.public_body.name)%> <% end %> +

    +

    + <%= _('From') %> + <%= @user&.name || '…' %>

    +

    <%= _('Subject') %> <%= @info_request.email_subject_request %>

    diff --git a/app/views/users/messages/opted_out.html.erb b/app/views/users/messages/opted_out.html.erb new file mode 100644 index 0000000000..e7c5a49cc8 --- /dev/null +++ b/app/views/users/messages/opted_out.html.erb @@ -0,0 +1,7 @@ +<% @title = _('Cannot send messages') %> + +

    <%= @title %>

    + +

    + <%= _('This user does not accept user to user messages.') %> +

    diff --git a/app/views/users/messages/rate_limited.html.erb b/app/views/users/messages/rate_limited.html.erb new file mode 100644 index 0000000000..15771d8aeb --- /dev/null +++ b/app/views/users/messages/rate_limited.html.erb @@ -0,0 +1,18 @@ +<% @title = _('Too many messages') %> + +

    <%= @title %>

    + +

    + <%= _('You have hit the rate limit on user messages. Users are ordinarily ' \ + 'limited to {{message_limit}} messages per day.', + message_limit: User::CONTENT_LIMIT[:user_messages]) %> +

    + +

    + <%= _("There is a limit on the number of messages you can send in a day " \ + "because we don’t want users to be bombarded with " \ + "large numbers of inappropriate messages. If you feel you have a " \ + "good reason to ask for the limit to be lifted in your case, " \ + "please get in touch.", + help_contact_path: help_contact_path) %> +

    diff --git a/bin/bundle_next b/bin/bundle_next deleted file mode 100755 index 8ecdb29ee7..0000000000 --- a/bin/bundle_next +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -BUNDLE_GEMFILE=Gemfile.rails_next bundle "$@" diff --git a/bin/rails_next b/bin/rails_next deleted file mode 100755 index c5bcd59661..0000000000 --- a/bin/rails_next +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -BUNDLE_GEMFILE=Gemfile.rails_next bundle exec rails "$@" diff --git a/bin/rspec_next b/bin/rspec_next deleted file mode 100755 index 5e3d1f68b7..0000000000 --- a/bin/rspec_next +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -BUNDLE_GEMFILE=Gemfile.rails_next bundle exec rspec "$@" diff --git a/bin/sidekiq b/bin/sidekiq new file mode 100755 index 0000000000..e7af7e7eb5 --- /dev/null +++ b/bin/sidekiq @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'sidekiq' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("sidekiq", "sidekiq") diff --git a/bin/sidekiqmon b/bin/sidekiqmon new file mode 100755 index 0000000000..0c907984ee --- /dev/null +++ b/bin/sidekiqmon @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'sidekiqmon' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +bundle_binstub = File.expand_path("bundle", __dir__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300).include?("This file was generated by Bundler") + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("sidekiq", "sidekiqmon") diff --git a/commonlib b/commonlib index 6438360fd5..8b638d674b 160000 --- a/commonlib +++ b/commonlib @@ -1 +1 @@ -Subproject commit 6438360fd5700044fd00533056a6bc1ba4da575e +Subproject commit 8b638d674badcb1dc6a4867d9f49571caecc923c diff --git a/config/alert-tracks-debian.example b/config/alert-tracks-debian.example index eb9886147c..81ef1147f1 100755 --- a/config/alert-tracks-debian.example +++ b/config/alert-tracks-debian.example @@ -22,9 +22,11 @@ LOGDIR=<%= vhost_dir %>/<%= vcspath %>/log LOGFILE=$LOGDIR/<%= daemon_name %>.log DUSER=<%= user %> SITE_HOME=<%= vhost_dir %>/<%= vcspath %> -# Set RAILS_ENV - not needed if using config/rails_env.rb -# RAILS_ENV=<%= rails_env %> -# export RAILS_ENV + +<% unless rails_env_defined? %> +RAILS_ENV=<%= rails_env %> +export RAILS_ENV +<% end %> <% if use_rbenv? %> RBENV_ROOT="/home/<%= user %>/.rbenv" diff --git a/config/application.rb b/config/application.rb index 88995704d2..ef52d7f85f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -3,7 +3,7 @@ require "rails" # Pick the frameworks you want: require "active_model/railtie" -# require "active_job/railtie" +require "active_job/railtie" require "active_record/railtie" require "active_storage/engine" require "action_controller/railtie" @@ -22,10 +22,6 @@ # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) -def rails_upgrade? - %w[1 true].include?(ENV['RAILS_UPGRADE']) -end - module Alaveteli class Application < Rails::Application # Configuration for the application, engines, and railties goes here. @@ -35,12 +31,9 @@ class Application < Rails::Application # # config.time_zone = "Central Time (US & Canada)" # config.eager_load_paths << Rails.root.join("extras") - - if rails_upgrade? - config.autoloader = :zeitwerk - config.active_record.legacy_connection_handling = false - config.active_support.use_rfc4122_namespaced_uuids = true - end + config.autoloader = :zeitwerk + config.active_record.legacy_connection_handling = false + config.active_support.use_rfc4122_namespaced_uuids = true # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] @@ -70,21 +63,24 @@ class Application < Rails::Application # Note that having set a zone, the Active Record # time_zone_aware_attributes flag is on, so times from models # will be in this time zone - config.time_zone = ::AlaveteliConfiguration::time_zone + config.time_zone = ::AlaveteliConfiguration.time_zone # Set the cache to use a memcached backend config.cache_store = :mem_cache_store, - { :namespace => "#{AlaveteliConfiguration::domain}_#{RUBY_VERSION}" } + { namespace: "#{AlaveteliConfiguration.domain}_#{RUBY_VERSION}" } config.action_dispatch.rack_cache = nil + # Use a real queuing backend for Active Job + config.active_job.queue_adapter = :sidekiq + config.after_initialize do |app| # Add a catch-all route to force routing errors to be handled by the application, # rather than by middleware. - app.routes.append { match '*path', :to => 'general#not_found', :via => [:get, :post] } + app.routes.append { match '*path', to: 'general#not_found', via: [:get, :post] } end - config.autoload_paths << "#{Rails.root.to_s}/app/controllers/concerns" - config.autoload_paths << "#{Rails.root.to_s}/app/models/concerns" + config.autoload_paths << "#{Rails.root}/app/controllers/concerns" + config.autoload_paths << "#{Rails.root}/app/models/concerns" config.enable_dependency_loading = true @@ -94,7 +90,7 @@ class Application < Rails::Application # Insert a bit of middleware code to prevent uneeded cookie setting. require "#{Rails.root}/lib/strip_empty_sessions" - config.middleware.insert_before ::ActionDispatch::Cookies, StripEmptySessions, :key => '_wdtk_cookie_session', :path => "/", :httponly => true + config.middleware.insert_before ::ActionDispatch::Cookies, StripEmptySessions, key: '_wdtk_cookie_session', path: "/", httponly: true require "#{Rails.root}/lib/deeply_nested_params" config.middleware.insert Rack::Head, DeeplyNestedParams @@ -103,6 +99,6 @@ class Application < Rails::Application config.middleware.insert 0, Rack::UTF8Sanitizer # Allow the generation of full URLs in emails - config.action_mailer.default_url_options = { :host => AlaveteliConfiguration::domain } + config.action_mailer.default_url_options = { host: AlaveteliConfiguration.domain } end end diff --git a/config/boot.rb b/config/boot.rb index 2ef988ccf4..662856d3b3 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -2,11 +2,4 @@ require "bundler/setup" # Set up gems listed in the Gemfile. -# TODO: Remove this. This is a hacky system for having a default environment. -# It looks for a config/rails_env.rb file, and reads stuff from there if -# it exists. Put just a line like this in there: -# ENV['RAILS_ENV'] = 'production' -rails_env_file = File.expand_path(File.join(File.dirname(__FILE__), 'rails_env.rb')) -if File.exist?(rails_env_file) - require rails_env_file -end +require File.expand_path('load_env.rb', __dir__) diff --git a/config/deploy.rb b/config/deploy.rb index f1e548693b..f647dd4d05 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -16,7 +16,7 @@ set :rails_env, configuration['rails_env'] set :daemon_name, configuration.fetch('daemon_name', 'alaveteli') -server configuration['server'], :app, :web, :db, :primary => true +server configuration['server'], :app, :web, :db, primary: true set(:rbenv_ruby_version) do command = "cat #{shared_path}/rbenv-version 2>/dev/null || true" @@ -51,7 +51,7 @@ [:start, :stop, :restart].each do |t| desc "#{t.to_s.capitalize} Alaveteli service defined in /etc/init.d/" - task t, :roles => :app, :except => { :no_release => true } do + task t, roles: :app, except: { no_release: true } do run "/etc/init.d/#{ daemon_name } #{ t }" end end @@ -71,7 +71,7 @@ "#{release_path}/log" => "#{shared_path}/log", "#{release_path}/tmp/pids" => "#{shared_path}/tmp/pids", "#{release_path}/lib/acts_as_xapian/xapiandbs" => "#{shared_path}/xapiandbs", - "#{release_path}/lib/themes" => "#{shared_path}/themes", + "#{release_path}/lib/themes" => "#{shared_path}/themes" } if rbenv_ruby_version diff --git a/config/environments/development.rb b/config/environments/development.rb index b63b66a169..a92d6846b3 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -64,10 +64,6 @@ # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true - # Use an evented file watcher to asynchronously detect changes in source code, - # routes, locales, etc. This feature depends on the listen gem. - config.file_watcher = ActiveSupport::EventedFileUpdateChecker - # Uncomment if you wish to allow Action Cable access from any origin. # config.action_cable.disable_request_forgery_protection = true @@ -92,7 +88,8 @@ if AlaveteliConfiguration.use_mailcatcher_in_development # So is queued, rather than giving immediate errors config.action_mailer.delivery_method = :smtp - config.action_mailer.smtp_settings = { :address => "localhost", :port => 1025 } + smtp = URI.parse(ENV.fetch('SMTP_URL', 'smtp://localhost:1025')) + config.action_mailer.smtp_settings = { address: smtp.host, port: smtp.port } else config.action_mailer.delivery_method = :sendmail end diff --git a/config/environments/production.rb b/config/environments/production.rb index 8962c5835b..dc04044cf5 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -120,13 +120,13 @@ if AlaveteliConfiguration.production_mailer_delivery_method.to_sym == :smtp config.action_mailer.smtp_settings = { - :address => AlaveteliConfiguration.smtp_mailer_address, - :port => AlaveteliConfiguration.smtp_mailer_port, - :domain => AlaveteliConfiguration.smtp_mailer_domain, - :user_name => AlaveteliConfiguration.smtp_mailer_user_name, - :password => AlaveteliConfiguration.smtp_mailer_password, - :authentication => AlaveteliConfiguration.smtp_mailer_authentication, - :enable_starttls_auto => AlaveteliConfiguration.smtp_mailer_enable_starttls_auto + address: AlaveteliConfiguration.smtp_mailer_address, + port: AlaveteliConfiguration.smtp_mailer_port, + domain: AlaveteliConfiguration.smtp_mailer_domain, + user_name: AlaveteliConfiguration.smtp_mailer_user_name, + password: AlaveteliConfiguration.smtp_mailer_password, + authentication: AlaveteliConfiguration.smtp_mailer_authentication, + enable_starttls_auto: AlaveteliConfiguration.smtp_mailer_enable_starttls_auto } end diff --git a/config/environments/test.rb b/config/environments/test.rb index c2c9e92e57..b8109c174c 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -26,6 +26,9 @@ config.action_controller.perform_caching = false config.cache_store = :null_store + # Use inline processing for Active Job + config.active_job.queue_adapter = :test + # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false @@ -75,9 +78,9 @@ if !AlaveteliConfiguration.exception_notifications_from.blank? && !AlaveteliConfiguration.exception_notifications_to.blank? middleware.use ExceptionNotification::Rack, - :email => { - :sender_address => AlaveteliConfiguration.exception_notifications_from, - :exception_recipients => AlaveteliConfiguration.exception_notifications_to + email: { + sender_address: AlaveteliConfiguration.exception_notifications_from, + exception_recipients: AlaveteliConfiguration.exception_notifications_to } end end diff --git a/config/general.yml-example b/config/general.yml-example index c1bfbcd1a1..5f3811de7e 100644 --- a/config/general.yml-example +++ b/config/general.yml-example @@ -952,6 +952,13 @@ BLOCK_SPAM_ABOUT_ME_TEXT: false # --- BLOCK_SPAM_COMMENTS: false +# Prevent users submitting user to user messages that appear to be spam. +# +# BLOCK_SPAM_USER_MESSAGES - Boolean (default: false) +# +# --- +BLOCK_SPAM_USER_MESSAGES: false + # Prevent user signups from spam email domains or names which appear to be spam. # # BLOCK_SPAM_SIGNUPS - Boolean (default: false) @@ -1282,3 +1289,19 @@ SURVEY_URL: '' # # --- USER_SIGN_IN_ACTIVITY_RETENTION_DAYS: 0 + +# Background jobs are processed by Rails' ActiveJob using Sidekiq. There are +# various ways to run Sidekiq depending to server resources and technical +# knowledge in order to run and maintain a Redis server. +# +# Can either be set to: +# - 'inline' to process jobs within the web application process, this was the +# default option up until Alaveteli 0.42 and doesn't require Redis to be. +# installed. Due to issues with requests with web requests timing out this has +# been superseded by the other options. +# - 'server' to process job by a server running as a system daemon. +# +# BACKGROUND_JOBS – String (default: 'server') +# +# --- +BACKGROUND_JOBS: 'server' diff --git a/config/httpd.conf-example b/config/httpd.conf-example index d545c419b1..8701159eea 100644 --- a/config/httpd.conf-example +++ b/config/httpd.conf-example @@ -23,7 +23,6 @@ # App server configuration PassengerAppRoot /var/www/alaveteli - PassengerResolveSymlinksInDocumentRoot on # Uncomment the following line if you want to run Alaveteli # with the ruby set by rbenv @@ -149,7 +148,7 @@ # Include optional configuration - Include vhost.d/alaveteli/*.conf + IncludeOptional vhost.d/alaveteli/*.conf diff --git a/config/initializers/alaveteli.rb b/config/initializers/alaveteli.rb index 463f9546bd..c2e41bd542 100644 --- a/config/initializers/alaveteli.rb +++ b/config/initializers/alaveteli.rb @@ -1,5 +1,5 @@ # MySociety specific helper functions -$:.push(File.join(File.dirname(__FILE__), '../../commonlib/rblib')) +$LOAD_PATH.push(File.join(File.dirname(__FILE__), '../../commonlib/rblib')) # ... if these fail to include, you need the commonlib submodule from git # (type "git submodule update --init" in the whatdotheyknow directory) @@ -10,7 +10,7 @@ load "util.rb" # Application version -ALAVETELI_VERSION = '0.42.0.1' +ALAVETELI_VERSION = '0.43.0.0' # Add new inflection rules using the following format # (all these examples are active by default): @@ -27,7 +27,7 @@ # Domain for URLs (so can work for scripts, not just web pages) -ActionMailer::Base.default_url_options[:host] = AlaveteliConfiguration::domain +ActionMailer::Base.default_url_options[:host] = AlaveteliConfiguration.domain # Load monkey patches and other things from lib/ require 'core_ext/warning' diff --git a/config/initializers/secure_headers.rb b/config/initializers/secure_headers.rb index 497d9c8d35..6129358dff 100644 --- a/config/initializers/secure_headers.rb +++ b/config/initializers/secure_headers.rb @@ -1,7 +1,7 @@ ::SecureHeaders::Configuration.default do |config| # https://tools.ietf.org/html/rfc6797 - if AlaveteliConfiguration::force_ssl + if AlaveteliConfiguration.force_ssl config.hsts = "max-age=#{20.years.to_i}; includeSubdomains" else config.hsts = SecureHeaders::OPT_OUT #don't send on non https sites diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index fec425e293..d1fe3b2487 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,3 +1,3 @@ # Be sure to restart your server when you modify this file. -Rails.application.config.session_store :cookie_store, :key => '_wdtk_cookie_session' +Rails.application.config.session_store :cookie_store, key: '_wdtk_cookie_session' diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb new file mode 100644 index 0000000000..171e7d8c8e --- /dev/null +++ b/config/initializers/sidekiq.rb @@ -0,0 +1,26 @@ +require File.expand_path('../load_env.rb', __dir__) + +def redis_config + { url: ENV['REDIS_URL'], password: ENV['REDIS_PASSWORD'] }. + merge(redis_sentinel_config) +end + +def redis_sentinel_config + return {} unless ENV['REDIS_SENTINELS'] + + sentinels = ENV['REDIS_SENTINELS'].split(',').map do |ip_and_port| + ip, port = ip_and_port.split(/:(\d+)$/) + ip = Regexp.last_match[1] if ip =~ /\[(.*?)\]/ + { host: ip, port: port&.to_i || 26_379 } + end + + { sentinels: sentinels, role: :master } +end + +Sidekiq.configure_client do |config| + config.redis = redis_config +end + +Sidekiq.configure_server do |config| + config.redis = redis_config +end diff --git a/config/initializers/theme_loader.rb b/config/initializers/theme_loader.rb index bd8dc69cdf..ab694b522a 100644 --- a/config/initializers/theme_loader.rb +++ b/config/initializers/theme_loader.rb @@ -28,11 +28,9 @@ def require_theme(theme_name) # By setting this ALAVETELI_TEST_THEME to a theme name, theme tests can run in the Rails # context with the theme loaded. Otherwise the themes from the config aren't loaded in testing # so they don't interfere with core Alaveteli tests - if defined? ALAVETELI_TEST_THEME - require_theme(ALAVETELI_TEST_THEME) - end + require_theme(ALAVETELI_TEST_THEME) if defined? ALAVETELI_TEST_THEME else - for url in AlaveteliConfiguration::theme_urls.reverse + AlaveteliConfiguration.theme_urls.reverse.each do |url| require_theme theme_url_to_theme_name(url) end end diff --git a/config/load_env.rb b/config/load_env.rb new file mode 100644 index 0000000000..3b257efd3a --- /dev/null +++ b/config/load_env.rb @@ -0,0 +1,7 @@ +# TODO: Remove this. This is a hacky system for having a default environment. +# It looks for a config/rails_env.rb file, and reads stuff from there if +# it exists. Put just a line like this in there: +# ENV['RAILS_ENV'] = 'production' + +rails_env_file = File.expand_path('rails_env.rb', __dir__) +require rails_env_file if File.exist?(rails_env_file) diff --git a/config/packages b/config/packages index cc263a015f..fbccd7733a 100644 --- a/config/packages +++ b/config/packages @@ -26,6 +26,7 @@ pdftk (>> 1.41+dfsg-1) | pdftk (<< 1.41+dfsg-1) # that version has a non-functio poppler-utils rake (>= 0.9.2.2) rdoc +redis ruby ruby-dev sqlite3 diff --git a/config/packages.generic b/config/packages.generic index 8fc93212d4..c57c7f05a0 100644 --- a/config/packages.generic +++ b/config/packages.generic @@ -22,6 +22,7 @@ poppler-utils postgresql postgresql-client rake +redis ruby ruby-dev sqlite3 diff --git a/config/packages.ubuntu-focal b/config/packages.ubuntu-focal index 3d110d05da..cdf44a01b9 100644 --- a/config/packages.ubuntu-focal +++ b/config/packages.ubuntu-focal @@ -22,6 +22,7 @@ poppler-utils postgresql postgresql-client rake +redis ruby ruby-dev sqlite3 diff --git a/config/poll-for-incoming-debian.example b/config/poll-for-incoming-debian.example index 01403e3955..45922c2d06 100755 --- a/config/poll-for-incoming-debian.example +++ b/config/poll-for-incoming-debian.example @@ -22,9 +22,11 @@ LOGDIR=<%= vhost_dir %>/<%= vcspath %>/log LOGFILE=$LOGDIR/<%= daemon_name %>.log DUSER=<%= user %> SITE_HOME=<%= vhost_dir %>/<%= vcspath %> -# Set RAILS_ENV - not needed if using config/rails_env.rb -# RAILS_ENV=<%= rails_env %> -# export RAILS_ENV + +<% unless rails_env_defined? %> +RAILS_ENV=<%= rails_env %> +export RAILS_ENV +<% end %> <% if use_rbenv? %> RBENV_ROOT="/home/<%= user %>/.rbenv" diff --git a/config/preinitializer.rb b/config/preinitializer.rb index 9836dad79c..beca9f5ac4 100644 --- a/config/preinitializer.rb +++ b/config/preinitializer.rb @@ -6,8 +6,8 @@ end if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24") - raise RuntimeError, "Your bundler version is too old for Rails 2.3." + - "Run `gem install bundler` to upgrade." + raise "Your bundler version is too old for Rails 2.3. Run `gem install " \ + "bundler` to upgrade." end begin @@ -15,6 +15,5 @@ ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__) Bundler.setup rescue Bundler::GemNotFound - raise RuntimeError, "Bundler couldn't find some gems." + - "Did you run `bundle install`?" + raise "Bundler couldn't find some gems. Did you run `bundle install`?" end diff --git a/config/rails_env.rb-example b/config/rails_env.rb-example new file mode 100644 index 0000000000..98950617ae --- /dev/null +++ b/config/rails_env.rb-example @@ -0,0 +1 @@ +# This file is needed for the mySociety deployment system diff --git a/config/routes.rb b/config/routes.rb index 2c3ac6875f..5fac394134 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,8 @@ # Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved. # Email: hello@mysociety.org; WWW: http://www.mysociety.org/ +require 'sidekiq/web' + include AlaveteliFeatures::Constraints # Allow easy extension from themes. Note these will have the highest priority. @@ -11,8 +13,18 @@ load File.join('config', f) end +class AdminConstraint # :nodoc: + def matches?(request) + user = User.find_by( + id: request.session[:user_id], + login_token: request.session[:user_login_token] + ) + user && user.is_admin? + end +end + Rails.application.routes.draw do - admin_constraint = lambda { |request| request.session[:using_admin] } + mount Sidekiq::Web => '/sidekiq', constraints: AdminConstraint.new root to: 'general#frontpage' @@ -197,12 +209,17 @@ resources :contributors, only: [:destroy] resource :download, only: [:show], format: true + resource :leaderboard, only: [:show], format: true end end end #### - resources :health_checks, :only => [:index] + namespace :health do + resources :checks, :only => [:index] + resources :metrics, :only => [:index], :defaults => { :format => 'txt' } + end + get '/health_checks' => redirect('/health/checks') resources :request, :only => [] do resource :report, :only => [:new, :create] @@ -482,6 +499,12 @@ resources :announcements, :only => [:destroy] #### + #### Admin::BlogPosts controller + namespace :admin do + resources :blog_posts, only: [:index, :edit, :update] + end + #### + #### AdminTag controller namespace :admin do resources :tags, param: :tag, only: [:index, :show] diff --git a/config/send-notifications-debian.example b/config/send-notifications-debian.example index 08fe801ef0..a62b11c003 100755 --- a/config/send-notifications-debian.example +++ b/config/send-notifications-debian.example @@ -22,9 +22,11 @@ LOGDIR=<%= vhost_dir %>/<%= vcspath %>/log LOGFILE=$LOGDIR/<%= daemon_name %>.log DUSER=<%= user %> SITE_HOME=<%= vhost_dir %>/<%= vcspath %> -# Set RAILS_ENV - not needed if using config/rails_env.rb -# RAILS_ENV=<%= rails_env %> -# export RAILS_ENV + +<% unless rails_env_defined? %> +RAILS_ENV=<%= rails_env %> +export RAILS_ENV +<% end %> <% if use_rbenv? %> RBENV_ROOT="/home/<%= user %>/.rbenv" diff --git a/config/sidekiq.service.example b/config/sidekiq.service.example new file mode 100644 index 0000000000..167d7c8200 --- /dev/null +++ b/config/sidekiq.service.example @@ -0,0 +1,22 @@ +[Unit] +Description=<%= daemon_name %> +After=syslog.target network.target + +[Service] +Type=notify + +WatchdogSec=10 + +User=<%= user %> +Group=<%= user %> +UMask=0002 + +WorkingDirectory=<%= vhost_dir %>/<%= vcspath %> + +ExecStart=/bin/bash -lc 'bundle exec sidekiq -e <%= rails_env %>' + +RestartSec=1 +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/config/sidekiq.yml b/config/sidekiq.yml new file mode 100644 index 0000000000..8c67045671 --- /dev/null +++ b/config/sidekiq.yml @@ -0,0 +1,6 @@ +development: + :concurrency: 1 +production: + :concurrency: 1 +:queues: + - default diff --git a/config/sysvinit-thin.example b/config/sysvinit-thin.example index 987f3ac233..f42ba66152 100755 --- a/config/sysvinit-thin.example +++ b/config/sysvinit-thin.example @@ -19,9 +19,11 @@ SITE_HOME=<%= vhost_dir %>/<%= vcspath %> DESC="Alaveteli app server" USER=<%= user %> CPUS=<%= cpus %> -# Set RAILS_ENV - not needed if using config/rails_env.rb -# RAILS_ENV=<%= rails_env %> -# export RAILS_ENV + +<% unless rails_env_defined? %> +RAILS_ENV=<%= rails_env %> +export RAILS_ENV +<% end %> CMD="bundle exec thin" diff --git a/config/test.yml b/config/test.yml index ff5c415084..1f596a1600 100644 --- a/config/test.yml +++ b/config/test.yml @@ -120,3 +120,5 @@ MAX_REQUESTS_PER_USER_PER_DAY: 2 SKIP_ADMIN_AUTH: true UTILITY_SEARCH_PATH: [] + +BACKGROUND_JOBS: 'server' diff --git a/db/migrate/006_version_public_body.rb b/db/migrate/006_version_public_body.rb index 60f1579d6f..0a999cdbc4 100644 --- a/db/migrate/006_version_public_body.rb +++ b/db/migrate/006_version_public_body.rb @@ -2,7 +2,7 @@ class VersionPublicBody < ActiveRecord::Migration[4.2] # 1.2 def self.up PublicBody.create_versioned_table - add_timestamps(:public_body_versions, :null => false) + add_timestamps(:public_body_versions, null: false) end def self.down diff --git a/db/migrate/017_add_email_confirmed_to_users.rb b/db/migrate/017_add_email_confirmed_to_users.rb index c6327b9251..b9e8e7177b 100644 --- a/db/migrate/017_add_email_confirmed_to_users.rb +++ b/db/migrate/017_add_email_confirmed_to_users.rb @@ -1,6 +1,6 @@ class AddEmailConfirmedToUsers < ActiveRecord::Migration[4.2] # 1.2 def self.up - add_column :users, :email_confirmed, :boolean, :default => false + add_column :users, :email_confirmed, :boolean, default: false end def self.down diff --git a/db/migrate/018_add_response_type_to_incoming_message.rb b/db/migrate/018_add_response_type_to_incoming_message.rb index 38c3744cd8..90fb31e37f 100644 --- a/db/migrate/018_add_response_type_to_incoming_message.rb +++ b/db/migrate/018_add_response_type_to_incoming_message.rb @@ -1,7 +1,7 @@ class AddResponseTypeToIncomingMessage < ActiveRecord::Migration[4.2] # 1.2 def self.up - add_column :incoming_messages, :user_classified, :boolean, :default => false - add_column :incoming_messages, :contains_information, :boolean, :default => false + add_column :incoming_messages, :user_classified, :boolean, default: false + add_column :incoming_messages, :contains_information, :boolean, default: false create_table :rejection_reasons do |t| t.column :incoming_message_id, :integer diff --git a/db/migrate/021_remove_contains_information_default.rb b/db/migrate/021_remove_contains_information_default.rb index a82d1034e2..e9abe404e9 100644 --- a/db/migrate/021_remove_contains_information_default.rb +++ b/db/migrate/021_remove_contains_information_default.rb @@ -1,11 +1,11 @@ class RemoveContainsInformationDefault < ActiveRecord::Migration[4.2] # 1.2 def self.up - change_column :incoming_messages, :contains_information, :boolean, :default => nil + change_column :incoming_messages, :contains_information, :boolean, default: nil drop_table :rejection_reasons end def self.down - change_column :incoming_messages, :contains_information, :boolean, :default => false + change_column :incoming_messages, :contains_information, :boolean, default: false create_table :rejection_reasons do |t| t.column :incoming_message_id, :integer t.column :reason, :string diff --git a/db/migrate/022_create_info_request_events.rb b/db/migrate/022_create_info_request_events.rb index 53b6bd9af3..0b116d000e 100644 --- a/db/migrate/022_create_info_request_events.rb +++ b/db/migrate/022_create_info_request_events.rb @@ -11,7 +11,7 @@ def self.up InfoRequest.find_each do |info_request| info_request_event = InfoRequestEvent.new info_request_event.event_type = 'sent' - info_request_event.params = { :email => info_request.recipient_email, :outgoing_message_id => info_request.outgoing_messages[0].id } + info_request_event.params = { email: info_request.recipient_email, outgoing_message_id: info_request.outgoing_messages[0].id } info_request_event.info_request = info_request info_request_event.created_at = info_request.outgoing_messages[0].sent_at info_request_event.save! diff --git a/db/migrate/024_add_is_bounce_to_incoming_messages.rb b/db/migrate/024_add_is_bounce_to_incoming_messages.rb index 6e60ca726e..383e0f4674 100644 --- a/db/migrate/024_add_is_bounce_to_incoming_messages.rb +++ b/db/migrate/024_add_is_bounce_to_incoming_messages.rb @@ -1,6 +1,6 @@ class AddIsBounceToIncomingMessages < ActiveRecord::Migration[4.2] # 2.0 def self.up - add_column :incoming_messages, :is_bounce, :boolean, :default => false + add_column :incoming_messages, :is_bounce, :boolean, default: false IncomingMessage.update_all "is_bounce = 'f'" end diff --git a/db/migrate/026_add_many_null_constraints.rb b/db/migrate/026_add_many_null_constraints.rb index 693769b1f1..0e98514b67 100644 --- a/db/migrate/026_add_many_null_constraints.rb +++ b/db/migrate/026_add_many_null_constraints.rb @@ -1,103 +1,103 @@ class AddManyNullConstraints < ActiveRecord::Migration[4.2] # 2.0 def self.up - change_column :users, :email, :string, :null => false - change_column :users, :name, :string, :null => false - change_column :users, :hashed_password, :string, :null => false - change_column :users, :salt, :string, :null => false - change_column :users, :created_at, :datetime, :null => false - change_column :users, :updated_at, :datetime, :null => false - change_column :users, :email_confirmed, :boolean, :null => false, :default =>false + change_column :users, :email, :string, null: false + change_column :users, :name, :string, null: false + change_column :users, :hashed_password, :string, null: false + change_column :users, :salt, :string, null: false + change_column :users, :created_at, :datetime, null: false + change_column :users, :updated_at, :datetime, null: false + change_column :users, :email_confirmed, :boolean, null: false, default: false - change_column :public_bodies, :name, :text, :null => false - change_column :public_bodies, :short_name, :text, :null => false - change_column :public_bodies, :request_email, :text, :null => false - change_column :public_bodies, :version, :integer, :null => false - change_column :public_bodies, :last_edit_editor, :string, :null => false - change_column :public_bodies, :last_edit_comment, :text, :null => false - change_column :public_bodies, :created_at, :datetime, :null => false - change_column :public_bodies, :updated_at, :datetime, :null => false + change_column :public_bodies, :name, :text, null: false + change_column :public_bodies, :short_name, :text, null: false + change_column :public_bodies, :request_email, :text, null: false + change_column :public_bodies, :version, :integer, null: false + change_column :public_bodies, :last_edit_editor, :string, null: false + change_column :public_bodies, :last_edit_comment, :text, null: false + change_column :public_bodies, :created_at, :datetime, null: false + change_column :public_bodies, :updated_at, :datetime, null: false - change_column :post_redirects, :token, :text, :null => false - change_column :post_redirects, :uri, :text, :null => false - change_column :post_redirects, :created_at, :datetime, :null => false - change_column :post_redirects, :updated_at, :datetime, :null => false - change_column :post_redirects, :email_token, :text, :null => false + change_column :post_redirects, :token, :text, null: false + change_column :post_redirects, :uri, :text, null: false + change_column :post_redirects, :created_at, :datetime, null: false + change_column :post_redirects, :updated_at, :datetime, null: false + change_column :post_redirects, :email_token, :text, null: false - change_column :outgoing_messages, :info_request_id, :integer, :null => false - change_column :outgoing_messages, :body, :text, :null => false - change_column :outgoing_messages, :status, :string, :null => false - change_column :outgoing_messages, :message_type, :string, :null => false - change_column :outgoing_messages, :created_at, :datetime, :null => false - change_column :outgoing_messages, :updated_at, :datetime, :null => false + change_column :outgoing_messages, :info_request_id, :integer, null: false + change_column :outgoing_messages, :body, :text, null: false + change_column :outgoing_messages, :status, :string, null: false + change_column :outgoing_messages, :message_type, :string, null: false + change_column :outgoing_messages, :created_at, :datetime, null: false + change_column :outgoing_messages, :updated_at, :datetime, null: false - change_column :info_requests, :title, :text, :null => false - change_column :info_requests, :user_id, :integer, :null => false - change_column :info_requests, :public_body_id, :integer, :null => false - change_column :info_requests, :created_at, :datetime, :null => false - change_column :info_requests, :updated_at, :datetime, :null => false + change_column :info_requests, :title, :text, null: false + change_column :info_requests, :user_id, :integer, null: false + change_column :info_requests, :public_body_id, :integer, null: false + change_column :info_requests, :created_at, :datetime, null: false + change_column :info_requests, :updated_at, :datetime, null: false - change_column :info_request_events, :info_request_id, :integer, :null => false - change_column :info_request_events, :event_type, :text, :null => false - change_column :info_request_events, :params_yaml, :text, :null => false - change_column :info_request_events, :created_at, :datetime, :null => false + change_column :info_request_events, :info_request_id, :integer, null: false + change_column :info_request_events, :event_type, :text, null: false + change_column :info_request_events, :params_yaml, :text, null: false + change_column :info_request_events, :created_at, :datetime, null: false - change_column :incoming_messages, :info_request_id, :integer, :null => false - change_column :incoming_messages, :raw_data, :text, :null => false - change_column :incoming_messages, :created_at, :datetime, :null => false - change_column :incoming_messages, :updated_at, :datetime, :null => false - change_column :incoming_messages, :user_classified, :boolean, :null => false, :default => false - change_column :incoming_messages, :is_bounce, :boolean, :null => false, :default => false + change_column :incoming_messages, :info_request_id, :integer, null: false + change_column :incoming_messages, :raw_data, :text, null: false + change_column :incoming_messages, :created_at, :datetime, null: false + change_column :incoming_messages, :updated_at, :datetime, null: false + change_column :incoming_messages, :user_classified, :boolean, null: false, default: false + change_column :incoming_messages, :is_bounce, :boolean, null: false, default: false end def self.down - change_column :users, :email, :string, :null => true - change_column :users, :name, :string, :null => true - change_column :users, :hashed_password, :string, :null => true - change_column :users, :salt, :string, :null => true - change_column :users, :created_at, :datetime, :null => true - change_column :users, :updated_at, :datetime, :null => true - change_column :users, :email_confirmed, :boolean, :null => true, :default =>false + change_column :users, :email, :string, null: true + change_column :users, :name, :string, null: true + change_column :users, :hashed_password, :string, null: true + change_column :users, :salt, :string, null: true + change_column :users, :created_at, :datetime, null: true + change_column :users, :updated_at, :datetime, null: true + change_column :users, :email_confirmed, :boolean, null: true, default: false - change_column :public_bodies, :name, :text, :null => true - change_column :public_bodies, :short_name, :text, :null => true - change_column :public_bodies, :request_email, :text, :null => true - change_column :public_bodies, :version, :integer, :null => true - change_column :public_bodies, :last_edit_editor, :string, :null => true - change_column :public_bodies, :last_edit_comment, :string, :null => true - change_column :public_bodies, :created_at, :datetime, :null => true - change_column :public_bodies, :updated_at, :datetime, :null => true + change_column :public_bodies, :name, :text, null: true + change_column :public_bodies, :short_name, :text, null: true + change_column :public_bodies, :request_email, :text, null: true + change_column :public_bodies, :version, :integer, null: true + change_column :public_bodies, :last_edit_editor, :string, null: true + change_column :public_bodies, :last_edit_comment, :string, null: true + change_column :public_bodies, :created_at, :datetime, null: true + change_column :public_bodies, :updated_at, :datetime, null: true - change_column :post_redirects, :token, :text, :null => true - change_column :post_redirects, :uri, :text, :null => true - change_column :post_redirects, :created_at, :datetime, :null => true - change_column :post_redirects, :updated_at, :datetime, :null => true - change_column :post_redirects, :email_token, :text, :null => true + change_column :post_redirects, :token, :text, null: true + change_column :post_redirects, :uri, :text, null: true + change_column :post_redirects, :created_at, :datetime, null: true + change_column :post_redirects, :updated_at, :datetime, null: true + change_column :post_redirects, :email_token, :text, null: true - change_column :outgoing_messages, :info_request_id, :integer, :null => true - change_column :outgoing_messages, :body, :text, :null => true - change_column :outgoing_messages, :status, :string, :null => true - change_column :outgoing_messages, :message_type, :string, :null => true - change_column :outgoing_messages, :created_at, :datetime, :null => true - change_column :outgoing_messages, :updated_at, :datetime, :null => true + change_column :outgoing_messages, :info_request_id, :integer, null: true + change_column :outgoing_messages, :body, :text, null: true + change_column :outgoing_messages, :status, :string, null: true + change_column :outgoing_messages, :message_type, :string, null: true + change_column :outgoing_messages, :created_at, :datetime, null: true + change_column :outgoing_messages, :updated_at, :datetime, null: true - change_column :info_requests, :title, :text, :null => true - change_column :info_requests, :user_id, :integer, :null => true - change_column :info_requests, :public_body_id, :integer, :null => true - change_column :info_requests, :created_at, :datetime, :null => true - change_column :info_requests, :updated_at, :datetime, :null => true + change_column :info_requests, :title, :text, null: true + change_column :info_requests, :user_id, :integer, null: true + change_column :info_requests, :public_body_id, :integer, null: true + change_column :info_requests, :created_at, :datetime, null: true + change_column :info_requests, :updated_at, :datetime, null: true - change_column :info_request_events, :info_request_id, :integer, :null => true - change_column :info_request_events, :event_type, :text, :null => true - change_column :info_request_events, :params_yaml, :text, :null => true - change_column :info_request_events, :created_at, :datetime, :null => true + change_column :info_request_events, :info_request_id, :integer, null: true + change_column :info_request_events, :event_type, :text, null: true + change_column :info_request_events, :params_yaml, :text, null: true + change_column :info_request_events, :created_at, :datetime, null: true - change_column :incoming_messages, :info_request_id, :integer, :null => true - change_column :incoming_messages, :raw_data, :text, :null => true - change_column :incoming_messages, :created_at, :datetime, :null => true - change_column :incoming_messages, :updated_at, :datetime, :null => true - change_column :incoming_messages, :user_classified, :boolean, :null => true, :default => false - change_column :incoming_messages, :is_bounce, :boolean, :null => true, :default => false + change_column :incoming_messages, :info_request_id, :integer, null: true + change_column :incoming_messages, :raw_data, :text, null: true + change_column :incoming_messages, :created_at, :datetime, null: true + change_column :incoming_messages, :updated_at, :datetime, null: true + change_column :incoming_messages, :user_classified, :boolean, null: true, default: false + change_column :incoming_messages, :is_bounce, :boolean, null: true, default: false end end diff --git a/db/migrate/027_change_classification_system.rb b/db/migrate/027_change_classification_system.rb index 9f4b82691d..7be5014719 100644 --- a/db/migrate/027_change_classification_system.rb +++ b/db/migrate/027_change_classification_system.rb @@ -5,9 +5,9 @@ def self.up add_column :info_requests, :described_state, :string InfoRequest.update_all "described_state = 'waiting_response'" - change_column :info_requests, :described_state, :string, :null => false + change_column :info_requests, :described_state, :string, null: false - add_column :info_requests, :awaiting_description, :boolean, :default => false, :null => false + add_column :info_requests, :awaiting_description, :boolean, default: false, null: false InfoRequest.update_all "awaiting_description = 't' where (select count(*) from incoming_messages where info_request_id = info_requests.id) > 0" add_column :info_requests, :described_last_incoming_message_id, :integer diff --git a/db/migrate/028_give_incoming_messages_events.rb b/db/migrate/028_give_incoming_messages_events.rb index d1ee0f6086..341bfecb8e 100644 --- a/db/migrate/028_give_incoming_messages_events.rb +++ b/db/migrate/028_give_incoming_messages_events.rb @@ -9,7 +9,7 @@ def self.up IncomingMessage.find_each do |incoming_message| info_request_event = InfoRequestEvent.new info_request_event.event_type = 'response' - info_request_event.params = { :incoming_message_id => incoming_message.id } + info_request_event.params = { incoming_message_id: incoming_message.id } info_request_event.info_request = incoming_message.info_request info_request_event.created_at = incoming_message.created_at info_request_event.save! diff --git a/db/migrate/033_add_prominence.rb b/db/migrate/033_add_prominence.rb index 0052ce5de4..caff00b289 100644 --- a/db/migrate/033_add_prominence.rb +++ b/db/migrate/033_add_prominence.rb @@ -1,6 +1,6 @@ class AddProminence < ActiveRecord::Migration[4.2] # 2.0 def self.up - add_column :info_requests, :prominence, :string, :null => false, :default => 'normal' + add_column :info_requests, :prominence, :string, null: false, default: 'normal' end def self.down diff --git a/db/migrate/035_track_overdue_alerts.rb b/db/migrate/035_track_overdue_alerts.rb index c1a379fe74..c8ecce98b7 100644 --- a/db/migrate/035_track_overdue_alerts.rb +++ b/db/migrate/035_track_overdue_alerts.rb @@ -1,10 +1,10 @@ class TrackOverdueAlerts < ActiveRecord::Migration[4.2] # 2.0 def self.up create_table :user_info_request_sent_alerts do |t| - t.column :user_id, :integer, :null => false - t.column :info_request_id, :integer, :null => false + t.column :user_id, :integer, null: false + t.column :info_request_id, :integer, null: false - t.column :alert_type, :string, :null => false + t.column :alert_type, :string, null: false end if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" diff --git a/db/migrate/036_add_public_body_tags.rb b/db/migrate/036_add_public_body_tags.rb index 4b3f4efa89..7ed033f323 100644 --- a/db/migrate/036_add_public_body_tags.rb +++ b/db/migrate/036_add_public_body_tags.rb @@ -1,9 +1,9 @@ class AddPublicBodyTags < ActiveRecord::Migration[4.2] # 2.0 def self.up create_table :public_body_tags do |t| - t.column :public_body_id, :integer, :null => false - t.column :name, :text, :null => false - t.column :created_at, :datetime, :null => false + t.column :public_body_id, :integer, null: false + t.column :name, :text, null: false + t.column :created_at, :datetime, null: false end if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" @@ -13,7 +13,7 @@ def self.up # MySQL cannot index text blobs like this # TODO: perhaps should change :name to be a :string if ActiveRecord::Base.connection.adapter_name != "MySQL" - add_index :public_body_tags, [:public_body_id, :name], :unique => true + add_index :public_body_tags, [:public_body_id, :name], unique: true end end diff --git a/db/migrate/037_add_url_name.rb b/db/migrate/037_add_url_name.rb index 8536b7f2ca..f8e12f6db3 100644 --- a/db/migrate/037_add_url_name.rb +++ b/db/migrate/037_add_url_name.rb @@ -9,9 +9,9 @@ def self.up end # MySQL cannot index text blobs like this if ActiveRecord::Base.connection.adapter_name != "MySQL" - add_index :public_bodies, :url_name, :unique => true + add_index :public_bodies, :url_name, unique: true end - change_column :public_bodies, :url_name, :text, :null => false + change_column :public_bodies, :url_name, :text, null: false end def self.down diff --git a/db/migrate/038_add_more_url_names.rb b/db/migrate/038_add_more_url_names.rb index f64347bf1b..0ab90598cb 100644 --- a/db/migrate/038_add_more_url_names.rb +++ b/db/migrate/038_add_more_url_names.rb @@ -10,7 +10,7 @@ def self.up if ActiveRecord::Base.connection.adapter_name != "MySQL" add_index :users, :url_name end - change_column :users, :url_name, :text, :null => false + change_column :users, :url_name, :text, null: false end def self.down diff --git a/db/migrate/039_request_url_names.rb b/db/migrate/039_request_url_names.rb index 549a586f4b..4dff313092 100644 --- a/db/migrate/039_request_url_names.rb +++ b/db/migrate/039_request_url_names.rb @@ -8,9 +8,9 @@ def self.up end # MySQL cannot index text blobs like this if ActiveRecord::Base.connection.adapter_name != "MySQL" - add_index :info_requests, :url_title, :unique => true + add_index :info_requests, :url_title, unique: true end - change_column :info_requests, :url_title, :text, :null => false + change_column :info_requests, :url_title, :text, null: false end def self.down diff --git a/db/migrate/041_index_requests_with_solr.rb b/db/migrate/041_index_requests_with_solr.rb index e269a93fe1..6e8369efe5 100644 --- a/db/migrate/041_index_requests_with_solr.rb +++ b/db/migrate/041_index_requests_with_solr.rb @@ -1,6 +1,6 @@ class IndexRequestsWithSolr < ActiveRecord::Migration[4.2] # 2.0 def self.up - add_column :info_requests, :solr_up_to_date, :boolean, :default => false, :null => false + add_column :info_requests, :solr_up_to_date, :boolean, default: false, null: false add_index :info_requests, :solr_up_to_date end diff --git a/db/migrate/042_unique_user_urls.rb b/db/migrate/042_unique_user_urls.rb index 038d98d5aa..ecf9d80ee9 100644 --- a/db/migrate/042_unique_user_urls.rb +++ b/db/migrate/042_unique_user_urls.rb @@ -8,7 +8,7 @@ def self.up # MySQL cannot index text blobs like this if ActiveRecord::Base.connection.adapter_name != "MySQL" remove_index :users, :url_name - add_index :users, :url_name, :unique => true + add_index :users, :url_name, unique: true end end @@ -16,7 +16,7 @@ def self.down # MySQL cannot index text blobs like this if ActiveRecord::Base.connection.adapter_name != "MySQL" remove_index :users, :url_name - add_index :users, :url_name, :unique => false + add_index :users, :url_name, unique: false end end diff --git a/db/migrate/044_remove_is_bounce.rb b/db/migrate/044_remove_is_bounce.rb index f919a86ab7..f60479cd32 100644 --- a/db/migrate/044_remove_is_bounce.rb +++ b/db/migrate/044_remove_is_bounce.rb @@ -4,6 +4,6 @@ def self.up end def self.down - add_column :incoming_messages, :is_bounce, :boolean, :default => false + add_column :incoming_messages, :is_bounce, :boolean, default: false end end diff --git a/db/migrate/045_add_circumstance_to_post_redirect.rb b/db/migrate/045_add_circumstance_to_post_redirect.rb index b176518860..a538186228 100644 --- a/db/migrate/045_add_circumstance_to_post_redirect.rb +++ b/db/migrate/045_add_circumstance_to_post_redirect.rb @@ -1,8 +1,8 @@ class AddCircumstanceToPostRedirect < ActiveRecord::Migration[4.2] # 2.0 def self.up - add_column :post_redirects, :circumstance, :text, :default => "normal" + add_column :post_redirects, :circumstance, :text, default: "normal" PostRedirect.update_all "circumstance = 'normal'" - change_column :post_redirects, :circumstance, :text, :default => "normal", :null => false + change_column :post_redirects, :circumstance, :text, default: "normal", null: false end def self.down diff --git a/db/migrate/046_add_last_event_id_to_alert_table.rb b/db/migrate/046_add_last_event_id_to_alert_table.rb index 23e1bb0e20..cd25aaa4e6 100644 --- a/db/migrate/046_add_last_event_id_to_alert_table.rb +++ b/db/migrate/046_add_last_event_id_to_alert_table.rb @@ -1,6 +1,6 @@ class AddLastEventIdToAlertTable < ActiveRecord::Migration[4.2] # 2.0 def self.up - add_column :user_info_request_sent_alerts, :info_request_event_id, :integer, :default => nil + add_column :user_info_request_sent_alerts, :info_request_event_id, :integer, default: nil if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" execute "ALTER TABLE user_info_request_sent_alerts ADD CONSTRAINT fk_user_info_request_sent_alert_info_request_event FOREIGN KEY (info_request_event_id) REFERENCES info_request_events(id)" # The coalesce is because null values are considered not equal in SQL, and we want them diff --git a/db/migrate/047_add_calculated_state.rb b/db/migrate/047_add_calculated_state.rb index 18ce52526b..9372e56766 100644 --- a/db/migrate/047_add_calculated_state.rb +++ b/db/migrate/047_add_calculated_state.rb @@ -1,6 +1,6 @@ class AddCalculatedState < ActiveRecord::Migration[4.2] # 2.0 def self.up - add_column :info_request_events, :calculated_state, :string, :default => nil + add_column :info_request_events, :calculated_state, :string, default: nil end def self.down diff --git a/db/migrate/049_track_things.rb b/db/migrate/049_track_things.rb index e371dd74ab..e7fe3c05cd 100644 --- a/db/migrate/049_track_things.rb +++ b/db/migrate/049_track_things.rb @@ -1,15 +1,15 @@ class TrackThings < ActiveRecord::Migration[4.2] # 2.0 def self.up create_table :track_things do |t| - t.column :tracking_user_id, :integer, :null => false - t.column :track_query, :string, :null => false + t.column :tracking_user_id, :integer, null: false + t.column :track_query, :string, null: false # optional foreign key links, for displaying people who are tracking this on pages - t.column :info_request_id, :integer, :default => nil - t.column :tracked_user_id, :integer, :default => nil - t.column :public_body_id, :integer, :default => nil + t.column :info_request_id, :integer, default: nil + t.column :tracked_user_id, :integer, default: nil + t.column :public_body_id, :integer, default: nil - t.column :track_medium, :string, :null => false + t.column :track_medium, :string, null: false end if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" @@ -20,11 +20,11 @@ def self.up end create_table :track_things_sent_emails do |t| - t.column :track_thing_id, :integer, :null => false + t.column :track_thing_id, :integer, null: false - t.column :info_request_event_id, :integer, :default => nil - t.column :user_id, :integer, :default => nil - t.column :public_body_id, :integer, :default => nil + t.column :info_request_event_id, :integer, default: nil + t.column :user_id, :integer, default: nil + t.column :public_body_id, :integer, default: nil end if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" diff --git a/db/migrate/050_improve_track_things.rb b/db/migrate/050_improve_track_things.rb index de0d8ad590..399ef0f8ce 100644 --- a/db/migrate/050_improve_track_things.rb +++ b/db/migrate/050_improve_track_things.rb @@ -1,7 +1,7 @@ class ImproveTrackThings < ActiveRecord::Migration[4.2] # 2.0 def self.up # SQLite at least needs a default for this - add_column :track_things, :track_type, :string, :null => false, :default => "internal_error" + add_column :track_things, :track_type, :string, null: false, default: "internal_error" add_column :track_things, :created_at, :datetime add_column :track_things, :updated_at, :datetime @@ -10,7 +10,7 @@ def self.up add_column :users, :last_daily_track_email, :datetime User.update_all "last_daily_track_email = '2000-01-01'" - change_column :users, :last_daily_track_email, :datetime, :default => "2000-01-01" + change_column :users, :last_daily_track_email, :datetime, default: "2000-01-01" end def self.down diff --git a/db/migrate/051_add_track_things_unique_indices.rb b/db/migrate/051_add_track_things_unique_indices.rb index 9ac875e215..89e4caa1ce 100644 --- a/db/migrate/051_add_track_things_unique_indices.rb +++ b/db/migrate/051_add_track_things_unique_indices.rb @@ -1,6 +1,6 @@ class AddTrackThingsUniqueIndices < ActiveRecord::Migration[4.2] # 2.0 def self.up - add_index :track_things, [:tracking_user_id, :track_query], :unique => true + add_index :track_things, [:tracking_user_id, :track_query], unique: true # GRRR - this index confuses Rails migrations, and it makes part of the index but not all # of it for the schema.rb, and hence in test databases, and the test databases fail. # I guess the query in ./activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb diff --git a/db/migrate/052_include_event_foreign_references.rb b/db/migrate/052_include_event_foreign_references.rb index 40ba7d34b6..e17a007551 100644 --- a/db/migrate/052_include_event_foreign_references.rb +++ b/db/migrate/052_include_event_foreign_references.rb @@ -4,11 +4,11 @@ def self.up add_column :info_request_events, :outgoing_message_id, :integer InfoRequestEvent.find_each do |event| incoming_message = event.incoming_message_via_params - if not incoming_message.nil? + unless incoming_message.nil? event.incoming_message_id = incoming_message.id end outgoing_message = event.outgoing_message_via_params - if not outgoing_message.nil? + unless outgoing_message.nil? event.outgoing_message_id = outgoing_message.id end event.save! diff --git a/db/migrate/053_acts_as_xapian_migration.rb b/db/migrate/053_acts_as_xapian_migration.rb index 683fde32ff..1281bb494d 100644 --- a/db/migrate/053_acts_as_xapian_migration.rb +++ b/db/migrate/053_acts_as_xapian_migration.rb @@ -1,23 +1,26 @@ class ActsAsXapianMigration < ActiveRecord::Migration[4.2] # 2.0 def self.up create_table :acts_as_xapian_jobs do |t| - t.column :model, :string, :null => false - t.column :model_id, :integer, :null => false + t.column :model, :string, null: false + t.column :model_id, :integer, null: false - t.column :action, :string, :null => false + t.column :action, :string, null: false end - add_index :acts_as_xapian_jobs, [:model, :model_id], :unique => true + add_index :acts_as_xapian_jobs, [:model, :model_id], unique: true remove_index :info_requests, :solr_up_to_date remove_column :info_requests, :solr_up_to_date - InfoRequest.find_each { |i| i.calculate_event_states; STDERR.puts "calculate_event_states " + i.id.to_s } + InfoRequest.find_each do |i| + i.calculate_event_states + STDERR.puts "calculate_event_states " + i.id.to_s + end end def self.down drop_table :acts_as_xapian_jobs - add_column :info_requests, :solr_up_to_date, :boolean, :default => false, :null => false + add_column :info_requests, :solr_up_to_date, :boolean, default: false, null: false add_index :info_requests, :solr_up_to_date end end diff --git a/db/migrate/055_stop_new_responses.rb b/db/migrate/055_stop_new_responses.rb index 6fbf1ca33b..0bd72cb148 100644 --- a/db/migrate/055_stop_new_responses.rb +++ b/db/migrate/055_stop_new_responses.rb @@ -1,6 +1,6 @@ class StopNewResponses < ActiveRecord::Migration[4.2] # 2.0 def self.up - add_column :info_requests, :stop_new_responses, :boolean, :default => false, :null => false + add_column :info_requests, :stop_new_responses, :boolean, default: false, null: false end def self.down diff --git a/db/migrate/057_add_law_used.rb b/db/migrate/057_add_law_used.rb index bb9d9fc583..725e836794 100644 --- a/db/migrate/057_add_law_used.rb +++ b/db/migrate/057_add_law_used.rb @@ -1,6 +1,6 @@ class AddLawUsed < ActiveRecord::Migration[4.2] # 2.0 def self.up - add_column :info_requests, :law_used, :string, :null => false, :default => 'foi' + add_column :info_requests, :law_used, :string, null: false, default: 'foi' end def self.down diff --git a/db/migrate/059_add_url_notes.rb b/db/migrate/059_add_url_notes.rb index b78dacea0c..6e0ce4eb00 100644 --- a/db/migrate/059_add_url_notes.rb +++ b/db/migrate/059_add_url_notes.rb @@ -1,7 +1,7 @@ class AddUrlNotes < ActiveRecord::Migration[4.2] # 2.0 def self.up - add_column :public_bodies, :home_page, :text, :null => false, :default => "" - add_column :public_bodies, :notes, :text, :null => false, :default => "" + add_column :public_bodies, :home_page, :text, null: false, default: "" + add_column :public_bodies, :notes, :text, null: false, default: "" add_column :public_body_versions, :home_page, :text add_column :public_body_versions, :notes, :text end diff --git a/db/migrate/062_add_comments.rb b/db/migrate/062_add_comments.rb index 2dd28e5a58..dfdd481b1d 100644 --- a/db/migrate/062_add_comments.rb +++ b/db/migrate/062_add_comments.rb @@ -1,16 +1,16 @@ class AddComments < ActiveRecord::Migration[4.2] # 2.0 def self.up create_table :comments do |t| - t.column :user_id, :integer, :null => false - t.column :comment_type, :string, :null => false, :default => "internal_error" + t.column :user_id, :integer, null: false + t.column :comment_type, :string, null: false, default: "internal_error" t.column :info_request_id, :integer - t.column :body, :text, :null => false - t.column :visible, :boolean, :default => true, :null => false + t.column :body, :text, null: false + t.column :visible, :boolean, default: true, null: false - t.column :created_at, :datetime, :null => false - t.column :updated_at, :datetime, :null => false + t.column :created_at, :datetime, null: false + t.column :updated_at, :datetime, null: false end if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" diff --git a/db/migrate/063_add_admin_users.rb b/db/migrate/063_add_admin_users.rb index e4121515c1..1a050757c6 100644 --- a/db/migrate/063_add_admin_users.rb +++ b/db/migrate/063_add_admin_users.rb @@ -1,6 +1,6 @@ class AddAdminUsers < ActiveRecord::Migration[4.2] # 2.0 def self.up - add_column :users, :admin_level, :string, :null => false, :default => 'none' + add_column :users, :admin_level, :string, null: false, default: 'none' end def self.down diff --git a/db/migrate/065_add_comments_to_user_track.rb b/db/migrate/065_add_comments_to_user_track.rb index c8b03a5ce1..b5b2721094 100644 --- a/db/migrate/065_add_comments_to_user_track.rb +++ b/db/migrate/065_add_comments_to_user_track.rb @@ -1,7 +1,7 @@ class AddCommentsToUserTrack < ActiveRecord::Migration[4.2] # 2.1 def self.up TrackThing.update_all "track_query = replace(track_query, 'variety:sent ', '') where track_type in ('public_body_updates', 'user_updates')" - TrackThing.where(:track_type => 'user_updates').each do |track_thing| + TrackThing.where(track_type: 'user_updates').each do |track_thing| track_thing.track_query = track_thing.track_query.gsub(/^requested_by:([^\s]+)$/, "requested_by:\\1 OR commented_by:\\1") track_thing.save! end diff --git a/db/migrate/066_add_first_letter.rb b/db/migrate/066_add_first_letter.rb index 61d0ce7403..98d66bd674 100644 --- a/db/migrate/066_add_first_letter.rb +++ b/db/migrate/066_add_first_letter.rb @@ -3,7 +3,7 @@ def self.up add_column :public_bodies, :first_letter, :string add_index :public_bodies, :first_letter PublicBody.update_all "first_letter = upper(substr(name, 1, 1))" - change_column :public_bodies, :first_letter, :string, :null => false + change_column :public_bodies, :first_letter, :string, null: false end def self.down diff --git a/db/migrate/067_factor_out_raw_email.rb b/db/migrate/067_factor_out_raw_email.rb index 9bd77757b9..1d3b8da20f 100644 --- a/db/migrate/067_factor_out_raw_email.rb +++ b/db/migrate/067_factor_out_raw_email.rb @@ -1,17 +1,17 @@ class FactorOutRawEmail < ActiveRecord::Migration[4.2] # 2.1 def self.up create_table :raw_emails do |t| - t.column :data, :text, :null => false + t.column :data, :text, null: false end - add_column :incoming_messages, :raw_email_id, :integer, :null => true - change_column :incoming_messages, :raw_data, :text, :null => true + add_column :incoming_messages, :raw_email_id, :integer, null: true + change_column :incoming_messages, :raw_data, :text, null: true if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" execute "ALTER TABLE incoming_messages ADD CONSTRAINT fk_incoming_messages_raw_email FOREIGN KEY (raw_email_id) REFERENCES raw_emails(id)" end - IncomingMessage.find_each(:batch_size => 10) do |incoming_message| + IncomingMessage.find_each(batch_size: 10) do |incoming_message| if incoming_message.raw_email_id.nil? STDERR.puts "doing incoming_message id #{incoming_message.id}" ActiveRecord::Base.transaction do @@ -25,7 +25,7 @@ def self.up end end - change_column :incoming_messages, :raw_email_id, :integer, :null => false + change_column :incoming_messages, :raw_email_id, :integer, null: false remove_column :incoming_messages, :raw_data end diff --git a/db/migrate/068_add_censor_table.rb b/db/migrate/068_add_censor_table.rb index 4a5630a29e..489a746f69 100644 --- a/db/migrate/068_add_censor_table.rb +++ b/db/migrate/068_add_censor_table.rb @@ -5,14 +5,14 @@ def self.up t.column :user_id, :integer t.column :public_body_id, :integer - t.column :text, :text, :null => false - t.column :replacement, :text, :null => false + t.column :text, :text, null: false + t.column :replacement, :text, null: false - t.column :last_edit_editor, :string, :null => false - t.column :last_edit_comment, :text, :null => false + t.column :last_edit_editor, :string, null: false + t.column :last_edit_comment, :text, null: false - t.column :created_at, :datetime, :null => false - t.column :updated_at, :datetime, :null => false + t.column :created_at, :datetime, null: false + t.column :updated_at, :datetime, null: false end if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" diff --git a/db/migrate/069_add_what_doing.rb b/db/migrate/069_add_what_doing.rb index 38cca80d29..35b39cdcff 100644 --- a/db/migrate/069_add_what_doing.rb +++ b/db/migrate/069_add_what_doing.rb @@ -3,7 +3,7 @@ def self.up add_column :outgoing_messages, :what_doing, :string add_index :outgoing_messages, :what_doing OutgoingMessage.update_all "what_doing = 'normal_sort'" - change_column :outgoing_messages, :what_doing, :string, :null => false + change_column :outgoing_messages, :what_doing, :string, null: false end def self.down diff --git a/db/migrate/071_add_exim_log.rb b/db/migrate/071_add_exim_log.rb index f2b15f53f7..19e3d70c5a 100644 --- a/db/migrate/071_add_exim_log.rb +++ b/db/migrate/071_add_exim_log.rb @@ -4,19 +4,19 @@ def self.up t.column :exim_log_done_id, :integer t.column :info_request_id, :integer - t.column :order, :integer, :null => false - t.column :line, :text, :null => false + t.column :order, :integer, null: false + t.column :line, :text, null: false - t.column :created_at, :datetime, :null => false - t.column :updated_at, :datetime, :null => false + t.column :created_at, :datetime, null: false + t.column :updated_at, :datetime, null: false end create_table :exim_log_dones do |t| - t.column :filename, :text, :null => false, :unique => true - t.column :last_stat, :datetime, :null => false + t.column :filename, :text, null: false, unique: true + t.column :last_stat, :datetime, null: false - t.column :created_at, :datetime, :null => false - t.column :updated_at, :datetime, :null => false + t.column :created_at, :datetime, null: false + t.column :updated_at, :datetime, null: false end add_index :exim_log_dones, :last_stat diff --git a/db/migrate/072_add_publication_scheme.rb b/db/migrate/072_add_publication_scheme.rb index aa966f80d2..d18fff0452 100644 --- a/db/migrate/072_add_publication_scheme.rb +++ b/db/migrate/072_add_publication_scheme.rb @@ -1,7 +1,7 @@ class AddPublicationScheme < ActiveRecord::Migration[4.2] # 2.1 def self.up - add_column :public_bodies, :publication_scheme, :text, :null => false, :default => "" - add_column :public_body_versions, :publication_scheme, :text, :null => false, :default => "" + add_column :public_bodies, :publication_scheme, :text, null: false, default: "" + add_column :public_body_versions, :publication_scheme, :text, null: false, default: "" end def self.down diff --git a/db/migrate/073_add_ban_user.rb b/db/migrate/073_add_ban_user.rb index 43baa6599d..f89e61c9c1 100644 --- a/db/migrate/073_add_ban_user.rb +++ b/db/migrate/073_add_ban_user.rb @@ -1,6 +1,6 @@ class AddBanUser < ActiveRecord::Migration[4.2] # 2.1 def self.up - add_column :users, :ban_text, :text, :null => false, :default => "" + add_column :users, :ban_text, :text, null: false, default: "" end def self.down diff --git a/db/migrate/074_create_holidays.rb b/db/migrate/074_create_holidays.rb index 106e49dd20..32872afd3b 100644 --- a/db/migrate/074_create_holidays.rb +++ b/db/migrate/074_create_holidays.rb @@ -60,7 +60,7 @@ def self.up } holidays.sort.each { |date, desc| - Holiday.create :day => date, :description => desc + Holiday.create day: date, description: desc } end diff --git a/db/migrate/075_add_charity_number.rb b/db/migrate/075_add_charity_number.rb index 1a529d1d13..7237ab9980 100644 --- a/db/migrate/075_add_charity_number.rb +++ b/db/migrate/075_add_charity_number.rb @@ -1,7 +1,7 @@ class AddCharityNumber < ActiveRecord::Migration[4.2] # 2.1 def self.up - add_column :public_bodies, :charity_number, :text, :null => false, :default => "" - add_column :public_body_versions, :charity_number, :text, :null => false, :default => "" + add_column :public_bodies, :charity_number, :text, null: false, default: "" + add_column :public_body_versions, :charity_number, :text, null: false, default: "" end def self.down diff --git a/db/migrate/078_expand_stop_new_responses.rb b/db/migrate/078_expand_stop_new_responses.rb index ef7a77a318..25200bd601 100644 --- a/db/migrate/078_expand_stop_new_responses.rb +++ b/db/migrate/078_expand_stop_new_responses.rb @@ -3,12 +3,12 @@ def self.up add_column :info_requests, :allow_new_responses_from, :string InfoRequest.update_all "allow_new_responses_from = 'anybody'" InfoRequest.update_all "allow_new_responses_from = 'nobody' where stop_new_responses" - change_column :info_requests, :allow_new_responses_from, :string, :null => false, :default => 'anybody' + change_column :info_requests, :allow_new_responses_from, :string, null: false, default: 'anybody' remove_column :info_requests, :stop_new_responses add_column :info_requests, :handle_rejected_responses, :string InfoRequest.update_all "handle_rejected_responses = 'bounce'" - change_column :info_requests, :handle_rejected_responses, :string, :null => false, :default => 'bounce' + change_column :info_requests, :handle_rejected_responses, :string, null: false, default: 'bounce' end def self.down diff --git a/db/migrate/079_add_profile_photo.rb b/db/migrate/079_add_profile_photo.rb index 0344fb7e35..9308691945 100644 --- a/db/migrate/079_add_profile_photo.rb +++ b/db/migrate/079_add_profile_photo.rb @@ -1,11 +1,11 @@ class AddProfilePhoto < ActiveRecord::Migration[4.2] # 2.1 def self.up create_table :profile_photos do |t| - t.column :data, :binary, :null => false - t.column :user_id, :integer, :null => false + t.column :data, :binary, null: false + t.column :user_id, :integer, null: false end - add_column :users, :profile_photo_id, :integer, :null => true + add_column :users, :profile_photo_id, :integer, null: true if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" execute "ALTER TABLE profile_photos ADD CONSTRAINT fk_profile_photos_user FOREIGN KEY (user_id) REFERENCES users(id)" diff --git a/db/migrate/081_add_event_prominence.rb b/db/migrate/081_add_event_prominence.rb index 3562e12136..a961f0ee8f 100644 --- a/db/migrate/081_add_event_prominence.rb +++ b/db/migrate/081_add_event_prominence.rb @@ -1,6 +1,6 @@ class AddEventProminence < ActiveRecord::Migration[4.2] # 2.1 def self.up - add_column :info_request_events, :prominence, :string, :null => false, :default => 'normal' + add_column :info_request_events, :prominence, :string, null: false, default: 'normal' end def self.down diff --git a/db/migrate/082_change_raw_email_to_binary.rb b/db/migrate/082_change_raw_email_to_binary.rb index f1cb28793f..7e3e075d3b 100644 --- a/db/migrate/082_change_raw_email_to_binary.rb +++ b/db/migrate/082_change_raw_email_to_binary.rb @@ -1,6 +1,6 @@ class ChangeRawEmailToBinary < ActiveRecord::Migration[4.2] # 2.1 def self.up - change_column :raw_emails, :data, :text, :null => true # allow null + change_column :raw_emails, :data, :text, null: true # allow null rename_column :raw_emails, :data, :data_text add_column :raw_emails, :data_binary, :binary end diff --git a/db/migrate/085_draft_profile_photo.rb b/db/migrate/085_draft_profile_photo.rb index 9083d9c943..1aab24128b 100644 --- a/db/migrate/085_draft_profile_photo.rb +++ b/db/migrate/085_draft_profile_photo.rb @@ -1,6 +1,6 @@ class DraftProfilePhoto < ActiveRecord::Migration[4.2] # 2.3 def self.up - add_column :profile_photos, :draft, :boolean, :default => false, :null => false + add_column :profile_photos, :draft, :boolean, default: false, null: false end def self.down diff --git a/db/migrate/086_allow_null_profile_photo_user.rb b/db/migrate/086_allow_null_profile_photo_user.rb index 9eba3deccb..788cff3306 100644 --- a/db/migrate/086_allow_null_profile_photo_user.rb +++ b/db/migrate/086_allow_null_profile_photo_user.rb @@ -1,6 +1,6 @@ class AllowNullProfilePhotoUser < ActiveRecord::Migration[4.2] # 2.3 def self.up - change_column :profile_photos, :user_id, :integer, :null => true + change_column :profile_photos, :user_id, :integer, null: true end def self.down diff --git a/db/migrate/087_add_about_me.rb b/db/migrate/087_add_about_me.rb index 0f84e34d75..41ade2a852 100644 --- a/db/migrate/087_add_about_me.rb +++ b/db/migrate/087_add_about_me.rb @@ -1,6 +1,6 @@ class AddAboutMe < ActiveRecord::Migration[4.2] # 2.3 def self.up - add_column :users, :about_me, :text, :null => false, :default => "" + add_column :users, :about_me, :text, null: false, default: "" end def self.down diff --git a/db/migrate/090_remove_tag_uniqueness.rb b/db/migrate/090_remove_tag_uniqueness.rb index 51b93d8f1d..595db36b9a 100644 --- a/db/migrate/090_remove_tag_uniqueness.rb +++ b/db/migrate/090_remove_tag_uniqueness.rb @@ -5,7 +5,7 @@ def self.up if ActiveRecord::Base.connection.adapter_name != "MySQL" remove_index :public_body_tags, [:public_body_id, :name] # allow the key to repeat, but not the value also - add_index :public_body_tags, [:public_body_id, :name, :value], :unique => true + add_index :public_body_tags, [:public_body_id, :name, :value], unique: true end end diff --git a/db/migrate/093_move_to_has_tag_string.rb b/db/migrate/093_move_to_has_tag_string.rb index b819626611..59d6b70cb8 100644 --- a/db/migrate/093_move_to_has_tag_string.rb +++ b/db/migrate/093_move_to_has_tag_string.rb @@ -10,7 +10,7 @@ def self.up # the model needs a default value, so build in stages: add_column :has_tag_string_tags, :model, :string HasTagString::HasTagStringTag.update_all "model = 'PublicBody'" - change_column :has_tag_string_tags, :model, :string, :null => false + change_column :has_tag_string_tags, :model, :string, null: false # just use this for a fresh project: # add_column :has_tag_string_tags, :model, :string, :null => false diff --git a/db/migrate/094_remove_old_tags_foreign_key.rb b/db/migrate/094_remove_old_tags_foreign_key.rb index b361d437ff..760b9b8cbc 100644 --- a/db/migrate/094_remove_old_tags_foreign_key.rb +++ b/db/migrate/094_remove_old_tags_foreign_key.rb @@ -4,7 +4,7 @@ def self.up execute "ALTER TABLE has_tag_string_tags DROP CONSTRAINT fk_public_body_tags_public_body" end - add_index :has_tag_string_tags, [:model, :model_id, :name, :value], :name => 'by_model_and_model_id_and_name_and_value' + add_index :has_tag_string_tags, [:model, :model_id, :name, :value], name: 'by_model_and_model_id_and_name_and_value' end def self.down diff --git a/db/migrate/096_create_translation_tables.rb b/db/migrate/096_create_translation_tables.rb index a9402c51c1..08b6dedf7c 100644 --- a/db/migrate/096_create_translation_tables.rb +++ b/db/migrate/096_create_translation_tables.rb @@ -1,21 +1,25 @@ class CreateTranslationTables < ActiveRecord::Migration[4.2] # 2.3 + class ::PublicBody + # This has been removed from the model but is needed for this old migration + # to work + translates :notes + end + def self.up - fields = { :name => :text, - :short_name => :text, - :request_email => :text, - :url_name => :text, - :notes => :text, - :first_letter => :string, - :publication_scheme => :text } + fields = { name: :text, + short_name: :text, + request_email: :text, + url_name: :text, + notes: :text, + first_letter: :string, + publication_scheme: :text } PublicBody.create_translation_table!(fields) # copy current values across to default locale PublicBody.all.each do |publicbody| - publicbody.translated_attributes.each do |a, default| + publicbody.translated_attributes.each do |a, _default| value = publicbody.read_attribute(a) - unless value.nil? - publicbody.send(:"#{a}=", value) - end + publicbody.send(:"#{a}=", value) unless value.nil? end publicbody.save! end diff --git a/db/migrate/097_add_comment_locale.rb b/db/migrate/097_add_comment_locale.rb index 920a89d76e..3be8631521 100644 --- a/db/migrate/097_add_comment_locale.rb +++ b/db/migrate/097_add_comment_locale.rb @@ -1,6 +1,6 @@ class AddCommentLocale < ActiveRecord::Migration[4.2] # 2.3 def self.up - add_column :comments, :locale, :text, :null => false, :default => "" + add_column :comments, :locale, :text, null: false, default: "" end def self.down diff --git a/db/migrate/099_move_raw_email_to_filesystem.rb b/db/migrate/099_move_raw_email_to_filesystem.rb index 3676ae6953..e764579e65 100644 --- a/db/migrate/099_move_raw_email_to_filesystem.rb +++ b/db/migrate/099_move_raw_email_to_filesystem.rb @@ -1,8 +1,8 @@ class MoveRawEmailToFilesystem < ActiveRecord::Migration[4.2] # 2.3 def self.up - RawEmail.find_each(:batch_size => 10) do |raw_email| - if !File.exist?(raw_email.filepath) - STDERR.puts "converting raw_email #{raw_email.id.to_s}" + RawEmail.find_each(batch_size: 10) do |raw_email| + unless File.exist?(raw_email.filepath) + STDERR.puts "converting raw_email #{raw_email.id}" raw_email.data = raw_email.dbdata end end diff --git a/db/migrate/101_add_hash_to_info_request.rb b/db/migrate/101_add_hash_to_info_request.rb index ad8da2ef76..8f72d1d599 100644 --- a/db/migrate/101_add_hash_to_info_request.rb +++ b/db/migrate/101_add_hash_to_info_request.rb @@ -6,10 +6,10 @@ def self.up # Create the missing events for requests already sent InfoRequest.all.each do |info_request| - info_request.idhash = Digest::SHA1.hexdigest(info_request.id.to_s + AlaveteliConfiguration::incoming_email_secret)[0,8] + info_request.idhash = Digest::SHA1.hexdigest(info_request.id.to_s + AlaveteliConfiguration.incoming_email_secret)[0,8] info_request.save! end - change_column :info_requests, :idhash, :string, :null => false + change_column :info_requests, :idhash, :string, null: false end def self.down remove_column :info_requests, :idhash diff --git a/db/migrate/103_add_user_bounce_columns.rb b/db/migrate/103_add_user_bounce_columns.rb index 5d27d4b072..d4ac9a181d 100644 --- a/db/migrate/103_add_user_bounce_columns.rb +++ b/db/migrate/103_add_user_bounce_columns.rb @@ -3,7 +3,7 @@ class AddUserBounceColumns < ActiveRecord::Migration[4.2] # 2.3 def self.up add_column :users, :email_bounced_at, :datetime - add_column :users, :email_bounce_message, :text, :default => "", :null => false + add_column :users, :email_bounce_message, :text, default: "", null: false end def self.down remove_column :users, :email_bounced_at diff --git a/db/migrate/106_add_hex_digest_to_foi_attachment.rb b/db/migrate/106_add_hex_digest_to_foi_attachment.rb index 2df588f4f3..390127e23e 100644 --- a/db/migrate/106_add_hex_digest_to_foi_attachment.rb +++ b/db/migrate/106_add_hex_digest_to_foi_attachment.rb @@ -1,6 +1,6 @@ class AddHexDigestToFoiAttachment < ActiveRecord::Migration[4.2] # 2.3 def self.up - add_column :foi_attachments, :hexdigest, :string, :limit => 32 + add_column :foi_attachments, :hexdigest, :string, limit: 32 end def self.down diff --git a/db/migrate/110_add_user_no_limit.rb b/db/migrate/110_add_user_no_limit.rb index be4094742f..25f2cd4538 100644 --- a/db/migrate/110_add_user_no_limit.rb +++ b/db/migrate/110_add_user_no_limit.rb @@ -2,7 +2,7 @@ class AddUserNoLimit < ActiveRecord::Migration[4.2] # 2.3 def self.up - add_column :users, :no_limit, :boolean, :default => false, :null => false + add_column :users, :no_limit, :boolean, default: false, null: false end def self.down remove_column :users, :no_limit diff --git a/db/migrate/111_create_purge_requests.rb b/db/migrate/111_create_purge_requests.rb index c732894797..12e7a21f96 100644 --- a/db/migrate/111_create_purge_requests.rb +++ b/db/migrate/111_create_purge_requests.rb @@ -2,9 +2,9 @@ class CreatePurgeRequests < ActiveRecord::Migration[4.2] # 2.3 def self.up create_table :purge_requests do |t| t.column :url, :string - t.column :created_at, :datetime, :null => false - t.column :model, :string, :null => false - t.column :model_id, :integer, :null => false + t.column :created_at, :datetime, null: false + t.column :model, :string, null: false + t.column :model_id, :integer, null: false end end diff --git a/db/migrate/113_add_external_fields_to_info_requests.rb b/db/migrate/113_add_external_fields_to_info_requests.rb index 3ac03b57de..38ec6449fb 100644 --- a/db/migrate/113_add_external_fields_to_info_requests.rb +++ b/db/migrate/113_add_external_fields_to_info_requests.rb @@ -1,8 +1,8 @@ class AddExternalFieldsToInfoRequests < ActiveRecord::Migration[4.2] # 2.3 def self.up change_column_null :info_requests, :user_id, true - add_column :info_requests, :external_user_name, :string, :null => true - add_column :info_requests, :external_url, :string, :null => true + add_column :info_requests, :external_user_name, :string, null: true + add_column :info_requests, :external_url, :string, null: true # NB This is corrected in 20120822145640 if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" diff --git a/db/migrate/114_add_attention_requested_flag_to_info_requests.rb b/db/migrate/114_add_attention_requested_flag_to_info_requests.rb index 878f484a30..e6df33d6f5 100644 --- a/db/migrate/114_add_attention_requested_flag_to_info_requests.rb +++ b/db/migrate/114_add_attention_requested_flag_to_info_requests.rb @@ -2,7 +2,7 @@ class AddAttentionRequestedFlagToInfoRequests < ActiveRecord::Migration[4.2] # 2.3 def self.up - add_column :info_requests, :attention_requested, :boolean, :default => false + add_column :info_requests, :attention_requested, :boolean, default: false end def self.down remove_column :info_requests, :attention_requested diff --git a/db/migrate/115_add_receive_email_alerts_to_user.rb b/db/migrate/115_add_receive_email_alerts_to_user.rb index 5428acb919..587227e7f3 100644 --- a/db/migrate/115_add_receive_email_alerts_to_user.rb +++ b/db/migrate/115_add_receive_email_alerts_to_user.rb @@ -1,6 +1,6 @@ class AddReceiveEmailAlertsToUser < ActiveRecord::Migration[4.2] # 2.3 def self.up - add_column :users, :receive_email_alerts, :boolean, :default => true, :null => false + add_column :users, :receive_email_alerts, :boolean, default: true, null: false end def self.down remove_column :users, :receive_email_alerts diff --git a/db/migrate/117_create_sessions.rb b/db/migrate/117_create_sessions.rb index ee0f7c8739..48a44d456c 100644 --- a/db/migrate/117_create_sessions.rb +++ b/db/migrate/117_create_sessions.rb @@ -1,9 +1,9 @@ class CreateSessions < ActiveRecord::Migration[4.2] # 2.3 def self.up create_table :sessions do |t| - t.string :session_id, :null => false + t.string :session_id, null: false t.text :data - t.timestamps :null => false + t.timestamps null: false end add_index :sessions, :session_id diff --git a/db/migrate/118_remove_sessions_again.rb b/db/migrate/118_remove_sessions_again.rb index 40fb624b98..4f011553c4 100644 --- a/db/migrate/118_remove_sessions_again.rb +++ b/db/migrate/118_remove_sessions_again.rb @@ -5,9 +5,9 @@ def self.up def self.down create_table :sessions do |t| - t.string :session_id, :null => false + t.string :session_id, null: false t.text :data - t.timestamps :null => false + t.timestamps null: false end add_index :sessions, :session_id diff --git a/db/migrate/20120910153022_create_request_classifications.rb b/db/migrate/20120910153022_create_request_classifications.rb index 72ff8cd331..14e51c170b 100644 --- a/db/migrate/20120910153022_create_request_classifications.rb +++ b/db/migrate/20120910153022_create_request_classifications.rb @@ -3,7 +3,7 @@ def self.up create_table :request_classifications do |t| t.integer :user_id t.integer :info_request_event_id - t.timestamps :null => false + t.timestamps null: false end add_index :request_classifications, :user_id end diff --git a/db/migrate/20120912170035_add_info_requests_count_to_public_bodies.rb b/db/migrate/20120912170035_add_info_requests_count_to_public_bodies.rb index 94a9a1bee6..e97dfa5c07 100644 --- a/db/migrate/20120912170035_add_info_requests_count_to_public_bodies.rb +++ b/db/migrate/20120912170035_add_info_requests_count_to_public_bodies.rb @@ -1,6 +1,6 @@ class AddInfoRequestsCountToPublicBodies < ActiveRecord::Migration[4.2] # 2.3 def self.up - add_column :public_bodies, :info_requests_count, :integer, :null => false, :default => 0 + add_column :public_bodies, :info_requests_count, :integer, null: false, default: 0 PublicBody.connection.execute("UPDATE public_bodies SET info_requests_count = (SELECT COUNT(*) FROM info_requests diff --git a/db/migrate/20120919140404_add_comments_allowed_to_info_request.rb b/db/migrate/20120919140404_add_comments_allowed_to_info_request.rb index 02c7b5736c..c1968fc190 100644 --- a/db/migrate/20120919140404_add_comments_allowed_to_info_request.rb +++ b/db/migrate/20120919140404_add_comments_allowed_to_info_request.rb @@ -1,6 +1,6 @@ class AddCommentsAllowedToInfoRequest < ActiveRecord::Migration[4.2] # 2.3 def self.up - add_column :info_requests, :comments_allowed, :boolean, :null => false, :default => true + add_column :info_requests, :comments_allowed, :boolean, null: false, default: true end def self.down diff --git a/db/migrate/20121022031914_add_disclosure_log.rb b/db/migrate/20121022031914_add_disclosure_log.rb index 54917bfbb4..e14cd55f52 100644 --- a/db/migrate/20121022031914_add_disclosure_log.rb +++ b/db/migrate/20121022031914_add_disclosure_log.rb @@ -1,7 +1,7 @@ class AddDisclosureLog < ActiveRecord::Migration[4.2] # 2.3 def self.up - add_column :public_bodies, :disclosure_log, :text, :null => false, :default => "" - add_column :public_body_versions, :disclosure_log, :text, :null => false, :default => "" + add_column :public_bodies, :disclosure_log, :text, null: false, default: "" + add_column :public_body_versions, :disclosure_log, :text, null: false, default: "" add_column :public_body_translations, :disclosure_log, :text end diff --git a/db/migrate/20130731142632_remove_prominence_from_info_request_event.rb b/db/migrate/20130731142632_remove_prominence_from_info_request_event.rb index c2f48c6130..b102b1bc63 100644 --- a/db/migrate/20130731142632_remove_prominence_from_info_request_event.rb +++ b/db/migrate/20130731142632_remove_prominence_from_info_request_event.rb @@ -4,6 +4,6 @@ def up end def down - add_column :info_request_events, :prominence, :string, :null => false, :default => 'normal' + add_column :info_request_events, :prominence, :string, null: false, default: 'normal' end end diff --git a/db/migrate/20130731145325_add_prominence_to_incoming_message.rb b/db/migrate/20130731145325_add_prominence_to_incoming_message.rb index 3362894cf8..eca1868f8d 100644 --- a/db/migrate/20130731145325_add_prominence_to_incoming_message.rb +++ b/db/migrate/20130731145325_add_prominence_to_incoming_message.rb @@ -1,5 +1,5 @@ class AddProminenceToIncomingMessage < ActiveRecord::Migration[4.2] # 3.1 def change - add_column :incoming_messages, :prominence, :string, :null => false, :default => 'normal' + add_column :incoming_messages, :prominence, :string, null: false, default: 'normal' end end diff --git a/db/migrate/20130822161803_add_prominence_fields_to_outgoing_message.rb b/db/migrate/20130822161803_add_prominence_fields_to_outgoing_message.rb index dbef805924..39b9ec3fd1 100644 --- a/db/migrate/20130822161803_add_prominence_fields_to_outgoing_message.rb +++ b/db/migrate/20130822161803_add_prominence_fields_to_outgoing_message.rb @@ -1,6 +1,6 @@ class AddProminenceFieldsToOutgoingMessage < ActiveRecord::Migration[4.2] # 3.1 def change - add_column :outgoing_messages, :prominence, :string, :null => false, :default => 'normal' + add_column :outgoing_messages, :prominence, :string, null: false, default: 'normal' add_column :outgoing_messages, :prominence_reason, :text end end diff --git a/db/migrate/20130919151140_add_can_make_batch_requests_to_user.rb b/db/migrate/20130919151140_add_can_make_batch_requests_to_user.rb index e66683c8a1..ec1f7fd7f4 100644 --- a/db/migrate/20130919151140_add_can_make_batch_requests_to_user.rb +++ b/db/migrate/20130919151140_add_can_make_batch_requests_to_user.rb @@ -1,5 +1,5 @@ class AddCanMakeBatchRequestsToUser < ActiveRecord::Migration[4.2] # 3.2 def change - add_column :users, :can_make_batch_requests, :boolean, :default => false, :null => false + add_column :users, :can_make_batch_requests, :boolean, default: false, null: false end end diff --git a/db/migrate/20131024114346_create_info_request_batches.rb b/db/migrate/20131024114346_create_info_request_batches.rb index 95fb2433b4..b311151cf9 100644 --- a/db/migrate/20131024114346_create_info_request_batches.rb +++ b/db/migrate/20131024114346_create_info_request_batches.rb @@ -1,11 +1,11 @@ class CreateInfoRequestBatches < ActiveRecord::Migration[4.2] # 3.2 def up create_table :info_request_batches do |t| - t.column :title, :text, :null => false - t.column :user_id, :integer, :null => false - t.timestamps :null => false + t.column :title, :text, null: false + t.column :user_id, :integer, null: false + t.timestamps null: false end - add_column :info_requests, :info_request_batch_id, :integer, :null => true + add_column :info_requests, :info_request_batch_id, :integer, null: true if ActiveRecord::Base.connection.adapter_name == "PostgreSQL" execute "ALTER TABLE info_requests ADD CONSTRAINT fk_info_requests_info_request_batch diff --git a/db/migrate/20131127105438_create_info_request_batch_public_bodies_join_table.rb b/db/migrate/20131127105438_create_info_request_batch_public_bodies_join_table.rb index 8c2fc616ee..44dc9e17eb 100644 --- a/db/migrate/20131127105438_create_info_request_batch_public_bodies_join_table.rb +++ b/db/migrate/20131127105438_create_info_request_batch_public_bodies_join_table.rb @@ -1,6 +1,6 @@ class CreateInfoRequestBatchPublicBodiesJoinTable < ActiveRecord::Migration[4.2] # 3.2 def change - create_table :info_request_batches_public_bodies, :id => false do |t| + create_table :info_request_batches_public_bodies, id: false do |t| t.integer :info_request_batch_id t.integer :public_body_id end diff --git a/db/migrate/20131211152641_create_public_body_change_requests.rb b/db/migrate/20131211152641_create_public_body_change_requests.rb index 39d5cee080..98cabe0635 100644 --- a/db/migrate/20131211152641_create_public_body_change_requests.rb +++ b/db/migrate/20131211152641_create_public_body_change_requests.rb @@ -9,8 +9,8 @@ def up t.column :public_body_email, :string t.column :source_url, :text t.column :notes, :text - t.column :is_open, :boolean, :null => false, :default => true - t.timestamps :null => false + t.column :is_open, :boolean, null: false, default: true + t.timestamps null: false end end diff --git a/db/migrate/20140325120619_create_spam_addresses.rb b/db/migrate/20140325120619_create_spam_addresses.rb index 7225a7ca42..9e99b23f25 100644 --- a/db/migrate/20140325120619_create_spam_addresses.rb +++ b/db/migrate/20140325120619_create_spam_addresses.rb @@ -1,9 +1,9 @@ class CreateSpamAddresses < ActiveRecord::Migration[4.2] # 3.2 def change create_table :spam_addresses do |t| - t.string :email, :null => false + t.string :email, null: false - t.timestamps :null => false + t.timestamps null: false end end end diff --git a/db/migrate/20140710094405_create_public_body_headings_and_categories.rb b/db/migrate/20140710094405_create_public_body_headings_and_categories.rb index 28d2f796ce..d604681cce 100644 --- a/db/migrate/20140710094405_create_public_body_headings_and_categories.rb +++ b/db/migrate/20140710094405_create_public_body_headings_and_categories.rb @@ -1,21 +1,21 @@ class CreatePublicBodyHeadingsAndCategories < ActiveRecord::Migration[4.2] # 3.2 def up - create_table :public_body_headings, :force => true do |t| + create_table :public_body_headings, force: true do |t| t.string :locale - t.text :name, :null => false + t.text :name, null: false t.integer :display_order end - create_table :public_body_categories, :force => true do |t| + create_table :public_body_categories, force: true do |t| t.string :locale - t.text :title, :null => false - t.text :category_tag, :null => false - t.text :description, :null => false + t.text :title, null: false + t.text :category_tag, null: false + t.text :description, null: false end - create_table :public_body_categories_public_body_headings, :id => false do |t| - t.integer :public_body_category_id, :null => false - t.integer :public_body_heading_id, :null => false + create_table :public_body_categories_public_body_headings, id: false do |t| + t.integer :public_body_category_id, null: false + t.integer :public_body_heading_id, null: false end end diff --git a/db/migrate/20140716131107_create_category_translation_tables.rb b/db/migrate/20140716131107_create_category_translation_tables.rb index f60ec1f3f6..c550dffb61 100644 --- a/db/migrate/20140716131107_create_category_translation_tables.rb +++ b/db/migrate/20140716131107_create_category_translation_tables.rb @@ -8,17 +8,15 @@ class PublicBodyHeading < ApplicationRecord def up default_locale = AlaveteliLocalization.default_locale - fields = {:title => :text, - :description => :text} + fields = {title: :text, + description: :text} PublicBodyCategory.create_translation_table!(fields) # copy current values across to the default locale - PublicBodyCategory.where(:locale => default_locale).each do |category| - category.translated_attributes.each do |a, default| + PublicBodyCategory.where(locale: default_locale).each do |category| + category.translated_attributes.each do |a, _default| value = category.read_attribute(a) - unless value.nil? - category.send(:"#{a}=", value) - end + category.send(:"#{a}=", value) unless value.nil? end category.save! end @@ -27,7 +25,7 @@ def up PublicBodyCategory.where('locale != ?', default_locale).each do |category| default_category = PublicBodyCategory.find_by_category_tag_and_locale(category.category_tag, default_locale) AlaveteliLocalization.with_locale(category.locale) do - category.translated_attributes.each do |a, default| + category.translated_attributes.each do |a, _default| value = category.read_attribute(a) unless value.nil? if default_category @@ -47,16 +45,14 @@ def up end end - fields = { :name => :text } + fields = { name: :text } PublicBodyHeading.create_translation_table!(fields) # copy current values across to the default locale - PublicBodyHeading.where(:locale => default_locale).each do |heading| - heading.translated_attributes.each do |a, default| + PublicBodyHeading.where(locale: default_locale).each do |heading| + heading.translated_attributes.each do |a, _default| value = heading.read_attribute(a) - unless value.nil? - heading.send(:"#{a}=", value) - end + heading.send(:"#{a}=", value) unless value.nil? end heading.save! end @@ -65,7 +61,7 @@ def up PublicBodyHeading.where('locale != ?', default_locale).each do |heading| default_heading = PublicBodyHeading.find_by_name_and_locale(heading.name, default_locale) AlaveteliLocalization.with_locale(heading.locale) do - heading.translated_attributes.each do |a, default| + heading.translated_attributes.each do |a, _default| value = heading.read_attribute(a) unless value.nil? if default_heading @@ -93,7 +89,7 @@ def up remove_column :public_body_categories, :description # and set category_tag to be unique - add_index :public_body_categories, :category_tag, :unique => true + add_index :public_body_categories, :category_tag, unique: true end def down @@ -128,9 +124,7 @@ def down end end end - new_categories.each do |cat| - cat.save! - end + new_categories.each(&:save!) new_headings = [] PublicBodyHeading.all.each do |heading| @@ -152,9 +146,7 @@ def down end end end - new_headings.each do |heading| - heading.save! - end + new_headings.each(&:save!) # drop the translation tables PublicBodyCategory.drop_translation_table! diff --git a/db/migrate/20140804120601_add_display_order_to_categories_and_headings.rb b/db/migrate/20140804120601_add_display_order_to_categories_and_headings.rb index 105335dd5f..73bec0b685 100644 --- a/db/migrate/20140804120601_add_display_order_to_categories_and_headings.rb +++ b/db/migrate/20140804120601_add_display_order_to_categories_and_headings.rb @@ -3,11 +3,11 @@ def up add_column :public_body_categories_public_body_headings, :category_display_order, :integer rename_table :public_body_categories_public_body_headings, :public_body_category_links add_column :public_body_category_links, :id, :primary_key - add_index :public_body_category_links, [:public_body_category_id, :public_body_heading_id], :name => "index_public_body_category_links_on_join_ids" + add_index :public_body_category_links, [:public_body_category_id, :public_body_heading_id], name: "index_public_body_category_links_on_join_ids" end def down - remove_index :public_body_category_links, :name => "index_public_body_category_links_on_join_ids" + remove_index :public_body_category_links, name: "index_public_body_category_links_on_join_ids" remove_column :public_body_category_links, :category_display_order remove_column :public_body_category_links, :id rename_table :public_body_category_links, :public_body_categories_public_body_headings diff --git a/db/migrate/20140824191444_create_widget_votes.rb b/db/migrate/20140824191444_create_widget_votes.rb index bc42597970..40cabc6337 100644 --- a/db/migrate/20140824191444_create_widget_votes.rb +++ b/db/migrate/20140824191444_create_widget_votes.rb @@ -2,9 +2,9 @@ class CreateWidgetVotes < ActiveRecord::Migration[4.2] # 3.2 def change create_table :widget_votes do |t| t.string :cookie - t.belongs_to :info_request, :null => false + t.belongs_to :info_request, null: false - t.timestamps :null => false + t.timestamps null: false end add_index :widget_votes, :info_request_id end diff --git a/db/migrate/20151006101417_add_otp_enabled_to_users.rb b/db/migrate/20151006101417_add_otp_enabled_to_users.rb index 3eabd39997..a40a173c6e 100644 --- a/db/migrate/20151006101417_add_otp_enabled_to_users.rb +++ b/db/migrate/20151006101417_add_otp_enabled_to_users.rb @@ -1,5 +1,5 @@ class AddOtpEnabledToUsers < ActiveRecord::Migration[4.2] # 3.2 def change - add_column :users, :otp_enabled, :boolean, :default => false, :null => false + add_column :users, :otp_enabled, :boolean, default: false, null: false end end diff --git a/db/migrate/20151006104739_add_counter_for_otp_to_users.rb b/db/migrate/20151006104739_add_counter_for_otp_to_users.rb index 792ac7dbdb..3d3320cebd 100644 --- a/db/migrate/20151006104739_add_counter_for_otp_to_users.rb +++ b/db/migrate/20151006104739_add_counter_for_otp_to_users.rb @@ -1,5 +1,5 @@ class AddCounterForOtpToUsers < ActiveRecord::Migration[4.2] # 3.2 def change - add_column :users, :otp_counter, :integer, :default => 1 + add_column :users, :otp_counter, :integer, default: 1 end end diff --git a/db/migrate/20151009162421_add_info_requests_visible_count_to_public_bodies.rb b/db/migrate/20151009162421_add_info_requests_visible_count_to_public_bodies.rb index 957092b5c8..9dcea71c5f 100644 --- a/db/migrate/20151009162421_add_info_requests_visible_count_to_public_bodies.rb +++ b/db/migrate/20151009162421_add_info_requests_visible_count_to_public_bodies.rb @@ -1,6 +1,6 @@ class AddInfoRequestsVisibleCountToPublicBodies < ActiveRecord::Migration[4.2] # 3.2 def up - add_column :public_bodies, :info_requests_visible_count, :integer, :null => false, :default => 0 + add_column :public_bodies, :info_requests_visible_count, :integer, null: false, default: 0 PublicBody.connection.execute("UPDATE public_bodies SET info_requests_visible_count = (SELECT COUNT(*) FROM info_requests diff --git a/db/migrate/20151020112248_set_longer_length_for_track_things_track_query.rb b/db/migrate/20151020112248_set_longer_length_for_track_things_track_query.rb index d7765baee3..2da6b7c074 100644 --- a/db/migrate/20151020112248_set_longer_length_for_track_things_track_query.rb +++ b/db/migrate/20151020112248_set_longer_length_for_track_things_track_query.rb @@ -1,9 +1,9 @@ class SetLongerLengthForTrackThingsTrackQuery < ActiveRecord::Migration[4.2] # 3.2 def up - change_column :track_things, :track_query, :string, :limit => 500 + change_column :track_things, :track_query, :string, limit: 500 end def down - change_column :track_things, :track_query, :string, :limit => 255 + change_column :track_things, :track_query, :string, limit: 255 end end diff --git a/db/migrate/20151104131702_add_last_public_response_at_to_info_request.rb b/db/migrate/20151104131702_add_last_public_response_at_to_info_request.rb index 3aeb44b37a..c761d62514 100644 --- a/db/migrate/20151104131702_add_last_public_response_at_to_info_request.rb +++ b/db/migrate/20151104131702_add_last_public_response_at_to_info_request.rb @@ -1,6 +1,6 @@ class AddLastPublicResponseAtToInfoRequest < ActiveRecord::Migration[4.2] # 3.2 def up - add_column :info_requests, :last_public_response_at, :datetime, :null => true + add_column :info_requests, :last_public_response_at, :datetime, null: true InfoRequest.connection. execute("UPDATE info_requests diff --git a/db/migrate/20160526154304_add_confirmed_not_spam_to_users.rb b/db/migrate/20160526154304_add_confirmed_not_spam_to_users.rb index 8691d9db5a..100e0970aa 100644 --- a/db/migrate/20160526154304_add_confirmed_not_spam_to_users.rb +++ b/db/migrate/20160526154304_add_confirmed_not_spam_to_users.rb @@ -1,5 +1,5 @@ class AddConfirmedNotSpamToUsers < ActiveRecord::Migration[4.2] # 3.2 def change - add_column :users, :confirmed_not_spam, :boolean, :default => false, :null => false + add_column :users, :confirmed_not_spam, :boolean, default: false, null: false end end diff --git a/db/migrate/20160602143125_add_reject_incoming_at_mta_to_info_request.rb b/db/migrate/20160602143125_add_reject_incoming_at_mta_to_info_request.rb index 2f22e43108..b4a24dff0a 100644 --- a/db/migrate/20160602143125_add_reject_incoming_at_mta_to_info_request.rb +++ b/db/migrate/20160602143125_add_reject_incoming_at_mta_to_info_request.rb @@ -1,6 +1,6 @@ class AddRejectIncomingAtMtaToInfoRequest < ActiveRecord::Migration[4.2] # 3.2 def up - add_column :info_requests, :reject_incoming_at_mta, :boolean, :default => false, :null => false + add_column :info_requests, :reject_incoming_at_mta, :boolean, default: false, null: false end def down diff --git a/db/migrate/20160602145046_add_rejected_incoming_count_to_info_request.rb b/db/migrate/20160602145046_add_rejected_incoming_count_to_info_request.rb index bc7763558b..719d56a2c1 100644 --- a/db/migrate/20160602145046_add_rejected_incoming_count_to_info_request.rb +++ b/db/migrate/20160602145046_add_rejected_incoming_count_to_info_request.rb @@ -1,6 +1,6 @@ class AddRejectedIncomingCountToInfoRequest < ActiveRecord::Migration[4.2] # 3.2 def up - add_column :info_requests, :rejected_incoming_count, :integer, :default => 0 + add_column :info_requests, :rejected_incoming_count, :integer, default: 0 end def down diff --git a/db/migrate/20160613145644_add_comments_count_to_users.rb b/db/migrate/20160613145644_add_comments_count_to_users.rb index ca411329c2..fa328121fc 100644 --- a/db/migrate/20160613145644_add_comments_count_to_users.rb +++ b/db/migrate/20160613145644_add_comments_count_to_users.rb @@ -1,6 +1,6 @@ class AddCommentsCountToUsers < ActiveRecord::Migration[4.2] # 3.2 def up - add_column :users, :comments_count, :integer, :default => 0, :null => false + add_column :users, :comments_count, :integer, default: 0, null: false Comment.distinct.pluck(:user_id).compact.each do |user_id| User.reset_counters(user_id, :comments) diff --git a/db/migrate/20160613151127_add_info_requests_count_to_users.rb b/db/migrate/20160613151127_add_info_requests_count_to_users.rb index ab7c1dd936..3145e2baca 100644 --- a/db/migrate/20160613151127_add_info_requests_count_to_users.rb +++ b/db/migrate/20160613151127_add_info_requests_count_to_users.rb @@ -1,6 +1,6 @@ class AddInfoRequestsCountToUsers < ActiveRecord::Migration[4.2] # 3.2 def up - add_column :users, :info_requests_count, :integer, :default => 0, :null => false + add_column :users, :info_requests_count, :integer, default: 0, null: false InfoRequest.distinct.pluck(:user_id).compact.each do |user_id| User.reset_counters(user_id, :info_requests) diff --git a/db/migrate/20160613151912_add_track_things_count_to_users.rb b/db/migrate/20160613151912_add_track_things_count_to_users.rb index b17e7bfafb..17dd14a847 100644 --- a/db/migrate/20160613151912_add_track_things_count_to_users.rb +++ b/db/migrate/20160613151912_add_track_things_count_to_users.rb @@ -1,6 +1,6 @@ class AddTrackThingsCountToUsers < ActiveRecord::Migration[4.2] # 3.2 def up - add_column :users, :track_things_count, :integer, :default => 0, :null => false + add_column :users, :track_things_count, :integer, default: 0, null: false TrackThing.distinct.pluck(:tracking_user_id).compact.each do |user_id| User.reset_counters(user_id, :track_things) diff --git a/db/migrate/20160613152433_add_request_classifications_count_to_users.rb b/db/migrate/20160613152433_add_request_classifications_count_to_users.rb index 8225001cd4..36510c2cf7 100644 --- a/db/migrate/20160613152433_add_request_classifications_count_to_users.rb +++ b/db/migrate/20160613152433_add_request_classifications_count_to_users.rb @@ -1,6 +1,6 @@ class AddRequestClassificationsCountToUsers < ActiveRecord::Migration[4.2] # 3.2 def up - add_column :users, :request_classifications_count, :integer, :default => 0, :null => false + add_column :users, :request_classifications_count, :integer, default: 0, null: false RequestClassification.distinct.pluck(:user_id).compact.each do |user_id| User.reset_counters(user_id, :request_classifications) diff --git a/db/migrate/20160613153739_add_public_body_change_requests_count_to_users.rb b/db/migrate/20160613153739_add_public_body_change_requests_count_to_users.rb index 871f99940b..108c1ab016 100644 --- a/db/migrate/20160613153739_add_public_body_change_requests_count_to_users.rb +++ b/db/migrate/20160613153739_add_public_body_change_requests_count_to_users.rb @@ -1,6 +1,6 @@ class AddPublicBodyChangeRequestsCountToUsers < ActiveRecord::Migration[4.2] # 3.2 def up - add_column :users, :public_body_change_requests_count, :integer, :default => 0, :null => false + add_column :users, :public_body_change_requests_count, :integer, default: 0, null: false PublicBodyChangeRequest.distinct.pluck(:user_id).compact.each do |user_id| User.reset_counters(user_id, :public_body_change_requests) diff --git a/db/migrate/20160613154616_add_info_request_batches_count_to_users.rb b/db/migrate/20160613154616_add_info_request_batches_count_to_users.rb index cd802279ec..777ea609be 100644 --- a/db/migrate/20160613154616_add_info_request_batches_count_to_users.rb +++ b/db/migrate/20160613154616_add_info_request_batches_count_to_users.rb @@ -1,6 +1,6 @@ class AddInfoRequestBatchesCountToUsers < ActiveRecord::Migration[4.2] # 3.2 def up - add_column :users, :info_request_batches_count, :integer, :default => 0, :null => false + add_column :users, :info_request_batches_count, :integer, default: 0, null: false InfoRequestBatch.distinct.pluck(:user_id).compact.each do |user_id| User.reset_counters(user_id, :info_request_batches) diff --git a/db/migrate/20160701155339_remove_comment_type_from_comment.rb b/db/migrate/20160701155339_remove_comment_type_from_comment.rb index 9b99a3186c..dbcdfc5b26 100644 --- a/db/migrate/20160701155339_remove_comment_type_from_comment.rb +++ b/db/migrate/20160701155339_remove_comment_type_from_comment.rb @@ -4,6 +4,6 @@ def up end def down - add_column :comments, :comment_type, :string, :null => false, :default => 'request' + add_column :comments, :comment_type, :string, null: false, default: 'request' end end diff --git a/db/migrate/20170216101547_add_attention_requested_to_comment.rb b/db/migrate/20170216101547_add_attention_requested_to_comment.rb index 1c3b419713..09487c1f5c 100644 --- a/db/migrate/20170216101547_add_attention_requested_to_comment.rb +++ b/db/migrate/20170216101547_add_attention_requested_to_comment.rb @@ -1,6 +1,6 @@ class AddAttentionRequestedToComment < ActiveRecord::Migration[4.2] # 4.0 def change add_column :comments, :attention_requested, :boolean, - :null => false, :default => false + null: false, default: false end end diff --git a/db/migrate/20170227140831_rolify_create_roles.rb b/db/migrate/20170227140831_rolify_create_roles.rb index 83e238b70b..fcc4ca7d86 100644 --- a/db/migrate/20170227140831_rolify_create_roles.rb +++ b/db/migrate/20170227140831_rolify_create_roles.rb @@ -2,12 +2,12 @@ class RolifyCreateRoles < ActiveRecord::Migration[4.2] # 4.0 def change create_table(:roles) do |t| t.string :name - t.references :resource, :polymorphic => true + t.references :resource, polymorphic: true - t.timestamps :null => false + t.timestamps null: false end - create_table(:users_roles, :id => false) do |t| + create_table(:users_roles, id: false) do |t| t.references :user t.references :role end diff --git a/db/migrate/20170301163735_create_draft_info_request_batches.rb b/db/migrate/20170301163735_create_draft_info_request_batches.rb index 301533d70b..ee5d72822e 100644 --- a/db/migrate/20170301163735_create_draft_info_request_batches.rb +++ b/db/migrate/20170301163735_create_draft_info_request_batches.rb @@ -5,7 +5,7 @@ def change t.text :body t.references :user - t.timestamps :null => false + t.timestamps null: false end add_index :draft_info_request_batches, :user_id end diff --git a/db/migrate/20170301164705_create_draft_info_request_batches_public_bodies_table.rb b/db/migrate/20170301164705_create_draft_info_request_batches_public_bodies_table.rb index 9179e28a7d..d5253f12f5 100644 --- a/db/migrate/20170301164705_create_draft_info_request_batches_public_bodies_table.rb +++ b/db/migrate/20170301164705_create_draft_info_request_batches_public_bodies_table.rb @@ -1,7 +1,7 @@ class CreateDraftInfoRequestBatchesPublicBodiesTable < ActiveRecord::Migration[4.2] # 4.0 def change create_table :draft_info_request_batches_public_bodies, - :id => false do |t| + id: false do |t| t.references :draft_info_request_batch t.references :public_body end diff --git a/db/migrate/20170316170248_edit_info_request_batch_index.rb b/db/migrate/20170316170248_edit_info_request_batch_index.rb index 0cf71de5d1..ffa081ab54 100644 --- a/db/migrate/20170316170248_edit_info_request_batch_index.rb +++ b/db/migrate/20170316170248_edit_info_request_batch_index.rb @@ -1,6 +1,6 @@ class EditInfoRequestBatchIndex < ActiveRecord::Migration[4.2] # 4.0 def change - remove_index :info_request_batches, :column => [:user_id, :body, :title] + remove_index :info_request_batches, column: [:user_id, :body, :title] add_index :info_request_batches, [:user_id, :title] end end diff --git a/db/migrate/20170411113908_create_alaveteli_pro_request_summaries.rb b/db/migrate/20170411113908_create_alaveteli_pro_request_summaries.rb index 4c9c8c736b..42b93f086a 100644 --- a/db/migrate/20170411113908_create_alaveteli_pro_request_summaries.rb +++ b/db/migrate/20170411113908_create_alaveteli_pro_request_summaries.rb @@ -4,9 +4,9 @@ def change t.text :title t.text :body t.text :public_body_names - t.references :summarisable, :polymorphic => true + t.references :summarisable, polymorphic: true - t.timestamps :null => false + t.timestamps null: false end end end diff --git a/db/migrate/20170412141214_add_unique_index_to_summarisable.rb b/db/migrate/20170412141214_add_unique_index_to_summarisable.rb index 167df22e25..90832d6c25 100644 --- a/db/migrate/20170412141214_add_unique_index_to_summarisable.rb +++ b/db/migrate/20170412141214_add_unique_index_to_summarisable.rb @@ -2,7 +2,7 @@ class AddUniqueIndexToSummarisable < ActiveRecord::Migration[4.2] # 4.1 def change add_index :request_summaries, [:summarisable_type, :summarisable_id], - :unique => true, - :name => "index_request_summaries_on_summarisable" + unique: true, + name: "index_request_summaries_on_summarisable" end end diff --git a/db/migrate/20170412150729_create_alaveteli_pro_request_summary_categories.rb b/db/migrate/20170412150729_create_alaveteli_pro_request_summary_categories.rb index d1979a48d5..0769d37bd1 100644 --- a/db/migrate/20170412150729_create_alaveteli_pro_request_summary_categories.rb +++ b/db/migrate/20170412150729_create_alaveteli_pro_request_summary_categories.rb @@ -1,18 +1,18 @@ class CreateAlaveteliProRequestSummaryCategories < ActiveRecord::Migration[4.2] # 4.1 def change create_table :request_summary_categories do |t| - t.text :slug, :unique => true - t.timestamps :null => false + t.text :slug, unique: true + t.timestamps null: false end create_join_table :request_summaries, :request_summary_categories, table_name: 'request_summaries_summary_categories' do |t| t.index [:request_summary_id, :request_summary_category_id], - :unique => :true, - :name => 'index_request_summaries_summary_categories_unique' + unique: :true, + name: 'index_request_summaries_summary_categories_unique' t.index [:request_summary_category_id, :request_summary_id], - :unique => :true, - :name => 'index_request_summary_categories_summaries_unique' + unique: :true, + name: 'index_request_summary_categories_summaries_unique' end end end diff --git a/db/migrate/20170717141302_drop_public_body_translated_columns.rb b/db/migrate/20170717141302_drop_public_body_translated_columns.rb index 1effc1d374..46ae9fb9f7 100644 --- a/db/migrate/20170717141302_drop_public_body_translated_columns.rb +++ b/db/migrate/20170717141302_drop_public_body_translated_columns.rb @@ -5,14 +5,14 @@ def up translation = record.translation_for(AlaveteliLocalization.default_locale) || record.translations.build( - :locale => AlaveteliLocalization.default_locale + locale: AlaveteliLocalization.default_locale ) if translation.new_record? fields = record.translated_attribute_names fields.each do |attribute_name| translation[attribute_name] = - record.read_attribute(attribute_name, :translated => false) + record.read_attribute(attribute_name, translated: false) end if translation.save @@ -68,15 +68,15 @@ def down # UPDATE statement rather than record.update which will # use the overridden attribute setters and update translations instead) puts "Migrating default locale translation to public body #{record.id}" - PublicBody.where(:id => record.id).update_all(fields_to_update) + PublicBody.where(id: record.id).update_all(fields_to_update) end end # Re-add the constraints change_column :public_bodies, - :name, :text, :null => false - change_column :public_bodies, :request_email, :text, :null => false - change_column :public_bodies, :url_name, :text, :null => false - change_column :public_bodies, :first_letter, :string, :null => false + :name, :text, null: false + change_column :public_bodies, :request_email, :text, null: false + change_column :public_bodies, :url_name, :text, null: false + change_column :public_bodies, :first_letter, :string, null: false end end diff --git a/db/migrate/20170718261524_add_expiring_notification_at.rb b/db/migrate/20170718261524_add_expiring_notification_at.rb index a1390b2b82..c8539aca73 100644 --- a/db/migrate/20170718261524_add_expiring_notification_at.rb +++ b/db/migrate/20170718261524_add_expiring_notification_at.rb @@ -14,9 +14,7 @@ def down private def column_exists?(table, column) - if data_source_exists?(table) - connection.column_exists?(table, column) - end + connection.column_exists?(table, column) if data_source_exists?(table) end def data_source_exists?(table) diff --git a/db/migrate/20170825150448_add_stripe_customer_id_to_pro_account.rb b/db/migrate/20170825150448_add_stripe_customer_id_to_pro_account.rb index 35957da64f..97196e469d 100644 --- a/db/migrate/20170825150448_add_stripe_customer_id_to_pro_account.rb +++ b/db/migrate/20170825150448_add_stripe_customer_id_to_pro_account.rb @@ -14,9 +14,7 @@ def down private def column_exists?(table, column) - if data_source_exists?(table) - connection.column_exists?(table, column) - end + connection.column_exists?(table, column) if data_source_exists?(table) end def data_source_exists?(table) diff --git a/db/migrate/20170914164031_remove_purge_request.rb b/db/migrate/20170914164031_remove_purge_request.rb index 42507cfdbe..9a2d1d8605 100644 --- a/db/migrate/20170914164031_remove_purge_request.rb +++ b/db/migrate/20170914164031_remove_purge_request.rb @@ -6,9 +6,9 @@ def up def down create_table :purge_requests do |t| t.column :url, :string - t.column :created_at, :datetime, :null => false - t.column :model, :string, :null => false - t.column :model_id, :integer, :null => false + t.column :created_at, :datetime, null: false + t.column :model, :string, null: false + t.column :model_id, :integer, null: false end end end diff --git a/db/migrate/20170922160120_remove_admin_level.rb b/db/migrate/20170922160120_remove_admin_level.rb index b3221fb326..188b3c0917 100644 --- a/db/migrate/20170922160120_remove_admin_level.rb +++ b/db/migrate/20170922160120_remove_admin_level.rb @@ -4,6 +4,6 @@ def self.up end def self.down - add_column :users, :admin_level, :string, :null => false, :default => 'none' + add_column :users, :admin_level, :string, null: false, default: 'none' end end diff --git a/db/migrate/20220902112339_remove_public_body_notes.rb b/db/migrate/20220902112339_remove_public_body_notes.rb new file mode 100644 index 0000000000..09d3f72b04 --- /dev/null +++ b/db/migrate/20220902112339_remove_public_body_notes.rb @@ -0,0 +1,22 @@ +class RemovePublicBodyNotes < ActiveRecord::Migration[6.1] + def up + if PublicBody::Translation.where.not(notes: nil).any? + raise <<~TXT + We can't run the RemovePublicBodyNotes database migration. + + We have dectected PublicBody::Translation objects which haven't been + migrated to the new Note model. + + Please deploy Alaveteli 0.42.0.0 and run the upgrade tasks: + https://github.com/mysociety/alaveteli/blob/0.42.0.0/doc/CHANGES.md#upgrade-notes + + TXT + end + + remove_column :public_body_translations, :notes + end + + def down + PublicBody.add_translation_fields! notes: :text + end +end diff --git a/db/migrate/20230127132719_remove_info_request_event_params_yaml.rb b/db/migrate/20230127132719_remove_info_request_event_params_yaml.rb new file mode 100644 index 0000000000..765b34aca2 --- /dev/null +++ b/db/migrate/20230127132719_remove_info_request_event_params_yaml.rb @@ -0,0 +1,22 @@ +class RemoveInfoRequestEventParamsYaml < ActiveRecord::Migration[7.0] + def up + if InfoRequestEvent.where(params: nil).any? + raise <<~TXT + We can't run the RemoveInfoRequestEventParamsYaml database migration. + + We have dectected InfoRequestEvent objects which haven't been migrated + to the new JSONB params column. + + Please deploy Alaveteli 0.42.0.0 and run the upgrade tasks: + https://github.com/mysociety/alaveteli/blob/0.42.0.0/doc/CHANGES.md#upgrade-notes + + TXT + end + + remove_column :info_request_events, :params_yaml + end + + def down + add_column :info_request_events, :params_yaml, :text + end +end diff --git a/db/migrate/20230209094128_remove_public_body_version_notes.rb b/db/migrate/20230209094128_remove_public_body_version_notes.rb new file mode 100644 index 0000000000..b99dba1c09 --- /dev/null +++ b/db/migrate/20230209094128_remove_public_body_version_notes.rb @@ -0,0 +1,5 @@ +class RemovePublicBodyVersionNotes < ActiveRecord::Migration[7.0] + def change + remove_column :public_body_versions, :notes, :text + end +end diff --git a/db/migrate/20230222154014_create_user_messages.rb b/db/migrate/20230222154014_create_user_messages.rb new file mode 100644 index 0000000000..917d95e809 --- /dev/null +++ b/db/migrate/20230222154014_create_user_messages.rb @@ -0,0 +1,8 @@ +class CreateUserMessages < ActiveRecord::Migration[7.0] + def change + create_table :user_messages do |t| + t.references :user, foreign_key: true + t.timestamps + end + end +end diff --git a/db/migrate/20230223145243_add_receive_user_messages_to_user.rb b/db/migrate/20230223145243_add_receive_user_messages_to_user.rb new file mode 100644 index 0000000000..6771349e4e --- /dev/null +++ b/db/migrate/20230223145243_add_receive_user_messages_to_user.rb @@ -0,0 +1,6 @@ +class AddReceiveUserMessagesToUser < ActiveRecord::Migration[7.0] + def change + add_column :users, :receive_user_messages, :boolean, + default: true, null: false + end +end diff --git a/db/migrate/20230301110831_add_user_messages_count_to_users.rb b/db/migrate/20230301110831_add_user_messages_count_to_users.rb new file mode 100644 index 0000000000..8d5d014913 --- /dev/null +++ b/db/migrate/20230301110831_add_user_messages_count_to_users.rb @@ -0,0 +1,5 @@ +class AddUserMessagesCountToUsers < ActiveRecord::Migration[7.0] + def change + add_column :users, :user_messages_count, :integer, default: 0, null: false + end +end diff --git a/db/migrate/20230314171033_create_blog_posts.rb b/db/migrate/20230314171033_create_blog_posts.rb new file mode 100644 index 0000000000..32c6181fba --- /dev/null +++ b/db/migrate/20230314171033_create_blog_posts.rb @@ -0,0 +1,11 @@ +class CreateBlogPosts < ActiveRecord::Migration[7.0] + def change + create_table :blog_posts do |t| + t.string :title + t.string :url + t.jsonb :data + + t.timestamps + end + end +end diff --git a/doc/CHANGES.md b/doc/CHANGES.md index 180577166e..7e6d47193f 100644 --- a/doc/CHANGES.md +++ b/doc/CHANGES.md @@ -1,3 +1,116 @@ +# 0.43.0.0 + +## Highlighted Features + +* Improve censor rules comment editing (Alexander Griffen) +* Reduce the visual prominence of defunct bodies in lists (Gareth Rees) +* Improve application health metrics (Graeme Porteous) +* Add ability to display blog posts on request/authority page sidebars using + tags (Graeme Porteous) +* Adding localisation to resent notice (Miroslav Schlossberg, Graeme Porteous) +* Add ability to paginate through requests in a batch (Gareth Rees) +* Add list of batch requests to admin user page (Gareth Rees) +* Add daily limit to user message creation (Gareth Rees) +* Add project leaderboards (Alexander Griffen) +* Add background job processing (Graeme Porteous) +* Add rate limiting to comment creation (Gareth Rees) +* Fix bug preventing ex-pro users follow up to still-private requests (Gareth + Rees, Graeme Porteous) +* Make it clearer that usernames are published (Gareth Rees) +* Add spam term checking to user to user messages (Gareth Rees) +* Install script improvements (Graeme Porteous) +* Update passenger config (Graeme Porteous) +* Removed legacy event params (Graeme Porteous) +* Removed legacy notes (Graeme Porteous) +* Fix rendering of notes on request new (Graeme Porteous) +* Add support for Ruby 3.2 (Graeme Porteous) +* Add support for Ruby 3.1 (Graeme Porteous) +* Upgrade to Rails 7 (Graeme Porteous) +* Improve processing of large PDF attachments (Graeme Porteous) +* Add support for Ruby 3.0 (Graeme Porteous) +* Drop support for Ruby 2.7 (Graeme Porteous) +* Code linting (Alexander Griffen, Graeme Porteous) +* Dependencies upgrades (Alexander Griffen, Graeme Porteous) + +## Upgrade Notes + +* _Required:_ This upgrade requires upgrading Ruby from 2.7 to 3.x. Alaveteli + can now run on all supported 3.x versions. We recommend upgrading to the 3.2. + See: https://github.com/mysociety/alaveteli/wiki/Migrating-an-existing-Alaveteli-site-from-Ruby-2.7-to-3.x + +* _Required:_ For the new background job processing feature you'll need Redis + Server, a popular open-source in-memory data store. And you'll need Sidekiq + an efficient background job processor for Ruby: + + 1. install Redis Server by running: + + sudo apt-get install redis-server + + 2. configure Sidekiq to run when your server starts by creating + `/etc/systemd/system/sidekiq.service` from `config/sidekiq.service.example`. + And running: + + systemctl enable sidekiq.service + systemctl daemon-reload + +* _Required:_ There are some database structure updates so remember to run: + + bin/rails db:migrate + +* _Optional:_ To upgrade the Ruby version in your development Docker container + please run: + + docker/reset + +* _Note:_ This release will be the last to support anonymous "external requests" + created by the API. If you rely on the API to create or update requests then + please contact us as it is our current intention to make the API read-only for + the next release. + +* _Note:_ This release will be the last to officially support Ubuntu Focal + 20.04. With the next release we will recommend using Ubuntu Jammy 22.04 LTS. + Although using Focal might still work as it will still be within Ubuntu's + long term support window. Please bear this in mind for future upgrades. + +### Changed Templates + +app/views/admin/tags/_tagging.html.erb +app/views/admin/users/_sign_in_table.html.erb +app/views/admin_censor_rule/_form.html.erb +app/views/admin_censor_rule/_list.html.erb +app/views/admin_censor_rule/index.html.erb +app/views/admin_comment/edit.html.erb +app/views/admin_general/_admin_navbar.html.erb +app/views/admin_general/_edit_comment.html.erb +app/views/admin_general/stats.html.erb +app/views/admin_public_body/_public_body.html.erb +app/views/admin_public_body/show.html.erb +app/views/admin_request/show.html.erb +app/views/admin_user/edit.html.erb +app/views/admin_user/show.html.erb +app/views/alaveteli_pro/general/_nav_items.html.erb +app/views/alaveteli_pro/info_request_batches/_message_preview.html.erb +app/views/alaveteli_pro/info_requests/_batch.html.erb +app/views/alaveteli_pro/info_requests/_message_preview.html.erb +app/views/alaveteli_pro/info_requests/_select_authority_form.html.erb +app/views/alaveteli_pro/info_requests/_sidebar.html.erb +app/views/alaveteli_pro/info_requests/new.html.erb +app/views/alaveteli_pro/plans/_pricing_tiers.html.erb +app/views/comment/rate_limited.html.erb +app/views/general/_nav_items.html.erb +app/views/general/blog.html.erb +app/views/general/frontpage.html.erb +app/views/health/checks/index.html.erb +app/views/projects/projects/show.html.erb +app/views/public_body/_body_listing_single.html.erb +app/views/public_body/show.html.erb +app/views/request/_batch.html.erb +app/views/request/_resent_outgoing_correspondence.html.erb +app/views/request/_resent_outgoing_correspondence.text.erb +app/views/request/_sidebar.html.erb +app/views/request/new.html.erb +app/views/request/preview.html.erb + # 0.42.0.1 ## Highlighted Features diff --git a/docker-compose.yml b/docker-compose.yml index 414ad83f1a..18a6cdbb23 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,18 +5,44 @@ services: build: context: . dockerfile: docker/Dockerfile + args: + RUBY_VERSION: '${RUBY_VERSION:-3.0}' environment: - BUNDLE_PATH=/bundle/vendor - DATABASE_URL=postgres://postgres:password@db/ + - REDIS_URL=redis://redis:6379 + - SMTP_URL=smtp://smtp:1025 ports: - 3000:3000 - - 1080:1080 volumes: - ./:/alaveteli - ../alaveteli-themes:/alaveteli-themes - bundle:/bundle depends_on: - db + - redis + - smtp + + sidekiq: + build: + context: . + dockerfile: docker/Dockerfile + args: + RUBY_VERSION: '${RUBY_VERSION:-3.0}' + command: bundle exec sidekiq + volumes: + - ./:/alaveteli + - ../alaveteli-themes:/alaveteli-themes + - bundle:/bundle + environment: + - BUNDLE_PATH=/bundle/vendor + - DATABASE_URL=postgres://postgres:password@db/ + - REDIS_URL=redis://redis:6379 + - SMTP_URL=smtp://smtp:1025 + depends_on: + - db + - redis + - smtp db: build: @@ -29,6 +55,18 @@ services: volumes: - postgres:/var/lib/postgresql/data + redis: + image: library/redis + command: redis-server + volumes: + - redis:/data + + smtp: + image: mailhog/mailhog + ports: + - 1080:8025 + volumes: bundle: {} postgres: {} + redis: {} diff --git a/docker/Dockerfile b/docker/Dockerfile index 875fbe51b8..c2b7f245e0 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,5 @@ -FROM ruby:2.7-bullseye +ARG RUBY_VERSION=3.0 +FROM ruby:${RUBY_VERSION}-bullseye ENV DOCKER 1 ENV DEBIAN_FRONTEND noninteractive @@ -21,11 +22,10 @@ RUN git clone https://github.com/vishnubob/wait-for-it.git /tmp/wait-for-it && \ chmod +x /tmp/wait-for-it/wait-for-it.sh && \ ln -s /tmp/wait-for-it/wait-for-it.sh /bin/wait-for-it -WORKDIR /alaveteli/ +WORKDIR /alaveteli +RUN git config --global --add safe.directory /alaveteli RUN gem update --system -RUN gem install mailcatcher EXPOSE 3000 -EXPOSE 1080 CMD wait-for-it db:5432 --strict -- ./docker/entrypoint.sh diff --git a/docker/README.md b/docker/README.md index b7f9af2831..3d028e270b 100644 --- a/docker/README.md +++ b/docker/README.md @@ -1,33 +1,2 @@ -Tips and tricks for using the Alaveteli Docker setup. - -Run the development app server: - -``` -docker/server -``` - -Run the rails console: - -``` -dc run --rm app bin/rails c -``` - -Run other rails commands: - -``` -dc run --rm app bin/rails routes -dc run --rm app bin/rails runner "puts 1" -# etc… -``` - -Run a command with an environment variable set: - -``` -dc run -e RAILS_ENV=test --rm app bin/rails db:migrate -``` - -Use `-T` to pipe local files to scripts run in the app container. - -``` -cat spec/fixtures/files/incoming-request-plain.email | dc run --rm -T app script/mailin -``` +See https://alaveteli.org/docs/installing/docker/ for a guide to installing +Alaveteli via Docker. diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 21da58236e..a947e94b7d 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -1,6 +1,4 @@ #!/bin/sh -mailcatcher --ip=0.0.0.0 - rm -f tmp/pids/server.pid bin/rails server -b 0.0.0.0 diff --git a/docker/env b/docker/env new file mode 100755 index 0000000000..a8c9e848bb --- /dev/null +++ b/docker/env @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +cd "$(dirname "$0")/.." + +if [ -e .ruby-version ]; then + export RUBY_VERSION="$(cat .ruby-version)" +fi diff --git a/docker/reset b/docker/reset index 17bc124478..1d12dec910 100755 --- a/docker/reset +++ b/docker/reset @@ -4,18 +4,26 @@ set -e cd "$(dirname "$0")/.." -while true -do - read -r -p 'This will remove your development database. Do you want to continue? ' choice - case "$choice" in - n|N) exit;; - y|Y) break;; - *) echo 'Response not valid';; - esac -done +. docker/env docker compose down -docker volume rm "$(basename $(pwd))_postgres" + +db_volume="$(basename $(pwd))_postgres" +if docker volume ls | grep $db_volume >/dev/null; then + while true + do + read -r -p 'Do you also want to reset your development database? ' choice + case "$choice" in + n|N) break;; + y|Y) + docker volume rm $db_volume >/dev/null + data_reset=true + break;; + *) echo 'Response not valid';; + esac + done +fi + docker compose build --pull -./docker/bootstrap +./docker/setup $data_reset diff --git a/docker/server b/docker/server index 6fa3706183..980fff0f6f 100755 --- a/docker/server +++ b/docker/server @@ -5,6 +5,7 @@ set -e cd "$(dirname "$0")/.." if [ -z "$DOCKER" ]; then + . docker/env docker compose up exit fi diff --git a/docker/setup b/docker/setup index c1da52a129..a107e5032a 100755 --- a/docker/setup +++ b/docker/setup @@ -5,8 +5,9 @@ set -e cd "$(dirname "$0")/.." if [ -z "$DOCKER" ]; then + . docker/env ./docker/bootstrap - docker compose run --rm app ./docker/setup + docker compose run --rm app ./docker/setup "$@" exit fi @@ -14,8 +15,10 @@ error_msg() { printf "\033[31m%s\033[0m\n" "$*"; } notice_msg() { printf "\033[33m%s\033[0m " "$*"; } success_msg() { printf "\033[32m%s\033[0m\n" "$*"; } +data_reset="${1:-false}" + notice_msg 'Installing Ruby gems...' -bundle install >/dev/null +bundle install success_msg 'done' if [ -L config/general.yml ]; then @@ -26,17 +29,19 @@ if [ -L config/general.yml ]; then success_msg 'done' fi -notice_msg 'Migrating development and test databases...' -bin/rails db:migrate db:seed >/dev/null -bin/rails db:migrate RAILS_ENV=test >/dev/null -success_msg 'done' +if $data_reset; then + notice_msg 'Migrating development and test databases...' + bin/rails db:migrate db:seed >/dev/null + bin/rails db:migrate RAILS_ENV=test >/dev/null + success_msg 'done' -notice_msg 'Loading sample data...' -bundle exec script/load-sample-data > /dev/null -success_msg 'done' + notice_msg 'Loading sample data...' + bundle exec script/load-sample-data > /dev/null + success_msg 'done' -notice_msg 'Rebuilding Xapian index...' -bundle exec script/destroy-and-rebuild-xapian-index > /dev/null -success_msg 'done' + notice_msg 'Rebuilding Xapian index...' + bundle exec script/destroy-and-rebuild-xapian-index > /dev/null + success_msg 'done' +fi success_msg 'Setup finished' diff --git a/gems/alaveteli_features/Rakefile b/gems/alaveteli_features/Rakefile index b7e9ed549b..c92b11ee06 100644 --- a/gems/alaveteli_features/Rakefile +++ b/gems/alaveteli_features/Rakefile @@ -3,4 +3,4 @@ require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) -task :default => :spec +task default: :spec diff --git a/gems/alaveteli_features/alaveteli_features.gemspec b/gems/alaveteli_features/alaveteli_features.gemspec index f1e643ced0..68a338bdb3 100644 --- a/gems/alaveteli_features/alaveteli_features.gemspec +++ b/gems/alaveteli_features/alaveteli_features.gemspec @@ -1,11 +1,8 @@ +require 'English' lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'alaveteli_features/version' -def rails_upgrade? - %w[1 true].include?(ENV['RAILS_UPGRADE']) -end - Gem::Specification.new do |spec| spec.name = "alaveteli_features" spec.version = AlaveteliFeatures::VERSION @@ -16,12 +13,12 @@ Gem::Specification.new do |spec| spec.homepage = "https://alaveteli.org" spec.license = "MIT" - spec.files = `git ls-files`.split($/) + spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR) spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ["lib"] - spec.add_dependency "rails", rails_upgrade? ? "~> 7.0.2" : "~> 6.1.4" + spec.add_dependency "rails", "~> 7.0.4" spec.add_dependency "flipper", "~> 0.10" spec.add_dependency "flipper-active_record", "~> 0.10" # Mime types 3 needs Ruby 2.0.0 or greater, but we need to support 1.9.3 so diff --git a/gems/alaveteli_features/lib/alaveteli_features.rb b/gems/alaveteli_features/lib/alaveteli_features.rb index e578691f58..66860937bb 100644 --- a/gems/alaveteli_features/lib/alaveteli_features.rb +++ b/gems/alaveteli_features/lib/alaveteli_features.rb @@ -19,7 +19,7 @@ def self.groups def self.backend return @backend if @backend - if self.tables_exist? + if tables_exist? @backend = Flipper.new(Flipper::Adapters::ActiveRecord.new) else if defined?(Rails) @@ -43,12 +43,9 @@ def self.backend=(backend) # We just want to know if our tables exist, but we can't do that without # risking an error def self.tables_exist? - begin - ActiveRecord::Base.establish_connection - return ActiveRecord::Base. - connection.data_source_exists?(:flipper_features) - rescue - return false - end + ActiveRecord::Base.establish_connection + ActiveRecord::Base.connection.data_source_exists?(:flipper_features) + rescue + false end end diff --git a/gems/alaveteli_features/lib/alaveteli_features/constraints.rb b/gems/alaveteli_features/lib/alaveteli_features/constraints.rb index 177a15d685..e68e9bf031 100644 --- a/gems/alaveteli_features/lib/alaveteli_features/constraints.rb +++ b/gems/alaveteli_features/lib/alaveteli_features/constraints.rb @@ -7,8 +7,8 @@ def initialize(feature) @feature = feature end - def matches?(request) - return feature_enabled? @feature + def matches?(_request) + feature_enabled? @feature end end end diff --git a/gems/alaveteli_features/lib/alaveteli_features/generators/alaveteli_features/install/install_generator.rb b/gems/alaveteli_features/lib/alaveteli_features/generators/alaveteli_features/install/install_generator.rb index 9c5db8ac0d..f3461f1e71 100644 --- a/gems/alaveteli_features/lib/alaveteli_features/generators/alaveteli_features/install/install_generator.rb +++ b/gems/alaveteli_features/lib/alaveteli_features/generators/alaveteli_features/install/install_generator.rb @@ -5,7 +5,7 @@ class InstallGenerator < Rails::Generators::Base class_option :migrate, type: :boolean, default: true, banner: 'Run AlaveteliFeatures migrations' def self.source_paths - paths = self.superclass.source_paths + paths = superclass.source_paths paths << File.expand_path('../templates', "../../#{__FILE__}") paths << File.expand_path('../templates', "../#{__FILE__}") paths << File.expand_path('../templates', __FILE__) diff --git a/lib/acts_as_xapian/acts_as_xapian.rb b/lib/acts_as_xapian/acts_as_xapian.rb index 610e9ebdc5..fd572e2444 100644 --- a/lib/acts_as_xapian/acts_as_xapian.rb +++ b/lib/acts_as_xapian/acts_as_xapian.rb @@ -12,6 +12,7 @@ # Make it so if Xapian isn't installed, the Rails app doesn't fail completely, # just when somebody does a search. +require 'English' begin require 'xapian' $acts_as_xapian_bindings_available = true @@ -99,7 +100,7 @@ def self.max_wildcard_expansion ###################################################################### # Initialisation def self.init(classname = nil, options = nil) - if not classname.nil? + unless classname.nil? # store class and options for use later, when we open the db in readable_init @@init_values.push([classname,options]) end @@ -111,7 +112,9 @@ def self.prepare_environment # barf if we can't figure out the environment environment = (ENV['RAILS_ENV'] or Rails.env) - raise "Set RAILS_ENV, so acts_as_xapian can find the right Xapian database" if not environment + unless environment + raise "Set RAILS_ENV, so acts_as_xapian can find the right Xapian database" + end # check for a config file config_file = Rails.root.join("config","xapian.yml") @@ -141,8 +144,12 @@ def self.prepare_environment # TODO: we perhaps don't need to rebuild database and enquire and queryparser - # but db.reopen wasn't enough by itself, so just do everything it's easier. def self.readable_init - raise NoXapianRubyBindingsError.new("Xapian Ruby bindings not installed") unless ActsAsXapian.bindings_available - raise "acts_as_xapian hasn't been called in any models" if @@init_values.empty? + unless ActsAsXapian.bindings_available + raise NoXapianRubyBindingsError, "Xapian Ruby bindings not installed" + end + if @@init_values.empty? + raise "acts_as_xapian hasn't been called in any models" + end prepare_environment @@ -151,9 +158,7 @@ def self.readable_init # only speculate about at the moment. (It is easy to reproduce this by # changing the code below to use reopen rather than open followed by # close, and running rake spec.) - if !@@db.nil? - @@db.close - end + @@db.close unless @@db.nil? # basic Xapian objects begin @@ -195,7 +200,7 @@ def self.init_query_parser @@values_by_prefix = {} @@value_ranges_store = [] - @@init_values.each do |classname, options| + @@init_values.each do |_classname, options| # go through the various field types, and tell query parser about them, # and error check them - i.e. check for consistency between models @@query_parser.add_boolean_prefix("model", "M") @@ -206,8 +211,10 @@ def self.init_query_parser end def self.init_values(values) - values.each do |method, index, prefix, value_type| - raise "Value index '#{index}' must be an Integer, is #{index.class}" unless index.is_a? Integer + values.each do |_method, index, prefix, value_type| + unless index.is_a? Integer + raise "Value index '#{index}' must be an Integer, is #{index.class}" + end if @@values_by_number.include?(index) && @@values_by_number[index] != prefix raise "Already have value index '#{index}' in another model " \ "but with different prefix '#{@@values_by_number[index]}'" @@ -238,10 +245,16 @@ def self.init_values(values) end def self.init_terms(terms) - terms.each do |method, term_code, prefix| - raise "Use a single capital letter for term code" if not term_code.match(/^[A-Z]$/) - raise "M and I are reserved for use as the model/id term" if term_code == "M" || term_code == "I" - raise "model and modelid are reserved for use as the model/id prefixes" if prefix == "model" || prefix == "modelid" + terms.each do |_method, term_code, prefix| + unless term_code.match(/^[A-Z]$/) + raise "Use a single capital letter for term code" + end + if term_code == "M" || term_code == "I" + raise "M and I are reserved for use as the model/id term" + end + if prefix == "model" || prefix == "modelid" + raise "model and modelid are reserved for use as the model/id prefixes" + end raise "Z is reserved for stemming terms" if term_code == "Z" if @@terms_by_capital.include?(term_code) && @@terms_by_capital[term_code] != prefix raise "Already have code '#{term_code}' in another model but with different prefix " \ @@ -257,8 +270,12 @@ def self.init_terms(terms) end def self.writable_init(suffix = "") - raise NoXapianRubyBindingsError.new("Xapian Ruby bindings not installed") unless ActsAsXapian.bindings_available - raise "acts_as_xapian hasn't been called in any models" if @@init_values.empty? + unless ActsAsXapian.bindings_available + raise NoXapianRubyBindingsError, "Xapian Ruby bindings not installed" + end + if @@init_values.empty? + raise "acts_as_xapian hasn't been called in any models" + end # if DB is not nil, then we're already initialised, so don't do it # again TODO: reopen it each time, xapian_spec.rb needs this so database @@ -295,9 +312,7 @@ def initialize_db self.runtime = 0.0 ActsAsXapian.readable_init - if ActsAsXapian.db.nil? - raise "ActsAsXapian not initialized" - end + raise "ActsAsXapian not initialized" if ActsAsXapian.db.nil? end MSET_MAX_TRIES = 5 @@ -306,29 +321,36 @@ def initialize_db def initialize_query(options) #raise options.to_yaml - self.runtime += Benchmark::realtime { - offset = options[:offset] || 0; offset = offset.to_i + self.runtime += Benchmark.realtime { + offset = options[:offset] || 0 + offset = offset.to_i limit = options[:limit] - raise "please specifiy maximum number of results to return with parameter :limit" if not limit + unless limit + raise "please specifiy maximum number of results to return with parameter :limit" + end limit = limit.to_i sort_by_prefix = options[:sort_by_prefix] || nil sort_by_ascending = options[:sort_by_ascending].nil? ? true : options[:sort_by_ascending] collapse_by_prefix = options[:collapse_by_prefix] || nil - ActsAsXapian.enquire.query = self.query + ActsAsXapian.enquire.query = query if sort_by_prefix.nil? ActsAsXapian.enquire.sort_by_relevance! else value = ActsAsXapian.values_by_prefix[sort_by_prefix] - raise "couldn't find prefix '" + sort_by_prefix.to_s + "'" if value.nil? + if value.nil? + raise "couldn't find prefix '" + sort_by_prefix.to_s + "'" + end ActsAsXapian.enquire.sort_by_value_then_relevance!(value, sort_by_ascending) end if collapse_by_prefix.nil? ActsAsXapian.enquire.collapse_key = Xapian::BAD_VALUENO else value = ActsAsXapian.values_by_prefix[collapse_by_prefix] - raise "couldn't find prefix '" + collapse_by_prefix + "'" if value.nil? + if value.nil? + raise "couldn't find prefix '" + collapse_by_prefix + "'" + end ActsAsXapian.enquire.collapse_key = value end @@ -362,80 +384,74 @@ def initialize_query(options) # Return a description of the query def description - self.query.description + query.description end # Does the query have non-prefixed search terms in it? def has_normal_search_terms? ret = false #x = '' - for t in self.query.terms + query.terms.each do |t| term = t.term #x = x + term.to_yaml + term.size.to_s + term[0..0] + "*" if term.size >= 2 && term[0..0] == 'Z' # normal terms begin Z (for stemmed), then have no capital letter prefix - if term[1..1] == term[1..1].downcase - ret = true - end + ret = true if term[1..1] == term[1..1].downcase end end - return ret + ret end # Estimate total number of results def matches_estimated - self.matches.matches_estimated + matches.matches_estimated end # Return query string with spelling correction def spelling_correction correction = ActsAsXapian.query_parser.get_corrected_query_string - if correction.empty? - return nil - end + return nil if correction.empty? correction.force_encoding('UTF-8') end # Return array of models found def results # If they've already pulled out the results, just return them. - if !self.cached_results.nil? - return self.cached_results - end + return cached_results unless cached_results.nil? docs = [] - self.runtime += Benchmark::realtime { + self.runtime += Benchmark.realtime { # Pull out all the results - iter = self.matches._begin - while not iter.equals(self.matches._end) - docs.push({:data => iter.document.data, - :percent => iter.percent, - :weight => iter.weight, - :collapse_count => iter.collapse_count}) + iter = matches._begin + until iter.equals(matches._end) + docs.push({data: iter.document.data, + percent: iter.percent, + weight: iter.weight, + collapse_count: iter.collapse_count}) iter.next end } # Log time taken, excluding database lookups below which will be displayed separately by ActiveRecord if ActiveRecord::Base.logger - ActiveRecord::Base.logger.add(Logger::DEBUG, " Xapian query (#{'%.5fs' % self.runtime}) #{self.log_description}") + ActiveRecord::Base.logger.add(Logger::DEBUG, format(" Xapian query (%.5fs) %s", self.runtime, self.log_description)) end # Look up without too many SQL queries lhash = {} lhash.default = [] - for doc in docs + docs.each do |doc| k = doc[:data].split('-') lhash[k[0]] = lhash[k[0]] + [k[1]] end # for each class, look up all ids chash = {} - for cls, ids in lhash + lhash.each do |cls, ids| found = cls.constantize. includes(cls.constantize.xapian_options[:eager_load]). where("#{cls.constantize.table_name}.#{cls.constantize.primary_key} in (?)", ids) - for f in found + found.each do |f| chash[[cls, f.id]] = f end end @@ -445,14 +461,14 @@ def results k = doc[:data].split('-') model_instance = chash[[k[0], k[1].to_i]] if model_instance - results << { :model => model_instance, - :percent => doc[:percent], - :weight => doc[:weight], - :collapse_count => doc[:collapse_count] } + results << { model: model_instance, + percent: doc[:percent], + weight: doc[:weight], + collapse_count: doc[:collapse_count] } end end self.cached_results = results - return results + results end end @@ -475,15 +491,17 @@ def initialize(model_classes, query_string, options = {}, user_query = nil) # Check parameters, convert to actual array of model classes new_model_classes = [] model_classes = [model_classes] if model_classes.class != Array - for model_class in model_classes - raise "pass in the model class itself, or a string containing its name" if model_class.class != Class && model_class.class != String + model_classes.each do |model_class| + if model_class.class != Class && model_class.class != String + raise "pass in the model class itself, or a string containing its name" + end model_class = model_class.constantize if model_class.class == String new_model_classes.push(model_class) end model_classes = new_model_classes # Set things up - self.initialize_db + initialize_db # Case of a string, searching for a Google-like syntax query self.query_string = query_string @@ -500,24 +518,28 @@ def initialize(model_classes, query_string, options = {}, user_query = nil) self.query = Xapian::Query.new(Xapian::Query::OP_AND, model_query, user_query) # Call base class constructor - self.initialize_query(options) + initialize_query(options) end # Return just normal words in the query i.e. Not operators, ones in # date ranges or similar. Use this for cheap highlighting with # TextHelper::highlight, and excerpt. def words_to_highlight(opts = {}) - default_opts = { :include_original => false, :regex => false } + default_opts = { include_original: false, regex: false } opts = default_opts.merge(opts) # Reject all prefixes other than Z, which we know is reserved for stems terms = query.terms.reject { |t| t.term.first.match(/^[A-Y]$/) } # Collect the stems including the Z prefix - raw_stems = terms.map { |t| t.term if t.term.start_with?('Z') }.compact.uniq.sort + raw_stems = terms.map { |t| if t.term.start_with?('Z') + t.term + end }.compact.uniq.sort # Collect stems, chopping the Z prefix off stems = raw_stems.map { |t| t[1..-1] }.compact.sort # Collect the non-stem terms - words = terms.map { |t| t.term unless t.term.start_with?('Z') }.compact.sort + words = terms.map { |t| unless t.term.start_with?('Z') + t.term + end }.compact.sort # Add the unstemmed words from the original query # Sometimes stems can be unhelpful with the :regex option, for example @@ -542,7 +564,7 @@ def words_to_highlight(opts = {}) # Text for lines in log file def log_description - "Search: " + self.query_string + "Search: " + query_string end private @@ -563,9 +585,9 @@ class Similar < QueryBase # model_classes - model classes to search within, e.g. [PublicBody, User] # query_models - list of models you want to find things similar to def initialize(model_classes, query_models, options = {}) - self.initialize_db + initialize_db - self.runtime += Benchmark::realtime { + self.runtime += Benchmark.realtime { # Case of an array, searching for models similar to those models in the array self.query_models = query_models @@ -577,7 +599,7 @@ def initialize(model_classes, query_models, options = {}) # Get set of relevant terms for those documents selection = Xapian::RSet.new iter = matches._begin - while not iter.equals(matches._end) + until iter.equals(matches._end) selection.add_document(iter) iter.next end @@ -591,11 +613,11 @@ def initialize(model_classes, query_models, options = {}) # Do main search for them self.important_terms = [] iter = eset._begin - while not iter.equals(eset._end) - self.important_terms.push(iter.term) + until iter.equals(eset._end) + important_terms.push(iter.term) iter.next end - similar_query = Xapian::Query.new(Xapian::Query::OP_OR, self.important_terms) + similar_query = Xapian::Query.new(Xapian::Query::OP_OR, important_terms) # Exclude original combined_query = Xapian::Query.new(Xapian::Query::OP_AND_NOT, similar_query, input_models_query) @@ -605,12 +627,12 @@ def initialize(model_classes, query_models, options = {}) } # Call base class constructor - self.initialize_query(options) + initialize_query(options) end # Text for lines in log file def log_description - "Similar: " + self.query_models.to_s + "Similar: " + query_models.to_s end end @@ -708,7 +730,7 @@ def self.update_index(flush = false, verbose = false) # Before calling writable_init we have to make sure every model class has been initialized. # i.e. has had its class code loaded, so acts_as_xapian has been called inside it, and # we have the info from acts_as_xapian. - model_classes = ActsAsXapianJob.distinct.pluck(:model).map { |a| a.constantize } + model_classes = ActsAsXapianJob.distinct.pluck(:model).map(&:constantize) # If there are no models in the queue, then nothing to do return if model_classes.empty? @@ -756,7 +778,9 @@ def self.update_index(flush = false, verbose = false) end def self.run_job(job, flush, verbose) - STDOUT.puts("ActsAsXapian.update_index #{job.action} #{job.model} #{job.model_id.to_s} #{Time.now.to_s}") if verbose + if verbose + STDOUT.puts("ActsAsXapian.update_index #{job.action} #{job.model} #{job.model_id} #{Time.now}") + end begin if job.action == 'update' @@ -776,9 +800,7 @@ def self.run_job(job, flush, verbose) job.action = 'destroy' retry end - if flush - ActsAsXapian.writable_db.flush - end + ActsAsXapian.writable_db.flush if flush job.destroy end @@ -817,12 +839,12 @@ def self.destroy_and_rebuild_index(model_classes, verbose = false, terms = true, new_path = ActsAsXapian.db_path + ".new" old_path = ActsAsXapian.db_path if File.exist?(new_path) - raise "found existing " + new_path + " which is not Xapian chert or glass database, please delete for me" if not ActsAsXapian._is_xapian_db(new_path) + unless ActsAsXapian._is_xapian_db(new_path) + raise "found existing " + new_path + " which is not Xapian chert or glass database, please delete for me" + end FileUtils.rm_r(new_path) end - if update_existing - FileUtils.cp_r(old_path, new_path) - end + FileUtils.cp_r(old_path, new_path) if update_existing ActsAsXapian.writable_init ActsAsXapian.writable_db.close # just to make an empty one to read # Index everything @@ -832,10 +854,14 @@ def self.destroy_and_rebuild_index(model_classes, verbose = false, terms = true, @@db_path = ActsAsXapian.db_path + ".new" ActsAsXapian.writable_init # Save time by running the indexing in one go and in-process - for model_class in model_classes - STDOUT.puts("ActsAsXapian.destroy_and_rebuild_index: Rebuilding #{model_class.to_s}") if verbose + model_classes.each do |model_class| + if verbose + STDOUT.puts("ActsAsXapian.destroy_and_rebuild_index: Rebuilding #{model_class}") + end model_class.find_each do |model| - STDOUT.puts("ActsAsXapian.destroy_and_rebuild_index #{model_class} #{model.id}") if verbose + if verbose + STDOUT.puts("ActsAsXapian.destroy_and_rebuild_index #{model_class} #{model.id}") + end model.xapian_index(terms, values, texts) end end @@ -847,17 +873,17 @@ def self.destroy_and_rebuild_index(model_classes, verbose = false, terms = true, temp_path = old_path + ".tmp" if File.exist?(temp_path) @@db_path = old_path - raise "temporary database found " + temp_path + " which is not Xapian chert or glass database, please delete for me" if not ActsAsXapian._is_xapian_db(temp_path) + unless ActsAsXapian._is_xapian_db(temp_path) + raise "temporary database found " + temp_path + " which is not Xapian chert or glass database, please delete for me" + end FileUtils.rm_r(temp_path) end - if File.exist?(old_path) - FileUtils.mv old_path, temp_path - end + FileUtils.mv old_path, temp_path if File.exist?(old_path) FileUtils.mv new_path, old_path # Delete old database if File.exist?(temp_path) - if not ActsAsXapian._is_xapian_db(temp_path) + unless ActsAsXapian._is_xapian_db(temp_path) @@db_path = old_path raise "old database now at " + temp_path + " is not Xapian chert or glass database, please delete for me" end @@ -871,7 +897,7 @@ def self.destroy_and_rebuild_index(model_classes, verbose = false, terms = true, def self._destroy_and_rebuild_index_safely(model_classes, verbose, terms, values, texts) batch_size = 1000 - for model_class in model_classes + model_classes.each do |model_class| model_class_count = model_class.count 0.step(model_class_count, batch_size) do |i| # We fork here, so each batch is run in a different process. This is @@ -883,9 +909,7 @@ def self._destroy_and_rebuild_index_safely(model_classes, verbose, terms, values pid = Process.fork # TODO: this will only work on Unix, tough if pid Process.waitpid(pid) - if not $?.success? - raise "batch fork child failed, exiting also" - end + raise "batch fork child failed, exiting also" unless $CHILD_STATUS.success? # database connection doesn't survive a fork, rebuild it else # fully reopen the database each time (with a new object) @@ -893,9 +917,13 @@ def self._destroy_and_rebuild_index_safely(model_classes, verbose, terms, values ActiveRecord::Base.establish_connection @@db_path = ActsAsXapian.db_path + ".new" ActsAsXapian.writable_init - STDOUT.puts("ActsAsXapian.destroy_and_rebuild_index: New batch. #{model_class.to_s} from #{i} to #{i + batch_size} of #{model_class_count} pid #{Process.pid.to_s}") if verbose + if verbose + STDOUT.puts("ActsAsXapian.destroy_and_rebuild_index: New batch. #{model_class} from #{i} to #{i + batch_size} of #{model_class_count} pid #{Process.pid}") + end model_class.limit(batch_size).offset(i).order(:id).each do |model| - STDOUT.puts("ActsAsXapian.destroy_and_rebuild_index #{model_class} #{model.id}") if verbose + if verbose + STDOUT.puts("ActsAsXapian.destroy_and_rebuild_index #{model_class} #{model.id}") + end model.xapian_index(terms, values, texts) end ActsAsXapian.writable_db.flush @@ -918,54 +946,52 @@ def self._destroy_and_rebuild_index_safely(model_classes, verbose, terms, values module InstanceMethods # Used internally def xapian_document_term - self.class.to_s + "-" + self.id.to_s + self.class.to_s + "-" + id.to_s end def xapian_value(field, type = nil, index_translations = false) - if index_translations && self.respond_to?("translations") - if type == :date or type == :boolean + if index_translations && respond_to?("translations") + if (type == :date) || (type == :boolean) value = single_xapian_value(field, type = type) else values = [] - for locale in self.translations.map { |x| x.locale } + translations.map(&:locale).each do |locale| AlaveteliLocalization.with_locale(locale) do values << single_xapian_value(field, type=type) end end - if values[0].kind_of?(Array) + if values[0].is_a?(Array) values = values.flatten - value = values.reject { |x| x.nil? } + value = values.reject(&:nil?) else - values = values.reject { |x| x.nil? } + values = values.reject(&:nil?) value = values.join(" ") end end else value = single_xapian_value(field, type = type) end - return value + value end # Extract value of a field from the model def single_xapian_value(field, type = nil) - value = self.send(field.to_sym) || self[field] + value = send(field.to_sym) || self[field] if type == :date - if value.kind_of?(Time) + if value.is_a?(Time) value.utc.strftime("%Y%m%d") - elsif value.kind_of?(Date) + elsif value.is_a?(Date) value.to_time.utc.strftime("%Y%m%d") else raise "Only Time or Date types supported by acts_as_xapian for :date fields, got " + value.class.to_s end elsif type == :boolean value ? true : false - else + elsif value.kind_of?(Array) # Arrays are for terms which require multiple of them, e.g. tags - if value.kind_of?(Array) - value.map { |v| v.to_s } - else - value.to_s - end + value.map(&:to_s) + else + value.to_s end end @@ -974,13 +1000,13 @@ def xapian_index(terms = true, values = true, texts = true) # if we have a conditional function for indexing, call it and destroy object if failed if self.class.xapian_options.include?(:if) if_value = xapian_value(self.class.xapian_options[:if], :boolean) - if not if_value - self.xapian_destroy + unless if_value + xapian_destroy return end end - existing_query = Xapian::Query.new("I" + self.xapian_document_term) + existing_query = Xapian::Query.new("I" + xapian_document_term) ActsAsXapian.enquire.query = existing_query match = ActsAsXapian.enquire.mset(0,1,1).matches[0] @@ -988,7 +1014,7 @@ def xapian_index(terms = true, values = true, texts = true) doc = match.document else doc = Xapian::Document.new - doc.data = self.xapian_document_term + doc.data = xapian_document_term doc.add_term("M" + self.class.to_s) doc.add_term("I" + doc.data) end @@ -996,11 +1022,11 @@ def xapian_index(terms = true, values = true, texts = true) # 1. Which terms to index? We allow the user to specify particular ones terms_to_index = [] drop_all_terms = false - if terms and self.xapian_options[:terms] - terms_to_index = self.xapian_options[:terms].dup + if terms && xapian_options[:terms] + terms_to_index = xapian_options[:terms].dup if terms.is_a?(String) terms_to_index.reject! { |term| !terms.include?(term[1]) } - if terms_to_index.length == self.xapian_options[:terms].length + if terms_to_index.length == xapian_options[:terms].length drop_all_terms = true end else @@ -1009,13 +1035,13 @@ def xapian_index(terms = true, values = true, texts = true) end # 2. Texts to index? Currently, it's all or nothing texts_to_index = [] - if texts and self.xapian_options[:texts] - texts_to_index = self.xapian_options[:texts] + if texts && xapian_options[:texts] + texts_to_index = xapian_options[:texts] end # 3. Values to index? Currently, it's all or nothing values_to_index = [] - if values and self.xapian_options[:values] - values_to_index = self.xapian_options[:values] + if values && xapian_options[:values] + values_to_index = xapian_options[:values] end # clear any existing data that we might want to replace @@ -1026,9 +1052,9 @@ def xapian_index(terms = true, values = true, texts = true) doc.add_term("I" + doc.data) else term_prefixes_to_index = terms_to_index.map { |x| x[1] } - for existing_term in doc.terms + doc.terms.each do |existing_term| first_letter = existing_term.term[0...1] - if !"MI".include?(first_letter) # it's not one of the reserved value + unless "MI".include?(first_letter) # it's not one of the reserved value if first_letter.match("^[A-Z]+") # it's a "value" (rather than indexed text) if term_prefixes_to_index.include?(first_letter) # it's a value that we've been asked to index doc.remove_term(existing_term.term) @@ -1040,10 +1066,10 @@ def xapian_index(terms = true, values = true, texts = true) end end - for term in terms_to_index + terms_to_index.each do |term| value = xapian_value(term[0]) - if value.kind_of?(Array) - for v in value + if value.is_a?(Array) + value.each do |v| doc.add_term(term[1] + v) doc.add_posting(term[1] + v, 1, Integer(term[3])) if term[3] end @@ -1055,14 +1081,14 @@ def xapian_index(terms = true, values = true, texts = true) if values doc.clear_values - for value in values_to_index + values_to_index.each do |value| doc.add_value(value[1], xapian_value(value[0], value[3])) end end if texts ActsAsXapian.term_generator.document = doc - for text in texts_to_index + texts_to_index.each do |text| ActsAsXapian.term_generator.increase_termpos # stop phrases spanning different text fields # The "100" here is a weight that could be varied for a boost # function. A lower number represents a higher weight, so we set the @@ -1078,39 +1104,43 @@ def xapian_index(terms = true, values = true, texts = true) # Delete record from the Xapian database def xapian_destroy - ActsAsXapian.writable_db.delete_document("I" + self.xapian_document_term) + ActsAsXapian.writable_db.delete_document("I" + xapian_document_term) end # Used to mark changes needed by batch indexer def xapian_mark_needs_index - xapian_create_job('update', self.class.base_class.to_s, self.id) + xapian_create_job('update', self.class.base_class.to_s, id) end def xapian_mark_needs_destroy - xapian_create_job('destroy', self.class.base_class.to_s, self.id) + xapian_create_job('destroy', self.class.base_class.to_s, id) end # Allow reindexing to be skipped if a flag is set def xapian_mark_needs_index_if_reindex - return true if (self.respond_to?(:no_xapian_reindex) && self.no_xapian_reindex == true) + if respond_to?(:no_xapian_reindex) && no_xapian_reindex == true + return true + end xapian_mark_needs_index end def xapian_create_job(action, model, model_id) begin - ActiveRecord::Base.transaction(:requires_new => true) do + ActiveRecord::Base.transaction(requires_new: true) do ActsAsXapianJob. where([ "model = ? and model_id = ?", model, model_id]). delete_all xapian_before_create_job_hook(action, model, model_id) - ActsAsXapianJob.create!(:model => model, - :model_id => model_id, - :action => action) + ActsAsXapianJob.create!(model: model, + model_id: model_id, + action: action) end rescue ActiveRecord::RecordNotUnique => e # Given the error handling in ActsAsXapian::update_index, we can just fail silently if # another process has inserted an acts_as_xapian_jobs record for this model. - raise unless (e.message =~ /duplicate key value violates unique constraint "index_acts_as_xapian_jobs_on_model_and_model_id"/) + unless e.message =~ /duplicate key value violates unique constraint "index_acts_as_xapian_jobs_on_model_and_model_id"/ + raise + end end end @@ -1127,9 +1157,7 @@ module ActsMethods # See top of this file for docs def acts_as_xapian(options) # Give error only on queries if bindings not available - if not ActsAsXapian.bindings_available - return - end + return unless ActsAsXapian.bindings_available include InstanceMethods diff --git a/lib/acts_as_xapian/tasks/xapian.rake b/lib/acts_as_xapian/tasks/xapian.rake index fee2ccf49d..da755e36ab 100644 --- a/lib/acts_as_xapian/tasks/xapian.rake +++ b/lib/acts_as_xapian/tasks/xapian.rake @@ -8,7 +8,7 @@ namespace :xapian do # after each model that is updated. This is safer, but slower. Specify # "verbose=true" to print model name as it is run. desc 'Updates Xapian search index with changes to models since last call' - task :update_index => :environment do + task update_index: :environment do ActsAsXapian.update_index(ENV['flush'], ENV['verbose']) end @@ -27,21 +27,23 @@ namespace :xapian do # index the two terms I and V (and "terms=false" will index none, # and "terms=true", the default, will index all) desc 'Completely rebuilds Xapian search index (must specify all models)' - task :destroy_and_rebuild_index => :environment do + task destroy_and_rebuild_index: :environment do def coerce_arg(arg, default) if arg == "false" - return false + false elsif arg == "true" - return true + true elsif arg.nil? - return default + default else - return arg + arg end end - raise "specify ALL your models with models=\"ModelName1 ModelName2\" as parameter" if ENV['models'].nil? + if ENV['models'].nil? + raise "specify ALL your models with models=\"ModelName1 ModelName2\" as parameter" + end ActsAsXapian.destroy_and_rebuild_index( - ENV['models'].split(" ").map { |m| m.constantize }, + ENV['models'].split(" ").map(&:constantize), coerce_arg(ENV['verbose'], false), coerce_arg(ENV['terms'], true), coerce_arg(ENV['values'], true), @@ -51,14 +53,16 @@ namespace :xapian do # Parameters - are models, query, offset, limit, sort_by_prefix, # collapse_by_prefix desc 'Run a query, return YAML of results' - task :query => :environment do - raise "specify models=\"ModelName1 ModelName2\" as parameter" if ENV['models'].nil? + task query: :environment do + if ENV['models'].nil? + raise "specify models=\"ModelName1 ModelName2\" as parameter" + end raise "specify query=\"your terms\" as parameter" if ENV['query'].nil? - s = ActsAsXapian::Search.new(ENV['models'].split(" ").map { |m| m.constantize }, + s = ActsAsXapian::Search.new(ENV['models'].split(" ").map(&:constantize), ENV['query'], - :offset => (ENV['offset'] || 0), :limit => (ENV['limit'] || 10), - :sort_by_prefix => (ENV['sort_by_prefix'] || nil), - :collapse_by_prefix => (ENV['collapse_by_prefix'] || nil) + offset: (ENV['offset'] || 0), limit: (ENV['limit'] || 10), + sort_by_prefix: (ENV['sort_by_prefix'] || nil), + collapse_by_prefix: (ENV['collapse_by_prefix'] || nil) ) STDOUT.puts(s.results.to_yaml) end diff --git a/lib/alaveteli_external_command.rb b/lib/alaveteli_external_command.rb index 3363d8cd6c..1dd1e1b9c1 100644 --- a/lib/alaveteli_external_command.rb +++ b/lib/alaveteli_external_command.rb @@ -36,9 +36,7 @@ def run(*args) # TODO: calling code should be able to specify error stream - may want to log it or # otherwise act upon it. opts = {} - if !args.empty? && args.last.is_a?(Hash) - opts = args.last - end + opts = args.last if !args.empty? && args.last.is_a?(Hash) program_path = find_program! xc = ExternalCommand.new(program_path, *command_args, *args) @@ -57,20 +55,18 @@ def run(*args) $stderr.puts(%Q[External Command: "#{program_name} #{args.join(' ')}" exited abnormally]) end $stderr.print(xc.err) - return nil + nil elsif xc.status != 0 # Error $stderr.puts(%Q[External Command: Error from command "#{program_name} #{args.join(' ')}":]) $stderr.print(xc.err) - return nil + nil + elsif opts.key? :append_to + opts[:append_to] << "\n\n" else - if opts.has_key? :append_to - opts[:append_to] << "\n\n" - else - return xc.out - end + xc.out end end diff --git a/lib/alaveteli_file_types.rb b/lib/alaveteli_file_types.rb index 7442702549..717d726295 100644 --- a/lib/alaveteli_file_types.rb +++ b/lib/alaveteli_file_types.rb @@ -31,16 +31,14 @@ class AlaveteliFileTypes class << self def all_extensions - return FileExtensionToMimeType.keys + FileExtensionToMimeType.keys end # Given file name and its content, return most likely type def filename_and_content_to_mimetype(filename, content) # Try filename ret = filename_to_mimetype(filename) - if !ret.nil? - return ret - end + return ret unless ret.nil? # Otherwise look inside the file to work out the type. # Mahoro is a Ruby binding for libmagic. @@ -49,43 +47,35 @@ def filename_and_content_to_mimetype(filename, content) mahoro_type.strip! # TODO: we shouldn't have to check empty? here, but Mahoro sometimes returns a blank line :( # e.g. for InfoRequestEvent 17930 - if mahoro_type.nil? || mahoro_type.empty? - return nil - end + return nil if mahoro_type.nil? || mahoro_type.empty? # text/plain types sometimes come with a charset mahoro_type.match(/^(.*);/) - if $1 - mahoro_type = $1 - end + mahoro_type = $1 if $1 # see if looks like a content type, or has something in it that does # and return that # mahoro returns junk "\012- application/msword" as mime type. mahoro_type.match(/([a-z0-9.-]+\/[a-z0-9.-]+)/) - if $1 - return $1 - end + return $1 if $1 # otherwise we got junk back from mahoro - return nil + nil end def filename_to_mimetype(filename) - if !filename - return nil - end + return nil unless filename if filename.match(/\.([^.]+)$/i) lext = $1.downcase if FileExtensionToMimeType.include?(lext) return FileExtensionToMimeType[lext] end end - return nil + nil end def mimetype_to_extension(mimetype) if FileExtensionToMimeTypeRev.include?(mimetype) return FileExtensionToMimeTypeRev[mimetype] end - return nil + nil end end end diff --git a/lib/alaveteli_geoip.rb b/lib/alaveteli_geoip.rb index 62d34f858b..bcb084e9f7 100644 --- a/lib/alaveteli_geoip.rb +++ b/lib/alaveteli_geoip.rb @@ -21,11 +21,11 @@ def self.instance end def initialize(database = nil) - database = AlaveteliConfiguration::geoip_database unless database + database = AlaveteliConfiguration.geoip_database unless database if database.present? && File.file?(database) @geoip = MaxMind::DB.new(database, mode: MaxMind::DB::MODE_MEMORY) end - @current_code = AlaveteliConfiguration::iso_country_code + @current_code = AlaveteliConfiguration.iso_country_code end # Public: Return the country code of the country indicated by diff --git a/lib/alaveteli_gettext/fuzzy_cleaner.rb b/lib/alaveteli_gettext/fuzzy_cleaner.rb index 59071cece1..34ecebbf6f 100644 --- a/lib/alaveteli_gettext/fuzzy_cleaner.rb +++ b/lib/alaveteli_gettext/fuzzy_cleaner.rb @@ -14,9 +14,7 @@ def clean_po(input) end # multiline msgstr if /^msgstr ""/.match(lines[index+1]) - while /^".+"/.match(lines[index+2]) - lines.delete_at(index+2) - end + lines.delete_at(index+2) while /^".+"/.match(lines[index+2]) lines.delete_at(index-1) end # plural msgstr diff --git a/lib/alaveteli_mail_poller.rb b/lib/alaveteli_mail_poller.rb index dc7b0cb64d..b7e3b2462f 100644 --- a/lib/alaveteli_mail_poller.rb +++ b/lib/alaveteli_mail_poller.rb @@ -23,7 +23,7 @@ def poll_for_incoming start do |pop3| pop3.each_mail do |popmail| received = get_mail(popmail) - found_mail = found_mail || received + found_mail ||= received end end found_mail @@ -35,9 +35,9 @@ def self.poll_for_incoming_loop if AlaveteliConfiguration.production_mailer_retriever_method == 'pop' poller = new Rails.logger.info "Starting #{ poller } polling loop" - while true + loop do sleep_seconds = 1 - while !poller.poll_for_incoming + until poller.poll_for_incoming Rails.logger.debug "#{ poller } sleeping for #{ sleep_seconds }" sleep sleep_seconds sleep_seconds *= 2 @@ -67,7 +67,7 @@ def get_mail(popmail) if send_exception_notifications? ExceptionNotifier.notify_exception( error, - :data => { mail: raw_email, + data: { mail: raw_email, unique_id: unique_id } ) end @@ -102,10 +102,10 @@ def retrieve?(unique_id) !failed?(unique_id) || retry?(unique_id) end - def start(&block) + def start() # Start a POP3 session and ensure that it will be closed in any case. unless block_given? - raise ArgumentError.new("AlaveteliMailPoller#start takes a block") + raise ArgumentError, "AlaveteliMailPoller#start takes a block" end pop3.enable_ssl(OpenSSL::SSL::VERIFY_NONE) if settings[:enable_ssl] @@ -113,13 +113,9 @@ def start(&block) yield pop3 rescue StandardError => error - if send_exception_notifications? - ExceptionNotifier.notify_exception(error) - end + ExceptionNotifier.notify_exception(error) if send_exception_notifications? ensure - if defined?(pop3) && pop3 && pop3.started? - pop3.finish - end + pop3.finish if defined?(pop3) && pop3 && pop3.started? end def default_pop3 diff --git a/lib/alaveteli_pro/metrics_report.rb b/lib/alaveteli_pro/metrics_report.rb index 40546dd5d5..77c755a6af 100644 --- a/lib/alaveteli_pro/metrics_report.rb +++ b/lib/alaveteli_pro/metrics_report.rb @@ -120,20 +120,18 @@ def new_stripe_users count = 0 sub_ids = [] stripe_plans.each do |plan_id| - begin - Stripe::Subscription.list( - 'created[gte]': report_start.to_i, - 'created[lte]': report_end.to_i, - plan: plan_id - ).auto_paging_each do |item| - if item.plan.id == plan_id - count += 1 - sub_ids << item.id - end + Stripe::Subscription.list( + 'created[gte]': report_start.to_i, + 'created[lte]': report_end.to_i, + plan: plan_id + ).auto_paging_each do |item| + if item.plan.id == plan_id + count += 1 + sub_ids << item.id end - rescue Stripe::InvalidRequestError - # tried to fetch a plan that's not set up end + rescue Stripe::InvalidRequestError + # tried to fetch a plan that's not set up end { new_and_returning_users: { count: count, subs: sub_ids } } end diff --git a/lib/alaveteli_rate_limiter/ip_rate_limiter.rb b/lib/alaveteli_rate_limiter/ip_rate_limiter.rb index b11d5a083e..8be4cba95f 100644 --- a/lib/alaveteli_rate_limiter/ip_rate_limiter.rb +++ b/lib/alaveteli_rate_limiter/ip_rate_limiter.rb @@ -26,7 +26,7 @@ def initialize(rule, opts = {}) @rule = find_rule(rule) path = Pathname.new(Rails.root + "tmp/#{@rule.name}_ip_rate_limiter.pstore") - @backend = opts[:backend] || Backends::PStoreDatabase.new(:path => path) + @backend = opts[:backend] || Backends::PStoreDatabase.new(path: path) @whitelist = opts[:whitelist] || self.class.defaults.whitelist end @@ -61,7 +61,7 @@ def find_rule(rule) case rule when Symbol rules = self.class.defaults.event_rules.fetch(rule) - Rule.from_hash(rules.merge(:name => rule)) + Rule.from_hash(rules.merge(name: rule)) when Rule rule else diff --git a/lib/alaveteli_rate_limiter/ip_rate_limiter/defaults.rb b/lib/alaveteli_rate_limiter/ip_rate_limiter/defaults.rb index 6d5856f334..1cbe94060e 100644 --- a/lib/alaveteli_rate_limiter/ip_rate_limiter/defaults.rb +++ b/lib/alaveteli_rate_limiter/ip_rate_limiter/defaults.rb @@ -3,9 +3,9 @@ module AlaveteliRateLimiter class IPRateLimiter class Defaults EVENT_RULES = { - :signup => { :count => 3, :window => { :value => 1, :unit => :hour } }, - :request => { :count => 3, :window => { :value => 1, :unit => :hour } }, - :comment => { :count => 20, :window => { :value => 1, :unit => :hour } } + signup: { count: 3, window: { value: 1, unit: :hour } }, + request: { count: 3, window: { value: 1, unit: :hour } }, + comment: { count: 20, window: { value: 1, unit: :hour } } } attr_accessor :whitelist diff --git a/lib/alaveteli_text_masker.rb b/lib/alaveteli_text_masker.rb index e2c827a3c4..a0dd232daf 100644 --- a/lib/alaveteli_text_masker.rb +++ b/lib/alaveteli_text_masker.rb @@ -1,3 +1,5 @@ +require 'tempfile' + module AlaveteliTextMasker include ConfigHelper @@ -47,11 +49,23 @@ def apply_masks(text, content_type, options = {}) private def uncompress_pdf(text) - AlaveteliExternalCommand.run("pdftk", "-", "output", "-", "uncompress", :stdin_string => text) + temp = Tempfile.new('pdftk', './tmp', encoding: 'ascii-8bit') + temp.write(text) + temp.close + + AlaveteliExternalCommand.run( + "pdftk", temp.path, "output", "-", "uncompress" + ) + ensure + temp.unlink end def compress_pdf(text) - if AlaveteliConfiguration::use_ghostscript_compression + temp = Tempfile.new('pdftk', './tmp', encoding: 'ascii-8bit') + temp.write(text) + temp.close + + if AlaveteliConfiguration.use_ghostscript_compression command = ["gs", "-sDEVICE=pdfwrite", "-dCompatibilityLevel=1.4", @@ -60,11 +74,13 @@ def compress_pdf(text) "-dQUIET", "-dBATCH", "-sOutputFile=-", - "-"] + temp.path] else - command = ["pdftk", "-", "output", "-", "compress"] + command = ["pdftk", temp.path, "output", "-", "compress"] end - AlaveteliExternalCommand.run(*(command + [ :stdin_string => text ])) + AlaveteliExternalCommand.run(*command) + ensure + temp.unlink end def apply_pdf_masks(text, options = {}) @@ -131,7 +147,7 @@ def apply_binary_masks(text, options = {}) # Replace censor items censor_rules = options[:censor_rules] || [] - text = censor_rules.reduce(text) { |text, rule| rule.apply_to_binary(text) } + text = censor_rules.reduce(text) { |t, rule| rule.apply_to_binary(t) } raise "internal error in apply_binary_masks" if text.bytesize != orig_size text @@ -157,7 +173,7 @@ def apply_text_masks(text, options = {}) memo.gsub(mask[:to_replace], mask[:replacement]) end - censor_rules.reduce(text) { |text, rule| rule.apply_to_text(text) } + censor_rules.reduce(text) { |t, rule| rule.apply_to_text(t) } end end diff --git a/lib/attachment_to_html.rb b/lib/attachment_to_html.rb index 34164e9bdb..928eb56aaa 100644 --- a/lib/attachment_to_html.rb +++ b/lib/attachment_to_html.rb @@ -17,7 +17,9 @@ def to_html(attachment, opts = {}) end view = View.new(adapter) - view.wrapper = 'wrapper_google_embed' if adapter.is_a?(Adapters::GoogleDocsViewer) + if adapter.is_a?(Adapters::GoogleDocsViewer) + view.wrapper = 'wrapper_google_embed' + end view.render do opts.fetch(:content_for, []).each do |k,v| diff --git a/lib/attachment_to_html/adapter.rb b/lib/attachment_to_html/adapter.rb index 8da1a078bd..51ce96d7e3 100644 --- a/lib/attachment_to_html/adapter.rb +++ b/lib/attachment_to_html/adapter.rb @@ -7,7 +7,7 @@ class Adapter # attachment - the FoiAttachment to convert to HTML # opts - a Hash of options (default: {}): # No options currently accepted - def initialize(attachment, opts = {}) + def initialize(attachment, _opts = {}) @attachment = attachment end @@ -45,7 +45,7 @@ def contains_images? end def create_tempfile(text) - tempfile = Tempfile.new('foiextract', '.', :encoding => text.encoding) + tempfile = Tempfile.new('foiextract', '.', encoding: text.encoding) tempfile.print(text) tempfile.flush tempfile diff --git a/lib/attachment_to_html/adapters/pdf.rb b/lib/attachment_to_html/adapters/pdf.rb index 76b8fd0d74..5787accf00 100644 --- a/lib/attachment_to_html/adapters/pdf.rb +++ b/lib/attachment_to_html/adapters/pdf.rb @@ -57,8 +57,8 @@ def convert "-enc", "UTF-8", "-noframes", "./#{File.basename(tempfile.path)}", - :timeout => 30, - :binary_output => false) + timeout: 30, + binary_output: false) cleanup_tempfile(tempfile) html diff --git a/lib/attachment_to_html/adapters/rtf.rb b/lib/attachment_to_html/adapters/rtf.rb index 0657133b3b..9ed0ff6f1c 100644 --- a/lib/attachment_to_html/adapters/rtf.rb +++ b/lib/attachment_to_html/adapters/rtf.rb @@ -39,7 +39,7 @@ def convert tempfile = create_tempfile(text) html = AlaveteliExternalCommand.run("unrtf", "--html", - tempfile.path, :timeout => 120 + tempfile.path, timeout: 120 ) cleanup_tempfile(tempfile) @@ -55,9 +55,7 @@ def sanitize_converted(html) invalid = %Q() valid = %Q(") - if html.include?(invalid) - html.sub!(invalid, valid) - end + html.sub!(invalid, valid) if html.include?(invalid) html end end diff --git a/lib/attachment_to_html/view.rb b/lib/attachment_to_html/view.rb index 1785e605aa..7bc4a64db0 100644 --- a/lib/attachment_to_html/view.rb +++ b/lib/attachment_to_html/view.rb @@ -5,8 +5,8 @@ def self.template @template || "#{ File.dirname(__FILE__) }/template.html.erb" end - def self.template=(path) - @template = path + class << self + attr_writer :template end attr_accessor :title, :body, :template, :wrapper diff --git a/lib/confidence_intervals.rb b/lib/confidence_intervals.rb index b482897c0c..5ddfa20cde 100644 --- a/lib/confidence_intervals.rb +++ b/lib/confidence_intervals.rb @@ -19,13 +19,11 @@ require 'statistics2' def ci_bounds(successes, total, power) - if total == 0 - raise RuntimeError, "Can't calculate the CI for 0 observations" - end + raise "Can't calculate the CI for 0 observations" if total == 0 z = Statistics2.pnormaldist(1 - power/2) phat = successes.to_f/total offset = z*Math.sqrt((phat*(1 - phat) + z*z/(4*total))/total) denominator = 1 + z*z/total - return [(phat + z*z/(2*total) - offset)/denominator, - (phat + z*z/(2*total) + offset)/denominator] + [(phat + z*z/(2*total) - offset)/denominator, + (phat + z*z/(2*total) + offset)/denominator] end diff --git a/lib/configuration.rb b/lib/configuration.rb index fa2c40bb68..14532ef8fc 100644 --- a/lib/configuration.rb +++ b/lib/configuration.rb @@ -13,7 +13,7 @@ # TODO: Make this return different values depending on the current rails environment module AlaveteliConfiguration - if !const_defined?(:DEFAULTS) + unless const_defined?(:DEFAULTS) # rubocop:disable Layout/LineLength DEFAULTS = { @@ -21,6 +21,7 @@ module AlaveteliConfiguration ADMIN_USERNAME: '', AUTHORITY_MUST_RESPOND: true, AVAILABLE_LOCALES: 'en', + BACKGROUND_JOBS: 'server', BLACKHOLE_PREFIX: 'do-not-reply-to-this-address', BLOCK_RATE_LIMITED_IPS: false, BLOCK_RESTRICTED_COUNTRY_IPS: false, @@ -29,6 +30,7 @@ module AlaveteliConfiguration BLOCK_SPAM_REQUESTS: false, BLOCK_SPAM_SIGNINS: false, BLOCK_SPAM_SIGNUPS: false, + BLOCK_SPAM_USER_MESSAGES: false, BLOG_FEED: '', BLOG_TIMEOUT: 60, CACHE_FRAGMENTS: true, @@ -134,9 +136,15 @@ module AlaveteliConfiguration # rubocop:enable Layout/LineLength end + def self.background_jobs + value = MySociety::Config.get('BACKGROUND_JOBS', DEFAULTS[:BACKGROUND_JOBS]) + return value if %w[inline server].include?(value) + raise 'Unknown value for BACKGROUND_JOBS. Please check config/general.yml' + end + def self.method_missing(name) key = name.to_s.upcase - if DEFAULTS.has_key?(key.to_sym) + if DEFAULTS.key?(key.to_sym) MySociety::Config.get(key, DEFAULTS[key.to_sym]) else super diff --git a/lib/data_export.rb b/lib/data_export.rb index dda50e6bfe..71eee643ed 100644 --- a/lib/data_export.rb +++ b/lib/data_export.rb @@ -58,7 +58,7 @@ def self.detects_gender(name) end def self.gender_lambda - lambda { |x| detects_gender(x.name) } + ->(x) { detects_gender(x.name) } end # Remove all instances of user's name (if there is a user), otherwise @@ -78,7 +78,7 @@ def self.case_insensitive_user_censor(text, user) # Returns a lambda to pass to export function that censors x.property def self.name_censor_lambda(property) - lambda do |x| + ->(x) do if x.respond_to?(:info_request) case_insensitive_user_censor(x.send(property), x.info_request.user) else @@ -167,8 +167,6 @@ def self.is_required?(model_name, to_run) to_run.include?(model_name) end - private - def self.handle_error(err, data) p "---" puts "Error processing data:" diff --git a/lib/database_collation.rb b/lib/database_collation.rb index f0cc6a8ac9..c72535d085 100644 --- a/lib/database_collation.rb +++ b/lib/database_collation.rb @@ -3,7 +3,7 @@ # a given language. Prefer the class method .supports? rather than creating a # new instance. class DatabaseCollation - MINIMUM_POSTGRESQL_VERSION = 90112 + MINIMUM_POSTGRESQL_VERSION = 90112 # rubocop:disable Style/NumericLiterals attr_reader :connection diff --git a/lib/generators/acts_as_xapian/templates/migration.rb b/lib/generators/acts_as_xapian/templates/migration.rb index 84a9dd766f..436aa9efc0 100644 --- a/lib/generators/acts_as_xapian/templates/migration.rb +++ b/lib/generators/acts_as_xapian/templates/migration.rb @@ -1,11 +1,11 @@ class CreateActsAsXapian < ActiveRecord::Migration def self.up create_table :acts_as_xapian_jobs do |t| - t.column :model, :string, :null => false - t.column :model_id, :integer, :null => false - t.column :action, :string, :null => false + t.column :model, :string, null: false + t.column :model_id, :integer, null: false + t.column :action, :string, null: false end - add_index :acts_as_xapian_jobs, [:model, :model_id], :unique => true + add_index :acts_as_xapian_jobs, [:model, :model_id], unique: true end def self.down drop_table :acts_as_xapian_jobs diff --git a/lib/graphs.rb b/lib/graphs.rb index f6a37b4f6e..3ffea5846f 100644 --- a/lib/graphs.rb +++ b/lib/graphs.rb @@ -6,19 +6,19 @@ module Graphs # as provided by our basic gnuplot configuration, do not rely on them # if you have altered the gnuplot install COLOURS = { - :darkblue => 8, - :lightblue => 3, - :yellow => 9, - :red => 6, - :lightgreen => 2, - :darkgreen => 10, - :cyan => 5, - :darkyellow => 7, - :mauve => 4, - :redbrown => 12, # previously "darky reddy brown" - :pink => 13, - :bluemauve => 11, - :limegreen => 14 + darkblue: 8, + lightblue: 3, + yellow: 9, + red: 6, + lightgreen: 2, + darkgreen: 10, + cyan: 5, + darkyellow: 7, + mauve: 4, + redbrown: 12, # previously "darky reddy brown" + pink: 13, + bluemauve: 11, + limegreen: 14 }.freeze COLORS = COLOURS @@ -46,7 +46,7 @@ def select_as_columns(sql) # for outputting the graph # returns the resulting Gnuplot::DataSet def create_dataset(data, options) - default = {:using => "1:2"} #in most cases, we just want the first 2 columns + default = {using: "1:2"} #in most cases, we just want the first 2 columns options = default.merge(options) Gnuplot::DataSet.new(data) do |ds| options.keys.each do |option| diff --git a/lib/health_checks.rb b/lib/health_checks.rb index 0d9be6921c..5d21cc1dc6 100644 --- a/lib/health_checks.rb +++ b/lib/health_checks.rb @@ -25,7 +25,7 @@ def each(&block) end def ok? - all.all? { |check| check.ok? } + all.all?(&:ok?) end private diff --git a/lib/i18n_fixes.rb b/lib/i18n_fixes.rb index be667a043f..daf18fbe2f 100644 --- a/lib/i18n_fixes.rb +++ b/lib/i18n_fixes.rb @@ -28,7 +28,8 @@ def gettext_interpolate(string, values) # $1, $2 don't work with SafeBuffer so casting to string as workaround safe = string.html_safe? string = string.to_str.gsub(MATCH) do - pattern, key = $1, $1.to_sym + pattern = $1 + key = $1.to_sym if !values.include?(key) raise I18n::MissingInterpolationArgument.new(pattern, string, values) @@ -51,7 +52,7 @@ def gettext_interpolate(string, values) module GettextI18nRails class Backend def available_locales - FastGettext.available_locales.map { |l| l.to_sym } || [] + FastGettext.available_locales.map(&:to_sym) || [] end end end diff --git a/lib/languages.rb b/lib/languages.rb index 99d852948d..1b5dbd32f9 100644 --- a/lib/languages.rb +++ b/lib/languages.rb @@ -190,6 +190,6 @@ def self.get_language_name(locale) locale = locale.to_s.sub("_", "-") # normalize return language_names[locale] if language_names[locale] main_part = I18n::Locale::Tag::Simple.tag(locale).subtags[0] - return language_names[main_part] + language_names[main_part] end end diff --git a/lib/mail_handler.rb b/lib/mail_handler.rb index 9a12ee2153..7694f2f12a 100644 --- a/lib/mail_handler.rb +++ b/lib/mail_handler.rb @@ -1,4 +1,5 @@ # Handles the parsing of email +require 'English' require 'tmpdir' module MailHandler @@ -20,38 +21,34 @@ def tnef_attachments(content) IO.popen("tnef -K -C #{dir} 2> /dev/null", "wb") do |f| f.write(content) f.close - if $?.signaled? - raise IOError, "tnef exited with signal #{$?.termsig}" - end - if $?.exited? && $?.exitstatus != 0 - raise TNEFParsingError, "tnef exited with status #{$?.exitstatus}" + raise IOError, "tnef exited with signal #{$CHILD_STATUS.termsig}" if $CHILD_STATUS.signaled? + if $CHILD_STATUS.exited? && $CHILD_STATUS.exitstatus != 0 + raise TNEFParsingError, "tnef exited with status #{$CHILD_STATUS.exitstatus}" end end found = 0 Dir.new(dir).sort.each do |file| # sort for deterministic behaviour if file != "." && file != ".." file_content = File.open("#{dir}/#{file}", "rb").read - attachments << { :content => file_content, - :filename => file } + attachments << { content: file_content, + filename: file } found += 1 end end - if found == 0 - raise TNEFParsingError, "tnef produced no attachments" - end + raise TNEFParsingError, "tnef produced no attachments" if found == 0 end attachments end def normalise_content_type(content_type) # e.g. http://www.whatdotheyknow.com/request/93/response/250 - if content_type == 'application/excel' or content_type == 'application/msexcel' or content_type == 'application/x-ms-excel' + if (content_type == 'application/excel') || (content_type == 'application/msexcel') || (content_type == 'application/x-ms-excel') content_type = 'application/vnd.ms-excel' end - if content_type == 'application/mspowerpoint' or content_type == 'application/x-ms-powerpoint' + if (content_type == 'application/mspowerpoint') || (content_type == 'application/x-ms-powerpoint') content_type = 'application/vnd.ms-powerpoint' end - if content_type == 'application/msword' or content_type == 'application/x-ms-word' + if (content_type == 'application/msword') || (content_type == 'application/x-ms-word') content_type = 'application/vnd.ms-word' end if content_type == 'application/x-zip-compressed' @@ -59,15 +56,15 @@ def normalise_content_type(content_type) end # e.g. http://www.whatdotheyknow.com/request/copy_of_current_swessex_scr_opt#incoming-9928 - if content_type == 'application/acrobat' or content_type == 'document/pdf' + if (content_type == 'application/acrobat') || (content_type == 'document/pdf') content_type = 'application/pdf' end - return content_type + content_type end def get_attachment_text_one_file(content_type, body, charset = 'utf-8') - # note re. charset: TMail always tries to convert email bodies + # NOTE: re. charset: TMail always tries to convert email bodies # to UTF8 by default, so normally it should already be that. text = '' # TODO: - tell all these command line tools to return utf-8 @@ -78,14 +75,14 @@ def get_attachment_text_one_file(content_type, body, charset = 'utf-8') tempfile.binmode tempfile.print body tempfile.flush - default_params = { :append_to => text, - :binary_output => false, - :timeout => 1200 } + default_params = { append_to: text, + binary_output: false, + timeout: 1200 } if content_type == 'application/vnd.ms-word' AlaveteliExternalCommand.run("wvText", tempfile.path, tempfile.path + ".txt", - { :memory_limit => 536870912, :timeout => 120 } ) + { memory_limit: 536_870_912, timeout: 120 } ) # Try catdoc if we get into trouble (e.g. for InfoRequestEvent 2701) - if not File.exist?(tempfile.path + ".txt") + if !File.exist?(tempfile.path + ".txt") AlaveteliExternalCommand.run("catdoc", tempfile.path, default_params) else text += File.read(tempfile.path + ".txt") + "\n\n" @@ -103,7 +100,7 @@ def get_attachment_text_one_file(content_type, body, charset = 'utf-8') "-dump-charset", "utf-8", "-force-html", "-dump", tempfile.path, - default_params.merge(:env => {"LANG" => "C"})) + default_params.merge(env: {"LANG" => "C"})) elsif content_type == 'application/vnd.ms-excel' # Bit crazy using /usr/bin/strings - but xls2csv, xlhtml and # py_xls2txt only extract text from cells, not from floating @@ -123,8 +120,8 @@ def get_attachment_text_one_file(content_type, body, charset = 'utf-8') "-c", tempfile.path, "word/document.xml", - {:binary_output => false}) - if !xml.nil? + {binary_output: false}) + unless xml.nil? doc = REXML::Document.new(xml) text += doc.each_element( './/text()' ) {}.join(" ") end @@ -135,18 +132,18 @@ def get_attachment_text_one_file(content_type, body, charset = 'utf-8') text += get_attachment_text_from_zip_file(zip_file) zip_file.close rescue - $stderr.puts("Error processing zip file: #{$!.inspect}") + $stderr.puts("Error processing zip file: #{$ERROR_INFO.inspect}") end end tempfile.close end - return text + text end def get_attachment_text_from_zip_file(zip_file) text = "" - for entry in zip_file + zip_file.each do |entry| if entry.file? filename = entry.to_s begin @@ -169,7 +166,7 @@ def get_attachment_text_from_zip_file(zip_file) text += get_attachment_text_one_file(content_type, body) end end - return text + text end # Turn instance methods into class methods diff --git a/lib/mail_handler/backends/mail_backend.rb b/lib/mail_handler/backends/mail_backend.rb index fd00e1eabf..8dc5e2336a 100644 --- a/lib/mail_handler/backends/mail_backend.rb +++ b/lib/mail_handler/backends/mail_backend.rb @@ -13,20 +13,20 @@ class Message # string as an ActiveSupport::Multibyte::Chars, whereas # previously TMail would return nil. - alias_method :old_to, :to - alias_method :old_cc, :cc + alias old_to to + alias old_cc cc def clean_addresses(old_method, val) - old_result = self.send(old_method, val) + old_result = send(old_method, val) old_result.class == Mail::AddressContainer ? old_result : nil end def to(val = nil) - self.clean_addresses :old_to, val + clean_addresses :old_to, val end def cc(val = nil) - self.clean_addresses :old_cc, val + clean_addresses :old_cc, val end end @@ -66,9 +66,7 @@ def mail_from_outlook(content) def get_subject(mail) subject = mail.subject - if subject - convert_string_to_utf8(subject).string - end + convert_string_to_utf8(subject).string if subject end def get_within_rfc822_subject(leaf) @@ -105,12 +103,10 @@ def first_from(mail) begin mail[:from].addrs[0] mail[:from].decoded - return mail[:from].addrs[0] + mail[:from].addrs[0] rescue - return mail[:from].value + mail[:from].value end - else - nil end end @@ -119,12 +115,10 @@ def get_from_address(mail) first_from = first_from(mail) if first_from if first_from.is_a?(String) - return nil + nil else - return first_from.address + first_from.address end - else - return nil end end @@ -133,12 +127,10 @@ def get_from_name(mail) first_from = first_from(mail) if first_from if first_from.is_a?(String) - return nil + nil else - return (first_from.display_name || nil) + (first_from.display_name || nil) end - else - return nil end end @@ -155,7 +147,7 @@ def get_all_addresses(mail, include_invalid: false) def empty_return_path?(mail) return false if mail['return-path'].nil? return true if mail['return-path'].value.blank? - return false + false end def get_auto_submitted(mail) @@ -177,7 +169,7 @@ def is_outlook?(part) if filename && AlaveteliFileTypes.filename_to_mimetype(filename) == 'application/vnd.ms-outlook' return true end - return false + false end # Convert a mail part which is an attached mail in one of @@ -252,17 +244,13 @@ def expand_and_normalize_parts(part, parent_mail) part_body = get_part_body(part) calc_mime = AlaveteliFileTypes.filename_and_content_to_mimetype(part_filename, part_body) - if calc_mime - part.content_type = calc_mime - end + part.content_type = calc_mime if calc_mime end # Use standard content types for Word documents etc. part.content_type = normalise_content_type(get_content_type(part)) decode_attached_part(part, parent_mail) - if original_charset - part.charset = original_charset - end + part.charset = original_charset if original_charset end end @@ -272,28 +260,24 @@ def expand_and_normalize_parts(part, parent_mail) def count_parts(part, parent_mail) if part.multipart? part.parts.each { |p| count_parts(p, parent_mail) } + elsif part.rfc822_attachment + count_parts(part.rfc822_attachment, parent_mail) else - if part.rfc822_attachment - count_parts(part.rfc822_attachment, parent_mail) - else - parent_mail.count_parts_count += 1 - part.url_part_number = parent_mail.count_parts_count - end + parent_mail.count_parts_count += 1 + part.url_part_number = parent_mail.count_parts_count end parent_mail.count_first_uudecode_count = parent_mail.count_parts_count end # Choose the best part from alternatives def choose_best_alternative(mail) - if mail.parts.any?(&:multipart?) - return mail.parts.detect(&:multipart?) - end + return mail.parts.detect(&:multipart?) if mail.parts.any?(&:multipart?) if mail.html_part - return mail.html_part + mail.html_part elsif mail.text_part - return mail.text_part + mail.text_part else - return mail.parts.first + mail.parts.first end end @@ -306,7 +290,7 @@ def get_attachment_leaves(mail) leaves = _get_attachment_leaves_recursive(mail, nil, mail) mail.count_parts_count = 0 count_parts(mail, mail) - return leaves + leaves end # Recurse through a mail part, selecting the best part wherever there is @@ -314,7 +298,7 @@ def get_attachment_leaves(mail) def _get_attachment_leaves_recursive(part, within_rfc822_attachment, parent_mail) leaves_found = [] if part.multipart? - if part.parts.size == 0 + if part.parts.empty? # This is typically caused by a missing final # MIME boundary, in which case the text of the # message (including the opening MIME @@ -335,19 +319,17 @@ def _get_attachment_leaves_recursive(part, within_rfc822_attachment, parent_mail parent_mail) end end - else + elsif part.rfc822_attachment # Add all the parts of a decoded attached message - if part.rfc822_attachment - leaves_found += _get_attachment_leaves_recursive(part.rfc822_attachment, - part.rfc822_attachment, - parent_mail) - else - # Store leaf - part.within_rfc822_attachment = within_rfc822_attachment - leaves_found += [part] - end + leaves_found += _get_attachment_leaves_recursive(part.rfc822_attachment, + part.rfc822_attachment, + parent_mail) + else + # Store leaf + part.within_rfc822_attachment = within_rfc822_attachment + leaves_found += [part] end - return leaves_found + leaves_found end # Add selected useful headers from an attached message to its body @@ -357,9 +339,9 @@ def extract_attached_message_headers(leaf) # RFC822 message and it is text, if so add headers. if leaf.within_rfc822_attachment == leaf && get_content_type(leaf) == 'text/plain' headers = "" - [ 'Date', 'Subject', 'From', 'To', 'Cc' ].each do |header| - if header_value = get_header_string(header, leaf.within_rfc822_attachment) - if !header_value.blank? + %w[Date Subject From To Cc].each do |header| + if (header_value = get_header_string(header, leaf.within_rfc822_attachment)) + unless header_value.blank? headers = headers + header + ": " + header_value.to_s + "\n" end end @@ -382,24 +364,22 @@ def get_attachment_attributes(mail) body = extract_attached_message_headers(leaf) end - leaf_attributes = { :url_part_number => leaf.url_part_number, - :content_type => get_content_type(leaf), - :filename => get_part_file_name(leaf), - :charset => leaf.charset, - :within_rfc822_subject => within_rfc822_subject, - :body => body, - :hexdigest => Digest::MD5.hexdigest(body) } + leaf_attributes = { url_part_number: leaf.url_part_number, + content_type: get_content_type(leaf), + filename: get_part_file_name(leaf), + charset: leaf.charset, + within_rfc822_subject: within_rfc822_subject, + body: body, + hexdigest: Digest::MD5.hexdigest(body) } end end # Format def address_from_name_and_email(name, email) - if !MySociety::Validate.is_valid_email(email) + unless MySociety::Validate.is_valid_email(email) raise "invalid email " + email + " passed to address_from_name_and_email" end - if name.nil? - return Mail::Address.new(email.dup).to_s - end + return Mail::Address.new(email.dup).to_s if name.nil? address = Mail::Address.new address.display_name = name.dup address.address = email.dup diff --git a/lib/mail_handler/backends/mail_extensions.rb b/lib/mail_handler/backends/mail_extensions.rb index 452eaa895e..1e0a028ff3 100644 --- a/lib/mail_handler/backends/mail_extensions.rb +++ b/lib/mail_handler/backends/mail_extensions.rb @@ -1,6 +1,6 @@ require 'mail/message' require 'mail/part' -require 'mail/fields/common/parameter_hash' +require 'mail/fields/parameter_hash' module Mail class Message attr_accessor :url_part_number @@ -22,7 +22,7 @@ def encoded value = Mail::Encodings.param_encode(value) key_name = "#{key_name}*" end - %Q{#{key_name}=#{quote_token(value)}} + %Q{#{key_name}=#{Mail::Utilities.quote_token(value)}} end.join(";\r\n\s") end end diff --git a/lib/mail_handler/reply_handler.rb b/lib/mail_handler/reply_handler.rb index e9137bac51..9133437db2 100644 --- a/lib/mail_handler/reply_handler.rb +++ b/lib/mail_handler/reply_handler.rb @@ -8,7 +8,7 @@ def self.permanently_failed_addresses(message) # Check for Exim’s X-Failed-Recipients header failed_recipients = MailHandler.get_header_string("X-Failed-Recipients", message) - if !failed_recipients.nil? + unless failed_recipients.nil? # The X-Failed-Recipients header contains the email address that failed # Check for the words "This is a permanent error." in the body, to indicate # a permanent failure @@ -36,7 +36,7 @@ def self.permanently_failed_addresses(message) end end end - if !permanently_failed_recipients.empty? + unless permanently_failed_recipients.empty? return permanently_failed_recipients end end @@ -52,7 +52,7 @@ def self.permanently_failed_addresses(message) end end - return [] + [] end def self.is_oof?(message) @@ -64,40 +64,26 @@ def self.is_oof?(message) subject = MailHandler.get_header_string("Subject", message).downcase if MailHandler.empty_return_path?(message) - if subject.start_with? "out of office: " - return true - end - if subject.start_with? "automatic reply: " - return true - end + return true if subject.start_with? "out of office: " + return true if subject.start_with? "automatic reply: " end if MailHandler.get_header_string("Auto-Submitted", message) == "auto-generated" - if subject =~ /out of( the)? office/ - return true - end + return true if subject =~ /out of( the)? office/ end - if subject.start_with? "out of office autoreply:" - return true - end - if subject == "out of office" - return true - end - if subject == "out of office reply" - return true - end - if subject.end_with? "is out of the office" - return true - end - return false + return true if subject.start_with? "out of office autoreply:" + return true if subject == "out of office" + return true if subject == "out of office reply" + return true if subject.end_with? "is out of the office" + false end def self.forward_on(raw_message, message = nil) - forward_to = self.get_forward_to_address(message) + forward_to = get_forward_to_address(message) IO.popen(%Q(/usr/sbin/sendmail -i "#{forward_to}"), 'wb') do |f| - f.write(raw_message); - f.close; + f.write(raw_message) + f.close end end @@ -146,7 +132,7 @@ def self.load_rails end def self.record_bounce(email_address, bounce_message) - self.load_rails + load_rails User.record_bounce_for_email(email_address, bounce_message) end end diff --git a/lib/memory_profiler.rb b/lib/memory_profiler.rb index a8e0267368..bc01745edc 100644 --- a/lib/memory_profiler.rb +++ b/lib/memory_profiler.rb @@ -13,7 +13,7 @@ # strings `ls -1t *profiler_strings* | head --lines=1` |sort > a; strings `ls -1t *profiler_strings* | head --lines=2 | tail --lines=1` |sort > b; diff b a |less class MemoryProfiler - DEFAULTS = {:delay => 10, :string_debug => false} + DEFAULTS = {delay: 10, string_debug: false} def self.start(opt={}) opt = DEFAULTS.dup.merge(opt) @@ -35,9 +35,7 @@ def self.start(opt={}) ObjectSpace.each_object do |o| curr[o.class] += 1 #Marshal.dump(o).size rescue 1 - if opt[:string_debug] and o.class == String - curr_strings.push o - end + curr_strings.push o if opt[:string_debug] && (o.class == String) end if opt[:string_debug] @@ -50,12 +48,12 @@ def self.start(opt={}) end delta.clear - (curr.keys + delta.keys).uniq.each do |k,v| + (curr.keys + delta.keys).uniq.each do |k,_v| delta[k] = curr[k]-prev[k] end file.puts "Top 20" - delta.sort_by { |k,v| -v.abs }[0..19].sort_by { |k,v| -v }.each do |k,v| + delta.sort_by { |_k,v| -v.abs }[0..19].sort_by { |_k,v| -v }.each do |k,v| file.printf "%+5d: %s (%d)\n", v, k.name, curr[k] unless v == 0 end file.flush diff --git a/lib/no_constraint_disabling.rb b/lib/no_constraint_disabling.rb index 0503efd99b..f6e00cf179 100644 --- a/lib/no_constraint_disabling.rb +++ b/lib/no_constraint_disabling.rb @@ -52,7 +52,7 @@ def self.create_fixtures(fixtures_directory, fixture_set_names, class_names = {} update_all_loaded_fixtures fixtures_map - connection.transaction(:requires_new => true) do + connection.transaction(requires_new: true) do # Patch - replace this... # *** # fixture_sets.each do |fs| diff --git a/lib/normalize_string.rb b/lib/normalize_string.rb index 8e1effb669..a1e42ddda7 100644 --- a/lib/normalize_string.rb +++ b/lib/normalize_string.rb @@ -76,18 +76,16 @@ def convert_string_to_utf8_or_binary(s, suggested_character_encoding=nil) end def convert_string_to_utf8(s, suggested_character_encoding=nil) - begin - result = normalize_string_to_utf8 s, suggested_character_encoding - StringConversionResult.new(result, false) - rescue EncodingNormalizationError - result = scrub(s) - StringConversionResult.new(result, true) - end + result = normalize_string_to_utf8 s, suggested_character_encoding + StringConversionResult.new(result, false) +rescue EncodingNormalizationError + result = scrub(s) + StringConversionResult.new(result, true) end def scrub(string) string = string.force_encoding("utf-8") - string.valid_encoding? ? string : string.encode("utf-16le", :invalid => :replace, :replace => "").encode("utf-8") + string.valid_encoding? ? string : string.encode("utf-16le", invalid: :replace, replace: "").encode("utf-8") end def log_text_details(message, text) diff --git a/lib/public_body_csv.rb b/lib/public_body_csv.rb index faea44b6f9..15526ce9ad 100644 --- a/lib/public_body_csv.rb +++ b/lib/public_body_csv.rb @@ -67,7 +67,7 @@ def initialize(args = {}) end def <<(public_body) - rows << CSV.generate_line(collect_public_body_attributes(public_body), :row_sep => '') + rows << CSV.generate_line(collect_public_body_attributes(public_body), row_sep: '') end # TODO: Just use CSV.generate diff --git a/lib/quiet_opener.rb b/lib/quiet_opener.rb index 81abfe1eea..cdd146fd10 100644 --- a/lib/quiet_opener.rb +++ b/lib/quiet_opener.rb @@ -16,10 +16,10 @@ def quietly_try_to_open(url, timeout=60) if !AlaveteliConfiguration.exception_notifications_from.blank? && !AlaveteliConfiguration.exception_notifications_to.blank? && defined?(request) - ExceptionNotifier.notify_exception(e, :env => request.env) + ExceptionNotifier.notify_exception(e, env: request.env) end Rails.logger.warn(e.message) result = "" end - return result + result end diff --git a/lib/routing_filters.rb b/lib/routing_filters.rb index 75b30c5e36..8648fee425 100644 --- a/lib/routing_filters.rb +++ b/lib/routing_filters.rb @@ -1,11 +1,5 @@ module RoutingFilter class Conditionallyprependlocale < RoutingFilter::Locale - # We need to be able to override this class attribute so from Rails 4.0 - # onwards we're going to need write access. It looks as though we don't - # use the equivalent instance variables so we can opt out of creating - # accessors for them - cattr_accessor :locales, instance_accessor: false - # Override core Locale filter not to prepend locale path segment # when there's only one locale def prepend_locale?(locale) @@ -18,12 +12,19 @@ def prepend_locale?(locale) # internally and may look like `en-US`, whereas the former is # what FastGettext and other POSIX-based systems use, and will # look like `en_US` - def around_generate(*args, &block) - params = args.extract_options! # this is because we might get a call like forum_topics_path(forum, topic, :locale => :en) - - locale = params.delete(:locale) # extract the passed :locale option - locale = AlaveteliLocalization.locale if locale.nil? # default to underscore locale when locale is nil (could also be false) - locale = nil unless valid_locale?(locale) # reset to no locale when locale is not valid + def around_generate(*args) + # this is because we might get a call like forum_topics_path(forum, topic, :locale => :en) + params = args.extract_options! + # extract the passed :locale option + locale = params.delete(:locale) + if locale.nil? + # default to underscore locale when locale is nil (could also be false) + locale = AlaveteliLocalization.locale + end + unless valid_locale?(locale) + # reset to no locale when locale is not valid + locale = nil + end args << params yield.tap do |result| @@ -40,19 +41,14 @@ def default_locale?(locale) # Reset the locale pattern when the locales are set. class << self def locales_pattern - super - end - - def locales=(locales) - @@locales_pattern = nil - @@locales = locales.map(&:to_sym) + %r(^/(#{locales.map { |l| Regexp.escape(l.to_s) }.join('|')})(?=/|$)) end end end end ActionDispatch::Routing::RouteSet::NamedRouteCollection::UrlHelper.class_eval do - def self.optimize_helper?(route) + def self.optimize_helper?(_route) false end end diff --git a/lib/stripe_mock_patch.rb b/lib/stripe_mock_patch.rb index d2144222ce..c8b13b8043 100644 --- a/lib/stripe_mock_patch.rb +++ b/lib/stripe_mock_patch.rb @@ -14,7 +14,7 @@ module RequestHandlers::Subscriptions # set_custom_status_from_metatdata method to set the status # from the stored info in the subscription metatdata when the # subscription is retrieved (including calling #refresh) - def retrieve_subscription(route, method_url, params, headers) + def retrieve_subscription(route, method_url, _params, _headers) route =~ method_url set_custom_status_from_metadata(subscriptions[$1]) if subscriptions[$1] @@ -25,7 +25,7 @@ def retrieve_subscription(route, method_url, params, headers) # set_custom_status_from_metatdata method to set the status # from the stored info in the subscription metatdata when multiple # subscriptions are retrieved (including from `Subscription::List`) - def retrieve_subscriptions(route, method_url, params, headers) + def retrieve_subscriptions(route, method_url, params, _headers) route =~ method_url subscriptions.values.each do |subscription| diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index c177e5ff81..636add9692 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -1,6 +1,6 @@ namespace :assets do desc 'Symlink non-digest asset paths to the most recent digest versions' - task :link_non_digest => :environment do + task link_non_digest: :environment do assets = Dir.glob(File.join(Rails.root, 'public/assets/**/*')) regex = /(-{1}[a-z0-9]{32}*\.{1}){1}/ assets.each do |file| diff --git a/lib/tasks/cleanup.rake b/lib/tasks/cleanup.rake index 0e1ad91044..b62367d4fb 100644 --- a/lib/tasks/cleanup.rake +++ b/lib/tasks/cleanup.rake @@ -1,24 +1,20 @@ namespace :cleanup do desc 'Clean up all message redelivery and destroy actions from the holding pen to make admin actions there faster' - task :holding_pen => :environment do + task holding_pen: :environment do dryrun = ENV['DRYRUN'] != '0' if ENV['DRYRUN'] - if dryrun - $stderr.puts "This is a dryrun - nothing will be deleted" - end + $stderr.puts "This is a dryrun - nothing will be deleted" if dryrun holding_pen = InfoRequest.holding_pen_request holding_pen.info_request_events. - where(:event_type => %w(redeliver_incoming destroy_incoming)). + where(event_type: %w(redeliver_incoming destroy_incoming)). find_each do |event| - $stderr.puts event.inspect if verbose or dryrun - if not dryrun - event.destroy - end + $stderr.puts event.inspect if verbose || dryrun + event.destroy unless dryrun end end desc 'Interactively cleanup spam user users' - task :spam_users => :environment do + task spam_users: :environment do spam_scorer = UserSpamScorer.new results = {} @@ -37,18 +33,19 @@ namespace :cleanup do user.with_lock do display_user(user, spam_score) - begin + loop do puts "Is this a spam account? [(Y)es/(n)o/(s)kip]" input = $stdin.gets.strip - end until %w(Y n s).include?(input) + break if %w(Y n s).include?(input) + end case input when 'Y' puts "Banning #{ user.id }\n\n" - user.update!(:ban_text => 'Banned for spamming') + user.update!(ban_text: 'Banned for spamming') when 'n' puts "Marking #{ user.id } as genuine\n\n" - user.update!(:confirmed_not_spam => true) + user.update!(confirmed_not_spam: true) when 's' puts "Skipping #{ user.id }\n\n" end @@ -57,28 +54,26 @@ namespace :cleanup do end desc 'Reindex banned users' - task :reindex_banned_users => :environment do - User.banned.find_each do |user| - user.xapian_mark_needs_index - end + task reindex_banned_users: :environment do + User.banned.find_each(&:xapian_mark_needs_index) end desc 'Export of last 2 days of requests to search for spam' - task :spam_requests => :environment do + task spam_requests: :environment do str = CSV.generate do |csv| # Make headers - csv << [ - 'info_request_id', - 'info_request_title', - 'user_id', - 'public_body_id', - 'public_body_name', - 'public_body_request_email', - 'created_at', + csv << %w[ + info_request_id + info_request_title + user_id + public_body_id + public_body_name + public_body_request_email + created_at ] # Add rows - InfoRequest.where(:created_at => [2.days.ago..Time.zone.now]).find_each do |request| + InfoRequest.where(created_at: [2.days.ago..Time.zone.now]).find_each do |request| csv << [ request.id, request.title, @@ -86,7 +81,7 @@ namespace :cleanup do request.public_body_id, request.public_body.name, request.public_body.request_email, - request.created_at.to_s, + request.created_at.to_s ] end end diff --git a/lib/tasks/config_files.rake b/lib/tasks/config_files.rake index b7af371d3b..5dfa0cbb99 100644 --- a/lib/tasks/config_files.rake +++ b/lib/tasks/config_files.rake @@ -20,180 +20,164 @@ namespace :config_files do end end - def convert_erb(file, replacements) - ExampleERBRenderer.new(file, replacements).lines + def convert_erb(file, **replacements) + puts ExampleERBRenderer.new(file, **replacements).lines end - def daemons(only_active = false) - daemons = [ 'alert-tracks', 'send-notifications' ] - if AlaveteliConfiguration.production_mailer_retriever_method == 'pop' || - !only_active - daemons << 'poll-for-incoming' - end - daemons + def default_replacements + { + cpus: ENV.fetch('CPUS') { '1' }, + mailto: ENV.fetch('MAILTO') { "#{ ENV['DEPLOY_USER'] }@localhost" }, + rails_env: ENV.fetch('RAILS_ENV') { 'development' }, + ruby_version: ENV.fetch('RUBY_VERSION') { '3.0.4' }, + site: ENV.fetch('SITE') { 'foi' }, + user: ENV.fetch('DEPLOY_USER') { 'alaveteli' }, + vcspath: ENV.fetch('VCSPATH') { 'alaveteli' }, + vhost_dir: ENV.fetch('VHOST_DIR') { '/var/www/alaveteli' }, + use_rbenv?: ENV.fetch('USE_RBENV', 'false') == 'true', + rails_env_defined?: ENV['RAILS_ENV_DEFINED'] == 'true' + } end - desc 'Return list of daemons to install based on the settings defined - in general.yml' - task :active_daemons => :environment do - puts daemons(true) + def daemons + [ + { + path: '/etc/init.d', + name: 'thin', + template: 'config/sysvinit-thin.example', + condition: -> { ENV['RAILS_ENV'] == 'production' } + }, + { + path: '/etc/init.d', + name: 'alert-tracks', + template: 'config/alert-tracks-debian.example' + }, + { + path: '/etc/init.d', + name: 'send-notifications', + template: 'config/send-notifications-debian.example' + }, + { + path: '/etc/init.d', + name: 'poll-for-incoming', + template: 'config/poll-for-incoming-debian.example', + condition: -> do + AlaveteliConfiguration.production_mailer_retriever_method == 'pop' + end + }, + { + path: '/etc/systemd/system', + name: 'sidekiq.service', + template: 'config/sidekiq.service.example', + condition: -> { AlaveteliConfiguration.background_jobs == 'server' } + } + ] end - desc 'Return list of all daemons the application defines' - task :all_daemons => :environment do - puts daemons + desc 'Return list of daemons to install based on the settings defined + in general.yml for a given path' + task active_daemons: :environment do + example = 'rake config_files:active_daemons PATH=/etc/init.d' + check_for_env_vars(['PATH'], example) + + puts daemons. + select { |d| d[:path] == ENV['PATH'] }. + select { |d| d.fetch(:condition, -> { true }).call }. + map { |d| d[:name] } end - desc 'Return the value of a config param' - task :get_config_value => :environment do - example = 'rake config_files:get_config_value ' \ - 'KEY=PRODUCTION_MAILER_RETRIEVER_METHOD' - check_for_env_vars(['KEY'], example) - key = ENV['KEY'] - if AlaveteliConfiguration::DEFAULTS.key?(key.to_sym) - puts MySociety::Config. - get(key, AlaveteliConfiguration::DEFAULTS[key.to_sym]) - end + desc 'Return list of all daemons the application defines for a given path' + task all_daemons: :environment do + example = 'rake config_files:all_daemons PATH=/etc/init.d' + check_for_env_vars(['PATH'], example) + + puts daemons. + select { |d| d[:path] == ENV['PATH'] }. + map { |d| d[:name] } end desc 'Convert wrapper example in config to a form suitable for running mail handling scripts with rbenv' - task :convert_wrapper => :environment do + task convert_wrapper: :environment do example = 'rake config_files:convert_wrapper DEPLOY_USER=deploy SCRIPT_FILE=config/run-with-rbenv-path.example' - check_for_env_vars(['DEPLOY_USER', - 'SCRIPT_FILE'], example) - - replacements = { - :user => ENV['DEPLOY_USER'], - } + check_for_env_vars(%w[DEPLOY_USER SCRIPT_FILE], example) - # Generate the template for potential further processing - convert_erb(ENV['SCRIPT_FILE'], replacements).each do |line| - puts line - end + convert_erb(ENV['SCRIPT_FILE'], **default_replacements) end desc 'Convert Debian example init script in config to a form suitable for installing in /etc/init.d' - task :convert_init_script => :environment do + task convert_init_script: :environment do example = 'rake config_files:convert_init_script ' \ 'DEPLOY_USER=deploy ' \ 'VHOST_DIR=/dir/above/alaveteli ' \ 'VCSPATH=alaveteli ' \ 'SITE=alaveteli ' \ 'SCRIPT_FILE=config/alert-tracks-debian.example ' \ - 'RUBY_VERSION=2.7.4 ' \ + 'RUBY_VERSION=3.0.4 ' \ 'USE_RBENV=false ' - check_for_env_vars(['DEPLOY_USER', - 'VHOST_DIR', - 'SCRIPT_FILE'], example) + check_for_env_vars(%w[DEPLOY_USER VHOST_DIR SCRIPT_FILE], example) - replacements = { - :user => ENV['DEPLOY_USER'], - :vhost_dir => ENV['VHOST_DIR'], - :vcspath => ENV.fetch('VCSPATH') { 'alaveteli' }, - :site => ENV.fetch('SITE') { 'foi' }, - :cpus => ENV.fetch('CPUS') { '1' }, - :rails_env => ENV.fetch('RAILS_ENV') { 'development' }, - :ruby_version => ENV.fetch('RUBY_VERSION') { '' }, - :use_rbenv? => ENV['USE_RBENV'] == 'true' - } + daemon_name = ENV.fetch('DAEMON_NAME') do + File.basename(ENV['SCRIPT_FILE'], '-debian.example') + end - # Use the filename for the $daemon_name ugly variable - daemon_name = File.basename(ENV['SCRIPT_FILE'], '-debian.example') - replacements.update(:daemon_name => "#{ replacements[:site] }-#{ daemon_name }") + replacements = default_replacements.merge( + daemon_name: "#{default_replacements[:site]}-#{daemon_name}" + ) - # Generate the template for potential further processing - converted = convert_erb(ENV['SCRIPT_FILE'], replacements) + convert_erb(ENV['SCRIPT_FILE'], **replacements) + end - # uncomment RAILS_ENV in to the generated template if its not set by the - # hard coded config file - unless File.exist?("#{ Rails.root }/config/rails_env.rb") - converted.each do |line| - line.gsub!(/^#\s*RAILS_ENV=/, "RAILS_ENV=") - line.gsub!(/^#\s*export RAILS_ENV/, "export RAILS_ENV") - end - end + desc 'Convert example daemon in config to a form suitable for installing ' \ + 'on a server' + task convert_daemon: :environment do + example = 'rake config_files:convert_daemon ' \ + 'DEPLOY_USER=deploy ' \ + 'VHOST_DIR=/dir/above/alaveteli ' \ + 'VCSPATH=alaveteli ' \ + 'SITE=alaveteli ' \ + 'DAEMON=alert-tracks ' \ + 'RUBY_VERSION=3.0.4 ' \ + 'USE_RBENV=false ' + check_for_env_vars(%w[DEPLOY_USER VHOST_DIR DAEMON], example) - converted.each do |line| - puts line - end + daemon = daemons.find { |d| d[:name] == ENV['DAEMON'] } + raise 'Unknown daemon' unless daemon + + ENV['SCRIPT_FILE'] = daemon[:template] + ENV['DAEMON_NAME'] = daemon[:name] + + Rake::Task['config_files:convert_init_script'].invoke end desc 'Convert Debian example crontab file in config to a form suitable for installing in /etc/cron.d' - task :convert_crontab => :environment do + task convert_crontab: :environment do example = 'rake config_files:convert_crontab ' \ 'DEPLOY_USER=deploy ' \ 'VHOST_DIR=/dir/above/alaveteli VCSPATH=alaveteli ' \ 'SITE=alaveteli CRONTAB=config/crontab-example ' \ 'MAILTO=cron-alaveteli@example.org ' \ - 'RUBY_VERSION=2.7.4 ' + 'RUBY_VERSION=3.0.4 ' \ 'USE_RBENV=false ' - check_for_env_vars(['DEPLOY_USER', - 'VHOST_DIR', - 'VCSPATH', - 'SITE', - 'CRONTAB'], example) - replacements = { - :user => ENV['DEPLOY_USER'], - :vhost_dir => ENV['VHOST_DIR'], - :vcspath => ENV['VCSPATH'], - :site => ENV['SITE'], - :mailto => ENV.fetch('MAILTO') { "#{ ENV['DEPLOY_USER'] }@localhost" }, - :ruby_version => ENV.fetch('RUBY_VERSION') { '' }, - :use_rbenv? => ENV['USE_RBENV'] == 'true' - } - - lines = [] - convert_erb(ENV['CRONTAB'], replacements).each do |line| - lines << line - end - - lines.each do |line| - puts line - end + check_for_env_vars(%w[DEPLOY_USER VHOST_DIR VCSPATH SITE CRONTAB], example) + convert_erb(ENV['CRONTAB'], **default_replacements) end desc 'Convert miscellaneous example scripts. This does not check for required environment variables for the script, so please check the script file itself.' - task :convert_script => :environment do + task convert_script: :environment do example = 'rake config_files:convert_script SCRIPT_FILE=config/run-with-rbenv-path.example' check_for_env_vars(['SCRIPT_FILE'], example) - - replacements = { - :user => ENV.fetch('DEPLOY_USER') { 'alaveteli' }, - :vhost_dir => ENV.fetch('VHOST_DIR') { '/var/www/alaveteli' }, - :vcspath => ENV.fetch('VCSPATH') { 'alaveteli' }, - :site => ENV.fetch('SITE') { 'foi' }, - :cpus => ENV.fetch('CPUS') { '1' }, - :rails_env => ENV.fetch('RAILS_ENV') { 'development' } - } - - # Generate the template for potential further processing - converted = convert_erb(ENV['SCRIPT_FILE'], replacements) - - # uncomment RAILS_ENV in to the generated template if its not set by the - # hard coded config file - unless File.exist?("#{ Rails.root }/config/rails_env.rb") - converted.each do |line| - line.gsub!(/^#\s*RAILS_ENV=/, "RAILS_ENV=") - line.gsub!(/^#\s*export RAILS_ENV/, "export RAILS_ENV") - end - end - - converted.each do |line| - puts line - end + convert_erb(ENV['SCRIPT_FILE'], **default_replacements) end desc 'Set reject_incoming_at_mta on old requests that are rejecting incoming mail' - task :set_reject_incoming_at_mta => :environment do + task set_reject_incoming_at_mta: :environment do example = 'rake config_files:set_reject_incoming_at_mta REJECTED_THRESHOLD=5 AGE_IN_MONTHS=12' - check_for_env_vars(['REJECTED_THRESHOLD', 'AGE_IN_MONTHS'], example) + check_for_env_vars(%w[REJECTED_THRESHOLD AGE_IN_MONTHS], example) dryrun = ENV['DRYRUN'] != '0' - if dryrun - STDERR.puts "Only a dry run; info_requests will not be updated" - end - options = {:rejection_threshold => ENV['REJECTED_THRESHOLD'], - :age_in_months => ENV['AGE_IN_MONTHS'], - :dryrun => dryrun} + STDERR.puts "Only a dry run; info_requests will not be updated" if dryrun + options = {rejection_threshold: ENV['REJECTED_THRESHOLD'], + age_in_months: ENV['AGE_IN_MONTHS'], + dryrun: dryrun} updated_count = InfoRequest.reject_incoming_at_mta(options) do |ids| puts "Info Request\tRejected incoming count\tLast updated" @@ -208,7 +192,7 @@ namespace :config_files do desc 'Set reject_incoming_at_mta on a list of requests identified by ' \ 'request address' task set_reject_incoming_at_mta_from_list: :environment do - example = 'rake temp:set_reject_incoming_at_mta_from_list ' \ + example = 'rake config_files:set_reject_incoming_at_mta_from_list ' \ 'FILE=/tmp/rejection_list.txt' check_for_env_vars(['FILE'], example) @@ -221,7 +205,7 @@ namespace :config_files do end desc 'Unset reject_incoming_at_mta on a request' - task :unset_reject_incoming_at_mta => :environment do + task unset_reject_incoming_at_mta: :environment do example = 'rake config_files:unset_reject_incoming_at_mta REQUEST_ID=4' check_for_env_vars(['REQUEST_ID'], example) info_request = InfoRequest.find(ENV['REQUEST_ID']) @@ -237,15 +221,15 @@ namespace :config_files do end desc 'Produce a list of email addresses for which the MTA should reject messages at RCPT time' - task :generate_mta_rejection_list => :environment do + task generate_mta_rejection_list: :environment do example = 'rake config_files:generate_mta_rejection_list MTA=(exim|postfix)' check_for_env_vars(['MTA'], example) mta = ENV['MTA'].downcase - unless ['postfix', 'exim'].include? mta + unless %w[postfix exim].include? mta puts "Error: Unrecognised MTA" exit 1 end - InfoRequest.where(:reject_incoming_at_mta => true).each do |info_request| + InfoRequest.where(reject_incoming_at_mta: true).each do |info_request| if mta == 'postfix' puts "#{info_request.incoming_email} REJECT" else diff --git a/lib/tasks/embargoes.rake b/lib/tasks/embargoes.rake index 0cabeeab71..1dc76343ba 100644 --- a/lib/tasks/embargoes.rake +++ b/lib/tasks/embargoes.rake @@ -1,7 +1,7 @@ namespace :embargoes do desc "Delete any embargoes that have expired" - task :expire_publishable => :environment do + task expire_publishable: :environment do AlaveteliPro::Embargo.expire_publishable end diff --git a/lib/tasks/export.rake b/lib/tasks/export.rake index 3c1327d2e1..d1ce9ef1fb 100644 --- a/lib/tasks/export.rake +++ b/lib/tasks/export.rake @@ -36,7 +36,7 @@ namespace :export do # file using something like `tee` # nice -n 19 [task] 1> exports/stdout.log 2> >(tee -a exports/stderr.log >&2) desc 'exports all non-personal information to export folder' - task :research_export => :environment do + task research_export: :environment do cut_off_date = ENV["CUTOFF_DATE"] to_run = ENV["MODELS"] @@ -59,121 +59,72 @@ namespace :export do HasTagStringTag.where(model_type: "PublicBody")) #export public body information - DataExport.csv_export( PublicBody, - to_run, - PublicBody.where("created_at < ?", cut_off_date), - ["id", - "name", - "short_name", - "created_at", - "updated_at", - "url_name", - "home_page", - "info_requests_count", - "info_requests_successful_count", - "info_requests_not_held_count", - "info_requests_overdue_count", - "info_requests_visible_classified_count", - "info_requests_visible_count"]) + DataExport.csv_export( + PublicBody, to_run, PublicBody.where("created_at < ?", cut_off_date), + %w[id name short_name created_at updated_at url_name home_page + info_requests_count info_requests_successful_count + info_requests_not_held_count info_requests_overdue_count + info_requests_visible_classified_count info_requests_visible_count] + ) #export non-personal user fields - DataExport.csv_export( User, - to_run, - User.active. - where("updated_at < ?", cut_off_date), - ["id", - "name", - "info_requests_count", - "track_things_count", - "request_classifications_count", - "public_body_change_requests_count", - "info_request_batches_count"], - override = { - "name" => DataExport.gender_lambda, - }, - header_map = { - "name" => "gender", - } - ) + DataExport.csv_export( + User, to_run, User.active.where("updated_at < ?", cut_off_date), + %w[id name info_requests_count track_things_count + request_classifications_count public_body_change_requests_count + info_request_batches_count], + override = { "name" => DataExport.gender_lambda }, + header_map = { "name" => "gender" } + ) #export InfoRequest Fields - DataExport.csv_export(InfoRequest, - to_run, - DataExport.exportable_requests(cut_off_date), - ["id", - "title", - "user_id", - "public_body_id", - "created_at", - "updated_at", - "described_state", - "awaiting_description", - "url_title", - "law_used", - "last_public_response_at", - "info_request_batch_id"]) - - DataExport.csv_export(InfoRequestBatch, - to_run, - InfoRequestBatch.where("updated_at < ?", cut_off_date), - ["id", - "title", - "user_id", - "sent_at", - "created_at", - "updated_at"]) + DataExport.csv_export( + InfoRequest, to_run, DataExport.exportable_requests(cut_off_date), + %w[id title user_id public_body_id created_at updated_at described_state + awaiting_description url_title law_used last_public_response_at + info_request_batch_id] + ) + + DataExport.csv_export( + InfoRequestBatch, to_run, + InfoRequestBatch.where("updated_at < ?", cut_off_date), + %w[id title user_id sent_at created_at updated_at] + ) #export incoming messages - only where normal prominence, # allow name_censor to some fields - DataExport.csv_export(IncomingMessage, - to_run, - DataExport.exportable_incoming_messages(cut_off_date), - ["id", - "info_request_id", - "created_at", - "updated_at", - "raw_email_id", - "cached_attachment_text_clipped", - "cached_main_body_text_folded", - "cached_main_body_text_unfolded", - "subject", - "sent_at", - "prominence"], - override = { - "cached_attachment_text_clipped" => DataExport.name_censor_lambda('cached_attachment_text_clipped'), - "cached_main_body_text_folded" => DataExport.name_censor_lambda('cached_main_body_text_folded'), - "cached_main_body_text_unfolded" => DataExport.name_censor_lambda('cached_main_body_text_unfolded'), - }) + DataExport.csv_export( + IncomingMessage, to_run, + DataExport.exportable_incoming_messages(cut_off_date), + %w[id info_request_id created_at updated_at raw_email_id + cached_attachment_text_clipped cached_main_body_text_folded + cached_main_body_text_unfolded subject sent_at prominence], + override = { + "cached_attachment_text_clipped" => + DataExport.name_censor_lambda('cached_attachment_text_clipped'), + "cached_main_body_text_folded" => + DataExport.name_censor_lambda('cached_main_body_text_folded'), + "cached_main_body_text_unfolded" => + DataExport.name_censor_lambda('cached_main_body_text_unfolded') + } + ) #export incoming messages - only where normal prominence, allow name_censor to some fields - DataExport.csv_export(OutgoingMessage, - to_run, - DataExport.exportable_outgoing_messages(cut_off_date), - ["id", - "info_request_id", - "created_at", - "updated_at", - "body", - "message_type", - "subject", - "last_sent_at", - "incoming_message_followup_id"], - override = { - "body" => DataExport.name_censor_lambda('body'), - }) + DataExport.csv_export( + OutgoingMessage, to_run, + DataExport.exportable_outgoing_messages(cut_off_date), + %w[id info_request_id created_at updated_at body message_type subject + last_sent_at incoming_message_followup_id], + override = { "body" => DataExport.name_censor_lambda('body') } + ) #export incoming messages - only where normal prominence, allow name_censor to some fields - DataExport.csv_export(FoiAttachment, - to_run, - DataExport.exportable_foi_attachments(cut_off_date), - ["id", - "content_type", - "filename", - "charset", - "url_part_number", - "incoming_message_id", - "within_rfc822_subject"]) - + DataExport.csv_export( + FoiAttachment, to_run, + DataExport.exportable_foi_attachments(cut_off_date), + %w[id content_type filename charset url_part_number incoming_message_id + within_rfc822_subject] + ) end end diff --git a/lib/tasks/geoip.rake b/lib/tasks/geoip.rake index 08dd7fe688..dade426ee2 100644 --- a/lib/tasks/geoip.rake +++ b/lib/tasks/geoip.rake @@ -38,29 +38,25 @@ namespace :geoip do downloaded_location = File.join(tmp_dir, 'geodata.tar.gz') File.open(downloaded_location, "wb") do |saved_file| - begin - URI.open(link, "rb") do |read_file| - saved_file.write(read_file.read) - end - - rescue OpenURI::HTTPError => ex - log 'Error downloading MaxMind geoip data file' - log " #{ex.message}" + URI.open(link, "rb") do |read_file| + saved_file.write(read_file.read) + end - if ex.message == '401 Unauthorized' - log 'Please check the MAXMIND_LICENSE_KEY setting in ' \ - 'config/general.yml' - end + rescue OpenURI::HTTPError => ex + log 'Error downloading MaxMind geoip data file' + log " #{ex.message}" - exit + if ex.message == '401 Unauthorized' + log 'Please check the MAXMIND_LICENSE_KEY setting in ' \ + 'config/general.yml' end + + exit end `tar -xzf #{downloaded_location} -C #{tmp_dir}` - unless File.exist?(target_dir) - FileUtils.mkdir target_dir - end + FileUtils.mkdir target_dir unless File.exist?(target_dir) extracted_folder = Dir["#{tmp_dir}/GeoLite2-Country_*"].last FileUtils.mv("#{extracted_folder}/GeoLite2-Country.mmdb", destination) diff --git a/lib/tasks/gettext.rake b/lib/tasks/gettext.rake index 7d6bb7ebc4..d32cd7b5ac 100644 --- a/lib/tasks/gettext.rake +++ b/lib/tasks/gettext.rake @@ -64,17 +64,17 @@ namespace :gettext do Rake::Task['find'].clear desc "Update pot/po files." - task :find => :environment do + task find: :environment do find(files: files_to_translate, root: locale_path) end desc "Update pot/po files for Alaveteli Pro." - task :find_alaveteli_pro => :environment do + task find_alaveteli_pro: :environment do find(files: pro_files_to_translate, root: pro_locale_path) end desc "Update pot/po files for a theme." - task :find_theme => :environment do + task find_theme: :environment do find(files: theme_files_to_translate, root: theme_locale_path) end @@ -121,7 +121,9 @@ namespace :gettext do lines << line end end - puts "Mappings unused in #{po_file}: #{lang_mappings.keys}" unless lang_mappings.empty? + unless lang_mappings.empty? + puts "Mappings unused in #{po_file}: #{lang_mappings.keys}" + end File.open(po_file, "w") { |f| f.puts(lines) } end end diff --git a/lib/tasks/graphs.rake b/lib/tasks/graphs.rake index 1c3d7e96bb..bd0511ca7a 100644 --- a/lib/tasks/graphs.rake +++ b/lib/tasks/graphs.rake @@ -4,7 +4,7 @@ require File.join(File.dirname(__FILE__), '../graphs') namespace :graphs do include Graphs - task :generate_user_use_graph => :environment do + task generate_user_use_graph: :environment do minimum_data_size = ENV.fetch('MINIMUM_DATA_SIZE', 1).to_i # set the local font path for the current task @@ -68,33 +68,33 @@ namespace :graphs do state_list = [ { - :title => "users each day ... who registered", - :colour => :lightblue + title: "users each day ... who registered", + colour: :lightblue }, { - :title => "... and since confirmed their email", - :with => "impulses", - :linewidth => 15, - :colour => :mauve, - :sql => confirmed_users + title: "... and since confirmed their email", + with: "impulses", + linewidth: 15, + colour: :mauve, + sql: confirmed_users }, { - :title => "...who made an FOI request", - :with => "lines", - :linewidth => 1, - :colour => :red, - :sql => active_users + title: "...who made an FOI request", + with: "lines", + linewidth: 1, + colour: :red, + sql: active_users } ] # plot all users - options = {:with => "impulses", - :linecolor => COLOURS[state_list[0][:colour]], - :linewidth => 15, :title => state_list[0][:title]} + options = {with: "impulses", + linecolor: COLOURS[state_list[0][:colour]], + linewidth: 15, title: state_list[0][:title]} all_users = select_as_columns(aggregate_signups) # nothing to do, bail - unless all_users and all_users[0].size >= minimum_data_size + unless all_users && (all_users[0].size >= minimum_data_size) if verbose exit "warning: no request data to graph, skipping task" else @@ -110,10 +110,10 @@ namespace :graphs do graph_param_sets << GraphParams.new( state_info[:sql], options.merge({ - :title => state_info[:title], - :linecolor => COLOURS[state_info[:colour]], - :with => state_info[:with], - :linewidth => state_info[:linewidth]}) + title: state_info[:title], + linecolor: COLOURS[state_info[:colour]], + with: state_info[:with], + linewidth: state_info[:linewidth]}) ) end end @@ -125,19 +125,19 @@ namespace :graphs do if all_users[0].size > 1 # plot cumulative user totals options.merge!({ - :title => "cumulative total number of users", - :axes => "x1y2", - :with => "lines", - :linewidth => 1, - :linecolor => COLOURS[:lightgreen], - :using => "1:3"}) + title: "cumulative total number of users", + axes: "x1y2", + with: "lines", + linewidth: 1, + linecolor: COLOURS[:lightgreen], + using: "1:3"}) plot_data_from_columns(all_users, options, plot.data) end end end end - task :generate_request_creation_graph => :environment do + task generate_request_creation_graph: :environment do minimum_data_size = ENV.fetch('MINIMUM_DATA_SIZE', 2).to_i # set the local font path for the current task @@ -189,21 +189,21 @@ namespace :graphs do # get the data, plot the graph - state_list = [ {:state => 'waiting_response', :colour => :darkblue}, - {:state => 'waiting_clarification', :colour => :lightblue}, - {:state => 'not_held', :colour => :yellow}, - {:state => 'rejected', :colour => :red}, - {:state => 'successful', :colour => :lightgreen}, - {:state => 'partially_successful', :colour => :darkgreen}, - {:state => 'requires_admin', :colour => :cyan}, - {:state => 'gone_postal', :colour => :darkyellow}, - {:state => 'internal_review', :colour => :mauve}, - {:state => 'error_message', :colour => :redbrown}, - {:state => 'user_withdrawn', :colour => :pink} ] - - options = {:with => "impulses", - :linecolor => COLOURS[state_list[0][:colour]], - :linewidth => 4, :title => state_list[0][:state]} + state_list = [ {state: 'waiting_response', colour: :darkblue}, + {state: 'waiting_clarification', colour: :lightblue}, + {state: 'not_held', colour: :yellow}, + {state: 'rejected', colour: :red}, + {state: 'successful', colour: :lightgreen}, + {state: 'partially_successful', colour: :darkgreen}, + {state: 'requires_admin', colour: :cyan}, + {state: 'gone_postal', colour: :darkyellow}, + {state: 'internal_review', colour: :mauve}, + {state: 'error_message', colour: :redbrown}, + {state: 'user_withdrawn', colour: :pink} ] + + options = {with: "impulses", + linecolor: COLOURS[state_list[0][:colour]], + linewidth: 4, title: state_list[0][:state]} # here be database-specific dragons... # this uses a window function which is not supported by MySQL, but @@ -219,7 +219,7 @@ namespace :graphs do # nothing to do, bail # (both nil and a single datapoint will result in an undrawable graph) - unless all_requests and all_requests[0].size >= minimum_data_size + unless all_requests && (all_requests[0].size >= minimum_data_size) if verbose abort "warning: no request data to graph, skipping task" else @@ -239,8 +239,8 @@ namespace :graphs do graph_param_sets << GraphParams.new( assemble_sql(state_exclusion_sql(previous_states)), options.merge({ - :title => state_info[:state], - :linecolor => COLOURS[state_info[:colour]]}) + title: state_info[:state], + linecolor: COLOURS[state_info[:colour]]}) ) end previous_states << state_list[index][:state] @@ -250,12 +250,12 @@ namespace :graphs do # plot the cumulative counts options.merge!({ - :with => "lines", - :linecolor => COLOURS[:lightgreen], - :linewidth => 1, - :title => "cumulative total number of requests", - :using => "1:3", - :axes => "x1y2", + with: "lines", + linecolor: COLOURS[:lightgreen], + linewidth: 1, + title: "cumulative total number of requests", + using: "1:3", + axes: "x1y2" }) plot_data_from_columns(all_requests, options, plot.data) end diff --git a/lib/tasks/import.rake b/lib/tasks/import.rake index 8e1d410511..24d94f4a68 100644 --- a/lib/tasks/import.rake +++ b/lib/tasks/import.rake @@ -3,11 +3,9 @@ require 'tempfile' namespace :import do desc 'Import public bodies from CSV provided on standard input' - task :import_csv => :environment do + task import_csv: :environment do dryrun = ENV['DRYRUN'] != '0' - if dryrun - STDERR.puts 'Only a dry run; public bodies will not be created' - end + STDERR.puts 'Only a dry run; public bodies will not be created' if dryrun tmp_csv = nil Tempfile.open('alaveteli') do |f| @@ -25,7 +23,7 @@ namespace :import do name_count = Hash.new { 0 } reader = CSV.open(tmp_csv.path, 'r') header_line = reader.shift - headers = header_line.map { |h| h.gsub /^#/, '' } + headers = header_line.map { |h| h.gsub(/^#/, '') } reader.each do |row_array| row = Hash[headers.zip row_array] @@ -61,13 +59,13 @@ namespace :import do import_args = [tmp_csv.path, tag, tag_behaviour, dryrun, editor, locales] errors, notes = - PublicBody.import_csv_from_file(*import_args) do |row_number, fields| + PublicBody.import_csv_from_file(*import_args) do |row_number, _fields| percent_complete = (100 * row_number.to_f / number_of_rows).to_i STDERR.print "#{row_number} out of #{number_of_rows} " STDERR.puts "(#{percent_complete}% complete)" end - if errors.length > 0 + if !errors.empty? STDERR.puts 'Import failed, with the following errors:' errors.each do |error| diff --git a/lib/tasks/reindex.rake b/lib/tasks/reindex.rake index b4aa4ea0ea..bb94fe28c8 100644 --- a/lib/tasks/reindex.rake +++ b/lib/tasks/reindex.rake @@ -1,7 +1,7 @@ namespace :reindex do desc "Reindex events in batches" - task :events => :environment do + task events: :environment do reindex_log = Logger.new("#{Rails.root}/log/reindex_events.log") last_id = ENV["LAST_EVENT_ID"] || 0 batch_size = (ENV["BATCH_SIZE"] || 300).to_i # default to 300 @@ -11,7 +11,7 @@ namespace :reindex do current_id = 0 # keep track of the current event begin - InfoRequestEvent.where("id > #{last_id}").find_in_batches(:batch_size => batch_size) do |events| + InfoRequestEvent.where("id > #{last_id}").find_in_batches(batch_size: batch_size) do |events| events.each do |event| current_id = event.id event.xapian_mark_needs_index @@ -32,7 +32,7 @@ namespace :reindex do end desc "Reindex public bodies in batches" - task :public_bodies => :environment do + task public_bodies: :environment do reindex_log = Logger.new("#{Rails.root}/log/reindex_public_bodies.log") last_id = ENV["LAST_PUBLIC_BODY_ID"] || 0 batch_size = (ENV["BATCH_SIZE"] || 300).to_i # default to 300 @@ -42,7 +42,7 @@ namespace :reindex do current_id = 0 # keep track of the current public body begin - PublicBody.where("id > #{last_id}").find_in_batches(:batch_size => batch_size) do |bodies| + PublicBody.where("id > #{last_id}").find_in_batches(batch_size: batch_size) do |bodies| bodies.each do |body| current_id = body.id body.xapian_mark_needs_index @@ -63,7 +63,7 @@ namespace :reindex do end desc "Reindex users in batches" - task :users => :environment do + task users: :environment do reindex_log = Logger.new("#{Rails.root}/log/reindex_users.log") last_id = ENV["LAST_USER_ID"] || 0 batch_size = (ENV["BATCH_SIZE"] || 300).to_i # default to 300 @@ -73,7 +73,7 @@ namespace :reindex do current_id = 0 # keep track of the current user begin - User.where("id > #{last_id}").find_in_batches(:batch_size => batch_size) do |users| + User.where("id > #{last_id}").find_in_batches(batch_size: batch_size) do |users| users.each do |user| current_id = user.id user.xapian_mark_needs_index diff --git a/lib/tasks/reminder.rake b/lib/tasks/reminder.rake index cfb18d8097..a65db96ee4 100644 --- a/lib/tasks/reminder.rake +++ b/lib/tasks/reminder.rake @@ -1,7 +1,7 @@ namespace :reminder do desc 'Send reminder email about public holiday data' - task :public_holidays => :environment do + task public_holidays: :environment do config = MySociety::Config.load_default ReminderMailer.public_holidays( diff --git a/lib/tasks/stats.rake b/lib/tasks/stats.rake index 41478c6ad9..ae2fef4f77 100644 --- a/lib/tasks/stats.rake +++ b/lib/tasks/stats.rake @@ -1,7 +1,7 @@ namespace :stats do desc 'Produce monthly transaction stats for a period starting START_YEAR' - task :show => :environment do + task show: :environment do example = 'rake stats:show START_YEAR=2009 [START_MONTH=3 END_YEAR=2012 END_MONTH=10]' check_for_env_vars(['START_YEAR'], example) start_year = (ENV['START_YEAR']).to_i @@ -72,13 +72,13 @@ namespace :stats do confirmed_users_count = User.active. - where(:email_confirmed => true). + where(email_confirmed: true). where(date_conditions). count pro_confirmed_users_count = User.pro.active. - where(:email_confirmed => true). + where(email_confirmed: true). where('users.created_at >= ? AND users.created_at < ?', month_start, month_end+1). @@ -112,7 +112,7 @@ namespace :stats do end desc 'Produce stats on volume of requests to authorities matching a set of tags. Specify tags as TAGS=tagone,tagtwo' - task :volumes_by_authority_tag => :environment do + task volumes_by_authority_tag: :environment do tags = ENV['TAGS'].split(',') first_request_datetime = InfoRequest.minimum(:created_at) start_year = first_request_datetime.strftime("%Y").to_i @@ -129,7 +129,7 @@ namespace :stats do puts "Bodies with tag '#{tag}': #{tag_bodies.size}" public_bodies += tag_bodies end - public_body_ids = public_bodies.map { |body| body.id }.uniq + public_body_ids = public_bodies.map(&:id).uniq public_body_condition_string = 'AND public_bodies.id in (?)' month_starts = (Date.new(start_year, start_month)..Date.new(end_year, end_month)).select { |d| d.day == 1 } headers = ['Period', @@ -168,7 +168,7 @@ namespace :stats do Prints the per-quarter number of created FOI Requests made to each Public Body found by the query. Specify the search query as QUERY='london school' DESC - task :number_of_requests_created => :environment do + task number_of_requests_created: :environment do query = ENV['QUERY'] start_at = PublicBody.minimum(:created_at) finish_at = PublicBody.maximum(:created_at) @@ -195,7 +195,7 @@ namespace :stats do Prints the per-quarter number of successful FOI Requests made to each Public Body found by the query. Specify the search query as QUERY='london school' DESC - task :number_of_requests_successful => :environment do + task number_of_requests_successful: :environment do query = ENV['QUERY'] start_at = PublicBody.minimum(:created_at) finish_at = PublicBody.maximum(:created_at) @@ -220,9 +220,9 @@ namespace :stats do end desc 'Update statistics in the public_bodies table' - task :update_public_bodies_stats => :environment do + task update_public_bodies_stats: :environment do verbose = ENV['VERBOSE'] == '1' - PublicBody.find_each(:batch_size => 10) do |public_body| + PublicBody.find_each(batch_size: 10) do |public_body| puts "Counting overdue requests for #{public_body.name}" if verbose # Look for values of 'waiting_response_overdue' and @@ -231,11 +231,11 @@ namespace :stats do overdue_count = 0 very_overdue_count = 0 - conditions = { :public_body_id => public_body.id, - :awaiting_description => false } + conditions = { public_body_id: public_body.id, + awaiting_description: false } InfoRequest. - is_searchable.where(conditions).find_each(:batch_size => 200) do |ir| + is_searchable.where(conditions).find_each(batch_size: 200) do |ir| case ir.calculate_status when 'waiting_response_very_overdue' very_overdue_count += 1 @@ -253,35 +253,35 @@ namespace :stats do desc 'Add InfoRequestEvents for the points when requests became overdue and very overdue' - task :update_overdue_info_request_events => :environment do + task update_overdue_info_request_events: :environment do InfoRequest.log_overdue_events InfoRequest.log_very_overdue_events end desc 'Add InfoRequestEvents for the points when requests embargoes began to expire' - task :update_expiring_embargo_info_request_events => :environment do + task update_expiring_embargo_info_request_events: :environment do AlaveteliPro::Embargo.log_expiring_events end desc 'Print a list of the admin URLs of requests with hidden material' - task :list_hidden => :environment do + task list_hidden: :environment do include Rails.application.routes.url_helpers - hidden_requests = InfoRequest.where(:prominence => 'hidden') - requester_only_requests = InfoRequest.where(:prominence => 'requester_only') + hidden_requests = InfoRequest.where(prominence: 'hidden') + requester_only_requests = InfoRequest.where(prominence: 'requester_only') hidden_incoming = InfoRequest.joins(:incoming_messages). - where(:incoming_messages => {:prominence => 'hidden'}).uniq + where(incoming_messages: {prominence: 'hidden'}).uniq requester_only_incoming = InfoRequest.joins(:incoming_messages). - where(:incoming_messages => {:prominence => 'requester_only'}).uniq + where(incoming_messages: {prominence: 'requester_only'}).uniq hidden_outgoing = InfoRequest.joins(:outgoing_messages). - where(:outgoing_messages => {:prominence => 'hidden'}).uniq + where(outgoing_messages: {prominence: 'hidden'}).uniq requester_only_outgoing = InfoRequest.joins(:outgoing_messages). - where(:outgoing_messages => {:prominence => 'requester_only'}).uniq + where(outgoing_messages: {prominence: 'requester_only'}).uniq hidden_comments = InfoRequest.joins(:comments). - where(:comments => {:visible => false}).uniq + where(comments: {visible: false}).uniq [['Hidden requests', hidden_requests], ['Requester-only requests', requester_only_requests], @@ -293,8 +293,8 @@ namespace :stats do unless list.empty? puts "\n#{title}\n" list.each do |request| - request_line = "#{admin_request_url(request, :host => AlaveteliConfiguration::domain)}" - if ['vexatious', 'not_foi'].include? request.described_state + request_line = admin_request_url(request, host: AlaveteliConfiguration.domain) + if %w[vexatious not_foi].include? request.described_state request_line << "\t#{request.described_state}" end puts "#{request_line}\n" @@ -304,9 +304,9 @@ namespace :stats do end desc 'Output all the requests made to the top 20 public bodies' - task :get_top20_body_requests => :environment do + task get_top20_body_requests: :environment do require 'csv' - puts CSV.generate_line(["public_body_id", "public_body_name", "request_created_timestamp", "request_title", "request_body"]) + puts CSV.generate_line(%w[public_body_id public_body_name request_created_timestamp request_title request_body]) PublicBody.limit(20).order(info_requests_visible_count: :desc).each do |body| body.info_requests.is_searchable.find_each do |request| diff --git a/lib/tasks/submodules.rake b/lib/tasks/submodules.rake index 50d768d93f..94e4034d98 100644 --- a/lib/tasks/submodules.rake +++ b/lib/tasks/submodules.rake @@ -1,7 +1,7 @@ namespace :submodules do desc "Check the status of the project's submodules" - task :check => :environment do + task check: :environment do commit_info = `git submodule status commonlib` case commit_info[0,1] when '+' diff --git a/lib/tasks/temp.rake b/lib/tasks/temp.rake index c5989df626..502952a811 100644 --- a/lib/tasks/temp.rake +++ b/lib/tasks/temp.rake @@ -1,121 +1,2 @@ namespace :temp do - desc 'Convert old Syck YAML to Psych YAML' - task convert_syck_to_psych_yaml: :environment do - require 'syck' - - # requiring Syck redefines the YAML constant, we need to reset this back to - # Psych otherwise we can't load the InfoRequestEvent instances. - Object.send(:remove_const, :YAML) - YAML = Psych - - scope = InfoRequestEvent.where(params: nil) - count = scope.count - - scope.find_each.with_index do |event, index| - begin - Psych.parse(event.params_yaml) - rescue Psych::SyntaxError - yaml = Syck.load(event.params_yaml) - - event.no_xapian_reindex = true - event.update(params_yaml: Psych.dump(yaml)) - end - - erase_line - print "Converted InfoRequestEvent#param_yaml #{index + 1}/#{count}" - end - - erase_line - puts "Converted InfoRequestEvent#params_yaml completed." - end - - desc "Fix old objects stored in YAML which can't be decoded" - task fix_old_objects_in_yaml: :environment do - scope = InfoRequestEvent.where(params: nil) - count = scope.count - - scope.find_each.with_index do |event, index| - yaml = Psych.dump( - event.params.inject({}) do |params, (key, value)| - begin - # each param value needs to be able to converted into YAML but this - # can blow up for old Ruby objects previously stored as newer Rails - # can't correctly decode values generated older versions - value.to_yaml if value.is_a?(ApplicationRecord) - rescue NoMethodError - # reload object from DB store YAML value doesn't need to be decoded - value = value.reload - end - params[key] = value - params - end - ) - - event.no_xapian_reindex = true - event.update(params_yaml: yaml) - - erase_line - print "Fixed InfoRequestEvent#param_yaml #{index + 1}/#{count}" - end - - erase_line - puts "Fixed InfoRequestEvent#params_yaml completed." - end - - desc 'Sanitise and populate events params json column from yaml' - task sanitise_and_populate_events_params_json: :environment do - scope = InfoRequestEvent.where(params: nil) - count = scope.count - - scope.find_each.with_index do |event, index| - event.no_xapian_reindex = true - event.update(params: event.params) - - erase_line - print "Populated InfoRequestEvent#param #{index + 1}/#{count}" - end - - erase_line - puts "Populated InfoRequestEvent#params completed." - end - - desc 'Migrate PublicBody notes into Note model' - task migrate_public_body_notes: :environment do - scope = PublicBody.where.not(notes: nil) - count = scope.count - - scope.with_translations.find_each.with_index do |body, index| - PublicBody.transaction do - body.legacy_note&.save - body.translations.update(notes: nil) - end - - erase_line - print "Migrated PublicBody#notes #{index + 1}/#{count}" - end - - erase_line - puts "Migrated PublicBody#notes completed." - end - - desc 'Populate incoming message from email' - task populate_incoming_message_from_email: :environment do - scope = IncomingMessage.where(from_email: nil) - count = scope.count - - scope.includes(:raw_email).find_each.with_index do |message, index| - message.update_columns(from_email: message.raw_email.from_email || '') - - erase_line - print "Populated IncomingMessage#from_email #{index + 1}/#{count}" - end - - erase_line - puts "Populated IncomingMessage#from_email completed." - end - - def erase_line - # https://en.wikipedia.org/wiki/ANSI_escape_code#Escape_sequences - print "\e[1G\e[K" - end end diff --git a/lib/tasks/themes.rake b/lib/tasks/themes.rake index b2b84106c2..572b1702da 100644 --- a/lib/tasks/themes.rake +++ b/lib/tasks/themes.rake @@ -31,9 +31,7 @@ namespace :themes do def uninstall(theme_name, verbose=false) possible_theme_dirs(theme_name).each do |dir| - if File.directory?(dir) - run_hook(theme_name, 'uninstall', verbose) - end + run_hook(theme_name, 'uninstall', verbose) if File.directory?(dir) end end @@ -63,7 +61,7 @@ namespace :themes do def committishes_to_try result = [] - theme_branch = AlaveteliConfiguration::theme_branch + theme_branch = AlaveteliConfiguration.theme_branch result.push "origin/#{theme_branch}" if theme_branch result.push usage_tag(ALAVETELI_VERSION) hotfix_match = /^(\d+\.\d+\.\d+)(\.\d+)+/.match(ALAVETELI_VERSION) @@ -82,11 +80,11 @@ namespace :themes do Git.checkout theme_directory, committish all_failed = false break - else - puts "Failed to find #{committish}; skipping..." if verbose + elsif verbose + puts "Failed to find #{committish}; skipping..." end end - puts "Falling to using HEAD instead" if all_failed and verbose + puts "Falling to using HEAD instead" if all_failed && verbose end def install_theme(theme_url, verbose, deprecated=false) @@ -135,7 +133,7 @@ namespace :themes do end desc "Install themes specified in the config file's THEME_URLS" - task :install => :environment do + task install: :environment do verbose = true theme_urls.each do |theme_url| install_theme(theme_url, verbose) @@ -164,9 +162,7 @@ namespace :themes do locale_extensions(locale).each do |locale_extension| filename = "#{template_name}#{locale_extension}.html.erb" filepath = "lib/themes/#{theme_name}/lib/views/help/#{filename}" - if File.exist?(filepath) - return filepath - end + return filepath if File.exist?(filepath) end nil end @@ -181,7 +177,7 @@ namespace :themes do else contents = File.read(template_file) help_template_info[:sections].each do |section| - if !contents.include?("##{section}") + unless contents.include?("##{section}") missing_sections << section puts "Missing section: #{section} in template #{help_template_info[:name]}" end @@ -195,7 +191,7 @@ namespace :themes do end desc "Check that all help sections referred to in the application are present in theme" - task :check_help_sections => :environment do + task check_help_sections: :environment do intro_message = <<-EOF @@ -216,36 +212,36 @@ EOF theme_url_to_theme_name(theme_url) end - help_templates_info = [{:name => 'about', - :sections => ['whybother_them', - 'reporting', - 'reporting_unavailable']}, - {:name => 'alaveteli', - :sections => []}, - {:name => 'api', - :sections => []}, - {:name => 'contact', - :sections => []}, - {:name => 'credits', - :sections => ['helpus']}, - {:name => 'officers', - :sections => ['copyright']}, - {:name => 'privacy', - :sections => ['email_address', - 'full_address', - 'postal_answer', - 'public_request', - 'real_name']}, - {:name => 'requesting', - :sections => ['focused', - 'data_protection', - 'missing_body', - 'quickly_response',]}, - {:name => 'unhappy', - :sections => ['internal_review', - 'other_means']}, - {:name => '_why_they_should_reply_by_email', - :sections => []}] + help_templates_info = [{name: 'about', + sections: %w[whybother_them + reporting + reporting_unavailable]}, + {name: 'alaveteli', + sections: []}, + {name: 'api', + sections: []}, + {name: 'contact', + sections: []}, + {name: 'credits', + sections: ['helpus']}, + {name: 'officers', + sections: ['copyright']}, + {name: 'privacy', + sections: %w[email_address + full_address + postal_answer + public_request + real_name]}, + {name: 'requesting', + sections: %w[focused + data_protection + missing_body + quickly_response]}, + {name: 'unhappy', + sections: %w[internal_review + other_means]}, + {name: '_why_they_should_reply_by_email', + sections: []}] theme_names.each do |theme_name| AlaveteliLocalization.available_locales.each do |locale| @@ -258,9 +254,7 @@ EOF missing = true end end - if !missing - puts "No missing templates or sections" - end + puts "No missing templates or sections" unless missing end end diff --git a/lib/tasks/translation.rake b/lib/tasks/translation.rake index 4cbb3bea69..2161bd77f0 100644 --- a/lib/tasks/translation.rake +++ b/lib/tasks/translation.rake @@ -26,13 +26,13 @@ namespace :translation do end desc "Create previews of translated emails" - task :preview_emails => :environment do - check_for_env_vars(['INFO_REQUEST_ID', - 'FOLLOW_UP_ID', - 'INCOMING_MESSAGE_ID', - 'COMMENT_ID', - 'TRACK_THING_ID', - 'DIR'], nil) + task preview_emails: :environment do + check_for_env_vars(%w[INFO_REQUEST_ID + FOLLOW_UP_ID + INCOMING_MESSAGE_ID + COMMENT_ID + TRACK_THING_ID + DIR], nil) info_request = InfoRequest.find(ENV['INFO_REQUEST_ID']) if info_request.outgoing_messages.empty? raise "Info request #{info_request.id} does not have any outgoing messages" @@ -148,10 +148,10 @@ namespace :translation do # track mailer xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], track_thing.track_query, - :sort_by_prefix => 'described_at', - :sort_by_ascending => true, - :collapse_by_prefix => nil, - :limit => 100) + sort_by_prefix: 'described_at', + sort_by_ascending: true, + collapse_by_prefix: nil, + limit: 100) event_digest_email = TrackMailer.event_digest(info_request.user, [[track_thing, xapian_object.results, @@ -159,11 +159,11 @@ namespace :translation do write_email(event_digest_email, 'Alerts on things the user is tracking', output_file) # user mailer - site_name = AlaveteliConfiguration::site_name + site_name = AlaveteliConfiguration.site_name reasons = { - :web => "", - :email => _("Then you can sign in to {{site_name}}", :site_name => site_name), - :email_subject => _("Confirm your account on {{site_name}}", :site_name => site_name) + web: "", + email: _("Then you can sign in to {{site_name}}", site_name: site_name), + email_subject: _("Confirm your account on {{site_name}}", site_name: site_name) } confirm_login_email = UserMailer.confirm_login(info_request.user, reasons, diff --git a/lib/tasks/usage.rb b/lib/tasks/usage.rb index 470f8997ed..8f760df83e 100644 --- a/lib/tasks/usage.rb +++ b/lib/tasks/usage.rb @@ -1,6 +1,6 @@ module Usage - def usage_message message + def usage_message(message) puts '' puts message puts '' @@ -10,15 +10,11 @@ def usage_message message def check_for_env_vars(env_vars, example) missing = [] env_vars.each do |env_var| - unless ENV[env_var] - missing << env_var - end + missing << env_var unless ENV[env_var] end - if !missing.empty? + unless missing.empty? usage = "Usage: This task requires #{env_vars.to_sentence} - missing #{missing.to_sentence}" - if example - usage += "\nExample: #{example}" - end + usage += "\nExample: #{example}" if example usage_message usage end end diff --git a/lib/tasks/users.rake b/lib/tasks/users.rake index 4ea8229cbc..cd353cf30b 100644 --- a/lib/tasks/users.rake +++ b/lib/tasks/users.rake @@ -20,7 +20,7 @@ namespace :users do end desc "Lists per domain stats" - task :stats_by_domain => :environment do + task stats_by_domain: :environment do raise "must supply a DOMAIN value" unless ENV["DOMAIN"] domain = ENV["DOMAIN"] from = ENV["START_DATE"] @@ -52,7 +52,7 @@ namespace :users do end desc "Bans all users for a specific domain" - task :ban_by_domain => :environment do + task ban_by_domain: :environment do raise "must supply a DOMAIN value" unless ENV["DOMAIN"] domain = ENV["DOMAIN"] from = ENV["START_DATE"] @@ -70,7 +70,7 @@ namespace :users do if input.downcase == "y" to_ban = UserStats.unbanned_by_domain(domain, from) count = to_ban. - update_all(:ban_text => "Banned for spamming") + update_all(ban_text: "Banned for spamming") p "#{count} accounts banned" else p "No action taken" @@ -85,7 +85,7 @@ namespace :users do FIELDS: A CSV list of User attributes to print (default: "id,name,email,activity") EOF - task :pro_activity => :environment do + task pro_activity: :environment do fields = if ENV['FIELDS'] ENV['FIELDS'].split(',').map(&:strip) @@ -99,9 +99,7 @@ namespace :users do end end_date = - if ENV['END_DATE'] - Time.zone.parse(ENV['END_DATE']).at_end_of_day - end + (Time.zone.parse(ENV['END_DATE']).at_end_of_day if ENV['END_DATE']) # Only auto-calculate missing dates if one has been provided without the # other diff --git a/lib/typeahead_search.rb b/lib/typeahead_search.rb index ac14a2522e..38c4e2f70c 100644 --- a/lib/typeahead_search.rb +++ b/lib/typeahead_search.rb @@ -34,13 +34,13 @@ def xapian_search def options { - :offset => (@page - 1) * @per_page, - :limit => @per_page, - :sort_by_prefix => nil, - :sort_by_ascending => true, - :collapse_by_prefix => collapse?, - :wildcard => @wildcard, - :model => @model + offset: (@page - 1) * @per_page, + limit: @per_page, + sort_by_prefix: nil, + sort_by_ascending: true, + collapse_by_prefix: collapse?, + wildcard: @wildcard, + model: @model } end @@ -58,9 +58,7 @@ def check_query end # don't run a search if there's no query - if @query.blank? - @run_search = false - end + @run_search = false if @query.blank? end diff --git a/lib/use_spans_for_errors.rb b/lib/use_spans_for_errors.rb index 55dc7fa853..ec394acc70 100644 --- a/lib/use_spans_for_errors.rb +++ b/lib/use_spans_for_errors.rb @@ -8,4 +8,4 @@ # # See http://dev.rubyonrails.org/ticket/2210 -ActionView::Base.field_error_proc = Proc.new { |html_tag, instance| %(#{html_tag}).html_safe } +ActionView::Base.field_error_proc = Proc.new { |html_tag, _instance| %(#{html_tag}).html_safe } diff --git a/lib/user_spam_scorer.rb b/lib/user_spam_scorer.rb index c20fe8b8ed..d61501609a 100644 --- a/lib/user_spam_scorer.rb +++ b/lib/user_spam_scorer.rb @@ -1,20 +1,20 @@ class UserSpamScorer DEFAULT_SCORE_MAPPINGS = { - :name_is_all_lowercase? => 1, - :name_is_one_word? => 1, - :name_includes_non_alpha_characters? => 3, - :name_is_garbled? => 5, - :email_from_suspicious_domain? => 5, - :email_from_spam_domain? => 8, - :email_from_spam_tld? => 3, - :name_is_spam_format? => 5, - :about_me_includes_currency_symbol? => 2, - :about_me_is_link_only? => 3, - :about_me_is_spam_format? => 1, - :about_me_includes_anchor_tag? => 1, - :about_me_already_exists? => 4, - :user_agent_is_suspicious? => 5, - :ip_range_is_suspicious? => 5 + name_is_all_lowercase?: 1, + name_is_one_word?: 1, + name_includes_non_alpha_characters?: 3, + name_is_garbled?: 5, + email_from_suspicious_domain?: 5, + email_from_spam_domain?: 8, + email_from_spam_tld?: 3, + name_is_spam_format?: 5, + about_me_includes_currency_symbol?: 2, + about_me_is_link_only?: 3, + about_me_is_spam_format?: 1, + about_me_includes_anchor_tag?: 1, + about_me_already_exists?: 4, + user_agent_is_suspicious?: 5, + ip_range_is_suspicious?: 5 }.freeze DEFAULT_CURRENCY_SYMBOLS = %w(£ $ € ¥ ¢).freeze diff --git a/lib/user_stats.rb b/lib/user_stats.rb index 7ea2d94af0..42a7cd7f51 100644 --- a/lib/user_stats.rb +++ b/lib/user_stats.rb @@ -64,7 +64,7 @@ def self.unbanned_by_domain(domain, start_date=nil) eligible = User. where("email LIKE ?", "%@#{domain}"). not_banned. - where.not(:id => User.with_role(:admin).pluck('users.id')) + where.not(id: User.with_role(:admin).pluck('users.id')) if start_date eligible.where("created_at >= ?", start_date) diff --git a/lib/world_foi_websites.rb b/lib/world_foi_websites.rb index 9dff21c045..822d66de8f 100644 --- a/lib/world_foi_websites.rb +++ b/lib/world_foi_websites.rb @@ -29,125 +29,125 @@ class WorldFOIWebsites def self.world_foi_websites world_foi_websites = [ - { :name => "WhatDoTheyKnow", - :country_name => "United Kingdom", - :country_iso_code => "GB", - :url => "https://www.whatdotheyknow.com" }, - { :name => "Ask The EU", - :country_name => "European Union", - :country_iso_code => "", - :url => "http://asktheeu.org" }, - { :name => "MuckRock.com", - :country_name => "United States of America", - :country_iso_code => "US", - :url => "http://www.muckrock.com" }, - { :name => "FYI", - :country_name => "New Zealand", - :country_iso_code => "NZ", - :url => "http://fyi.org.nz" }, - { :name => "Frag den Staat", - :country_name => "Deutschland", - :country_iso_code => "DE", - :url => "http://fragdenstaat.de" }, - { :name => "Queremos Saber", - :country_name => "Brasil", - :country_iso_code => "BR", - :url => "http://queremossaber.org.br" }, - { :name => "Ki Mit Tud", - :country_name => "Magyarország", - :country_iso_code => "HU", - :url => "http://kimittud.atlatszo.hu/" }, - { :name => "PravoDaSznam", - :country_name => "Bosna i Hercegovina", - :country_iso_code => "BA", - :url => "http://www.pravodaznam.ba/" }, - { :name => "Right To Know", - :country_name => "Australia", - :country_iso_code => "AU", - :url => "http://www.righttoknow.org.au" }, - { :name => "Informace pro Vsechny", - :country_name => "České Republiky", - :country_iso_code => "CZ", - :url => "http://www.infoprovsechny.cz" }, - { :name => "¿Qué Sabés?", - :country_name => "Uruguay", - :country_iso_code => "UY", - :url => "http://www.quesabes.org/" }, - { :name => "Nu Vă Supărați", - :country_name => "România", - :country_iso_code => "RO", - :url => "http://nuvasuparati.info/" }, - { :name => "Доступ до правди", - :country_name => "Україна", - :country_iso_code => "UA", - :url => "https://dostup.pravda.com.ua/" }, - { :name => "Ask Data", - :country_name => "מְדִינַת יִשְׂרָאֵל", - :country_iso_code => "IL", - :url => "http://askdata.org.il/" }, - { :name => "Слободен пристап", - :country_name => "Република Македонија", - :country_iso_code => "MK", - :url => "http://www.slobodenpristap.mk/" }, - { :name => "Imamo pravo znati", - :country_name => "Republika Hrvatska", - :country_iso_code => "HR", - :url => "http://imamopravoznati.org/" }, - { :name => 'Right2Know.my', - :country_name => 'Malaysia', - :country_iso_code => 'MY', - :url => "http://foi.sinarproject.org/" }, - { :name => 'Sobanukirwa', - :country_name => 'Rwanda', - :country_iso_code => 'RW', - :url => "https://sobanukirwa.rw/" }, - { :name => 'AccessInfo.hk', - :country_name => '香港', - :country_iso_code => 'HK', - :url => "https://accessinfo.hk/" }, - { :name => 'Ask Your Government Uganda', - :country_name => 'Uganda', - :country_iso_code => 'UG', - :url => "http://askyourgov.ug/" }, - { :name => 'Mimes Brønn', - :country_name => 'Norge', - :country_iso_code => 'NO', - :url => "https://www.mimesbronn.no/" }, - { :name => 'QueremoSaber', - :country_name => 'Paraguay', - :country_iso_code => 'PY', - :url => "https://www.queremosaber.org.py/" }, - { :name => 'Derecho a Preguntar', - :country_name => 'Nicaragua', - :country_iso_code => 'NI', - :url => "https://derechoapreguntar.org/" }, - { :name => 'InfoLib', - :country_name => 'Liberia', - :country_iso_code => 'LR', - :url => "http://infolib.org.lr/" }, - { :name => 'MaDada', - :country_name => 'France', - :country_iso_code => 'FR', - :url => "https://madada.fr/" }, - { :name => 'Handlingar', - :country_name => 'Sweden', - :country_iso_code => 'SE', - :url => "https://handlingar.se/" }, - { :name => 'VreauInfo', - :country_name => 'Moldova', - :country_iso_code => 'MD', - :url => "https://www.vreauinfo.md/" }, - { :name => 'Derecho al Dato', - :country_name => 'Argentina', - :country_iso_code => 'AR', - :url => 'https://derechoaldato.com.ar/' }, + { name: "WhatDoTheyKnow", + country_name: "United Kingdom", + country_iso_code: "GB", + url: "https://www.whatdotheyknow.com" }, + { name: "Ask The EU", + country_name: "European Union", + country_iso_code: "", + url: "http://asktheeu.org" }, + { name: "MuckRock.com", + country_name: "United States of America", + country_iso_code: "US", + url: "http://www.muckrock.com" }, + { name: "FYI", + country_name: "New Zealand", + country_iso_code: "NZ", + url: "http://fyi.org.nz" }, + { name: "Frag den Staat", + country_name: "Deutschland", + country_iso_code: "DE", + url: "http://fragdenstaat.de" }, + { name: "Queremos Saber", + country_name: "Brasil", + country_iso_code: "BR", + url: "http://queremossaber.org.br" }, + { name: "Ki Mit Tud", + country_name: "Magyarország", + country_iso_code: "HU", + url: "http://kimittud.atlatszo.hu/" }, + { name: "PravoDaSznam", + country_name: "Bosna i Hercegovina", + country_iso_code: "BA", + url: "http://www.pravodaznam.ba/" }, + { name: "Right To Know", + country_name: "Australia", + country_iso_code: "AU", + url: "http://www.righttoknow.org.au" }, + { name: "Informace pro Vsechny", + country_name: "České Republiky", + country_iso_code: "CZ", + url: "http://www.infoprovsechny.cz" }, + { name: "¿Qué Sabés?", + country_name: "Uruguay", + country_iso_code: "UY", + url: "http://www.quesabes.org/" }, + { name: "Nu Vă Supărați", + country_name: "România", + country_iso_code: "RO", + url: "http://nuvasuparati.info/" }, + { name: "Доступ до правди", + country_name: "Україна", + country_iso_code: "UA", + url: "https://dostup.pravda.com.ua/" }, + { name: "Ask Data", + country_name: "מְדִינַת יִשְׂרָאֵל", + country_iso_code: "IL", + url: "http://askdata.org.il/" }, + { name: "Слободен пристап", + country_name: "Република Македонија", + country_iso_code: "MK", + url: "http://www.slobodenpristap.mk/" }, + { name: "Imamo pravo znati", + country_name: "Republika Hrvatska", + country_iso_code: "HR", + url: "http://imamopravoznati.org/" }, + { name: 'Right2Know.my', + country_name: 'Malaysia', + country_iso_code: 'MY', + url: "http://foi.sinarproject.org/" }, + { name: 'Sobanukirwa', + country_name: 'Rwanda', + country_iso_code: 'RW', + url: "https://sobanukirwa.rw/" }, + { name: 'AccessInfo.hk', + country_name: '香港', + country_iso_code: 'HK', + url: "https://accessinfo.hk/" }, + { name: 'Ask Your Government Uganda', + country_name: 'Uganda', + country_iso_code: 'UG', + url: "http://askyourgov.ug/" }, + { name: 'Mimes Brønn', + country_name: 'Norge', + country_iso_code: 'NO', + url: "https://www.mimesbronn.no/" }, + { name: 'QueremoSaber', + country_name: 'Paraguay', + country_iso_code: 'PY', + url: "https://www.queremosaber.org.py/" }, + { name: 'Derecho a Preguntar', + country_name: 'Nicaragua', + country_iso_code: 'NI', + url: "https://derechoapreguntar.org/" }, + { name: 'InfoLib', + country_name: 'Liberia', + country_iso_code: 'LR', + url: "http://infolib.org.lr/" }, + { name: 'MaDada', + country_name: 'France', + country_iso_code: 'FR', + url: "https://madada.fr/" }, + { name: 'Handlingar', + country_name: 'Sweden', + country_iso_code: 'SE', + url: "https://handlingar.se/" }, + { name: 'VreauInfo', + country_name: 'Moldova', + country_iso_code: 'MD', + url: "https://www.vreauinfo.md/" }, + { name: 'Derecho al Dato', + country_name: 'Argentina', + country_iso_code: 'AR', + url: 'https://derechoaldato.com.ar/' } ] - return world_foi_websites + world_foi_websites end def self.by_code(code) - result = self.world_foi_websites.find { |x| x[:country_iso_code].downcase == code.downcase } - return result + result = world_foi_websites.find { |x| x[:country_iso_code].downcase == code.downcase } + result end def self.can_ask_the_eu?(code) diff --git a/lib/xapian_queries.rb b/lib/xapian_queries.rb index e95ea8ef0c..958df79191 100644 --- a/lib/xapian_queries.rb +++ b/lib/xapian_queries.rb @@ -20,10 +20,8 @@ def get_request_variety_from_params(params) varieties << ['variety:comment'] end end - if !varieties.empty? - query = " (#{varieties.join(' OR ')})" - end - return query + query = " (#{varieties.join(' OR ')})" unless varieties.empty? + query end def get_status_from_params(params) @@ -54,25 +52,23 @@ def get_status_from_params(params) if params[:latest_status].include? "gone_postal" statuses << ['latest_status:gone_postal'] end - if !statuses.empty? - query = " (#{statuses.join(' OR ')})" - end + query = " (#{statuses.join(' OR ')})" unless statuses.empty? end - return query + query end def get_date_range_from_params(params) query = "" - if params.has_key?(:request_date_after) && !params.has_key?(:request_date_before) + if params.key?(:request_date_after) && !params.key?(:request_date_before) params[:request_date_before] = Time.zone.now.strftime("%d/%m/%Y") query += " #{params[:request_date_after]}..#{params[:request_date_before]}" - elsif !params.has_key?(:request_date_after) && params.has_key?(:request_date_before) + elsif !params.key?(:request_date_after) && params.key?(:request_date_before) params[:request_date_after] = "01/01/2001" end - if params.has_key?(:request_date_after) + if params.key?(:request_date_after) query = " #{params[:request_date_after]}..#{params[:request_date_before]}" end - return query + query end def make_query_from_params(params) diff --git a/lib/yaml_compatibility.rb b/lib/yaml_compatibility.rb deleted file mode 100644 index 07096a3424..0000000000 --- a/lib/yaml_compatibility.rb +++ /dev/null @@ -1,102 +0,0 @@ -## -# Class to load YAML which includes legacy marshalled Ruby objects. -# -class YAMLCompatibility - def self.load(yaml, aliases: false, filename: nil, fallback: nil, - symbolize_names: false) - result = if Gem::Version.new(YAML::VERSION) >= Gem::Version.new('3.1.0') - YAML.parse(yaml, filename: filename) - else - YAML.parse(yaml, filename) - end - return fallback unless result - - result = visitor.accept(result) - symbolize_names!(result) if symbolize_names - result - end - - def self.visitor - class_loader = LegacyMapClassLoader.new - scanner = YAML::ScalarScanner.new(class_loader) - YAML::Visitors::ToRuby.new(scanner, class_loader) - end - - # :nodoc: - class LazyAttributeHash < ActiveModel::LazyAttributeHash - def key?(key) - delegate_hash.key?(key) || - (values && values.key?(key)) || - (types && types.key?(key)) - end - end - - # :nodoc: - class TimeZoneConverter - def init_with(_coder); end - end - - # :nodoc: - LegacyObject = Class.new - - # :nodoc: - class LegacyMapClassLoader < YAML::ClassLoader - private - - MAPPINGS = { - 'ActiveModel::LazyAttributeHash' => - 'YAMLCompatibility::LazyAttributeHash', - 'ActiveRecord::LazyAttributeHash' => - 'YAMLCompatibility::LazyAttributeHash', - - # Rails <5 - 'ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter' => - 'YAMLCompatibility::TimeZoneConverter', - 'ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Integer' => - 'ActiveModel::Type::Integer', - - # Rails 5.0 - 'ActiveModel::Type::Text' => - 'ActiveRecord::Type::Text', - - # Legacy classes - 'PublicBodyTag' => - 'YAMLCompatibility::LegacyObject', - - 'TMail::AddressHeader' => - 'YAMLCompatibility::LegacyObject', - 'TMail::Config' => - 'YAMLCompatibility::LegacyObject', - 'TMail::ContentDispositionHeader' => - 'YAMLCompatibility::LegacyObject', - 'TMail::ContentTransferEncodingHeader' => - 'YAMLCompatibility::LegacyObject', - 'TMail::ContentTypeHeader' => - 'YAMLCompatibility::LegacyObject', - 'TMail::DateTimeHeader' => - 'YAMLCompatibility::LegacyObject', - 'TMail::Mail' => - 'YAMLCompatibility::LegacyObject', - 'TMail::MessageIdHeader' => - 'YAMLCompatibility::LegacyObject', - 'TMail::MimeVersionHeader' => - 'YAMLCompatibility::LegacyObject', - 'TMail::ReceivedHeader' => - 'YAMLCompatibility::LegacyObject', - 'TMail::ReferencesHeader' => - 'YAMLCompatibility::LegacyObject', - 'TMail::ReturnPathHeader' => - 'YAMLCompatibility::LegacyObject', - 'TMail::SingleAddressHeader' => - 'YAMLCompatibility::LegacyObject', - 'TMail::StringPort' => - 'YAMLCompatibility::LegacyObject', - 'TMail::UnstructuredHeader' => - 'YAMLCompatibility::LegacyObject' - } - - def resolve(klassname) - super(MAPPINGS[klassname] || klassname) - end - end -end diff --git a/locale/af_ZA/app.po b/locale/af_ZA/app.po index cb8077a351..67242268ee 100644 --- a/locale/af_ZA/app.po +++ b/locale/af_ZA/app.po @@ -31,13 +31,14 @@ # Translators: # Translators: # Translators: +# Translators: # FOI Monkey, 2022 # FOI Monkey, 2022 msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: FOI Monkey, 2022\n" "Language-Team: Afrikaans (South Africa) (http://app.transifex.com/mysociety/al" @@ -445,6 +446,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -607,6 +611,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -670,6 +677,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -934,6 +944,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -1003,6 +1016,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1530,6 +1546,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2204,6 +2223,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Onthou my op hierdie rekanaar" @@ -2390,6 +2412,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2426,6 +2451,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2491,6 +2540,9 @@ msgstr "Meld af" msgid "Sign up" msgstr "Registreer" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2545,6 +2597,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2962,9 +3017,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3185,6 +3246,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3311,9 +3375,15 @@ msgstr "Vandag" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3660,6 +3730,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "Ja" @@ -3789,6 +3862,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4409,6 +4485,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/aln/app.po b/locale/aln/app.po index 22f9f9519b..4d917401c6 100644 --- a/locale/aln/app.po +++ b/locale/aln/app.po @@ -31,13 +31,14 @@ # Translators: # Translators: # Translators: +# Translators: # Valon , 2011 # Valon , 2011 msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Valon , 2011\n" "Language-Team: Albanian Gheg (http://app.transifex.com/mysociety/alaveteli/lan" @@ -438,6 +439,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -600,6 +604,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -663,6 +670,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -927,6 +937,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -996,6 +1009,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1523,6 +1539,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2197,6 +2216,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2383,6 +2405,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2419,6 +2444,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2484,6 +2533,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2538,6 +2590,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2955,9 +3010,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3178,6 +3239,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3304,9 +3368,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3653,6 +3723,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3782,6 +3855,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4402,6 +4478,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/app.pot b/locale/app.pot index 4ba73e0c8c..d81fbc0cae 100644 --- a/locale/app.pot +++ b/locale/app.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-10-09 01:10+0200\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -406,6 +406,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -568,6 +571,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -631,6 +637,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -895,6 +904,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -964,6 +976,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1491,6 +1506,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2165,6 +2183,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2351,6 +2372,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2387,6 +2411,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2452,6 +2500,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2506,6 +2557,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2923,9 +2977,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3146,6 +3206,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3272,9 +3335,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3621,6 +3690,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3750,6 +3822,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4370,6 +4445,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/ar/app.po b/locale/ar/app.po index 002343139b..a6abe272a6 100644 --- a/locale/ar/app.po +++ b/locale/ar/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Aladdin El-Haraty , 2012 # Aladdin El-Haraty , 2012 # Aladdin El-Haraty , 2012 @@ -50,7 +51,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: , 2013\n" "Language-Team: Arabic (http://app.transifex.com/mysociety/alaveteli/language/a" @@ -489,6 +490,9 @@ msgstr "يمكن ان تستند كل الخيارات اسفله على your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1609,6 +1625,9 @@ msgstr "آخر مطلب وقع الإطلاع عليه: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2296,6 +2315,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2485,6 +2507,9 @@ msgstr "البحث عن مساهماتك" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "ابعث متابعة " @@ -2521,6 +2546,30 @@ msgstr "ابعث رسالة ل {{user_name}} فقط لمشاهدة كيفية ا msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2586,6 +2635,9 @@ msgstr "تسجيل الخروج" msgid "Sign up" msgstr "اشترك" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2646,6 +2698,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3073,9 +3128,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "عدد المطالب التي بامكانك تقديمها في اليوم الواحد محدود, لاننا لاننا لا تريد ان تكثر على السلطات العامة الطلبات الغير ملائمة. ان كان لديك سبب وجيه لتسألهم الترفيع في العدد المحدد للطلبات في حالتك, الرجاء الاتصال بنا." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3305,6 +3366,9 @@ msgstr "" "سرعة رد السلطات على الطلبات , عدد الطلبات\n" "التي تسوجب ردا بريديا و اكثر ." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3437,9 +3501,15 @@ msgstr "اليوم" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "طلبات كثيرة جدا" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3808,6 +3878,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "اكتب طلبك بلغة بسيطة ودقيقة." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3937,6 +4010,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "لقد بلغت السقف الأقصى للطلبات الجديدة. المستخدمون محددون عادة ب {{max_requests_per_user_per_day}} طلب في كل 24 ساعة. ستتمكن من القيام بطلب جديد خلال{{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4580,6 +4656,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/bg/app.po b/locale/bg/app.po index 9b057ee1f4..f4815f0a2f 100644 --- a/locale/bg/app.po +++ b/locale/bg/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Anton Stoychev , 2013 # Anton Stoychev , 2013 # Liz Conlan , 2018 @@ -41,7 +42,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: louisecrow , 2014\n" "Language-Team: Bulgarian (http://app.transifex.com/mysociety/alaveteli/languag" @@ -482,6 +483,9 @@ msgstr "Всички опции по-долу могат да се използ msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -650,6 +654,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "Размножено заявление, създадено от {{info_request_user}} на {{date}}." +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Започващи с" @@ -713,6 +720,9 @@ msgstr " Спиране на някои известия от {{site_name}}" msgid "Cancel, return to your profile page" msgstr "Отказ и връщане в страницата на профила Ви" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Промяна на имейла в {{site_name}}" @@ -979,6 +989,9 @@ msgstr "Готово >>" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Сваляне на zip файл с цялата кореспонденция" @@ -1052,6 +1065,9 @@ msgstr "История на събитията" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Това, което напишете на тази страница, включително Вашето име,\n" @@ -1621,6 +1637,9 @@ msgstr "Последно гледано заявление: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2310,6 +2329,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2499,6 +2521,9 @@ msgstr "Търсене в допринесеното от Вас" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Изпращане на пояснително съобщение" @@ -2535,6 +2560,30 @@ msgstr "Изпращане на съобщение до {{user_name}} само msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Изпратено до един орган от {{info_request_user}} на {{date}}." @@ -2600,6 +2649,9 @@ msgstr "Изход" msgid "Sign up" msgstr "Регистриране" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2660,6 +2712,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3093,9 +3148,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Има ограничение на броя заявления на ден, които може да направите, понеже не желаем публичните органи да бъдат бомбардирани с голям брой неуместни заявления. Ако считате, че имате основателна причина да поискате вдигане на лимита във Вашия случай, молим, уведомете ни." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Все още няма нищо за показване." @@ -3324,6 +3385,9 @@ msgstr "" "бързината, с която органите отговарят на заявления, броят на заявленията,\n" "които изискват отговор по пощата и много други." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3458,9 +3522,15 @@ msgstr "Днес" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Твърде много заявления" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3827,6 +3897,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "Напишете заявлението си ясно и конкретно." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3956,6 +4029,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Вие достигнахте лимита за нови заявления. Потребителите обикновено са ограничени до {{max_requests_per_user_per_day}} заявления на всеки 24 часа. Ще можете да отправите друго заявление в {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4605,6 +4681,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/bs/app.po b/locale/bs/app.po index b65c95fdcc..51a1e51423 100644 --- a/locale/bs/app.po +++ b/locale/bs/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Krule , 2011 # BORIS , 2011 # BORIS , 2011 @@ -44,7 +45,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: vedad , 2011\n" "Language-Team: Bosnian (http://app.transifex.com/mysociety/alaveteli/language/" @@ -472,6 +473,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -640,6 +644,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Počevši sa" @@ -703,6 +710,9 @@ msgstr "Poništi neka {{site_name}} upozorenja" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Promijeniti e-mail na {{site_name}}" @@ -969,6 +979,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Preuzmite svu korespondenciju u zip fajlu" @@ -1040,6 +1053,9 @@ msgstr "Prikaz prošlih događanja" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Sve što unesete na ovu stranicu, uključujući Vaše ime, \n" @@ -1602,6 +1618,9 @@ msgstr "Zadnji pregledani zahtjev: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2289,6 +2308,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2475,6 +2497,9 @@ msgstr "Pretražite Vaše doprinose" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2511,6 +2536,30 @@ msgstr "Pošalji poruku {{user_name}} samo da vidite kako radi" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2576,6 +2625,9 @@ msgstr "Odjavite se" msgid "Sign up" msgstr "Registrujte se" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2636,6 +2688,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3069,9 +3124,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3294,6 +3355,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3426,9 +3490,15 @@ msgstr "Danas" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3795,6 +3865,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "Pišite Vaš zahtjev jednostavnim, preciznim jezikom." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3924,6 +3997,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4554,6 +4630,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/ca/app.po b/locale/ca/app.po index b2a9c0961f..2e2e32aa8c 100644 --- a/locale/ca/app.po +++ b/locale/ca/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # David Cabo , 2012,2014 # ecapfri , 2012 # ecapfri , 2012 @@ -43,7 +44,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: mmtarres , 2012\n" "Language-Team: Catalan (http://app.transifex.com/mysociety/alaveteli/language/" @@ -487,6 +488,9 @@ msgstr "All the options below can use variety or latest msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -655,6 +659,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Començant per" @@ -718,6 +725,9 @@ msgstr "Cancelar alertas de {{site_name}}" msgid "Cancel, return to your profile page" msgstr "Cancelar, volver a mi perfil" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Cambiar correo en {{site_name}}" @@ -986,6 +996,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Descarregar un fitxer ZIP amb tota la correspondència" @@ -1055,6 +1068,9 @@ msgstr "Historial de eventos" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Tot el que escriguis en aquesta pàgina, incloent el teu nom, \n" @@ -1621,6 +1637,9 @@ msgstr "Última solicitud vista: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2309,6 +2328,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2498,6 +2520,9 @@ msgstr "Busca tus aportaciones" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Enviar una resposta" @@ -2534,6 +2559,30 @@ msgstr "Envia un missatge a {{user_name}} sólo para ver cómo funciona" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2599,6 +2648,9 @@ msgstr "Tancar sessió" msgid "Sign up" msgstr "Registra't" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2659,6 +2711,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3091,9 +3146,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Hay un límite en el número de solicitudes que puedes hacer en un día, porque no queremos que los organismos públicos reciban un número exagerado de solicitudes mal formuladas. Si necesitas que el límite no se aplique en tu caso, por favor contacta con nosotros." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3322,6 +3383,9 @@ msgstr "" "estadísticas sobre por ejemplo la velocidad de respuesta de los organismos o\n" "el número de solicitudes que piden usar correo ordinario." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3454,9 +3518,15 @@ msgstr "Hoy" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3819,6 +3889,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "Escriu la teva sol·licitud en un llenguatge senzill i clar." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3948,6 +4021,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Has alcanzado el límite de solicitudes en un día, que es de {{max_requests_per_user_per_day}} solicitudes en un plazo de 24 horas. Podrás enviar una nueva solicitud en {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4591,6 +4667,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/ckb/app.po b/locale/ckb/app.po index cb76b51a19..80dab25c12 100644 --- a/locale/ckb/app.po +++ b/locale/ckb/app.po @@ -31,11 +31,12 @@ # Translators: # Translators: # Translators: +# Translators: msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Graeme Porteous \n" "Language-Team: Central Kurdish (http://app.transifex.com/mysociety/alaveteli/l" @@ -436,6 +437,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -598,6 +602,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -661,6 +668,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -925,6 +935,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -994,6 +1007,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1521,6 +1537,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2195,6 +2214,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2381,6 +2403,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2417,6 +2442,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2482,6 +2531,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2536,6 +2588,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2953,9 +3008,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3176,6 +3237,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3302,9 +3366,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3651,6 +3721,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3780,6 +3853,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4400,6 +4476,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/cs/app.po b/locale/cs/app.po index b565aa0768..3a3db62edf 100644 --- a/locale/cs/app.po +++ b/locale/cs/app.po @@ -31,6 +31,8 @@ # Translators: # Translators: # Translators: +# Translators: +# Appukonrad , 2012 # Appukonrad , 2012 # Graeme Porteous , 2021 # Hana Hunt , 2016-2018,2020-2021 @@ -41,6 +43,7 @@ # janakneschke , 2013 # janakneschke , 2012-2013 # janakneschke , 2013 +# Jiří Podhorecký, 2021 # Appukonrad , 2012,2015-2017 # Jiří Podhorecký, 2021-2022 # josefpospisil , 2012 @@ -57,7 +60,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Jiří Podhorecký, 2021\n" "Language-Team: Czech (http://app.transifex.com/mysociety/alaveteli/language/cs" @@ -492,6 +495,9 @@ msgstr "Všechny níže uvedené možnosti variety or l msgid "All time" msgstr "Vždy" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "Nejlepší hráči" @@ -656,6 +662,9 @@ msgstr "Odstraněno s těchto stránek" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "Dávka vytvořena {{info_request_user}} dne {{date}}." +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Začínající na" @@ -719,6 +728,9 @@ msgstr "Zrušte tato upozornění stránek {{site_name}}" msgid "Cancel, return to your profile page" msgstr "Zrušit, návrat zpět do stránky s profilem" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Změnit e-mail na stránkách {{site_name}}" @@ -993,6 +1005,9 @@ msgstr "Hotovo >>" msgid "Download Data" msgstr "Stažená data" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Stáhnout zazipovaný soubor celé korespondence" @@ -1064,6 +1079,9 @@ msgstr "Historie případu" msgid "Every citizen has the right to access information held by public authorities." msgstr "Každý občan má právo na přístup k informacím veřejných institucí" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "Veškeré informace, které vložíte na tuto stránku, včetně vašeho jména, budou trvale uveřejněny na tomto webu." @@ -1614,6 +1632,9 @@ msgstr "Naposled prohlížený dotaz: {{request_url}}" msgid "Latest" msgstr "Nejnovější" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Zjistěte více →" @@ -2299,6 +2320,9 @@ msgstr "Nařízení" msgid "Rejected" msgstr "Zamítnuto" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Zapamatovat mé údaje (zašrktněte, pokud chcete být déle přihlášeni; nezaškrtávejte, pokud jste na veřejně přístupném počítači)." @@ -2488,6 +2512,9 @@ msgstr "Prohledávat vlastní příspěvky" msgid "Section" msgstr "Sekce" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Odpovědět" @@ -2524,6 +2551,30 @@ msgstr "Vznést dotaz na uživatele {{user_name}}. Tímto způsobem si můžete msgid "Sending..." msgstr "Odesílá se..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Odešlete {{authority_count}} instituci od {{info_request_user}} dne {{date}}." @@ -2591,6 +2642,9 @@ msgstr "Odhlásit" msgid "Sign up" msgstr "Registrovat" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2650,6 +2704,9 @@ msgstr "Omlouváme se, teď nelze přídávat nové komentáře. Prosím zkuste msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "Omlouváme se, teď nelze poslat vaši žádost. Prosím zkuste to později. " @@ -3079,9 +3136,15 @@ msgstr "Tuto stránku používá více než jedna osoba s tímt msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Počet dotazů za jeden den je limitován. Nechceme, aby byly instituce bombardovány velkým množstvím nerelevantních dotazů. Pokud máte dobrý důvod, proč by měl být váš limit navýšen, prosímekontaktujte nás." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Zatím tu nic není" @@ -3310,6 +3373,9 @@ msgstr "Sekce se statistickými informacemi o institucích je v současnosti v t msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "Tato tabulka ukazuje technické detaily související s tímto dotazem vzneseným na stránkách {{site_name}}. Tento přehled lze použít k analýze rychlosti, s jakou instituce odpovídají na dotazy, počtu dotazů, které byly zodpovězeny poštou atd. " +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "Tomuto uživateli byl zablokován přístup na stránky {{site_name}} " @@ -3442,9 +3508,15 @@ msgstr "Dnes" msgid "Too many annotations" msgstr "Příliš mnoho poznámek" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Příliš mnoho dotazů" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Nejlepší hráči" @@ -3813,6 +3885,9 @@ msgstr "" "Svůj dotaz formulujte v jasných bodech. \n" "Pokud žádáte o více nesouvisejících informací, rozdělte je do více dotazů. " +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "Ano" @@ -3948,6 +4023,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Dosáhli jste početního limitu stanoveného pro nové dotazy. Uživatelé mohou podat {{max_requests_per_user_per_day}} dotazů během 24 hodin. Nový dotaz můžete podat za {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "Opustili jste tento projekt" @@ -4621,6 +4699,11 @@ msgstr[1] "{{number_of_comments}} připomínky" msgstr[2] "{{number_of_comments}} připomínek" msgstr[3] "{{number_of_comments}} připomínek" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} dotaz" diff --git a/locale/cy/app.po b/locale/cy/app.po index 7b712754b9..29dade8740 100644 --- a/locale/cy/app.po +++ b/locale/cy/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Cymrodor , 2014,2017 # Cymrodor , 2014 # skenaja , 2011-2012 @@ -54,7 +55,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: PerryX , 2013\n" "Language-Team: Welsh (http://app.transifex.com/mysociety/alaveteli/language/cy" @@ -463,6 +464,9 @@ msgstr "Gall yr holl opsiynau isod defnyddio variety neu >" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Lawrlwytho ffeil zip o bob gohebiaeth" @@ -1021,6 +1034,9 @@ msgstr "Hanes y digwyddiad" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "Dangosir popeth yr ydych yn rhoi i mewn ar y dudalen hon, gan gynnwys eich enw, yn gyhoeddus ar y wefan hon am byth (pam?)." @@ -1556,6 +1572,9 @@ msgstr "Y cais diwethaf edrychwyd arno: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Dysgu mwy →" @@ -2230,6 +2249,9 @@ msgstr "" msgid "Rejected" msgstr "Gwrthodwyd" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2416,6 +2438,9 @@ msgstr "Chwilio eich cyfraniadau" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Anfon neges ddilynol" @@ -2452,6 +2477,30 @@ msgstr "Anfon neges i {{user_name}} dim ond i weld sut mae'n gweithio" msgid "Sending..." msgstr "Yn anfon..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Anfonwyd at un awdurdod gan {{info_request_user}} ar {{date}}." @@ -2519,6 +2568,9 @@ msgstr "Allgofnodwch" msgid "Sign up" msgstr "Cofrestrwch" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2573,6 +2625,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2990,9 +3045,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Mae cyfyngiad ar y nifer o geisiadau y gallwch eu gwneud mewn diwrnod, oherwydd nid ydym am i awdurdodau cyhoeddus gael eu peledu gyda nifer fawr o geisiadau amhriodol. Os ydych yn teimlo bod gennych reswm da dros ofyn i'r terfyn gael ei godi yn eich achos chi, cysylltwch â ni." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Does dim i'w ddangos eto." @@ -3215,6 +3276,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "Mae'r tabl hwn yn dangos manylion technegol y digwyddiadau mewnol a ddigwyddodd i'r cais hwn ar {{site_name}}. Gallai hwn gael ei ddefnyddio i gynhyrchu gwybodaeth am ba mor gyflym y mae awdurdodau yn ymateb i geisiadau, nifer y ceisiadau sy'n gofyn am ymateb drwy'r post a llawer mwy." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3341,9 +3405,15 @@ msgstr "Heddiw" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Gormod o geisiadau" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3690,6 +3760,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "Ysgrifennwch eich cais mewn iaith syml, gryno." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3819,6 +3892,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Rydych chi wedi cyrraedd y terfyn cyfradd ar geisiadau newydd. Fel arfer cyfyngir defnyddwyr i {{max_requests_per_user_per_day}} cais mewn unrhyw gyfnod treigl 24-awr. Byddwch yn gallu gwneud cais arall ymhen {{ can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4455,6 +4531,11 @@ msgstr[1] "{{number_of_comments}} sylw" msgstr[2] "{{number_of_comments}} sylw" msgstr[3] "{{number_of_comments}} sylw" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} cais" diff --git a/locale/de/app.po b/locale/de/app.po index a4bcf5fdc6..d0bf72b7c5 100644 --- a/locale/de/app.po +++ b/locale/de/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # andreas.pavlou , 2016 # andreas.pavlou , 2016 # arne , 2015-2016 @@ -48,7 +49,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: stefanw , 2011\n" "Language-Team: German (http://app.transifex.com/mysociety/alaveteli/language/d" @@ -478,6 +479,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -644,6 +648,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Mit Anfangsbuchstabe" @@ -707,6 +714,9 @@ msgstr "Einige Benachrichtigungen für {{site_name}} abbestellen" msgid "Cancel, return to your profile page" msgstr "Abbrechen, zurück zur Profilseite" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Email ändern auf {{site_name}}" @@ -973,6 +983,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Laden Sie eine Zip-Datei des gesamten Schriftverkehrs herunter." @@ -1044,6 +1057,9 @@ msgstr "Verlaufsübersicht" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Jegliche auf dieser Seite eingegebene Information, inklusive Ihrem Namen, ⏎ wird\n" @@ -1581,6 +1597,9 @@ msgstr "Zuletzt angesehene Anfrage: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Mehr erfahren" @@ -2258,6 +2277,9 @@ msgstr "" msgid "Rejected" msgstr "Abgelehnt" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Login speichern (Sie bleiben eingeloggt. Nutzen Sie diese Funktion nicht an öffentlichen Computern) " @@ -2447,6 +2469,9 @@ msgstr "Suchen Sie Ihre Beiträge" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Nachfrage senden" @@ -2483,6 +2508,30 @@ msgstr "Nachricht senden an {{user_name}} um zu sehen wie es funktioniert" msgid "Sending..." msgstr "Senden..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2548,6 +2597,9 @@ msgstr "Ausloggen" msgid "Sign up" msgstr "Benutzerkonto erstellen" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2604,6 +2656,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3021,9 +3076,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3246,6 +3307,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3374,9 +3438,15 @@ msgstr "Heute" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Zu viele Anfragen" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3726,6 +3796,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "Formulieren Sie Ihre Anfrage in schlicht und präzise ." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3855,6 +3928,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4484,6 +4560,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/el/app.po b/locale/el/app.po index 008d14dcba..81dd461146 100644 --- a/locale/el/app.po +++ b/locale/el/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Andreas Nedelkos , 2017 # Graeme Porteous , 2021 # Maria Nathanail , 2021 @@ -42,7 +43,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: ΜΑΡΙΑ ΝΑΘΑΝΑΗΛ , 2021\n" "Language-Team: Greek (http://app.transifex.com/mysociety/alaveteli/language/el" @@ -453,6 +454,9 @@ msgstr "Όλες οι επιλογές παρακάτω μπορούν να χρ msgid "All time" msgstr "Όλων των εποχών" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "Καλύτεροι παίκτες όλων των εποχών" @@ -615,6 +619,9 @@ msgstr "Έχει εκδιωχτεί από αυτό το site" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "Παρτίδα που δημιουργήθηκε από {{info_request_user}} στις {{date}}." +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Ξεκινώντας με" @@ -678,6 +685,9 @@ msgstr "Ακυρώστε κάποιες ειδοποιήσεις από το {{s msgid "Cancel, return to your profile page" msgstr "Ακυρώστε, επιστρέψτε στη σελίδα του προφίλ σας" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Αλλάξτε email στο {{site_name}}" @@ -942,6 +952,9 @@ msgstr "Ολοκληρώθηκε >>" msgid "Download Data" msgstr "Κατεβάστε δεδομένα" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Κατεβάστε ένα αρχείο zip με όλη την αλληλογραφία" @@ -1011,6 +1024,9 @@ msgstr "Ιστορικό συμβάντων" msgid "Every citizen has the right to access information held by public authorities." msgstr "Κάθε πολίτης έχει το δικαίωμα να αποκτήσει πληροφορίες από δημόσιους οργανισμούς." +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "Οτιδήποτε εισάγετε σε αυτή την σελίδα, συμπεριλαμβανομένου του ονόματός σας, θα εμφανίζετε δημόσια σε αυτή την ιστοσελίδα για πάντα" @@ -1543,6 +1559,9 @@ msgstr "Τελευταία αίτηση που είδατε: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Μάθετε περισσότερα →" @@ -2217,6 +2236,9 @@ msgstr "" msgid "Rejected" msgstr "Έχει απορριφθεί" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Να με θυμάσαι (σας κρατά συνδεδεμένο για μεγαλύτερο χρονικό διάστημα, μην το χρησιμοποιείτε σε δημόσιο υπολογιστή)" @@ -2403,6 +2425,9 @@ msgstr "Αναζητήστε τις συνεισφορές σας" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Στείλτε ένα followup" @@ -2439,6 +2464,30 @@ msgstr "Αποστολή μηνύματος στον {{user_name}} για να msgid "Sending..." msgstr "Αποστολή..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Εστάλη στις αρχές από {{info_request_user}} στις {{date}}." @@ -2504,6 +2553,9 @@ msgstr "Αποσύνδεση" msgid "Sign up" msgstr "Δημιουργία λογαριασμού" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2558,6 +2610,9 @@ msgstr "Λυπούμαστε, αυτή τη στιγμή είναι αδύνατ msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "Λυπούμαστε, αυτή τη στιγμή δεν είναι δυνατόν να σταλεί το αίτημά σας. Παρακαλούμε δοκιμάστε ξανά αργότερα. " @@ -2975,9 +3030,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Υπάρχει ένα όριο στον αριθμό αιτημάτων που μπορείτε να κάνετε σε μια μέρα, γιατί δεν θέλουμε οι δημόσιες αρχές να βομβαρδίζονται με μεγάλο αριθμό ανάρμοστων αιτημάτων. Αν πιστεύετε ότι έχετε καλό λόγο να ζητήσετε αύξηση του ορίου στην περίπτωσή σας, παρακαλούμε επικοινωνήστε ." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Δεν υπάρχει τίποτα για να εμφανιστεί ακόμα." @@ -3198,6 +3259,9 @@ msgstr "Αυτό το τμήμα σχετικά με τις στατιστικέ msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "Αυτός ο πίνακας δείχνει τις τεχνικές λεπτομέρειες των εσωτερικών διεργασιών που συνέβησαν με αυτό το αίτημα στο {{site_name}}. Αυτό θα μπορούσε να παρέχει πληροφορίες σχετικά με την ταχύτητα με την οποία οι αρχές ανταποκρίνονται στα αιτήματα, τον αριθμό των αιτήσεων που απαιτούν ταχυδρομική απάντηση και πολλά άλλα." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "Ο χρήστης αυτός έχει τεθεί σε αναστολή από το {{site_name}}" @@ -3324,9 +3388,15 @@ msgstr "Σήμερα" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Πάρα πολλά αιτήματα" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Κορυφαίοι πρόσφατοι παίκτες" @@ -3673,6 +3743,9 @@ msgstr "Γράψτε ένα απαντητικό μήνυμα για το Αίτ msgid "Write your request in simple, precise language." msgstr "Γράψτε ένα αίτημα σε απλή, συγκεκριμένη γλώσσα ." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "Ναι" @@ -3802,6 +3875,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Φτάσατε το όριο νέων αιτημάτων. Οι χρήστες/-ριες συνήθως περιορίζονται σε {{max_requests_per_user_per_day}} αιτήματα σε κάθε 24ωρο. Θα μπορείτε να καταθέσετε νέο αίτημα σε {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "Εγκαταλείψατε το σχέδιο " @@ -4422,6 +4498,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "{{number_of_comments}} σχόλιο" msgstr[1] "{{number_of_comments}} σχόλια" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} αίτηση" diff --git a/locale/en/app.po b/locale/en/app.po index 90b54a8b0c..5b9dccfa54 100644 --- a/locale/en/app.po +++ b/locale/en/app.po @@ -35,7 +35,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Graeme Porteous \n" "Language-Team: English (http://www.transifex.com/mysociety/alaveteli/language/" @@ -446,6 +446,9 @@ msgstr "All the options below can use variety or latest msgid "All time" msgstr "All time" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "All time best players" @@ -608,6 +611,9 @@ msgstr "Banned from this site" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "Batch created by {{info_request_user}} on {{date}}." +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Beginning with" @@ -671,6 +677,9 @@ msgstr "Cancel some {{site_name}} alerts" msgid "Cancel, return to your profile page" msgstr "Cancel, return to your profile page" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Change email on {{site_name}}" @@ -935,6 +944,9 @@ msgstr "Done >>" msgid "Download Data" msgstr "Download Data" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Download a zip file of all correspondence" @@ -1004,6 +1016,9 @@ msgstr "Event history" msgid "Every citizen has the right to access information held by public authorities." msgstr "Every citizen has the right to access information held by public authorities." +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" @@ -1531,6 +1546,9 @@ msgstr "Last request viewed: {{request_url}}" msgid "Latest" msgstr "Latest" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Learn more →" @@ -2205,6 +2223,9 @@ msgstr "Regulation" msgid "Rejected" msgstr "Rejected" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Remember me (keeps you signed in longer; do not use on a public computer)" @@ -2391,6 +2412,9 @@ msgstr "Search your contributions" msgid "Section" msgstr "Section" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Send a followup" @@ -2427,6 +2451,30 @@ msgstr "Send message to {{user_name}} just to see how it works" msgid "Sending..." msgstr "Sending..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Sent to one authority by {{info_request_user}} on {{date}}." @@ -2492,6 +2540,9 @@ msgstr "Sign out" msgid "Sign up" msgstr "Sign up" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." @@ -2546,6 +2597,9 @@ msgstr "Sorry, we're currently unable to add your annotation. Please try again l msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "Sorry, we're currently unable to create your account. Please try again later." +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "Sorry, we're currently unable to send your request. Please try again later." @@ -2963,9 +3017,15 @@ msgstr "There is more than one person who uses this site and ha msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "There is nothing to display yet." @@ -3186,6 +3246,9 @@ msgstr "This section on public body statistics is currently experimental, so the msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "This user has been suspended from {{site_name}} " @@ -3312,9 +3375,15 @@ msgstr "Today" msgid "Too many annotations" msgstr "Too many annotations" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Too many requests" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Top recent players" @@ -3661,6 +3730,9 @@ msgstr "Write your FOI follow up message to {{authority_name}}" msgid "Write your request in simple, precise language." msgstr "Write your request in simple, precise language." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "Yes" @@ -3790,6 +3862,9 @@ msgstr "You have hit the rate limit on annotations. Users are ordinarily limited msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "You have left the project." @@ -4410,6 +4485,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "{{number_of_comments}} comment" msgstr[1] "{{number_of_comments}} comments" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} request" diff --git a/locale/en_HK/app.po b/locale/en_HK/app.po index 2f652f8e81..5cab7d3019 100644 --- a/locale/en_HK/app.po +++ b/locale/en_HK/app.po @@ -31,11 +31,12 @@ # Translators: # Translators: # Translators: +# Translators: msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Graeme Porteous \n" "Language-Team: English (Hong Kong) (http://app.transifex.com/mysociety/alavete" @@ -436,6 +437,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -598,6 +602,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -661,6 +668,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -925,6 +935,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -994,6 +1007,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1521,6 +1537,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2195,6 +2214,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2381,6 +2403,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2417,6 +2442,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2482,6 +2531,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2536,6 +2588,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2953,9 +3008,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3176,6 +3237,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3302,9 +3366,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3651,6 +3721,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3780,6 +3853,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4400,6 +4476,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/en_IE/app.po b/locale/en_IE/app.po index f193229767..b3e2d59be4 100644 --- a/locale/en_IE/app.po +++ b/locale/en_IE/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # John Cross , 2012 # handelaar , 2011 # John Cross , 2012 @@ -40,7 +41,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: John Cross , 2012\n" "Language-Team: English (Ireland) (http://app.transifex.com/mysociety/alaveteli" @@ -441,6 +442,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -603,6 +607,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -666,6 +673,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -930,6 +940,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -999,6 +1012,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1526,6 +1542,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2200,6 +2219,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2386,6 +2408,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2422,6 +2447,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2487,6 +2536,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2541,6 +2593,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2958,9 +3013,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3181,6 +3242,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3307,9 +3371,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3656,6 +3726,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3785,6 +3858,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4405,6 +4481,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/en_RW/app.po b/locale/en_RW/app.po index 06a689aad5..338c5f2fc7 100644 --- a/locale/en_RW/app.po +++ b/locale/en_RW/app.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2018-12-21 12:21+0000\n" "Last-Translator: Liz Conlan \n" "Language-Team: LANGUAGE \n" @@ -418,6 +418,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -580,6 +583,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -643,6 +649,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -907,6 +916,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -976,6 +988,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1512,6 +1527,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2186,6 +2204,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2375,6 +2396,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2411,6 +2435,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2476,6 +2524,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2530,6 +2581,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2952,9 +3006,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "There is a limit on the number of requests you can make in a day, because we don’t want public agencies to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3179,6 +3239,9 @@ msgstr "" "the speed with which agencies respond to requests, the number of requests\n" "which require a postal response and much more." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3305,9 +3368,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3654,6 +3723,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3783,6 +3855,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4403,6 +4478,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/en_UG/app.po b/locale/en_UG/app.po index f7b4d2ee3c..40439d7377 100644 --- a/locale/en_UG/app.po +++ b/locale/en_UG/app.po @@ -31,12 +31,13 @@ # Translators: # Translators: # Translators: +# Translators: # Liz Conlan , 2018 msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Liz Conlan , 2018\n" "Language-Team: English (Uganda) (http://app.transifex.com/mysociety/alaveteli/" @@ -448,6 +449,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -610,6 +614,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -673,6 +680,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -937,6 +947,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -1006,6 +1019,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1542,6 +1558,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2216,6 +2235,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2405,6 +2427,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2441,6 +2466,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2506,6 +2555,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2560,6 +2612,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2982,9 +3037,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "There is a limit on the number of requests you can make in a day, because we don’t want public agencies to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3209,6 +3270,9 @@ msgstr "" "the speed with which agencies respond to requests, the number of requests\n" "which require a postal response and much more." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3335,9 +3399,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3684,6 +3754,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3813,6 +3886,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4433,6 +4509,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/en_US/app.po b/locale/en_US/app.po index f87cc98e5d..0cb3b8f217 100644 --- a/locale/en_US/app.po +++ b/locale/en_US/app.po @@ -31,11 +31,12 @@ # Translators: # Translators: # Translators: +# Translators: msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Graeme Porteous \n" "Language-Team: English (United States) (http://app.transifex.com/mysociety/ala" @@ -436,6 +437,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -598,6 +602,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -661,6 +668,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -925,6 +935,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -994,6 +1007,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1521,6 +1537,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2195,6 +2214,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2381,6 +2403,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2417,6 +2442,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2482,6 +2531,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2536,6 +2588,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2953,9 +3008,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3176,6 +3237,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3302,9 +3366,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3651,6 +3721,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3780,6 +3853,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4400,6 +4476,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/es/app.po b/locale/es/app.po index c989e1d80c..ef126ae689 100644 --- a/locale/es/app.po +++ b/locale/es/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Anatoli Pena , 2017 # Anatoli Pena , 2017 # Anatoli Pena , 2017 @@ -61,7 +62,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: vickyanderica , 2011\n" "Language-Team: Spanish (http://app.transifex.com/mysociety/alaveteli/language/" @@ -505,6 +506,9 @@ msgstr "All the options below can use variety or latest msgid "All time" msgstr "Todo el tiempo" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "Los mejores jugadores de todos los tiempos. " @@ -673,6 +677,9 @@ msgstr "Vedado el ingreso al sitio" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "Lote creado por {{info_request_user}} el {{date}}." +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Comenzando por" @@ -736,6 +743,9 @@ msgstr "Cancelar alertas de {{site_name}}" msgid "Cancel, return to your profile page" msgstr "Cancelar, volver a mi perfil" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Cambiar correo en {{site_name}}" @@ -1004,6 +1014,9 @@ msgstr "Hecho >>" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Descarga un fichero ZIP con toda la correspondencia" @@ -1075,6 +1088,9 @@ msgstr "Historial de eventos" msgid "Every citizen has the right to access information held by public authorities." msgstr "Todos los ciudadanos tienen el derecho a acceder a la información que tiene los organismos y autoridades públicas." +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Todo lo que escribas en esta página, incluyendo tu nombre, \n" @@ -1649,6 +1665,9 @@ msgstr "Última solicitud vista: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Conoce más →" @@ -2337,6 +2356,9 @@ msgstr "" msgid "Rejected" msgstr "Rechazada" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" "Recuérdame (mantiene la sesión abierta;\n" @@ -2528,6 +2550,9 @@ msgstr "Busca tus aportaciones" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Mandar una respuesta" @@ -2564,6 +2589,30 @@ msgstr "Enviar un mensaje a {{user_name}} sólo para ver cómo funciona" msgid "Sending..." msgstr "Enviando..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Enviada a un organismo por {{info_request_user}} el {{date}}." @@ -2630,6 +2679,9 @@ msgstr "Cerrar sesión" msgid "Sign up" msgstr "Registrarse" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2690,6 +2742,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3123,9 +3178,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Hay un límite en el número de solicitudes que puedes hacer en un día, porque no queremos que los organismos públicos reciban un número exagerado de solicitudes mal formuladas. Si necesitas que el límite no se aplique en tu caso, por favor contacta con nosotros." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "No hay nada que mostrar aún." @@ -3355,6 +3416,9 @@ msgstr "" "estadísticas sobre por ejemplo la velocidad de respuesta de los organismos o\n" "el número de solicitudes que piden usar correo ordinario." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3487,9 +3551,15 @@ msgstr "Hoy" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Demasiados pedidos" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Los mejores jugadores recientes" @@ -3856,6 +3926,9 @@ msgstr "Escribe tu mensaje de seguimiento a {{authority_name}}" msgid "Write your request in simple, precise language." msgstr "Escribe tu solicitud en un lenguaje sencillo y claro." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3985,6 +4058,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Has alcanzado el límite de solicitudes en un día, que es de {{max_requests_per_user_per_day}} solicitudes en un plazo de 24 horas. Podrás enviar una nueva solicitud en {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4639,6 +4715,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} solicitudes." diff --git a/locale/es_AR/app.po b/locale/es_AR/app.po index b6f7a1ebd4..f967a24479 100644 --- a/locale/es_AR/app.po +++ b/locale/es_AR/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Anatoli Pena , 2017 # andreas.pavlou , 2015,2017 # Fabrizio Scrollini , 2012 @@ -50,7 +51,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Victor Diaz , 2014\n" "Language-Team: Spanish (Argentina) (http://app.transifex.com/mysociety/alavete" @@ -494,6 +495,9 @@ msgstr "All the options below can use variety or latest msgid "All time" msgstr "Todo el tiempo" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "Los mejores jugadores de todos los tiempos. " @@ -662,6 +666,9 @@ msgstr "Vedado el ingreso al sitio" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "Lote creado por {{info_request_user}} el {{date}}." +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Comenzando por" @@ -725,6 +732,9 @@ msgstr "Cancelar alertas de {{site_name}}" msgid "Cancel, return to your profile page" msgstr "Cancelar, volver a mi perfil" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Cambiar correo en {{site_name}}" @@ -993,6 +1003,9 @@ msgstr "Hecho >>" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Descarga un fichero ZIP con toda la correspondencia" @@ -1064,6 +1077,9 @@ msgstr "Historial de eventos" msgid "Every citizen has the right to access information held by public authorities." msgstr "Todos los ciudadanos tienen el derecho a acceder a la información que tiene los organismos y autoridades públicas." +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Todo lo que escribas en esta página, incluyendo tu nombre, \n" @@ -1638,6 +1654,9 @@ msgstr "Última solicitud vista: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Conoce más →" @@ -2326,6 +2345,9 @@ msgstr "" msgid "Rejected" msgstr "Rechazada" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" "Recuérdame (mantiene la sesión abierta;\n" @@ -2517,6 +2539,9 @@ msgstr "Busca tus aportaciones" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Mandar una respuesta" @@ -2553,6 +2578,30 @@ msgstr "Enviar un mensaje a {{user_name}} sólo para ver cómo funciona" msgid "Sending..." msgstr "Enviando..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Enviada a un organismo por {{info_request_user}} el {{date}}." @@ -2619,6 +2668,9 @@ msgstr "Cerrar sesión" msgid "Sign up" msgstr "Registrarse" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2679,6 +2731,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3112,9 +3167,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Hay un límite en el número de solicitudes que puedes hacer en un día, porque no queremos que los organismos públicos reciban un número exagerado de solicitudes mal formuladas. Si necesitas que el límite no se aplique en tu caso, por favor contacta con nosotros." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "No hay nada que mostrar aún." @@ -3344,6 +3405,9 @@ msgstr "" "estadísticas sobre por ejemplo la velocidad de respuesta de los organismos o\n" "el número de solicitudes que piden usar correo ordinario." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3476,9 +3540,15 @@ msgstr "Hoy" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Demasiados pedidos" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Los mejores jugadores recientes" @@ -3845,6 +3915,9 @@ msgstr "Escribe tu mensaje de seguimiento a {{authority_name}}" msgid "Write your request in simple, precise language." msgstr "Escribe tu solicitud en un lenguaje sencillo y claro." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3974,6 +4047,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Has alcanzado el límite de solicitudes en un día, que es de {{max_requests_per_user_per_day}} solicitudes en un plazo de 24 horas. Podrás enviar una nueva solicitud en {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4628,6 +4704,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} solicitudes." diff --git a/locale/es_NI/app.po b/locale/es_NI/app.po index 7f2acbcbed..a71ad38c83 100644 --- a/locale/es_NI/app.po +++ b/locale/es_NI/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Fabrizio Scrollini , 2012 # Fabrizio Scrollini , 2012 # Gaba , 2012,2014 @@ -51,7 +52,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Victor Diaz , 2014\n" "Language-Team: Spanish (Nicaragua) (http://app.transifex.com/mysociety/alavete" @@ -497,6 +498,9 @@ msgstr "Todas las opciones a continuación pueden usar variedad msgid "All time" msgstr "Todo el tiempo" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "Todo el tiempo los mejores jugadores" @@ -665,6 +669,9 @@ msgstr "Expulso de este sitio" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "Bloque creado por {{info_request_user}} en {{date}}." +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Comenzando por" @@ -728,6 +735,9 @@ msgstr "Cancelar alertas de {{site_name}}" msgid "Cancel, return to your profile page" msgstr "Cancelar, volver a mi perfil" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Cambiar correo en {{site_name}}" @@ -994,6 +1004,9 @@ msgstr "Hecho >>" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Descarga un fichero ZIP con toda la correspondencia" @@ -1065,6 +1078,9 @@ msgstr "Historial de eventos" msgid "Every citizen has the right to access information held by public authorities." msgstr "Todos los ciudadanos tienen derecho a acceder a la información pública en poder de las entidades públicas." +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "Todo lo que escribas en esta página, incluyendo tu nombre, estará disponible públicamente en está web (¿por qué?)." @@ -1638,6 +1654,9 @@ msgstr "Última solicitud vista: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2326,6 +2345,9 @@ msgstr "" msgid "Rejected" msgstr "Rechazado" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" "Recuérdame (mantiene la sesión abierta;\n" @@ -2517,6 +2539,9 @@ msgstr "Busca tus aportaciones" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Mandar una respuesta" @@ -2553,6 +2578,30 @@ msgstr "Enviar un mensaje a {{user_name}} sólo para ver cómo funciona" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Enviado por {{authority_count}} la autoridad {{info_request_user}} el {{date}}." @@ -2619,6 +2668,9 @@ msgstr "Cerrar sesión" msgid "Sign up" msgstr "Iniciar cesión " +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2679,6 +2731,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3112,9 +3167,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Hay un límite en el número de solicitudes que puedes hacer en un día, porque no queremos que los Entidades públicas reciban un número exagerado de solicitudes mal formuladas. Si necesitas que el límite no se aplique en tu caso, por favor contacta con nosotros." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "No hay nada que mostrar aún." @@ -3344,6 +3405,9 @@ msgstr "" "estadísticas sobre por ejemplo la velocidad de respuesta de las entidades o\n" "el número de solicitudes que piden usar correo ordinario." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3476,9 +3540,15 @@ msgstr "Hoy" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Demasiados pedidos" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3845,6 +3915,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "Escribe tu solicitud en un lenguaje sencillo y claro." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3974,6 +4047,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Has alcanzado el límite de solicitudes en un día, que es de {{max_requests_per_user_per_day}} solicitudes en un plazo de 24 horas. Podrás enviar una nueva solicitud en {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4624,6 +4700,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/es_PA/app.po b/locale/es_PA/app.po index 99324ec474..13497ddef8 100644 --- a/locale/es_PA/app.po +++ b/locale/es_PA/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Aida Martinez , 2016 # Fabrizio Scrollini , 2012 # Fabrizio Scrollini , 2012 @@ -52,7 +53,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Victor Diaz , 2014\n" "Language-Team: Spanish (Panama) (http://app.transifex.com/mysociety/alaveteli/" @@ -498,6 +499,9 @@ msgstr "Todas las opciones a continuación pueden usar variedad msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "Mejores jugadores de todos los tiempos" @@ -667,6 +671,9 @@ msgstr "Bloqueado de este sitio Web" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "Bloque creado por {{info_request_user}} en {{date}}." +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Comenzando por" @@ -730,6 +737,9 @@ msgstr "Cancelar alertas de {{site_name}}" msgid "Cancel, return to your profile page" msgstr "Cancelar, volver a mi perfil" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Cambiar dirección de correo en {{site_name}}" @@ -996,6 +1006,9 @@ msgstr "Listo >>" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Descarge un documento ZIP con toda la correspondencia" @@ -1067,6 +1080,9 @@ msgstr "Historial de eventos" msgid "Every citizen has the right to access information held by public authorities." msgstr "Todo ciudadano tiene el derecho de acceder a la información en poder de las instituciones públicas. " +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Todo lo que escriba en esta página, incluyendo su nombre,\n" @@ -1639,6 +1655,9 @@ msgstr "Última solicitud vista: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Aprenda más →" @@ -2325,6 +2344,9 @@ msgstr "" msgid "Rejected" msgstr "Rechazado" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Recuérdame (mantiene la sesión abierta; no lo use en un ordenador público)" @@ -2514,6 +2536,9 @@ msgstr "Busque sus aportaciones" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Enviar un seguimiento a la respuesta" @@ -2550,6 +2575,30 @@ msgstr "Enviar un mensaje a {{user_name}} sólo para ver cómo funciona" msgid "Sending..." msgstr "Enviando..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Enviado a una institución pública {{info_request_user}} el {{date}}" @@ -2616,6 +2665,9 @@ msgstr "Cerrar sesión" msgid "Sign up" msgstr "Registrarse" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2676,6 +2728,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3105,9 +3160,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Hay un límite en el número de solicitudes que puede realizar en un día, porque no queremos que las instituciones públicas reciban un número exagerado de solicitudes mal formuladas. Si necesita que el límite no se aplique en su caso, por favor contáctenos." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "No hay nada que mostrar aún." @@ -3336,6 +3397,9 @@ msgstr "" " con la solicitud en {{site_name}}. Estos datos pueden ser utilizados para generar estadísticas sobre\n" " por ejemplo la velocidad de respuesta de las instituciones." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3468,9 +3532,15 @@ msgstr "Hoy" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Demasiadas solicitudes" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Los mejores jugadores más recientes" @@ -3834,6 +3904,9 @@ msgstr "Para enviar un mensaje de seguimiento sobre acces a la información a {{ msgid "Write your request in simple, precise language." msgstr "Escriba su solicitud en un lenguaje sencillo y claro." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3963,6 +4036,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Ha alcanzado el límite de solicitudes en un día, que es de {{max_requests_per_user_per_day}} solicitudes en un plazo de 24 horas. Podrá enviar una nueva solicitud en {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4613,6 +4689,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} solicitud" diff --git a/locale/es_PY/app.po b/locale/es_PY/app.po index ce3b7b2337..86c7d2b405 100644 --- a/locale/es_PY/app.po +++ b/locale/es_PY/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Fabrizio Scrollini , 2012 # Fabrizio Scrollini , 2012 # Gaba , 2012,2014 @@ -51,7 +52,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Victor Diaz , 2014\n" "Language-Team: Spanish (Paraguay) (http://app.transifex.com/mysociety/alavetel" @@ -497,6 +498,9 @@ msgstr "Todas las opciones a continuación pueden usar variedad msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -665,6 +669,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "Bloque creado por {{info_request_user}} en {{date}}." +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Comenzando por" @@ -728,6 +735,9 @@ msgstr "Cancelar alertas de {{site_name}}" msgid "Cancel, return to your profile page" msgstr "Cancelar, volver a mi perfil" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Cambiar correo en {{site_name}}" @@ -994,6 +1004,9 @@ msgstr "Hecho >>" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Descarga un fichero ZIP con toda la correspondencia" @@ -1065,6 +1078,9 @@ msgstr "Historial de eventos" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "Todo lo que escribas en esta página, incluyendo tu nombre, estará disponible públicamente en está web (¿por qué?)." @@ -1632,6 +1648,9 @@ msgstr "Última solicitud vista: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2320,6 +2339,9 @@ msgstr "" msgid "Rejected" msgstr "Rechazado" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" "Recuérdame (mantiene la sesión abierta;\n" @@ -2511,6 +2533,9 @@ msgstr "Busca tus aportaciones" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Mandar una respuesta" @@ -2547,6 +2572,30 @@ msgstr "Enviar un mensaje a {{user_name}} sólo para ver cómo funciona" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Enviado por {{authority_count}} la autoridad {{info_request_user}} el {{date}}." @@ -2613,6 +2662,9 @@ msgstr "Cerrar sesión" msgid "Sign up" msgstr "Iniciar sesión " +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2673,6 +2725,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3106,9 +3161,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Hay un límite en el número de solicitudes que puedes hacer en un día, porque no queremos que las entidades públicas reciban un número exagerado de solicitudes mal formuladas. Si necesitas que el límite no se aplique en tu caso, por favor contacta con nosotros." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "No hay nada que mostrar aún." @@ -3338,6 +3399,9 @@ msgstr "" "estadísticas sobre por ejemplo la velocidad de respuesta de las entidades o\n" "el número de solicitudes que piden usar correo ordinario." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3470,9 +3534,15 @@ msgstr "Hoy" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Demasiados pedidos" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3839,6 +3909,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "Escribe tu solicitud en un lenguaje sencillo y claro." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3968,6 +4041,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Has alcanzado el límite de solicitudes en un día, que es de {{max_requests_per_user_per_day}} solicitudes en un plazo de 24 horas. Podrás enviar una nueva solicitud en {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4618,6 +4694,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/eu/app.po b/locale/eu/app.po index ae61887ae9..0a15baf4f3 100644 --- a/locale/eu/app.po +++ b/locale/eu/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # David Cabo , 2012 # sroberto , 2012 # Liz Conlan , 2018 @@ -41,7 +42,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: sroberto , 2012\n" "Language-Team: Basque (http://app.transifex.com/mysociety/alaveteli/language/e" @@ -464,6 +465,9 @@ msgstr "Beheko aukera guztiek erabil dezakete variety edo your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Orrialde honetan idatziko duzun guztia, zure izena barne, \n" @@ -1562,6 +1578,9 @@ msgstr "Ikusi den azken eskabidea: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2238,6 +2257,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2427,6 +2449,9 @@ msgstr "Bilatu zure ekarpenak" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Bidali erantzuna" @@ -2463,6 +2488,30 @@ msgstr "Bidali _____-ri mezua {{user_name}} nola funtzionatzen duen ikustearren" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2528,6 +2577,9 @@ msgstr "Itxi saioa" msgid "Sign up" msgstr "Erregistratu" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2584,6 +2636,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3009,9 +3064,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Badago egunean egin ditzakezun eskabide kopuru mugatua, ez dugulako nahi erakunde publikoek gaizki idatzitako eskabide gehiegizkoak jaso ditzaten. Zure kasuan muga hau aplika ez dadin behar izanez gero, mesedez jar zaitez gurekin harremanetan." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3234,6 +3295,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "Ondoko taulak {{site_name}} eskabidearekin zerikusia duten barne gertaeren datu teknikoak erakusten ditu. Datu hauek erabil daitezke estatistikak sortzeko, esaterako erakundeen erantzun abiadura edo posta arrunta erabiltzeko eskatzen duten eskabide kopurua." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3362,9 +3426,15 @@ msgstr "Gaur" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3714,6 +3784,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "Idatz ezazu zure eskabidea hizkera erraz eta argi batez." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3843,6 +3916,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Egun bateko eskabide kopurua gainditu duzu, hau da 24 ordutan H{{max_requests_per_user_per_day}} eskabide egin daitezke. Eskabide berria egin ahal izango duzu {{can_make_another_request}}-ean." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4473,6 +4549,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/fa/app.po b/locale/fa/app.po index a8c27f13ee..bbf398ad60 100644 --- a/locale/fa/app.po +++ b/locale/fa/app.po @@ -31,11 +31,12 @@ # Translators: # Translators: # Translators: +# Translators: msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Graeme Porteous \n" "Language-Team: Persian (http://app.transifex.com/mysociety/alaveteli/language/" @@ -436,6 +437,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -598,6 +602,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -661,6 +668,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -925,6 +935,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -994,6 +1007,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1521,6 +1537,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2195,6 +2214,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2381,6 +2403,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2417,6 +2442,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2482,6 +2531,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2536,6 +2588,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2953,9 +3008,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3176,6 +3237,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3302,9 +3366,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3651,6 +3721,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3780,6 +3853,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4400,6 +4476,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/fi/app.po b/locale/fi/app.po index d04526a938..f70057ba8f 100644 --- a/locale/fi/app.po +++ b/locale/fi/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # apoikola , 2013 # apoikola , 2013 # Juha-Matti Santala , 2013 @@ -39,7 +40,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Juha-Matti Santala , 2013\n" "Language-Team: Finnish (http://app.transifex.com/mysociety/alaveteli/language/" @@ -440,6 +441,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -602,6 +606,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -665,6 +672,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -929,6 +939,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -998,6 +1011,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1525,6 +1541,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2199,6 +2218,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2385,6 +2407,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2421,6 +2446,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2486,6 +2535,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2540,6 +2592,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2957,9 +3012,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3180,6 +3241,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3306,9 +3370,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3655,6 +3725,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3784,6 +3857,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4404,6 +4480,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/fr/app.po b/locale/fr/app.po index da943cd317..07ffad097b 100644 --- a/locale/fr/app.po +++ b/locale/fr/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # 0c5d54599df8b711a7a254a114ba48aa, 2011 # Adrien Chauvet, 2013 # Adrien Chauvet, 2013 @@ -76,7 +77,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: vickyanderica , 2011\n" "Language-Team: French (http://app.transifex.com/mysociety/alaveteli/language/f" @@ -521,6 +522,9 @@ msgstr "Toutes les options ci-dessous peuvent utiliser Etat ou msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "Palmarès des meilleurs acteurs" @@ -685,6 +689,9 @@ msgstr "Banni de ce site" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "Groupe creé par {{info_request_user}} le {{date}}" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Commence par" @@ -748,6 +755,9 @@ msgstr "Annuler les alertes {{site_name}} " msgid "Cancel, return to your profile page" msgstr "Annuler, retourner à votre page de profil" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Changer le courriel sur {{site_name}}" @@ -1016,6 +1026,9 @@ msgstr "Fait >>" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Télécharger un fichier zip de toute la correspondance" @@ -1089,6 +1102,9 @@ msgstr "Historique des événements" msgid "Every citizen has the right to access information held by public authorities." msgstr "Chaque citoyen a la droit d'accédez aux informations détenues par les autorités publiques." +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Tout ce que vous indiquez dans cette page, y compris votre nom ,\n" @@ -1654,6 +1670,9 @@ msgstr "Dernière demande consultée : {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "En savoir plus →" @@ -2333,6 +2352,9 @@ msgstr "" msgid "Rejected" msgstr "Rejeté" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Souvenez-vous de moi (vous permet de rester connecté longtemps; ne pas utiliser sur un ordinateur publique)" @@ -2522,6 +2544,9 @@ msgstr "Chercher vos contributions" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Envoyer un suivi" @@ -2558,6 +2583,30 @@ msgstr "Envoyer un message à {{user_name}} juste pour voir comment ça marche" msgid "Sending..." msgstr "Envoi..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Envoyé à {{info_request_user}} ce {{date}}." @@ -2624,6 +2673,9 @@ msgstr "Se déconnecter" msgid "Sign up" msgstr "Créer un compte" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2681,6 +2733,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3106,9 +3161,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Il y a une limite sur le nombre de demandes que vous pouvez faire en une journée, parce que nous ne voulons pas que les autorités publiques soient bombardées avec un grand nombre de demandes inappropriées. Si vous sentez que vous avez une bonne raison de demander que la limite soit levée pour vous, veuillez nous contacter." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Il n'y a rien à afficher encore." @@ -3336,6 +3397,9 @@ msgstr "" " la vitesse avec laquelle les autorités répondent aux demandes, le nombre de demandes \n" " qui nécessitent une réponse postale et bien plus encore." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3468,9 +3532,15 @@ msgstr "Aujourd'hui" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Trop de demandes " +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Palmarès des acteurs récents" @@ -3836,6 +3906,9 @@ msgstr "Ecrivez votre message de suivi à {{authority_name}}" msgid "Write your request in simple, precise language." msgstr "Formulez votre demande en langage simple et precis ." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3965,6 +4038,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Vous avez atteint la limite du nombre des nouvelles demandes. Les utilisateurs sont normalement limités à {max_requests_per_user_per_day}} demandes par jour . Vous serez en mesure de faire une autre demande dans {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4620,6 +4696,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} demandes" diff --git a/locale/fr_BE/app.po b/locale/fr_BE/app.po index d5b4ceb616..365a4ae055 100644 --- a/locale/fr_BE/app.po +++ b/locale/fr_BE/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # 0c5d54599df8b711a7a254a114ba48aa, 2011 # Adrien Chauvet, 2013 # Adrien Chauvet, 2013 @@ -61,7 +62,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: vickyanderica , 2011\n" "Language-Team: French (Belgium) (http://app.transifex.com/mysociety/alaveteli/" @@ -485,6 +486,9 @@ msgstr "Toutes les options ci-dessous peuvent utiliser variety msgid "All time" msgstr "Tout le temps" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "Palmarès des meilleurs acteurs" @@ -647,6 +651,9 @@ msgstr "Banni de ce site" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "Groupe créé par {{info_request_user}} le {{date}}" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Commence par" @@ -710,6 +717,9 @@ msgstr "Annuler certaines alertes de {{site_name}} " msgid "Cancel, return to your profile page" msgstr "Annuler et retourner à votre page de profil" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Changer l'email utilisé sur {{site_name}}" @@ -974,6 +984,9 @@ msgstr "C'est fait" msgid "Download Data" msgstr "Télécharger les données" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Télécharger un fichier zip de toute la correspondance" @@ -1043,6 +1056,9 @@ msgstr "Historique des événements" msgid "Every citizen has the right to access information held by public authorities." msgstr "Chaque citoyen a le droit d'accéder aux informations détenues par les autorités publiques." +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "Tout ce que vous indiquez dans cette page, y compris votre nom, sera public sur ce site (pourquoi?)." @@ -1579,6 +1595,9 @@ msgstr "Dernière demande consultée : {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "En savoir plus →" @@ -2254,6 +2273,9 @@ msgstr "" msgid "Rejected" msgstr "Rejeté" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Souvenez-vous de moi (vous permet de rester connecté, ne pas utiliser sur un ordinateur public)" @@ -2440,6 +2462,9 @@ msgstr "Rechercher vos contributions" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Envoyer un message de suivi" @@ -2476,6 +2501,30 @@ msgstr "Envoyer un message à {{user_name}} juste pour voir comment cela fonctio msgid "Sending..." msgstr "Envoi..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Envoyé à une autorité par {{info_request_user}} le {{date}}." @@ -2542,6 +2591,9 @@ msgstr "Se déconnecter" msgid "Sign up" msgstr "S'inscrire" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2598,6 +2650,9 @@ msgstr "Désolé, nous sommes actuellement dans l'impossibilité d'ajouter votre msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "Désolé, nous sommes actuellement dans l'impossibilité d'envoyer votre demande. Merci d'essayer ultérieurement." @@ -3015,9 +3070,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Il y a une limite concernant le nombre de demandes que vous pouvez effectuer en une journée, parce que nous ne voulons pas que les autorités publiques soient bombardées avec un grand nombre de demandes inappropriées. Si vous estimez que vous avez une bonne raison de demander que la limite soit augmentée pour vous, veuillez nous contacter." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "A ce stade, il n'y a rien à afficher." @@ -3240,6 +3301,9 @@ msgstr "Cette section sur les statistiques de l'organisme public est actuellemen msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "Ce tableau présente les détails techniques des événements internes concernant cette demande faite via {{site_name}}. Ces données pourraient être utilisées pour générer des informations sur la vitesse avec laquelle les autorités répondent aux demandes, le nombre de demandes qui nécessitent une réponse postale et bien plus encore." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "Cet utilisateur a été suspendu de {{site_name}}" @@ -3366,9 +3430,15 @@ msgstr "Aujourd'hui" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Trop de demandes " +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Palmarès des acteurs récents" @@ -3720,6 +3790,9 @@ msgstr "Ecrivez votre message de suivi à {{authority_name}}" msgid "Write your request in simple, precise language." msgstr "Formulez votre demande en langage simple et précis." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "Oui" @@ -3852,6 +3925,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Vous avez atteint la limite maximale de nouvelles demandes. Les utilisateurs sont limités à {{max_requests_per_user_per_day}} demandes par période de 24h. Vous pourrez faire une autre demande dans {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "Vous avez quitté le projet." @@ -4489,6 +4565,11 @@ msgstr[0] "{{number_of_comments}} commentaire" msgstr[1] "{{number_of_comments}} commentaires" msgstr[2] "{{number_of_comments}} commentaires" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} demande" diff --git a/locale/fr_CA/app.po b/locale/fr_CA/app.po index ed71d06e54..164d5717a7 100644 --- a/locale/fr_CA/app.po +++ b/locale/fr_CA/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # 0c5d54599df8b711a7a254a114ba48aa, 2011 # andreas.pavlou , 2013 # 0c5d54599df8b711a7a254a114ba48aa, 2011 @@ -53,7 +54,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: vickyanderica , 2011\n" "Language-Team: French (Canada) (http://app.transifex.com/mysociety/alaveteli/l" @@ -496,6 +497,9 @@ msgstr "Toutes les options ci-dessous peuvent utiliser variety msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -660,6 +664,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Commence avec" @@ -723,6 +730,9 @@ msgstr "Annuler certaines alertes de {{site_name}}" msgid "Cancel, return to your profile page" msgstr "Annuler, retourner à votre page de profil" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Changer le courriel sur {{site_name}}" @@ -991,6 +1001,9 @@ msgstr "Fait >>" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Télécharger un fichier zip de toute la correspondance" @@ -1064,6 +1077,9 @@ msgstr "Historique des événements" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Tout ce que vous indiquez sur cette page, y compris votre nom ,\n" @@ -1626,6 +1642,9 @@ msgstr "Dernière demande consultée : {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2305,6 +2324,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2494,6 +2516,9 @@ msgstr "Chercher dans vos demandes" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Envoyer un message de suivi" @@ -2530,6 +2555,30 @@ msgstr "Envoyer un message à {{user_name}} Juste pour voir comment cela fonctio msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2595,6 +2644,9 @@ msgstr "Se déconnecter" msgid "Sign up" msgstr "Créer un compte" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2653,6 +2705,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3080,9 +3135,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Il y a un nombre limite de demandes pouvant être formulées par jour (nous voulons éviter que les organismes soient bombardés de demandes inappropriées). Si vous croyez que vous devriez être exempté de cette limite, veuillez nous contacter." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3308,6 +3369,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "Ce tableau détaille les événements techniques liés à cette demande. Cette information peut vous aider à retracer la suite des événements et, par exemple, à voir avec précision quand ont été échangés les différents messages." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3442,9 +3506,15 @@ msgstr "Aujourd'hui" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Trop de demandes " +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3806,6 +3876,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "Formulez votre demande en langage simple et précis ." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3935,6 +4008,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Vous avez atteint la limite de nouvelles demandes permises. Les utilisateurs sont normalement limités à {max_requests_per_user_per_day}} demandes par jour. Vous serez en mesure de faire une autre demande dans {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4590,6 +4666,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/fr_FR/app.po b/locale/fr_FR/app.po index 5053bde03a..2ccdbc9158 100644 --- a/locale/fr_FR/app.po +++ b/locale/fr_FR/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # 0c5d54599df8b711a7a254a114ba48aa, 2011 # a270031086f2a0d3514bc0cb507b48f6, 2019 # Adrien Chauvet, 2013 @@ -62,9 +63,9 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" -"Last-Translator: Laurent S, 2019-2023\n" +"Last-Translator: vickyanderica , 2011\n" "Language-Team: French (France) (http://app.transifex.com/mysociety/alaveteli/l" "anguage/fr_FR/)\n" "MIME-Version: 1.0\n" @@ -486,6 +487,9 @@ msgstr "Toutes les options ci-dessous peuvent utiliser variety msgid "All time" msgstr "Tout le temps" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "Palmarès des meilleurs acteurs" @@ -648,6 +652,9 @@ msgstr "Banni de ce site" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "Groupe créé par {{info_request_user}} le {{date}}" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Commence par" @@ -711,6 +718,9 @@ msgstr "Annuler certaines alertes de {{site_name}} " msgid "Cancel, return to your profile page" msgstr "Annuler et retourner à votre page de profil" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Changer l'email utilisé sur {{site_name}}" @@ -1015,6 +1025,9 @@ msgstr "C'est fait" msgid "Download Data" msgstr "Télécharger la donnée" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Télécharger un fichier zip de toute la correspondance" @@ -1084,6 +1097,9 @@ msgstr "Historique des événements" msgid "Every citizen has the right to access information held by public authorities." msgstr "Ma Dada est un site associatif qui vous aide à faire des demandes d’accès aux documents administratifs communicables." +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "Tout ce que vous indiquez dans cette page, y compris votre nom, sera public sur ce site (pourquoi?)." @@ -1618,6 +1634,9 @@ msgstr "Dernière demande consultée : {{request_url}}" msgid "Latest" msgstr "Dernier" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "En savoir plus →" @@ -2299,6 +2318,9 @@ msgstr "Regulation" msgid "Rejected" msgstr "Rejetée" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Souvenez-vous de moi (vous permet de rester connecté, ne pas utiliser sur un ordinateur public)" @@ -2485,6 +2507,9 @@ msgstr "Rechercher vos contributions" msgid "Section" msgstr "Section" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Envoyer un message" @@ -2521,6 +2546,30 @@ msgstr "Envoyer un message à {{user_name}} juste pour voir comment cela fonctio msgid "Sending..." msgstr "Envoi..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Envoyé à une autorité par {{info_request_user}} le {{date}}." @@ -2587,6 +2636,9 @@ msgstr "Se déconnecter" msgid "Sign up" msgstr "S'inscrire" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2643,6 +2695,9 @@ msgstr "Désolé, nous sommes actuellement dans l'impossibilité d'ajouter votre msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "Désolé, nous sommes actuellement dans l'impossibilité d'envoyer votre demande. Merci d'essayer ultérieurement." @@ -3064,9 +3119,15 @@ msgstr "Il y a plus d'une personne qui utilise ce site et ce no msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Il y a une limite concernant le nombre de demandes que vous pouvez effectuer en une journée, parce que nous ne voulons pas que les autorités publiques soient bombardées avec un grand nombre de demandes inappropriées. Si vous estimez que vous avez une bonne raison de demander que la limite soit augmentée pour vous, veuillez nous contacter." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "A ce stade, il n'y a rien à afficher." @@ -3289,6 +3350,9 @@ msgstr "Cette section sur les statistiques de l'organisme public est actuellemen msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "Ce tableau présente les détails techniques des événements internes concernant cette demande faite via {{site_name}}. Ces données pourraient être utilisées pour générer des informations sur la vitesse avec laquelle les autorités répondent aux demandes, le nombre de demandes qui nécessitent une réponse postale et bien plus encore." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "Cet utilisateur a été suspendu de {{site_name}} " @@ -3415,9 +3479,15 @@ msgstr "Aujourd'hui" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Trop de demandes " +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Palmarès des acteurs récents" @@ -3769,6 +3839,9 @@ msgstr "Ecrivez votre message de suivi à {{authority_name}}" msgid "Write your request in simple, precise language." msgstr "Formulez votre demande en langage simple et précis." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "Oui" @@ -3901,6 +3974,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Vous avez atteint la limite maximale de nouvelles demandes. Les utilisateurs sont limités à {{max_requests_per_user_per_day}} demandes par période de 24h. Vous pourrez faire une autre demande dans {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "Vous avez quitté ce projet" @@ -4538,6 +4614,11 @@ msgstr[0] "{{number_of_comments}} commentaire" msgstr[1] "{{number_of_comments}} commentaires" msgstr[2] "{{number_of_comments}} commentaires" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} demande" diff --git a/locale/ga_IE/app.po b/locale/ga_IE/app.po index 7e177cdb11..ac16fa8c09 100644 --- a/locale/ga_IE/app.po +++ b/locale/ga_IE/app.po @@ -31,12 +31,13 @@ # Translators: # Translators: # Translators: +# Translators: # Niall Ó Tuathail , 2015 msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Niall Ó Tuathail , 2015\n" "Language-Team: Irish (Ireland) (http://app.transifex.com/mysociety/alaveteli/l" @@ -438,6 +439,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -600,6 +604,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Ag tosú le" @@ -663,6 +670,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -927,6 +937,9 @@ msgstr "Críochnaithe >>" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -996,6 +1009,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1523,6 +1539,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2197,6 +2216,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2383,6 +2405,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2419,6 +2444,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2484,6 +2533,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2538,6 +2590,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2955,9 +3010,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3178,6 +3239,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3304,9 +3368,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3653,6 +3723,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3782,6 +3855,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4402,6 +4478,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/gl/app.po b/locale/gl/app.po index 26f465908a..1f5e391c3b 100644 --- a/locale/gl/app.po +++ b/locale/gl/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # David Cabo , 2012 # Liz Conlan , 2018 # louisecrow , 2014 @@ -39,7 +40,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: louisecrow , 2014\n" "Language-Team: Galician (http://app.transifex.com/mysociety/alaveteli/language" @@ -483,6 +484,9 @@ msgstr "All the options below can use variety or latest msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -651,6 +655,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Comenzando por" @@ -714,6 +721,9 @@ msgstr "Cancelar alertas de {{site_name}}" msgid "Cancel, return to your profile page" msgstr "Cancelar, volver a mi perfil" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Cambiar correo en {{site_name}}" @@ -982,6 +992,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Descargar un fichero ZIP con toda la correspondencia" @@ -1053,6 +1066,9 @@ msgstr "Historial de eventos" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Todo lo que escribas en esta página, incluyendo tu nombre, \n" @@ -1621,6 +1637,9 @@ msgstr "Última solicitud vista: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2309,6 +2328,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2498,6 +2520,9 @@ msgstr "Busca tus aportaciones" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Mandar una respuesta" @@ -2534,6 +2559,30 @@ msgstr "Enviar un mensaje a {{user_name}} sólo para ver cómo funciona" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2599,6 +2648,9 @@ msgstr "Cerrar sesión" msgid "Sign up" msgstr "Registrarse" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2659,6 +2711,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3092,9 +3147,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Hay un límite en el número de solicitudes que puedes hacer en un día, porque no queremos que los organismos públicos reciban un número exagerado de solicitudes mal formuladas. Si necesitas que el límite no se aplique en tu caso, por favor contacta con nosotros." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3323,6 +3384,9 @@ msgstr "" "estadísticas sobre por ejemplo la velocidad de respuesta de los organismos o\n" "el número de solicitudes que piden usar correo ordinario." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3457,9 +3521,15 @@ msgstr "Hoy" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3824,6 +3894,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "Escribe tu solicitud en un lenguaje sencillo y claro." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3953,6 +4026,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Has alcanzado el límite de solicitudes en un día, que es de {{max_requests_per_user_per_day}} solicitudes en un plazo de 24 horas. Podrás enviar una nueva solicitud en {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4596,6 +4672,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/he_IL/app.po b/locale/he_IL/app.po index a1e6eb9c90..78eb9c3ee7 100644 --- a/locale/he_IL/app.po +++ b/locale/he_IL/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Liz Conlan , 2018 # louisecrow , 2014 # louisecrow , 2014 @@ -53,7 +54,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Z.D , 2013\n" "Language-Team: Hebrew (Israel) (http://app.transifex.com/mysociety/alaveteli/l" @@ -495,6 +496,9 @@ msgstr "כל האפשרויות למטה יכולות לעשות שימושyour name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "כל מה שתזינו בדף הזה, כולל השם שלכם, יוצג פתוח לציבור באתר הזה לתמיד(למה?)." @@ -1617,6 +1633,9 @@ msgstr "בקשה אחרונה שנצפתה: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2304,6 +2323,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "זכור אותי (משאיר אתכם מחוברים לזמן רב יותר; אל תסמנו על מחשב ציבורי)" @@ -2492,6 +2514,9 @@ msgstr "חפש בין התוספות שלך" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "לשלוח הודעת המשך" @@ -2528,6 +2553,30 @@ msgstr "שלחו הודעה {{user_name}} רק כדי לראות איך זה ע msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2593,6 +2642,9 @@ msgstr "התנתק" msgid "Sign up" msgstr "הרשמה" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2653,6 +2705,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3083,9 +3138,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "מספר הבקשות שניתן להגיש ביום מוגבל, כי אנו לא רוצים להציף את הרשויות הציבוריות בבקשות שווא. אם אתם רוצים להגדיל את המספר המותר, צרו קשר." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3316,6 +3377,9 @@ msgstr "" " המהירות בה רשויות מגיבות לבקשות, מספר הבקשות\n" " שדרשו שליחת דואר ודברים רבים נוספים." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3446,9 +3510,15 @@ msgstr "היום" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "יותר מדי בקשות" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3809,6 +3879,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "כתבו את בקשתכם בשפה פשוטה ומדויקת." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3938,6 +4011,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "עברתם את המכסה היומית המותרת להגשת בקשות מידע. לרוב מוגבלים המשתמשים ל- {{max_requests_per_user_per_day}} בקשות ביממה. תוכלו להגיש בקשה נוספת בעוד {{can_make_another_request}} שעות." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4601,6 +4677,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/hr/app.po b/locale/hr/app.po index 9fb40978da..491726bcfb 100644 --- a/locale/hr/app.po +++ b/locale/hr/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # ae792aa766bbca91f3f4821acaa19518_a48216f <924a924c26027fc002ca6fada3386ff5_247255>, 2015 # Bojan Opacak , 2013 # Bojan Opacak , 2013 @@ -63,9 +64,9 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" -"Last-Translator: Miroslav Schlossberg, 2021-2023\n" +"Last-Translator: Žana Počuča , 2015,2021\n" "Language-Team: Croatian (http://app.transifex.com/mysociety/alaveteli/language" "/hr/)\n" "MIME-Version: 1.0\n" @@ -475,6 +476,9 @@ msgstr "Sve opcije ispod mogu koristiti variety ili lat msgid "All time" msgstr "Sveukupno" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "Svo vrijeme najbolji igrači" @@ -637,6 +641,9 @@ msgstr "Zabranjen pristup na ovoj stranici" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "Seriju je napravio/la {{info_request_user}} dana {{date}}." +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Počevši sa" @@ -700,6 +707,9 @@ msgstr "Poništite neka upozorenja na {{site_name}}" msgid "Cancel, return to your profile page" msgstr "Odustanite, vratite se na stranicu svojeg profila" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Promijenite elektroničku poštu na {{site_name}}" @@ -964,6 +974,9 @@ msgstr "Završeno >>" msgid "Download Data" msgstr "Preuzmi podatke" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Preuzmite svu korespondenciju u zip datoteci" @@ -1033,6 +1046,9 @@ msgstr "Prikaz prošlih događanja" msgid "Every citizen has the right to access information held by public authorities." msgstr "Svaki građanin ima pravo na pristup informacijama koje posjeduju tijela javne vlasti." +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "Sve što unesete na ovu stranicu, uključujući vaše ime, bit će javno prikazano na ovoj internetskoj stranici zauvijek" @@ -1564,6 +1580,9 @@ msgstr "Zadnje pregledani zahtjev: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Saznajte više →" @@ -2239,6 +2258,9 @@ msgstr "" msgid "Rejected" msgstr "Odbijen" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Zapamti me (ostajete dulje prijavljeni; ne koristite na javnim računalima)" @@ -2425,6 +2447,9 @@ msgstr "Pretražite Vaše doprinose" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Pošaljite dodatnu poruku" @@ -2461,6 +2486,30 @@ msgstr "Pošaljite poruku {{user_name}} samo da vidite kako radi" msgid "Sending..." msgstr "Slanje..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Poslano jednoj ustanovi od {{info_request_user}} dana {{date}}." @@ -2527,6 +2576,9 @@ msgstr "Odjavite se" msgid "Sign up" msgstr "Registrirajte se" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2581,6 +2633,9 @@ msgstr "Nažalost, trenutno ne možemo dodati vašu bilješku. Molimo pokušajte msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "Nažalost, trenutno ne možemo poslati Vaš zahtjev. Molimo pokušajte ponovo kasnije." @@ -2998,9 +3053,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Postoji ograničenje broja zahtjeva koje možete dnevno izraditi. Ne želimo da tijela javne vlasti budu zatrpane velikim brojem neprikladnih zahtjeva. Ukoliko mislite da, u Vašem slučaju, imate dobar razlog zatražiti veći broj zahtjeva, molimo javite nam se." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Još nema ničega za prikazati." @@ -3223,6 +3284,9 @@ msgstr "Ovaj je odjeljak o statistici tijela javne vlasti trenutno eksperimental msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "Ova tablica prikazuje tehničke detalje internih događaja vezanih uz ovaj zahtjev na {{site_name}}. To se može iskoristiti za dobivanje informacija o brzini kojom tijela javne vlasti odgovaraju na zahtjeve, o broju zahtjeva koji žele odgovoriti poštom i mnogo drugih stvari." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "Ovaj korisnik je suspendiran na {{site_name}} " @@ -3349,9 +3413,15 @@ msgstr "Danas" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Previše zahtjeva" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Najnoviji vrhunski igrači" @@ -3700,6 +3770,9 @@ msgstr "Napišite svoju dodatnu poruku za pravo na pristup informacijama za {{au msgid "Write your request in simple, precise language." msgstr "Pišite Vaš zahtjev jednostavnim, preciznim jezikom." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "Da" @@ -3832,6 +3905,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Dosegli ste limit novih zahtjeva. Korisnici su ograničeni na {{max_requests_per_user_per_day}} zahtjeva u periodu od 24 sata. Novi zatjev bit će moguć za {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "Napustili ste projekt." @@ -4469,6 +4545,11 @@ msgstr[0] "{{number_of_comments}} komentara" msgstr[1] "{{number_of_comments}} komentara" msgstr[2] "{{number_of_comments}} komentara" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} zahtjeva" diff --git a/locale/hu_HU/app.po b/locale/hu_HU/app.po index 238f19f518..a19b3e0b7c 100644 --- a/locale/hu_HU/app.po +++ b/locale/hu_HU/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # alaveteli_hu , 2012 # alaveteli_hu , 2012 # Dohány Tamás, 2021-2022 @@ -48,7 +49,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: iamdtms, 2021-2022\n" "Language-Team: Hungarian (Hungary) (http://app.transifex.com/mysociety/alavete" @@ -484,6 +485,9 @@ msgstr "Az alábbi beállítások mindegyike használhatja a változatzip formátumban" @@ -1052,6 +1065,9 @@ msgstr "Eseménytörténet" msgid "Every citizen has the right to access information held by public authorities." msgstr "Minden állampolgárnak joga van hozzáférni a hatóságok birtokában lévő információkhoz." +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Az ön neve, valamint minden, amit itt beír,\n" @@ -1624,6 +1640,9 @@ msgstr "Legutóbb megtekintett igénylés: {{request_url}}" msgid "Latest" msgstr "Legújabb" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "További információ →" @@ -2313,6 +2332,9 @@ msgstr "Szabályozás" msgid "Rejected" msgstr "Elutasítva" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Emlékezzen rám (továbbra is bejelentkezve marad; ne használja nyilvános számítógépen)" @@ -2502,6 +2524,9 @@ msgstr "Keresés az adatigényléseimben" msgid "Section" msgstr "Szakasz" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Emlékeztető üzenet küldése - Rákérdezhet az adatgazdánál, hogy hogy áll az igénylése." @@ -2538,6 +2563,30 @@ msgstr "Üzenet küldése a következőnek: {{user_name}} Csak hogy megnézzük, msgid "Sending..." msgstr "Küldés..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Elküldte {{authority_count}} hatóságnak, {{info_request_user}}, {{date}}." @@ -2603,6 +2652,9 @@ msgstr "Kijelentkezés" msgid "Sign up" msgstr "Regisztráció" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2663,6 +2715,9 @@ msgstr "Sajnáljuk, jelenleg nem tudjuk hozzáadni a kommentjét. Kérlek, prób msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "Sajnáljuk, jelenleg nem tudjuk elküldeni kérését. Kérlek, próbáld újra később." @@ -3096,9 +3151,15 @@ msgstr "Egynél több személy használja ezt az oldalt és ren msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Ennek a korlátozásnak az az oka hogy nem szeretnénk ha nagy mennyiségű inadekvát adatigényléssel árasztaná el az adatgazdákat valaki. Ha úgy érzi hogy nyomós oka van ennél több adatigénylést kezdeményezni rövid időn belül, kérjük, lépjen kapcsolatba velünk." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Még nincs mit megjeleníteni." @@ -3327,6 +3388,9 @@ msgstr "" "a közintézmények milyen gyorsan válaszolnak, mennyi igénylés esetén\n" "van szükség postai válaszra stb.. " +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "Ezt a felhasználót felfüggesztettük a {{site_name}} webhelyen" @@ -3459,9 +3523,15 @@ msgstr "Ma " msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Túl sok igénylés" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Legújabb játékosok" @@ -3826,6 +3896,9 @@ msgstr "Írja meg az FOI nyomon követési üzenetét a következőnek: {{author msgid "Write your request in simple, precise language." msgstr "Igénylését egyszerűen és pontosan fogalmazza meg!" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "Igen" @@ -3957,6 +4030,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Felhasználóink 24 órán belül legfeljebb {{max_requests_per_user_per_day}} új adatigénylést kezdeményezhetnek. Ön elérte ezt a számot, ezért a következő adatigénylését legkorábban kb. {{can_make_another_request}} óra múlva küldheti el." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "Kilépett a projektből." @@ -4602,6 +4678,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "{{number_of_comments}} megjegyzés" msgstr[1] "{{number_of_comments}} megjegyzés" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} igénylés" diff --git a/locale/id/app.po b/locale/id/app.po index a2c719120f..781aa31525 100644 --- a/locale/id/app.po +++ b/locale/id/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Agung Riyadi , 2013 # Agung Riyadi , 2012-2013 # agustriwanto , 2012 @@ -47,7 +48,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Agung Riyadi , 2012-2013\n" "Language-Team: Indonesian (http://app.transifex.com/mysociety/alaveteli/langua" @@ -492,6 +493,9 @@ msgstr "Semua pilihan di bawah dapat menggunakanjenis atauyour name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Semua yang Anda masukkan di halaman ini, termasuknama Anda, \n" @@ -1634,6 +1650,9 @@ msgstr "Permintaan terakhir yang dilihat: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2321,6 +2340,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2510,6 +2532,9 @@ msgstr "Cari kontribusi Anda" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Kirim tindak lanjut" @@ -2546,6 +2571,30 @@ msgstr "Kirim pesan kepada {{user_name}} hanya untuk melihat cara kerjanya" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2611,6 +2660,9 @@ msgstr "Keluar" msgid "Sign up" msgstr "Daftar" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2671,6 +2723,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3104,9 +3159,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Ada batas jumlah permintaan yang dapat Anda buat dalam sehari, karena kami tidak mau otoritas publik dibombardir dengan sejumlah besar permintaan yang tidak sesuai. Jika Anda merasa Anda memiliki alasan yang bagus untuk meminta batasan ini dicabut dalam kasus Anda, silakan berhubungan." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3334,6 +3395,9 @@ msgstr "" "kecepatan otoritas dalam merespon permintaan, jumlah permintaan\n" "yang membutuhkan respon pos dan banyak lagi." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3468,9 +3532,15 @@ msgstr "Hari ini" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Terlalu banyak permintaan" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3837,6 +3907,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "Tulis permintaan Anda dalam bahasa yang sederhana, tepat." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3966,6 +4039,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Anda telah mencapai batas kecepatan permintaan baru. Pengguna biasanya dibatasi sampai {{max_requests_per_user_per_day}} permintaan dalam jangka waktu 24 jam berjalan. Anda akan dapat membuat permintaan lain dalam {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4612,6 +4688,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/is/app.po b/locale/is/app.po index 864538bfa2..18857701cc 100644 --- a/locale/is/app.po +++ b/locale/is/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Finnur Magnusson , 2015 # Liz Conlan , 2018 # Ölvir Gíslason , 2016 @@ -39,9 +40,9 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" -"Last-Translator: Páll Hilmarsson , 2020-2021,2023\n" +"Last-Translator: Ölvir Gíslason , 2016\n" "Language-Team: Icelandic (http://app.transifex.com/mysociety/alaveteli/languag" "e/is/)\n" "MIME-Version: 1.0\n" @@ -472,6 +473,9 @@ msgstr "Með öllum neðangreindum valkostum má nota variety o msgid "All time" msgstr "Allra tíma" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "Þau allra afkastamestu" @@ -640,6 +644,9 @@ msgstr "Í banni á þessum vef" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "Hópbeiðni búin til af {{info_request_user}} þann {{date}}." +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Byrjar á" @@ -703,6 +710,9 @@ msgstr "Hætta við einhverjar {{site_name}} viðvaranir" msgid "Cancel, return to your profile page" msgstr "Hætta við, fara aftur á þína síðu" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Breyta netfangi á {{site_name}}" @@ -967,6 +977,9 @@ msgstr "Lokið >>" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Sækja zip-skrá með öllum samskiptum" @@ -1038,6 +1051,9 @@ msgstr "Færsluferill" msgid "Every citizen has the right to access information held by public authorities." msgstr "Allir borgarar hafa rétt á að fá aðgang að upplýsingum sem stjórnvöld búa yfir." +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Allt sem þú setur á þetta vefsvæði, þar á meðal nafnið þitt,\n" @@ -1582,6 +1598,9 @@ msgstr "Síðasta beiðni sem var skoðuð: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Meiri upplýsingar →" @@ -2258,6 +2277,9 @@ msgstr "" msgid "Rejected" msgstr "Hafnað" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Muna mig (þú verður lengur innskráð/ur; ekki haka við þetta á tæki sem fleiri en þú nota)" @@ -2447,6 +2469,9 @@ msgstr "Leitaðu í þínum innleggjum" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Senda svar/viðbót" @@ -2483,6 +2508,30 @@ msgstr "Senda skilaboð til {{user_name}} til að prófa hvernig það virkar" msgid "Sending..." msgstr "Sendi..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Sent til eins stjórnvalds af {{info_request_user}} þann {{date}}" @@ -2548,6 +2597,9 @@ msgstr "Útskrá" msgid "Sign up" msgstr "Nýskrá" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2606,6 +2658,9 @@ msgstr "Því miður getum við ekki bætt við athugasemd þinni núna. Reyndu msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "Því miður getum við ekki send beiðnina þína núna. Reyndu aftur síðar." @@ -3031,9 +3086,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Fjöldi þeirra beiðna sem hægt er að leggja fram á einum degi er takmarkaður því við viljum forðast að stjórnvöld fái mikinn fjölda óviðeigandi beiðna. Hafðu samband ef þér finnst ástæða til að aflétta takmörkuninni í þínu tilfelli." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Ekkert til að sýna enn." @@ -3254,6 +3315,9 @@ msgstr "Hlutinn um tölfræði stjórnvalda er á tilraunastigi svo það eru ý msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "Þessi tafla sýnir tæknilegar upplýsingar um feril beiðnarinnar á {{site_name}}. Þetta má til dæmis nota til að fá fram upplýsingar um það hversu hratt stjórnvöld bregðast við beiðnum og fjölda þeirra beiðna sem þarf að svara bréflega, svo fátt eitt sé nefnt." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3382,9 +3446,15 @@ msgstr "Í dag" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Of margar beiðnir" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Afkastamest upp á síðkastið" @@ -3736,6 +3806,9 @@ msgstr "Skrifa ítrekunarskilaboð vegna upplýsingabeiðni til {{authority_name msgid "Write your request in simple, precise language." msgstr "Skrifaðu beiðnina þín með einföldu, markvissu máli" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3865,6 +3938,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Þú hefur náð hámarksfjölda nýrra beiðna. Takmarkið fyrir notendur er yfirleitt {{max_requests_per_user_per_day}} beiðnir á hverjum sólarhring. Þú getur lagt fram nýja beiðni eftir {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4491,6 +4567,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} beiðni" diff --git a/locale/is_IS/app.po b/locale/is_IS/app.po index 8a2d89dd61..30ee627fbd 100644 --- a/locale/is_IS/app.po +++ b/locale/is_IS/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Finnur Magnusson , 2015 # Liz Conlan , 2018 # Ölvir Gíslason , 2016 @@ -39,7 +40,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Ölvir Gíslason , 2016\n" "Language-Team: Icelandic (Iceland) (http://app.transifex.com/mysociety/alavete" @@ -472,6 +473,9 @@ msgstr "Með öllum neðangreindum valkostum má nota variety o msgid "All time" msgstr "Allra tíma" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "Þau allra afkastamestu" @@ -640,6 +644,9 @@ msgstr "Í banni á þessum vef" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "Hópbeiðni búin til af {{info_request_user}} þann {{date}}." +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Byrjar á" @@ -703,6 +710,9 @@ msgstr "Hætta við einhverjar {{site_name}} viðvaranir" msgid "Cancel, return to your profile page" msgstr "Hætta við, fara aftur á þína síðu" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Breyta netfangi á {{site_name}}" @@ -967,6 +977,9 @@ msgstr "Lokið >>" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Sækja zip-skrá með öllum samskiptum" @@ -1038,6 +1051,9 @@ msgstr "Færsluferill" msgid "Every citizen has the right to access information held by public authorities." msgstr "Allir borgarar hafa rétt á að fá aðgang að upplýsingum sem stjórnvöld búa yfir." +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Allt sem þú setur á þetta vefsvæði, þar á meðal nafnið þitt,\n" @@ -1582,6 +1598,9 @@ msgstr "Síðasta beiðni sem var skoðuð: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Meiri upplýsingar →" @@ -2258,6 +2277,9 @@ msgstr "" msgid "Rejected" msgstr "Hafnað" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Muna mig (þú verður lengur innskráð/ur; ekki haka við þetta á tæki sem fleiri en þú nota)" @@ -2447,6 +2469,9 @@ msgstr "Leitaðu í þínum innleggjum" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Senda svar/viðbót" @@ -2483,6 +2508,30 @@ msgstr "Senda skilaboð til {{user_name}} til að prófa hvernig það virkar" msgid "Sending..." msgstr "Sendi..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Sent til eins stjórnvalds af {{info_request_user}} þann {{date}}" @@ -2548,6 +2597,9 @@ msgstr "Útskrá" msgid "Sign up" msgstr "Nýskrá" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2606,6 +2658,9 @@ msgstr "Því miður getum við ekki bætt við athugasemd þinni núna. Reyndu msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "Því miður getum við ekki send beiðnina þína núna. Reyndu aftur síðar." @@ -3031,9 +3086,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Fjöldi þeirra beiðna sem hægt er að leggja fram á einum degi er takmarkaður því við viljum forðast að stjórnvöld fái mikinn fjölda óviðeigandi beiðna. Hafðu samband ef þér finnst ástæða til að aflétta takmörkuninni í þínu tilfelli." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Ekkert til að sýna enn." @@ -3254,6 +3315,9 @@ msgstr "Hlutinn um tölfræði stjórnvalda er á tilraunastigi svo það eru ý msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "Þessi tafla sýnir tæknilegar upplýsingar um feril beiðnarinnar á {{site_name}}. Þetta má til dæmis nota til að fá fram upplýsingar um það hversu hratt stjórnvöld bregðast við beiðnum og fjölda þeirra beiðna sem þarf að svara bréflega, svo fátt eitt sé nefnt." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3382,9 +3446,15 @@ msgstr "Í dag" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Of margar beiðnir" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Afkastamest upp á síðkastið" @@ -3736,6 +3806,9 @@ msgstr "Skrifa ítrekunarskilaboð vegna upplýsingabeiðni til {{authority_name msgid "Write your request in simple, precise language." msgstr "Skrifaðu beiðnina þín með einföldu, markvissu máli" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3865,6 +3938,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Þú hefur náð hámarksfjölda nýrra beiðna. Takmarkið fyrir notendur er yfirleitt {{max_requests_per_user_per_day}} beiðnir á hverjum sólarhring. Þú getur lagt fram nýja beiðni eftir {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4491,6 +4567,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} beiðni" diff --git a/locale/it/app.po b/locale/it/app.po index a6ae357a4c..e2ae50b431 100644 --- a/locale/it/app.po +++ b/locale/it/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Antonella , 2014-2015 # Claudio Cesarano , 2015-2016 # Giancarlo , 2015 @@ -43,7 +44,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Marco Giustini , 2013\n" "Language-Team: Italian (http://app.transifex.com/mysociety/alaveteli/language/" @@ -468,6 +469,9 @@ msgstr "Tutte le opzioni qui sotto possono usare la variety o < msgid "All time" msgstr "Globale" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "I migliori" @@ -630,6 +634,9 @@ msgstr "Bannato da questo sito" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "Gruppo di richieste creato da {{info_request_user}} il {{date}}." +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "quelle che iniziano per " @@ -693,6 +700,9 @@ msgstr "Cancella alcuni avvisi di {{site_name}} " msgid "Cancel, return to your profile page" msgstr "Cancella e torna al tuo profilo" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Cambia l'indirizzo email su {{site_name}}" @@ -957,6 +967,9 @@ msgstr "Fatto >>" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Scarica un file .zip di tutta la corrispondenza" @@ -1026,6 +1039,9 @@ msgstr "Cronologia" msgid "Every citizen has the right to access information held by public authorities." msgstr "Ogni cittadino ha diritto di accedere alle informazioni possedute dalle pubbliche amministrazioni." +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "Tutto ciò che scrivi in questa pagina, incluso il tuo nome sarà pubblicato su questo sito e sarà visibile (perché?)." @@ -1570,6 +1586,9 @@ msgstr "Ultima richiesta visualizzata: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Scopri di più →" @@ -2247,6 +2266,9 @@ msgstr "" msgid "Rejected" msgstr "Rifiutata" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Ricordami (mantiene l'accesso più a lungo: non usare questa funzione su un computer pubblico)" @@ -2436,6 +2458,9 @@ msgstr "Cerca i tuoi contributi" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Invia un messaggio di risposta" @@ -2472,6 +2497,30 @@ msgstr "Invia un messaggio a {{user_name}} per vedere come funziona" msgid "Sending..." msgstr "Invio in corso..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Spedito da {{info_request_user}} il {{date}}." @@ -2538,6 +2587,9 @@ msgstr "Esci" msgid "Sign up" msgstr "Registrati" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2594,6 +2646,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3013,9 +3068,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Abbiamo impostato un limite al numero di richieste quotidiane che puoi fare, perché non vogliamo che le amministrazioni siano bombardate con un numero eccessivo di richieste, magari non appropriate. Se pensi che nel tuo caso serva un'eccezione scrivici." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Non c'è ancora niente da mostrare." @@ -3239,6 +3300,9 @@ msgstr "Questa sezione sulle statistiche che riguardano le pubbliche amministraz msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "Questa tabella mostra dettagli tecnici relativi alla risposta alla richiesta spedita attraverso {{site_name}}. Può essere usata per ricavare informazioni sulla rapidità di risposta delle amministrazioni, il numero di richieste che richiedono risposta per posta ecc." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3365,9 +3429,15 @@ msgstr "Oggi" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Troppe richieste" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Gli utenti più attivi di recente" @@ -3716,6 +3786,9 @@ msgstr "Rispondi a \"{{authority_name}}\"" msgid "Write your request in simple, precise language." msgstr "Devi scrivere la tua richiesta in un linguaggio semplice e preciso." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3845,6 +3918,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Hai raggiunto il limite di nuove richieste. Gli utenti possono inviare non più di {{max_requests_per_user_per_day}} richieste in un periodo di 24 ore. Potrai inviare una nuova richiesta tra {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4485,6 +4561,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} richiesta" diff --git a/locale/it_IT/app.po b/locale/it_IT/app.po index 58ad0ca11b..0d8fb0db6c 100644 --- a/locale/it_IT/app.po +++ b/locale/it_IT/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Giancarlo , 2015 # guido romeo , 2015 # 1bb8f5eb4bc72723d4109decfd20c765, 2017-2018 @@ -39,7 +40,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Marco Giustini , 2013\n" "Language-Team: Italian (Italy) (http://app.transifex.com/mysociety/alaveteli/l" @@ -464,6 +465,9 @@ msgstr "Tutte le opzioni qui sotto possono usare la variety o < msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "I migliori" @@ -626,6 +630,9 @@ msgstr "Bannato da questo sito" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "Gruppo di richieste creato da {{info_request_user}} il {{date}}." +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "quelle che iniziano per " @@ -689,6 +696,9 @@ msgstr "Cancella alcuni avvisi di {{site_name}} " msgid "Cancel, return to your profile page" msgstr "Cancella e torna al tuo profilo" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Cambia l'indirizzo email su {{site_name}}" @@ -953,6 +963,9 @@ msgstr "Fatto >>" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Scarica un file .zip di tutta la corrispondenza" @@ -1022,6 +1035,9 @@ msgstr "Cronologia" msgid "Every citizen has the right to access information held by public authorities." msgstr "Ogni cittadino ha diritto di accedere alle informazioni possedute dalle pubbliche amministrazioni." +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "Tutto ciò che scrivi in questa pagina, incluso il tuo nome sarà pubblicato su questo sito e sarà visibile (perché?)." @@ -1566,6 +1582,9 @@ msgstr "Ultima richiesta visualizzata: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Scopri di più →" @@ -2243,6 +2262,9 @@ msgstr "" msgid "Rejected" msgstr "Rifiutata" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Ricordami (mantiene l'accesso più a lungo: non usare questa funzione su un computer pubblico)" @@ -2432,6 +2454,9 @@ msgstr "Cerca i tuoi contributi" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Invia un messaggio di risposta" @@ -2468,6 +2493,30 @@ msgstr "Invia un messaggio a {{user_name}} per vedere come funziona" msgid "Sending..." msgstr "Invio in corso..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Spedito da {{info_request_user}} il {{date}}." @@ -2534,6 +2583,9 @@ msgstr "Esci" msgid "Sign up" msgstr "Registrati" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2590,6 +2642,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3009,9 +3064,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Abbiamo impostato un limite al numero di richieste quotidiane che puoi fare, perché non vogliamo che le amministrazioni siano bombardate con un numero eccessivo di richieste, magari non appropriate. Se pensi che nel tuo caso serva un'eccezione scrivici." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Non c'è ancora niente da mostrare." @@ -3235,6 +3296,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "Questa tabella mostra dettagli tecnici relativi alla risposta alla richiesta spedita attraverso {{site_name}}. Può essere usata per ricavare informazioni sulla rapidità di risposta delle amministrazioni, il numero di richieste che richiedono risposta per posta ecc." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3361,9 +3425,15 @@ msgstr "Oggi" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Troppe richieste" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Gli utenti più attivi di recente" @@ -3712,6 +3782,9 @@ msgstr "Rispondi a \"{{authority_name}}\"" msgid "Write your request in simple, precise language." msgstr "Devi scrivere la tua richiesta in un linguaggio semplice e preciso." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3841,6 +3914,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Hai raggiunto il limite di nuove richieste. Gli utenti possono inviare non più di {{max_requests_per_user_per_day}} richieste in un periodo di 24 ore. Potrai inviare una nuova richiesta tra {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4478,6 +4554,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} richiesta" diff --git a/locale/ka/app.po b/locale/ka/app.po index 03ce58957a..4a8cf7ee20 100644 --- a/locale/ka/app.po +++ b/locale/ka/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Jubo Beridzishvili, 2021-2023 # Lela Merabishvili, 2021 # Lela Merabishvili, 2021-2022 @@ -41,9 +42,9 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" -"Last-Translator: Jubo Beridzishvili, 2021-2023\n" +"Last-Translator: Natalie Hiirulainen , 2021,2023\n" "Language-Team: Georgian (http://app.transifex.com/mysociety/alaveteli/language" "/ka/)\n" "MIME-Version: 1.0\n" @@ -449,6 +450,9 @@ msgstr "ქვემოთ მოცემულ ყველა ვარია msgid "All time" msgstr "ყველა დროის" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "ყველა დროის საუკეთესო მოთამაშეები" @@ -611,6 +615,9 @@ msgstr "დაბლოკილია ვებგვერდიდან" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "შექმნილია მომხმარებლის მიერ {{info_request_user}} თარიღით {{date}}." +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "რომლებიც იწყება" @@ -674,6 +681,9 @@ msgstr "ვებგვერდის {{site_name}} ზოგიერთი msgid "Cancel, return to your profile page" msgstr "გააუქმე, ან დაბრუნდი შენი პროფილის გვერდზე" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "შეცვალე ელ-ფოსტა ვებგვერდისთვის {{site_name}}" @@ -944,6 +954,9 @@ msgstr "დასრულება >>" msgid "Download Data" msgstr "მონაცემების გადმოწერა" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "მიმოწერის ისტორიის ZIP ფორმატით გადმოწერა" @@ -1013,6 +1026,9 @@ msgstr "მოქმედებების ისტორია" msgid "Every citizen has the right to access information held by public authorities." msgstr "ყველა მოქალაქეს აქვს უფლება გამოითხოვოს ინფორმაცია, რომელსაც საჯარო დაწესებულებები ფლობენ. " +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "ამ გვერდზე მითითებული ყველა ინფორმაცია, მათ შორის შენი სახელი, პორტალზე საჯაროდ, განუსაზღვრელი ვადით განთავსდება" @@ -1540,6 +1556,9 @@ msgstr "ბოლოს ნანახი მოთხოვნა: {{request_u msgid "Latest" msgstr "უკანასკნელი" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "გაიგე მეტი →" @@ -2222,6 +2241,9 @@ msgstr "რეგულაცია" msgid "Rejected" msgstr "უარყოფილია" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "დამახსოვრება (არ გამოიყენო საჯარო კომპიუტერზე)" @@ -2408,6 +2430,9 @@ msgstr "ძებნა" msgid "Section" msgstr "სექცია" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "პასუხის გაგზავნა" @@ -2444,6 +2469,30 @@ msgstr "წერილის გაგზავნა მომხმარე msgid "Sending..." msgstr "იგზავნება..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "გაუგზავნე {{authority_count}} საჯარო დაწესებულებას {{info_request_user}}-ის მიერ, თარიღით {{date}}." @@ -2509,6 +2558,9 @@ msgstr "გამოსვლა" msgid "Sign up" msgstr "რეგისტრაცია" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2563,6 +2615,9 @@ msgstr "ბოდიში, ამ ეტაპზე შენს ანოტ msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "ბოდიში, შენი მოთხოვნის გაგზავნა ვერ მოხერხდა. მოგვიანებით კიდევ სცადე." @@ -2980,9 +3035,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "ლიმიტის დაწესებით ვცდილობთ, რომ საჯარო დაწესებულებები დიდი ოდენობით შეუსაბამო განცხადებების მიღებისგან დავაზღვიოთ. თუ ფიქრობ, რომ ლეგიტიმური მიზეზი გაქვს ლიმიტის გასაზრდელად, დაგვიკავშირდი." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "საჩვენებელი არაფერია" @@ -3203,6 +3264,9 @@ msgstr "საჯარო უწყების სტატისტიკა msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "მოცემული ცხრილი აღნიშნავს მოთხოვნის ირგვლივ განხორციელებული მოქმედებების ისტორიას პორტალზე {{site_name}}. ცხრილის გამოყენება შეიძლება იმის გასარკვევად, თუ რა სისწრაფით პასუხობდნენ საჯარო დაწესებულებები მოთხოვნებს, რამდენი განაცხადი მოითხოვდა პასუხს საფოსტო მომსახურებით და ა.შ." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "მომხმარებელი დაბლოკილია საიტიდან {{site_name}} " @@ -3329,9 +3393,15 @@ msgstr "დღეს" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "უპს. განცხადებების დღიური ლიმიტი ამოიწურა" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "ბოლო დროის საუკეთესო მოთამაშეები" @@ -3678,6 +3748,9 @@ msgstr "გაუგზავნე საპასუხო წერილი msgid "Write your request in simple, precise language." msgstr " მოკლე და მკაფიო მესიჯებით მიმართვა საჯარო დაწესებულებებს გაუმარტივებს უკეთ აღიქვან შენი მოთხოვნილი ინფორმაციის შინაარსი, რაც ნიშნავს, რომ პასუხს უფრო მალე დაგიბრუნებენ." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "დიახ" @@ -3807,6 +3880,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "სამწუხაროდ, 24 საათის მანძილზე არაუმეტეს {{max_requests_per_user_per_day}} განცხადების გაგზავნა შეგიძლია." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "შენ ეს პროექტი დატოვე" @@ -4427,6 +4503,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "{{number_of_comments}} კომენტარი" msgstr[1] "{{number_of_comments}} კომენტარი" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} მოთხოვნა" diff --git a/locale/mk/app.po b/locale/mk/app.po index 6287167b20..af438011fd 100644 --- a/locale/mk/app.po +++ b/locale/mk/app.po @@ -31,11 +31,12 @@ # Translators: # Translators: # Translators: +# Translators: msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Graeme Porteous \n" "Language-Team: Macedonian (http://app.transifex.com/mysociety/alaveteli/langua" @@ -436,6 +437,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -598,6 +602,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -661,6 +668,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -925,6 +935,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -994,6 +1007,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1521,6 +1537,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2195,6 +2214,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2381,6 +2403,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2417,6 +2442,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2482,6 +2531,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2536,6 +2588,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2953,9 +3008,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3176,6 +3237,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3302,9 +3366,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3651,6 +3721,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3780,6 +3853,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4400,6 +4476,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/mk_MK/app.po b/locale/mk_MK/app.po index a24fedbc3a..ef80f5e8b0 100644 --- a/locale/mk_MK/app.po +++ b/locale/mk_MK/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Liz Conlan , 2018 # louisecrow , 2014 # louisecrow , 2014 @@ -38,7 +39,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: louisecrow , 2014\n" "Language-Team: Macedonian (Macedonia) (http://app.transifex.com/mysociety/alav" @@ -485,6 +486,9 @@ msgstr "Сите опции подолу може да користат msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -653,6 +657,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Започнувајќи со" @@ -716,6 +723,9 @@ msgstr "Откажете некои предупредувања за {{site_nam msgid "Cancel, return to your profile page" msgstr "Откажете и вратете се до страницата на вашиот профил" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Промени е-пошта на {{site_name}}" @@ -990,6 +1000,9 @@ msgstr "Готово >>" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Преземете zip датотека од целата кореспонденција" @@ -1063,6 +1076,9 @@ msgstr "Историја на настани" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Се што ќе внесете на оваа страница, вклучувајќи го и вашето име,\n" @@ -1636,6 +1652,9 @@ msgstr "Последно видено барање: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2325,6 +2344,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2514,6 +2536,9 @@ msgstr "Пребарајте ги вашите придонеси" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Испратете реакција" @@ -2550,6 +2575,30 @@ msgstr "Испратете порака до {{user_name}} само да вид msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2615,6 +2664,9 @@ msgstr "Одјавете се" msgid "Sign up" msgstr "Регистрирајте се" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2675,6 +2727,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3108,9 +3163,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Постои ограничување за бројот на барања кои може да ги направите во еден ден, бидејќи не сакаме имателите да бидат „бомбардирани“ со голем број на барања. Доколку сметате дека имате јака причина зошто ова ограничување не треба да важи за вас, ве молиме стапете во контакт." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3339,6 +3400,9 @@ msgstr "" "брзината со која имателите одговараат на барањата, бројот на барањата\n" "кои изнудуваат одговор преку пошта и др.." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3473,9 +3537,15 @@ msgstr "Денес" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Премногу барања" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3842,6 +3912,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "Напишете го вашето барање со едноставен, прецизен речник." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3971,6 +4044,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Го исполнивте ограничувањето за нови барања. Корисниците обично се ограничени на {{max_requests_per_user_per_day}} барања во период од 24 часа. Ќе може да направите ново барање за {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4620,6 +4696,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/nb/app.po b/locale/nb/app.po index 8104f28fc7..ff4df81ce5 100644 --- a/locale/nb/app.po +++ b/locale/nb/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # 2b81488fecf64b01474cdd73adee6da4_f428fa4 <168fddc5dd8708c6cc0c28446af80acb_220254>, 2017 # andreli , 2013 # Hans-Petter Fjeld , 2014 @@ -56,7 +57,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: pere , 2013,2015\n" "Language-Team: Norwegian Bokmål (http://app.transifex.com/mysociety/alaveteli/" @@ -503,6 +504,9 @@ msgstr "Alle alternativene nedenfor kan bruke variety eller your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Alt som du skriver inn på denne tjenesten, inkludert navnet ditt,\n" @@ -1628,6 +1644,9 @@ msgstr "Siste henvendelse du så på: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Lær mer →" @@ -2315,6 +2334,9 @@ msgstr "" msgid "Rejected" msgstr "Avvist" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Husk meg (lar deg være logget inn lengre, ikke bruk dette på en offentlig datamaskin)" @@ -2504,6 +2526,9 @@ msgstr "Søk i dine bidrag" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Send en oppfølgning" @@ -2540,6 +2565,30 @@ msgstr "Send melding til {{user_name}} bare for å se hvordan det fungerer" msgid "Sending..." msgstr "Sender..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Sendt til en myndighet av {{info_request_user}} den {{date}}." @@ -2605,6 +2654,9 @@ msgstr "Logg ut" msgid "Sign up" msgstr "Lag konto" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2665,6 +2717,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3096,9 +3151,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Det er en grense på antall henvendelser du kan lage på én dag, fordi vi ikke ønsker at offentlige myndigheter skal bli oversvømt med et stort antall upassende henvendelser. Dersom du synes du har en god grunn til at grensen skal økes i ditt tilfelle, vennligst ta kontakt." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Det er ingenting å vise enda." @@ -3323,6 +3384,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "Denne tabellen viser de tekniske detaljene til interne hendelser som skjedde med denne henvendelsen på {{site_name}}. Dette kan brukes til å generere informasjon om hvor raskt ulike etater svarer på henvendelser, antall henvendelser som krever papirpostsvar og mye mer." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3455,9 +3519,15 @@ msgstr "Idag" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "For mange henvendelser" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3822,6 +3892,9 @@ msgstr "Skriv din oppfølgningsmelding til {{authority_name}}" msgid "Write your request in simple, precise language." msgstr "Skriv henvendelsen i enkelt, nøyaktig språk." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3951,6 +4024,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Du har truffet grensen for antall nye henvendelser. Brukere er ordinært begrenset til {{max_requests_per_user_per_day}} henvendelser i en 24-timers periode. Du kan gjøre en ny henvendelse {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4591,6 +4667,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} henvendelse" diff --git a/locale/ne/app.po b/locale/ne/app.po index 4d17a80681..22fb6423c1 100644 --- a/locale/ne/app.po +++ b/locale/ne/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Amit Shrestha , 2017 # Anjesh Ojha , 2017 # arjun gautam , 2016 @@ -65,7 +66,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Yudeep Rajbhandari , 2017\n" "Language-Team: Nepali (http://app.transifex.com/mysociety/alaveteli/language/n" @@ -495,6 +496,9 @@ msgstr "तल रहेका सबै विकल्प varietyyour name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "तपाईँ ले यो पेजमा लेख्नु भएको हरेक कुराहरू,तपाईँको सहितनामसहित,\n" @@ -1619,6 +1635,9 @@ msgstr "अन्तिम पटक हेरिएको: {{request_url}} " msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "थप जान्नुहोस् →" @@ -2295,6 +2314,9 @@ msgstr "" msgid "Rejected" msgstr "फर्काइयो" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "मलाई सम्झनुहोस् (लामो समयसम्म प्रवेश गराइराख्छ;सार्वजनिक कम्प्युटरमा प्रयोग नगर्नुहोस्)" @@ -2484,6 +2506,9 @@ msgstr "तपाईंको योगदान खोज" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "फलोअप पठाउनुहोस्" @@ -2520,6 +2545,30 @@ msgstr "कसरी काम गर्छ भनेर हेर्नका msgid "Sending..." msgstr "पठाउँदै..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "{{date}} मा {{info_request_user}} द्वारा एउटा निकायलाई पठाइएको | " @@ -2585,6 +2634,9 @@ msgstr "साइन आउट गर्नुहोस्" msgid "Sign up" msgstr "साइन अप गर्नुहोस्" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2645,6 +2697,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3064,9 +3119,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "एक दिनमा कति सन्देश पठाउने भन्ने सीमाना छ, किन भने सार्वजनिक निकायहरू हाम्रो साइटबाट प्राप्त हुने अनुरोधहरूबाट ग्रसित नहुन्। यदि तपाईँको यस सीमालाई हटाइनु पर्छ भन्ने तपाईँसँग कुनै कारण छ भने थाह दिनुहोस्।" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "हालसम्म देखाउनको लागी केहि छैन |" @@ -3295,6 +3356,9 @@ msgstr "" "र कसलाई कति वटा अनुरोधहरू छन् भन्ने पनि\n" "कतिलाई हुलाकद्वारा जवाफ दिनु पर्छ इत्यादि। " +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3425,9 +3489,15 @@ msgstr "आज" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "धेरै अनुरोधहरू" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "हालका शीर्ष प्रयोगकर्ताहरू" @@ -3779,6 +3849,9 @@ msgstr "{{authority_name}}मा तपाईंले FOI सन्देश msgid "Write your request in simple, precise language." msgstr "सटीक, सरल भाषामा आफ्नो अनुरोध लेख्नुहोस्" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3908,6 +3981,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "तपाईंले नयाँ अनुरोधमा दर सीमा भेटाउनु भ​एको छ​। प्रयोगकर्ताहरु सामान्यतया २४-घण्टाको अवधिमा {{max_requests_per_user_per_day}} अनुरोधमा सिमित छन्। तपाईं {{can_make_another_request}}मा अर्को अनुरोध गर्न सक्षम हुनुहुनेछ।" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4547,6 +4623,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} अनुरोध" diff --git a/locale/ne_NP/app.po b/locale/ne_NP/app.po index f2a8bc361e..656593c3bb 100644 --- a/locale/ne_NP/app.po +++ b/locale/ne_NP/app.po @@ -31,11 +31,12 @@ # Translators: # Translators: # Translators: +# Translators: msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Graeme Porteous \n" "Language-Team: Nepali (Nepal) (http://app.transifex.com/mysociety/alaveteli/la" @@ -436,6 +437,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -598,6 +602,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -661,6 +668,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -925,6 +935,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -994,6 +1007,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1521,6 +1537,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2195,6 +2214,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2381,6 +2403,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2417,6 +2442,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2482,6 +2531,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2536,6 +2588,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2953,9 +3008,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3176,6 +3237,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3302,9 +3366,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3651,6 +3721,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3780,6 +3853,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4400,6 +4476,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/nl/app.po b/locale/nl/app.po index 191bc48492..03c0e7af95 100644 --- a/locale/nl/app.po +++ b/locale/nl/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Edwin Bosveld , 2013,2016 # Gareth Rees , 2020 # Graeme Porteous , 2019,2021 @@ -43,7 +44,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Luis Villegas, 2022\n" "Language-Team: Dutch (http://app.transifex.com/mysociety/alaveteli/language/nl" @@ -480,6 +481,9 @@ msgstr "Alle opties hieronder kunnen voor de dubbele punt varietyyour name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Alles wat je op deze pagina invult, ook je naam, \n" @@ -1609,6 +1625,9 @@ msgstr "Laatst bekeken verzoek: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Meer weten →" @@ -2289,6 +2308,9 @@ msgstr "" msgid "Rejected" msgstr "Geweigerd" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Aangemeld blijven (gebruik dit niet op een openbare computer)" @@ -2475,6 +2497,9 @@ msgstr "Doorzoek je bijdragen" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Stuur een follow-up bericht" @@ -2511,6 +2536,30 @@ msgstr "Verstuur een bericht aan {{user_name}} om te zien hoe het werkt" msgid "Sending..." msgstr "Wordt verzonden..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Verzonden naar een overheidsinstantie door {{info_request_user}} on {{date}}." @@ -2576,6 +2625,9 @@ msgstr "Log uit" msgid "Sign up" msgstr "Schrijf je in" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2630,6 +2682,9 @@ msgstr "Tot onze spijt kunnen wij je opmerking niet plaatsen. Probeer het later msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "Tot onze spijt kunnen wij je Woo-verzoek niet verzenden. Probeer het later alsjeblieft opnieuw." @@ -3051,9 +3106,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Er is een limiet aan het aantal verzoeken dat je per dag kunt versturen, omdat we niet willen dat de overheidsinstanties gebombardeerd worden met grote aantallen ongepaste verzoeken. Als je van mening bent dat je een goede reden hebt dat de limiet voor jou moet worden opgehoogd, gelieve ons te contacteren." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Er is voorlopig nog niets te tonen." @@ -3280,6 +3341,9 @@ msgstr "" "Deze tabel toont de technische details van de interne gebeurtenissen m.b.t. dit verzoek op {{site_name}}. Deze gegevens zouden gebruikt kunnen worden om informatie te verzamelen over de \n" " snelheid waarmee overheidsinstanties besluiten op verzoeken, het aantal verzoeken die per post beantwoord moeten worden, enzovoort." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "Deze gebruiker wordt tijdelijk geweerd van {{site_name}} " @@ -3425,9 +3489,15 @@ msgstr "Vandaag" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Te veel verzoeken" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Recente topspelers" @@ -3783,6 +3853,9 @@ msgstr "Formuleer een follow-up bericht over je Woo-verzoek aan {{authority_name msgid "Write your request in simple, precise language." msgstr "Formuleer je verzoek eenvoudig en nauwkeurig." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3912,6 +3985,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Je hebt het maximaal toegestane aantal verzoeken verstuurd. Het aantal verzoeken is beperkt tot {{max_requests_per_user_per_day}} per 24u. Je kunt weer een nieuw verzoek doen op {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4534,6 +4610,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "{{number_of_comments}} commentaar" msgstr[1] "{{number_of_comments}} opmerkingen" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} vraag" diff --git a/locale/nl_BE/app.po b/locale/nl_BE/app.po index c3465f8bdc..56c9bf2a88 100644 --- a/locale/nl_BE/app.po +++ b/locale/nl_BE/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Christophe Van Gheluwe , 2017 # claude transparencia , 2017-2018,2021 # Edwin Bosveld , 2013,2016 @@ -43,7 +44,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: louisecrow , 2017\n" "Language-Team: Dutch (Belgium) (http://app.transifex.com/mysociety/alaveteli/l" @@ -478,6 +479,9 @@ msgstr "Alle opties hieronder kunnen voor de dubbele punt varietyyour name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Alles wat u op deze pagina invult, ook uw naam, \n" @@ -1610,6 +1626,9 @@ msgstr "Laatst bekeken aanvraag: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Meer weten →" @@ -2290,6 +2309,9 @@ msgstr "" msgid "Rejected" msgstr "Geweigerd" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Aangemeld blijven (gebruik dit niet op een openbare computer)" @@ -2479,6 +2501,9 @@ msgstr "Zoek uw bijdragen" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Verzend een opvolgbericht" @@ -2515,6 +2540,30 @@ msgstr "Zend het bericht aan {{user_name}}, enkel om te zien hoe het werkt" msgid "Sending..." msgstr "Wordt verzonden..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Verzonden naar een overheidsinstantie door {{info_request_user}} on {{date}}." @@ -2580,6 +2629,9 @@ msgstr "Deconnecteer" msgid "Sign up" msgstr "Schrijf u in" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2638,6 +2690,9 @@ msgstr "Tot onze spijt kunnen wij uw commentaar thans niet toevoegen. Probeer a. msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "Tot onze spijt kunnen wij uw aanvraag nu niet verzenden. Probeer a.u.b. later opnieuw." @@ -3065,9 +3120,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Er staat een limiet op het aantal aanvragen dat u per dag kunt uitvoeren, omdat we niet willen dat de overheidsinstellingen gebombardeerd worden met een ongepast aantal aanvragen. Als u meent dat u een goede reden heeft om deze limiet voor u te verhogen, gelieve dan ons te contacteren." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Er is voorlopig nog niets te tonen." @@ -3294,6 +3355,9 @@ msgstr "" "Deze tabel toont de technische details van de interne gebeurtenissen m.b.t. deze aanvraag uitgevoerd via {{site_name}}. Deze gegevens zouden kunnen gebruikt worden om informatie op te stellen aangaande de \n" " snelheid waarmee de overheidsinstellingen antwoorden, het aantal aanvragen die een antwoord per post vereisen en veel meer." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3426,9 +3490,15 @@ msgstr "Vandaag" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Te veel aanvragen" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "De meest recente spelers" @@ -3786,6 +3856,9 @@ msgstr "Formuleer uw WOB follow-up bericht aan {{authority_name}}" msgid "Write your request in simple, precise language." msgstr "Formuleer uw vraag eenvoudig en nauwkeurig." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3915,6 +3988,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "U heeft de limiet voor nieuwe aanvragen bereikt. De gebruikers zijn beperkt tot {{max_requests_per_user_per_day}} aanvragen per 24u. U kan een nieuwe aanvraag doen op {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4543,6 +4619,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "{{number_of_comments}} commentaar" msgstr[1] "{{number_of_comments}} commentaren" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} vraag" diff --git a/locale/nn/app.po b/locale/nn/app.po index eeb2210c11..8533c5c868 100644 --- a/locale/nn/app.po +++ b/locale/nn/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # andreli , 2013 # Hans-Petter Fjeld , 2014 # b99f4c81950a40007b4adaea695ecb99_1c02644 , 2015 @@ -55,7 +56,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: velmont , 2015\n" "Language-Team: Norwegian Nynorsk (http://app.transifex.com/mysociety/alaveteli" @@ -500,6 +501,9 @@ msgstr "Alle alternativa nedanfor kan bruka variety eller your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Alt som du skriv inn på denne tenesta, inkluderte namnet ditt,\n" @@ -1627,6 +1643,9 @@ msgstr "Siste førespurnad du såg på: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Lær meir →" @@ -2314,6 +2333,9 @@ msgstr "" msgid "Rejected" msgstr "Avvist" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Hugs meg (lèt deg loggast inn lengre, ikkje bruk dette på ei offentleg datamaskin)" @@ -2503,6 +2525,9 @@ msgstr "Søk i bidraga dine" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Send ei oppfølging" @@ -2539,6 +2564,30 @@ msgstr "Send melding til {{user_name}} berre for å sjå korleis det fungerer" msgid "Sending..." msgstr "Sender..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Sendt til ei styresmakt av {{info_request_user}} den {{date}}." @@ -2604,6 +2653,9 @@ msgstr "Logg ut" msgid "Sign up" msgstr "Lag konto" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2664,6 +2716,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3095,9 +3150,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Det er ei grense på mengd førespurnader du kan laga på éin dag, fordi vi ikkje ynskjer at offentlege styresmakter skal oversymjast med ei stort mengd upassande førespurnader. Dersom du synest du har ein god grunn til at grensa skal aukast i tilfellet ditt, ver venleg og ta kontakt." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Det er ikkje noko å visa endå." @@ -3322,6 +3383,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "Denne tabellen viser dei tekniske detaljane til interne hendingar som skjedde med denne førespurnaden på {{site_name}}. Dette kan brukast til å generera informasjon om der raskt ulike etatar svarar på førespurnader, mengd førespurnader som krev papirpostsvar og mykje meir." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3455,9 +3519,15 @@ msgstr "Idag" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "For mange førespurnader" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3818,6 +3888,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "Skriv førespurnaden i enkelt, nøyaktig språk." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3947,6 +4020,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Du har treft grensa for mengd nye førespurnader. Brukarar er ordinært avgrensa til {{max_requests_per_user_per_day}} førespurnader i perioden til-ein 24 timar. Du kan gjera ein ny førespurnad {{can_maka_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4587,6 +4663,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/pap/app.po b/locale/pap/app.po index 1830a6c612..85a6e940f4 100644 --- a/locale/pap/app.po +++ b/locale/pap/app.po @@ -31,13 +31,14 @@ # Translators: # Translators: # Translators: +# Translators: # Luis Villegas, 2022 # Luis Villegas, 2022 msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Luis Villegas, 2022\n" "Language-Team: Papiamento (http://app.transifex.com/mysociety/alaveteli/langua" @@ -448,6 +449,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -610,6 +614,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -673,6 +680,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -937,6 +947,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -1006,6 +1019,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1533,6 +1549,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2207,6 +2226,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2393,6 +2415,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2429,6 +2454,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2494,6 +2543,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2548,6 +2600,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2965,9 +3020,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3188,6 +3249,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3314,9 +3378,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3663,6 +3733,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3792,6 +3865,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4412,6 +4488,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/pl/app.po b/locale/pl/app.po index 45c60625fb..98d1a5e342 100644 --- a/locale/pl/app.po +++ b/locale/pl/app.po @@ -31,13 +31,14 @@ # Translators: # Translators: # Translators: +# Translators: # Ewa Modrzejewska , 2013 # Ewa Modrzejewska , 2013 msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Ewa Modrzejewska , 2013\n" "Language-Team: Polish (http://app.transifex.com/mysociety/alaveteli/language/p" @@ -440,6 +441,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -602,6 +606,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -665,6 +672,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -929,6 +939,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -998,6 +1011,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1525,6 +1541,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2199,6 +2218,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2385,6 +2407,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2421,6 +2446,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2486,6 +2535,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2540,6 +2592,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2957,9 +3012,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3180,6 +3241,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3306,9 +3370,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3655,6 +3725,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3784,6 +3857,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4404,6 +4480,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/pt_BR/app.po b/locale/pt_BR/app.po index 90356dcb4b..41eb8567e5 100644 --- a/locale/pt_BR/app.po +++ b/locale/pt_BR/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # elaste <3laste2000@gmail.com>, 2012 # serramassuda , 2012 # Bruno , 2012 @@ -76,7 +77,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Vítor Márcio Paiva de Sousa Baptista , 2013\n" @@ -504,6 +505,9 @@ msgstr "Todas as opções abaixo podem usar variedade ou your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "Tudo o que você publicar nesta página, incluindo seu nome, será exibido publicamente neste site para sempre ( por quê? )." @@ -1600,6 +1616,9 @@ msgstr "Último pedido visualizado: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2274,6 +2293,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2460,6 +2482,9 @@ msgstr "Buscar suas contribuições" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Enviar um mensagem de acompanhamento" @@ -2496,6 +2521,30 @@ msgstr "Enviar mensagem para {{user_name}} veja como isso funciona" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2561,6 +2610,9 @@ msgstr "Sair" msgid "Sign up" msgstr "Cadastrar" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2615,6 +2667,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3037,9 +3092,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Há um limite de pedidos de informação que você pode fazer em um dia, porque não queremos que as autoridades públicas sejam bombardeadas por um número grande de pedidos inapropriados. Se você considera ter uma boa razão para seu limite ser ampliado, por favor nos contate." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3265,6 +3326,9 @@ msgstr "" "Esta tabela mostra detalhes técnicos dos eventos internos que\n" "aconteceram para esta requisição no {{site_name}}. Isto pode ser usado para gerar informação sobre a velocidade com a qual autoridades respondem às requisições, o número de requisições que requerem uma resposta por correio e muito mais." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3393,9 +3457,15 @@ msgstr "Hoje" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Excessivas requisições" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3742,6 +3812,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "Escreva seu pedido de forma simples." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3871,6 +3944,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Você atingiu o raro limite de pedidos novos. Usuários estão normalmente limitados a {{max_requests_per_user_per_day}} pedidos em um período de 24 horas. Você poderá fazer outro pedido em {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4513,6 +4589,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/pt_PT/app.po b/locale/pt_PT/app.po index 14e72b4f63..90948c9941 100644 --- a/locale/pt_PT/app.po +++ b/locale/pt_PT/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Bruno , 2012 # Carlos Vieira , 2011 # danielabsilva , 2011 @@ -60,7 +61,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Vítor Márcio Paiva de Sousa Baptista , 2013\n" @@ -488,6 +489,9 @@ msgstr "Todas as opções abaixo podem usar variedade ou your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "Tudo o que você publicar nesta página, incluindo seu nome, será exibido publicamente neste site para sempre ( por quê? )." @@ -1588,6 +1604,9 @@ msgstr "Último pedido visualizado: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2262,6 +2281,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Lembre-se de mim (mantém-te autenticado por mais tempo; não utilizar num computador público)" @@ -2451,6 +2473,9 @@ msgstr "Buscar suas contribuições" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Enviar um mensagem de acompanhamento" @@ -2487,6 +2512,30 @@ msgstr "Enviar mensagem para {{user_name}} veja como isso funciona" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Enviado a uma entidade por {{info_request_user}} em{{date}}." @@ -2553,6 +2602,9 @@ msgstr "Sair" msgid "Sign up" msgstr "Cadastrar" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2607,6 +2659,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3029,9 +3084,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Há um limite de pedidos de informação que você pode fazer em um dia, porque não queremos que as autoridades públicas sejam bombardeadas por um número grande de pedidos inapropriados. Se você considera ter uma boa razão para seu limite ser ampliado, por favor contacte-nos." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Ainda não existe informação para divulgar." @@ -3259,6 +3320,9 @@ msgstr "" "a velocidade com a qual as entidades respondem aos pedidos, o número de pedidos\n" " que requerem uma resposta por correio e muito mais." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3387,9 +3451,15 @@ msgstr "Hoje" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Excessivas requisições" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3738,6 +3808,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "Escreva seu pedido de forma simples." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3867,6 +3940,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Você atingiu o raro limite de pedidos novos. Usuários estão normalmente limitados a {{max_requests_per_user_per_day}} pedidos em um período de 24 horas. Você poderá fazer outro pedido em {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4511,6 +4587,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/ro_RO/app.po b/locale/ro_RO/app.po index 643680e54e..2334cb923d 100644 --- a/locale/ro_RO/app.po +++ b/locale/ro_RO/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Andra Ciuraru , 2016 # Andrei Cristian Petcu , 2012-2013 # Andrei Cristian Petcu , 2012-2013 @@ -60,7 +61,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Vitalie Zama , 2016\n" "Language-Team: Romanian (Romania) (http://app.transifex.com/mysociety/alavetel" @@ -501,6 +502,9 @@ msgstr "Toate opţiunile de mai jos pot utiliza varietatea sa msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "Cei mai buni jucători" @@ -667,6 +671,9 @@ msgstr "Blocat pe acest site" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "Grup de solicitări create de {{info_request_user}} la data de {{date}}." +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Începând cu" @@ -730,6 +737,9 @@ msgstr "Anulaţi niste alerte {{site_name}} " msgid "Cancel, return to your profile page" msgstr "Anulează şi revino la pagina ta de profil" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Modificaţi emailul pe {{site_name}}" @@ -998,6 +1008,9 @@ msgstr "Făcut >>" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Descărcaţi un fisier .zip cu toată corespondenţa" @@ -1071,6 +1084,9 @@ msgstr "Istoric evenimente" msgid "Every citizen has the right to access information held by public authorities." msgstr "Fiecare cetățean are dreptul să acceseze informațiile deținute de instituțiile publice." +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Tot ce introduci pe această pagină, inclusiv numele tău, \n" @@ -1649,6 +1665,9 @@ msgstr "Ultima cerere vizionată {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Învață mai multe →" @@ -2338,6 +2357,9 @@ msgstr "" msgid "Rejected" msgstr "Respins" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Ține-mă minte (te menține autentificate o perioadă mai lungă; nu folosi pe un computer public)" @@ -2527,6 +2549,9 @@ msgstr "Caută contribuţia ta" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Trimiteţi o urmărire" @@ -2563,6 +2588,30 @@ msgstr "Trimite un mesaj către {{user_name}} doar să vedeţi cum funcţioneaz msgid "Sending..." msgstr "Se trimite..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Trimis către o instituție publică de utilizatorul {{info_request_user}} la data {{date}}." @@ -2629,6 +2678,9 @@ msgstr "Ieşire din cont" msgid "Sign up" msgstr "Înscriere " +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2688,6 +2740,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3115,9 +3170,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Există o limită a numărului de cereri pe care le puteţi face într-o zi, deoarece nu dorim ca autorităţile publice să fie bombardate cu un mare număr de cereri inadecvate. Dacă consideraţi că aveţi un motiv întemeiat pentru a cere mărirea acestei limite, vă rugăm contactaţi." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Încă nu este nimic de afișat." @@ -3347,6 +3408,9 @@ msgstr "" "viteza cu care autorităţile răspund la solicitări, la numărul de solicitări\n" "care au nevoie de un răspuns scris şi multe altele." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3479,9 +3543,15 @@ msgstr "Azi" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Prea multe cereri" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Topul utilizatorilor." @@ -3850,6 +3920,9 @@ msgstr "Scrie un mesaj ulterior instituției {{authority_name}}" msgid "Write your request in simple, precise language." msgstr "Formulează solicitarea ta într-un limbaj precis, simplu." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3979,6 +4052,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Aţi atins limita maximă pentru cereri. Utilizatorii sunt de obicei limitaţi la {{max_requests_per_user_per_day}} cereri într-un interval de 24 de ore. Veţi putea face o nouă cerere în {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4634,6 +4710,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/rw/app.po b/locale/rw/app.po index 70c142f126..7cc01ea7bc 100644 --- a/locale/rw/app.po +++ b/locale/rw/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Clarisse Umutesi Mwitegereze , 2014-2015 # Gareth Rees , 2015 # Graeme Porteous , 2020 @@ -44,7 +45,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Stephen Abbott Pugh , 2015\n" "Language-Team: Kinyarwanda (http://app.transifex.com/mysociety/alaveteli/langu" @@ -491,6 +492,9 @@ msgstr "Amahitamo yose akurikira ashobora gukoreshwaho impindukayour name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Ibintu byose ushyira kuri uru rubuga, harimo amazina yawe,\n" @@ -1638,6 +1654,9 @@ msgstr "Ikibazo giheruka kurebwa: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Menya byinshi →" @@ -2327,6 +2346,9 @@ msgstr "" msgid "Rejected" msgstr "Cyanzwe" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Munyibuke (ituma ukomeza kuba ku murongo igihe kirekire; ntuyikoreshe kuri mudasobwa rusange)" @@ -2516,6 +2538,9 @@ msgstr "Shaka inyunganizi zawe" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Ohereza ubutumwa bwo gurikirana" @@ -2552,6 +2577,30 @@ msgstr "Oherereza ubutumwa {{user_name}} kureba gusa uko ikora " msgid "Sending..." msgstr "Inyandiko irikugenda…" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Byohererejwe umuyobozi na {{info_request_user}} kuwa {{date}}." @@ -2617,6 +2666,9 @@ msgstr "Sohoka" msgid "Sign up" msgstr "Funguza" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2677,6 +2729,9 @@ msgstr "Mutwihanganire ntidushoboye kongeraho ubusobanuro.Muze kongere mu gihe k msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "Mwihangane,ntabow dushoboye kohereza ikibazo cyanyu.Muze kongera mu gihe kiri imbere." @@ -3110,9 +3165,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Hari umubare ntarengwa w'ibibazo ushobora kubaza ku munsi, kuberako tutifuza ko abayobozi babazwa ibibazo byinshi bidakwiye. Niba wumva ifite impamvu ifatika yatuma usaba guhabwa umubare w'ibibazo birenze, ushobora kutwandikira." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Nta kintu cyo kugaragaza kiraboneka." @@ -3341,6 +3402,9 @@ msgstr "" "gihe abayobozi bafata mu gusubiza ibibazo, umubare w'ibibazo\n" "bisubizwa hakoreshejwe iposita n'ibindi byinshi." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3475,9 +3539,15 @@ msgstr "Uyu munsi" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Ibibazo byinshi cyane" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Abakinyi bitwaye neze mu buryo buhambaye" @@ -3844,6 +3914,9 @@ msgstr "Andika ubutumwa bukurikirana ibyo wasabye kuri {{authority_name}}" msgid "Write your request in simple, precise language." msgstr "Andika ikibazo cyawe mu magambo yoroshye kandi urasa ku ntego." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3973,6 +4046,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Wagejeje umubare w'ibibazo ntarengwa. Abakoresha uru rubuga basanzwe bemerewe ibibazo {{max_requests_per_user_per_day}} mu gihe cy'amasaha 24. Ushobora kubaza ikindi kibazo mu {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4623,6 +4699,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} ibyasabwe" diff --git a/locale/se/app.po b/locale/se/app.po index 5f6a049876..b2d1782b0a 100644 --- a/locale/se/app.po +++ b/locale/se/app.po @@ -31,11 +31,12 @@ # Translators: # Translators: # Translators: +# Translators: msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Graeme Porteous \n" "Language-Team: Northern Sami (http://app.transifex.com/mysociety/alaveteli/lan" @@ -436,6 +437,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -598,6 +602,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -661,6 +668,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -925,6 +935,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -994,6 +1007,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1521,6 +1537,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2195,6 +2214,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2381,6 +2403,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2417,6 +2442,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2482,6 +2531,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2536,6 +2588,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2953,9 +3008,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3176,6 +3237,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3302,9 +3366,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3651,6 +3721,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3780,6 +3853,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4400,6 +4476,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/si/app.po b/locale/si/app.po index 4666056385..76022a6555 100644 --- a/locale/si/app.po +++ b/locale/si/app.po @@ -31,11 +31,12 @@ # Translators: # Translators: # Translators: +# Translators: msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Graeme Porteous \n" "Language-Team: Sinhala (http://app.transifex.com/mysociety/alaveteli/language/" @@ -436,6 +437,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -598,6 +602,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -661,6 +668,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -925,6 +935,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -994,6 +1007,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1521,6 +1537,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2195,6 +2214,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2381,6 +2403,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2417,6 +2442,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2482,6 +2531,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2536,6 +2588,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2953,9 +3008,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3176,6 +3237,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3302,9 +3366,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3651,6 +3721,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3780,6 +3853,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4400,6 +4476,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/sk/app.po b/locale/sk/app.po index 6ba0834140..8faccf37e7 100644 --- a/locale/sk/app.po +++ b/locale/sk/app.po @@ -31,11 +31,12 @@ # Translators: # Translators: # Translators: +# Translators: msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Graeme Porteous \n" "Language-Team: Slovak (http://app.transifex.com/mysociety/alaveteli/language/s" @@ -437,6 +438,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -599,6 +603,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -662,6 +669,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -926,6 +936,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -995,6 +1008,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1522,6 +1538,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2196,6 +2215,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2382,6 +2404,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2418,6 +2443,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2483,6 +2532,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2537,6 +2589,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2954,9 +3009,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3177,6 +3238,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3303,9 +3367,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3652,6 +3722,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3781,6 +3854,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4401,6 +4477,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/sl/app.po b/locale/sl/app.po index c732b21090..3fea9a9725 100644 --- a/locale/sl/app.po +++ b/locale/sl/app.po @@ -31,9 +31,11 @@ # Translators: # Translators: # Translators: +# Translators: # Ana Šemerl Harmel, 2022 # Ana Šemerl Harmel, 2022 # Jernej Trebežnik, 2023 +# Jernej Trebežnik, 2023 # Liz Conlan , 2018 # louisecrow , 2014 # louisecrow , 2014 @@ -47,9 +49,9 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" -"Last-Translator: Jernej Trebežnik, 2023\n" +"Last-Translator: zejn , 2013\n" "Language-Team: Slovenian (http://app.transifex.com/mysociety/alaveteli/languag" "e/sl/)\n" "MIME-Version: 1.0\n" @@ -473,6 +475,9 @@ msgstr "Pri vseh izbirah spodaj lahko uporabite variety ali your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "Vse kar vpisujete na tej strani, vključno z vašim imenom, bo za vedno javno objavljeno na tej strani (zakaj?)." @@ -1599,6 +1616,9 @@ msgstr "Zadnji pregledani zahtevek: {{request_url}}" msgid "Latest" msgstr "Najnovejše" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Več informacij →" @@ -2285,6 +2305,9 @@ msgstr "Predpisi" msgid "Rejected" msgstr "Zavrnjeno" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Zapomni si me ( dlje časa boste ostali prijavljeni; ne uporabljajte v javno dostopnem računalniku)" @@ -2474,6 +2497,9 @@ msgstr "Iščite po vaših prispevkih" msgid "Section" msgstr "Oddelek" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Pošljite odziv" @@ -2510,6 +2536,30 @@ msgstr "Pošlji sporočilo {{user_name}}, da vidite kako deluje" msgid "Sending..." msgstr "Pošiljanje..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Poslal na en organ {{info_request_user}} v {{date}}." @@ -2577,6 +2627,9 @@ msgstr "Odjava" msgid "Sign up" msgstr "Nov račun" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "Prijave iz Tor so blokirane zaradi obsežne zlorabe. Prosimo, stopite v stik z nami, če je to za vas težava." @@ -2637,6 +2690,9 @@ msgstr "Oprostite, trenutno ne moremo dodati vašega zaznamka. Prosimo poskusite msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "Oprostite, trenutno ne moremo ustvariti vašega uporabniškega računa. Prosimo poskusite ponovno kasneje." +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "Oprostite, vaše zahteve trenutno ne moremo poslati. Prosimo poskusite ponovno kasneje." @@ -3059,9 +3115,15 @@ msgstr "Obstaja več kot ena oseba ki uporablja to stran in i msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Število pripisov, ki jih lahko naredite v enem dnevu je omejeno, ker ne želimo, da bi bilo spletno mesto bombardirano z velikim številom neprimernih pripisov. Če menite, da imate upravičen razlog za dvig te omejitve nas kontaktirajte " +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Obstaja omejitev na število dnevnih zahtevkov, ki jih lahko naredite, ker ne želimo javnih organov zasuti z veliko količino zahtevkov z neprimernimi zahtevami. Če se vam zdi, da imate upravičen razlog za dvig omejitve, nas kontaktirajte." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Ni ničesar za prikazati." @@ -3286,6 +3348,9 @@ msgstr "Ta stran s statistikami o javnih organih je trenutno v preizkusni fazi, msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "Ta tabela prikazuje tehnične podrobnosti internih dogodkov, ki so se dogajali na tem zahtevku na {{site_name}}. To lahko uporabite, da zgenerirate informacije o odzivnosti oz. hitrosti, s katero organi odgovarjajo na zahteve, število zahtev ki zahtevajo poštno pošiljanje in še mnogo več." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "Uporabnik je bil izključen iz {{site_name}} " @@ -3414,9 +3479,15 @@ msgstr "Danes" msgid "Too many annotations" msgstr "Preveč opomb" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Preveč zahtevkov" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Najboljši nedavni prosilci" @@ -3769,6 +3840,9 @@ msgstr "Napišite nadaljnje sporočilo za dostop do informacij javnega značaja msgid "Write your request in simple, precise language." msgstr "Zapišite vaš zahtevek v enostavnem in nedvoumnem jeziku." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "Da" @@ -3907,6 +3981,9 @@ msgstr "Dosegli ste limit komentarjev. Uporabniki so ponavadi omejeni na {{comme msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Prišli ste do omejitve števila novih zahtevkov. Uporabniki so običajno omejeni na {{max_requests_per_user_per_day}} na 24 urno obdobje. Nov zahtevek boste lahko naredili v {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "Zapustili ste projekt." @@ -4563,6 +4640,11 @@ msgstr[1] "{{number_of_comments}} komentarjev" msgstr[2] "{{number_of_comments}} komentarjev" msgstr[3] "{{number_of_comments}} komentarjev" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} zahteva" diff --git a/locale/sq/app.po b/locale/sq/app.po index aac84b18dd..28b028c912 100644 --- a/locale/sq/app.po +++ b/locale/sq/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # arianit , 2022 # arianit , 2012 # arianit , 2012,2022 @@ -50,7 +51,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Valon , 2011\n" "Language-Team: Albanian (http://app.transifex.com/mysociety/alaveteli/language" @@ -482,6 +483,9 @@ msgstr "Te gjitha opsionet si me poshte mund te perdorin varietyyour name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Çdo gjë që ke shkruar në këtë faqe, përfshi edhe emrin tënd, \n" @@ -1584,6 +1600,9 @@ msgstr "Kerkesa e fundit e pare: {{request_url}}" msgid "Latest" msgstr "Më të fundit" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Meso me teper →" @@ -2265,6 +2284,9 @@ msgstr "Rregullorja" msgid "Rejected" msgstr "Refuzuar" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Më kutjo mua (të mban signed in më gjatë; mos e përdorni në kompjutera publik)" @@ -2454,6 +2476,9 @@ msgstr "Kërko kontributet e tua" msgid "Section" msgstr "Seksioni" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Dërgo mesazh vijues" @@ -2490,6 +2515,30 @@ msgstr "Dërgo mesazh tek {{user_name}} vetëm për të parë se si funksionon" msgid "Sending..." msgstr "Duke derguar..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Derguar tek nje institucion nga {{info_request_user}} me {{date}}." @@ -2555,6 +2604,9 @@ msgstr "Ç'kyçu" msgid "Sign up" msgstr "Regjistrohu" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "Regjistrimet nga Tor janë bllokuar për shkak të keqpërdorimit të gjerë. Ju lutemi na kontaktoni nëse ky është një problem për ju." @@ -2611,6 +2663,9 @@ msgstr "Na vjen keq që për momentin nuk mund të shtojmë shënimin. Provoni p msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "Na vjen keq, për momentin nuk jemi të gjendje të krijojmë llogarinë tuaj. Provo më vonë." +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "Na vjen keq, për momentin nuk mund të dërgojmë kërkesën. Provo prap më vonë." @@ -3036,9 +3091,15 @@ msgstr "Ka më shumë se një person që përdor këtë faqe dhe ka këtë emër msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Ekziston një kufi në numrin e shënimeve që mund të bëni brenda një dite, sepse ne nuk duam që faqja të bombardohet me një numër të madh shënimesh të papërshtatshme. Nëse mendoni se keni një arsye të mirë për të kërkuar heqjen e kufirit në rastin tuaj, ju lutemi na kontaktoni." +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Ka nje kufi lidhur me numrin e kerkesave qe mund te dergoni ne nje dite, sepse nuk duam qe institucionet publike te bombardohen me nje numer te madh kerkesash te papershtatshme. Nese ju mnedoni se keni asye te forta per te kerkuar anullimin e kufirit per rastin tuaj, ju lutem na kontaktoni." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Nuk ka ende asgje per t'u shfaqur" @@ -3264,6 +3325,9 @@ msgstr "" "shpejtësisë me të cilën institucionet i përgjigjen kërkesave, numrit të kërkesave\n" "që kërkojne përgjigje postale dhe gjëra të tjera." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "Ky përdorues është pezulluar nga {{site_name}} " @@ -3392,9 +3456,15 @@ msgstr "Sot" msgid "Too many annotations" msgstr "Shumë shënime" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Shumë kërkesa" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Top lojtarë e rishtëm" @@ -3747,6 +3817,9 @@ msgstr "Shkruaj mesazhin tënd pasues QDP te {{authority_name}}" msgid "Write your request in simple, precise language." msgstr "Shkruaje kërkesën tënde me gjuhë të thjeshtë, dhe të saktë." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "Po" @@ -3878,6 +3951,9 @@ msgstr "Keni arritur kufirin e tarifës për shënimet. Përdoruesit zakonisht k msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Keni mberritur ne kufirin e kerkesave te reja. Perdoruesit zakonisht jane te kufizuar ne dergimin e {{max_requests_per_user_per_day}} kerkesave per nje periudhe 24 oreshe. Ju do keni mundesi te beni nje kerkese tjeter ne{{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "Keni lënë projektin." @@ -4514,6 +4590,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "{{number_of_comments}} koment" msgstr[1] "{{number_of_comments}} komente" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} kërkesë" diff --git a/locale/sr/app.po b/locale/sr/app.po index a9290ce0e9..4e5df020e8 100644 --- a/locale/sr/app.po +++ b/locale/sr/app.po @@ -31,11 +31,12 @@ # Translators: # Translators: # Translators: +# Translators: msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Graeme Porteous \n" "Language-Team: Serbian (http://app.transifex.com/mysociety/alaveteli/language/" @@ -437,6 +438,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -599,6 +603,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -662,6 +669,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -926,6 +936,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -995,6 +1008,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1522,6 +1538,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2196,6 +2215,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2382,6 +2404,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2418,6 +2443,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2483,6 +2532,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2537,6 +2589,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2954,9 +3009,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3177,6 +3238,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3303,9 +3367,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3652,6 +3722,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3781,6 +3854,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4401,6 +4477,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/sr@latin/app.po b/locale/sr@latin/app.po index 8d542df7df..d595f5cf1c 100644 --- a/locale/sr@latin/app.po +++ b/locale/sr@latin/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Aleksandar Krstić , 2015 # Goran Rakic , 2013 # Goran Vučković , 2013 @@ -47,7 +48,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Goran Vučković , 2013\n" "Language-Team: Serbian (Latin) (http://app.transifex.com/mysociety/alaveteli/l" @@ -495,6 +496,9 @@ msgstr "Sve opcije ispod mogu da koriste variety ili la msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -663,6 +667,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Počevši sa" @@ -726,6 +733,9 @@ msgstr "Otkaži neka {{site_name}} upozorenja" msgid "Cancel, return to your profile page" msgstr "Otkaži i vrati se na stranicu sa profilom korisnika" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Promenite e-mail adresu na {{site_name}}" @@ -994,6 +1004,9 @@ msgstr "Urađeno >>" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Preuzmite svu korespondenciju u zip fajlu" @@ -1067,6 +1080,9 @@ msgstr "Istorija promena" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Sve što unesete na ovu stranicu, uključujući i Vaše ime, \n" @@ -1640,6 +1656,9 @@ msgstr "Poslednji pregledani zahtev: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2329,6 +2348,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2518,6 +2540,9 @@ msgstr "Tražite Vaše doprinose" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Pošaljite reakciju" @@ -2554,6 +2579,30 @@ msgstr "Pošalji poruku za {{user_name}} samo da vidite kako radi" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2619,6 +2668,9 @@ msgstr "Odjavite se" msgid "Sign up" msgstr "Registrujte se" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2679,6 +2731,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3113,9 +3168,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Postoji ograničenje broja zahteva koje možete podneti u jednom danu, pošto želimo da izbegnemo da javne ustanove budu bombardovane velikim brojem neprikladnih zahteva. Ako mislite da u Vašem slučaju ovo ograničenje treba ukloniti, molimo da nam se javite." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3345,6 +3406,9 @@ msgstr "" "brzine kojom ustanove odgovaraju na zahteve, broja zahteva\n" "koji zahtevaju poštanski odgovor - i mnogo drugih namena." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3477,9 +3541,15 @@ msgstr "Danas" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Previše zahteva" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3847,6 +3917,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "Pišite Vaš zahtev jednostavnim, preciznim jezikom." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3976,6 +4049,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Dostigli ste limit broja unetih zahteva dnevno. Uobičajeni limit za korisnike sistema je {{max_requests_per_user_per_day}} podnetih zahteva u periodu od 24h. Novi zahtev ćete moći podneti {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4628,6 +4704,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/sv/app.po b/locale/sv/app.po index bfa2b190fd..397d901fca 100644 --- a/locale/sv/app.po +++ b/locale/sv/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # 03992e16f8df6e39b9d1cc0ff635887e, 2016 # Elenor Weijmar, 2018 # Elenor Weijmar, 2018-2022 @@ -54,7 +55,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Mattias Axell , 2015,2019-2022\n" "Language-Team: Swedish (http://app.transifex.com/mysociety/alaveteli/language/" @@ -474,6 +475,9 @@ msgstr "Alla alternativen nedan kan använda variety eller your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "Allt som du anger på denna sida, inklusive ditt namn, kommer att visas offentligt på denna hemsida för evigt" @@ -1563,6 +1579,9 @@ msgstr "Senast visade begäran: {{request_url}}" msgid "Latest" msgstr "Senaste" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Lär dig mer →" @@ -2240,6 +2259,9 @@ msgstr "Reglering" msgid "Rejected" msgstr "Nekad" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Kom ihåg mig (håller dig inloggad längre; använd inte i en publik dator i offentlig miljö)" @@ -2426,6 +2448,9 @@ msgstr "Sök dina bidrag" msgid "Section" msgstr "Sektion" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Skicka en uppföljning" @@ -2462,6 +2487,30 @@ msgstr "Skicka meddelande till {{user_name}} bara för att se hur det fungerar" msgid "Sending..." msgstr "Skickar..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "Skickat till en myndighet av {{info_request_user}} den {{date}}." @@ -2527,6 +2576,9 @@ msgstr "Logga ut" msgid "Sign up" msgstr "Registrera dig" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "Registreringar från Tor har blockerats på grund av extensiva missbruk. Vänligen kontakta oss anonymt om detta är ett problem för dig." @@ -2581,6 +2633,9 @@ msgstr "Ursäkta, vi kan för närvarande inte lägga till din anteckning. Vänl msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "Förlåt, vi kan för närvarande inte skapa ditt konto. Vänligen försök igen senare." +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "Ursäkta, vi kan för närvarande inte skicka din begäran. Vänligen försök igen senare." @@ -2998,9 +3053,15 @@ msgstr "Det finns fler än en person som använder denna sida o msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Det finns en gräns för antalet kommentarer du kan göra på en dag. Om du känner att du har en bra anledning att begära att gränsen hävs i ditt fall, vänligen hör av dig." +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Det finns en gräns för antalet förfrågningar som du kan göra på en dag. Detta eftersom myndigheterna inte ska överbelastas med för stort antal förfrågningar. Om du har en bra anledning att få begränsningen borttagen i ditt fall, vänligen ta kontakt med oss." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Det finns inget att visa än." @@ -3221,6 +3282,9 @@ msgstr "Denna sida för statistik om förfrågningar och myndigheter på Handlin msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "Denna tabell visar de tekniska detaljerna av de interna händelser som hänt denna begäran på {{site_name}}. Detta kan användas för att generera information om den hastighet myndigheter har för att svara på förfrågningar, antalet förfrågningar som kräver ett postsvar och mycket mer." +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "Denna användare har blivit avstängd från {{site_name}} " @@ -3347,9 +3411,15 @@ msgstr "Idag" msgid "Too many annotations" msgstr "För många kommentarer" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "För många förfrågningar" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "Nyligen hjälpsamma användare" @@ -3696,6 +3766,9 @@ msgstr "Skriv ditt uppföljningssvar angående begäran om allmän handling till msgid "Write your request in simple, precise language." msgstr "Skriv din begäran i enkelt, tydligt språk." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "Ja" @@ -3825,6 +3898,9 @@ msgstr "Du har nått gränsen för anteckningar/kommentarer. Användare är vanl msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Du har nått gränsen för att göra nya förfrågningar. Användare är vanligtvis begränsade till {{max_requests_per_user_per_day}} förfrågningar under en 24-timmarsperiod. Du kommer att kunna göra förfrågningar igen om {{can_make_another_request}}." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "Du har lämnat projektet." @@ -4455,6 +4531,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "{{number_of_comments}} kommentar" msgstr[1] "{{number_of_comments}} kommentarer" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} begäran" diff --git a/locale/sw_KE/app.po b/locale/sw_KE/app.po index 61d4551c1c..317750236b 100644 --- a/locale/sw_KE/app.po +++ b/locale/sw_KE/app.po @@ -31,11 +31,12 @@ # Translators: # Translators: # Translators: +# Translators: msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Graeme Porteous \n" "Language-Team: Swahili (Kenya) (http://app.transifex.com/mysociety/alaveteli/l" @@ -436,6 +437,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -598,6 +602,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -661,6 +668,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -925,6 +935,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -994,6 +1007,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1521,6 +1537,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2195,6 +2214,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2381,6 +2403,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2417,6 +2442,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2482,6 +2531,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2536,6 +2588,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2953,9 +3008,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3176,6 +3237,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3302,9 +3366,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3651,6 +3721,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3780,6 +3853,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4400,6 +4476,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/tr/app.po b/locale/tr/app.po index 5ad6032425..c400b1651d 100644 --- a/locale/tr/app.po +++ b/locale/tr/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Baran Ozgul , 2012 # Baran Ozgul , 2012 # Baran Ozgul , 2012 @@ -45,7 +46,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Senol Kaya , 2018\n" "Language-Team: Turkish (http://app.transifex.com/mysociety/alaveteli/language/" @@ -477,6 +478,9 @@ msgstr "Aşağıdaki tüm seçenekler iki nokta üst üste işaretinden önce your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "Bu sayfada adınız dahil girdiğiniz her türlü bilgi sonsuza kadar bu web sitesindehalka açık şekilde görünür olacaktır. " @@ -1585,6 +1601,9 @@ msgstr "Görüntülenen en son başvuru: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "Daha fazla bilgi →" @@ -2261,6 +2280,9 @@ msgstr "" msgid "Rejected" msgstr "Reddedildi" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Beni hatırla (siteye giriş yaptıktan sonra, daha uzun süre kalmanızı sağlar. Halka açık bir bilgisayarda kullanmayın)" @@ -2452,6 +2474,9 @@ msgstr "Kendi katkılarınızı arayın" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Bir takip iletisi gönderin" @@ -2488,6 +2513,30 @@ msgstr "Şu adrese mesaj gönder {{user_name}} nasıl çalıştığını bir gö msgid "Sending..." msgstr "Gönderiliyor..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "{{info_request_user}} tarafından {{date}} tarihinde {{authority_count}} kuruluşa gönderildi" @@ -2553,6 +2602,9 @@ msgstr "Hesabınızdan çıkış yapın" msgid "Sign up" msgstr "Hesap oluşturun" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2611,6 +2663,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3032,9 +3087,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Bir gün içinde yapabileceğiniz bilgi edinme başvurusu sınırlıdır çünkü kamu kurum ve kuruluşlarının çok sayıda gönderilmiş uygunsuz başvuruyla bir mesaj bombardmanına maruz kalmasını istemiyoruz. Eğer sizin durumunuzda bu sınırın kaldırılması için iyi bir neden olduğunu düşünüyorsanız lütfen bizimle iletişime geçin." +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "Henüz gösterilecek bir şey yok. " @@ -3260,6 +3321,9 @@ msgstr "" " {{site_name}} sitesinde bu başvuruyla ilgili site içinde gerçekleşmiş adımların teknik detaylarını görebilirsiniz. Bu tablo, kamu kuruluşlarının başvurulara cevap verme hızı\n" ", postayla cevap verilmesi gereken başvuru sayısı ve birçok başka konuda bilgi üretmek için kullanılabilir. " +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3396,9 +3460,15 @@ msgstr "Bugün" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Çok fazla sayıda başvuru" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3755,6 +3825,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "Başvurunuzu sade, net bir dille yazın." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3884,6 +3957,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Yeni başvurulara uygulanan sınıra eriştiniz. Kullancılar normal koşullarda 24 saatlik bir süre zarfında en çok {{max_requests_per_user_per_day}} başvuru yapabilir. {{can_make_another_request}} sonra yeni bir başvuru yapabilirsiniz. " +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4522,6 +4598,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/tr_TR/app.po b/locale/tr_TR/app.po index a7d2b4bdb6..766f786bca 100644 --- a/locale/tr_TR/app.po +++ b/locale/tr_TR/app.po @@ -31,12 +31,13 @@ # Translators: # Translators: # Translators: +# Translators: # Senol Kaya , 2018 msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Senol Kaya , 2018\n" "Language-Team: Turkish (Turkey) (http://app.transifex.com/mysociety/alaveteli/" @@ -469,6 +470,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -631,6 +635,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -694,6 +701,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -958,6 +968,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -1027,6 +1040,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1554,6 +1570,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2228,6 +2247,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2414,6 +2436,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2450,6 +2475,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2515,6 +2564,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2569,6 +2621,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2986,9 +3041,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3209,6 +3270,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3335,9 +3399,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3684,6 +3754,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3813,6 +3886,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4433,6 +4509,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/uk/app.po b/locale/uk/app.po index b1ad59a63e..893b2120a8 100644 --- a/locale/uk/app.po +++ b/locale/uk/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Ferents , 2013 # Ferents , 2013 # Gareth Rees , 2017 @@ -46,7 +47,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Natalie Hiirulainen , 2012,2014,2016-2019" ",2021\n" @@ -480,6 +481,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -644,6 +648,9 @@ msgstr "Забанено" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "Група запитів створена користувачем {{info_request_user}} {{date}}" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "Ті, що починаються з" @@ -707,6 +714,9 @@ msgstr "Скасувати деякі повідомлення сайту" msgid "Cancel, return to your profile page" msgstr "Скасувати, повернутися на сторінку профілю" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "Змінити електронну адресу на сайті" @@ -975,6 +985,9 @@ msgstr "Зроблено " msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "Завантажити zip-архів усієї переписки" @@ -1048,6 +1061,9 @@ msgstr "Історія" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" "Усе, що ви введете на цій сторінці (включно з вашим іменем), \n" @@ -1614,6 +1630,9 @@ msgstr "Останній переглянутий запит: {{request_url}}" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2297,6 +2316,9 @@ msgstr "" msgid "Rejected" msgstr "Відхилено" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "Запам’ятати мене" @@ -2485,6 +2507,9 @@ msgstr "Пошук у вашій активності на сайті" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "Надішліть додатковий запит" @@ -2521,6 +2546,30 @@ msgstr "Надіслати повідомлення до {{user_name}} прос msgid "Sending..." msgstr "Надислаю..." +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2586,6 +2635,9 @@ msgstr "Вийти" msgid "Sign up" msgstr "Зареєструватися" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2640,6 +2692,9 @@ msgstr "Вибачте, зараз ми не можемо додати ваш к msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -3059,9 +3114,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "Ми встановили обмеження на кількість запитів, які можна відправитипротягом одного дня. Ви можете попросити про зняття цього обмеження, написавши нам. Ваше прохання має бути обґрунтованим" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3290,6 +3351,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3418,9 +3482,15 @@ msgstr "Сьогодні" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "Забагато запитів" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3781,6 +3851,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "Використовуйте в запиті просту, зрозумілу мову." +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3910,6 +3983,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "Ви перевищили кількість дозволених запитів. Користувачі не можуть надсилати більш ніж{{max_requests_per_user_per_day}} запитів протягом 24 годин." +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4567,6 +4643,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}} запит" diff --git a/locale/vi/app.po b/locale/vi/app.po index 32b0c17bc0..04d91a44e1 100644 --- a/locale/vi/app.po +++ b/locale/vi/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # Anh Phan , 2013 # Anh Phan , 2013 # Anh Phan , 2013 @@ -40,7 +41,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Anh Phan , 2013\n" "Language-Team: Vietnamese (http://app.transifex.com/mysociety/alaveteli/langua" @@ -441,6 +442,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -603,6 +607,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -666,6 +673,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -930,6 +940,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -999,6 +1012,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1526,6 +1542,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2200,6 +2219,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2386,6 +2408,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2422,6 +2447,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2487,6 +2536,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2541,6 +2593,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2958,9 +3013,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3181,6 +3242,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3309,9 +3373,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3658,6 +3728,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3787,6 +3860,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4407,6 +4483,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/yue/app.po b/locale/yue/app.po index a60183730b..d4105ee8b3 100644 --- a/locale/yue/app.po +++ b/locale/yue/app.po @@ -31,11 +31,12 @@ # Translators: # Translators: # Translators: +# Translators: msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Graeme Porteous \n" "Language-Team: Cantonese (http://app.transifex.com/mysociety/alaveteli/languag" @@ -436,6 +437,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -598,6 +602,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -661,6 +668,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -925,6 +935,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -994,6 +1007,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1521,6 +1537,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2195,6 +2214,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2381,6 +2403,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2417,6 +2442,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2482,6 +2531,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2536,6 +2588,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2953,9 +3008,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3176,6 +3237,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3302,9 +3366,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3651,6 +3721,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3780,6 +3853,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4400,6 +4476,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/zh_CN/app.po b/locale/zh_CN/app.po index f037af0802..32eb98a0d5 100644 --- a/locale/zh_CN/app.po +++ b/locale/zh_CN/app.po @@ -31,11 +31,12 @@ # Translators: # Translators: # Translators: +# Translators: msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Graeme Porteous \n" "Language-Team: Chinese (China) (http://app.transifex.com/mysociety/alaveteli/l" @@ -436,6 +437,9 @@ msgstr "" msgid "All time" msgstr "" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "" @@ -598,6 +602,9 @@ msgstr "" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "" @@ -661,6 +668,9 @@ msgstr "" msgid "Cancel, return to your profile page" msgstr "" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "" @@ -925,6 +935,9 @@ msgstr "" msgid "Download Data" msgstr "" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "" @@ -994,6 +1007,9 @@ msgstr "" msgid "Every citizen has the right to access information held by public authorities." msgstr "" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "" @@ -1521,6 +1537,9 @@ msgstr "" msgid "Latest" msgstr "" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "" @@ -2195,6 +2214,9 @@ msgstr "" msgid "Rejected" msgstr "" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "" @@ -2381,6 +2403,9 @@ msgstr "" msgid "Section" msgstr "" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "" @@ -2417,6 +2442,30 @@ msgstr "" msgid "Sending..." msgstr "" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "" @@ -2482,6 +2531,9 @@ msgstr "" msgid "Sign up" msgstr "" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2536,6 +2588,9 @@ msgstr "" msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "" @@ -2953,9 +3008,15 @@ msgstr "" msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "" @@ -3176,6 +3237,9 @@ msgstr "" msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "" @@ -3302,9 +3366,15 @@ msgstr "" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "" @@ -3651,6 +3721,9 @@ msgstr "" msgid "Write your request in simple, precise language." msgstr "" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "" @@ -3780,6 +3853,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "" @@ -4400,6 +4476,11 @@ msgid_plural "{{number_of_comments}} comments" msgstr[0] "" msgstr[1] "" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "" diff --git a/locale/zh_HK/app.po b/locale/zh_HK/app.po index 1385349dfc..ba7161085d 100644 --- a/locale/zh_HK/app.po +++ b/locale/zh_HK/app.po @@ -31,6 +31,7 @@ # Translators: # Translators: # Translators: +# Translators: # beckymak , 2015 # caxekis , 2013 # caxekis , 2013 @@ -51,7 +52,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2011-03-09 17:48+0000\n" "Last-Translator: Yan Hin So , 2020\n" "Language-Team: Chinese (Hong Kong) (http://app.transifex.com/mysociety/alavete" @@ -459,6 +460,9 @@ msgstr "以下所有選項可在冒號前用varietyl msgid "All time" msgstr "歷來" +msgid "All time best contributors" +msgstr "" + msgid "All time best players" msgstr "歷來最佳玩家" @@ -621,6 +625,9 @@ msgstr "禁止進入本網站" msgid "Batch created by {{info_request_user}} on {{date}}." msgstr "{{info_request_user}}於{{date}}建立本批量要求。" +msgid "Before you start" +msgstr "" + msgid "Beginning with" msgstr "開始" @@ -684,6 +691,9 @@ msgstr "取消{{site_name}}的一些提示" msgid "Cancel, return to your profile page" msgstr "取消並返回個人簡介" +msgid "Cannot send messages" +msgstr "" + msgid "Change email on {{site_name}}" msgstr "更換在{{site_name}}使用的電郵地址" @@ -948,6 +958,9 @@ msgstr "完成 >>" msgid "Download Data" msgstr "下載資料" +msgid "Download Leaderboard Data" +msgstr "" + msgid "Download a zip file of all correspondence" msgstr "下載含全部回覆的壓縮檔案" @@ -1017,6 +1030,9 @@ msgstr "過往活動" msgid "Every citizen has the right to access information held by public authorities." msgstr "每一位公民都有權向公共機構索取資料。" +msgid "Everything that you enter on this page, including your name ({{user_name}}), will be displayed publicly on this website forever" +msgstr "" + msgid "Everything that you enter on this page, including your name, will be displayed publicly on this website forever" msgstr "你在本頁輸入的所有資料(包括你的姓名),將會在本站永久公開顯示。" @@ -1540,6 +1556,9 @@ msgstr "最後已讀要求:{{request_url}}" msgid "Latest" msgstr "最新" +msgid "Latest news and campaigns" +msgstr "" + msgid "Learn more →" msgstr "了解更多 →" @@ -2213,6 +2232,9 @@ msgstr "規例" msgid "Rejected" msgstr "拒絕提供資料" +msgid "Related blog posts" +msgstr "" + msgid "Remember me (keeps you signed in longer; do not use on a public computer)" msgstr "記住我(延長保留你的登入狀態;不要在公共電腦上使用此功能)" @@ -2399,6 +2421,9 @@ msgstr "搜尋你提供的資料" msgid "Section" msgstr "部份" +msgid "See all →" +msgstr "" + msgid "Send a followup" msgstr "跟進要求" @@ -2435,6 +2460,30 @@ msgstr "向{{user_name}}發出訊息,以體驗通訊系統" msgid "Sending..." msgstr "傳送中……" +msgid "Sent a follow up to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_link}} again." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent a follow up to {{public_body_name}} again." +msgstr "" + +msgid "Sent request to {{public_body_link}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_link}} again." +msgstr "" + +msgid "Sent request to {{public_body_name}} again, using a new contact address." +msgstr "" + +msgid "Sent request to {{public_body_name}} again." +msgstr "" + msgid "Sent to one authority by {{info_request_user}} on {{date}}." msgid_plural "Sent to {{authority_count}} authorities by {{info_request_user}} on {{date}}." msgstr[0] "{{info_request_user}}於{{date}}發至{{authority_count}}個公共機構。" @@ -2499,6 +2548,9 @@ msgstr "登出" msgid "Sign up" msgstr "登記" +msgid "Signing your request" +msgstr "" + msgid "Signups from Tor have been blocked due to extensive misuse. Please contact us if this is a problem for you." msgstr "" @@ -2553,6 +2605,9 @@ msgstr "抱歉,我們現時無法加入你的備註,請稍後再作備註。 msgid "Sorry, we're currently unable to create your account. Please try again later." msgstr "" +msgid "Sorry, we're currently unable to send your message. Please try again later." +msgstr "" + msgid "Sorry, we're currently unable to send your request. Please try again later." msgstr "抱歉,我們現時無法寄出你的要求,請稍後再寄。" @@ -2970,9 +3025,15 @@ msgstr "有多過一個人利用此網站及擁有此名稱。 msgid "There is a limit on the number of annotations you can make in a day because we don’t want the site to be bombarded with large numbers of inappropriate annotations. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "" +msgid "There is a limit on the number of messages you can send in a day because we don’t want users to be bombarded with large numbers of inappropriate messages. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." +msgstr "" + msgid "There is a limit on the number of requests you can make in a day, because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. If you feel you have a good reason to ask for the limit to be lifted in your case, please get in touch." msgstr "因為我們不希望公共機構收到過量不恰當的要求,所以你每天能夠提出的要求設有上限。如果你認為有足夠理由要求撤銷上限, 請聯絡我們。" +msgid "There is also a limit on the speed at which you are able to create annotations. Please try again later if you have not hit your daily limit." +msgstr "" + msgid "There is nothing to display yet." msgstr "暫未有內容顯示。" @@ -3191,6 +3252,9 @@ msgstr "目前仍在試驗這個在公共機構統計的部份,請用家謹記 msgid "This table shows the technical details of the internal events that happened to this request on {{site_name}}. This could be used to generate information about the speed with which authorities respond to requests, the number of requests which require a postal response and much more." msgstr "此列表顯示了些內部事件的技術細節,那些事件都曾出現於載列在{{site_name}}的本項要求。這些細節或用以了解公共機構的回應速度、需以郵寄方式回覆要求的數目等。" +msgid "This user does not accept user to user messages." +msgstr "" + msgid "This user has been suspended from {{site_name}} " msgstr "此用戶已被{{site_name}}封鎖。" @@ -3317,9 +3381,15 @@ msgstr "今天" msgid "Too many annotations" msgstr "" +msgid "Too many messages" +msgstr "" + msgid "Too many requests" msgstr "過多要求" +msgid "Top recent contributors" +msgstr "" + msgid "Top recent players" msgstr "近期的頂級玩家" @@ -3664,6 +3734,9 @@ msgstr "撰寫索取資料要求,並傳予{{authority_name}}" msgid "Write your request in simple, precise language." msgstr "請以顯淺易明的文字撰寫要求。" +msgid "Writing your request" +msgstr "" + msgid "Yes" msgstr "是" @@ -3790,6 +3863,9 @@ msgstr "" msgid "You have hit the rate limit on new requests. Users are ordinarily limited to {{max_requests_per_user_per_day}} requests in any rolling 24-hour period. You will be able to make another request in {{can_make_another_request}}." msgstr "你已達到發出新要求的上限。一般用戶只可在連續24小時內提出最多{{max_requests_per_user_per_day}}個請求。你可於{{can_make_another_request}}再提出請求。" +msgid "You have hit the rate limit on user messages. Users are ordinarily limited to {{message_limit}} messages per day." +msgstr "" + msgid "You have left the project." msgstr "你已離開項目。" @@ -4393,6 +4469,11 @@ msgid "{{number_of_comments}} comment" msgid_plural "{{number_of_comments}} comments" msgstr[0] "{{number_of_comments}}則評論" +msgid "{{number_of_contributions}} contribution" +msgid_plural "{{number_of_contributions}} contributions" +msgstr[0] "" +msgstr[1] "" + msgid "{{number_of_requests}} request" msgid_plural "{{number_of_requests}} requests" msgstr[0] "{{number_of_requests}}項要求" diff --git a/locale_alaveteli_pro/app.pot b/locale_alaveteli_pro/app.pot index 7aa3aec457..ed8ad754b4 100644 --- a/locale_alaveteli_pro/app.pot +++ b/locale_alaveteli_pro/app.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2017-01-20 17:40+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -436,6 +436,9 @@ msgstr "" msgid "Friendly support" msgstr "" +msgid "From" +msgstr "" + msgid "From this screen you can get a helpful overview of your requests, and use quick actions to keep them up to date. Why not start your first one now?" msgstr "" @@ -499,9 +502,6 @@ msgstr "" msgid "Important info about requests to this authority" msgstr "" -msgid "Introductory Pricing" -msgstr "" - msgid "Investigating asbestos use in schools" msgstr "" diff --git a/locale_alaveteli_pro/en/app.po b/locale_alaveteli_pro/en/app.po index b4e7bd1f09..d386eec5e9 100644 --- a/locale_alaveteli_pro/en/app.po +++ b/locale_alaveteli_pro/en/app.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: alaveteli\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-12-22 13:14+0000\n" +"POT-Creation-Date: 2023-04-20 14:26+0100\n" "PO-Revision-Date: 2017-01-20 17:40+0000\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -436,6 +436,9 @@ msgstr "For journalists, academics and power users" msgid "Friendly support" msgstr "Friendly support" +msgid "From" +msgstr "" + msgid "From this screen you can get a helpful overview of your requests, and use quick actions to keep them up to date. Why not start your first one now?" msgstr "From this screen you can get a helpful overview of your requests, and use quick actions to keep them up to date. Why not start your first one now?" @@ -499,9 +502,6 @@ msgstr "Image credits:" msgid "Important info about requests to this authority" msgstr "Important info about requests to this authority" -msgid "Introductory Pricing" -msgstr "Introductory Pricing" - msgid "Investigating asbestos use in schools" msgstr "Investigating asbestos use in schools" diff --git a/script/handle-mail-replies b/script/handle-mail-replies index 267ad56321..b2638c763b 100755 --- a/script/handle-mail-replies +++ b/script/handle-mail-replies @@ -1,4 +1,6 @@ #!/bin/bash +export RUBYOPT="-W0" + cd "`dirname "${BASH_SOURCE[0]}"`" exec bundle exec ./handle-mail-replies.rb "$@" diff --git a/script/handle-mail-replies.rb b/script/handle-mail-replies.rb index 5d1462412b..d751772166 100755 --- a/script/handle-mail-replies.rb +++ b/script/handle-mail-replies.rb @@ -91,7 +91,9 @@ def main(in_test_mode) return 2 if MailHandler::ReplyHandler.is_oof?(message) # Otherwise forward the message on - MailHandler::ReplyHandler.forward_on(raw_message, message) unless in_test_mode + unless in_test_mode + MailHandler::ReplyHandler.forward_on(raw_message, message) + end return 0 end end diff --git a/script/install-as-user b/script/install-as-user index 3d2d1ae4c0..bf1b811326 100755 --- a/script/install-as-user +++ b/script/install-as-user @@ -110,24 +110,6 @@ if [ $USE_RBENV = true ]; then gem install bundler fi -# Prevent extreme deprecation warnings on Ruby 2.7.0 provided by Ubuntu Focal -# (Fixed in Ruby 2.7.2). ensure_line_present is not available here, so just do -# this as it's pretty temporary. -RUBY27_OPT_COMMENT="Set Ruby options for Ruby 2.7" -RUBY27_OPT_START="# START $RUBY27_OPT_COMMENT" -RUBY27_OPT_END="# END $RUBY27_OPT_COMMENT" -if ruby -v | grep "2.7.[01]" > /dev/null && ! grep "$RUBY27_OPT_START" "$BASHRC" > /dev/null -then - cat >>$BASHRC < /dev/null; then - export RUBYOPT='-W:no-deprecated -W:no-experimental' -fi -$RUBY27_OPT_END -EOF -fi - # Speed up the installation of gems: echo 'gem: --no-ri --no-rdoc' > "$HOME/.gemrc" @@ -141,6 +123,12 @@ RANDOM_EMAIL_SECRET=$(random_alphanumerics 32) RANDOM_EMERGENCY_PASSWORD=$(random_alphanumerics 10) RANDOM_COOKIE_SECRET=$(random_alphanumerics 100) +if [ "$DEVELOPMENT_INSTALL" = true ]; then + STAGING_SITE=1 +else + STAGING_SITE=0 +fi + if ! [ -f config/general.yml ] then sed -r \ @@ -158,6 +146,7 @@ then -e "s,^( *CONTACT_EMAIL:).*,\\1 'postmaster@$HOST'," \ -e "s,^( *TRACK_SENDER_EMAIL:).*,\\1 'postmaster@$HOST'," \ -e "s,^( *SECRET_KEY_BASE:).*,\\1 '$RANDOM_COOKIE_SECRET'," \ + -e "s,^( *STAGING_SITE:).*,\\1 '$STAGING_SITE'," \ -e "s,^( *FORWARD_NONBOUNCE_RESPONSES_TO:).*,\\1 'user-support@$HOST'," \ -e "s,^( *HTML_TO_PDF_COMMAND:).*,\\1 '/usr/local/bin/wkhtmltopdf'," \ -e "s,^( *EXCEPTION_NOTIFICATIONS_FROM:).*,\\1 'do-not-reply-to-this-address@$HOST'," \ diff --git a/script/load-mail-server-logs b/script/load-mail-server-logs index c517434387..0e575dfc6c 100755 --- a/script/load-mail-server-logs +++ b/script/load-mail-server-logs @@ -1,5 +1,7 @@ #!/bin/bash +export RUBYOPT="-W0" + LOC="`dirname "${BASH_SOURCE[0]}"`"/.. cd "$LOC" diff --git a/script/load-sample-data b/script/load-sample-data index 0301522731..1fb8a51ee2 100755 --- a/script/load-sample-data +++ b/script/load-sample-data @@ -42,7 +42,7 @@ fixture_files = ["public_bodies", # append everything else that isn't order critical Dir["#{fixtures_dir}/**/*.yml"].map{ |f| f[(fixtures_dir.size + 1)..-5] }.each do |fixture| - next if fixture =~ /yaml_compatibility|refusal_advice/ + next if fixture =~ /refusal_advice/ fixture_files << fixture unless fixture_files.include?(fixture) end diff --git a/script/mailin b/script/mailin index 4d00fcaa80..41dfbf5a5e 100755 --- a/script/mailin +++ b/script/mailin @@ -1,5 +1,7 @@ #!/bin/bash +export RUBYOPT="-W0" + # Wire this script to receive incoming email for request responses. INPUT=$(mktemp -t foi-mailin-mail-XXXXXXXX) diff --git a/script/rails-deploy-before-down b/script/rails-deploy-before-down index d7a68a21f7..3a30acebef 100755 --- a/script/rails-deploy-before-down +++ b/script/rails-deploy-before-down @@ -77,9 +77,8 @@ OPTION_STAGING_SITE=$(bin/config STAGING_SITE) STAGING_SITE="${OPTION_STAGING_SITE:-1}" # Force appropriate environment in production -if [ "$STAGING_SITE" = "0" ] -then - cat <<-END +if [ ! -f config/rails_env.rb ]; then + [ "$STAGING_SITE" = "0" ] && cat <<-END ***************************************************************** WARNING: About to make config/rails_env.rb which, via special @@ -92,35 +91,45 @@ then ***************************************************************** END - echo "ENV['RAILS_ENV'] ||= 'production'" > config/rails_env.rb + +else + RAILS_ENV=$(ruby -r ./config/rails_env.rb -e "puts ENV['RAILS_ENV']") + if ([ "$STAGING_SITE" = "0" ] && [ "$RAILS_ENV" != "production" ]) || + ([ "$STAGING_SITE" = "1" ] && [ "$RAILS_ENV" = "production" ]); then + # STAGING_SITE and RAILS_ENV mismatch - remove line + sed -i "/^ENV\['RAILS_ENV'\]/d" config/rails_env.rb + fi +fi + +if [ "$STAGING_SITE" = "0" ] && [ "$RAILS_ENV" != "production" ]; then + # Set RAILS_ENV to production + echo "ENV['RAILS_ENV'] ||= 'production'" >> config/rails_env.rb fi OPTION_BUNDLE_PATH=$(bin/config BUNDLE_PATH) BUNDLE_PATH="${OPTION_BUNDLE_PATH:-vendor/bundle}" +bundle config set --local path $BUNDLE_PATH -bundle_install_options="--path $BUNDLE_PATH" - -if [ "$CI" = "true" ] -then - bundle_install_options="$bundle_install_options --deployment" -elif [ "$STAGING_SITE" = "0" ] +if [ "$STAGING_SITE" = "0" ] then - bundle_install_options="$bundle_install_options --without development debug test --deployment" + bundle config set --local deployment 'true' + bundle config set --local without 'development debug test' else - bundle_install_options="$bundle_install_options" + bundle config unset --local deployment + bundle config unset --local without fi -echo "Running bundle install with options: $bundle_install_options" -bundle install $bundle_install_options +echo "Bundle install options:" +bundle config list + +echo "Running bundle install:" +bundle install bundle exec rake submodules:check bundle exec rake themes:install -if ! [ "$CI" = "true" ] -then - bundle exec rake geoip:download_data -fi +bundle exec rake geoip:download_data if [ "$STAGING_SITE" = "0" ] then diff --git a/script/runner b/script/runner index bdbc1dbba4..1579046450 100755 --- a/script/runner +++ b/script/runner @@ -11,7 +11,7 @@ Dir.chdir(alaveteli_dir) do # If the environment variable LOGFILE is present, # redirect STDERR and STDOUT to that file. - if ENV.has_key? "LOGFILE" + if ENV.key? "LOGFILE" STDERR.reopen(STDOUT.reopen(ENV["LOGFILE"], "a")) STDOUT.sync=true puts "Daemon starting at #{Time.new}" @@ -26,7 +26,7 @@ Dir.chdir(alaveteli_dir) do # If the environment variable PIDFILE is present, # write the pid of the daemon process to that file. - if ENV.has_key? "PIDFILE" + if ENV.key? "PIDFILE" File.open(ENV["PIDFILE"], 'w') do |fh| fh.puts pid end diff --git a/script/site-specific-install.sh b/script/site-specific-install.sh index 9a45617090..6b399516d6 100755 --- a/script/site-specific-install.sh +++ b/script/site-specific-install.sh @@ -27,20 +27,28 @@ install_mailutils() { } clear_daemon() { - echo -n "Removing /etc/init.d/$SITE-$1... " - rm -f "/etc/init.d/$SITE-$1" + path=$1 + if [ $path = "/etc/init.d" ]; then name="$SITE-$2"; fi + if [ $path = "/etc/systemd/system" ]; then name="$SITE.$2"; fi + + echo -n "Removing $path/$name... " + rm -f "$path/$name" echo $DONE_MSG } install_daemon() { - echo -n "Creating /etc/init.d/$SITE-$1... " - (su -l -c "cd '$REPOSITORY' && bundle exec rake config_files:convert_init_script DEPLOY_USER='$UNIX_USER' VHOST_DIR='$DIRECTORY' VCSPATH='$SITE' SITE='$SITE' RUBY_VERSION='$RUBY_VERSION' USE_RBENV=$USE_RBENV RAILS_ENV='$RAILS_ENV' SCRIPT_FILE=config/$1-debian.example" "$UNIX_USER") > /etc/init.d/"$SITE-$1" - chgrp "$UNIX_USER" /etc/init.d/"$SITE-$1" - chmod 754 /etc/init.d/"$SITE-$1" + path=$1 + if [ $path = "/etc/init.d" ]; then name="$SITE-$2"; fi + if [ $path = "/etc/systemd/system" ]; then name="$SITE.$2"; fi + + echo -n "Creating $path/$name... " + (su -l -c "cd '$REPOSITORY' && bundle exec rake config_files:convert_daemon DEPLOY_USER='$UNIX_USER' VHOST_DIR='$DIRECTORY' VCSPATH='$SITE' SITE='$SITE' RUBY_VERSION='$RUBY_VERSION' USE_RBENV=$USE_RBENV RAILS_ENV='$RAILS_ENV' RAILS_ENV_DEFINED='$RAILS_ENV_DEFINED' DAEMON=$2" "$UNIX_USER") > $path/$name + chgrp "$UNIX_USER" $path/$name + chmod 754 $path/$name if which systemctl > /dev/null then - systemctl enable "$SITE-$1" + systemctl enable "$name" fi echo $DONE_MSG @@ -63,6 +71,28 @@ install_daemon() { [ -z "$DEVELOPMENT_INSTALL" ] && misuse DEVELOPMENT_INSTALL [ -z "$BIN_DIRECTORY" ] && misuse BIN_DIRECTORY +if [ -f $REPOSITORY/config/general.yml ]; then + STAGING_SITE=$(su -l -c "cd '$REPOSITORY' && bin/config STAGING_SITE" "$UNIX_USER") + if ([ "$STAGING_SITE" = "0" ] && [ "$DEVELOPMENT_INSTALL" = "true" ]) || + ([ "$STAGING_SITE" = "1" ] && [ "$DEVELOPMENT_INSTALL" != "true" ]); then + cat <<-END + + ***************************************************************** + ERROR: Configuration mismatch + + In config/general.yml you have STAGING_SITE set to $STAGING_SITE but you're + running the install script with DEVELOPMENT_INSTALL set to $DEVELOPMENT_INSTALL + + Please either update config/general.yml or change the flags used + when invoking the install script + ***************************************************************** + +END + + exit 1 + fi +fi + update_mysociety_apt_sources apt-get -y update @@ -169,7 +199,11 @@ fi # Ensure we have required Ruby version from the current distribution package, if # not then install using rbenv -required_ruby="$(cat $REPOSITORY/.ruby-version.example)" +if [ -f $REPOSITORY/.ruby-version ]; then + required_ruby="$(cat $REPOSITORY/.ruby-version)" +else + required_ruby="$(cat $REPOSITORY/.ruby-version.example)" +fi current_ruby="$(ruby --version | awk 'match($0, /[0-9\.]+/) {print substr($0,RSTART,RLENGTH)}')" if [ "$(printf '%s\n' "$required_ruby" "$current_ruby" | sort -V | head -n1)" = "$required_ruby" ]; then echo "Current Ruby (${current_ruby}) is greater than or equal to required version (${required_ruby})" @@ -213,7 +247,7 @@ su -l -c "$BIN_DIRECTORY/install-as-user '$UNIX_USER' '$HOST' '$DIRECTORY' '$RUB echo "ALTER USER \"$UNIX_USER\" WITH NOSUPERUSER;" | su -l -c 'psql' postgres -RETRIEVER_METHOD=$(su -l -c "cd '$REPOSITORY' && bundle exec rake config_files:get_config_value KEY=PRODUCTION_MAILER_RETRIEVER_METHOD" "$UNIX_USER") +RETRIEVER_METHOD=$(su -l -c "cd '$REPOSITORY' && bin/config PRODUCTION_MAILER_RETRIEVER_METHOD" "$UNIX_USER") if [ x"$RETRIEVER_METHOD" = x"pop" ] && [ "$DEVELOPMENT_INSTALL" = true ]; then # Install dovecot @@ -250,6 +284,12 @@ fi cd "$REPOSITORY" +if [ -f config/rails_env.rb ]; then + RAILS_ENV_DEFINED=$(ruby -r ./config/rails_env.rb -e "puts ENV.keys.include?('RAILS_ENV')") +else + RAILS_ENV_DEFINED=false +fi + if [ "$DEVELOPMENT_INSTALL" = true ]; then RAILS_ENV=development else @@ -285,28 +325,31 @@ sed -r \ -i /etc/cron.d/alaveteli echo $DONE_MSG -if [ ! "$DEVELOPMENT_INSTALL" = true ]; then - echo -n "Creating /etc/init.d/$SITE... " - (su -l -c "cd '$REPOSITORY' && bundle exec rake config_files:convert_init_script DEPLOY_USER='$UNIX_USER' VHOST_DIR='$DIRECTORY' VCSPATH='$SITE' SITE='$SITE' RUBY_VERSION='$RUBY_VERSION' USE_RBENV=$USE_RBENV RAILS_ENV='$RAILS_ENV' SCRIPT_FILE=config/sysvinit-thin.example" "$UNIX_USER") > /etc/init.d/"$SITE" - chgrp "$UNIX_USER" /etc/init.d/"$SITE" - chmod 754 /etc/init.d/"$SITE" +# Clear existing legacy daemons if present +if [ -f /etc/init.d/$SITE ] +then + echo "Clearing any legacy daemons" + echo -n "Removing /etc/init.d/$SITE... " + rm -f "/etc/init.d/$SITE" echo $DONE_MSG fi -# Clear existing daemons -all_daemons=$(su -l -c "cd '$REPOSITORY' && bundle exec rake config_files:all_daemons" "$UNIX_USER") -echo "Clearing any existing daemons" -for daemon in $all_daemons -do - clear_daemon $daemon -done - -# Install required daemons -active_daemons=$(su -l -c "cd '$REPOSITORY' && bundle exec rake config_files:active_daemons" "$UNIX_USER") -echo "Creating daemons for active daemons" -for daemon in $active_daemons -do - install_daemon $daemon +for path in "/etc/init.d" "/etc/systemd/system"; do + # Clear existing daemons + all_daemons=$(su -l -c "cd '$REPOSITORY' && bundle exec rake config_files:all_daemons PATH='$path'" "$UNIX_USER") + echo "Clearing any existing $path daemons" + for daemon in $all_daemons + do + clear_daemon $path $daemon + done + + # Install required daemons + active_daemons=$(su -l -c "cd '$REPOSITORY' && bundle exec rake config_files:active_daemons PATH='$path'" "$UNIX_USER") + echo "Creating daemons for active $path daemons" + for daemon in $active_daemons + do + install_daemon $path $daemon + done done if which systemctl > /dev/null diff --git a/script/switch-theme.rb b/script/switch-theme.rb index 18ba015f10..a93ae2bc96 100755 --- a/script/switch-theme.rb +++ b/script/switch-theme.rb @@ -72,7 +72,7 @@ def show_themes if ARGV.length == 1 requested_theme = ARGV[0] else - STDERR.puts "Usage: #{$0} " + STDERR.puts "Usage: #{$PROGRAM_NAME} " show_themes exit 1 end @@ -100,7 +100,7 @@ def show_themes exit 1 end -def symlink target, link_directory, link_name +def symlink(target, link_directory, link_name) tmp = Tempfile.new link_name, link_directory full_link_name = File.join(link_directory, link_name) target = Pathname.new(target).relative_path_from(File.dirname(full_link_name)) diff --git a/script/update-rubocop-config.rb b/script/update-rubocop-config.rb index 863412be40..593d2d3fb0 100755 --- a/script/update-rubocop-config.rb +++ b/script/update-rubocop-config.rb @@ -34,7 +34,13 @@ def default_config File.write(tmp_path, Net::HTTP.get(uri)) unless File.exist?(tmp_path) - m.deep_merge!(YAML.load_file(tmp_path)) + if RUBY_VERSION < "3.1" + yaml = YAML.load_file(tmp_path) + else + yaml = YAML.load_file(tmp_path, permitted_classes: [Regexp, Symbol]) + end + + m.deep_merge!(yaml) end end diff --git a/spec/controllers/admin/blog_posts_controller_spec.rb b/spec/controllers/admin/blog_posts_controller_spec.rb new file mode 100644 index 0000000000..d02aabd3f9 --- /dev/null +++ b/spec/controllers/admin/blog_posts_controller_spec.rb @@ -0,0 +1,116 @@ +require 'spec_helper' + +RSpec.describe Admin::BlogPostsController do + describe 'GET index' do + it 'renders the index template' do + get :index + expect(response).to render_template('index') + end + + it 'responds successfully' do + get :index + expect(response).to be_successful + end + + it 'loads blog posts' do + post_1 = FactoryBot.create(:blog_post) + post_2 = FactoryBot.create(:blog_post) + get :index + expect(assigns[:blog_posts]).to include(post_1, post_2) + end + + it 'orders blog posts by descending ID' do + expect(Blog::Post).to receive(:order).with(id: :desc). + and_return(double.as_null_object) + get :index + end + + it 'paginates blog posts' do + assoication = double.as_null_object + allow(Blog::Post).to receive(:order).and_return(assoication) + + get :index + expect(assoication).to have_received(:paginate). + with(page: nil, per_page: 25) + + get :index, params: { page: 1 } + expect(assoication).to have_received(:paginate). + with(page: '1', per_page: 25) + end + end + + describe 'GET edit' do + context 'blog post exists' do + let(:blog_post) { FactoryBot.create(:blog_post) } + + it 'renders the edit template' do + get :edit, params: { id: blog_post.id } + expect(response).to render_template('edit') + end + + it 'loads blog post by ID' do + get :edit, params: { id: blog_post.id } + expect(assigns[:blog_post]).to eq(blog_post) + end + + it 'responds successfully' do + get :edit, params: { id: blog_post.id } + expect(response).to be_successful + end + end + + context 'blog post does not exists' do + it 'returns a 404' do + expect { get :edit, params: { id: 1 } }.to raise_error( + ActiveRecord::RecordNotFound + ) + end + end + end + + describe 'PATCH #update' do + let(:blog_post) { FactoryBot.build(:blog_post, id: 1) } + let(:params) { { tag_string: 'foo' } } + + before do + allow(Blog::Post).to receive(:find).and_return(blog_post) + end + + context 'when a successful update' do + before do + allow(blog_post).to receive(:update).and_return(true) + end + + it 'assigns the blog post' do + patch :update, params: { id: blog_post.id, blog_post: params } + expect(assigns[:blog_post]).to eq(blog_post) + end + + it 'sets a notice' do + patch :update, params: { id: blog_post.id, blog_post: params } + expect(flash[:notice]).to eq('Blog Post successfully updated.') + end + + it 'redirects to the blog posts admin' do + patch :update, params: { id: blog_post.id, blog_post: params } + expect(response).to redirect_to(admin_blog_posts_path) + end + end + + context 'on an unsuccessful update' do + before do + allow(blog_post).to receive(:update).and_return(false) + end + + it 'assigns the blog post' do + patch :update, params: { id: blog_post.id, blog_post: params } + expect(assigns[:blog_post]).to eq(blog_post) + end + + it 'renders the form again' do + patch :update, params: { id: blog_post.id, blog_post: params } + expect(response).to render_template(:edit) + end + end + end +end diff --git a/spec/controllers/admin_censor_rule_controller_spec.rb b/spec/controllers/admin_censor_rule_controller_spec.rb index ecc56710a4..d99c311e2a 100644 --- a/spec/controllers/admin_censor_rule_controller_spec.rb +++ b/spec/controllers/admin_censor_rule_controller_spec.rb @@ -73,7 +73,7 @@ let(:info_request) { FactoryBot.create(:info_request) } before do - get :new, params: { :request_id => info_request.id } + get :new, params: { request_id: info_request.id } end it 'returns a successful response' do @@ -108,7 +108,7 @@ let(:user) { FactoryBot.create(:user) } before do - get :new, params: { :user_id => user.id } + get :new, params: { user_id: user.id } end it 'returns a successful response' do @@ -143,7 +143,7 @@ let(:public_body) { FactoryBot.create(:public_body) } before do - get :new, params: { :body_id => public_body.id } + get :new, params: { body_id: public_body.id } end it 'returns a successful response' do @@ -187,7 +187,7 @@ end def create_censor_rule - post :create, params: { :censor_rule => censor_rule_params } + post :create, params: { censor_rule: censor_rule_params } end it 'sets the last_edit_editor to the current admin' do @@ -269,32 +269,32 @@ def create_censor_rule it 'sets the last_edit_editor to the current admin' do post :create, params: { - :request_id => info_request.id, - :censor_rule => censor_rule_params + request_id: info_request.id, + censor_rule: censor_rule_params } expect(assigns[:censor_rule].last_edit_editor).to eq('*unknown*') end it 'finds an info request if the request_id param is supplied' do post :create, params: { - :request_id => info_request.id, - :censor_rule => censor_rule_params + request_id: info_request.id, + censor_rule: censor_rule_params } expect(assigns[:info_request]).to eq(info_request) end it 'associates the info request with the new censor rule' do post :create, params: { - :request_id => info_request.id, - :censor_rule => censor_rule_params + request_id: info_request.id, + censor_rule: censor_rule_params } expect(assigns[:censor_rule].info_request).to eq(info_request) end it 'sets the URL for the form to POST to' do post :create, params: { - :request_id => info_request.id, - :censor_rule => censor_rule_params + request_id: info_request.id, + censor_rule: censor_rule_params } expect(assigns[:form_url]). to eq(admin_request_censor_rules_path(info_request)) @@ -304,16 +304,16 @@ def create_censor_rule it 'persists the censor rule' do post :create, params: { - :censor_rule => censor_rule_params, - :request_id => info_request.id + censor_rule: censor_rule_params, + request_id: info_request.id } expect(assigns[:censor_rule]).to be_persisted end it 'confirms the censor rule is created' do post :create, params: { - :censor_rule => censor_rule_params, - :request_id => info_request.id + censor_rule: censor_rule_params, + request_id: info_request.id } msg = 'Censor rule was successfully created.' expect(flash[:notice]).to eq(msg) @@ -322,15 +322,15 @@ def create_censor_rule it 'calls expire_requests on the new censor_rule' do allow(InfoRequest).to receive(:find).and_return(info_request) censor_rule_spy = FactoryBot.build(:info_request_censor_rule, - :info_request => info_request) + info_request: info_request) allow(info_request.censor_rules).to receive(:build). and_return(censor_rule_spy) allow(censor_rule_spy).to receive(:expire_requests) post :create, params: { - :censor_rule => censor_rule_params, - :request_id => info_request.id + censor_rule: censor_rule_params, + request_id: info_request.id } expect(censor_rule_spy).to have_received(:expire_requests) @@ -338,8 +338,8 @@ def create_censor_rule it 'redirects to the associated info request' do post :create, params: { - :censor_rule => censor_rule_params, - :request_id => info_request.id + censor_rule: censor_rule_params, + request_id: info_request.id } expect(response).to redirect_to( admin_request_path(assigns[:censor_rule].info_request) @@ -355,16 +355,16 @@ def create_censor_rule it 'does not persist the censor rule' do post :create, params: { - :censor_rule => censor_rule_params, - :request_id => info_request.id + censor_rule: censor_rule_params, + request_id: info_request.id } expect(assigns[:censor_rule]).to be_new_record end it 'renders the form' do post :create, params: { - :censor_rule => censor_rule_params, - :request_id => info_request.id + censor_rule: censor_rule_params, + request_id: info_request.id } expect(response).to render_template('new') end @@ -377,7 +377,7 @@ def create_censor_rule let(:user) { FactoryBot.create(:user) } let(:censor_rule_params) do - params = FactoryBot.attributes_for(:user_censor_rule, :user => user) + params = FactoryBot.attributes_for(:user_censor_rule, user: user) # last_edit_editor gets set in the controller params.delete(:last_edit_editor) params @@ -385,8 +385,8 @@ def create_censor_rule def create_censor_rule post :create, params: { - :user_id => user.id, - :censor_rule => censor_rule_params + user_id: user.id, + censor_rule: censor_rule_params } end @@ -415,7 +415,7 @@ def create_censor_rule it 'calls expire_requests on the new censor_rule' do allow(User).to receive(:find) { user } censor_rule = FactoryBot.build(:user_censor_rule, - :user => user) + user: user) allow(user.censor_rules).to receive(:build) { censor_rule } allow(censor_rule).to receive(:expire_requests) @@ -441,16 +441,16 @@ def create_censor_rule it 'does not persist the censor rule' do post :create, params: { - :censor_rule => censor_rule_params, - :user_id => user.id + censor_rule: censor_rule_params, + user_id: user.id } expect(assigns[:censor_rule]).to be_new_record end it 'renders the form' do post :create, params: { - :censor_rule => censor_rule_params, - :user_id => user.id + censor_rule: censor_rule_params, + user_id: user.id } expect(response).to render_template('new') end @@ -472,8 +472,8 @@ def create_censor_rule before(:each) do post :create, params: { - :body_id => public_body.id, - :censor_rule => censor_rule_params + body_id: public_body.id, + censor_rule: censor_rule_params } end @@ -498,16 +498,16 @@ def create_censor_rule it 'persists the censor rule' do post :create, params: { - :censor_rule => censor_rule_params, - :body_id => public_body.id + censor_rule: censor_rule_params, + body_id: public_body.id } expect(assigns[:censor_rule]).to be_persisted end it 'confirms the censor rule is created' do post :create, params: { - :censor_rule => censor_rule_params, - :body_id => public_body.id + censor_rule: censor_rule_params, + body_id: public_body.id } msg = 'Censor rule was successfully created.' expect(flash[:notice]).to eq(msg) @@ -516,13 +516,13 @@ def create_censor_rule it 'calls expire_requests on the new censor_rule' do allow(PublicBody).to receive(:find) { public_body } censor_rule = FactoryBot.build(:public_body_censor_rule, - :public_body => public_body) + public_body: public_body) allow(public_body.censor_rules).to receive(:build) { censor_rule } allow(censor_rule).to receive(:expire_requests) post :create, params: { - :censor_rule => censor_rule_params, - :body_id => public_body.id + censor_rule: censor_rule_params, + body_id: public_body.id } expect(censor_rule).to have_received(:expire_requests) @@ -530,8 +530,8 @@ def create_censor_rule it 'redirects to the associated public body' do post :create, params: { - :censor_rule => censor_rule_params, - :body_id => public_body.id + censor_rule: censor_rule_params, + body_id: public_body.id } expect(response).to redirect_to( admin_body_path(assigns[:censor_rule].public_body) @@ -547,16 +547,16 @@ def create_censor_rule it 'does not persist the censor rule' do post :create, params: { - :censor_rule => censor_rule_params, - :body_id => public_body.id + censor_rule: censor_rule_params, + body_id: public_body.id } expect(assigns[:censor_rule]).to be_new_record end it 'renders the form' do post :create, params: { - :censor_rule => censor_rule_params, - :body_id => public_body.id + censor_rule: censor_rule_params, + body_id: public_body.id } expect(response).to render_template('new') end @@ -573,17 +573,17 @@ def create_censor_rule let(:censor_rule) { FactoryBot.create(:info_request_censor_rule) } it 'returns a successful response' do - get :edit, params: { :id => censor_rule.id } + get :edit, params: { id: censor_rule.id } expect(response).to be_successful end it 'renders the correct template' do - get :edit, params: { :id => censor_rule.id } + get :edit, params: { id: censor_rule.id } expect(response).to render_template('edit') end it 'finds the correct censor rule to edit' do - get :edit, params: { :id => censor_rule.id } + get :edit, params: { id: censor_rule.id } expect(assigns[:censor_rule]).to eq(censor_rule) end @@ -594,17 +594,17 @@ def create_censor_rule let(:censor_rule) { FactoryBot.create(:user_censor_rule) } it 'returns a successful response' do - get :edit, params: { :id => censor_rule.id } + get :edit, params: { id: censor_rule.id } expect(response).to be_successful end it 'renders the correct template' do - get :edit, params: { :id => censor_rule.id } + get :edit, params: { id: censor_rule.id } expect(response).to render_template('edit') end it 'finds the correct censor rule to edit' do - get :edit, params: { :id => censor_rule.id } + get :edit, params: { id: censor_rule.id } expect(assigns[:censor_rule]).to eq(censor_rule) end @@ -615,17 +615,17 @@ def create_censor_rule let(:censor_rule) { FactoryBot.create(:public_body_censor_rule) } it 'returns a successful response' do - get :edit, params: { :id => censor_rule.id } + get :edit, params: { id: censor_rule.id } expect(response).to be_successful end it 'renders the correct template' do - get :edit, params: { :id => censor_rule.id } + get :edit, params: { id: censor_rule.id } expect(response).to render_template('edit') end it 'finds the correct censor rule to edit' do - get :edit, params: { :id => censor_rule.id } + get :edit, params: { id: censor_rule.id } expect(assigns[:censor_rule]).to eq(censor_rule) end @@ -636,17 +636,17 @@ def create_censor_rule let(:censor_rule) { FactoryBot.create(:global_censor_rule) } it 'returns a successful response' do - get :edit, params: { :id => censor_rule.id } + get :edit, params: { id: censor_rule.id } expect(response).to be_successful end it 'renders the correct template' do - get :edit, params: { :id => censor_rule.id } + get :edit, params: { id: censor_rule.id } expect(response).to render_template('edit') end it 'finds the correct censor rule to edit' do - get :edit, params: { :id => censor_rule.id } + get :edit, params: { id: censor_rule.id } expect(assigns[:censor_rule]).to eq(censor_rule) end @@ -662,8 +662,8 @@ def create_censor_rule it 'finds the correct censor rule to edit' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(assigns[:censor_rule]).to eq(censor_rule) @@ -671,8 +671,8 @@ def create_censor_rule it 'sets the last_edit_editor to the current admin' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(assigns[:censor_rule].last_edit_editor).to eq('*unknown*') @@ -682,8 +682,8 @@ def create_censor_rule it 'updates the censor rule' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } censor_rule.reload expect(censor_rule.text).to eq('different text') @@ -691,8 +691,8 @@ def create_censor_rule it 'confirms the censor rule is updated' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } msg = 'Censor rule was successfully updated.' expect(flash[:notice]).to eq(msg) @@ -702,8 +702,8 @@ def create_censor_rule allow(CensorRule).to receive(:find) { censor_rule } allow(censor_rule).to receive(:expire_requests) put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(censor_rule).to have_received(:expire_requests) @@ -711,8 +711,8 @@ def create_censor_rule it 'redirects to the censor rule index' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(response).to redirect_to(admin_censor_rules_path) @@ -728,8 +728,8 @@ def create_censor_rule it 'does not update the censor rule' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } censor_rule.reload expect(censor_rule.text).to eq('some text to redact') @@ -737,8 +737,8 @@ def create_censor_rule it 'renders the form' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(response).to render_template('edit') @@ -754,8 +754,8 @@ def create_censor_rule it 'finds the correct censor rule to edit' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(assigns[:censor_rule]).to eq(censor_rule) @@ -763,8 +763,8 @@ def create_censor_rule it 'sets the last_edit_editor to the current admin' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(assigns[:censor_rule].last_edit_editor).to eq('*unknown*') @@ -774,8 +774,8 @@ def create_censor_rule it 'updates the censor rule' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } censor_rule.reload expect(censor_rule.text).to eq('different text') @@ -783,8 +783,8 @@ def create_censor_rule it 'confirms the censor rule is updated' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } msg = 'Censor rule was successfully updated.' expect(flash[:notice]).to eq(msg) @@ -794,8 +794,8 @@ def create_censor_rule allow(CensorRule).to receive(:find) { censor_rule } allow(censor_rule).to receive(:expire_requests) put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(censor_rule).to have_received(:expire_requests) @@ -803,8 +803,8 @@ def create_censor_rule it 'redirects to the associated info request' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(response).to redirect_to( @@ -822,8 +822,8 @@ def create_censor_rule it 'does not update the censor rule' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } censor_rule.reload expect(censor_rule.text).to eq('some text to redact') @@ -831,8 +831,8 @@ def create_censor_rule it 'renders the form' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(response).to render_template('edit') @@ -848,8 +848,8 @@ def create_censor_rule it 'finds the correct censor rule to edit' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(assigns[:censor_rule]).to eq(censor_rule) @@ -857,8 +857,8 @@ def create_censor_rule it 'sets the last_edit_editor to the current admin' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(assigns[:censor_rule].last_edit_editor).to eq('*unknown*') @@ -867,8 +867,8 @@ def create_censor_rule context 'successfully saving the censor rule' do it 'updates the censor rule' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } censor_rule.reload expect(censor_rule.text).to eq('different text') @@ -876,8 +876,8 @@ def create_censor_rule it 'confirms the censor rule is updated' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } msg = 'Censor rule was successfully updated.' expect(flash[:notice]).to eq(msg) @@ -887,8 +887,8 @@ def create_censor_rule allow(CensorRule).to receive(:find) { censor_rule } allow(censor_rule).to receive(:expire_requests) put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(censor_rule).to have_received(:expire_requests) @@ -896,8 +896,8 @@ def create_censor_rule it 'redirects to the associated info request' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(response).to redirect_to( @@ -914,8 +914,8 @@ def create_censor_rule it 'does not update the censor rule' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } censor_rule.reload expect(censor_rule.text).to eq('some text to redact') @@ -923,8 +923,8 @@ def create_censor_rule it 'renders the form' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(response).to render_template('edit') @@ -940,8 +940,8 @@ def create_censor_rule it 'finds the correct censor rule to edit' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(assigns[:censor_rule]).to eq(censor_rule) @@ -949,8 +949,8 @@ def create_censor_rule it 'sets the last_edit_editor to the current admin' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(assigns[:censor_rule].last_edit_editor).to eq('*unknown*') @@ -960,8 +960,8 @@ def create_censor_rule it 'updates the censor rule' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } censor_rule.reload expect(censor_rule.text).to eq('different text') @@ -969,8 +969,8 @@ def create_censor_rule it 'confirms the censor rule is updated' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } msg = 'Censor rule was successfully updated.' expect(flash[:notice]).to eq(msg) @@ -980,8 +980,8 @@ def create_censor_rule allow(CensorRule).to receive(:find) { censor_rule } allow(censor_rule).to receive(:expire_requests) put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(censor_rule).to have_received(:expire_requests) @@ -989,8 +989,8 @@ def create_censor_rule it 'redirects to the associated public body' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(response).to redirect_to( @@ -1008,8 +1008,8 @@ def create_censor_rule it 'does not update the censor rule' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } censor_rule.reload expect(censor_rule.text).to eq('some text to redact') @@ -1017,8 +1017,8 @@ def create_censor_rule it 'renders the form' do put :update, params: { - :id => censor_rule.id, - :censor_rule => { :text => 'different text' } + id: censor_rule.id, + censor_rule: { text: 'different text' } } expect(response).to render_template('edit') @@ -1037,18 +1037,18 @@ def create_censor_rule let(:censor_rule) { FactoryBot.create(:global_censor_rule) } it 'finds the correct censor rule to destroy' do - delete :destroy, params: { :id => censor_rule.id } + delete :destroy, params: { id: censor_rule.id } expect(assigns[:censor_rule]).to eq(censor_rule) end it 'confirms the censor rule is destroyed in all cases' do - delete :destroy, params: { :id => censor_rule.id } + delete :destroy, params: { id: censor_rule.id } msg = 'Censor rule was successfully destroyed.' expect(flash[:notice]).to eq(msg) end it 'redirects to the censor rules index' do - delete :destroy, params: { :id => censor_rule.id } + delete :destroy, params: { id: censor_rule.id } expect(response).to redirect_to(admin_censor_rules_path) end @@ -1059,12 +1059,12 @@ def create_censor_rule let(:censor_rule) { FactoryBot.create(:info_request_censor_rule) } it 'finds the correct censor rule to destroy' do - delete :destroy, params: { :id => censor_rule.id } + delete :destroy, params: { id: censor_rule.id } expect(assigns[:censor_rule]).to eq(censor_rule) end it 'confirms the censor rule is destroyed in all cases' do - delete :destroy, params: { :id => censor_rule.id } + delete :destroy, params: { id: censor_rule.id } msg = 'Censor rule was successfully destroyed.' expect(flash[:notice]).to eq(msg) end @@ -1072,13 +1072,13 @@ def create_censor_rule it 'calls expire_requests on the censor rule' do expect(CensorRule).to receive(:find) { censor_rule } allow(censor_rule).to receive(:expire_requests) - delete :destroy, params: { :id => censor_rule.id } + delete :destroy, params: { id: censor_rule.id } expect(censor_rule).to have_received(:expire_requests) end it 'redirects to the associated info request' do - delete :destroy, params: { :id => censor_rule.id } + delete :destroy, params: { id: censor_rule.id } expect(response). to redirect_to(admin_request_path(censor_rule.info_request)) end @@ -1090,12 +1090,12 @@ def create_censor_rule let(:censor_rule) { FactoryBot.create(:user_censor_rule) } it 'finds the correct censor rule to destroy' do - delete :destroy, params: { :id => censor_rule.id } + delete :destroy, params: { id: censor_rule.id } expect(assigns[:censor_rule]).to eq(censor_rule) end it 'confirms the censor rule is destroyed in all cases' do - delete :destroy, params: { :id => censor_rule.id } + delete :destroy, params: { id: censor_rule.id } msg = 'Censor rule was successfully destroyed.' expect(flash[:notice]).to eq(msg) end @@ -1103,13 +1103,13 @@ def create_censor_rule it 'calls expire_requests on the censor rule' do expect(CensorRule).to receive(:find) { censor_rule } allow(censor_rule).to receive(:expire_requests) - delete :destroy, params: { :id => censor_rule.id } + delete :destroy, params: { id: censor_rule.id } expect(censor_rule).to have_received(:expire_requests) end it 'redirects to the associated info request' do - delete :destroy, params: { :id => censor_rule.id } + delete :destroy, params: { id: censor_rule.id } expect(response).to redirect_to(admin_user_path(censor_rule.user)) end @@ -1120,12 +1120,12 @@ def create_censor_rule let(:censor_rule) { FactoryBot.create(:public_body_censor_rule) } it 'finds the correct censor rule to destroy' do - delete :destroy, params: { :id => censor_rule.id } + delete :destroy, params: { id: censor_rule.id } expect(assigns[:censor_rule]).to eq(censor_rule) end it 'confirms the censor rule is destroyed in all cases' do - delete :destroy, params: { :id => censor_rule.id } + delete :destroy, params: { id: censor_rule.id } msg = 'Censor rule was successfully destroyed.' expect(flash[:notice]).to eq(msg) end @@ -1133,13 +1133,13 @@ def create_censor_rule it 'calls expire_requests on the censor rule' do expect(CensorRule).to receive(:find) { censor_rule } allow(censor_rule).to receive(:expire_requests) - delete :destroy, params: { :id => censor_rule.id } + delete :destroy, params: { id: censor_rule.id } expect(censor_rule).to have_received(:expire_requests) end it 'redirects to the associated public body' do - delete :destroy, params: { :id => censor_rule.id } + delete :destroy, params: { id: censor_rule.id } expect(response). to redirect_to(admin_body_path(censor_rule.public_body)) end diff --git a/spec/controllers/admin_comment_controller_spec.rb b/spec/controllers/admin_comment_controller_spec.rb index 19812fbe24..4eb0bb4ed7 100644 --- a/spec/controllers/admin_comment_controller_spec.rb +++ b/spec/controllers/admin_comment_controller_spec.rb @@ -25,17 +25,17 @@ it 'assigns the query' do sign_in admin_user - get :index, params: { :query => 'hello' } + get :index, params: { query: 'hello' } expect(assigns[:query]).to eq('hello') end it 'filters comments by the search query' do Comment.destroy_all - comment_1 = FactoryBot.create(:comment, :body => 'Hello world') - comment_2 = FactoryBot.create(:comment, :body => 'Hi! hello world') - comment_3 = FactoryBot.create(:comment, :body => 'xyz') + comment_1 = FactoryBot.create(:comment, body: 'Hello world') + comment_2 = FactoryBot.create(:comment, body: 'Hi! hello world') + comment_3 = FactoryBot.create(:comment, body: 'xyz') sign_in admin_user - get :index, params: { :query => 'hello' } + get :index, params: { query: 'hello' } expect(assigns[:comments]).to eq([comment_2, comment_1]) end @@ -94,13 +94,13 @@ it 'renders the edit template' do sign_in admin_user - get :edit, params: { :id => comment.id } + get :edit, params: { id: comment.id } expect(response).to render_template('edit') end it 'gets the comment' do sign_in admin_user - get :edit, params: { :id => comment.id } + get :edit, params: { id: comment.id } expect(assigns[:comment]).to eq(comment) end @@ -114,7 +114,7 @@ comment.info_request.create_embargo expect { sign_in admin_user - get :edit, params: { :id => comment.id } + get :edit, params: { id: comment.id } }.to raise_error ActiveRecord::RecordNotFound end end @@ -126,7 +126,7 @@ with_feature_enabled(:alaveteli_pro) do comment.info_request.create_embargo sign_in pro_admin_user - get :edit, params: { :id => comment.id } + get :edit, params: { id: comment.id } expect(response).to render_template('edit') end end @@ -138,25 +138,25 @@ let(:pro_admin_user) { FactoryBot.create(:pro_admin_user) } let(:admin_user) { FactoryBot.create(:admin_user) } let(:comment) { FactoryBot.create(:comment) } - let(:atts) { FactoryBot.attributes_for(:comment, :body => 'I am new') } + let(:atts) { FactoryBot.attributes_for(:comment, body: 'I am new') } context 'on valid data submission' do it 'gets the comment' do sign_in admin_user - put :update, params: { :id => comment.id, :comment => atts } + put :update, params: { id: comment.id, comment: atts } expect(assigns[:comment]).to eq(comment) end it 'updates the comment' do sign_in admin_user - put :update, params: { :id => comment.id, :comment => atts } + put :update, params: { id: comment.id, comment: atts } expect(Comment.find(comment.id).body).to eq('I am new') end it 'logs the update event' do sign_in admin_user - put :update, params: { :id => comment.id, :comment => atts } + put :update, params: { id: comment.id, comment: atts } most_recent_event = Comment.find(comment.id).info_request_events.last expect(most_recent_event.event_type).to eq('edit_comment') expect(most_recent_event.comment_id).to eq(comment.id) @@ -165,13 +165,13 @@ context 'the attention_requested flag is the only change' do let(:atts) do FactoryBot.attributes_for(:comment, - :body => comment.body, - :attention_requested => true) + body: comment.body, + attention_requested: true) end before do sign_in admin_user - put :update, params: { :id => comment.id, :comment => atts } + put :update, params: { id: comment.id, comment: atts } end it 'logs the update event' do @@ -182,9 +182,9 @@ it 'captures the old and new attention_requested values' do most_recent_event = Comment.find(comment.id).info_request_events.last expect(most_recent_event.params). - to include(:old_attention_requested => false) + to include(old_attention_requested: false) expect(most_recent_event.params). - to include(:attention_requested => true) + to include(attention_requested: true) end it 'updates the comment' do @@ -199,10 +199,10 @@ it 'logs a "hide_comment" event' do atts = FactoryBot.attributes_for(:comment, - :attention_requested => true, - :visible => false) + attention_requested: true, + visible: false) sign_in admin_user - put :update, params: { :id => comment.id, :comment => atts } + put :update, params: { id: comment.id, comment: atts } last_event = Comment.find(comment.id).info_request_events.last expect(last_event.event_type).to eq('hide_comment') @@ -214,11 +214,11 @@ it 'logs an "edit_comment" event' do atts = FactoryBot.attributes_for(:comment, - :attention_requested => true, - :visible => false, - :body => 'updated text') + attention_requested: true, + visible: false, + body: 'updated text') sign_in admin_user - put :update, params: { :id => comment.id, :comment => atts } + put :update, params: { id: comment.id, comment: atts } last_event = Comment.find(comment.id).info_request_events.last expect(last_event.event_type).to eq('edit_comment') @@ -230,21 +230,21 @@ it 'shows a success notice' do atts = FactoryBot.attributes_for(:comment, - :attention_requested => true, - :visible => false, - :body => 'updated text') + attention_requested: true, + visible: false, + body: 'updated text') sign_in admin_user - put :update, params: { :id => comment.id, :comment => atts } + put :update, params: { id: comment.id, comment: atts } expect(flash[:notice]).to eq("Comment successfully updated.") end it 'redirects to the request page' do atts = FactoryBot.attributes_for(:comment, - :attention_requested => true, - :visible => false, - :body => 'updated text') + attention_requested: true, + visible: false, + body: 'updated text') sign_in admin_user - put :update, params: { :id => comment.id, :comment => atts } + put :update, params: { id: comment.id, comment: atts } expect(response).to redirect_to(admin_request_path(comment.info_request)) end end @@ -255,8 +255,8 @@ with_feature_enabled(:alaveteli_pro) do sign_in admin_user put :update, params: { - :id => comment.id, - :comment => { :body => '' } + id: comment.id, + comment: { body: '' } } expect(response).to render_template('edit') end @@ -274,7 +274,7 @@ comment.info_request.create_embargo expect { sign_in admin_user - put :update, params: { :id => comment.id } + put :update, params: { id: comment.id } }.to raise_error ActiveRecord::RecordNotFound end end @@ -286,7 +286,7 @@ with_feature_enabled(:alaveteli_pro) do comment.info_request.create_embargo sign_in pro_admin_user - put :update, params: { :id => comment.id, :comment => atts } + put :update, params: { id: comment.id, comment: atts } expect(Comment.find(comment.id).body).to eq('I am new') end end diff --git a/spec/controllers/admin_general_controller_spec.rb b/spec/controllers/admin_general_controller_spec.rb index 2d963f9983..8fd21e3564 100644 --- a/spec/controllers/admin_general_controller_spec.rb +++ b/spec/controllers/admin_general_controller_spec.rb @@ -54,7 +54,7 @@ it 'assigns messages sent to the holding pen to the view' do undeliverable = FactoryBot. create(:incoming_message, - :info_request => InfoRequest.holding_pen_request) + info_request: InfoRequest.holding_pen_request) sign_in admin_user get :index expect(assigns[:holding_pen_messages]).to eq([undeliverable]) @@ -65,8 +65,7 @@ it 'assigns public_request_tasks to true' do undeliverable = FactoryBot. create(:incoming_message, - :info_request => - InfoRequest.holding_pen_request) + info_request: InfoRequest.holding_pen_request) sign_in admin_user get :index expect(assigns[:public_request_tasks]).to be true @@ -329,7 +328,7 @@ public_body.save! public_body.reload @second_public_body_version = public_body.versions.latest - get :timeline, params: { :all => 1 } + get :timeline, params: { all: 1 } end it 'assigns an array of events in order of descending date to the view' do @@ -347,8 +346,8 @@ before do get :timeline, params: { - :all => 1, - :event_type => 'info_request_event' + all: 1, + event_type: 'info_request_event' } end @@ -366,7 +365,7 @@ context 'when event_type is authority_change' do before do - get :timeline, params: { :all => 1, :event_type => 'authority_change' } + get :timeline, params: { all: 1, event_type: 'authority_change' } end it 'assigns an array of public body versions in order of descending diff --git a/spec/controllers/admin_holiday_imports_controller_spec.rb b/spec/controllers/admin_holiday_imports_controller_spec.rb index 8030aabbb7..e3f3786ba7 100644 --- a/spec/controllers/admin_holiday_imports_controller_spec.rb +++ b/spec/controllers/admin_holiday_imports_controller_spec.rb @@ -17,8 +17,8 @@ describe 'if the import is valid' do it 'populates the import' do - mock_import = double(HolidayImport, :valid? => true, - :populate => nil) + mock_import = double(HolidayImport, valid?: true, + populate: nil) allow(HolidayImport).to receive(:new).and_return(mock_import) expect(mock_import).to receive(:populate) get :new @@ -70,7 +70,7 @@ describe 'if the import can be saved' do before do - mock_import = double(HolidayImport, :save => true) + mock_import = double(HolidayImport, save: true) allow(HolidayImport).to receive(:new).and_return(mock_import) post :create end @@ -88,7 +88,7 @@ describe 'if the import cannot be saved' do before do - mock_import = double(HolidayImport, :save => false) + mock_import = double(HolidayImport, save: false) allow(HolidayImport).to receive(:new).and_return(mock_import) post :create end diff --git a/spec/controllers/admin_holidays_controller_spec.rb b/spec/controllers/admin_holidays_controller_spec.rb index 3f5d143caa..b00d57a4ba 100644 --- a/spec/controllers/admin_holidays_controller_spec.rb +++ b/spec/controllers/admin_holidays_controller_spec.rb @@ -5,9 +5,9 @@ describe 'GET index' do before do - @holiday_one = FactoryBot.create(:holiday, :day => Date.new(2010, 1, 1)) - @holiday_two = FactoryBot.create(:holiday, :day => Date.new(2011, 2, 2)) - @holiday_three = FactoryBot.create(:holiday, :day => Date.new(2011, 3, 3)) + @holiday_one = FactoryBot.create(:holiday, day: Date.new(2010, 1, 1)) + @holiday_two = FactoryBot.create(:holiday, day: Date.new(2011, 2, 2)) + @holiday_three = FactoryBot.create(:holiday, day: Date.new(2011, 3, 3)) end it 'gets a hash of holidays keyed by year' do @@ -46,7 +46,7 @@ it 'renders the new form partial' do get :new, xhr: true - expect(response).to render_template(:partial => '_new_form') + expect(response).to render_template(partial: '_new_form') end end @@ -64,7 +64,7 @@ 'day(1i)' => '2010', 'day(2i)' => '1', 'day(3i)' => '1' } - post :create, params: { :holiday => @holiday_params } + post :create, params: { holiday: @holiday_params } end it 'creates a new holiday' do @@ -85,7 +85,7 @@ before do allow_any_instance_of(Holiday).to receive(:save).and_return(false) - post :create, params: { :holiday => @holiday_params } + post :create, params: { holiday: @holiday_params } end it 'renders the new template' do @@ -104,7 +104,7 @@ describe 'when not using ajax' do it 'renders the edit template' do - get :edit, params: { :id => @holiday.id } + get :edit, params: { id: @holiday.id } expect(response).to render_template('edit') end @@ -113,14 +113,14 @@ describe 'when using ajax' do it 'renders the edit form partial' do - get :edit, xhr: true, params: { :id => @holiday.id } - expect(response).to render_template(:partial => '_edit_form') + get :edit, xhr: true, params: { id: @holiday.id } + expect(response).to render_template(partial: '_edit_form') end end it 'gets the holiday in the id param' do - get :edit, params: { :id => @holiday.id } + get :edit, params: { id: @holiday.id } expect(assigns[:holiday]).to eq(@holiday) end @@ -129,11 +129,11 @@ describe 'PUT update' do before do - @holiday = FactoryBot.create(:holiday, :day => Date.new(2010, 1, 1), - :description => "Test Holiday") + @holiday = FactoryBot.create(:holiday, day: Date.new(2010, 1, 1), + description: "Test Holiday") put :update, params: { - :id => @holiday.id, - :holiday => { :description => 'New Test Holiday' } + id: @holiday.id, + holiday: { description: 'New Test Holiday' } } end @@ -158,8 +158,8 @@ before do allow_any_instance_of(Holiday).to receive(:update).and_return(false) put :update, params: { - :id => @holiday.id, - :holiday => { :description => 'New Test Holiday' } + id: @holiday.id, + holiday: { description: 'New Test Holiday' } } end @@ -174,7 +174,7 @@ before(:each) do @holiday = FactoryBot.create(:holiday) - delete :destroy, params: { :id => @holiday.id } + delete :destroy, params: { id: @holiday.id } end it 'finds the holiday to destroy' do diff --git a/spec/controllers/admin_incoming_message_controller_spec.rb b/spec/controllers/admin_incoming_message_controller_spec.rb index 9551d65bb0..4d21488a21 100644 --- a/spec/controllers/admin_incoming_message_controller_spec.rb +++ b/spec/controllers/admin_incoming_message_controller_spec.rb @@ -26,15 +26,15 @@ it 'asks the incoming message to destroy itself' do allow(IncomingMessage).to receive(:find).and_return(@im) expect(@im).to receive(:destroy) - post :destroy, params: { :id => @im.id } + post :destroy, params: { id: @im.id } end it 'expires the file cache for the associated info_request' do info_request = FactoryBot.create(:info_request) allow(@im).to receive(:info_request).and_return(info_request) allow(IncomingMessage).to receive(:find).and_return(@im) - expect(@im.info_request).to receive(:expire).with(:preserve_database_cache => true) - post :destroy, params: { :id => @im.id } + expect(@im.info_request).to receive(:expire).with(preserve_database_cache: true) + post :destroy, params: { id: @im.id } end context 'if the request is embargoed', feature: :alaveteli_pro do @@ -78,8 +78,8 @@ allow(IncomingMessage).to receive(:find).and_return(incoming_message) expect(previous_info_request).to receive(:expire) post :redeliver, params: { - :id => incoming_message.id, - :url_title => destination_info_request.url_title + id: incoming_message.id, + url_title: destination_info_request.url_title } end @@ -87,8 +87,8 @@ with_duplicate_xapian_job_creation do post :redeliver, params: { - :id => incoming_message.id, - :url_title => destination_info_request.url_title + id: incoming_message.id, + url_title: destination_info_request.url_title } end @@ -96,8 +96,8 @@ it 'shouldn\'t do anything if no message_id is supplied' do post :redeliver, params: { - :id => incoming_message.id, - :url_title => '' + id: incoming_message.id, + url_title: '' } # It shouldn't delete this message assert_equal IncomingMessage.exists?(incoming_message.id), true @@ -145,12 +145,12 @@ end it 'should be successful' do - get :edit, params: { :id => @incoming.id } + get :edit, params: { id: @incoming.id } expect(response).to be_successful end it 'should assign the incoming message to the view' do - get :edit, params: { :id => @incoming.id } + get :edit, params: { id: @incoming.id } expect(assigns[:incoming_message]).to eq(@incoming) end @@ -182,7 +182,7 @@ before do sign_in(admin_user) - @incoming = FactoryBot.create(:incoming_message, :prominence => 'normal') + @incoming = FactoryBot.create(:incoming_message, prominence: 'normal') @default_params = { id: @incoming.id, incoming_message: { @@ -258,9 +258,9 @@ def make_request(params=@default_params) context 'if the incoming message is not valid' do it 'should render the edit template' do - make_request({:id => @incoming.id, - :incoming_message => {:prominence => 'fantastic', - :prominence_reason => 'dull'}}) + make_request({id: @incoming.id, + incoming_message: {prominence: 'fantastic', + prominence_reason: 'dull'}}) expect(response).to render_template("edit") end @@ -295,12 +295,12 @@ def make_request(params=@default_params) let(:request) { FactoryBot.create(:info_request) } let(:spam1) { FactoryBot.create( :incoming_message, - :subject => "Buy a watch!1!!", - :info_request => request) } + subject: "Buy a watch!1!!", + info_request: request) } let(:spam2) { FactoryBot.create( :incoming_message, - :subject => "Best cheap w@tches!!1!", - :info_request => request) } + subject: "Best cheap w@tches!!1!", + info_request: request) } let(:spam_ids) { [spam1.id, spam2.id] } before { sign_in(admin_user) } @@ -309,29 +309,29 @@ def make_request(params=@default_params) it "destroys the selected messages" do post :bulk_destroy, params: { - :request_id => request.id, - :ids => spam_ids.join(","), - :commit => "Yes" + request_id: request.id, + ids: spam_ids.join(","), + commit: "Yes" } - expect(IncomingMessage.where(:id => spam_ids)).to be_empty + expect(IncomingMessage.where(id: spam_ids)).to be_empty end it 'expires the file cache for the associated info_request' do allow(InfoRequest).to receive(:find).and_return(request) - expect(request).to receive(:expire).with(:preserve_database_cache => true) + expect(request).to receive(:expire).with(preserve_database_cache: true) post :bulk_destroy, params: { - :request_id => request.id, - :ids => spam_ids.join(","), - :commit => "Yes" + request_id: request.id, + ids: spam_ids.join(","), + commit: "Yes" } end it "redirects back to the admin page for the request" do post :bulk_destroy, params: { - :request_id => request.id, - :ids => spam_ids.join(","), - :commit => "Yes" + request_id: request.id, + ids: spam_ids.join(","), + commit: "Yes" } expect(response).to redirect_to(admin_request_url(request)) @@ -339,9 +339,9 @@ def make_request(params=@default_params) it "sets a success message in flash" do post :bulk_destroy, params: { - :request_id => request.id, - :ids => spam_ids.join(","), - :commit => "Yes" + request_id: request.id, + ids: spam_ids.join(","), + commit: "Yes" } expect(response).to redirect_to(admin_request_url(request)) @@ -350,12 +350,12 @@ def make_request(params=@default_params) it "only destroys selected messages" do post :bulk_destroy, params: { - :request_id => request.id, - :ids => spam2.id, - :commit => "Yes" + request_id: request.id, + ids: spam2.id, + commit: "Yes" } - expect(IncomingMessage.where(:id => spam_ids)).to eq([spam1]) + expect(IncomingMessage.where(id: spam_ids)).to eq([spam1]) end context "not all the messages can be destroyed" do @@ -365,9 +365,9 @@ def make_request(params=@default_params) allow(IncomingMessage).to receive(:where).and_return([spam1, spam2]) msg = "Incoming Messages #{spam2.id} could not be destroyed" post :bulk_destroy, params: { - :request_id => request.id, - :ids => spam_ids.join(","), - :commit => "Yes" + request_id: request.id, + ids: spam_ids.join(","), + commit: "Yes" } expect(flash[:error]).to match(msg) @@ -381,19 +381,19 @@ def make_request(params=@default_params) it "does not destroy the messages" do post :bulk_destroy, params: { - :request_id => request.id, - :ids => spam_ids.split(","), - :commit => "No" + request_id: request.id, + ids: spam_ids.split(","), + commit: "No" } - expect(IncomingMessage.where(:id => spam_ids)).to match_array([spam1, spam2]) + expect(IncomingMessage.where(id: spam_ids)).to match_array([spam1, spam2]) end it "redirects back to the admin page for the request" do post :bulk_destroy, params: { - :request_id => request.id, - :ids => spam_ids.join(","), - :commit => "No" + request_id: request.id, + ids: spam_ids.join(","), + commit: "No" } expect(response).to redirect_to(admin_request_url(request)) diff --git a/spec/controllers/admin_info_request_event_controller_spec.rb b/spec/controllers/admin_info_request_event_controller_spec.rb index cc1ff6fc98..d69ff903f9 100644 --- a/spec/controllers/admin_info_request_event_controller_spec.rb +++ b/spec/controllers/admin_info_request_event_controller_spec.rb @@ -10,12 +10,12 @@ describe 'when handling valid data' do it 'gets the info request event' do - put :update, params: { :id => info_request_event } + put :update, params: { id: info_request_event } expect(assigns[:info_request_event]).to eq(info_request_event) end it 'sets the described and calculated states on the event' do - put :update, params: { :id => info_request_event } + put :update, params: { id: info_request_event } event = InfoRequestEvent.find(info_request_event.id) expect(event.described_state).to eq('waiting_clarification') expect(event.calculated_state).to eq('waiting_clarification') @@ -27,40 +27,40 @@ info_request = info_request_event.info_request travel_to(info_request.date_response_required_by) do outgoing_message = - OutgoingMessage.new(:status => 'ready', - :message_type => 'followup', - :what_doing => 'normal_sort', - :info_request_id => info_request.id, - :body => "Here's the clarification.") + OutgoingMessage.new(status: 'ready', + message_type: 'followup', + what_doing: 'normal_sort', + info_request_id: info_request.id, + body: "Here's the clarification.") outgoing_message.record_email_delivery( 'foi@example.com', 'example.id' ) outgoing_message.save! - put :update, params: { :id => info_request_event } + put :update, params: { id: info_request_event } expect(info_request.reload.date_initial_request_last_sent_at). to eq(Time.zone.now.to_date) end end it 'shows a success notice' do - put :update, params: { :id => info_request_event } + put :update, params: { id: info_request_event } expect(flash[:notice]). to eq('Old response marked as having been a request for clarification') end it 'redirects to the request admin page' do - put :update, params: { :id => info_request_event } + put :update, params: { id: info_request_event } expect(response). to redirect_to(admin_request_url(info_request_event.info_request)) end end it 'raises an exception if the event is not a response' do - put :update, params: { :id => info_request_event } + put :update, params: { id: info_request_event } info_request_event = FactoryBot.create(:sent_event) expect { - put :update, params: { :id => info_request_event } + put :update, params: { id: info_request_event } }.to raise_error(RuntimeError, "can only mark responses as requires clarification") end diff --git a/spec/controllers/admin_outgoing_message_controller_spec.rb b/spec/controllers/admin_outgoing_message_controller_spec.rb index f7a8e972fa..6ccf8cfc88 100644 --- a/spec/controllers/admin_outgoing_message_controller_spec.rb +++ b/spec/controllers/admin_outgoing_message_controller_spec.rb @@ -13,19 +13,19 @@ let(:outgoing) { info_request.outgoing_messages.first } it 'should be successful' do - get :edit, params: { :id => outgoing.id } + get :edit, params: { id: outgoing.id } expect(response).to be_successful end it 'should assign the outgoing message to the view' do - get :edit, params: { :id => outgoing.id } + get :edit, params: { id: outgoing.id } expect(assigns[:outgoing_message]).to eq(outgoing) end context 'when the message is the initial outgoing message' do it 'sets is_initial_message to true' do - get :edit, params: { :id => outgoing.id } + get :edit, params: { id: outgoing.id } expect(assigns[:is_initial_message]).to eq(true) end @@ -35,8 +35,8 @@ it 'sets is_initial_message to false' do outgoing = FactoryBot.create(:new_information_followup, - :info_request => info_request) - get :edit, params: { :id => outgoing.id } + info_request: info_request) + get :edit, params: { id: outgoing.id } expect(assigns[:is_initial_message]).to eq(false) end @@ -73,34 +73,34 @@ let(:info_request) { FactoryBot.create(:info_request) } let(:outgoing) do FactoryBot.create(:new_information_followup, - :info_request => info_request) + info_request: info_request) end it 'finds the outgoing message' do - delete :destroy, params: { :id => outgoing.id } + delete :destroy, params: { id: outgoing.id } expect(assigns[:outgoing_message]).to eq(outgoing) end context 'successfully destroying the message' do it 'destroys the message' do - delete :destroy, params: { :id => outgoing.id } + delete :destroy, params: { id: outgoing.id } expect(assigns[:outgoing_message]).to_not be_persisted end it 'logs an event on the info request' do - delete :destroy, params: { :id => outgoing.id } + delete :destroy, params: { id: outgoing.id } expect(info_request.reload.last_event.event_type). to eq('destroy_outgoing') end it 'informs the user' do - delete :destroy, params: { :id => outgoing.id } + delete :destroy, params: { id: outgoing.id } expect(flash[:notice]).to eq('Outgoing message successfully destroyed.') end it 'redirects to the admin request page' do - delete :destroy, params: { :id => outgoing.id } + delete :destroy, params: { id: outgoing.id } expect(response).to redirect_to(admin_request_url(info_request)) end @@ -113,17 +113,17 @@ end it 'does not destroy the message' do - delete :destroy, params: { :id => outgoing.id } + delete :destroy, params: { id: outgoing.id } expect(assigns[:outgoing_message]).to be_persisted end it 'informs the user' do - delete :destroy, params: { :id => outgoing.id } + delete :destroy, params: { id: outgoing.id } expect(flash[:error]).to eq('Could not destroy the outgoing message.') end it 'redirects to the outgoing message edit page' do - delete :destroy, params: { :id => outgoing.id } + delete :destroy, params: { id: outgoing.id } expect(response). to redirect_to(edit_admin_outgoing_message_path(outgoing)) end @@ -134,13 +134,13 @@ it 'sets is_initial_message to true' do outgoing = FactoryBot.create(:initial_request) - delete :destroy, params: { :id => outgoing.id } + delete :destroy, params: { id: outgoing.id } expect(assigns[:is_initial_message]).to eq(true) end it 'prevents the destruction of the message' do outgoing = FactoryBot.create(:initial_request) - delete :destroy, params: { :id => outgoing.id } + delete :destroy, params: { id: outgoing.id } expect(assigns[:outgoing_message]).to be_persisted end @@ -149,12 +149,12 @@ context 'when the message is not initial outgoing message' do it 'sets is_initial_message to false' do - delete :destroy, params: { :id => outgoing.id } + delete :destroy, params: { id: outgoing.id } expect(assigns[:is_initial_message]).to eq(false) end it 'allows the destruction of the message' do - delete :destroy, params: { :id => outgoing.id } + delete :destroy, params: { id: outgoing.id } expect(assigns[:outgoing_message]).to_not be_persisted end @@ -254,7 +254,7 @@ def make_request(params = default_params) info_request = FactoryBot.create(:info_request) allow_any_instance_of(OutgoingMessage).to receive(:info_request) { info_request } - outgoing = FactoryBot.create(:initial_request, :info_request => info_request) + outgoing = FactoryBot.create(:initial_request, info_request: info_request) expect(info_request).to receive(:expire) @@ -280,10 +280,10 @@ def make_request(params = default_params) context 'if the incoming message is not valid' do it 'should render the edit template' do - make_request({:id => outgoing.id, - :outgoing_message => {:prominence => 'fantastic', - :prominence_reason => 'dull', - :body => 'Some information please'}}) + make_request({id: outgoing.id, + outgoing_message: {prominence: 'fantastic', + prominence_reason: 'dull', + body: 'Some information please'}}) expect(response).to render_template("edit") end diff --git a/spec/controllers/admin_public_body_categories_controller_spec.rb b/spec/controllers/admin_public_body_categories_controller_spec.rb index 41c4c294a4..3af79ee4af 100644 --- a/spec/controllers/admin_public_body_categories_controller_spec.rb +++ b/spec/controllers/admin_public_body_categories_controller_spec.rb @@ -33,8 +33,8 @@ heading = FactoryBot.create(:public_body_heading) with_heading = FactoryBot.create(:public_body_category) - PublicBodyCategoryLink.create!(:public_body_heading_id => heading.id, - :public_body_category_id => with_heading.id) + PublicBodyCategoryLink.create!(public_body_heading_id: heading.id, + public_body_category_id: with_heading.id) get :index @@ -88,11 +88,11 @@ before(:each) do PublicBodyCategory.destroy_all - @params = { :category_tag => 'new_test_category', - :translations_attributes => { - 'en' => { :locale => 'en', - :title => 'New Category', - :description => 'New category for testing stuff' } + @params = { category_tag: 'new_test_category', + translations_attributes: { + 'en' => { locale: 'en', + title: 'New Category', + description: 'New category for testing stuff' } } } end @@ -100,23 +100,23 @@ PublicBodyCategory.destroy_all expect { - post :create, params: { :public_body_category => @params } + post :create, params: { public_body_category: @params } }.to change { PublicBodyCategory.count }.from(0).to(1) end it 'can create a category when the default locale is an underscore locale' do AlaveteliLocalization.set_locales('es en_GB', 'en_GB') post :create, params: { - :public_body_category => { - :title => 'New Category en_GB', - :description => 'test', - :category_tag => 'new_test_category' + public_body_category: { + title: 'New Category en_GB', + description: 'test', + category_tag: 'new_test_category' } } expect( PublicBodyCategory. - find_by(:title => 'New Category en_GB'). + find_by(title: 'New Category en_GB'). translations. first. locale @@ -128,21 +128,21 @@ params = FactoryBot.attributes_for(:public_body_category) post :create, params: { - :public_body_category => @params, - :headings => { "heading_#{ heading.id }" => heading.id } + public_body_category: @params, + headings: { "heading_#{ heading.id }" => heading.id } } - category = PublicBodyCategory.where(:title => @params[:translations_attributes]['en'][:title]).first + category = PublicBodyCategory.where(title: @params[:translations_attributes]['en'][:title]).first expect(category.public_body_headings).to eq([heading]) end it 'notifies the admin that the category was created' do - post :create, params: { :public_body_category => @params } + post :create, params: { public_body_category: @params } expect(flash[:notice]).to eq('Category was successfully created.') end it 'redirects to the categories index' do - post :create, params: { :public_body_category => @params } + post :create, params: { public_body_category: @params } expect(response).to redirect_to(admin_categories_path) end @@ -152,27 +152,27 @@ before(:each) do PublicBodyCategory.destroy_all - @params = { :category_tag => 'new_test_category', - :translations_attributes => { - 'en' => { :locale => 'en', - :title => 'New Category', - :description => 'New category for testing stuff' }, - 'es' => { :locale => 'es', - :title => 'Mi Nuevo Category', - :description => 'ES Description' } + @params = { category_tag: 'new_test_category', + translations_attributes: { + 'en' => { locale: 'en', + title: 'New Category', + description: 'New category for testing stuff' }, + 'es' => { locale: 'es', + title: 'Mi Nuevo Category', + description: 'ES Description' } } } end it 'saves the category' do expect { - post :create, params: { :public_body_category => @params } + post :create, params: { public_body_category: @params } }.to change { PublicBodyCategory.count }.from(0).to(1) end it 'saves the default locale translation' do - post :create, params: { :public_body_category => @params } + post :create, params: { public_body_category: @params } - category = PublicBodyCategory.where(:title => 'New Category').first + category = PublicBodyCategory.where(title: 'New Category').first AlaveteliLocalization.with_locale(:en) do expect(category.title).to eq('New Category') @@ -180,9 +180,9 @@ end it 'saves the alternative locale translation' do - post :create, params: { :public_body_category => @params } + post :create, params: { public_body_category: @params } - category = PublicBodyCategory.where(:title => 'New Category').first + category = PublicBodyCategory.where(title: 'New Category').first AlaveteliLocalization.with_locale(:es) do expect(category.title).to eq('Mi Nuevo Category') @@ -194,14 +194,14 @@ context 'on failure' do it 'renders the form if creating the record was unsuccessful' do - post :create, params: { :public_body_category => { :title => '' } } + post :create, params: { public_body_category: { title: '' } } expect(response).to render_template('new') end it 'is rebuilt with the given params' do post :create, params: { - :public_body_category => { - :title => 'Need a description' + public_body_category: { + title: 'Need a description' } } expect(assigns(:public_body_category).title).to eq('Need a description') @@ -212,24 +212,24 @@ context 'on failure for multiple locales' do before(:each) do - @params = { :category_tag => 'new_test_category', - :translations_attributes => { - 'en' => { :locale => 'en', - :title => 'Need a description', - :description => nil }, - 'es' => { :locale => 'es', - :title => 'Mi Nuevo Category', - :description => 'ES Description' } + @params = { category_tag: 'new_test_category', + translations_attributes: { + 'en' => { locale: 'en', + title: 'Need a description', + description: nil }, + 'es' => { locale: 'es', + title: 'Mi Nuevo Category', + description: 'ES Description' } } } end it 'is rebuilt with the default locale translation' do - post :create, params: { :public_body_category => @params } + post :create, params: { public_body_category: @params } expect(assigns(:public_body_category).title).to eq('Need a description') end it 'is rebuilt with the alternative locale translation' do - post :create, params: { :public_body_category => @params } + post :create, params: { public_body_category: @params } AlaveteliLocalization.with_locale(:es) do expect(assigns(:public_body_category).title).to eq('Mi Nuevo Category') @@ -252,17 +252,17 @@ end it 'responds successfully' do - get :edit, params: { :id => @category.id } + get :edit, params: { id: @category.id } expect(response).to be_successful end it 'finds the requested category' do - get :edit, params: { :id => @category.id } + get :edit, params: { id: @category.id } expect(assigns[:public_body_category]).to eq(@category) end it 'builds new translations if the body does not already have a translation in the specified locale' do - get :edit, params: { :id => @category.id } + get :edit, params: { id: @category.id } expect(assigns[:public_body_category].translations.map(&:locale)).to include(:fr) end @@ -270,19 +270,19 @@ # FIXME: I wanted to call PublicBody.destroy_all here so that we # have a known DB state, but the constraints were preventing the # deletion of the fixture data - FactoryBot.create(:public_body, :tag_string => 'wont_be_found') + FactoryBot.create(:public_body, tag_string: 'wont_be_found') - category = FactoryBot.create(:public_body_category, :category_tag => 'spec') - expected_bodies = [FactoryBot.create(:public_body, :tag_string => 'spec'), - FactoryBot.create(:public_body, :tag_string => 'spec')] + category = FactoryBot.create(:public_body_category, category_tag: 'spec') + expected_bodies = [FactoryBot.create(:public_body, tag_string: 'spec'), + FactoryBot.create(:public_body, tag_string: 'spec')] - get :edit, params: { :id => category.id } + get :edit, params: { id: category.id } expect(assigns(:tagged_public_bodies).sort).to eq(expected_bodies.sort) end it 'renders the edit template' do - get :edit, params: { :id => @category.id } + get :edit, params: { id: @category.id } expect(response).to render_template('edit') end @@ -294,9 +294,9 @@ @heading = FactoryBot.create(:public_body_heading) @category = FactoryBot.create(:public_body_category) link = FactoryBot.create(:public_body_category_link, - :public_body_category => @category, - :public_body_heading => @heading, - :category_display_order => 0) + public_body_category: @category, + public_body_heading: @heading, + category_display_order: 0) @tag = @category.category_tag AlaveteliLocalization.with_locale('es') do @category.title = 'Los category' @@ -304,23 +304,23 @@ @category.save! end - @params = { :category_tag => @category.category_tag, - :translations_attributes => { - 'en' => { :id => @category.translation_for(:en).id, - :locale => 'en', - :title => @category.title(:en), - :description => @category.description(:en) }, - 'es' => { :id => @category.translation_for(:es).id, - :locale => 'es', - :title => @category.title(:es), - :description => @category.description(:es) } + @params = { category_tag: @category.category_tag, + translations_attributes: { + 'en' => { id: @category.translation_for(:en).id, + locale: 'en', + title: @category.title(:en), + description: @category.description(:en) }, + 'es' => { id: @category.translation_for(:es).id, + locale: 'es', + title: @category.title(:es), + description: @category.description(:es) } } } end it 'finds the category to update' do post :update, params: { - :id => @category.id, - :public_body_category => @params + id: @category.id, + public_body_category: @params } expect(assigns(:public_body_category)).to eq(@category) end @@ -329,16 +329,15 @@ # FIXME: I wanted to call PublicBody.destroy_all here so that we # have a known DB state, but the constraints were preventing the # deletion of the fixture data - FactoryBot.create(:public_body, :tag_string => 'wont_be_found') + FactoryBot.create(:public_body, tag_string: 'wont_be_found') - category = FactoryBot.create(:public_body_category, :category_tag => 'spec') - expected_bodies = [FactoryBot.create(:public_body, :tag_string => 'spec'), - FactoryBot.create(:public_body, :tag_string => 'spec')] + category = FactoryBot.create(:public_body_category, category_tag: 'spec') + expected_bodies = [FactoryBot.create(:public_body, tag_string: 'spec'), + FactoryBot.create(:public_body, tag_string: 'spec')] post :update, params: { - :id => category.id, - :public_body_category => - category.serializable_hash.except(:title, :description) + id: category.id, + public_body_category: category.serializable_hash.except(:title, :description) } expect(assigns(:tagged_public_bodies)).to match_array(expected_bodies) @@ -350,16 +349,16 @@ heading = FactoryBot.create(:public_body_heading) post :update, params: { - :id => @category.id, - :public_body_category => { - :translations_attributes => { + id: @category.id, + public_body_category: { + translations_attributes: { 'en' => { - :id => @category.translation_for(:en).id, - :title => 'Renamed' + id: @category.translation_for(:en).id, + title: 'Renamed' } } }, - :headings => { "heading_#{ heading.id }" => heading.id } + headings: { "heading_#{ heading.id }" => heading.id } } category = PublicBodyCategory.find(@category.id) @@ -369,11 +368,11 @@ context 'when the category has associated bodies' do it 'does not save edits to category_tag' do - body = FactoryBot.create(:public_body, :tag_string => @tag) + body = FactoryBot.create(:public_body, tag_string: @tag) post :update, params: { - :id => @category.id, - :public_body_category => { :category_tag => 'Renamed' } + id: @category.id, + public_body_category: { category_tag: 'Renamed' } } category = PublicBodyCategory.find(@category.id) @@ -381,24 +380,24 @@ end it 'notifies the user that the category_tag could not be updated' do - body = FactoryBot.create(:public_body, :tag_string => @tag) + body = FactoryBot.create(:public_body, tag_string: @tag) msg = %Q(There are authorities associated with this category, so the tag can't be renamed).squish post :update, params: { - :id => @category.id, - :public_body_category => { :category_tag => 'Renamed' } + id: @category.id, + public_body_category: { category_tag: 'Renamed' } } expect(flash[:error]).to eq(msg) end it 'renders the edit action' do - body = FactoryBot.create(:public_body, :tag_string => @tag) + body = FactoryBot.create(:public_body, tag_string: @tag) post :update, params: { - :id => @category.id, - :public_body_category => { :category_tag => 'Renamed' } + id: @category.id, + public_body_category: { category_tag: 'Renamed' } } expect(response).to render_template('edit') @@ -409,12 +408,12 @@ context 'on success' do before(:each) do - @params = { :id => @category.id, - :public_body_category => { - :translations_attributes => { + @params = { id: @category.id, + public_body_category: { + translations_attributes: { 'en' => { - :id => @category.translation_for(:en).id, - :title => 'Renamed' + id: @category.translation_for(:en).id, + title: 'Renamed' } } } @@ -438,11 +437,11 @@ end it 'saves edits to category_tag if the category has no associated bodies' do - category = FactoryBot.create(:public_body_category, :category_tag => 'empty') + category = FactoryBot.create(:public_body_category, category_tag: 'empty') post :update, params: { - :id => category.id, - :public_body_category => { :category_tag => 'Renamed' } + id: category.id, + public_body_category: { category_tag: 'Renamed' } } category = PublicBodyCategory.find(category.id) @@ -453,8 +452,8 @@ AlaveteliLocalization.set_locales('es en_GB', 'en_GB') post :update, params: { - :id => @category.id, - :public_body_category => { :name => 'Category en_GB' } + id: @category.id, + public_body_category: { name: 'Category en_GB' } } expect( @@ -469,20 +468,20 @@ it "saves edits to a public body category in another locale" do expect(@category.title(:es)).to eq('Los category') post :update, params: { - :id => @category.id, - :public_body_category => { - :translations_attributes => { + id: @category.id, + public_body_category: { + translations_attributes: { 'en' => { - :id => @category.translation_for(:en).id, - :locale => 'en', - :title => @category.title(:en), - :description => @category.description(:en) + id: @category.translation_for(:en).id, + locale: 'en', + title: @category.title(:en), + description: @category.description(:en) }, 'es' => { - :id => @category.translation_for(:es).id, - :locale => 'es', - :title => 'Renamed', - :description => 'ES Description' + id: @category.translation_for(:es).id, + locale: 'es', + title: 'Renamed', + description: 'ES Description' } } } @@ -498,19 +497,19 @@ @category.reload put :update, params: { - :id => @category.id, - :public_body_category => { - :translations_attributes => { + id: @category.id, + public_body_category: { + translations_attributes: { 'en' => { - :id => @category.translation_for(:en).id, - :locale => 'en', - :title => @category.title(:en), - :description => @category.description(:en) + id: @category.translation_for(:en).id, + locale: 'en', + title: @category.title(:en), + description: @category.description(:en) }, 'es' => { - :locale => "es", - :title => "Example Public Body Category ES", - :description => @category.description(:es) + locale: "es", + title: "Example Public Body Category ES", + description: @category.description(:es) } } } @@ -530,24 +529,24 @@ @category.reload post :update, params: { - :id => @category.id, - :public_body_category => { - :translations_attributes => { + id: @category.id, + public_body_category: { + translations_attributes: { 'en' => { - :id => @category.translation_for(:en).id, - :locale => 'en', - :title => @category.title(:en), - :description => @category.description(:en) + id: @category.translation_for(:en).id, + locale: 'en', + title: @category.title(:en), + description: @category.description(:en) }, 'es' => { - :locale => "es", - :title => "Example Public Body Category ES", - :description => 'ES Description' + locale: "es", + title: "Example Public Body Category ES", + description: 'ES Description' }, 'fr' => { - :locale => "fr", - :title => "Example Public Body Category FR", - :description => 'FR Description' + locale: "fr", + title: "Example Public Body Category FR", + description: 'FR Description' } } } @@ -567,22 +566,22 @@ it 'updates an existing translation and adds a third translation' do post :update, params: { - :id => @category.id, - :public_body_category => { - :translations_attributes => { - 'en' => { :id => @category.translation_for(:en).id, - :locale => 'en', - :title => @category.title(:en), - :description => @category.description(:en) }, + id: @category.id, + public_body_category: { + translations_attributes: { + 'en' => { id: @category.translation_for(:en).id, + locale: 'en', + title: @category.title(:en), + description: @category.description(:en) }, # Update existing translation - 'es' => { :id => @category.translation_for(:es).id, - :locale => "es", - :title => "Renamed Example Public Body Category ES", - :description => @category.description }, + 'es' => { id: @category.translation_for(:es).id, + locale: "es", + title: "Renamed Example Public Body Category ES", + description: @category.description }, # Add new translation - 'fr' => { :locale => "fr", - :title => "Example Public Body Category FR", - :description => @category.description } + 'fr' => { locale: "fr", + title: "Example Public Body Category FR", + description: @category.description } } } } @@ -601,14 +600,14 @@ it "redirects to the edit page after a successful update" do post :update, params: { - :id => @category.id, - :public_body_category => { - :translations_attributes => { + id: @category.id, + public_body_category: { + translations_attributes: { 'en' => { - :id => @category.translation_for(:en).id, - :locale => 'en', - :title => @category.title(:en), - :description => @category.description(:en) + id: @category.translation_for(:en).id, + locale: 'en', + title: @category.title(:en), + description: @category.description(:en) } } } @@ -623,14 +622,14 @@ it 'renders the form if creating the record was unsuccessful' do post :update, params: { - :id => @category.id, - :public_body_category => { - :translations_attributes => { + id: @category.id, + public_body_category: { + translations_attributes: { 'en' => { - :id => @category.translation_for(:en).id, - :locale => 'en', - :title => '', - :description => @category.description(:en) + id: @category.translation_for(:en).id, + locale: 'en', + title: '', + description: @category.description(:en) } } } @@ -640,14 +639,14 @@ it 'is rebuilt with the given params' do post :update, params: { - :id => @category.id, - :public_body_category => { - :translations_attributes => { + id: @category.id, + public_body_category: { + translations_attributes: { 'en' => { - :id => @category.translation_for(:en).id, - :locale => 'en', - :title => 'Need a description', - :description => '' + id: @category.translation_for(:en).id, + locale: 'en', + title: 'Need a description', + description: '' } } } @@ -660,31 +659,31 @@ context 'on failure for multiple locales' do before(:each) do - @params = { :category_tag => 'new_test_category', - :translations_attributes => { - 'en' => { :id => @category.translation_for(:en).id, - :locale => 'en', - :title => 'Need a description', - :description => '' }, - 'es' => { :id => @category.translation_for(:es).id, - :locale => 'es', - :title => 'Mi Nuevo Category', - :description => 'ES Description' } + @params = { category_tag: 'new_test_category', + translations_attributes: { + 'en' => { id: @category.translation_for(:en).id, + locale: 'en', + title: 'Need a description', + description: '' }, + 'es' => { id: @category.translation_for(:es).id, + locale: 'es', + title: 'Mi Nuevo Category', + description: 'ES Description' } } } end it 'is rebuilt with the default locale translation' do post :update, params: { - :id => @category.id, - :public_body_category => @params + id: @category.id, + public_body_category: @params } expect(assigns(:public_body_category).title(:en)).to eq('Need a description') end it 'is rebuilt with the alternative locale translation' do post :update, params: { - :id => @category.id, - :public_body_category => @params + id: @category.id, + public_body_category: @params } AlaveteliLocalization.with_locale(:es) do @@ -704,7 +703,7 @@ category = FactoryBot.create(:public_body_category) expect { - post :destroy, params: { :id => category.id } + post :destroy, params: { id: category.id } }.to change { PublicBodyCategory.count }.from(1).to(0) end @@ -712,23 +711,23 @@ PublicBodyCategory.destroy_all tag = 'empty' - authority = FactoryBot.create(:public_body, :tag_string => tag) - category = FactoryBot.create(:public_body_category, :category_tag => tag) + authority = FactoryBot.create(:public_body, tag_string: tag) + category = FactoryBot.create(:public_body_category, category_tag: tag) expect { - post :destroy, params: { :id => category.id } + post :destroy, params: { id: category.id } }.to change { PublicBodyCategory.count }.from(1).to(0) end it 'notifies the admin that the category was destroyed' do category = FactoryBot.create(:public_body_category) - post :destroy, params: { :id => category.id } + post :destroy, params: { id: category.id } expect(flash[:notice]).to eq('Category was successfully destroyed.') end it 'redirects to the categories index' do category = FactoryBot.create(:public_body_category) - post :destroy, params: { :id => category.id } + post :destroy, params: { id: category.id } expect(response).to redirect_to(admin_categories_path) end diff --git a/spec/controllers/admin_public_body_controller_spec.rb b/spec/controllers/admin_public_body_controller_spec.rb index 2f05087ff9..485f27f6fc 100644 --- a/spec/controllers/admin_public_body_controller_spec.rb +++ b/spec/controllers/admin_public_body_controller_spec.rb @@ -10,12 +10,12 @@ end it "searches for 'humpa'" do - get :index, params: { :query => "humpa" } + get :index, params: { query: "humpa" } expect(assigns[:public_bodies]).to eq([ public_bodies(:humpadink_public_body) ]) end it "searches for 'humpa' in another locale" do - get :index, params: { :query => "humpa", :locale => "es" } + get :index, params: { query: "humpa", locale: "es" } expect(assigns[:public_bodies]).to eq([ public_bodies(:humpadink_public_body) ]) end @@ -24,19 +24,19 @@ describe 'GET #show' do let(:public_body) { FactoryBot.create(:public_body) } let(:info_request) { FactoryBot.create(:info_request, - :public_body => public_body) } + public_body: public_body) } let(:admin_user) { FactoryBot.create(:admin_user) } let(:pro_admin_user) { FactoryBot.create(:pro_admin_user) } it "returns successfully" do sign_in admin_user - get :show, params: { :id => public_body.id } + get :show, params: { id: public_body.id } expect(response).to be_successful end it "sets a using_admin flag" do sign_in admin_user - get :show, params: { :id => public_body.id} + get :show, params: { id: public_body.id} expect(session[:using_admin]).to eq(1) end @@ -46,7 +46,7 @@ public_body.save! end sign_in admin_user - get :show, params: { :id => public_body.id, :locale => "es" } + get :show, params: { id: public_body.id, locale: "es" } expect(assigns[:public_body].name).to eq 'El Public Body' end @@ -54,7 +54,7 @@ not a pro admin user' do info_request.create_embargo sign_in admin_user - get :show, params: { :id => public_body.id } + get :show, params: { id: public_body.id } expect(assigns[:info_requests].include?(info_request)).to be false end @@ -65,7 +65,7 @@ with_feature_enabled(:alaveteli_pro) do info_request.create_embargo sign_in admin_user - get :show, params: { :id => public_body.id } + get :show, params: { id: public_body.id } expect(assigns[:info_requests].include?(info_request)).to be false end end @@ -76,7 +76,7 @@ with_feature_enabled(:alaveteli_pro) do info_request.create_embargo sign_in pro_admin_user - get :show, params: { :id => public_body.id } + get :show, params: { id: public_body.id } expect(assigns[:info_requests].include?(info_request)).to be true end end @@ -116,7 +116,7 @@ it 'should populate the name, email address and last edit comment on the public body' do change_request = FactoryBot.create(:add_body_request) - get :new, params: { :change_request_id => change_request.id } + get :new, params: { change_request_id: change_request.id } expect(assigns[:public_body].name).to eq(change_request.public_body_name) expect(assigns[:public_body].request_email).to eq(change_request.public_body_email) expect(assigns[:public_body].last_edit_comment).to match('Notes: Please') @@ -124,7 +124,7 @@ it 'should assign a default response text to the view' do change_request = FactoryBot.create(:add_body_request) - get :new, params: { :change_request_id => change_request.id } + get :new, params: { change_request_id: change_request.id } expect(assigns[:change_request_user_response]).to match("Thanks for your suggestion to add A New Body") end @@ -137,11 +137,11 @@ context 'on success' do before(:each) do - @params = { :public_body => { :name => 'New Quango', - :short_name => 'nq', - :request_email => 'newquango@localhost', - :tag_string => 'spec', - :last_edit_comment => 'From test code' } } + @params = { public_body: { name: 'New Quango', + short_name: 'nq', + request_email: 'newquango@localhost', + tag_string: 'spec', + last_edit_comment: 'From test code' } } end it 'creates a new body in the default locale' do @@ -177,15 +177,15 @@ context 'on success for multiple locales' do before(:each) do - @params = { :public_body => { :name => 'New Quango', - :short_name => 'nq', - :request_email => 'newquango@localhost', - :tag_string => 'spec', - :last_edit_comment => 'From test code', - :translations_attributes => { - 'es' => { :locale => 'es', - :name => 'Los Quango', - :short_name => 'lq' } + @params = { public_body: { name: 'New Quango', + short_name: 'nq', + request_email: 'newquango@localhost', + tag_string: 'spec', + last_edit_comment: 'From test code', + translations_attributes: { + 'es' => { locale: 'es', + name: 'Los Quango', + short_name: 'lq' } } } } end @@ -227,9 +227,9 @@ it 'renders the form if creating the record was unsuccessful' do post :create, params: { - :public_body => { - :name => '', - :translations_attributes => {} + public_body: { + name: '', + translations_attributes: {} } } expect(response).to render_template('new') @@ -237,10 +237,10 @@ it 'is rebuilt with the given params' do post :create, params: { - :public_body => { - :name => '', - :request_email => 'newquango@localhost', - :translations_attributes => {} + public_body: { + name: '', + request_email: 'newquango@localhost', + translations_attributes: {} } } expect(assigns(:public_body).request_email).to eq('newquango@localhost') @@ -251,11 +251,11 @@ context 'on failure for multiple locales' do before(:each) do - @params = { :public_body => { :name => '', - :request_email => 'newquango@localhost', - :translations_attributes => { - 'es' => { :locale => 'es', - :name => 'Los Quango' } + @params = { public_body: { name: '', + request_email: 'newquango@localhost', + translations_attributes: { + 'es' => { locale: 'es', + name: 'Los Quango' } } } } end @@ -282,17 +282,16 @@ @change_request = FactoryBot.create(:add_body_request) post :create, params: { - :public_body => { - :name => "New Quango", - :short_name => "", - :tag_string => "blah", - :request_email => 'newquango@localhost', - :last_edit_comment => 'From test code' + public_body: { + name: "New Quango", + short_name: "", + tag_string: "blah", + request_email: 'newquango@localhost', + last_edit_comment: 'From test code' }, - :change_request_id => @change_request.id, - :subject => 'Adding a new body', - :response => - 'The URL will be [Authority URL will be inserted here]' + change_request_id: @change_request.id, + subject: 'Adding a new body', + response: 'The URL will be [Authority URL will be inserted here]' } end @@ -324,27 +323,27 @@ end it 'responds successfully' do - get :edit, params: { :id => @body.id } + get :edit, params: { id: @body.id } expect(response).to be_successful end it 'finds the requested body' do - get :edit, params: { :id => @body.id } + get :edit, params: { id: @body.id } expect(assigns[:public_body]).to eq(@body) end it 'builds new translations if the body does not already have a translation in the specified locale' do - get :edit, params: { :id => @body.id } + get :edit, params: { id: @body.id } expect(assigns[:public_body].translations.map(&:locale)).to include(:fr) end it 'renders the edit template' do - get :edit, params: { :id => @body.id } + get :edit, params: { id: @body.id } expect(response).to render_template('edit') end it "edits a public body in another locale" do - get :edit, params: { :id => 3, :locale => :en } + get :edit, params: { id: 3, locale: :en } # When editing a body, the controller returns all available translations expect(assigns[:public_body].find_translation_by_locale("es").name).to eq('El Department for Humpadinking') @@ -358,16 +357,16 @@ before do @change_request = FactoryBot.create(:update_body_request) get :edit, params: { - :id => @change_request.public_body_id, - :change_request_id => @change_request.id + id: @change_request.public_body_id, + change_request_id: @change_request.id } end it 'should populate the email address and last edit comment on the public body' do change_request = FactoryBot.create(:update_body_request) get :edit, params: { - :id => change_request.public_body_id, - :change_request_id => change_request.id + id: change_request.public_body_id, + change_request_id: change_request.id } expect(assigns[:public_body].request_email).to eq(@change_request.public_body_email) expect(assigns[:public_body].last_edit_comment).to match('Notes: Please') @@ -389,16 +388,16 @@ @body.save! end - @params = { :id => @body.id, - :public_body => { :name => 'Renamed', - :short_name => @body.short_name, - :request_email => @body.request_email, - :tag_string => @body.tag_string, - :last_edit_comment => 'From test code', - :translations_attributes => { - 'es' => { :id => @body.translation_for(:es).id, - :locale => 'es', - :title => @body.name(:es) } + @params = { id: @body.id, + public_body: { name: 'Renamed', + short_name: @body.short_name, + request_email: @body.request_email, + tag_string: @body.tag_string, + last_edit_comment: 'From test code', + translations_attributes: { + 'es' => { id: @body.translation_for(:es).id, + locale: 'es', + title: @body.name(:es) } } } } end @@ -432,14 +431,14 @@ it 'saves edits to a public body heading in another locale' do expect(@body.name(:es)).to eq('Los Quango') post :update, params: { - :id => @body.id, - :public_body => { - :name => @body.name(:en), - :translations_attributes => { + id: @body.id, + public_body: { + name: @body.name(:en), + translations_attributes: { 'es' => { - :id => @body.translation_for(:es).id, - :locale => 'es', - :name => 'Renamed' + id: @body.translation_for(:es).id, + locale: 'es', + name: 'Renamed' } } } @@ -455,13 +454,13 @@ @body.reload put :update, params: { - :id => @body.id, - :public_body => { - :name => @body.name(:en), - :translations_attributes => { + id: @body.id, + public_body: { + name: @body.name(:en), + translations_attributes: { 'es' => { - :locale => "es", - :name => "Example Public Body ES" + locale: "es", + name: "Example Public Body ES" } } } @@ -479,9 +478,9 @@ it 'creates a new translation for the default locale' do AlaveteliLocalization.set_locales('es en_GB', 'en_GB') put :update, params: { - :id => @body.id, - :public_body => { - :name => "Example Public Body en_GB" + id: @body.id, + public_body: { + name: "Example Public Body en_GB" } } @@ -494,17 +493,17 @@ @body.reload post :update, params: { - :id => @body.id, - :public_body => { - :name => @body.name(:en), - :translations_attributes => { + id: @body.id, + public_body: { + name: @body.name(:en), + translations_attributes: { 'es' => { - :locale => "es", - :name => "Example Public Body ES" + locale: "es", + name: "Example Public Body ES" }, 'fr' => { - :locale => "fr", - :name => "Example Public Body FR" + locale: "fr", + name: "Example Public Body FR" } } } @@ -524,17 +523,17 @@ it 'updates an existing translation and adds a third translation' do post :update, params: { - :id => @body.id, - :public_body => { - :name => @body.name(:en), - :translations_attributes => { + id: @body.id, + public_body: { + name: @body.name(:en), + translations_attributes: { # Update existing translation - 'es' => { :id => @body.translation_for(:es).id, - :locale => "es", - :name => "Renamed Example Public Body ES" }, + 'es' => { id: @body.translation_for(:es).id, + locale: "es", + name: "Renamed Example Public Body ES" }, # Add new translation - 'fr' => { :locale => "fr", - :name => "Example Public Body FR" } + 'fr' => { locale: "fr", + name: "Example Public Body FR" } } } } @@ -557,10 +556,10 @@ it 'renders the form if creating the record was unsuccessful' do post :update, params: { - :id => @body.id, - :public_body => { - :name => '', - :translations_attributes => {} + id: @body.id, + public_body: { + name: '', + translations_attributes: {} } } expect(response).to render_template('edit') @@ -568,11 +567,11 @@ it 'is rebuilt with the given params' do post :update, params: { - :id => @body.id, - :public_body => { - :name => '', - :request_email => 'updated@localhost', - :translations_attributes => {} + id: @body.id, + public_body: { + name: '', + request_email: 'updated@localhost', + translations_attributes: {} } } expect(assigns(:public_body).request_email).to eq('updated@localhost') @@ -583,12 +582,12 @@ context 'on failure for multiple locales' do before(:each) do - @params = { :id => @body.id, - :public_body => { :name => '', - :translations_attributes => { - 'es' => { :id => @body.translation_for(:es).id, - :locale => 'es', - :name => 'Mi Nuevo Body' } + @params = { id: @body.id, + public_body: { name: '', + translations_attributes: { + 'es' => { id: @body.translation_for(:es).id, + locale: 'es', + name: 'Mi Nuevo Body' } } } } end @@ -612,16 +611,16 @@ before do @change_request = FactoryBot.create(:update_body_request) post :update, params: { - :id => @change_request.public_body_id, - :public_body => { - :name => "New Quango", - :short_name => "", - :request_email => 'newquango@localhost', - :last_edit_comment => 'From test code' + id: @change_request.public_body_id, + public_body: { + name: "New Quango", + short_name: "", + request_email: 'newquango@localhost', + last_edit_comment: 'From test code' }, - :change_request_id => @change_request.id, - :subject => 'Body update', - :response => 'Done.' + change_request_id: @change_request.id, + subject: 'Body update', + response: 'Done.' } end @@ -646,14 +645,14 @@ it "does not destroy a public body that has associated requests" do id = public_bodies(:humpadink_public_body).id n = PublicBody.count - post :destroy, params: { :id => id } - expect(response).to redirect_to(:controller=>'admin_public_body', :action=>'show', :id => id) + post :destroy, params: { id: id } + expect(response).to redirect_to(controller: 'admin_public_body', action: 'show', id: id) expect(PublicBody.count).to eq(n) end it "destroys a public body" do n = PublicBody.count - post :destroy, params: { :id => public_bodies(:forlorn_public_body).id } + post :destroy, params: { id: public_bodies(:forlorn_public_body).id } expect(response).to redirect_to admin_bodies_path expect(PublicBody.count).to eq(n - 1) end @@ -706,7 +705,7 @@ end it 'should handle a nil csv file param' do - post :import_csv, params: { :commit => 'Dry run' } + post :import_csv, params: { commit: 'Dry run' } expect(response).to be_successful end @@ -714,8 +713,8 @@ it 'should assign the original filename to the view' do post :import_csv, params: { - :csv_file => @file_object, - :commit => 'Dry run' + csv_file: @file_object, + commit: 'Dry run' } expect(assigns[:original_csv_file]).to eq('fake-authority-type.csv') end @@ -728,16 +727,16 @@ expect(@controller).to receive(:retrieve_csv_data).with('csv_upload-2046-12-31-394') post :import_csv, params: { - :temporary_csv_file => 'csv_upload-2046-12-31-394', - :original_csv_file => 'original_contents.txt', - :commit => 'Dry run' + temporary_csv_file: 'csv_upload-2046-12-31-394', + original_csv_file: 'original_contents.txt', + commit: 'Dry run' } end it 'should raise an error on an invalid temp file name' do - params = { :temporary_csv_file => 'bad_name', - :original_csv_file => 'original_contents.txt', - :commit => 'Dry run'} + params = { temporary_csv_file: 'bad_name', + original_csv_file: 'original_contents.txt', + commit: 'Dry run'} expected_error = "Invalid filename in upload_csv: bad_name" expect { post :import_csv, params: params @@ -746,9 +745,9 @@ it 'should raise an error if the temp file does not exist' do temp_name = "csv_upload-20461231-394" - params = { :temporary_csv_file => temp_name, - :original_csv_file => 'original_contents.txt', - :commit => 'Dry run'} + params = { temporary_csv_file: temp_name, + original_csv_file: 'original_contents.txt', + commit: 'Dry run'} expected_error = "Missing file in upload_csv: csv_upload-20461231-394" expect { post :import_csv, params: params @@ -757,8 +756,8 @@ it 'should assign the temporary filename to the view' do post :import_csv, params: { - :csv_file => @file_object, - :commit => 'Dry run' + csv_file: @file_object, + commit: 'Dry run' } temporary_filename = assigns[:temporary_csv_file] expect(temporary_filename).to match(/csv_upload-#{Time.zone.now.strftime("%Y%m%d")}-\d{1,5}/) @@ -792,9 +791,9 @@ def setup_emergency_credentials(username, password) it "disallows non-authenticated users to do anything" do @request.env["HTTP_AUTHORIZATION"] = "" n = PublicBody.count - post :destroy, params: { :id => 3 } + post :destroy, params: { id: 3 } expect(response). - to redirect_to(signin_path(:token => get_last_post_redirect.token)) + to redirect_to(signin_path(token: get_last_post_redirect.token)) expect(PublicBody.count).to eq(n) expect(session[:using_admin]).to eq(nil) end @@ -804,7 +803,7 @@ def setup_emergency_credentials(username, password) config['SKIP_ADMIN_AUTH'] = true @request.env["HTTP_AUTHORIZATION"] = "" n = PublicBody.count - post :destroy, params: { :id => public_bodies(:forlorn_public_body).id } + post :destroy, params: { id: public_bodies(:forlorn_public_body).id } expect(PublicBody.count).to eq(n - 1) expect(session[:using_admin]).to eq(1) end @@ -813,9 +812,9 @@ def setup_emergency_credentials(username, password) setup_emergency_credentials('biz', 'fuz') n = PublicBody.count basic_auth_login(@request, "baduser", "badpassword") - post :destroy, params: { :id => public_bodies(:forlorn_public_body).id } + post :destroy, params: { id: public_bodies(:forlorn_public_body).id } expect(response). - to redirect_to(signin_path(:token => get_last_post_redirect.token)) + to redirect_to(signin_path(token: get_last_post_redirect.token)) expect(PublicBody.count).to eq(n) expect(session[:using_admin]).to eq(nil) end @@ -825,12 +824,12 @@ def setup_emergency_credentials(username, password) n = PublicBody.count basic_auth_login(@request, "biz", "fuz") post :show, params: { - :id => public_bodies(:humpadink_public_body).id, - :emergency => 1 + id: public_bodies(:humpadink_public_body).id, + emergency: 1 } expect(session[:using_admin]).to eq(1) n = PublicBody.count - post :destroy, params: {:id => public_bodies(:forlorn_public_body).id } + post :destroy, params: {id: public_bodies(:forlorn_public_body).id } expect(session[:using_admin]).to eq(1) expect(PublicBody.count).to eq(n - 1) end @@ -840,11 +839,11 @@ def setup_emergency_credentials(username, password) allow(AlaveteliConfiguration).to receive(:disable_emergency_user).and_return(true) n = PublicBody.count basic_auth_login(@request, "biz", "fuz") - post :show, params: { :id => public_bodies(:humpadink_public_body).id, - :emergency => 1 } + post :show, params: { id: public_bodies(:humpadink_public_body).id, + emergency: 1 } expect(session[:using_admin]).to eq(nil) n = PublicBody.count - post :destroy, params: { :id => public_bodies(:forlorn_public_body).id } + post :destroy, params: { id: public_bodies(:forlorn_public_body).id } expect(session[:using_admin]).to eq(nil) expect(PublicBody.count).to eq(n) end @@ -853,7 +852,7 @@ def setup_emergency_credentials(username, password) sign_in users(:admin_user) @request.env["HTTP_AUTHORIZATION"] = "" n = PublicBody.count - post :destroy, params: { :id => public_bodies(:forlorn_public_body).id } + post :destroy, params: { id: public_bodies(:forlorn_public_body).id } expect(PublicBody.count).to eq(n - 1) expect(session[:using_admin]).to eq(1) end @@ -862,9 +861,9 @@ def setup_emergency_credentials(username, password) sign_in users(:robin_user) @request.env["HTTP_AUTHORIZATION"] = "" n = PublicBody.count - post :destroy, params: { :id => public_bodies(:forlorn_public_body).id } + post :destroy, params: { id: public_bodies(:forlorn_public_body).id } expect(response). - to redirect_to(signin_path(:token => get_last_post_redirect.token)) + to redirect_to(signin_path(token: get_last_post_redirect.token)) expect(PublicBody.count).to eq(n) expect(session[:using_admin]).to eq(nil) end @@ -874,15 +873,15 @@ def setup_emergency_credentials(username, password) it 'returns the emergency account name for someone who logged in with the emergency account' do setup_emergency_credentials('biz', 'fuz') basic_auth_login(@request, "biz", "fuz") - post :show, params: { :id => public_bodies(:humpadink_public_body).id, - :emergency => 1 } + post :show, params: { id: public_bodies(:humpadink_public_body).id, + emergency: 1 } expect(controller.send(:admin_current_user)).to eq('biz') end it 'returns the current user url_name for a superuser' do sign_in users(:admin_user) @request.env["HTTP_AUTHORIZATION"] = "" - post :show, params: { :id => public_bodies(:humpadink_public_body).id } + post :show, params: { id: public_bodies(:humpadink_public_body).id } expect(controller.send(:admin_current_user)).to eq(users(:admin_user).url_name) end @@ -891,7 +890,7 @@ def setup_emergency_credentials(username, password) config['SKIP_ADMIN_AUTH'] = true @request.env["HTTP_AUTHORIZATION"] = "" @request.env["REMOTE_USER"] = "i_am_admin" - post :show, params: { :id => public_bodies(:humpadink_public_body).id } + post :show, params: { id: public_bodies(:humpadink_public_body).id } expect(controller.send(:admin_current_user)).to eq("i_am_admin") end diff --git a/spec/controllers/admin_public_body_headings_controller_spec.rb b/spec/controllers/admin_public_body_headings_controller_spec.rb index bf8cf3621a..613d705ed3 100644 --- a/spec/controllers/admin_public_body_headings_controller_spec.rb +++ b/spec/controllers/admin_public_body_headings_controller_spec.rb @@ -37,27 +37,27 @@ before(:each) do PublicBodyHeading.destroy_all - @params = { :translations_attributes => { - 'en' => { :locale => 'en', - :name => 'New Heading' } + @params = { translations_attributes: { + 'en' => { locale: 'en', + name: 'New Heading' } } } end it 'creates a new heading in the default locale' do expect { - post :create, params: { :public_body_heading => @params } + post :create, params: { public_body_heading: @params } }.to change { PublicBodyHeading.count }.from(0).to(1) end it 'can create a heading when the default locale is an underscore locale' do AlaveteliLocalization.set_locales('es en_GB', 'en_GB') post :create, params: { - :public_body_heading => { :name => 'New Heading en_GB' } + public_body_heading: { name: 'New Heading en_GB' } } expect( PublicBodyHeading. - find_by(:name => 'New Heading en_GB'). + find_by(name: 'New Heading en_GB'). translations. first. locale @@ -65,12 +65,12 @@ end it 'notifies the admin that the heading was created' do - post :create, params: { :public_body_heading => @params } + post :create, params: { public_body_heading: @params } expect(flash[:notice]).to eq('Heading was successfully created.') end it 'redirects to the categories index' do - post :create, params: { :public_body_heading => @params } + post :create, params: { public_body_heading: @params } expect(response).to redirect_to(admin_categories_path) end @@ -80,24 +80,24 @@ before(:each) do PublicBodyHeading.destroy_all - @params = { :translations_attributes => { - 'en' => { :locale => 'en', - :name => 'New Heading' }, - 'es' => { :locale => 'es', - :name => 'Mi Nuevo Heading' } + @params = { translations_attributes: { + 'en' => { locale: 'en', + name: 'New Heading' }, + 'es' => { locale: 'es', + name: 'Mi Nuevo Heading' } } } end it 'saves the heading' do expect { - post :create, params: { :public_body_heading => @params } + post :create, params: { public_body_heading: @params } }.to change { PublicBodyHeading.count }.from(0).to(1) end it 'saves the default locale translation' do - post :create, params: { :public_body_heading => @params } + post :create, params: { public_body_heading: @params } - heading = PublicBodyHeading.where(:name => 'New Heading').first + heading = PublicBodyHeading.where(name: 'New Heading').first AlaveteliLocalization.with_locale(:en) do expect(heading.name).to eq('New Heading') @@ -105,9 +105,9 @@ end it 'saves the alternative locale translation' do - post :create, params: { :public_body_heading => @params } + post :create, params: { public_body_heading: @params } - heading = PublicBodyHeading.where(:name => 'New Heading').first + heading = PublicBodyHeading.where(name: 'New Heading').first AlaveteliLocalization.with_locale(:es) do expect(heading.name).to eq('Mi Nuevo Heading') @@ -119,14 +119,14 @@ context 'on failure' do it 'renders the form if creating the record was unsuccessful' do - post :create, params: { :public_body_heading => { :name => '' } } + post :create, params: { public_body_heading: { name: '' } } expect(response).to render_template('new') end it 'is rebuilt with the given params' do post :create, params: { - :public_body_heading => { :name => 'Need a description' } + public_body_heading: { name: 'Need a description' } } expect(assigns(:public_body_heading).name).to eq('Need a description') end @@ -136,21 +136,21 @@ context 'on failure for multiple locales' do before(:each) do - @params = { :translations_attributes => { - 'en' => { :locale => 'en', - :name => 'Need a description' }, - 'es' => { :locale => 'es', - :name => 'Mi Nuevo Heading' } + @params = { translations_attributes: { + 'en' => { locale: 'en', + name: 'Need a description' }, + 'es' => { locale: 'es', + name: 'Mi Nuevo Heading' } } } end it 'is rebuilt with the default locale translation' do - post :create, params: { :public_body_heading => @params } + post :create, params: { public_body_heading: @params } expect(assigns(:public_body_heading).name).to eq('Need a description') end it 'is rebuilt with the alternative locale translation' do - post :create, params: { :public_body_heading => @params } + post :create, params: { public_body_heading: @params } AlaveteliLocalization.with_locale(:es) do expect(assigns(:public_body_heading).name).to eq('Mi Nuevo Heading') @@ -172,22 +172,22 @@ end it 'responds successfully' do - get :edit, params: { :id => @heading.id } + get :edit, params: { id: @heading.id } expect(response).to be_successful end it 'finds the requested heading' do - get :edit, params: { :id => @heading.id } + get :edit, params: { id: @heading.id } expect(assigns[:public_body_heading]).to eq(@heading) end it 'builds new translations if the body does not already have a translation in the specified locale' do - get :edit, params: { :id => @heading.id } + get :edit, params: { id: @heading.id } expect(assigns[:public_body_heading].translations.map(&:locale)).to include(:fr) end it 'renders the edit template' do - get :edit, params: { :id => @heading.id } + get :edit, params: { id: @heading.id } expect(response).to render_template('edit') end @@ -201,20 +201,20 @@ @heading.name = 'Los heading' @heading.save! end - @params = { :translations_attributes => { - 'en' => { :id => @heading.translation_for(:en).id, - :locale => 'en', - :name => @heading.name(:en) }, - 'es' => { :id => @heading.translation_for(:es).id, - :locale => 'es', - :title => @heading.name(:es) } + @params = { translations_attributes: { + 'en' => { id: @heading.translation_for(:en).id, + locale: 'en', + name: @heading.name(:en) }, + 'es' => { id: @heading.translation_for(:es).id, + locale: 'es', + title: @heading.name(:es) } } } end it 'finds the heading to update' do post :update, params: { - :id => @heading.id, - :public_body_category => @params + id: @heading.id, + public_body_category: @params } expect(assigns(:public_body_heading)).to eq(@heading) end @@ -222,11 +222,11 @@ context 'on success' do before(:each) do - @params = { :id => @heading.id, - :public_body_heading => { - :translations_attributes => { - 'en' => { :id => @heading.translation_for(:en).id, - :name => 'Renamed' } + @params = { id: @heading.id, + public_body_heading: { + translations_attributes: { + 'en' => { id: @heading.translation_for(:en).id, + name: 'Renamed' } } } } @@ -247,9 +247,9 @@ AlaveteliLocalization.set_locales('es en_GB', 'en_GB') post :update, params: { - :id => @heading.id, - :public_body_heading => { - :name => 'Heading en_GB' + id: @heading.id, + public_body_heading: { + name: 'Heading en_GB' } } @@ -269,18 +269,18 @@ it 'saves edits to a public body heading in another locale' do expect(@heading.name(:es)).to eq('Los heading') post :update, params: { - :id => @heading.id, - :public_body_heading => { - :translations_attributes => { + id: @heading.id, + public_body_heading: { + translations_attributes: { 'en' => { - :id => @heading.translation_for(:en).id, - :locale => 'en', - :name => @heading.name(:en) + id: @heading.translation_for(:en).id, + locale: 'en', + name: @heading.name(:en) }, 'es' => { - :id => @heading.translation_for(:es).id, - :locale => 'es', - :name => 'Renamed' + id: @heading.translation_for(:es).id, + locale: 'es', + name: 'Renamed' } } } @@ -296,17 +296,17 @@ @heading.reload put :update, params: { - :id => @heading.id, - :public_body_heading => { - :translations_attributes => { + id: @heading.id, + public_body_heading: { + translations_attributes: { 'en' => { - :id => @heading.translation_for(:en).id, - :locale => 'en', - :name => @heading.name(:en) + id: @heading.translation_for(:en).id, + locale: 'en', + name: @heading.name(:en) }, 'es' => { - :locale => "es", - :name => "Example Public Body Heading ES" + locale: "es", + name: "Example Public Body Heading ES" } } } @@ -326,21 +326,21 @@ @heading.reload post :update, params: { - :id => @heading.id, - :public_body_heading => { - :translations_attributes => { + id: @heading.id, + public_body_heading: { + translations_attributes: { 'en' => { - :id => @heading.translation_for(:en).id, - :locale => 'en', - :name => @heading.name(:en) + id: @heading.translation_for(:en).id, + locale: 'en', + name: @heading.name(:en) }, 'es' => { - :locale => "es", - :name => "Example Public Body Heading ES" + locale: "es", + name: "Example Public Body Heading ES" }, 'fr' => { - :locale => "fr", - :name => "Example Public Body Heading FR" + locale: "fr", + name: "Example Public Body Heading FR" } } } @@ -360,19 +360,19 @@ it 'updates an existing translation and adds a third translation' do post :update, params: { - :id => @heading.id, - :public_body_heading => { - :translations_attributes => { - 'en' => { :id => @heading.translation_for(:en).id, - :locale => 'en', - :name => @heading.name(:en) }, + id: @heading.id, + public_body_heading: { + translations_attributes: { + 'en' => { id: @heading.translation_for(:en).id, + locale: 'en', + name: @heading.name(:en) }, # Update existing translation - 'es' => { :id => @heading.translation_for(:es).id, - :locale => "es", - :name => "Renamed Example Public Body Heading ES" }, + 'es' => { id: @heading.translation_for(:es).id, + locale: "es", + name: "Renamed Example Public Body Heading ES" }, # Add new translation - 'fr' => { :locale => "fr", - :name => "Example Public Body Heading FR" } + 'fr' => { locale: "fr", + name: "Example Public Body Heading FR" } } } } @@ -391,13 +391,13 @@ it "redirects to the edit page after a successful update" do post :update, params: { - :id => @heading.id, - :public_body_heading => { - :translations_attributes => { + id: @heading.id, + public_body_heading: { + translations_attributes: { 'en' => { - :id => @heading.translation_for(:en).id, - :locale => 'en', - :name => @heading.name(:en) + id: @heading.translation_for(:en).id, + locale: 'en', + name: @heading.name(:en) } } } @@ -412,13 +412,13 @@ it 'renders the form if creating the record was unsuccessful' do post :update, params: { - :id => @heading.id, - :public_body_heading => { - :translations_attributes => { + id: @heading.id, + public_body_heading: { + translations_attributes: { 'en' => { - :id => @heading.translation_for(:en).id, - :locale => 'en', - :name => '' + id: @heading.translation_for(:en).id, + locale: 'en', + name: '' } } } @@ -428,13 +428,13 @@ it 'is rebuilt with the given params' do post :update, params: { - :id => @heading.id, - :public_body_heading => { - :translations_attributes => { + id: @heading.id, + public_body_heading: { + translations_attributes: { 'en' => { - :id => @heading.translation_for(:en).id, - :locale => 'en', - :name => 'Need a description' + id: @heading.translation_for(:en).id, + locale: 'en', + name: 'Need a description' } } } @@ -447,28 +447,28 @@ context 'on failure for multiple locales' do before(:each) do - @params = { :translations_attributes => { - 'en' => { :id => @heading.translation_for(:en).id, - :locale => 'en', - :name => '' }, - 'es' => { :id => @heading.translation_for(:es).id, - :locale => 'es', - :name => 'Mi Nuevo Heading' } + @params = { translations_attributes: { + 'en' => { id: @heading.translation_for(:en).id, + locale: 'en', + name: '' }, + 'es' => { id: @heading.translation_for(:es).id, + locale: 'es', + name: 'Mi Nuevo Heading' } } } end it 'is rebuilt with the default locale translation' do post :update, params: { - :id => @heading.id, - :public_body_heading => @params + id: @heading.id, + public_body_heading: @params } expect(assigns(:public_body_heading).name(:en)).to eq('') end it 'is rebuilt with the alternative locale translation' do post :update, params: { - :id => @heading.id, - :public_body_heading => @params + id: @heading.id, + public_body_heading: @params } AlaveteliLocalization.with_locale(:es) do @@ -488,7 +488,7 @@ heading = FactoryBot.create(:public_body_heading) expect { - post :destroy, params: { :id => heading.id } + post :destroy, params: { id: heading.id } }.to change { PublicBodyHeading.count }.from(1).to(0) end @@ -499,24 +499,24 @@ heading = FactoryBot.create(:public_body_heading) category = FactoryBot.create(:public_body_category) link = FactoryBot.create(:public_body_category_link, - :public_body_category => category, - :public_body_heading => heading, - :category_display_order => 0) + public_body_category: category, + public_body_heading: heading, + category_display_order: 0) expect { - post :destroy, params: { :id => heading.id } + post :destroy, params: { id: heading.id } }.to change { PublicBodyHeading.count }.from(1).to(0) end it 'notifies the admin that the heading was destroyed' do heading = FactoryBot.create(:public_body_heading) - post :destroy, params: { :id => heading.id } + post :destroy, params: { id: heading.id } expect(flash[:notice]).to eq('Heading was successfully destroyed.') end it 'redirects to the categories index' do heading = FactoryBot.create(:public_body_heading) - post :destroy, params: { :id => heading.id } + post :destroy, params: { id: heading.id } expect(response).to redirect_to(admin_categories_path) end @@ -527,9 +527,9 @@ render_views before do - @first = FactoryBot.create(:public_body_heading, :display_order => 0) - @second = FactoryBot.create(:public_body_heading, :display_order => 1) - @default_params = { :headings => [@second.id, @first.id] } + @first = FactoryBot.create(:public_body_heading, display_order: 0) + @second = FactoryBot.create(:public_body_heading, display_order: 1) + @default_params = { headings: [@second.id, @first.id] } end def make_request(params=@default_params) @@ -553,7 +553,7 @@ def make_request(params=@default_params) context 'when handling invalid input' do before do - @params = { :headings => [@second.id, @first.id, @second.id + 1]} + @params = { headings: [@second.id, @first.id, @second.id + 1]} end it 'should return an "unprocessable entity" status and an error message' do @@ -579,16 +579,16 @@ def make_request(params=@default_params) @heading = FactoryBot.create(:public_body_heading) @first_category = FactoryBot.create(:public_body_category) @first_link = FactoryBot.create(:public_body_category_link, - :public_body_category => @first_category, - :public_body_heading => @heading, - :category_display_order => 0) + public_body_category: @first_category, + public_body_heading: @heading, + category_display_order: 0) @second_category = FactoryBot.create(:public_body_category) @second_link = FactoryBot.create(:public_body_category_link, - :public_body_category => @second_category, - :public_body_heading => @heading, - :category_display_order => 1) - @default_params = { :categories => [@second_category.id, @first_category.id], - :id => @heading } + public_body_category: @second_category, + public_body_heading: @heading, + category_display_order: 1) + @default_params = { categories: [@second_category.id, @first_category.id], + id: @heading } @old_order = [@first_category, @second_category] @new_order = [@second_category, @first_category] end @@ -617,7 +617,7 @@ def make_request(params=@default_params) before do @new_category = FactoryBot.create(:public_body_category) - @params = @default_params.merge(:categories => [@second_category.id, + @params = @default_params.merge(categories: [@second_category.id, @first_category.id, @new_category.id]) end diff --git a/spec/controllers/admin_raw_email_controller_spec.rb b/spec/controllers/admin_raw_email_controller_spec.rb index e81bb0e7a5..095c21aa41 100644 --- a/spec/controllers/admin_raw_email_controller_spec.rb +++ b/spec/controllers/admin_raw_email_controller_spec.rb @@ -13,7 +13,7 @@ before { sign_in admin_user } it 'renders the show template' do - get :show, params: { :id => raw_email.id } + get :show, params: { id: raw_email.id } end context 'when showing a message with a "From" address in the holding pen' do @@ -27,7 +27,7 @@ end let(:public_body) do - FactoryBot.create(:public_body, :request_email => 'body@example.uk') + FactoryBot.create(:public_body, request_email: 'body@example.uk') end let(:info_request) { info_request = FactoryBot.create(:info_request) } @@ -39,7 +39,7 @@ let(:incoming_message) do incoming_message = FactoryBot.create( :plain_incoming_message, - :info_request => InfoRequest.holding_pen_request, + info_request: InfoRequest.holding_pen_request ) incoming_message.raw_email.data = raw_email_data incoming_message.raw_email.save! @@ -49,20 +49,20 @@ let!(:info_request_event) do FactoryBot.create( :info_request_event, - :event_type => 'response', - :info_request => InfoRequest.holding_pen_request, - :incoming_message => incoming_message, - :params => {:rejected_reason => 'Too dull'} + event_type: 'response', + info_request: InfoRequest.holding_pen_request, + incoming_message: incoming_message, + params: {rejected_reason: 'Too dull'} ) end it 'assigns public bodies that match the "From" domain' do - get :show, params: { :id => incoming_message.raw_email.id } + get :show, params: { id: incoming_message.raw_email.id } expect(assigns[:public_bodies]).to eq [public_body] end it 'assigns guessed requests based on the hash' do - get :show, params: { :id => incoming_message.raw_email.id } + get :show, params: { id: incoming_message.raw_email.id } guess = InfoRequest::Guess.new(info_request, invalid_to, :idhash) expect(assigns[:guessed_info_requests]).to eq([guess]) end @@ -71,20 +71,20 @@ other_request = FactoryBot.create(:incoming_message, subject: 'Basic Email'). info_request - get :show, params: { :id => incoming_message.raw_email.id } + get :show, params: { id: incoming_message.raw_email.id } guess = InfoRequest::Guess.new(other_request, 'Basic Email', :subject) expect(assigns[:guessed_info_requests]).to include(guess) end it 'assigns a reason why the message is in the holding pen' do - get :show, params: { :id => incoming_message.raw_email.id } + get :show, params: { id: incoming_message.raw_email.id } expect(assigns[:rejected_reason]).to eq 'Too dull' end it 'assigns a default reason if no reason is given' do info_request_event.params = {} info_request_event.save! - get :show, params: { :id => incoming_message.raw_email.id } + get :show, params: { id: incoming_message.raw_email.id } expect(assigns[:rejected_reason]).to eq 'unknown reason' end @@ -96,7 +96,7 @@ before { sign_in admin_user } it 'sends the email as an RFC-822 attachment' do - get :show, params: { :id => raw_email.id, :format => 'eml' } + get :show, params: { id: raw_email.id, format: 'eml' } expect(response.media_type).to eq('message/rfc822') expect(response.body).to eq(raw_email.data) end diff --git a/spec/controllers/admin_request_controller_spec.rb b/spec/controllers/admin_request_controller_spec.rb index 588cc62687..00c165ceae 100644 --- a/spec/controllers/admin_request_controller_spec.rb +++ b/spec/controllers/admin_request_controller_spec.rb @@ -51,13 +51,13 @@ context 'when passed a query' do let!(:dog_request) { FactoryBot.create(:info_request, - :title => 'A dog request') } + title: 'A dog request') } let!(:cat_request) { FactoryBot.create(:info_request, - :title => 'A cat request') } + title: 'A cat request') } it 'assigns info requests with titles matching the query to the view case insensitively' do - get :index, params: { :query => 'Cat' } + get :index, params: { query: 'Cat' } expect(assigns[:info_requests].include?(dog_request)).to be false expect(assigns[:info_requests].include?(cat_request)).to be true end @@ -65,7 +65,7 @@ it 'does not include embargoed requests if the current user is an admin user' do cat_request.create_embargo - get :index, params: { :query => 'cat' } + get :index, params: { query: 'cat' } expect(assigns[:info_requests].include?(cat_request)).to be false end @@ -74,7 +74,7 @@ admin user' do with_feature_enabled(:alaveteli_pro) do cat_request.create_embargo - get :index, params: { :query => 'cat' } + get :index, params: { query: 'cat' } expect(assigns[:info_requests].include?(cat_request)).to be false end end @@ -84,7 +84,7 @@ with_feature_enabled(:alaveteli_pro) do cat_request.create_embargo sign_in pro_admin_user - get :index, params: { :query => 'cat' } + get :index, params: { query: 'cat' } expect(assigns[:info_requests].include?(cat_request)).to be true end end @@ -103,12 +103,12 @@ render_views it "is successful" do - get :show, params: { :id => info_request } + get :show, params: { id: info_request } expect(response).to be_successful end it 'shows an external info request with no username' do - get :show, params: { :id => external_request } + get :show, params: { id: external_request } expect(response).to be_successful end @@ -142,7 +142,7 @@ before { sign_in(admin_user) } it "is successful" do - get :edit, params: { :id => info_request } + get :edit, params: { id: info_request } expect(response).to be_successful end @@ -178,14 +178,14 @@ it "saves edits to a request" do post :update, params: { - :id => info_request, - :info_request => { - :title => "Renamed", - :prominence => "normal", - :described_state => "waiting_response", - :awaiting_description => false, - :allow_new_responses_from => 'anybody', - :handle_rejected_responses => 'bounce' + id: info_request, + info_request: { + title: "Renamed", + prominence: "normal", + described_state: "waiting_response", + awaiting_description: false, + allow_new_responses_from: 'anybody', + handle_rejected_responses: 'bounce' } } expect(request.flash[:notice]).to include('successful') @@ -198,14 +198,14 @@ with(info_request.id).and_return(info_request) expect(info_request).to receive(:expire) post :update, params: { - :id => info_request.id, - :info_request => { - :title => "Renamed", - :prominence => "normal", - :described_state => "waiting_response", - :awaiting_description => false, - :allow_new_responses_from => 'anybody', - :handle_rejected_responses => 'bounce' + id: info_request.id, + info_request: { + title: "Renamed", + prominence: "normal", + described_state: "waiting_response", + awaiting_description: false, + allow_new_responses_from: 'anybody', + handle_rejected_responses: 'bounce' } } end @@ -250,19 +250,19 @@ allow(InfoRequest).to receive(:find). with(info_request.id).and_return(info_request) expect(info_request).to receive(:destroy) - delete :destroy, params: { :id => info_request.id } + delete :destroy, params: { id: info_request.id } end it 'uses a different flash message to avoid trying to fetch a non existent user record' do info_request = info_requests(:external_request) - delete :destroy, params: { :id => info_request.id } + delete :destroy, params: { id: info_request.id } expect(request.flash[:notice]).to include('external') end it 'redirects after destroying a request with incoming_messages' do incoming_message = FactoryBot.create(:incoming_message_with_html_attachment, - :info_request => info_request) - delete :destroy, params: { :id => info_request.id } + info_request: info_request) + delete :destroy, params: { id: info_request.id } expect(response).to redirect_to(admin_requests_url) end @@ -298,9 +298,9 @@ it "hides requests and sends a notification email that it has done so" do post :hide, params: { - :id => info_request.id, - :explanation => "Foo", - :reason => "vexatious" + id: info_request.id, + explanation: "Foo", + reason: "vexatious" } info_request.reload expect(info_request.prominence).to eq("requester_only") @@ -316,9 +316,9 @@ with(info_request.id).and_return(info_request) expect(info_request).to receive(:expire) post :hide, params: { - :id => info_request.id, - :explanation => "Foo", - :reason => "vexatious" + id: info_request.id, + explanation: "Foo", + reason: "vexatious" } end @@ -329,9 +329,9 @@ allow(InfoRequest).to receive(:find).with(@info_request.id). and_return(@info_request) - @default_params = { :id => @info_request.id, - :explanation => 'Foo', - :reason => 'vexatious' } + @default_params = { id: @info_request.id, + explanation: 'Foo', + reason: 'vexatious' } end def make_request(params=@default_params) @@ -340,9 +340,9 @@ def make_request(params=@default_params) it 'should redirect the the admin page for the request' do make_request - expect(response).to redirect_to(:controller => 'admin_request', - :action => 'show', - :id => @info_request.id) + expect(response).to redirect_to(controller: 'admin_request', + action: 'show', + id: @info_request.id) end it 'should set the request prominence to "requester_only"' do diff --git a/spec/controllers/admin_spam_addresses_controller_spec.rb b/spec/controllers/admin_spam_addresses_controller_spec.rb index 4a7c514a85..b26644c616 100644 --- a/spec/controllers/admin_spam_addresses_controller_spec.rb +++ b/spec/controllers/admin_spam_addresses_controller_spec.rb @@ -29,34 +29,34 @@ let(:spam_params) { FactoryBot.attributes_for(:spam_address) } it 'creates a new spam address with the given parameters' do - post :create, params: { :spam_address => spam_params } + post :create, params: { spam_address: spam_params } expect(assigns(:spam_address).email).to eq(spam_params[:email]) expect(assigns(:spam_address)).to be_persisted end it 'redirects to the index action if successful' do allow_any_instance_of(SpamAddress).to receive(:save).and_return(true) - post :create, params: { :spam_address => spam_params } + post :create, params: { spam_address: spam_params } expect(response).to redirect_to(admin_spam_addresses_path) end it 'notifies the admin the spam address has been created' do allow_any_instance_of(SpamAddress).to receive(:save).and_return(true) - post :create, params: { :spam_address => spam_params } + post :create, params: { spam_address: spam_params } msg = "#{ spam_params[:email] } has been added to the spam addresses list" expect(flash[:notice]).to eq(msg) end it 'renders the index action if the address could not be saved' do allow_any_instance_of(SpamAddress).to receive(:save).and_return(false) - post :create, params: { :spam_address => spam_params } + post :create, params: { spam_address: spam_params } expect(response).to render_template('index') end it 'collects the spam addresses if the address could not be saved' do 3.times { FactoryBot.create(:spam_address) } allow_any_instance_of(SpamAddress).to receive(:save).and_return(false) - post :create, params: { :spam_address => spam_params } + post :create, params: { spam_address: spam_params } expect(assigns(:spam_addresses)).to eq(SpamAddress.all) end @@ -66,7 +66,7 @@ before(:each) do @spam = FactoryBot.create(:spam_address) - delete :destroy, params: { :id => @spam.id } + delete :destroy, params: { id: @spam.id } end it 'finds the spam address to delete' do diff --git a/spec/controllers/admin_user_controller_spec.rb b/spec/controllers/admin_user_controller_spec.rb index 995333c6c2..ed2e47d478 100644 --- a/spec/controllers/admin_user_controller_spec.rb +++ b/spec/controllers/admin_user_controller_spec.rb @@ -31,68 +31,68 @@ end it 'assigns a custom sort order if valid' do - get :index, params: { :sort_order => 'created_at_asc' } + get :index, params: { sort_order: 'created_at_asc' } expect(assigns[:sort_order]).to eq('created_at_asc') end it 'uses the default sort order if a custom sort order is invalid' do - get :index, params: { :sort_order => 'invalid' } + get :index, params: { sort_order: 'invalid' } expect(assigns[:sort_order]).to eq('name_asc') end it 'sorts the records by name_asc' do User.destroy_all - u1 = FactoryBot.create(:user, :name => 'Bob') - u2 = FactoryBot.create(:user, :name => 'Alice') - get :index, params: { :sort_order => 'name_asc' } + u1 = FactoryBot.create(:user, name: 'Bob') + u2 = FactoryBot.create(:user, name: 'Alice') + get :index, params: { sort_order: 'name_asc' } expect(assigns[:admin_users]).to eq([u2, u1]) end it 'sorts the records by name_desc' do User.destroy_all - u1 = FactoryBot.create(:user, :name => 'Alice') - u2 = FactoryBot.create(:user, :name => 'Bob') - get :index, params: { :sort_order => 'name_desc' } + u1 = FactoryBot.create(:user, name: 'Alice') + u2 = FactoryBot.create(:user, name: 'Bob') + get :index, params: { sort_order: 'name_desc' } expect(assigns[:admin_users]).to eq([u2, u1]) end it 'sorts the records by created_at_asc' do User.destroy_all - u1 = FactoryBot.create(:user, :name => 'Bob') - u2 = FactoryBot.create(:user, :name => 'Alice') - get :index, params: { :sort_order => 'created_at_asc' } + u1 = FactoryBot.create(:user, name: 'Bob') + u2 = FactoryBot.create(:user, name: 'Alice') + get :index, params: { sort_order: 'created_at_asc' } expect(assigns[:admin_users]).to eq([u1, u2]) end it 'sorts the records by created_at_desc' do User.destroy_all - u1 = FactoryBot.create(:user, :name => 'Alice') - u2 = FactoryBot.create(:user, :name => 'Bob') - get :index, params: { :sort_order => 'created_at_desc' } + u1 = FactoryBot.create(:user, name: 'Alice') + u2 = FactoryBot.create(:user, name: 'Bob') + get :index, params: { sort_order: 'created_at_desc' } expect(assigns[:admin_users]).to eq([u2, u1]) end it 'sorts the records by updated_at_asc' do User.destroy_all - u1 = FactoryBot.create(:user, :name => 'Alice') - u2 = FactoryBot.create(:user, :name => 'Bob') + u1 = FactoryBot.create(:user, name: 'Alice') + u2 = FactoryBot.create(:user, name: 'Bob') u1.touch - get :index, params: { :sort_order => 'updated_at_asc' } + get :index, params: { sort_order: 'updated_at_asc' } expect(assigns[:admin_users]).to eq([u2, u1]) end it 'sorts the records by updated_at_desc' do User.destroy_all - u1 = FactoryBot.create(:user, :name => 'Bob') - u2 = FactoryBot.create(:user, :name => 'Alice') + u1 = FactoryBot.create(:user, name: 'Bob') + u2 = FactoryBot.create(:user, name: 'Alice') u1.touch - get :index, params: { :sort_order => 'updated_at_desc' } + get :index, params: { sort_order: 'updated_at_desc' } expect(assigns[:admin_users]).to eq([u1, u2]) end it "assigns users matching a case-insensitive query to the view" do - user = FactoryBot.create(:user, :name => 'Bob Smith') - get :index, params: { :query => 'bob' } + user = FactoryBot.create(:user, name: 'Bob Smith') + get :index, params: { query: 'bob' } expect(assigns[:admin_users].include?(user)).to be true end @@ -110,10 +110,10 @@ it 'searches and sorts the records' do User.destroy_all - u1 = FactoryBot.create(:user, :name => 'Alice Smith') - u2 = FactoryBot.create(:user, :name => 'Bob Smith') - u3 = FactoryBot.create(:user, :name => 'John Doe') - get :index, params: { :query => 'smith', :sort_order => 'name_desc' } + u1 = FactoryBot.create(:user, name: 'Alice Smith') + u2 = FactoryBot.create(:user, name: 'Bob Smith') + u3 = FactoryBot.create(:user, name: 'John Doe') + get :index, params: { query: 'smith', sort_order: 'name_desc' } expect(assigns[:admin_users]).to eq([u2, u1]) end @@ -121,7 +121,7 @@ User.destroy_all admin_user = FactoryBot.create(:admin_user) user = FactoryBot.create(:user) - get :index, params: { :roles => [ 'admin' ] } + get :index, params: { roles: [ 'admin' ] } expect(assigns[:admin_users]).to eq([admin_user]) end @@ -130,7 +130,7 @@ admin_user = FactoryBot.create(:admin_user) pro_user = FactoryBot.create(:pro_user) user = FactoryBot.create(:user) - get :index, params: { :roles => [ 'admin', 'pro' ] } + get :index, params: { roles: %w[admin pro] } expect(assigns[:admin_users]).to eq([admin_user, pro_user]) end @@ -143,13 +143,13 @@ it "is successful" do sign_in admin_user - get :show, params: { :id => FactoryBot.create(:user) } + get :show, params: { id: FactoryBot.create(:user) } expect(response).to be_successful end it "assigns the user's info requests to the view" do sign_in admin_user - get :show, params: { :id => info_request.user } + get :show, params: { id: info_request.user } expect(assigns[:info_requests]).to eq([info_request]) end @@ -157,7 +157,7 @@ not a pro admin user' do info_request.create_embargo sign_in admin_user - get :show, params: { :id => info_request.user } + get :show, params: { id: info_request.user } expect(assigns[:info_requests]).to eq([]) end @@ -168,7 +168,7 @@ with_feature_enabled(:alaveteli_pro) do info_request.create_embargo sign_in admin_user - get :show, params: { :id => info_request.user } + get :show, params: { id: info_request.user } expect(assigns[:info_requests]).to eq([]) end end @@ -178,7 +178,7 @@ with_feature_enabled(:alaveteli_pro) do info_request.create_embargo sign_in pro_admin_user - get :show, params: { :id => info_request.user } + get :show, params: { id: info_request.user } expect(assigns[:info_requests].include?(info_request)).to be true end end @@ -186,20 +186,20 @@ end it "assigns the user's comments to the view" do - comment = FactoryBot.create(:comment, :info_request => info_request, - :user => info_request.user) + comment = FactoryBot.create(:comment, info_request: info_request, + user: info_request.user) sign_in admin_user - get :show, params: { :id => info_request.user } + get :show, params: { id: info_request.user } expect(assigns[:comments]).to eq([comment]) end it 'does not include comments on embargoed requests if the current user is not a pro admin user' do - comment = FactoryBot.create(:comment, :info_request => info_request, - :user => info_request.user) + comment = FactoryBot.create(:comment, info_request: info_request, + user: info_request.user) info_request.create_embargo sign_in admin_user - get :show, params: { :id => info_request.user } + get :show, params: { id: info_request.user } expect(assigns[:comments]).to eq([]) end @@ -208,11 +208,11 @@ it 'does not include comments on embargoed requests if the current user is not a pro admin user' do with_feature_enabled(:alaveteli_pro) do - comment = FactoryBot.create(:comment, :info_request => info_request, - :user => info_request.user) + comment = FactoryBot.create(:comment, info_request: info_request, + user: info_request.user) info_request.create_embargo sign_in admin_user - get :show, params: { :id => info_request.user } + get :show, params: { id: info_request.user } expect(assigns[:comments]).to eq([]) end end @@ -220,11 +220,11 @@ it 'includes comments on embargoed requests if the current user is a pro admin user' do with_feature_enabled(:alaveteli_pro) do - comment = FactoryBot.create(:comment, :info_request => info_request, - :user => info_request.user) + comment = FactoryBot.create(:comment, info_request: info_request, + user: info_request.user) info_request.create_embargo sign_in pro_admin_user - get :show, params: { :id => info_request.user } + get :show, params: { id: info_request.user } expect(assigns[:comments]).to eq([comment]) end end @@ -245,15 +245,15 @@ user = FactoryBot.create(:user) expect(user.can_make_batch_requests?).to be false sign_in admin_user - post :update, params: { :id => user.id, - :admin_user => { - :can_make_batch_requests => '1', - :name => user.name, - :email => user.email, - :ban_text => user.ban_text, - :about_me => user.about_me, - :no_limit => user.no_limit, - :confirmed_not_spam => user.confirmed_not_spam + post :update, params: { id: user.id, + admin_user: { + can_make_batch_requests: '1', + name: user.name, + email: user.email, + ban_text: user.ban_text, + about_me: user.about_me, + no_limit: user.no_limit, + confirmed_not_spam: user.confirmed_not_spam } } expect(flash[:notice]).to eq('User successfully updated.') @@ -264,17 +264,17 @@ it "should not allow an existing email address to be used" do existing_email = 'donotreuse@localhost' - FactoryBot.create(:user, :email => existing_email) - user = FactoryBot.create(:user, :email => 'user1@localhost') + FactoryBot.create(:user, email: existing_email) + user = FactoryBot.create(:user, email: 'user1@localhost') sign_in admin_user - post :update, params: { :id => user.id, - :admin_user => { - :name => user.name, - :email => existing_email, - :ban_text => user.ban_text, - :about_me => user.about_me, - :no_limit => user.no_limit, - :confirmed_not_spam => user.confirmed_not_spam + post :update, params: { id: user.id, + admin_user: { + name: user.name, + email: existing_email, + ban_text: user.ban_text, + about_me: user.about_me, + no_limit: user.no_limit, + confirmed_not_spam: user.confirmed_not_spam } } user = User.find(user.id) @@ -283,17 +283,17 @@ it "sets the user's roles" do user = FactoryBot.create(:user) - admin_role = Role.where(:name => 'admin').first + admin_role = Role.where(name: 'admin').first expect(user.is_admin?).to be false sign_in admin_user - post :update, params: { :id => user.id, - :admin_user => { - :name => user.name, - :ban_text => user.ban_text, - :about_me => user.about_me, - :role_ids => [ admin_role.id ], - :no_limit => user.no_limit, - :confirmed_not_spam => user.confirmed_not_spam + post :update, params: { id: user.id, + admin_user: { + name: user.name, + ban_text: user.ban_text, + about_me: user.about_me, + role_ids: [ admin_role.id ], + no_limit: user.no_limit, + confirmed_not_spam: user.confirmed_not_spam } } user = User.find(user.id) @@ -303,14 +303,13 @@ it "unsets the user's roles if no role ids are supplied" do expect(admin_user.is_admin?).to be true sign_in admin_user - post :update, params: { :id => admin_user.id, - :admin_user => { - :name => admin_user.name, - :ban_text => admin_user.ban_text, - :about_me => admin_user.about_me, - :no_limit => admin_user.no_limit, - :confirmed_not_spam => - admin_user.confirmed_not_spam + post :update, params: { id: admin_user.id, + admin_user: { + name: admin_user.name, + ban_text: admin_user.ban_text, + about_me: admin_user.about_me, + no_limit: admin_user.no_limit, + confirmed_not_spam: admin_user.confirmed_not_spam } } user = User.find(admin_user.id) @@ -319,17 +318,17 @@ it 'does not set a role the setter cannot grant and revoke' do user = FactoryBot.create(:user) - pro_role = Role.where(:name => 'pro').first + pro_role = Role.where(name: 'pro').first expect(user.is_pro?).to be false sign_in admin_user - post :update, params: { :id => user.id, - :admin_user => { - :name => user.name, - :ban_text => user.ban_text, - :about_me => user.about_me, - :role_ids => [pro_role.id], - :no_limit => user.no_limit, - :confirmed_not_spam => user.confirmed_not_spam + post :update, params: { id: user.id, + admin_user: { + name: user.name, + ban_text: user.ban_text, + about_me: user.about_me, + role_ids: [pro_role.id], + no_limit: user.no_limit, + confirmed_not_spam: user.confirmed_not_spam } } expect(flash[:error]).to eq("Not permitted to change roles") @@ -342,14 +341,14 @@ role_id = Role.maximum(:id) + 1 expect(user.is_pro?).to be false sign_in admin_user - post :update, params: { :id => user.id, - :admin_user => { - :name => user.name, - :ban_text => user.ban_text, - :about_me => user.about_me, - :role_ids => [role_id], - :no_limit => user.no_limit, - :confirmed_not_spam => user.confirmed_not_spam + post :update, params: { id: user.id, + admin_user: { + name: user.name, + ban_text: user.ban_text, + about_me: user.about_me, + role_ids: [role_id], + no_limit: user.no_limit, + confirmed_not_spam: user.confirmed_not_spam } } user = User.find(user.id) @@ -366,51 +365,51 @@ end it 'redirects to the page the admin was previously on' do - comment = FactoryBot.create(:visible_comment, :user => @user) + comment = FactoryBot.create(:visible_comment, user: @user) post :modify_comment_visibility, params: { - :id => @user.id, - :comment_ids => comment.id, - :hide_selected => 'hidden' + id: @user.id, + comment_ids: comment.id, + hide_selected: 'hidden' } expect(response).to redirect_to(admin_user_path(@user)) end it 'sets the given comments visibility to hidden' do - comments = FactoryBot.create_list(:visible_comment, 3, :user => @user) + comments = FactoryBot.create_list(:visible_comment, 3, user: @user) comment_ids = comments.map(&:id) post :modify_comment_visibility, params: { - :id => @user.id, - :comment_ids => comment_ids, - :hide_selected => 'hidden' + id: @user.id, + comment_ids: comment_ids, + hide_selected: 'hidden' } Comment.find(comment_ids).each { |comment| expect(comment).not_to be_visible } end it 'sets the given comments visibility to visible' do - comments = FactoryBot.create_list(:hidden_comment, 3, :user => @user) + comments = FactoryBot.create_list(:hidden_comment, 3, user: @user) comment_ids = comments.map(&:id) post :modify_comment_visibility, params: { - :id => @user.id, - :comment_ids => comment_ids, - :unhide_selected => 'visible' + id: @user.id, + comment_ids: comment_ids, + unhide_selected: 'visible' } Comment.find(comment_ids).each { |comment| expect(comment).to be_visible } end it 'only modifes the given list of comments' do - unaffected_comment = FactoryBot.create(:hidden_comment, :user => @user) - affected_comment = FactoryBot.create(:hidden_comment, :user => @user) + unaffected_comment = FactoryBot.create(:hidden_comment, user: @user) + affected_comment = FactoryBot.create(:hidden_comment, user: @user) post :modify_comment_visibility, params: { - :id => @user.id, - :comment_ids => affected_comment.id, - :unhide_selected => 'visible' + id: @user.id, + comment_ids: affected_comment.id, + unhide_selected: 'visible' } expect(Comment.find(unaffected_comment.id)).not_to be_visible @@ -418,14 +417,14 @@ end it 'preserves the visibility if a comment is already of the requested visibility' do - hidden_comment = FactoryBot.create(:hidden_comment, :user => @user) - visible_comment = FactoryBot.create(:visible_comment, :user => @user) + hidden_comment = FactoryBot.create(:hidden_comment, user: @user) + visible_comment = FactoryBot.create(:visible_comment, user: @user) comment_ids = [hidden_comment.id, visible_comment.id] post :modify_comment_visibility, params: { - :id => @user.id, - :comment_ids => comment_ids, - :unhide_selected => 'visible' + id: @user.id, + comment_ids: comment_ids, + unhide_selected: 'visible' } Comment.find(comment_ids).each { |c| expect(c).to be_visible } diff --git a/spec/controllers/alaveteli_pro/account_request_controller_spec.rb b/spec/controllers/alaveteli_pro/account_request_controller_spec.rb index d996281805..d6899bce73 100644 --- a/spec/controllers/alaveteli_pro/account_request_controller_spec.rb +++ b/spec/controllers/alaveteli_pro/account_request_controller_spec.rb @@ -46,7 +46,7 @@ post :create, params: { account_request: account_request_params } expect(ActionMailer::Base.deliveries.size).to eq 1 mail = ActionMailer::Base.deliveries.first - expect(mail.to.first).to eq AlaveteliConfiguration::pro_contact_email + expect(mail.to.first).to eq AlaveteliConfiguration.pro_contact_email end end diff --git a/spec/controllers/alaveteli_pro/dashboard_controller_spec.rb b/spec/controllers/alaveteli_pro/dashboard_controller_spec.rb index d934c75a61..121f1a10b2 100644 --- a/spec/controllers/alaveteli_pro/dashboard_controller_spec.rb +++ b/spec/controllers/alaveteli_pro/dashboard_controller_spec.rb @@ -30,12 +30,12 @@ context 'if a page param is passed' do it 'assigns @page a numerical page param' do - get :index, params: { :page => 2 } + get :index, params: { page: 2 } expect(assigns[:page]).to eq 2 end it 'does not assign a non-numerical page param' do - get :index, params: { :page => 'foo' } + get :index, params: { page: 'foo' } expect(assigns[:page]).to eq 1 end end diff --git a/spec/controllers/alaveteli_pro/info_requests_controller_spec.rb b/spec/controllers/alaveteli_pro/info_requests_controller_spec.rb index 6134ca5ece..8f7c8d1556 100644 --- a/spec/controllers/alaveteli_pro/info_requests_controller_spec.rb +++ b/spec/controllers/alaveteli_pro/info_requests_controller_spec.rb @@ -39,8 +39,8 @@ context 'when a search is passed' do it 'applies the search' do - get :index, params: { :alaveteli_pro_request_filter => { - :search => 'foo' + get :index, params: { alaveteli_pro_request_filter: { + search: 'foo' } } expect(assigns[:request_summaries].size).to eq 1 diff --git a/spec/controllers/alaveteli_pro/payment_methods_controller_spec.rb b/spec/controllers/alaveteli_pro/payment_methods_controller_spec.rb index 352a12409e..ff00f0db3e 100644 --- a/spec/controllers/alaveteli_pro/payment_methods_controller_spec.rb +++ b/spec/controllers/alaveteli_pro/payment_methods_controller_spec.rb @@ -31,7 +31,7 @@ it 'redirects to the login form' do expect(response). - to redirect_to(signin_path(:token => PostRedirect.last.token)) + to redirect_to(signin_path(token: PostRedirect.last.token)) end end diff --git a/spec/controllers/alaveteli_pro/plans_controller_spec.rb b/spec/controllers/alaveteli_pro/plans_controller_spec.rb index d816a50bb9..3da26da3b0 100644 --- a/spec/controllers/alaveteli_pro/plans_controller_spec.rb +++ b/spec/controllers/alaveteli_pro/plans_controller_spec.rb @@ -56,7 +56,7 @@ it 'redirects to the login form' do expect(response). - to redirect_to(signin_path(:token => PostRedirect.last.token)) + to redirect_to(signin_path(token: PostRedirect.last.token)) end it 'sets in_pro_area' do @@ -123,7 +123,7 @@ source: stripe_helper.generate_card_token) Stripe::Subscription.create(customer: customer, plan: 'pro') - user.create_pro_account(:stripe_customer_id => customer.id) + user.create_pro_account(stripe_customer_id: customer.id) user.add_role(:pro) get :show, params: { id: 'pro' } end @@ -149,7 +149,7 @@ Stripe::Subscription.create(customer: customer, plan: 'pro') subscription.delete - user.create_pro_account(:stripe_customer_id => customer.id) + user.create_pro_account(stripe_customer_id: customer.id) get :show, params: { id: 'pro' } end diff --git a/spec/controllers/alaveteli_pro/public_bodies_controller_spec.rb b/spec/controllers/alaveteli_pro/public_bodies_controller_spec.rb index 1b0837a2b4..6dfd96e264 100644 --- a/spec/controllers/alaveteli_pro/public_bodies_controller_spec.rb +++ b/spec/controllers/alaveteli_pro/public_bodies_controller_spec.rb @@ -4,7 +4,7 @@ describe "#index" do let!(:pro_user) { FactoryBot.create(:pro_user) } - let!(:body) { FactoryBot.create(:public_body, :name => 'example') } + let!(:body) { FactoryBot.create(:public_body, name: 'example') } let!(:defunct_body) do FactoryBot.create(:public_body, :defunct, name: 'defunct') end @@ -12,8 +12,8 @@ FactoryBot.create(:public_body, :not_apply, name: 'not_apply') end let!(:not_requestable_body) do - FactoryBot.create(:public_body, :name => 'not_requestable', - :request_email => 'blank') + FactoryBot.create(:public_body, name: 'not_requestable', + request_email: 'blank') end before do diff --git a/spec/controllers/alaveteli_pro/subscriptions_controller_spec.rb b/spec/controllers/alaveteli_pro/subscriptions_controller_spec.rb index e299a4f6bb..e0dcdd4864 100644 --- a/spec/controllers/alaveteli_pro/subscriptions_controller_spec.rb +++ b/spec/controllers/alaveteli_pro/subscriptions_controller_spec.rb @@ -39,7 +39,7 @@ it 'redirects to the login form' do expect(response). - to redirect_to(signin_path(:token => PostRedirect.last.token)) + to redirect_to(signin_path(token: PostRedirect.last.token)) end end @@ -197,7 +197,7 @@ customer = Stripe::Customer.create(email: user.email, source: stripe_helper.generate_card_token) - user.create_pro_account(:stripe_customer_id => customer.id) + user.create_pro_account(stripe_customer_id: customer.id) post :create, params: { 'stripe_token' => token, @@ -472,7 +472,7 @@ context 'when invalid params are submitted' do it 'redirects to the plan page if there is a plan' do - post :create, params: { :plan_id => 'pro' } + post :create, params: { plan_id: 'pro' } expect(response).to redirect_to(plan_path('pro')) end @@ -768,7 +768,7 @@ it 'redirects to the login form' do expect(response). - to redirect_to(signin_path(:token => PostRedirect.last.token)) + to redirect_to(signin_path(token: PostRedirect.last.token)) end end @@ -900,7 +900,7 @@ it 'redirects to the login form' do expect(response). - to redirect_to(signin_path(:token => PostRedirect.last.token)) + to redirect_to(signin_path(token: PostRedirect.last.token)) end end @@ -933,7 +933,7 @@ let(:customer) do customer = Stripe::Customer.create({ email: user.email, - source: stripe_helper.generate_card_token, + source: stripe_helper.generate_card_token }) user.pro_account.update!(stripe_customer_id: customer.id) customer @@ -971,7 +971,7 @@ let(:other_subscription) do customer = Stripe::Customer.create({ email: 'test@example.org', - source: stripe_helper.generate_card_token, + source: stripe_helper.generate_card_token }) Stripe::Subscription.create(customer: customer, plan: plan.id) end @@ -1102,7 +1102,7 @@ context 'when invalid params are submitted' do it 'redirects to the plan page if there is a plan' do - delete :destroy, params: { :id => 'unknown' } + delete :destroy, params: { id: 'unknown' } expect(response).to redirect_to(subscriptions_path) end diff --git a/spec/controllers/api_controller_spec.rb b/spec/controllers/api_controller_spec.rb index 7b9114f876..41711838e5 100644 --- a/spec/controllers/api_controller_spec.rb +++ b/spec/controllers/api_controller_spec.rb @@ -15,7 +15,7 @@ it 'should check that an API key is given as a param' do expect { - post :create_request, params: { :request_json => @request_data.to_json } + post :create_request, params: { request_json: @request_data.to_json } }.to raise_error ApplicationController::PermissionDenied expect(InfoRequest.count).to eq(@number_of_requests) end @@ -23,8 +23,8 @@ it 'should check the API key' do expect { post :create_request, params: { - :k => 'This is not really an API key', - :request_json => @request_data.to_json + k: 'This is not really an API key', + request_json: @request_data.to_json } }.to raise_error ApplicationController::PermissionDenied expect(InfoRequest.count).to eq(@number_of_requests) @@ -34,8 +34,8 @@ def _create_request post :create_request, params: { - :k => public_bodies(:geraldine_public_body).api_key, - :request_json => { + k: public_bodies(:geraldine_public_body).api_key, + request_json: { 'title' => 'Tell me about your chickens', 'body' => "Dear Sir,\n\nI should like to know about your " \ "chickens.\n\nYours in faith,\nBob\n", @@ -52,20 +52,20 @@ def _create_request it 'should create a new request from a POST' do number_of_requests = InfoRequest. - where(:public_body_id => public_bodies(:geraldine_public_body).id). + where(public_body_id: public_bodies(:geraldine_public_body).id). count request_data = { 'title' => 'Tell me about your chickens', 'body' => "Dear Sir,\n\nI should like to know about your chickens.\n\nYours in faith,\nBob\n", 'external_url' => 'http://www.example.gov.uk/foi/chickens_23', - 'external_user_name' => 'Bob Smith', + 'external_user_name' => 'Bob Smith' } post :create_request, params: { - :k => public_bodies(:geraldine_public_body).api_key, - :request_json => request_data.to_json + k: public_bodies(:geraldine_public_body).api_key, + request_json: request_data.to_json } expect(response).to be_successful @@ -76,7 +76,7 @@ def _create_request updated_count = InfoRequest. - where(:public_body_id => public_bodies(:geraldine_public_body).id). + where(public_body_id: public_bodies(:geraldine_public_body).id). count expect(updated_count).to eq(number_of_requests + 1) @@ -103,7 +103,7 @@ def _create_request # Initially it has no incoming messages initial_count = - IncomingMessage.where(:info_request_id => request_id).count + IncomingMessage.where(info_request_id: request_id).count expect(initial_count).to eq(0) # Now add one @@ -111,9 +111,9 @@ def _create_request response_body = "Thank you for your request for information, which we are handling in accordance with the Freedom of Information Act 2000. You will receive a response within 20 working days or before the next full moon, whichever is sooner.\n\nYours sincerely,\nJohn Gandermulch,\nExample Council FOI Officer\n" post :add_correspondence, params: { - :k => public_bodies(:geraldine_public_body).api_key, - :id => request_id, - :correspondence_json => { + k: public_bodies(:geraldine_public_body).api_key, + id: request_id, + correspondence_json: { 'direction' => 'response', 'sent_at' => sent_at, 'body' => response_body @@ -123,7 +123,7 @@ def _create_request # And make sure it worked expect(response).to be_successful incoming_messages = - IncomingMessage.where(:info_request_id => request_id) + IncomingMessage.where(info_request_id: request_id) expect(incoming_messages.count).to eq(1) incoming_message = incoming_messages[0] @@ -137,7 +137,7 @@ def _create_request # Initially it has one outgoing message outgoing_messages = - OutgoingMessage.where(:info_request_id => request_id).count + OutgoingMessage.where(info_request_id: request_id).count expect(outgoing_messages).to eq(1) # Add another, as a followup @@ -145,9 +145,9 @@ def _create_request followup_body = "Pls answer ASAP.\nkthxbye\n" post :add_correspondence, params: { - :k => public_bodies(:geraldine_public_body).api_key, - :id => request_id, - :correspondence_json => { + k: public_bodies(:geraldine_public_body).api_key, + id: request_id, + correspondence_json: { 'direction' => 'request', 'sent_at' => sent_at, 'body' => followup_body @@ -158,8 +158,8 @@ def _create_request expect(response).to be_successful followup_messages = - OutgoingMessage.where(:info_request_id => request_id, - :message_type => 'followup') + OutgoingMessage.where(info_request_id: request_id, + message_type: 'followup') expect(followup_messages.size).to eq(1) followup_message = followup_messages[0] @@ -173,7 +173,7 @@ def _create_request request_id = info_requests(:external_request).id # Initially it has no incoming messages - actual1 = IncomingMessage.where(:info_request_id => request_id).count + actual1 = IncomingMessage.where(info_request_id: request_id).count expect(actual1).to eq(0) # Now add one @@ -181,10 +181,10 @@ def _create_request response_body = "Thank you for your request for information, which we are handling in accordance with the Freedom of Information Act 2000. You will receive a response within 20 working days or before the next full moon, whichever is sooner.\n\nYours sincerely,\nJohn Gandermulch,\nExample Council FOI Officer\n" post :add_correspondence, params: { - :k => public_bodies(:geraldine_public_body).api_key, - :id => request_id, - :state => 'successful', - :correspondence_json => { + k: public_bodies(:geraldine_public_body).api_key, + id: request_id, + state: 'successful', + correspondence_json: { 'direction' => 'response', 'sent_at' => sent_at, 'body' => response_body @@ -194,7 +194,7 @@ def _create_request # And make sure it worked expect(response).to be_successful - actual2 = IncomingMessage.where(:info_request_id => request_id).count + actual2 = IncomingMessage.where(info_request_id: request_id).count expect(actual2).to eq(1) request = InfoRequest.find_by_id(request_id) @@ -207,7 +207,7 @@ def _create_request # Initially it has no incoming messages initial_count = - IncomingMessage.where(:info_request_id => request_id).count + IncomingMessage.where(info_request_id: request_id).count expect(initial_count).to eq(0) # Now add one @@ -215,10 +215,10 @@ def _create_request response_body = "Thank you for your request for information, which we are handling in accordance with the Freedom of Information Act 2000. You will receive a response within 20 working days or before the next full moon, whichever is sooner.\n\nYours sincerely,\nJohn Gandermulch,\nExample Council FOI Officer\n" post :add_correspondence, params: { - :k => public_bodies(:geraldine_public_body).api_key, - :id => request_id, - :state => 'random_string', - :correspondence_json => { + k: public_bodies(:geraldine_public_body).api_key, + id: request_id, + state: 'random_string', + correspondence_json: { 'direction' => 'response', 'sent_at' => sent_at, 'body' => response_body @@ -232,7 +232,7 @@ def _create_request ]) incoming_messages = - IncomingMessage.where(:info_request_id => request_id) + IncomingMessage.where(info_request_id: request_id) expect(incoming_messages.count).to eq(0) request = InfoRequest.find_by_id(request_id) expect(request.described_state).to eq('waiting_response') @@ -245,9 +245,9 @@ def _create_request request_id = info_requests(:naughty_chicken_request).id post :add_correspondence, params: { - :k => public_bodies(:geraldine_public_body).api_key, - :id => request_id, - :correspondence_json => { + k: public_bodies(:geraldine_public_body).api_key, + id: request_id, + correspondence_json: { 'direction' => 'request', 'sent_at' => Time.zone.now.iso8601, 'body' => 'xxx' @@ -270,9 +270,9 @@ def _create_request post :add_correspondence, params: { - :k => public_bodies(:humpadink_public_body).api_key, - :id => request_id, - :correspondence_json => { + k: public_bodies(:humpadink_public_body).api_key, + id: request_id, + correspondence_json: { 'direction' => 'request', 'sent_at' => Time.zone.now.iso8601, 'body' => 'xxx' @@ -295,9 +295,9 @@ def _create_request response_body = "Thank you for your request for information, which we are handling in accordance with the Freedom of Information Act 2000. You will receive a response within 20 working days or before the next full moon, whichever is sooner.\n\nYours sincerely,\nJohn Gandermulch,\nExample Council FOI Officer\n" post :add_correspondence, params: { - :k => public_bodies(:geraldine_public_body).api_key, - :id => request_id, - :correspondence_json => { + k: public_bodies(:geraldine_public_body).api_key, + id: request_id, + correspondence_json: { 'direction' => 'response', 'sent_at' => sent_at, 'body' => response_body @@ -313,9 +313,9 @@ def _create_request response_body = "Thank you for your request for information, which we are handling in accordance with the Freedom of Information Act 2000. You will receive a response within 20 working days or before the next full moon, whichever is sooner.\n\nYours sincerely,\nJohn Gandermulch,\nExample Council FOI Officer\n" post :add_correspondence, params: { - :k => public_bodies(:geraldine_public_body).api_key, - :id => request_id, - :correspondence_json => { + k: public_bodies(:geraldine_public_body).api_key, + id: request_id, + correspondence_json: { 'direction' => 'response', 'sent_at' => sent_at, 'body' => response_body @@ -328,14 +328,14 @@ def _create_request it 'should not allow files to be attached to a followup' do post :add_correspondence, params: { - :k => public_bodies(:geraldine_public_body).api_key, - :id => info_requests(:external_request).id, - :correspondence_json => { + k: public_bodies(:geraldine_public_body).api_key, + id: info_requests(:external_request).id, + correspondence_json: { 'direction' => 'request', 'sent_at' => Time.zone.now.iso8601, 'body' => 'Are you joking, or are you serious?' }.to_json, - :attachments => [ + attachments: [ fixture_file_upload('tfl.pdf') ] } @@ -351,7 +351,7 @@ def _create_request request_id = info_requests(:external_request).id # Initially it has no incoming messages - actual1 = IncomingMessage.where(:info_request_id => request_id).count + actual1 = IncomingMessage.where(info_request_id: request_id).count expect(actual1).to eq(0) # Now add one @@ -359,14 +359,14 @@ def _create_request response_body = "Thank you for your request for information, which we are handling in accordance with the Freedom of Information Act 2000. You will receive a response within 20 working days or before the next full moon, whichever is sooner.\n\nYours sincerely,\nJohn Gandermulch,\nExample Council FOI Officer\n" post :add_correspondence, params: { - :k => public_bodies(:geraldine_public_body).api_key, - :id => request_id, - :correspondence_json => { + k: public_bodies(:geraldine_public_body).api_key, + id: request_id, + correspondence_json: { 'direction' => 'response', 'sent_at' => sent_at, 'body' => response_body }.to_json, - :attachments => [ + attachments: [ fixture_file_upload('tfl.pdf') ] } @@ -374,7 +374,7 @@ def _create_request # And make sure it worked expect(response).to be_successful - incoming_messages = IncomingMessage.where(:info_request_id => request_id) + incoming_messages = IncomingMessage.where(info_request_id: request_id) expect(incoming_messages.count).to eq(1) incoming_message = incoming_messages[0] @@ -402,9 +402,9 @@ def _create_request # Now accept an update post :update_state, params: { - :k => public_bodies(:geraldine_public_body).api_key, - :id => request_id, - :state => 'partially_successful' + k: public_bodies(:geraldine_public_body).api_key, + id: request_id, + state: 'partially_successful' } # It should have updated the status @@ -430,9 +430,9 @@ def _create_request # Now post an invalid update post :update_state, params: { - :k => public_bodies(:geraldine_public_body).api_key, - :id => request_id, - :state => 'random_string' + k: public_bodies(:geraldine_public_body).api_key, + id: request_id, + state: 'random_string' } # Check that the error has been raised... @@ -449,8 +449,8 @@ def _create_request allow(InfoRequest).to receive(:find_by_id).with(request_id).and_return(nil) post :update_state, params: { - :k => public_bodies(:geraldine_public_body).api_key, - :id => request_id, :state => "successful" + k: public_bodies(:geraldine_public_body).api_key, + id: request_id, state: "successful" } expect(response.status).to eq(404) @@ -461,8 +461,8 @@ def _create_request request_id = info_requests(:naughty_chicken_request).id post :update_state, params: { - :k => public_bodies(:geraldine_public_body).api_key, - :id => request_id, :state => 'successful' + k: public_bodies(:geraldine_public_body).api_key, + id: request_id, state: 'successful' } expect(response.status).to eq(403) @@ -476,8 +476,8 @@ def _create_request info_request = info_requests(:naughty_chicken_request) get :show_request, params: { - :k => public_bodies(:geraldine_public_body).api_key, - :id => info_request.id + k: public_bodies(:geraldine_public_body).api_key, + id: info_request.id } expect(response).to be_successful @@ -494,8 +494,8 @@ def _create_request it 'should show information about an external request' do info_request = info_requests(:external_request) get :show_request, params: { - :k => public_bodies(:geraldine_public_body).api_key, - :id => info_request.id + k: public_bodies(:geraldine_public_body).api_key, + id: info_request.id } expect(response).to be_successful @@ -510,9 +510,9 @@ def _create_request it 'should show an Atom feed of new request events' do get :body_request_events, params: { - :id => public_bodies(:geraldine_public_body).id, - :k => public_bodies(:geraldine_public_body).api_key, - :feed_type => 'atom' + id: public_bodies(:geraldine_public_body).id, + k: public_bodies(:geraldine_public_body).api_key, + feed_type: 'atom' } expect(response).to be_successful @@ -521,16 +521,16 @@ def _create_request assigns[:events].each do |event| expect(event.info_request.public_body).to eq(public_bodies(:geraldine_public_body)) expect(event.outgoing_message).not_to be_nil - expect(event.event_type).to satisfy { |x| ['sent', 'followup_sent', 'resent', 'followup_resent'].include?(x) } + expect(event.event_type).to satisfy { |x| %w[sent followup_sent resent followup_resent].include?(x) } end end it 'should show a JSON feed of new request events' do get :body_request_events, params: { - :id => public_bodies(:geraldine_public_body).id, - :k => public_bodies(:geraldine_public_body).api_key, - :feed_type => 'json' + id: public_bodies(:geraldine_public_body).id, + k: public_bodies(:geraldine_public_body).api_key, + feed_type: 'json' } expect(response).to be_successful @@ -538,21 +538,21 @@ def _create_request assigns[:events].each do |event| expect(event.info_request.public_body).to eq(public_bodies(:geraldine_public_body)) expect(event.outgoing_message).not_to be_nil - expect(event.event_type).to satisfy { |x| ['sent', 'followup_sent', 'resent', 'followup_resent'].include?(x) } + expect(event.event_type).to satisfy { |x| %w[sent followup_sent resent followup_resent].include?(x) } end expect(assigns[:event_data].size).to eq(assigns[:events].size) assigns[:event_data].each do |event_record| - expect(event_record[:event_type]).to satisfy { |x| ['sent', 'followup_sent', 'resent', 'followup_resent'].include?(x) } + expect(event_record[:event_type]).to satisfy { |x| %w[sent followup_sent resent followup_resent].include?(x) } end end it 'should honour the since_event_id parameter' do get :body_request_events, params: { - :id => public_bodies(:geraldine_public_body).id, - :k => public_bodies(:geraldine_public_body).api_key, - :feed_type => 'json' + id: public_bodies(:geraldine_public_body).id, + k: public_bodies(:geraldine_public_body).api_key, + feed_type: 'json' } expect(response).to be_successful @@ -561,10 +561,10 @@ def _create_request get :body_request_events, params: { - :id => public_bodies(:geraldine_public_body).id, - :k => public_bodies(:geraldine_public_body).api_key, - :feed_type => 'json', - :since_event_id => second_event_id + id: public_bodies(:geraldine_public_body).id, + k: public_bodies(:geraldine_public_body).api_key, + feed_type: 'json', + since_event_id: second_event_id } expect(response).to be_successful expect(assigns[:event_data]).to eq([first_event]) @@ -573,10 +573,10 @@ def _create_request it 'should honour the since_date parameter' do get :body_request_events, params: { - :id => public_bodies(:humpadink_public_body).id, - :k => public_bodies(:humpadink_public_body).api_key, - :since_date => '2010-01-01', - :feed_type => 'atom' + id: public_bodies(:humpadink_public_body).id, + k: public_bodies(:humpadink_public_body).api_key, + since_date: '2010-01-01', + feed_type: 'atom' } expect(response).to be_successful @@ -588,10 +588,10 @@ def _create_request get :body_request_events, params: { - :id => public_bodies(:humpadink_public_body).id, - :k => public_bodies(:humpadink_public_body).api_key, - :since_date => '2010-01-01', - :feed_type => 'json' + id: public_bodies(:humpadink_public_body).id, + k: public_bodies(:humpadink_public_body).api_key, + since_date: '2010-01-01', + feed_type: 'json' } assigns[:events].each do |event| expect(event.created_at).to be >= Date.new(2010, 1, 1) @@ -607,9 +607,9 @@ def _create_request before do get :body_request_events, params: { - :id => public_bodies(:humpadink_public_body).id, - :k => public_bodies(:humpadink_public_body).api_key, - :feed_type => 'atom' + id: public_bodies(:humpadink_public_body).id, + k: public_bodies(:humpadink_public_body).api_key, + feed_type: 'atom' } end @@ -626,10 +626,10 @@ def _create_request # from the fixtures get :body_request_events, params: { - :id => public_bodies(:humpadink_public_body).id, - :k => public_bodies(:humpadink_public_body).api_key, - :since_date => '2018-01-01', - :feed_type => 'atom' + id: public_bodies(:humpadink_public_body).id, + k: public_bodies(:humpadink_public_body).api_key, + since_date: '2018-01-01', + feed_type: 'atom' } end diff --git a/spec/controllers/attachments_controller_spec.rb b/spec/controllers/attachments_controller_spec.rb index 889e8d57d5..61c83a2235 100644 --- a/spec/controllers/attachments_controller_spec.rb +++ b/spec/controllers/attachments_controller_spec.rb @@ -57,7 +57,7 @@ def show(params = {}) # check the file permissions key_path = @controller.send(:cache_key_path) - octal_stat = sprintf("%o", File.stat(key_path).mode)[-4..-1] + octal_stat = format("%o", File.stat(key_path).mode)[-4..-1] expect(octal_stat).to eq('0644') # clean up and remove the file @@ -76,20 +76,20 @@ def show(params = {}) # https://github.com/mysociety/alaveteli/issues/351 it "should return 404 for ugly URLs containing a request id that isn't an integer" do ugly_id = "55195" - expect { show(:id => ugly_id) } + expect { show(id: ugly_id) } .to raise_error(ActiveRecord::RecordNotFound) end it "should return 404 when incoming message and request ids don't match" do - expect { show(:id => info_request.id + 1) } + expect { show(id: info_request.id + 1) } .to raise_error(ActiveRecord::RecordNotFound) end it "should return 404 for ugly URLs contain a request id that isn't an integer, even if the integer prefix refers to an actual request" do ugly_id = "#{FactoryBot.create(:info_request).id}95" - expect { show(:id => ugly_id) } + expect { show(id: ugly_id) } .to raise_error(ActiveRecord::RecordNotFound) end @@ -103,7 +103,7 @@ def show(params = {}) 'interesting.pdf' ) expect(attachment).to be_nil - show(:part => 5) + show(part: 5) expect(response.status).to eq(303) new_location = response.header['Location'] expect(new_location) @@ -114,11 +114,11 @@ def show(params = {}) info_request = FactoryBot.create(:info_request_with_html_attachment) get :show, params: { - :incoming_message_id => info_request.incoming_messages.first.id, - :id => info_request.id, - :part => 5, - :file_name => 'interesting.html', - :skip_cache => 1 + incoming_message_id: info_request.incoming_messages.first.id, + id: info_request.id, + part: 5, + file_name: 'interesting.html', + skip_cache: 1 } expect(response.body).to match('dull') end @@ -127,11 +127,11 @@ def show(params = {}) info_request = FactoryBot.create(:info_request_with_html_attachment) get :show, params: { - :incoming_message_id => info_request.incoming_messages.first.id, - :id => info_request.id, - :part => 2, - :file_name => 'http://trying.to.hack', - :skip_cache => 1 + incoming_message_id: info_request.incoming_messages.first.id, + id: info_request.id, + part: 2, + file_name: 'http://trying.to.hack', + skip_cache: 1 } expect(response.status).to eq(303) end @@ -140,11 +140,11 @@ def show(params = {}) info_request = FactoryBot.create(:info_request_with_html_attachment) get :show, params: { - :incoming_message_id => info_request.incoming_messages.first.id, - :id => info_request.id, - :part => 2, - :file_name => 'interesting.html', - :skip_cache => 1 + incoming_message_id: info_request.incoming_messages.first.id, + id: info_request.id, + part: 2, + file_name: 'interesting.html', + skip_cache: 1 } # Nokogiri adds the meta tag; see @@ -165,17 +165,17 @@ def show(params = {}) it "censors attachments downloaded directly" do info_request = FactoryBot.create(:info_request_with_html_attachment) - info_request.censor_rules.create!(:text => 'dull', - :replacement => "Mouse", - :last_edit_editor => 'unknown', - :last_edit_comment => 'none') + info_request.censor_rules.create!(text: 'dull', + replacement: "Mouse", + last_edit_editor: 'unknown', + last_edit_comment: 'none') get :show, params: { - :incoming_message_id => info_request.incoming_messages.first.id, - :id => info_request.id, - :part => 2, - :file_name => 'interesting.html', - :skip_cache => 1 + incoming_message_id: info_request.incoming_messages.first.id, + id: info_request.id, + part: 2, + file_name: 'interesting.html', + skip_cache: 1 } expect(response.media_type).to eq('text/html') expect(response.body).to have_content "Mouse" @@ -183,17 +183,17 @@ def show(params = {}) it "should censor with rules on the user (rather than the request)" do info_request = FactoryBot.create(:info_request_with_html_attachment) - info_request.user.censor_rules.create!(:text => 'dull', - :replacement => "Mouse", - :last_edit_editor => 'unknown', - :last_edit_comment => 'none') + info_request.user.censor_rules.create!(text: 'dull', + replacement: "Mouse", + last_edit_editor: 'unknown', + last_edit_comment: 'none') get :show, params: { - :incoming_message_id => info_request.incoming_messages.first.id, - :id => info_request.id, - :part => 2, - :file_name => 'interesting.html', - :skip_cache => 1 + incoming_message_id: info_request.incoming_messages.first.id, + id: info_request.id, + part: 2, + file_name: 'interesting.html', + skip_cache: 1 } expect(response.media_type).to eq('text/html') expect(response.body).to have_content "Mouse" @@ -204,11 +204,11 @@ def show(params = {}) expect { get :show, params: { - :incoming_message_id => info_request.incoming_messages.first.id, - :id => info_request.id, - :part => 2, - :file_name => 'interesting.pdf', - :skip_cache => 1 + incoming_message_id: info_request.incoming_messages.first.id, + id: info_request.id, + part: 2, + file_name: 'interesting.pdf', + skip_cache: 1 } }.to raise_error ActiveRecord::RecordNotFound end @@ -271,11 +271,10 @@ def show(params = {}) let(:info_request) { FactoryBot.create(:info_request_with_incoming_attachments) } def get_html_attachment(params = {}) - default_params = { :incoming_message_id => - info_request.incoming_messages.first.id, - :id => info_request.id, - :part => 2, - :file_name => 'interesting.pdf.html' } + default_params = { incoming_message_id: info_request.incoming_messages.first.id, + id: info_request.id, + part: 2, + file_name: 'interesting.pdf.html' } get :show_as_html, params: default_params.merge(params) end @@ -299,14 +298,14 @@ def get_html_attachment(params = {}) it "should return 404 for ugly URLs containing a request id that isn't an integer" do ugly_id = "55195" - expect { get_html_attachment(:id => ugly_id) } + expect { get_html_attachment(id: ugly_id) } .to raise_error(ActiveRecord::RecordNotFound) end it "should return 404 for ugly URLs contain a request id that isn't an integer, even if the integer prefix refers to an actual request" do ugly_id = "#{FactoryBot.create(:info_request).id}95" - expect { get_html_attachment(:id => ugly_id) } + expect { get_html_attachment(id: ugly_id) } .to raise_error(ActiveRecord::RecordNotFound) end @@ -315,10 +314,10 @@ def get_html_attachment(params = {}) expect { get :show_as_html, params: { - :incoming_message_id => info_request.incoming_messages.first.id, - :id => info_request.id, - :part => 2, - :file_name => 'interesting.pdf.html' + incoming_message_id: info_request.incoming_messages.first.id, + id: info_request.id, + part: 2, + file_name: 'interesting.pdf.html' } }.to raise_error ActiveRecord::RecordNotFound end diff --git a/spec/controllers/comment_controller_spec.rb b/spec/controllers/comment_controller_spec.rb index 4ba7b71b8b..77624b40a5 100644 --- a/spec/controllers/comment_controller_spec.rb +++ b/spec/controllers/comment_controller_spec.rb @@ -14,11 +14,11 @@ it 'returns a 404 when the info request is embargoed' do expect { post :new, params: { - :url_title => embargoed_request.url_title, - :comment => { :body => "Some content" }, - :type => 'request', - :submitted_comment => 1, - :preview => 1 + url_title: embargoed_request.url_title, + comment: { body: "Some content" }, + type: 'request', + submitted_comment: 1, + preview: 1 } }.to raise_error ActiveRecord::RecordNotFound end @@ -32,11 +32,11 @@ it 'returns a 404 when the info request is embargoed' do expect { post :new, params: { - :url_title => embargoed_request.url_title, - :comment => { :body => "Some content" }, - :type => 'request', - :submitted_comment => 1, - :preview => 1 + url_title: embargoed_request.url_title, + comment: { body: "Some content" }, + type: 'request', + submitted_comment: 1, + preview: 1 } }.to raise_error ActiveRecord::RecordNotFound end @@ -49,11 +49,11 @@ it 'allows them to comment' do post :new, params: { - :url_title => embargoed_request.url_title, - :comment => { :body => "Some content" }, - :type => 'request', - :submitted_comment => 1, - :preview => 1 + url_title: embargoed_request.url_title, + comment: { body: "Some content" }, + type: 'request', + submitted_comment: 1, + preview: 1 } expect(response).to be_successful end @@ -63,11 +63,11 @@ it "should give an error and render 'new' template when body text is just some whitespace" do post :new, params: { - :url_title => info_requests(:naughty_chicken_request).url_title, - :comment => { :body => " " }, - :type => 'request', - :submitted_comment => 1, - :preview => 1 + url_title: info_requests(:naughty_chicken_request).url_title, + comment: { body: " " }, + type: 'request', + submitted_comment: 1, + preview: 1 } expect(assigns[:comment].errors[:body]).not_to be_nil expect(response).to render_template('new') @@ -76,27 +76,26 @@ it "should show preview when input is good" do post :new, params: { - :url_title => info_requests(:naughty_chicken_request).url_title, - :comment => { - :body => - "A good question, but why not also ask about nice chickens?" - }, :type => 'request', - :submitted_comment => 1, - :preview => 1 + url_title: info_requests(:naughty_chicken_request).url_title, + comment: { + body: "A good question, but why not also ask about nice chickens?" + }, type: 'request', + submitted_comment: 1, + preview: 1 } expect(response).to render_template('preview') end it "should redirect to sign in page when input is good and nobody is logged in" do - params = { :url_title => info_requests(:naughty_chicken_request).url_title, - :comment => { :body => "A good question, but why not also ask about nice chickens?" }, - :type => 'request', - :submitted_comment => 1, - :preview => 0 + params = { url_title: info_requests(:naughty_chicken_request).url_title, + comment: { body: "A good question, but why not also ask about nice chickens?" }, + type: 'request', + submitted_comment: 1, + preview: 0 } post :new, params: params expect(response). - to redirect_to(signin_path(:token => get_last_post_redirect.token)) + to redirect_to(signin_path(token: get_last_post_redirect.token)) # post_redirect.post_params.should == params # TODO: get this working. there's a : vs '' problem amongst others end @@ -105,28 +104,31 @@ post :new, params: { - :url_title => info_requests(:naughty_chicken_request).url_title, - :comment => { - :body => - "A good question, but why not also ask about nice chickens?" + url_title: info_requests(:naughty_chicken_request).url_title, + comment: { + body: "A good question, but why not also ask about nice chickens?" }, - :type => 'request', - :submitted_comment => 1, - :preview => 0 + type: 'request', + submitted_comment: 1, + preview: 0 } - comment_array = Comment.where(:body => "A good question, but why not " \ + comment_array = Comment.where(body: "A good question, but why not " \ "also ask about nice chickens?") expect(comment_array.size).to eq(1) comment = comment_array[0] expect(ActionMailer::Base.deliveries.size).to eq(0) - expect(response).to redirect_to(:controller => 'request', :action => 'show', :url_title => info_requests(:naughty_chicken_request).url_title) + expect(response).to redirect_to(controller: 'request', action: 'show', url_title: info_requests(:naughty_chicken_request).url_title) end it 'errors if the same comment is submitted twice' do user = FactoryBot.build(:user) + + # Ignore rate limiting + allow_any_instance_of(User).to receive(:can_make_comments?).and_return(true) + info_request = FactoryBot.build(:info_request, user: user) comment = FactoryBot.create(:comment, info_request: info_request, user: user) @@ -147,11 +149,11 @@ info_request = info_requests(:spam_1_request) post :new, params: { - :url_title => info_request.url_title, - :comment => { :body => "I demand to be heard!" }, - :type => 'request', - :submitted_comment => 1, - :preview => 0 + url_title: info_request.url_title, + comment: { body: "I demand to be heard!" }, + type: 'request', + submitted_comment: 1, + preview: 0 } expect(response).to redirect_to(show_request_path(info_request.url_title)) @@ -164,11 +166,11 @@ info_request = info_requests(:fancy_dog_request) post :new, params: { - :url_title => info_request.url_title, - :comment => { :body => "I demand to be heard!" }, - :type => 'request', - :submitted_comment => 1, - :preview => 0 + url_title: info_request.url_title, + comment: { body: "I demand to be heard!" }, + type: 'request', + submitted_comment: 1, + preview: 0 } expect(response).to redirect_to(show_request_path(info_request.url_title)) @@ -179,11 +181,11 @@ expected = "Updated text" post :new, params: { - :url_title => info_requests(:naughty_chicken_request).url_title, - :comment => { :body => expected }, - :type => 'request', - :submitted_comment => 1, - :reedit => 1 + url_title: info_requests(:naughty_chicken_request).url_title, + comment: { body: expected }, + type: 'request', + submitted_comment: 1, + reedit: 1 } expect(assigns[:comment].body).to eq(expected) expect(response).to render_template('new') @@ -221,9 +223,9 @@ describe 'when handling a comment that looks like spam' do let(:user) { FactoryBot.create(:user, - :locale => 'en', - :name => 'bob', - :confirmed_not_spam => false) } + locale: 'en', + name: 'bob', + confirmed_not_spam: false) } let(:body) { FactoryBot.create(:public_body) } let(:request) { FactoryBot.create(:info_request) } @@ -237,13 +239,13 @@ sign_in user post :new, params: { - :url_title => request.url_title, - :comment => { - :body => "[HD] Watch Jason Bourne Online free MOVIE Full-HD" + url_title: request.url_title, + comment: { + body: "[HD] Watch Jason Bourne Online free MOVIE Full-HD" }, - :type => 'request', - :submitted_comment => 1, - :preview => 0 + type: 'request', + submitted_comment: 1, + preview: 0 } mail = ActionMailer::Base.deliveries.first expect(mail.subject).to match(/spam annotation from user #{ user.id }/) @@ -253,13 +255,13 @@ sign_in user post :new, params: { - :url_title => request.url_title, - :comment => { - :body => "[HD] Watch Jason Bourne Online free MOVIE Full-HD" + url_title: request.url_title, + comment: { + body: "[HD] Watch Jason Bourne Online free MOVIE Full-HD" }, - :type => 'request', - :submitted_comment => 1, - :preview => 0 + type: 'request', + submitted_comment: 1, + preview: 0 } expect(flash[:error]) .to eq("Sorry, we're currently unable to add your annotation. Please try again later.") @@ -269,13 +271,13 @@ sign_in user post :new, params: { - :url_title => request.url_title, - :comment => { - :body => "[HD] Watch Jason Bourne Online free MOVIE Full-HD" + url_title: request.url_title, + comment: { + body: "[HD] Watch Jason Bourne Online free MOVIE Full-HD" }, - :type => 'request', - :submitted_comment => 1, - :preview => 0 + type: 'request', + submitted_comment: 1, + preview: 0 } expect(response).to render_template('new') end @@ -286,13 +288,13 @@ sign_in user post :new, params: { - :url_title => request.url_title, - :comment => { - :body => "[HD] Watch Jason Bourne Online free MOVIE Full-HD" + url_title: request.url_title, + comment: { + body: "[HD] Watch Jason Bourne Online free MOVIE Full-HD" }, - :type => 'request', - :submitted_comment => 1, - :preview => 0 + type: 'request', + submitted_comment: 1, + preview: 0 } expect(response).to redirect_to show_request_path(request.url_title) end @@ -309,13 +311,13 @@ sign_in user post :new, params: { - :url_title => request.url_title, - :comment => { - :body => "[HD] Watch Jason Bourne Online free MOVIE Full-HD" + url_title: request.url_title, + comment: { + body: "[HD] Watch Jason Bourne Online free MOVIE Full-HD" }, - :type => 'request', - :submitted_comment => 1, - :preview => 0 + type: 'request', + submitted_comment: 1, + preview: 0 } mail = ActionMailer::Base.deliveries.first expect(mail.subject).to match(/spam annotation from user #{ user.id }/) @@ -325,13 +327,13 @@ sign_in user post :new, params: { - :url_title => request.url_title, - :comment => { - :body => "[HD] Watch Jason Bourne Online free MOVIE Full-HD" + url_title: request.url_title, + comment: { + body: "[HD] Watch Jason Bourne Online free MOVIE Full-HD" }, - :type => 'request', - :submitted_comment => 1, - :preview => 0 + type: 'request', + submitted_comment: 1, + preview: 0 } expect(response).to redirect_to show_request_path(request.url_title) end @@ -351,8 +353,8 @@ end it 'should be successful' do - get :new, params: { :url_title => @external_request.url_title, - :type => 'request' } + get :new, params: { url_title: @external_request.url_title, + type: 'request' } expect(response).to be_successful end @@ -369,8 +371,8 @@ it "sets @in_pro_area" do sign_in pro_user with_feature_enabled(:alaveteli_pro) do - get :new, params: { :url_title => embargoed_request.url_title, - :type => 'request' } + get :new, params: { url_title: embargoed_request.url_title, + type: 'request' } expect(assigns[:in_pro_area]).to eq true end end diff --git a/spec/controllers/concerns/hashable_params_spec.rb b/spec/controllers/concerns/hashable_params_spec.rb index bc354e3e0b..4c60da887a 100644 --- a/spec/controllers/concerns/hashable_params_spec.rb +++ b/spec/controllers/concerns/hashable_params_spec.rb @@ -29,7 +29,7 @@ let(:raw_params) { ActionController::Parameters.new(params_hash) } it 'does not strip unpermitted keys' do - expect(subject.keys).to match_array(['foo', 'bar']) + expect(subject.keys).to match_array(%w[foo bar]) end it 'returns a hash' do diff --git a/spec/controllers/concerns/translatable_params_spec.rb b/spec/controllers/concerns/translatable_params_spec.rb index a6cdc47ef9..d93dfcea44 100644 --- a/spec/controllers/concerns/translatable_params_spec.rb +++ b/spec/controllers/concerns/translatable_params_spec.rb @@ -5,34 +5,30 @@ describe '#translatable_params' do - let(:keys) { { :translated_keys => [ :name, :locale ], - :general_keys => [ :status ] } } + let(:keys) { { translated_keys: [ :name, :locale ], + general_keys: [ :status ] } } it 'whitelists translatable_params' do - params = { :name => 'Some name', - :status => 'good', - :id => 40, - :translations_attributes => - { :en => - { :locale => 'en', - :name => 'Other name', - :bad => "value" } } } - expected = { :name => 'Some name', - :status => 'good', - :translations_attributes => - { :en => - { :locale => 'en', - :name => 'Other name' } } } + params = { name: 'Some name', + status: 'good', + id: 40, + translations_attributes: { en: { locale: 'en', + name: 'Other name', + bad: "value" } } } + expected = { name: 'Some name', + status: 'good', + translations_attributes: { en: { locale: 'en', + name: 'Other name' } } } params = ActionController::Parameters.new(params) - expect(translatable_params(params, keys)). + expect(translatable_params(params, **keys)). to eq(ActionController::Parameters.new(expected).permit!) end context 'when there are no params' do it 'returns an empty hash' do - expect(translatable_params(nil, keys)).to eq({}) + expect(translatable_params(nil, **keys)).to eq({}) end end @@ -45,48 +41,45 @@ describe '#whitelist' do - let(:keys) { { :translated_keys => [ :name, :locale ], - :general_keys => [ :status ] } } + let(:keys) { { translated_keys: [ :name, :locale ], + general_keys: [ :status ] } } it 'removes a non-whitelisted model param' do - params = { :name => 'Some name', - :status => 'good', - :id => 40 } - expected = { :name => 'Some name', - :status => 'good' } + params = { name: 'Some name', + status: 'good', + id: 40 } + expected = { name: 'Some name', + status: 'good' } params = ActionController::Parameters.new(params) - expect(TranslatableParams::WhitelistedParams.new(keys).whitelist(params)). - to eq(ActionController::Parameters.new(expected).permit!) + expect( + TranslatableParams::WhitelistedParams.new(**keys).whitelist(params) + ).to eq(ActionController::Parameters.new(expected).permit!) end it 'allows id in the translation params' do - params = { :translations_attributes => - { :en => - { :id => 40, - :locale => 'en', - :name => 'Other name' } } } + params = { translations_attributes: { en: { id: 40, + locale: 'en', + name: 'Other name' } } } expected = ActionController::Parameters.new(params).permit! params = params = ActionController::Parameters.new(params) - expect(TranslatableParams::WhitelistedParams.new(keys).whitelist(params.dup)). - to eq(expected) + expect( + TranslatableParams::WhitelistedParams.new(**keys).whitelist(params.dup) + ).to eq(expected) end it 'removes a non-whitelisted translation param' do - params = { :translations_attributes => - { :en => - { :locale => 'en', - :name => 'Other name', - :bad => "value" } } } - expected = { :translations_attributes => - { :en => - { :locale => 'en', - :name => 'Other name' } } } + params = { translations_attributes: { en: { locale: 'en', + name: 'Other name', + bad: "value" } } } + expected = { translations_attributes: { en: { locale: 'en', + name: 'Other name' } } } params = ActionController::Parameters.new(params) - expect(TranslatableParams::WhitelistedParams.new(keys).whitelist(params)). - to eq(ActionController::Parameters.new(expected).permit!) + expect( + TranslatableParams::WhitelistedParams.new(**keys).whitelist(params) + ).to eq(ActionController::Parameters.new(expected).permit!) end end diff --git a/spec/controllers/followups_controller_spec.rb b/spec/controllers/followups_controller_spec.rb index 9b1521c450..50b429302a 100644 --- a/spec/controllers/followups_controller_spec.rb +++ b/spec/controllers/followups_controller_spec.rb @@ -4,7 +4,7 @@ render_views let(:request_user) { FactoryBot.create(:user) } - let(:request) { FactoryBot.create(:info_request_with_incoming, :user => request_user) } + let(:request) { FactoryBot.create(:info_request_with_incoming, user: request_user) } let(:message_id) { request.incoming_messages[0].id } let(:pro_user) { FactoryBot.create(:pro_user) } @@ -14,7 +14,7 @@ it 'raises an ActiveRecord::RecordNotFound error for an embargoed request' do embargoed_request = FactoryBot.create(:embargoed_request) expect { - get :new, params: { :request_id => embargoed_request.id } + get :new, params: { request_id: embargoed_request.id } }.to raise_error(ActiveRecord::RecordNotFound) end end @@ -27,7 +27,7 @@ it 'finds their own embargoed requests' do embargoed_request = FactoryBot.create(:embargoed_request, user: pro_user) - get :new, params: { :request_id => embargoed_request.id } + get :new, params: { request_id: embargoed_request.id } expect(response).to be_successful end @@ -42,7 +42,7 @@ it 'raises an ActiveRecord::RecordNotFound error for other embargoed requests' do embargoed_request = FactoryBot.create(:embargoed_request) expect { - get :new, params: { :request_id => embargoed_request.id } + get :new, params: { request_id: embargoed_request.id } }.to raise_error(ActiveRecord::RecordNotFound) end end @@ -50,8 +50,8 @@ it "displays 'wrong user' message when not logged in as the request owner" do sign_in FactoryBot.create(:user) get :new, params: { - :request_id => request.id, - :incoming_message_id => message_id + request_id: request.id, + incoming_message_id: message_id } expect(response).to render_template('user/wrong_user') end @@ -59,27 +59,27 @@ it "does not allow follow ups to external requests" do sign_in FactoryBot.create(:user) external_request = FactoryBot.create(:external_request) - get :new, params: { :request_id => external_request.id } + get :new, params: { request_id: external_request.id } expect(response).to render_template('followup_bad') expect(assigns[:reason]).to eq('external') end it "redirects to the signin page if not logged in" do - get :new, params: { :request_id => request.id } + get :new, params: { request_id: request.id } expect(response). - to redirect_to(signin_url(:token => get_last_post_redirect.token)) + to redirect_to(signin_url(token: get_last_post_redirect.token)) end it "calls the message a followup if there is an incoming message" do expected_reason = "To send a follow up message to #{request.public_body.name}" - get :new, params: { :request_id => request.id, - :incoming_message_id => message_id } + get :new, params: { request_id: request.id, + incoming_message_id: message_id } expect(get_last_post_redirect.reason_params[:web]).to eq(expected_reason) end it "calls the message a reply if there is no incoming message" do expected_reason = "To reply to #{request.public_body.name}." - get :new, params: { :request_id => request.id } + get :new, params: { request_id: request.id } expect(get_last_post_redirect.reason_params[:web]).to eq(expected_reason) end @@ -90,16 +90,25 @@ end it "shows the followup form" do - get :new, params: { :request_id => request.id } + get :new, params: { request_id: request.id } expect(response).to render_template('new') end it "shows the followup form when replying to an incoming message" do - get :new, params: { :request_id => request.id, - :incoming_message_id => message_id } + get :new, params: { request_id: request.id, + incoming_message_id: message_id } expect(response).to render_template('new') end + context 'the request is still embargoed but the user is no longer pro' do + before { request.create_embargo!(embargo_duration: '3_months') } + + it 'shows the followup form' do + get :new, params: { request_id: request.id } + expect(response).to render_template('new') + end + end + context 'the request has responses' do let(:message_id) { request.incoming_messages[0].id } @@ -112,20 +121,20 @@ end it "offers the opportunity to reply to the main address" do - get :new, params: { :request_id => request.id, - :incoming_message_id => message_id } + get :new, params: { request_id: request.id, + incoming_message_id: message_id } expect(response.body). to have_css("div#other_recipients ul li", - :text => "the main FOI contact address for") + text: "the main FOI contact address for") end it "offers an opportunity to reply to another address" do get :new, params: { - :request_id => request.id, - :incoming_message_id => message_id + request_id: request.id, + incoming_message_id: message_id } expect(response.body). - to have_css("div#other_recipients ul li", :text => "Frob") + to have_css("div#other_recipients ul li", text: "Frob") end end @@ -133,12 +142,12 @@ context "the request is hidden" do let(:hidden_request) do - FactoryBot.create(:info_request_with_incoming, :user => request_user, - :prominence => "hidden") + FactoryBot.create(:info_request_with_incoming, user: request_user, + prominence: "hidden") end it "does not show the form, even to the request owner" do - get :new, params: { :request_id => hidden_request.id } + get :new, params: { request_id: hidden_request.id } expect(response).to render_template('request/hidden') end @@ -146,9 +155,9 @@ incoming_message_id = hidden_request.incoming_messages[0].id expect do get :new, params: { - :request_id => hidden_request.id, - :incoming_message_id => incoming_message_id, - :format => 'json' + request_id: hidden_request.id, + incoming_message_id: incoming_message_id, + format: 'json' } end.to raise_error ActionController::UnknownFormat end @@ -162,7 +171,7 @@ it "does not allow follow ups to external requests" do sign_in FactoryBot.create(:user) external_request = FactoryBot.create(:external_request) - get :new, params: { :request_id => external_request.id } + get :new, params: { request_id: external_request.id } expect(response).to render_template('followup_bad') expect(assigns[:reason]).to eq('external') end @@ -170,7 +179,7 @@ it 'the response code should be successful' do sign_in FactoryBot.create(:user) get :new, params: { - :request_id => FactoryBot.create(:external_request).id + request_id: FactoryBot.create(:external_request).id } expect(response).to be_successful end @@ -186,7 +195,7 @@ it "sets @in_pro_area" do sign_in pro_user with_feature_enabled(:alaveteli_pro) do - get :new, params: { :request_id => embargoed_request.id } + get :new, params: { request_id: embargoed_request.id } expect(assigns[:in_pro_area]).to eq true end end @@ -221,8 +230,8 @@ describe "POST #preview" do let(:dummy_message) do - { :body => "What a useless response! You suck.", - :what_doing => 'normal_sort' } + { body: "What a useless response! You suck.", + what_doing: 'normal_sort' } end context "when not logged in" do @@ -230,20 +239,20 @@ embargoed_request = FactoryBot.create(:embargoed_request) expect { post :preview, params: { - :outgoing_message => dummy_message, - :request_id => embargoed_request.id + outgoing_message: dummy_message, + request_id: embargoed_request.id } }.to raise_error(ActiveRecord::RecordNotFound) end it "redirects to the signin page" do post :preview, params: { - :outgoing_message => dummy_message, - :request_id => request.id, - :incoming_message_id => message_id + outgoing_message: dummy_message, + request_id: request.id, + incoming_message_id: message_id } expect(response). - to redirect_to(signin_url(:token => get_last_post_redirect.token)) + to redirect_to(signin_url(token: get_last_post_redirect.token)) end end @@ -256,8 +265,8 @@ embargoed_request = FactoryBot.create(:embargoed_request, user: pro_user) post :preview, params: { - :outgoing_message => dummy_message, - :request_id => embargoed_request.id + outgoing_message: dummy_message, + request_id: embargoed_request.id } expect(response).to be_successful end @@ -266,8 +275,8 @@ embargoed_request = FactoryBot.create(:embargoed_request) expect { post :preview, params: { - :outgoing_message => dummy_message, - :request_id => embargoed_request.id + outgoing_message: dummy_message, + request_id: embargoed_request.id } }.to raise_error(ActiveRecord::RecordNotFound) end @@ -276,9 +285,9 @@ it "displays a wrong user message when not logged in as the request owner" do sign_in FactoryBot.create(:user) post :preview, params: { - :outgoing_message => dummy_message, - :request_id => request.id, - :incoming_message_id => message_id + outgoing_message: dummy_message, + request_id: request.id, + incoming_message_id: message_id } expect(response).to render_template('user/wrong_user') end @@ -291,12 +300,12 @@ it "displays the edit form with an error when the message body is blank" do post :preview, params: { - :request_id => request.id, - :outgoing_message => { - :body => "", - :what_doing => "normal_sort" + request_id: request.id, + outgoing_message: { + body: "", + what_doing: "normal_sort" }, - :incoming_message_id => message_id + incoming_message_id: message_id } expect(response).to render_template("new") @@ -305,20 +314,20 @@ it "shows a preview when input is good" do post :preview, params: { - :outgoing_message => dummy_message, - :request_id => request.id, - :incoming_message_id => message_id, - :preview => 1 + outgoing_message: dummy_message, + request_id: request.id, + incoming_message_id: message_id, + preview: 1 } expect(response).to render_template('preview') end it "allows re-editing of a preview" do post :preview, params: { - :outgoing_message => dummy_message, - :request_id => request.id, - :incoming_message_id => message_id, - :reedit => "Re-edit this request" + outgoing_message: dummy_message, + request_id: request.id, + incoming_message_id: message_id, + reedit: "Re-edit this request" } expect(response).to render_template('new') end @@ -334,7 +343,7 @@ it "sets @in_pro_area" do sign_in pro_user with_feature_enabled(:alaveteli_pro) do - get :new, params: { :request_id => embargoed_request.id } + get :new, params: { request_id: embargoed_request.id } expect(assigns[:in_pro_area]).to eq true end end @@ -345,8 +354,8 @@ describe "POST #create" do let(:dummy_message) do - { :body => "What a useless response! You suck.", - :what_doing => 'normal_sort' } + { body: "What a useless response! You suck.", + what_doing: 'normal_sort' } end before(:each) do @@ -382,20 +391,20 @@ embargoed_request = FactoryBot.create(:embargoed_request) expect { post :create, params: { - :outgoing_message => dummy_message, - :request_id => embargoed_request.id + outgoing_message: dummy_message, + request_id: embargoed_request.id } }.to raise_error(ActiveRecord::RecordNotFound) end it "redirects to the signin page" do post :create, params: { - :outgoing_message => dummy_message, - :request_id => request.id, - :incoming_message_id => message_id + outgoing_message: dummy_message, + request_id: request.id, + incoming_message_id: message_id } expect(response). - to redirect_to(signin_url(:token => get_last_post_redirect.token)) + to redirect_to(signin_url(token: get_last_post_redirect.token)) end end @@ -407,10 +416,10 @@ it 'finds their own embargoed requests' do embargoed_request = FactoryBot.create(:embargoed_request, user: pro_user) - expected_url = show_request_url(:url_title => embargoed_request.url_title) + expected_url = show_request_url(url_title: embargoed_request.url_title) post :create, params: { - :outgoing_message => dummy_message, - :request_id => embargoed_request.id + outgoing_message: dummy_message, + request_id: embargoed_request.id } expect(response).to redirect_to(expected_url) end @@ -419,8 +428,8 @@ embargoed_request = FactoryBot.create(:embargoed_request) expect { post :create, params: { - :outgoing_message => dummy_message, - :request_id => embargoed_request.id + outgoing_message: dummy_message, + request_id: embargoed_request.id } }.to raise_error(ActiveRecord::RecordNotFound) end @@ -429,18 +438,18 @@ it "only allows the request owner to make a followup" do sign_in FactoryBot.create(:user) post :create, params: { - :outgoing_message => dummy_message, - :request_id => request.id, - :incoming_message_id => message_id + outgoing_message: dummy_message, + request_id: request.id, + incoming_message_id: message_id } expect(response).to render_template('user/wrong_user') end it "gives an error and renders 'show_response' when a body isn't given" do post :create, params: { - :outgoing_message => dummy_message.merge(:body => ''), - :request_id => request.id, - :incoming_message_id => message_id + outgoing_message: dummy_message.merge(body: ''), + request_id: request.id, + incoming_message_id: message_id } expect(assigns[:outgoing_message].errors[:body]). @@ -468,9 +477,9 @@ def send_request it "updates the status for successful followup sends" do post :create, params: { - :outgoing_message => dummy_message, - :request_id => request.id, - :incoming_message_id => message_id + outgoing_message: dummy_message, + request_id: request.id, + incoming_message_id: message_id } expect(request.reload.described_state).to eq('waiting_response') @@ -504,9 +513,9 @@ def send_request request.set_described_state('waiting_clarification') post :create, params: { - :outgoing_message => dummy_message, - :request_id => request.id, - :incoming_message_id => message_id + outgoing_message: dummy_message, + request_id: request.id, + incoming_message_id: message_id } expect(request.reload.get_last_public_response_event.calculated_state). @@ -515,34 +524,34 @@ def send_request it "redirects to the request page" do post :create, params: { - :outgoing_message => dummy_message, - :request_id => request.id, - :incoming_message_id => message_id + outgoing_message: dummy_message, + request_id: request.id, + incoming_message_id: message_id } expect(response). - to redirect_to(show_request_url(:url_title => request.url_title)) + to redirect_to(show_request_url(url_title: request.url_title)) end it "displays the a confirmation once the message has been sent" do post :create, params: { - :outgoing_message => dummy_message, - :request_id => request.id, - :incoming_message_id => message_id + outgoing_message: dummy_message, + request_id: request.id, + incoming_message_id: message_id } expect(flash[:notice]).to eq('Your follow up message has been sent on its way.') end it "displays an error if the request has been closed to new responses" do closed_request = FactoryBot.create(:info_request_with_incoming, - :user => request_user, - :allow_new_responses_from => "nobody") + user: request_user, + allow_new_responses_from: "nobody") post :create, params: { - :outgoing_message => dummy_message, - :request_id => closed_request.id, - :incoming_message_id => closed_request.incoming_messages[0].id + outgoing_message: dummy_message, + request_id: closed_request.id, + incoming_message_id: closed_request.incoming_messages[0].id } deliveries = ActionMailer::Base.deliveries expect(deliveries.size).to eq(0) @@ -560,15 +569,15 @@ def send_request before(:each) do post :create, params: { - :outgoing_message => dummy_message, - :request_id => request.id, - :incoming_message_id => message_id + outgoing_message: dummy_message, + request_id: request.id, + incoming_message_id: message_id } post :create, params: { - :outgoing_message => dummy_message, - :request_id => request.id, - :incoming_message_id => message_id + outgoing_message: dummy_message, + request_id: request.id, + incoming_message_id: message_id } end diff --git a/spec/controllers/general_controller_spec.rb b/spec/controllers/general_controller_spec.rb index 5f6246ac4a..76ba24baff 100644 --- a/spec/controllers/general_controller_spec.rb +++ b/spec/controllers/general_controller_spec.rb @@ -21,69 +21,54 @@ expect(response.media_type).to eq('application/json') end end -end - -RSpec.describe GeneralController, "when trying to show the blog" do - it "should fail silently if the blog is returning an error" do - allow(AlaveteliConfiguration).to receive(:blog_feed). - and_return("http://blog.example.com") - stub_request(:get, %r|blog.example.com|).to_return(status: 500) - get :blog - expect(response.status).to eq(200) - expect(assigns[:blog_items].count).to eq(0) - end -end -RSpec.describe GeneralController, 'when getting the blog feed' do - - before do - allow(AlaveteliConfiguration).to receive(:blog_feed).and_return("http://blog.example.com") - # Don't call out to external url during tests - allow(controller).to receive(:quietly_try_to_open).and_return('') - end + describe 'GET blog' do + let(:blog) { Blog.new } - it 'should add a lang param correctly to a url with no querystring' do - get :blog - expect(assigns[:feed_url]).to eq("http://blog.example.com?lang=en") - end + before do + allow(Blog).to receive(:new).and_return(blog) + end - it 'should add a lang param correctly to a url with an existing querystring' do - allow(AlaveteliConfiguration).to receive(:blog_feed).and_return("http://blog.example.com?alt=rss") - get :blog - expect(assigns[:feed_url]).to eq("http://blog.example.com?alt=rss&lang=en") - end + context 'when feed is configured' do + render_views - it 'should parse an item from an example feed' do - allow(controller).to receive(:quietly_try_to_open).and_return(load_file_fixture("blog_feed.atom")) - get :blog - expect(assigns[:blog_items].count).to eq(1) - end + before do + allow(AlaveteliConfiguration).to receive(:blog_feed). + and_return('http://blog.example.com') + allow(blog).to receive(:quietly_try_to_open). + and_return(load_file_fixture('blog_feed.atom')) + end - context 'if no feed is configured' do + it 'assigns blog' do + get :blog + expect(assigns[:blog]).to eq(blog) + end - before do - allow(AlaveteliConfiguration).to receive(:blog_feed).and_return('') - end + it 'assigns feed_autodetect' do + get :blog + expect(assigns[:feed_autodetect]).to eq(blog.feeds) + end - it 'should raise an ActiveRecord::RecordNotFound error' do - expect { + it 'escapes any javascript from the entries' do get :blog - }.to raise_error(ActiveRecord::RecordNotFound) + expect(response.body).not_to include( + '' + ) + end end - end - - context 'when the blog has entries' do - render_views + context 'when feed is not configured' do + before do + allow(AlaveteliConfiguration).to receive(:blog_feed).and_return('') + end - it 'should escape any javascript from the entries' do - allow(controller).to receive(:quietly_try_to_open).and_return(load_file_fixture("blog_feed.atom")) - get :blog - expect(response.body).not_to include('') + it 'should raise an ActiveRecord::RecordNotFound error' do + expect { + get :blog + }.to raise_error(ActiveRecord::RecordNotFound) + end end - end - end RSpec.describe GeneralController, "when showing the frontpage" do @@ -91,16 +76,16 @@ render_views before do - public_body = mock_model(PublicBody, :name => "Example Public Body", - :url_name => 'example_public_body') - info_request = mock_model(InfoRequest, :public_body => public_body, - :title => 'Example Request', - :url_title => 'example_request') - info_request_event = mock_model(InfoRequestEvent, :created_at => Time.zone.now, - :info_request => info_request, - :described_at => Time.zone.now, - :search_text_main => 'example text') - xapian_result = double('xapian result', :results => [{:model => info_request_event}]) + public_body = mock_model(PublicBody, name: "Example Public Body", + url_name: 'example_public_body') + info_request = mock_model(InfoRequest, public_body: public_body, + title: 'Example Request', + url_title: 'example_request') + info_request_event = mock_model(InfoRequestEvent, created_at: Time.zone.now, + info_request: info_request, + described_at: Time.zone.now, + search_text_main: 'example text') + xapian_result = double('xapian result', results: [{model: info_request_event}]) allow(controller).to receive(:perform_search).and_return(xapian_result) end @@ -159,8 +144,8 @@ describe 'when using locales' do it "should use our test PO files rather than the application one" do - get :frontpage, params: { :locale => 'es' } - expect(response.body).to match /XOXO/ + get :frontpage, params: { locale: 'es' } + expect(response.body).to match(/XOXO/) end end @@ -193,7 +178,7 @@ it "should render the front page successfully with post_redirect if post_params is not set" do session[:post_redirect_token] = 'orphaned_token' - get :frontpage, params: { :post_redirect => 1 } + get :frontpage, params: { post_redirect: 1 } expect(response).to be_successful end @@ -226,22 +211,22 @@ end it "should redirect from search query URL to pretty URL" do - post :search_redirect, params: { :query => "mouse" } # query hidden in POST parameters - expect(response).to redirect_to(:action => 'search', :combined => "mouse", :view => "all") # URL /search/:query/all + post :search_redirect, params: { query: "mouse" } # query hidden in POST parameters + expect(response).to redirect_to(action: 'search', combined: "mouse", view: "all") # URL /search/:query/all end it "should find info request when searching for '\"fancy dog\"'" do - get :search, params: { :combined => '"fancy dog"' } + get :search, params: { combined: '"fancy dog"' } expect(response).to render_template('search') expect(assigns[:xapian_requests].matches_estimated).to eq(1) expect(assigns[:xapian_requests].results.size).to eq(1) expect(assigns[:xapian_requests].results[0][:model]).to eq(info_request_events(:useless_outgoing_message_event)) - assigns[:xapian_requests].words_to_highlight == ["fancy", "dog"] + assigns[:xapian_requests].words_to_highlight == %w[fancy dog] end it "should find public body and incoming message when searching for 'geraldine quango'" do - get :search, params: { :combined => 'geraldine quango' } + get :search, params: { combined: 'geraldine quango' } expect(response).to render_template('search') expect(assigns[:xapian_requests].matches_estimated).to eq(1) @@ -254,64 +239,62 @@ end it "should filter results based on end of URL being 'all'" do - get :search, params: { :combined => "bob/all" } + get :search, params: { combined: "bob/all" } expect(assigns[:xapian_requests].results.map { |x| x[:model] }).to match_array([ info_request_events(:useless_outgoing_message_event), info_request_events(:silly_outgoing_message_event), info_request_events(:useful_incoming_message_event), - info_request_events(:another_useful_incoming_message_event), + info_request_events(:another_useful_incoming_message_event) ]) expect(assigns[:xapian_users].results.map { |x| x[:model] }).to eq([users(:bob_smith_user)]) expect(assigns[:xapian_bodies].results).to eq([]) end it "should filter results based on end of URL being 'users'" do - get :search, params: { :combined => "bob/users" } + get :search, params: { combined: "bob/users" } expect(assigns[:xapian_requests]).to eq(nil) expect(assigns[:xapian_users].results.map { |x| x[:model] }).to eq([users(:bob_smith_user)]) expect(assigns[:xapian_bodies]).to eq(nil) end it 'should highlight words for a user-only request' do - get :search, params: { :combined => "bob/users" } + get :search, params: { combined: "bob/users" } expect(assigns[:highlight_words]).to eq([/\b(bob)\w*\b/iu, /\b(bob)\b/iu]) end it 'should show spelling corrections for a user-only request' do - get :search, params: { :combined => "rob/users" } + get :search, params: { combined: "rob/users" } expect(assigns[:spelling_correction]).to eq('bob') expect(response.body).to include('did_you_mean') end it "should filter results based on end of URL being 'requests'" do - get :search, params: { :combined => "bob/requests" } + get :search, params: { combined: "bob/requests" } expect(assigns[:xapian_requests].results.map { |x|x[:model] }).to match_array([ info_request_events(:useless_outgoing_message_event), info_request_events(:silly_outgoing_message_event), info_request_events(:useful_incoming_message_event), - info_request_events(:another_useful_incoming_message_event), + info_request_events(:another_useful_incoming_message_event) ]) expect(assigns[:xapian_users]).to eq(nil) expect(assigns[:xapian_bodies]).to eq(nil) end it "should filter results based on end of URL being 'bodies'" do - get :search, params: { :combined => "quango/bodies" } + get :search, params: { combined: "quango/bodies" } expect(assigns[:xapian_requests]).to eq(nil) expect(assigns[:xapian_users]).to eq(nil) expect(assigns[:xapian_bodies].results.map { |x|x[:model] }).to eq([public_bodies(:geraldine_public_body)]) end it 'should prioritise direct matches of public body names' do - FactoryBot. - create(:public_body, - name: 'Cardiff Business Technology Centre Limited', - notes: 'Something something cardiff council something else.') + FactoryBot.create(:public_body, :with_note, + name: 'Cardiff Business Technology Centre Limited', + note_body: 'Something cardiff council something else.') - FactoryBot. - create(:public_body, - name: 'Cardiff and Vale of Glamorgan Community Health Council', - notes: 'Another notes mentioning Cardiff Council.') + FactoryBot.create(:public_body, :with_note, + name: 'Cardiff and Vale of Glamorgan Health Council', + note_body: 'Another notes mentioning Cardiff Council.') FactoryBot.create(:public_body, name: 'Cardiff Council') @@ -325,19 +308,19 @@ end it 'should show "Browse all" link if there are no results for a search restricted to bodies' do - get :search, params: { :combined => "noresultsshouldbefound/bodies" } + get :search, params: { combined: "noresultsshouldbefound/bodies" } expect(response.body).to include('Browse all') end it "should show help when searching for nothing" do - get :search_redirect, params: { :query => nil } + get :search_redirect, params: { query: nil } expect(response).to render_template('search') expect(assigns[:total_hits]).to be_nil expect(assigns[:query]).to be_nil end it "should not show unconfirmed users" do - get :search, params: { :combined => "unconfirmed/users" } + get :search, params: { combined: "unconfirmed/users" } expect(response).to render_template('search') expect(assigns[:xapian_users].results.map { |x|x[:model] }).to eq([]) end @@ -348,41 +331,41 @@ u.save! update_xapian_index - get :search, params: { :combined => "unconfirmed/users" } + get :search, params: { combined: "unconfirmed/users" } expect(response).to render_template('search') expect(assigns[:xapian_users].results.map { |x|x[:model] }).to eq([u]) end it "should show tracking links for requests-only searches" do - get :search, params: { :combined => "bob/requests" } + get :search, params: { combined: "bob/requests" } expect(response.body).to include('Track this search') end it 'should not show high page offsets as these are extremely slow to generate' do expect { - get :search, params: { :combined => 'bob/all', :page => 25 } + get :search, params: { combined: 'bob/all', page: 25 } }.to raise_error(ActiveRecord::RecordNotFound) end it 'should pass xapian error messages to flash and redirect to a blank search page' do error_text = "Your query was not quite right. QueryParserError: Syntax: AND " - get :search, params: { :combined => "test AND" } + get :search, params: { combined: "test AND" } expect(flash[:error]).to eq(error_text) - expect(response).to redirect_to(:action => 'search', :combined => "") + expect(response).to redirect_to(action: 'search', combined: "") end context "when passed a non-HTML request" do it "raises unknown format error" do expect do - get :search, params: { :combined => '"fancy dog"', :format => :json } + get :search, params: { combined: '"fancy dog"', format: :json } end.to raise_error ActionController::UnknownFormat end it "does not call the search" do expect(controller).not_to receive(:perform_search) begin - get :search, params: { :combined => '"fancy dog"', :format => :json } + get :search, params: { combined: '"fancy dog"', format: :json } rescue ActionController::UnknownFormat # noop end diff --git a/spec/controllers/health_checks_controller_spec.rb b/spec/controllers/health/checks_controller_spec.rb similarity index 61% rename from spec/controllers/health_checks_controller_spec.rb rename to spec/controllers/health/checks_controller_spec.rb index b5f6aad67a..9568ea9f23 100644 --- a/spec/controllers/health_checks_controller_spec.rb +++ b/spec/controllers/health/checks_controller_spec.rb @@ -1,26 +1,22 @@ require 'spec_helper' -RSpec.describe HealthChecksController do - +RSpec.describe Health::ChecksController do describe 'GET index' do - it 'returns a 200 if all health checks pass' do - allow(HealthChecks).to receive_messages(:ok? => true) + allow(HealthChecks).to receive_messages(ok?: true) get :index expect(response.status).to eq(200) end it 'returns a 500 if the health check fails' do - allow(HealthChecks).to receive_messages(:ok? => false) + allow(HealthChecks).to receive_messages(ok?: false) get :index expect(response.status).to eq(500) end it 'does not render a layout' do get :index - expect(response).to render_template(:layout => false) + expect(response).to render_template(layout: false) end - end - end diff --git a/spec/controllers/health/metrics_controller_spec.rb b/spec/controllers/health/metrics_controller_spec.rb new file mode 100644 index 0000000000..7e3d1e9a7f --- /dev/null +++ b/spec/controllers/health/metrics_controller_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' + +RSpec.describe Health::MetricsController do + describe 'GET index' do + it 'returns a 200' do + get :index, format: 'txt' + expect(response.status).to eq(200) + end + + it 'assigns sidekiq_stats' do + get :index, format: 'txt' + expect(assigns[:sidekiq_stats]).to_not be_nil + end + + it 'assigns xapian_queued_jobs' do + get :index, format: 'txt' + expect(assigns[:xapian_queued_jobs]).to_not be_nil + end + + it 'does not render a layout' do + get :index, format: 'txt' + expect(response).to render_template(layout: false) + end + end +end diff --git a/spec/controllers/help_controller_spec.rb b/spec/controllers/help_controller_spec.rb index c816fa13b4..18810286c3 100644 --- a/spec/controllers/help_controller_spec.rb +++ b/spec/controllers/help_controller_spec.rb @@ -28,14 +28,14 @@ context 'when a url_title param is supplied' do it 'assigns the info_request' do - get :unhappy, params: { :url_title => info_request.url_title } + get :unhappy, params: { url_title: info_request.url_title } expect(assigns[:info_request]).to eq info_request end it 'raises an ActiveRecord::RecordNotFound error if the InfoRequest is not found' do expect { - get :unhappy, params: { :url_title => 'something_not_existing' } + get :unhappy, params: { url_title: 'something_not_existing' } }.to raise_error ActiveRecord::RecordNotFound end @@ -43,7 +43,7 @@ is embargoed' do info_request = FactoryBot.create(:embargoed_request) expect { - get :unhappy, params: { :url_title => info_request.url_title } + get :unhappy, params: { url_title: info_request.url_title } }.to raise_error ActiveRecord::RecordNotFound end end @@ -77,7 +77,7 @@ end it 'should render the locale-specific template if available' do - get :contact, params: { :locale => 'es' } + get :contact, params: { locale: 'es' } expect(response.body).to match('contáctenos theme one') end @@ -136,14 +136,14 @@ it 'sends a contact message' do post :contact, params: { - :contact => { - :name => 'Vinny Vanilli', - :email => 'vinny@localhost', - :subject => 'Why do I have such an ace name?', - :comment => '', - :message => "You really should know!!!\n\nVinny" + contact: { + name: 'Vinny Vanilli', + email: 'vinny@localhost', + subject: 'Why do I have such an ace name?', + comment: '', + message: "You really should know!!!\n\nVinny" }, - :submitted_contact_form => 1 + submitted_contact_form: 1 } expect(response).to redirect_to(frontpage_path) @@ -183,14 +183,14 @@ it 'has rudimentary spam protection' do post :contact, params: { - :contact => { - :name => 'Vinny Vanilli', - :email => 'vinny@localhost', - :subject => 'Why do I have such an ace name?', - :comment => 'I AM A SPAMBOT', - :message => "You really should know!!!\n\nVinny" + contact: { + name: 'Vinny Vanilli', + email: 'vinny@localhost', + subject: 'Why do I have such an ace name?', + comment: 'I AM A SPAMBOT', + message: "You really should know!!!\n\nVinny" }, - :submitted_contact_form => 1 + submitted_contact_form: 1 } expect(response).to redirect_to(frontpage_path) @@ -208,13 +208,13 @@ it 'does not accept a form without a comment param' do post :contact, params: { - :contact => { - :name => 'Vinny Vanilli', - :email => 'vinny@localhost', - :subject => 'Why do I have such an ace name?', - :message => "You really should know!!!\n\nVinny" + contact: { + name: 'Vinny Vanilli', + email: 'vinny@localhost', + subject: 'Why do I have such an ace name?', + message: "You really should know!!!\n\nVinny" }, - :submitted_contact_form => 1 + submitted_contact_form: 1 } expect(response).to redirect_to(frontpage_path) end diff --git a/spec/controllers/info_request_batch_controller_spec.rb b/spec/controllers/info_request_batch_controller_spec.rb index 8533279e9c..97c73563da 100644 --- a/spec/controllers/info_request_batch_controller_spec.rb +++ b/spec/controllers/info_request_batch_controller_spec.rb @@ -6,11 +6,11 @@ let(:second_public_body) { FactoryBot.create(:public_body) } let(:bodies) { [first_public_body, second_public_body] } let!(:info_request_batch) do - FactoryBot.create(:info_request_batch, :title => 'Matched title', - :body => 'Matched body', - :public_bodies => bodies) + FactoryBot.create(:info_request_batch, title: 'Matched title', + body: 'Matched body', + public_bodies: bodies) end - let(:params) { {:id => info_request_batch.id} } + let(:params) { {id: info_request_batch.id} } let(:action) { get :show, params: params } let(:pro_user) { FactoryBot.create(:pro_user) } @@ -34,18 +34,18 @@ describe 'assigning @info_requests' do context 'when the batch has been sent' do let!(:first_request) do - FactoryBot.create(:info_request, :info_request_batch => info_request_batch, - :public_body => first_public_body) + FactoryBot.create(:info_request, info_request_batch: info_request_batch, + public_body: first_public_body) end let!(:second_request) do - FactoryBot.create(:info_request, :info_request_batch => info_request_batch, - :public_body => second_public_body) + FactoryBot.create(:info_request, info_request_batch: info_request_batch, + public_body: second_public_body) end let!(:hidden_request) do - FactoryBot.create(:hidden_request, :info_request_batch => info_request_batch) + FactoryBot.create(:hidden_request, info_request_batch: info_request_batch) end let!(:backpage_request) do - FactoryBot.create(:backpage_request, :info_request_batch => info_request_batch) + FactoryBot.create(:backpage_request, info_request_batch: info_request_batch) end before do diff --git a/spec/controllers/one_time_passwords_controller_spec.rb b/spec/controllers/one_time_passwords_controller_spec.rb index c9e5fa7a9d..84a98025c1 100644 --- a/spec/controllers/one_time_passwords_controller_spec.rb +++ b/spec/controllers/one_time_passwords_controller_spec.rb @@ -13,7 +13,7 @@ get :show expect(response). - to redirect_to(signin_path(:token => PostRedirect.last.token)) + to redirect_to(signin_path(token: PostRedirect.last.token)) end it 'assigns the signed in user' do @@ -53,7 +53,7 @@ it 'redirects to the sign-in page without a signed in user' do post :create expect(response). - to redirect_to(signin_path(:token => PostRedirect.last.token)) + to redirect_to(signin_path(token: PostRedirect.last.token)) end it 'assigns the signed in user' do @@ -129,7 +129,7 @@ it 'redirects to the sign-in page without a signed in user' do put :update expect(response). - to redirect_to(signin_path(:token => PostRedirect.last.token)) + to redirect_to(signin_path(token: PostRedirect.last.token)) end it 'assigns the signed in user' do @@ -140,7 +140,7 @@ end it 'regenerates the otp_code' do - user = FactoryBot.create(:user, :otp_enabled => true) + user = FactoryBot.create(:user, otp_enabled: true) expected = ROTP::HOTP.new(user.otp_secret_key).at(2) sign_in user put :update @@ -148,21 +148,21 @@ end it 'sets a successful notification message' do - user = FactoryBot.create(:user, :otp_enabled => true) + user = FactoryBot.create(:user, otp_enabled: true) sign_in user put :update expect(flash[:notice]).to eq('Two factor one time passcode updated') end it 'redirects back to #show on success' do - user = FactoryBot.create(:user, :otp_enabled => true) + user = FactoryBot.create(:user, otp_enabled: true) sign_in user put :update expect(response).to redirect_to(one_time_password_path) end it 'renders #show on failure' do - user = FactoryBot.create(:user, :otp_enabled => true) + user = FactoryBot.create(:user, otp_enabled: true) allow_any_instance_of(User). to receive(:increment!).and_return(false) sign_in user @@ -171,7 +171,7 @@ end it 'warns the user on failure' do - user = FactoryBot.create(:user, :otp_enabled => true) + user = FactoryBot.create(:user, otp_enabled: true) allow_any_instance_of(User). to receive(:increment!).and_return(false) sign_in user @@ -200,7 +200,7 @@ user = FactoryBot.create(:user) delete :destroy expect(response). - to redirect_to(signin_path(:token => PostRedirect.last.token)) + to redirect_to(signin_path(token: PostRedirect.last.token)) end it 'assigns the signed in user' do diff --git a/spec/controllers/outgoing_messages/delivery_statuses_controller_spec.rb b/spec/controllers/outgoing_messages/delivery_statuses_controller_spec.rb index 5b8496b99e..d791a9c6af 100644 --- a/spec/controllers/outgoing_messages/delivery_statuses_controller_spec.rb +++ b/spec/controllers/outgoing_messages/delivery_statuses_controller_spec.rb @@ -10,7 +10,7 @@ 2015-11-22 00:37:00 [17619] 1a0IeK-0004aB-Na <= request@example.com U=alaveteli P=local S=3973 id=ogm-jh217mwec@example.com@localhost T="RE: An FOI Request about Potatoes 15" from for body@example.com body@example.com\n EOF lines.map do |line| - mock_model(MailServerLog, line: line, :is_owning_user? => true) + mock_model(MailServerLog, line: line, is_owning_user?: true) end end diff --git a/spec/controllers/password_changes_controller_spec.rb b/spec/controllers/password_changes_controller_spec.rb index 48f9ec47b6..5da8077c59 100644 --- a/spec/controllers/password_changes_controller_spec.rb +++ b/spec/controllers/password_changes_controller_spec.rb @@ -5,7 +5,7 @@ describe 'GET new' do it 'assigns the pretoken if supplied' do - get :new, params: { :pretoken => 'abcdef' } + get :new, params: { pretoken: 'abcdef' } expect(assigns[:pretoken]).to eq('abcdef') end @@ -15,7 +15,7 @@ end it 'assigns nil to the pretoken if blank' do - get :new, params: { :pretoken => '' } + get :new, params: { pretoken: '' } expect(assigns[:pretoken]).to eq(nil) end @@ -53,8 +53,8 @@ user = FactoryBot.create(:user) sign_in user post :create, params: { - :password_change_user => { - :email => 'hacker@localhost' + password_change_user: { + email: 'hacker@localhost' } } expect(assigns[:password_change_user]).to eq(user) @@ -82,7 +82,7 @@ it 'assigns the user' do user = FactoryBot.create(:user) post :create, params: { - :password_change_user => { :email => user.email } + password_change_user: { email: user.email } } expect(assigns[:password_change_user]).to eq(user) end @@ -90,7 +90,7 @@ it 'finds the user if the email case is different' do user = FactoryBot.create(:user) post :create, params: { - :password_change_user => { :email => user.email.upcase } + password_change_user: { email: user.email.upcase } } expect(assigns[:password_change_user]).to eq(user) end @@ -109,16 +109,16 @@ circumstance: 'change_password' } post :create, params: { - :password_change_user => { :email => user.email } + password_change_user: { email: user.email } } post_redirect = PostRedirect.last expected_attrs[:uri] = edit_password_change_url(post_redirect.token) - post_redirect_attrs = { :uri => post_redirect.uri, - :post_params => post_redirect.post_params, - :reason_params => post_redirect.reason_params, - :circumstance => post_redirect.circumstance } + post_redirect_attrs = { uri: post_redirect.uri, + post_params: post_redirect.post_params, + reason_params: post_redirect.reason_params, + circumstance: post_redirect.circumstance } expect(post_redirect_attrs).to eq(expected_attrs) end @@ -127,25 +127,25 @@ it 'adds the pretoken to the post redirect uri' do user = FactoryBot.create(:user) - pretoken = PostRedirect.create(:user => user, :uri => '/') + pretoken = PostRedirect.create(user: user, uri: '/') post :create, params: { - :password_change_user => { - :email => user.email + password_change_user: { + email: user.email }, - :pretoken => pretoken.token + pretoken: pretoken.token } post_redirect = PostRedirect.last expected = edit_password_change_url(post_redirect.token, - :pretoken => pretoken.token) + pretoken: pretoken.token) expect(post_redirect.uri).to include(expected) end it 'does not add a blank pretoken to the post redirect uri' do user = FactoryBot.create(:user) - pretoken = PostRedirect.create(:user => user, :uri => '/') + pretoken = PostRedirect.create(user: user, uri: '/') post :create, params: { - :password_change_user => { :email => user.email }, - :pretoken => '' + password_change_user: { email: user.email }, + pretoken: '' } post_redirect = PostRedirect.last expected = edit_password_change_url(post_redirect.token) @@ -158,7 +158,7 @@ user = FactoryBot.create(:user) post :create, params: { - :password_change_user => { :email => user.email } + password_change_user: { email: user.email } } email = ActionMailer::Base.deliveries.last @@ -168,8 +168,8 @@ it 'does not send a confirmation email for an unknown email' do post :create, params: { - :password_change_user => { - :email => 'unknown-email@example.org' + password_change_user: { + email: 'unknown-email@example.org' } } expect(ActionMailer::Base.deliveries.size).to eq(0) @@ -178,15 +178,15 @@ it 'renders the confirmation message' do user = FactoryBot.create(:user) post :create, params: { - :password_change_user => { :email => user.email } + password_change_user: { email: user.email } } expect(response).to render_template(:check_email) end it 'renders the confirmation message for an unknown email' do post :create, params: { - :password_change_user => { - :email => 'unknown-email@example.org' + password_change_user: { + email: 'unknown-email@example.org' } } expect(response).to render_template(:check_email) @@ -196,14 +196,14 @@ msg = "That doesn't look like a valid email address. Please check " \ "you have typed it correctly." post :create, params: { - :password_change_user => { :email => 'invalid-email' } + password_change_user: { email: 'invalid-email' } } expect(flash[:error]).to eq(msg) end it 're-renders the form with an invalid email format' do post :create, params: { - :password_change_user => { :email => 'invalid-email' } + password_change_user: { email: 'invalid-email' } } expect(response).to render_template(:new) end @@ -216,26 +216,26 @@ let(:user) { FactoryBot.create(:user) } let(:post_redirect) do - PostRedirect.create(:user => user, :uri => frontpage_url) + PostRedirect.create(user: user, uri: frontpage_url) end it 'assigns the pretoken if supplied' do - get :edit, params: { :id => post_redirect.token, :pretoken => 'abcdef' } + get :edit, params: { id: post_redirect.token, pretoken: 'abcdef' } expect(assigns[:pretoken]).to eq('abcdef') end it 'assigns nil to the pretoken if not supplied' do - get :edit, params: { :id => post_redirect.token } + get :edit, params: { id: post_redirect.token } expect(assigns[:pretoken]).to eq(nil) end it 'assigns nil to the pretoken if blank' do - get :edit, params: { :id => post_redirect.token, :pretoken => '' } + get :edit, params: { id: post_redirect.token, pretoken: '' } expect(assigns[:pretoken]).to eq(nil) end it 'assigns the user' do - get :edit, params: { :id => post_redirect.token } + get :edit, params: { id: post_redirect.token } expect(assigns[:password_change_user]).to eq(user) end @@ -244,14 +244,14 @@ let(:post_redirect) { PostRedirect.new(user: nil) } it 'redirects to new for the user to enter their email' do - get :edit, params: { :id => post_redirect.token } + get :edit, params: { id: post_redirect.token } expect(response).to redirect_to(new_password_change_path) end it 'redirects to new with a pretoken for the user to enter their email' do - get :edit, params: { :id => post_redirect.token, :pretoken => 'abcdef' } + get :edit, params: { id: post_redirect.token, pretoken: 'abcdef' } expect(response). - to redirect_to(new_password_change_path(:pretoken => 'abcdef')) + to redirect_to(new_password_change_path(pretoken: 'abcdef')) end end @@ -259,7 +259,7 @@ context 'invalid token' do it 'redirects to new to force an email confirmation' do - get :edit, params: { :id => 'invalid' } + get :edit, params: { id: 'invalid' } expect(response).to redirect_to new_password_change_path end @@ -312,47 +312,47 @@ let(:user) { FactoryBot.create(:user) } let(:post_redirect) do - PostRedirect.create(:user => user, :uri => frontpage_path) + PostRedirect.create(user: user, uri: frontpage_path) end before(:each) do @valid_password_params = - { :password => 'secret123456', - :password_confirmation => 'secret123456' } + { password: 'secret123456', + password_confirmation: 'secret123456' } @invalid_password_params = - { :password => 'secret', - :password_confirmation => 'password' } + { password: 'secret', + password_confirmation: 'password' } end it 'changes the password on success' do old_hash = user.hashed_password put :update, params: { - :id => post_redirect.token, - :password_change_user => @valid_password_params + id: post_redirect.token, + password_change_user: @valid_password_params } expect(user.reload.hashed_password).not_to eq(old_hash) end it 'notifies the user the password change has been successful' do put :update, params: { - :id => post_redirect.token, - :password_change_user => @valid_password_params + id: post_redirect.token, + password_change_user: @valid_password_params } expect(flash[:notice]).to eq('Your password has been changed.') end it 'assigns the user from a post redirect' do put :update, params: { - :id => post_redirect.token, - :password_change_user => @valid_password_params + id: post_redirect.token, + password_change_user: @valid_password_params } expect(assigns[:password_change_user]).to eq(user) end it 'logs in the user on success' do put :update, params: { - :id => post_redirect.token, - :password_change_user => @valid_password_params + id: post_redirect.token, + password_change_user: @valid_password_params } expect(session[:user_id]).to eq(user.id) end @@ -360,28 +360,28 @@ it 'retains the old password on failure' do old_hash = user.hashed_password put :update, params: { - :id => post_redirect.token, - :password_change_user => @invalid_password_params + id: post_redirect.token, + password_change_user: @invalid_password_params } expect(user.reload.hashed_password).to eq(old_hash) end it 're-renders the form on failure' do put :update, params: { - :id => post_redirect.token, - :password_change_user => @invalid_password_params + id: post_redirect.token, + password_change_user: @invalid_password_params } expect(response).to render_template(:edit) end context 'no user is specified' do - let(:post_redirect) { PostRedirect.new(:user => nil) } + let(:post_redirect) { PostRedirect.new(user: nil) } it 'redirects to #new when a user cannot be found' do put :update, params: { - :id => post_redirect.token, - :password_change_user => @valid_password_params + id: post_redirect.token, + password_change_user: @valid_password_params } expect(response).to redirect_to(new_password_change_path) end @@ -392,8 +392,8 @@ it 'redirects to new to force an email confirmation' do put :update, params: { - :id => 'invalid', - :password_change_user => @valid_password_params + id: 'invalid', + password_change_user: @valid_password_params } expect(response).to redirect_to new_password_change_path end @@ -403,30 +403,30 @@ context 'when a pretoken is supplied' do it 'redirects to the post redirect uri' do - pretoken = PostRedirect.create(:user => user, :uri => '/') + pretoken = PostRedirect.create(user: user, uri: '/') put :update, params: { - :id => post_redirect.token, - :password_change_user => @valid_password_params, - :pretoken => pretoken.token + id: post_redirect.token, + password_change_user: @valid_password_params, + pretoken: pretoken.token } expect(response).to redirect_to(pretoken.uri) end it 'does not redirect to another domain' do - pretoken = PostRedirect.create(:user => user, :uri => 'http://bad.place.com/') + pretoken = PostRedirect.create(user: user, uri: 'http://bad.place.com/') put :update, params: { - :id => post_redirect.token, - :password_change_user => @valid_password_params, - :pretoken => pretoken.token + id: post_redirect.token, + password_change_user: @valid_password_params, + pretoken: pretoken.token } expect(response).to redirect_to('/') end it 'redirects to the user profile with a blank pretoken' do put :update, params: { - :id => post_redirect.token, - :password_change_user => @valid_password_params, - :pretoken => '' + id: post_redirect.token, + password_change_user: @valid_password_params, + pretoken: '' } expect(response).to redirect_to(show_user_profile_path(user.url_name)) end @@ -437,8 +437,8 @@ it 'redirects to the user profile on success' do put :update, params: { - :id => post_redirect.token, - :password_change_user => @valid_password_params + id: post_redirect.token, + password_change_user: @valid_password_params } expect(response).to redirect_to(show_user_profile_path(user.url_name)) end @@ -456,10 +456,10 @@ it 'changes the password with a correct otp_code' do old_hash = user.hashed_password - params = @valid_password_params.merge(:otp_code => user.otp_code) + params = @valid_password_params.merge(otp_code: user.otp_code) put :update, params: { - :id => post_redirect.token, - :password_change_user => params + id: post_redirect.token, + password_change_user: params } expect(user.reload.hashed_password).not_to eq(old_hash) @@ -467,22 +467,22 @@ it 'redirects to the two factor page to show the new OTP' do old_hash = user.hashed_password - params = @valid_password_params.merge(:otp_code => user.otp_code) + params = @valid_password_params.merge(otp_code: user.otp_code) put :update, params: { - :id => post_redirect.token, - :password_change_user => params + id: post_redirect.token, + password_change_user: params } expect(response).to redirect_to(one_time_password_path) end it 'redirects to the two factor page even if there is a pretoken redirect' do - pretoken = PostRedirect.create(:user => user, :uri => '/') - params = @valid_password_params.merge(:otp_code => user.otp_code) + pretoken = PostRedirect.create(user: user, uri: '/') + params = @valid_password_params.merge(otp_code: user.otp_code) put :update, params: { - :id => post_redirect.token, - :password_change_user => params, - :pretoken => pretoken.token + id: post_redirect.token, + password_change_user: params, + pretoken: pretoken.token } expect(response).to redirect_to(one_time_password_path) @@ -490,10 +490,10 @@ it 'reminds the user that they have a new OTP' do old_hash = user.hashed_password - params = @valid_password_params.merge(:otp_code => user.otp_code) + params = @valid_password_params.merge(otp_code: user.otp_code) put :update, params: { - :id => post_redirect.token, - :password_change_user => params + id: post_redirect.token, + password_change_user: params } msg = "Your password has been changed. " \ @@ -504,10 +504,10 @@ it 'does not change the password with an incorrect otp_code' do old_hash = user.hashed_password - params = @valid_password_params.merge(:otp_code => 'invalid') + params = @valid_password_params.merge(otp_code: 'invalid') put :update, params: { - :id => post_redirect.token, - :password_change_user => params + id: post_redirect.token, + password_change_user: params } expect(user.reload.hashed_password).to eq(old_hash) @@ -516,8 +516,8 @@ it 'does not change the password without an otp_code' do old_hash = user.hashed_password put :update, params: { - :id => post_redirect.token, - :password_change_user => @valid_password_params + id: post_redirect.token, + password_change_user: @valid_password_params } expect(user.reload.hashed_password).to eq(old_hash) diff --git a/spec/controllers/projects/extracts_controller_spec.rb b/spec/controllers/projects/extracts_controller_spec.rb index 49eed8cc26..e976cff679 100644 --- a/spec/controllers/projects/extracts_controller_spec.rb +++ b/spec/controllers/projects/extracts_controller_spec.rb @@ -79,6 +79,7 @@ project.info_requests.each do |info_request| FactoryBot.create(:project_submission, :for_extraction, + project: project, info_request: info_request) end diff --git a/spec/controllers/projects/leaderboards_controller_spec.rb b/spec/controllers/projects/leaderboards_controller_spec.rb new file mode 100644 index 0000000000..1ea5398d2a --- /dev/null +++ b/spec/controllers/projects/leaderboards_controller_spec.rb @@ -0,0 +1,73 @@ +require 'spec_helper' + +spec_meta = { + type: :controller, + feature: :projects +} + +RSpec.describe Projects::LeaderboardsController, spec_meta do + describe 'GET #show' do + def show(format: 'csv') + get :show, params: { project_id: '1', format: format } + end + + let(:project) { FactoryBot.create(:project) } + let(:ability) { Object.new.extend(CanCan::Ability) } + + before do + allow(Project).to receive(:find).with('1').and_return(project) + allow(controller).to receive(:current_ability).and_return(ability) + end + + context 'when not authorised to download project' do + before { ability.cannot :download, project } + + it 'raises access denied expection' do + expect { show }.to raise_error(CanCan::AccessDenied) + end + end + + shared_context 'when authorised to download project' do + before { ability.can :download, project } + end + + context 'when HTML format' do + include_context 'when authorised to download project' + + it 'raises unknown format error' do + expect { show(format: 'html') }.to raise_error( + ActionController::UnknownFormat + ) + end + end + + context 'when CSV format' do + include_context 'when authorised to download project' + + before do + allow(Project::Leaderboard).to receive(:new).with(project).and_return( + double(to_csv: 'CSV_DATA', name: 'NAME') + ) + show + end + + it 'is a successful request' do + expect(response).to be_successful + end + + it 'returns CSV data' do + expect(response.body).to eq 'CSV_DATA' + end + + it 'returns content disposition' do + expect(response.header['Content-Disposition']).to( + eq 'attachment; filename="NAME"; filename*=UTF-8\'\'NAME' + ) + end + + it 'returns CSV content type' do + expect(response.header['Content-Type']).to eq 'text/csv' + end + end + end +end diff --git a/spec/controllers/public_body_change_requests_controller_spec.rb b/spec/controllers/public_body_change_requests_controller_spec.rb index f29716d0d6..4feba9297b 100644 --- a/spec/controllers/public_body_change_requests_controller_spec.rb +++ b/spec/controllers/public_body_change_requests_controller_spec.rb @@ -27,19 +27,19 @@ before do @email = "test@example.com" name = "Test User" - @change_request_params = {:user_email => @email, - :user_name => name, - :public_body_name => 'New Body', - :public_body_email => 'new_body@example.com', - :notes => 'Please', - :source => 'http://www.example.com', - :comment => '' } + @change_request_params = {user_email: @email, + user_name: name, + public_body_name: 'New Body', + public_body_email: 'new_body@example.com', + notes: 'Please', + source: 'http://www.example.com', + comment: '' } end it "should send an email to the site contact address" do allow(@controller).to receive(:verify_recaptcha).and_return(true) post :create, params: { - :public_body_change_request => @change_request_params + public_body_change_request: @change_request_params } change_request_id = assigns[:change_request].id deliveries = ActionMailer::Base.deliveries @@ -57,7 +57,7 @@ it 'sets render_recaptcha to true if there is no logged in user' do post :create, params: { - :public_body_change_request => @change_request_params + public_body_change_request: @change_request_params } expect(assigns[:render_recaptcha]).to eq(true) end @@ -65,7 +65,7 @@ it 'sets render_recaptcha to false if there is a logged in user' do sign_in FactoryBot.create(:user) post :create, params: { - :public_body_change_request => @change_request_params + public_body_change_request: @change_request_params } expect(assigns[:render_recaptcha]).to eq(false) end @@ -73,7 +73,7 @@ it 're-renders the form if the recaptcha verification was unsuccessful' do allow(@controller).to receive(:verify_recaptcha).and_return(false) post :create, params: { - :public_body_change_request => @change_request_params + public_body_change_request: @change_request_params } expect(response).to render_template(:new) end @@ -81,7 +81,7 @@ it 'should show a notice' do allow(@controller).to receive(:verify_recaptcha).and_return(true) post :create, params: { - :public_body_change_request => @change_request_params + public_body_change_request: @change_request_params } expected_text = "Your request to add an authority has been sent. Thank you for getting in touch! We'll get back to you soon." expect(flash[:notice]).to eq(expected_text) @@ -90,16 +90,16 @@ it 'should redirect to the frontpage' do allow(@controller).to receive(:verify_recaptcha).and_return(true) post :create, params: { - :public_body_change_request => @change_request_params + public_body_change_request: @change_request_params } expect(response).to redirect_to frontpage_url end it 'has rudimentary spam protection' do - spam_request_params = @change_request_params.merge({ :comment => 'I AM A SPAMBOT' }) + spam_request_params = @change_request_params.merge({ comment: 'I AM A SPAMBOT' }) post :create, params: { - :public_body_change_request => spam_request_params + public_body_change_request: spam_request_params } expect(response).to redirect_to(frontpage_path) @@ -115,19 +115,19 @@ @email = "test@example.com" name = "Test User" @public_body = FactoryBot.create(:public_body) - @change_request_params = {:user_email => @email, - :user_name => name, - :public_body_id => @public_body.id, - :public_body_email => 'new_body@example.com', - :notes => 'Please', - :source => 'http://www.example.com', - :comment => '' } + @change_request_params = {user_email: @email, + user_name: name, + public_body_id: @public_body.id, + public_body_email: 'new_body@example.com', + notes: 'Please', + source: 'http://www.example.com', + comment: '' } end it 'should send an email to the site contact address' do allow(@controller).to receive(:verify_recaptcha).and_return(true) post :create, params: { - :public_body_change_request => @change_request_params + public_body_change_request: @change_request_params } change_request_id = assigns[:change_request].id deliveries = ActionMailer::Base.deliveries @@ -146,7 +146,7 @@ it 'should show a notice' do allow(@controller).to receive(:verify_recaptcha).and_return(true) post :create, params: { - :public_body_change_request => @change_request_params + public_body_change_request: @change_request_params } expected_text = "Your request to update the address for #{@public_body.name} has been sent. Thank you for getting in touch! We'll get back to you soon." expect(flash[:notice]).to eq(expected_text) @@ -155,7 +155,7 @@ it 'should redirect to the frontpage' do allow(@controller).to receive(:verify_recaptcha).and_return(true) post :create, params: { - :public_body_change_request => @change_request_params + public_body_change_request: @change_request_params } expect(response).to redirect_to frontpage_url end diff --git a/spec/controllers/public_body_controller_spec.rb b/spec/controllers/public_body_controller_spec.rb index 8dfcf0a1ce..a7fd6a011c 100644 --- a/spec/controllers/public_body_controller_spec.rb +++ b/spec/controllers/public_body_controller_spec.rb @@ -10,89 +10,89 @@ end it "should be successful" do - get :show, params: { :url_name => "dfh", :view => 'all' } + get :show, params: { url_name: "dfh", view: 'all' } expect(response).to be_successful end it "should render with 'show' template" do - get :show, params: { :url_name => "dfh", :view => 'all' } + get :show, params: { url_name: "dfh", view: 'all' } expect(response).to render_template('show') end it "should assign the body" do - get :show, params: { :url_name => "dfh", :view => 'all' } + get :show, params: { url_name: "dfh", view: 'all' } expect(assigns[:public_body]).to eq(public_bodies(:humpadink_public_body)) end it "should assign the requests (1)" do - get :show, params: { :url_name => "tgq", :view => 'all' } - conditions = { :public_body_id => public_bodies(:geraldine_public_body).id } + get :show, params: { url_name: "tgq", view: 'all' } + conditions = { public_body_id: public_bodies(:geraldine_public_body).id } actual = assigns[:xapian_requests].results.map { |x| x[:model].info_request } expect(actual).to match_array(InfoRequest.where(conditions)) end it "should assign the requests (2)" do - get :show, params: { :url_name => "tgq", :view => 'successful' } - conditions = { :described_state => 'successful', - :public_body_id => public_bodies(:geraldine_public_body).id } + get :show, params: { url_name: "tgq", view: 'successful' } + conditions = { described_state: 'successful', + public_body_id: public_bodies(:geraldine_public_body).id } actual = assigns[:xapian_requests].results.map { |x| x[:model].info_request } expect(actual).to match_array(InfoRequest.where(conditions)) end it "should assign the requests (3)" do - get :show, params: { :url_name => "dfh", :view => 'all' } - conditions = { :public_body_id => public_bodies(:humpadink_public_body).id } + get :show, params: { url_name: "dfh", view: 'all' } + conditions = { public_body_id: public_bodies(:humpadink_public_body).id } actual = assigns[:xapian_requests].results.map { |x| x[:model].info_request } expect(actual).to match_array(InfoRequest.where(conditions)) end it "should display the body using same locale as that used in url_name" do - get :show, params: { :url_name => "edfh", :view => 'all', :locale => "es" } + get :show, params: { url_name: "edfh", view: 'all', locale: "es" } expect(response.body).to have_content("Baguette") end it 'should show public body names in the selected locale language if present for a locale with underscores' do AlaveteliLocalization.set_locales('he_IL en', 'en') - get :show, params: { :url_name => 'dfh', - :view => 'all', - :locale => 'he_IL' } + get :show, params: { url_name: 'dfh', + view: 'all', + locale: 'he_IL' } expect(response.body).to have_content('Hebrew Humpadinking') end it "should redirect use to the relevant locale even when url_name is for a different locale" do - get :show, params: { :url_name => "edfh", :view => 'all' } + get :show, params: { url_name: "edfh", view: 'all' } expect(response).to redirect_to "http://test.host/body/dfh" end it "should redirect to newest name if you use historic name of public body in URL" do - get :show, params: { :url_name => "hdink", :view => 'all' } - expect(response).to redirect_to(:controller => 'public_body', :action => 'show', :url_name => "dfh") + get :show, params: { url_name: "hdink", view: 'all' } + expect(response).to redirect_to(controller: 'public_body', action: 'show', url_name: "dfh") end it "should redirect to lower case name if you use mixed case name in URL" do - get :show, params: { :url_name => "dFh", :view => 'all' } - expect(response).to redirect_to(:controller => 'public_body', :action => 'show', :url_name => "dfh") + get :show, params: { url_name: "dFh", view: 'all' } + expect(response).to redirect_to(controller: 'public_body', action: 'show', url_name: "dfh") end it 'keeps the search_params flash' do # Make two get requests to simulate the flash getting swept after the # first response. search_params = { 'query' => 'Quango' } - get :show, params: { :url_name => 'dfh', :view => 'all' }, - flash: { :search_params => search_params } - get :show, params: { :url_name => 'dfh', :view => 'all' } + get :show, params: { url_name: 'dfh', view: 'all' }, + flash: { search_params: search_params } + get :show, params: { url_name: 'dfh', view: 'all' } expect(flash[:search_params]).to eq(search_params) end it 'should not show high page offsets as these are extremely slow to generate' do expect { - get :show, params: { :url_name => 'dfh', :view => 'all', :page => 25 } + get :show, params: { url_name: 'dfh', view: 'all', page: 25 } }.to raise_error(ActiveRecord::RecordNotFound) end it 'should not raise an error when given an empty query param' do - get :show, params: { :url_name => "dfh", :view => 'all', :query => nil } + get :show, params: { url_name: "dfh", view: 'all', query: nil } expect(response).to be_successful end end @@ -111,16 +111,16 @@ def make_single_language_example(locale) AlaveteliLocalization.with_locale(locale) do case locale when :en - result = PublicBody.new(:name => 'English only', - :short_name => 'EO') + result = PublicBody.new(name: 'English only', + short_name: 'EO') when :es - result = PublicBody.new(:name => 'Español Solamente', - :short_name => 'ES') + result = PublicBody.new(name: 'Español Solamente', + short_name: 'ES') when :en_GB - result = PublicBody.new(:name => 'GB English', - :short_name => 'GB') + result = PublicBody.new(name: 'GB English', + short_name: 'GB') else - raise StandardError.new "Unknown locale #{locale}" + raise StandardError, "Unknown locale #{locale}" end result.request_email = "#{locale}@example.org" result.last_edit_editor = 'test' @@ -134,7 +134,7 @@ def make_single_language_example(locale) it "with no fallback, should only return bodies from the current locale" do @english_only = make_single_language_example :en @spanish_only = make_single_language_example :es - get :list, params: { :locale => 'es' } + get :list, params: { locale: 'es' } expect(assigns[:public_bodies].include?(@english_only)).to eq(false) expect(assigns[:public_bodies].include?(@spanish_only)).to eq(true) end @@ -142,27 +142,27 @@ def make_single_language_example(locale) it "if fallback is requested, should list all bodies from default locale, even when there are no translations for selected locale" do allow(AlaveteliConfiguration).to receive(:public_body_list_fallback_to_default_locale).and_return(true) @english_only = make_single_language_example :en - get :list, params: { :locale => 'es' } + get :list, params: { locale: 'es' } expect(assigns[:public_bodies].include?(@english_only)).to eq(true) end it 'if fallback is requested, should still list public bodies only with translations in the current locale' do allow(AlaveteliConfiguration).to receive(:public_body_list_fallback_to_default_locale).and_return(true) @spanish_only = make_single_language_example :es - get :list, params: { :locale => 'es' } + get :list, params: { locale: 'es' } expect(assigns[:public_bodies].include?(@spanish_only)).to eq(true) end it "if fallback is requested, make sure that there are no duplicates listed" do allow(AlaveteliConfiguration).to receive(:public_body_list_fallback_to_default_locale).and_return(true) - get :list, params: { :locale => 'es' } - pb_ids = assigns[:public_bodies].map { |pb| pb.id } + get :list, params: { locale: 'es' } + pb_ids = assigns[:public_bodies].map(&:id) unique_pb_ids = pb_ids.uniq - expect(pb_ids.sort).to be === unique_pb_ids.sort + expect(pb_ids.sort).to eq(unique_pb_ids.sort) end it 'should show public body names in the selected locale language if present' do - get :list, params: { :locale => 'es' } + get :list, params: { locale: 'es' } expect(response.body).to have_content('El Department for Humpadinking') end @@ -170,13 +170,13 @@ def make_single_language_example(locale) AlaveteliLocalization.set_locales(available_locales='en en_GB', default_locale='en') @gb_only = make_single_language_example :en_GB - get :list, params: { :locale => 'en_GB' } + get :list, params: { locale: 'en_GB' } expect(response.body).to have_content(@gb_only.name) end it 'should not show the internal admin authority' do PublicBody.internal_admin_body - get :list, params: { :locale => 'en' } + get :list, params: { locale: 'en' } expect(response.body).not_to have_content('Internal admin authority') end @@ -185,16 +185,16 @@ def make_single_language_example(locale) # Public Body Name # ... eo extract all of those, and check that they are ordered: allow(AlaveteliConfiguration).to receive(:public_body_list_fallback_to_default_locale).and_return(true) - get :list, params: { :locale => 'es' } + get :list, params: { locale: 'es' } parsed = Nokogiri::HTML(response.body) public_body_names = parsed.xpath '//span[@class="head"]/a/text()' - public_body_names = public_body_names.map { |pb| pb.to_s } + public_body_names = public_body_names.map(&:to_s) expect(public_body_names).to eq(public_body_names.sort) end it 'should show public body names in the selected locale language if present for a locale with underscores' do AlaveteliLocalization.set_locales('he_IL en', 'en') - get :list, params: { :locale => 'he_IL' } + get :list, params: { locale: 'he_IL' } expect(response.body).to have_content('Hebrew Humpadinking') end @@ -223,7 +223,7 @@ def make_single_language_example(locale) with(an_instance_of(String)). and_return(true) - get :list, params: { :locale => 'en_GB' } + get :list, params: { locale: 'en_GB' } expect(assigns[:public_bodies].to_sql).to include('COLLATE') end @@ -235,7 +235,7 @@ def make_single_language_example(locale) with(an_instance_of(String)). and_return(false) - get :list, params: { :locale => 'unknown' } + get :list, params: { locale: 'unknown' } expect(assigns[:public_bodies].to_sql).to_not include('COLLATE') end @@ -248,7 +248,7 @@ def make_single_language_example(locale) with(an_instance_of(String)). and_return(true) - get :list, params: { :locale => 'en_GB' } + get :list, params: { locale: 'en_GB' } expect(assigns[:public_bodies].to_sql).to include('COLLATE') end @@ -261,23 +261,23 @@ def make_single_language_example(locale) with(an_instance_of(String)). and_return(false) - get :list, params: { :locale => 'unknown' } + get :list, params: { locale: 'unknown' } expect(assigns[:public_bodies].to_sql).to_not include('COLLATE') end it "should support simple searching of bodies by title" do - get :list, params: { :public_body_query => 'quango' } + get :list, params: { public_body_query: 'quango' } expect(assigns[:public_bodies]).to eq([ public_bodies(:geraldine_public_body) ]) end it "should support simple searching of bodies by short_name" do - get :list, params: { :public_body_query => 'DfH' } + get :list, params: { public_body_query: 'DfH' } expect(assigns[:public_bodies]).to eq([ public_bodies(:humpadink_public_body) ]) end - it "should support simple searching of bodies by notes" do - get :list, params: { :public_body_query => 'Albatross' } + xit "should support simple searching of bodies by notes" do + get :list, params: { public_body_query: 'Albatross' } expect(assigns[:public_bodies]).to eq([ public_bodies(:humpadink_public_body) ]) end @@ -299,18 +299,18 @@ def make_single_language_example(locale) category = FactoryBot.create(:public_body_category) heading = FactoryBot.create(:public_body_heading) - PublicBodyCategoryLink.create(:public_body_heading_id => heading.id, - :public_body_category_id => category.id) + PublicBodyCategoryLink.create(public_body_heading_id: heading.id, + public_body_category_id: category.id) public_bodies(:humpadink_public_body).tag_string = category.category_tag - get :list, params: { :tag => category.category_tag } + get :list, params: { tag: category.category_tag } expect(response).to render_template('list') expect(assigns[:public_bodies]).to eq([ public_bodies(:humpadink_public_body) ]) expect(assigns[:tag]).to eq(category.category_tag) expect(assigns[:description]). to eq("Found 1 public authority in the category ‘#{category.title}’") - get :list, params: { :tag => "other" } + get :list, params: { tag: "other" } expect(response).to render_template('list') expect(assigns[:public_bodies]).to eq([ public_bodies(:other_public_body), public_bodies(:forlorn_public_body), @@ -331,17 +331,17 @@ def make_single_language_example(locale) it "should list a machine tagged thing, should get it in both ways" do public_bodies(:humpadink_public_body).tag_string = "eats_cheese:stilton" - get :list, params: { :tag => "eats_cheese" } + get :list, params: { tag: "eats_cheese" } expect(response).to render_template('list') expect(assigns[:public_bodies]).to eq([ public_bodies(:humpadink_public_body) ]) expect(assigns[:tag]).to eq("eats_cheese") - get :list, params: { :tag => "eats_cheese:jarlsberg" } + get :list, params: { tag: "eats_cheese:jarlsberg" } expect(response).to render_template('list') expect(assigns[:public_bodies]).to eq([ ]) expect(assigns[:tag]).to eq("eats_cheese:jarlsberg") - get :list, params: { :tag => "eats_cheese:stilton" } + get :list, params: { tag: "eats_cheese:stilton" } expect(response).to render_template('list') expect(assigns[:public_bodies]).to eq([ public_bodies(:humpadink_public_body) ]) expect(assigns[:tag]).to eq("eats_cheese:stilton") @@ -350,9 +350,9 @@ def make_single_language_example(locale) it 'should not include hidden requests in the request count' do fake_pb = FactoryBot.create(:public_body) hidden_request = FactoryBot.create(:info_request, - :prominence => 'hidden', - :public_body => fake_pb) - visible_request = FactoryBot.create(:info_request, :public_body => fake_pb) + prominence: 'hidden', + public_body: fake_pb) + visible_request = FactoryBot.create(:info_request, public_body: fake_pb) fake_pb.reload expect(fake_pb.info_requests.size).to eq(2) expect(fake_pb.info_requests.is_searchable.size).to eq(1) @@ -372,7 +372,7 @@ def make_single_language_example(locale) it 'raises an UnknownFormat error if asked for a json version of a list' do expect { - get :list, params: { :format => 'json' } + get :list, params: { format: 'json' } }.to raise_error(ActionController::UnknownFormat) end @@ -383,7 +383,7 @@ def make_single_language_example(locale) FactoryBot.create(:public_body, name: "Åčçèñtéd Authority") end - get :list, params: { :tag => "å", :locale => 'cs' } + get :list, params: { tag: "å", locale: 'cs' } expect(response).to render_template('list') expect(assigns[:public_bodies]).to eq([ authority ]) expect(assigns[:tag]).to eq("Å") @@ -394,7 +394,7 @@ def make_single_language_example(locale) RSpec.describe PublicBodyController, "when showing JSON version for API" do it "should be successful" do - get :show, params: { :url_name => "dfh", :format => "json", :view => 'all' } + get :show, params: { url_name: "dfh", format: "json", view: 'all' } pb = JSON.parse(response.body) expect(pb.class.to_s).to eq('Hash') @@ -416,7 +416,7 @@ def make_single_language_example(locale) it 'sends CSV file as response' do get :list_all_csv - response.body.should eq IO.binread(fixture) + expect(response.body).to eq IO.binread(fixture) end end @@ -444,17 +444,17 @@ def make_single_language_example(locale) end it 'renders the search_ahead template' do - get :search_typeahead, params: { :query => "" } + get :search_typeahead, params: { query: "" } expect(response).to render_template('public_body/_search_ahead') end it 'assigns the xapian search to the view as xapian_requests' do - get :search_typeahead, params: { :query => "Geraldine Humpadinking" } + get :search_typeahead, params: { query: "Geraldine Humpadinking" } expect(assigns[:xapian_requests]).to be_an_instance_of ActsAsXapian::Search end it "shows the number of bodies matching the keywords" do - get :search_typeahead, params: { :query => "Geraldine Humpadinking" } + get :search_typeahead, params: { query: "Geraldine Humpadinking" } expect(response.body).to match("2 matching authorities") end diff --git a/spec/controllers/reports_controller_spec.rb b/spec/controllers/reports_controller_spec.rb index 14721604ea..bf78fd28d1 100644 --- a/spec/controllers/reports_controller_spec.rb +++ b/spec/controllers/reports_controller_spec.rb @@ -9,13 +9,12 @@ context "when reporting a request when not logged in" do it "should only allow logged-in users to report requests" do post :create, params: { - :request_id => info_request.url_title, - :reason => "my reason" + request_id: info_request.url_title, + reason: "my reason" } expect(flash[:notice]).to match(/You need to be logged in/) expect(response) - .to redirect_to show_request_path(:url_title => - info_request.url_title) + .to redirect_to show_request_path(url_title: info_request.url_title) end end @@ -26,8 +25,8 @@ it "finds the expected request" do post :create, params: { - :request_id => info_request.url_title, - :reason => "my reason" + request_id: info_request.url_title, + reason: "my reason" } expect(assigns(:info_request)).to eq(info_request) @@ -35,8 +34,8 @@ it "sets reportable to the request" do post :create, params: { - :request_id => info_request.url_title, - :reason => "my reason" + request_id: info_request.url_title, + reason: "my reason" } expect(assigns(:reportable)).to eq(info_request) @@ -44,8 +43,8 @@ it "sets report_reasons to the request report reasons" do post :create, params: { - :request_id => info_request.url_title, - :reason => "my reason" + request_id: info_request.url_title, + reason: "my reason" } expect(assigns(:report_reasons)).to eq(info_request.report_reasons) @@ -70,23 +69,23 @@ it 'ignores an empty comment_id param' do post :create, params: { - :request_id => info_request.url_title, - :comment_id => '', - :reason => "my reason" + request_id: info_request.url_title, + comment_id: '', + reason: "my reason" } expect(assigns[:comment]).to be_nil end it "should 404 for non-existent requests" do expect { - post :create, params: { :request_id => "hjksfdhjk_louytu_qqxxx" } + post :create, params: { request_id: "hjksfdhjk_louytu_qqxxx" } }.to raise_error(ActiveRecord::RecordNotFound) end it 'should 404 for embargoed requests' do info_request = FactoryBot.create(:embargoed_request) expect { - post :create, params: { :request_id => info_request.url_title } + post :create, params: { request_id: info_request.url_title } }.to raise_error(ActiveRecord::RecordNotFound) end @@ -94,12 +93,11 @@ expect(info_request.attention_requested).to eq(false) post :create, params: { - :request_id => info_request.url_title, - :reason => "my reason" + request_id: info_request.url_title, + reason: "my reason" } expect(response) - .to redirect_to show_request_path(:url_title => - info_request.url_title) + .to redirect_to show_request_path(url_title: info_request.url_title) info_request.reload expect(info_request.attention_requested).to eq(true) @@ -110,9 +108,9 @@ expected = "This request has been reported for administrator attention" post :create, params: { - :request_id => info_request.url_title, - :reason => "my reason", - :message => "It's just not" + request_id: info_request.url_title, + reason: "my reason", + message: "It's just not" } expect(flash[:notice]).to eq(expected) @@ -120,28 +118,26 @@ it "should not allow a request to be reported twice" do post :create, params: { - :request_id => info_request.url_title, - :reason => "my reason" + request_id: info_request.url_title, + reason: "my reason" } expect(response) - .to redirect_to show_request_url(:url_title => - info_request.url_title) + .to redirect_to show_request_url(url_title: info_request.url_title) post :create, params: { - :request_id => info_request.url_title, - :reason => "my reason" + request_id: info_request.url_title, + reason: "my reason" } expect(response) - .to redirect_to show_request_url(:url_title => - info_request.url_title) + .to redirect_to show_request_url(url_title: info_request.url_title) expect(flash[:notice]).to match(/has already been reported/) end it "should send an email from the reporter to admins" do post :create, params: { - :request_id => info_request.url_title, - :reason => "my reason", - :message => "It's just not" + request_id: info_request.url_title, + reason: "my reason", + message: "It's just not" } deliveries = ActionMailer::Base.deliveries expect(deliveries.size).to eq(1) @@ -155,8 +151,8 @@ it "should force the user to pick a reason" do post :create, params: { - :request_id => info_request.url_title, - :reason => "" + request_id: info_request.url_title, + reason: "" } expect(response).to render_template("new") expect(flash[:error]).to eq("Please choose a reason") @@ -170,15 +166,15 @@ end let(:comment) do - FactoryBot.create(:comment, :info_request => info_request, - :attention_requested => false) + FactoryBot.create(:comment, info_request: info_request, + attention_requested: false) end it "finds the expected request" do post :create, params: { - :request_id => info_request.url_title, - :comment_id => comment.id, - :reason => "my reason" + request_id: info_request.url_title, + comment_id: comment.id, + reason: "my reason" } expect(assigns(:info_request)).to eq(info_request) @@ -186,9 +182,9 @@ it "finds the expected comment" do post :create, params: { - :request_id => info_request.url_title, - :comment_id => comment.id, - :reason => "my reason" + request_id: info_request.url_title, + comment_id: comment.id, + reason: "my reason" } expect(assigns(:comment)).to eq(comment) @@ -196,9 +192,9 @@ it "sets reportable to the comment" do post :create, params: { - :request_id => info_request.url_title, - :comment_id => comment.id, - :reason => "my reason" + request_id: info_request.url_title, + comment_id: comment.id, + reason: "my reason" } expect(assigns(:reportable)).to eq(comment) @@ -206,9 +202,9 @@ it "sets report_reasons to the comment report reasons" do post :create, params: { - :request_id => info_request.url_title, - :comment_id => comment.id, - :reason => "my reason" + request_id: info_request.url_title, + comment_id: comment.id, + reason: "my reason" } expect(assigns(:report_reasons)).to eq(comment.report_reasons) @@ -218,18 +214,18 @@ new_comment = FactoryBot.create(:comment) expect { post :create, params: { - :request_id => info_request.url_title, - :comment_id => new_comment.id, - :reason => "my reason" + request_id: info_request.url_title, + comment_id: new_comment.id, + reason: "my reason" } }.to raise_error(ActiveRecord::RecordNotFound) end it "marks the comment as having been reported" do post :create, params: { - :request_id => info_request.url_title, - :comment_id => comment.id, - :reason => "my reason" + request_id: info_request.url_title, + comment_id: comment.id, + reason: "my reason" } comment.reload @@ -238,9 +234,9 @@ it "does not mark the parent request as having been reported" do post :create, params: { - :request_id => info_request.url_title, - :comment_id => comment.id, - :reason => "my reason" + request_id: info_request.url_title, + comment_id: comment.id, + reason: "my reason" } info_request.reload @@ -250,10 +246,10 @@ it "sends an email alerting admins to the report" do post :create, params: { - :request_id => info_request.url_title, - :comment_id => comment.id, - :reason => "my reason", - :message => "It's just not" + request_id: info_request.url_title, + comment_id: comment.id, + reason: "my reason", + message: "It's just not" } deliveries = ActionMailer::Base.deliveries @@ -278,10 +274,10 @@ "administrator attention" post :create, params: { - :request_id => info_request.url_title, - :comment_id => comment.id, - :reason => "my reason", - :message => "It's just not" + request_id: info_request.url_title, + comment_id: comment.id, + reason: "my reason", + message: "It's just not" } expect(flash[:notice]).to eq(expected) @@ -289,15 +285,14 @@ it "redirects to the parent info_request page" do post :create, params: { - :request_id => info_request.url_title, - :comment_id => comment.id, - :reason => "my reason", - :message => "It's just not" + request_id: info_request.url_title, + comment_id: comment.id, + reason: "my reason", + message: "It's just not" } expect(response) - .to redirect_to show_request_path(:url_title => - info_request.url_title) + .to redirect_to show_request_path(url_title: info_request.url_title) end end @@ -310,9 +305,9 @@ context "not logged in" do it "should require the user to be logged in" do - get :new, params: { :request_id => info_request.url_title } + get :new, params: { request_id: info_request.url_title } expect(response). - to redirect_to(signin_path(:token => PostRedirect.last.token)) + to redirect_to(signin_path(token: PostRedirect.last.token)) end end @@ -322,42 +317,42 @@ end it "finds the expected request" do - get :new, params: { :request_id => info_request.url_title } + get :new, params: { request_id: info_request.url_title } expect(assigns(:info_request)).to eq(info_request) end it "sets reportable to the request" do - get :new, params: { :request_id => info_request.url_title } + get :new, params: { request_id: info_request.url_title } expect(assigns(:reportable)).to eq(info_request) end it "sets report_reasons to the request report reasons" do - get :new, params: { :request_id => info_request.url_title } + get :new, params: { request_id: info_request.url_title } expect(assigns(:report_reasons)).to eq(info_request.report_reasons) end it "sets the page title" do - get :new, params: { :request_id => info_request.url_title } + get :new, params: { request_id: info_request.url_title } expect(assigns(:title)). to eq("Report request: #{ info_request.title }") end it "should show the form" do - get :new, params: { :request_id => info_request.url_title } + get :new, params: { request_id: info_request.url_title } expect(response).to render_template("new") end it "should 404 for non-existent requests" do expect { - get :new, params: { :request_id => "hjksfdhjk_louytu_qqxxx" } + get :new, params: { request_id: "hjksfdhjk_louytu_qqxxx" } }.to raise_error(ActiveRecord::RecordNotFound) end it 'should 404 for embargoed requests' do info_request = FactoryBot.create(:embargoed_request) expect { - get :new, params: { :request_id => info_request.url_title } + get :new, params: { request_id: info_request.url_title } }.to raise_error(ActiveRecord::RecordNotFound) end @@ -371,23 +366,23 @@ end let(:comment) do - FactoryBot.create(:comment, :info_request => info_request, - :attention_requested => false) + FactoryBot.create(:comment, info_request: info_request, + attention_requested: false) end it "finds the expected request" do get :new, params: { - :request_id => info_request.url_title, - :comment_id => comment.id + request_id: info_request.url_title, + comment_id: comment.id } expect(assigns(:info_request)).to eq(info_request) end it "finds the expected comment" do get :new, params: { - :request_id => info_request.url_title, - :comment_id => comment.id, - :reason => "my reason" + request_id: info_request.url_title, + comment_id: comment.id, + reason: "my reason" } expect(assigns(:comment)).to eq(comment) @@ -395,8 +390,8 @@ it "sets reportable to the comment" do get :new, params: { - :request_id => info_request.url_title, - :comment_id => comment.id + request_id: info_request.url_title, + comment_id: comment.id } expect(assigns(:reportable)).to eq(comment) @@ -404,8 +399,8 @@ it "sets report_reasons to the comment report reasons" do get :new, params: { - :request_id => info_request.url_title, - :comment_id => comment.id + request_id: info_request.url_title, + comment_id: comment.id } expect(assigns(:report_reasons)).to eq(comment.report_reasons) @@ -413,8 +408,8 @@ it "sets the page title" do get :new, params: { - :request_id => info_request.url_title, - :comment_id => comment.id + request_id: info_request.url_title, + comment_id: comment.id } expect(assigns(:title)). @@ -425,35 +420,35 @@ new_comment = FactoryBot.create(:comment) expect { get :new, params: { - :request_id => info_request.url_title, - :comment_id => new_comment.id + request_id: info_request.url_title, + comment_id: new_comment.id } }.to raise_error(ActiveRecord::RecordNotFound) end it "should show the form" do get :new, params: { - :request_id => info_request.url_title, - :comment_id => comment.id + request_id: info_request.url_title, + comment_id: comment.id } expect(response).to render_template("new") end it "copies the comment id into a hidden form field" do get :new, params: { - :request_id => info_request.url_title, - :comment_id => comment.id + request_id: info_request.url_title, + comment_id: comment.id } expect(response.body). to have_selector("input#comment_id[value=\"#{comment.id}\"]", - :visible => false) + visible: false) end it "should 404 for non-existent requests" do expect { get :new, params: { - :request_id => "hjksfdhjk_louytu_qqxxx", - :comment_id => comment.id + request_id: "hjksfdhjk_louytu_qqxxx", + comment_id: comment.id } }.to raise_error(ActiveRecord::RecordNotFound) end @@ -462,8 +457,8 @@ info_request = FactoryBot.create(:embargoed_request) expect { get :new, params: { - :request_id => info_request.url_title, - :comment_id => comment.id + request_id: info_request.url_title, + comment_id: comment.id } }.to raise_error(ActiveRecord::RecordNotFound) end diff --git a/spec/controllers/request_controller_spec.rb b/spec/controllers/request_controller_spec.rb index 658d59d0ca..d1fef1160e 100644 --- a/spec/controllers/request_controller_spec.rb +++ b/spec/controllers/request_controller_spec.rb @@ -7,26 +7,26 @@ end it "should be successful" do - get :list, params: { :view => 'all' } + get :list, params: { view: 'all' } expect(response).to be_successful end it "should render with 'list' template" do - get :list, params: { :view => 'all' } + get :list, params: { view: 'all' } expect(response).to render_template('list') end it "should return 404 for pages we don't want to serve up" do xap_results = double(ActsAsXapian::Search, - :results => (1..25).to_a.map { |m| { :model => m } }, - :matches_estimated => 1000000) + results: (1..25).to_a.map { |m| { model: m } }, + matches_estimated: 1_000_000) expect { - get :list, params: { :view => 'all', :page => 100 } + get :list, params: { view: 'all', page: 100 } }.to raise_error(ActiveRecord::RecordNotFound) end it "raise unknown format error" do - expect { get :list, params: { :view => "all", :format => :json } }.to( + expect { get :list, params: { view: "all", format: :json } }.to( raise_error ActionController::UnknownFormat ) end @@ -34,7 +34,7 @@ it 'should not raise an error for a page param of less than zero, but should treat it as a param of 1' do expect { - get :list, params: { :view => 'all', :page => "-1" } + get :list, params: { view: 'all', page: "-1" } }.not_to raise_error expect(assigns[:page]).to eq(1) end @@ -49,28 +49,28 @@ end it "should be successful" do - get :show, params: { :url_title => 'why_do_you_have_such_a_fancy_dog' } + get :show, params: { url_title: 'why_do_you_have_such_a_fancy_dog' } expect(response).to be_successful end it "should render with 'show' template" do - get :show, params: { :url_title => 'why_do_you_have_such_a_fancy_dog' } + get :show, params: { url_title: 'why_do_you_have_such_a_fancy_dog' } expect(response).to render_template('show') end it "should assign the request" do - get :show, params: { :url_title => 'why_do_you_have_such_a_fancy_dog' } + get :show, params: { url_title: 'why_do_you_have_such_a_fancy_dog' } expect(assigns[:info_request]).to eq(info_requests(:fancy_dog_request)) end it "should redirect from a numeric URL to pretty one" do - get :show, params: { :url_title => info_requests(:naughty_chicken_request).id.to_s } - expect(response).to redirect_to(:action => 'show', :url_title => info_requests(:naughty_chicken_request).url_title) + get :show, params: { url_title: info_requests(:naughty_chicken_request).id.to_s } + expect(response).to redirect_to(action: 'show', url_title: info_requests(:naughty_chicken_request).url_title) end it 'should return a 404 for GET requests to a malformed request URL' do expect { - get :show, params: { :url_title => '228%85' } + get :show, params: { url_title: '228%85' } }.to raise_error(ActiveRecord::RecordNotFound) end @@ -197,14 +197,14 @@ it 'raises ActiveRecord::RecordNotFound' do embargoed_request = FactoryBot.create(:embargoed_request) expect { - get :show, params: { :url_title => embargoed_request.url_title } + get :show, params: { url_title: embargoed_request.url_title } }.to raise_error(ActiveRecord::RecordNotFound) end it "doesn't even redirect from a numeric id" do embargoed_request = FactoryBot.create(:embargoed_request) expect { - get :show, params: { :url_title => embargoed_request.id } + get :show, params: { url_title: embargoed_request.id } }.to raise_error(ActiveRecord::RecordNotFound) end end @@ -213,7 +213,7 @@ describe 'when viewing anonymously' do it 'should be successful' do sign_in nil - get :show, params: { :url_title => 'balalas' } + get :show, params: { url_title: 'balalas' } expect(response).to be_successful end end @@ -221,7 +221,7 @@ describe 'when the request is being viewed by an admin' do def make_request sign_in users(:admin_user) - get :show, params: { :url_title => 'balalas' } + get :show, params: { url_title: 'balalas' } end it 'should be successful' do @@ -236,12 +236,12 @@ def make_request describe 'when the request is external' do it 'should assign the "update status" flag to the view as falsey if the parameter is present' do - get :show, params: { :url_title => 'balalas', :update_status => 1 } + get :show, params: { url_title: 'balalas', update_status: 1 } expect(assigns[:update_status]).to be_falsey end it 'should assign the "update status" flag to the view as falsey if the parameter is not present' do - get :show, params: { :url_title => 'balalas' } + get :show, params: { url_title: 'balalas' } expect(assigns[:update_status]).to be_falsey end @@ -249,32 +249,32 @@ def make_request it 'should assign the "update status" flag to the view as truthy if the parameter is present' do get :show, params: { - :url_title => 'why_do_you_have_such_a_fancy_dog', - :update_status => 1 + url_title: 'why_do_you_have_such_a_fancy_dog', + update_status: 1 } expect(assigns[:update_status]).to be_truthy end it 'should assign the "update status" flag to the view as falsey if the parameter is not present' do - get :show, params: { :url_title => 'why_do_you_have_such_a_fancy_dog' } + get :show, params: { url_title: 'why_do_you_have_such_a_fancy_dog' } expect(assigns[:update_status]).to be_falsey end it 'should require login' do sign_in nil get :show, params: { - :url_title => 'why_do_you_have_such_a_fancy_dog', - :update_status => 1 + url_title: 'why_do_you_have_such_a_fancy_dog', + update_status: 1 } expect(response). - to redirect_to(signin_path(:token => get_last_post_redirect.token)) + to redirect_to(signin_path(token: get_last_post_redirect.token)) end it 'should work if logged in as the requester' do sign_in users(:bob_smith_user) get :show, params: { - :url_title => 'why_do_you_have_such_a_fancy_dog', - :update_status => 1 + url_title: 'why_do_you_have_such_a_fancy_dog', + update_status: 1 } expect(response).to render_template "request/show" end @@ -282,8 +282,8 @@ def make_request it 'should not work if logged in as not the requester' do sign_in users(:silly_name_user) get :show, params: { - :url_title => 'why_do_you_have_such_a_fancy_dog', - :update_status => 1 + url_title: 'why_do_you_have_such_a_fancy_dog', + update_status: 1 } expect(response).to render_template "user/wrong_user" end @@ -291,8 +291,8 @@ def make_request it 'should work if logged in as an admin user' do sign_in users(:admin_user) get :show, params: { - :url_title => 'why_do_you_have_such_a_fancy_dog', - :update_status => 1 + url_title: 'why_do_you_have_such_a_fancy_dog', + update_status: 1 } expect(response).to render_template "request/show" end @@ -304,7 +304,7 @@ def make_request before :each do sign_in pro_user get :show, params: { - :url_title => 'why_do_you_have_such_a_fancy_dog', + url_title: 'why_do_you_have_such_a_fancy_dog', pro: "1" } end @@ -315,13 +315,13 @@ def make_request it "should set @sidebar_template to the pro sidebar" do expect(assigns[:sidebar_template]). - to eq ("alaveteli_pro/info_requests/sidebar") + to eq("alaveteli_pro/info_requests/sidebar") end end describe 'when params[:pro] is not set' do before :each do - get :show, params: { :url_title => 'why_do_you_have_such_a_fancy_dog' } + get :show, params: { url_title: 'why_do_you_have_such_a_fancy_dog' } end it "should set @in_pro_area to false" do @@ -329,7 +329,7 @@ def make_request end it "should set @sidebar_template to the normal sidebar" do - expect(assigns[:sidebar_template]).to eq ("sidebar") + expect(assigns[:sidebar_template]).to eq("sidebar") end end @@ -342,9 +342,9 @@ def make_request with_feature_enabled(:alaveteli_pro) do sign_in pro_user get :show, params: { - :url_title => pro_request.url_title, - :pro => "1", - :update_status => "1" + url_title: pro_request.url_title, + pro: "1", + update_status: "1" } expect(assigns[:show_top_describe_state_form]).to be false end @@ -356,14 +356,14 @@ def make_request it "is false" do info_request = info_requests(:naughty_chicken_request) expect(info_request.awaiting_description).to be false - get :show, params: { :url_title => info_request.url_title } + get :show, params: { url_title: info_request.url_title } expect(assigns[:show_top_describe_state_form]).to be false end context "but the request is awaiting_description" do it "is true" do get :show, params: { - :url_title => 'why_do_you_have_such_a_fancy_dog' + url_title: 'why_do_you_have_such_a_fancy_dog' } expect(assigns[:show_top_describe_state_form]).to be true end @@ -376,8 +376,8 @@ def make_request info_request = info_requests(:naughty_chicken_request) expect(info_request.awaiting_description).to be false get :show, params: { - :url_title => info_request.url_title, - :update_status => "1" + url_title: info_request.url_title, + update_status: "1" } expect(assigns[:show_top_describe_state_form]).to be true end @@ -385,8 +385,8 @@ def make_request context "and the request is awaiting_description" do it "is true" do get :show, params: { - :url_title => 'why_do_you_have_such_a_fancy_dog', - :update_status => "1" + url_title: 'why_do_you_have_such_a_fancy_dog', + update_status: "1" } expect(assigns[:show_top_describe_state_form]).to be true end @@ -398,7 +398,7 @@ def make_request it "is false" do info_request = FactoryBot.create(:info_request) info_request.set_described_state('not_foi') - get :show, params: { :url_title => info_request.url_title } + get :show, params: { url_title: info_request.url_title } expect(assigns[:show_top_describe_state_form]).to be false end end @@ -413,8 +413,8 @@ def make_request with_feature_enabled(:alaveteli_pro) do sign_in pro_user get :show, params: { - :url_title => pro_request.url_title, - :pro => "1" + url_title: pro_request.url_title, + pro: "1" } expect(assigns[:show_bottom_describe_state_form]).to be false end @@ -424,7 +424,7 @@ def make_request context "when @in_pro_area is false" do context "and the request is awaiting_description" do it "is true" do - get :show, params: { :url_title => 'why_do_you_have_such_a_fancy_dog' } + get :show, params: { url_title: 'why_do_you_have_such_a_fancy_dog' } expect(assigns[:show_bottom_describe_state_form]).to be true end end @@ -433,7 +433,7 @@ def make_request it "is false" do info_request = info_requests(:naughty_chicken_request) expect(info_request.awaiting_description).to be false - get :show, params: { :url_title => info_request.url_title } + get :show, params: { url_title: info_request.url_title } expect(assigns[:show_bottom_describe_state_form]).to be false end end @@ -443,7 +443,7 @@ def make_request it "is false" do info_request = FactoryBot.create(:info_request) info_request.set_described_state('not_foi') - get :show, params: { :url_title => info_request.url_title } + get :show, params: { url_title: info_request.url_title } expect(assigns[:show_bottom_describe_state_form]).to be false end end @@ -452,22 +452,22 @@ def make_request it "should set @state_transitions for the request" do info_request = FactoryBot.create(:info_request) expected_transitions = { - :pending => { + pending: { "waiting_response" => "No response has been received (maybe there's just an acknowledgement)", "waiting_clarification" => "Clarification has been requested", "gone_postal" => "A response will be sent by postal mail" }, - :complete => { + complete: { "not_held" => "The authority do not have the information (maybe they say who does)", "partially_successful" => "Some of the information has been sent ", "successful" => "All the information has been sent", "rejected" => "The request has been refused" }, - :other => { + other: { "error_message" => "An error message has been received" } } - get :show, params: { :url_title => info_request.url_title } + get :show, params: { url_title: info_request.url_title } expect(assigns(:state_transitions)).to eq(expected_transitions) end @@ -483,13 +483,13 @@ def make_request it "@show_owner_update_status_action should be false" do expect(info_request.is_old_unclassified?).to be true - get :show, params: { :url_title => info_request.url_title } + get :show, params: { url_title: info_request.url_title } expect(assigns[:show_owner_update_status_action]).to be false end it "@show_other_user_update_status_action should be true" do expect(info_request.is_old_unclassified?).to be true - get :show, params: { :url_title => info_request.url_title } + get :show, params: { url_title: info_request.url_title } expect(assigns[:show_other_user_update_status_action]).to be true end end @@ -498,12 +498,12 @@ def make_request let(:info_request) { FactoryBot.create(:info_request) } it "@show_owner_update_status_action should be true" do - get :show, params: { :url_title => info_request.url_title } + get :show, params: { url_title: info_request.url_title } expect(assigns[:show_owner_update_status_action]).to be true end it "@show_other_user_update_status_action should be false" do - get :show, params: { :url_title => info_request.url_title } + get :show, params: { url_title: info_request.url_title } expect(assigns[:show_other_user_update_status_action]).to be false end end @@ -516,7 +516,7 @@ def make_request end it "should hide all status update options" do - get :show, params: { :url_title => info_request.url_title } + get :show, params: { url_title: info_request.url_title } expect(assigns[:show_owner_update_status_action]).to be false expect(assigns[:show_other_user_update_status_action]).to be false end @@ -635,7 +635,7 @@ def expect_hidden(hidden_template) it "should return matching bodies" do sign_in @user - get :select_authority, params: { :query => "Quango" } + get :select_authority, params: { query: "Quango" } expect(response).to render_template('select_authority') assigns[:xapian_requests].results.size == 1 @@ -726,19 +726,19 @@ def expect_hidden(hidden_template) it "should redirect to front page if no public body specified" do get :new - expect(response).to redirect_to(:controller => 'general', :action => 'frontpage') + expect(response).to redirect_to(controller: 'general', action: 'frontpage') end it "should redirect to front page if no public body specified, when logged in" do sign_in @user get :new - expect(response).to redirect_to(:controller => 'general', :action => 'frontpage') + expect(response).to redirect_to(controller: 'general', action: 'frontpage') end it "should redirect 'bad request' page when a body has no email address" do @body.request_email = "" @body.save! - get :new, params: { :public_body_id => @body.id } + get :new, params: { public_body_id: @body.id } expect(response).to render_template('new_bad_contact') end @@ -748,13 +748,13 @@ def expect_hidden(hidden_template) it "displays a flash error message without escaping the HTML" do post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "Test Request" + info_request: { + public_body_id: @body.id, + title: "Test Request" }, - :outgoing_message => { :body => "me@here.com" }, - :submitted_new_request => 1, - :preview => 1 + outgoing_message: { body: "me@here.com" }, + submitted_new_request: 1, + preview: 1 } expect(response.body).to have_css('div#error p') @@ -770,12 +770,12 @@ def expect_hidden(hidden_template) it "displays a flash error message without escaping the HTML" do sign_in @user post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "Test Request" }, - :outgoing_message => { :body => "me@here.com" }, - :submitted_new_request => 1, - :preview => 1 + info_request: { + public_body_id: @body.id, + title: "Test Request" }, + outgoing_message: { body: "me@here.com" }, + submitted_new_request: 1, + preview: 1 } expect(response.body).to have_css('div#error p') @@ -792,13 +792,13 @@ def expect_hidden(hidden_template) it 'displays an error message warning about the postcode' do post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "Test Request" + info_request: { + public_body_id: @body.id, + title: "Test Request" }, - :outgoing_message => { :body => "SW1A 1AA" }, - :submitted_new_request => 1, - :preview => 1 + outgoing_message: { body: "SW1A 1AA" }, + submitted_new_request: 1, + preview: 1 } expect(response.body).to have_content('Your request contains a postcode') @@ -836,7 +836,7 @@ def send_request pro_user = FactoryBot.create(:pro_user) public_body = FactoryBot.create(:public_body) sign_in pro_user - get :new, params: { :url_name => public_body.url_name } + get :new, params: { url_name: public_body.url_name } expected_url = new_alaveteli_pro_info_request_url( public_body: public_body.url_name) expect(response).to redirect_to(expected_url) @@ -844,13 +844,13 @@ def send_request end it "should accept a public body parameter" do - get :new, params: { :public_body_id => @body.id } + get :new, params: { public_body_id: @body.id } expect(assigns[:info_request].public_body).to eq(@body) expect(response).to render_template('new') end it 'assigns a default text for the request' do - get :new, params: { :public_body_id => @body.id } + get :new, params: { public_body_id: @body.id } expect(assigns[:info_request].public_body).to eq(@body) expect(response).to render_template('new') default_message = <<-EOF.strip_heredoc @@ -862,7 +862,7 @@ def send_request end it 'allows the default text to be set via the default_letter param' do - get :new, params: { :url_name => @body.url_name, :default_letter => "test" } + get :new, params: { url_name: @body.url_name, default_letter: "test" } default_message = <<-EOF.strip_heredoc Dear Geraldine Quango, @@ -875,10 +875,10 @@ def send_request it 'should display one meaningful error message when no message body is added' do post :new, params: { - :info_request => { :public_body_id => @body.id }, - :outgoing_message => { :body => "" }, - :submitted_new_request => 1, - :preview => 1 + info_request: { public_body_id: @body.id }, + outgoing_message: { body: "" }, + submitted_new_request: 1, + preview: 1 } expect(assigns[:info_request].errors.full_messages).not_to include('Outgoing messages is invalid') expect(assigns[:outgoing_message].errors.full_messages).to include('Body Please enter your letter requesting information') @@ -887,41 +887,40 @@ def send_request it "should give an error and render 'new' template when a summary isn't given" do post :new, params: { - :info_request => { :public_body_id => @body.id }, - :outgoing_message => { - :body => - "This is a silly letter. It is too short to be interesting." + info_request: { public_body_id: @body.id }, + outgoing_message: { + body: "This is a silly letter. It is too short to be interesting." }, - :submitted_new_request => 1, - :preview => 1 + submitted_new_request: 1, + preview: 1 } expect(assigns[:info_request].errors[:title]).not_to be_nil expect(response).to render_template('new') end it "should redirect to sign in page when input is good and nobody is logged in" do - params = { :info_request => { :public_body_id => @body.id, - :title => "Why is your quango called Geraldine?", :tag_string => "" }, - :outgoing_message => { :body => "This is a silly letter. It is too short to be interesting." }, - :submitted_new_request => 1, :preview => 0 + params = { info_request: { public_body_id: @body.id, + title: "Why is your quango called Geraldine?", tag_string: "" }, + outgoing_message: { body: "This is a silly letter. It is too short to be interesting." }, + submitted_new_request: 1, preview: 0 } post :new, params: params expect(response). - to redirect_to(signin_path(:token => get_last_post_redirect.token)) + to redirect_to(signin_path(token: get_last_post_redirect.token)) # post_redirect.post_params.should == params # TODO: get this working. there's a : vs '' problem amongst others end it 'redirects to the frontpage if the action is sent the invalid public_body param' do post :new, params: { - :info_request => { - :public_body => @body.id, - :title => 'Why Geraldine?', - :tag_string => '' + info_request: { + public_body: @body.id, + title: 'Why Geraldine?', + tag_string: '' }, - :outgoing_message => { :body => 'This is a silly letter.'}, - :submitted_new_request => 1, - :preview => 1 + outgoing_message: { body: 'This is a silly letter.'}, + submitted_new_request: 1, + preview: 1 } expect(response).to redirect_to frontpage_url end @@ -929,50 +928,50 @@ def send_request it "should show preview when input is good" do sign_in @user post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "Why is your quango called Geraldine?", - :tag_string => "" + info_request: { + public_body_id: @body.id, + title: "Why is your quango called Geraldine?", + tag_string: "" }, - :outgoing_message => { - :body => "This is a silly letter. It is too short to be interesting." + outgoing_message: { + body: "This is a silly letter. It is too short to be interesting." }, - :submitted_new_request => 1, - :preview => 1 + submitted_new_request: 1, + preview: 1 } expect(response).to render_template('preview') end it "should allow re-editing of a request" do post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "Why is your quango called Geraldine?", - :tag_string => "" + info_request: { + public_body_id: @body.id, + title: "Why is your quango called Geraldine?", + tag_string: "" }, - :outgoing_message => { - :body => "This is a silly letter. It is too short to be interesting." + outgoing_message: { + body: "This is a silly letter. It is too short to be interesting." }, - :submitted_new_request => 1, - :preview => 0, - :reedit => "Re-edit this request" + submitted_new_request: 1, + preview: 0, + reedit: "Re-edit this request" } expect(response).to render_template('new') end it "re-editing preserves the message body" do post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "Why is your quango called Geraldine?", - :tag_string => "" + info_request: { + public_body_id: @body.id, + title: "Why is your quango called Geraldine?", + tag_string: "" }, - :outgoing_message => { - :body => "This is a silly letter. It is too short to be interesting." + outgoing_message: { + body: "This is a silly letter. It is too short to be interesting." }, - :submitted_new_request => 1, - :preview => 0, - :reedit => "Re-edit this request" + submitted_new_request: 1, + preview: 0, + reedit: "Re-edit this request" } expect(assigns[:outgoing_message].body). to include('This is a silly letter. It is too short to be interesting.') @@ -981,19 +980,19 @@ def send_request it "should create the request and outgoing message, and send the outgoing message by email, and redirect to request page when input is good and somebody is logged in" do sign_in @user post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "Why is your quango called Geraldine?", - :tag_string => "" + info_request: { + public_body_id: @body.id, + title: "Why is your quango called Geraldine?", + tag_string: "" }, - :outgoing_message => { - :body => "This is a silly letter. It is too short to be interesting." + outgoing_message: { + body: "This is a silly letter. It is too short to be interesting." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } - ir_array = InfoRequest.where(:title => "Why is your quango called Geraldine?") + ir_array = InfoRequest.where(title: "Why is your quango called Geraldine?") expect(ir_array.size).to eq(1) ir = ir_array[0] expect(ir.outgoing_messages.size).to eq(1) @@ -1005,22 +1004,22 @@ def send_request mail = deliveries[0] expect(mail.body).to match(/This is a silly letter. It is too short to be interesting./) - expect(response).to redirect_to show_request_url(:url_title => ir.url_title) + expect(response).to redirect_to show_request_url(url_title: ir.url_title) end it "sets the request_sent flash to true if successful" do sign_in @user post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "Why is your quango called Geraldine?", - :tag_string => "" + info_request: { + public_body_id: @body.id, + title: "Why is your quango called Geraldine?", + tag_string: "" }, - :outgoing_message => { - :body => "This is a silly letter. It is too short to be interesting." + outgoing_message: { + body: "This is a silly letter. It is too short to be interesting." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } expect(flash[:request_sent]).to be true @@ -1032,16 +1031,16 @@ def send_request # We use raw_body here, so white space is the same post :new, params: { - :info_request => { - :public_body_id => info_requests(:fancy_dog_request).public_body_id, - :title => info_requests(:fancy_dog_request).title + info_request: { + public_body_id: info_requests(:fancy_dog_request).public_body_id, + title: info_requests(:fancy_dog_request).title }, - :outgoing_message => { - :body => info_requests(:fancy_dog_request).outgoing_messages[0].raw_body + outgoing_message: { + body: info_requests(:fancy_dog_request).outgoing_messages[0].raw_body }, - :submitted_new_request => 1, - :preview => 0, - :mouse_house => 1 + submitted_new_request: 1, + preview: 0, + mouse_house: 1 } expect(response).to render_template('new') end @@ -1051,34 +1050,33 @@ def send_request post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "Why is your quango called Geraldine?", - :tag_string => "" + info_request: { + public_body_id: @body.id, + title: "Why is your quango called Geraldine?", + tag_string: "" }, - :outgoing_message => { - :body => - "This is a silly letter. It is too short to be interesting." + outgoing_message: { + body: "This is a silly letter. It is too short to be interesting." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "Why is your quango called Geraldine?", - :tag_string => "" + info_request: { + public_body_id: @body.id, + title: "Why is your quango called Geraldine?", + tag_string: "" }, - :outgoing_message => { - :body => "This is a sensible letter. It is too long to be boring." + outgoing_message: { + body: "This is a sensible letter. It is too long to be boring." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } - ir_array = InfoRequest.where(:title => "Why is your quango called Geraldine?"). + ir_array = InfoRequest.where(title: "Why is your quango called Geraldine?"). order(:id) expect(ir_array.size).to eq(2) @@ -1087,7 +1085,7 @@ def send_request expect(ir.url_title).not_to eq(ir2.url_title) - expect(response).to redirect_to show_request_url(:url_title => ir2.url_title) + expect(response).to redirect_to show_request_url(url_title: ir2.url_title) end it 'should respect the rate limit' do @@ -1096,48 +1094,48 @@ def send_request sign_in users(:robin_user) post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "What is the answer to the ultimate question?", - :tag_string => "" + info_request: { + public_body_id: @body.id, + title: "What is the answer to the ultimate question?", + tag_string: "" }, - :outgoing_message => { - :body => "Please supply the answer from your files." + outgoing_message: { + body: "Please supply the answer from your files." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } - expect(response).to redirect_to show_request_url(:url_title => 'what_is_the_answer_to_the_ultima') + expect(response).to redirect_to show_request_url(url_title: 'what_is_the_answer_to_the_ultima') post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "Why did the chicken cross the road?", - :tag_string => "" + info_request: { + public_body_id: @body.id, + title: "Why did the chicken cross the road?", + tag_string: "" }, - :outgoing_message => { - :body => "Please send me all the relevant documents you hold." + outgoing_message: { + body: "Please send me all the relevant documents you hold." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } - expect(response).to redirect_to show_request_url(:url_title => 'why_did_the_chicken_cross_the_ro') + expect(response).to redirect_to show_request_url(url_title: 'why_did_the_chicken_cross_the_ro') post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "What's black and white and red all over?", - :tag_string => "" + info_request: { + public_body_id: @body.id, + title: "What's black and white and red all over?", + tag_string: "" }, - :outgoing_message => { - :body => "Please send all minutes of meetings and email records " \ + outgoing_message: { + body: "Please send all minutes of meetings and email records " \ "that address this question." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } expect(response).to render_template('user/rate_limited') end @@ -1150,50 +1148,50 @@ def send_request users(:robin_user).save! post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "What is the answer to the ultimate question?", - :tag_string => "" + info_request: { + public_body_id: @body.id, + title: "What is the answer to the ultimate question?", + tag_string: "" }, - :outgoing_message => { - :body => "Please supply the answer from your files." + outgoing_message: { + body: "Please supply the answer from your files." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } - expect(response).to redirect_to show_request_url(:url_title => 'what_is_the_answer_to_the_ultima') + expect(response).to redirect_to show_request_url(url_title: 'what_is_the_answer_to_the_ultima') post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "Why did the chicken cross the road?", - :tag_string => "" + info_request: { + public_body_id: @body.id, + title: "Why did the chicken cross the road?", + tag_string: "" }, - :outgoing_message => { - :body => "Please send me all the relevant documents you hold." + outgoing_message: { + body: "Please send me all the relevant documents you hold." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } - expect(response).to redirect_to show_request_url(:url_title => 'why_did_the_chicken_cross_the_ro') + expect(response).to redirect_to show_request_url(url_title: 'why_did_the_chicken_cross_the_ro') post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "What's black and white and red all over?", - :tag_string => "" + info_request: { + public_body_id: @body.id, + title: "What's black and white and red all over?", + tag_string: "" }, - :outgoing_message => { - :body => "Please send all minutes of meetings and email records " \ + outgoing_message: { + body: "Please send all minutes of meetings and email records " \ "that address this question." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } - expect(response).to redirect_to show_request_url(:url_title => 'whats_black_and_white_and_red_al') + expect(response).to redirect_to show_request_url(url_title: 'whats_black_and_white_and_red_al') end describe 'when rendering a reCAPTCHA' do @@ -1207,14 +1205,14 @@ def send_request it 'sets render_recaptcha to false' do post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "What's black and white and red all over?", - :tag_string => "" + info_request: { + public_body_id: @body.id, + title: "What's black and white and red all over?", + tag_string: "" }, - :outgoing_message => { :body => "Please send info" }, - :submitted_new_request => 1, - :preview => 0 + outgoing_message: { body: "Please send info" }, + submitted_new_request: 1, + preview: 0 } expect(assigns[:render_recaptcha]).to eq(false) end @@ -1229,46 +1227,46 @@ def send_request it 'sets render_recaptcha to true if there is no logged in user' do post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "What's black and white and red all over?", - :tag_string => "" + info_request: { + public_body_id: @body.id, + title: "What's black and white and red all over?", + tag_string: "" }, - :outgoing_message => { :body => "Please send info" }, - :submitted_new_request => 1, - :preview => 0 + outgoing_message: { body: "Please send info" }, + submitted_new_request: 1, + preview: 0 } expect(assigns[:render_recaptcha]).to eq(true) end it 'sets render_recaptcha to true if there is a logged in user who is not confirmed as not spam' do - sign_in FactoryBot.create(:user, :confirmed_not_spam => false) + sign_in FactoryBot.create(:user, confirmed_not_spam: false) post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "What's black and white and red all over?", - :tag_string => "" + info_request: { + public_body_id: @body.id, + title: "What's black and white and red all over?", + tag_string: "" }, - :outgoing_message => { :body => "Please send info" }, - :submitted_new_request => 1, - :preview => 0 + outgoing_message: { body: "Please send info" }, + submitted_new_request: 1, + preview: 0 } expect(assigns[:render_recaptcha]).to eq(true) end it 'sets render_recaptcha to false if there is a logged in user who is confirmed as not spam' do - sign_in FactoryBot.create(:user, :confirmed_not_spam => true) + sign_in FactoryBot.create(:user, confirmed_not_spam: true) post :new, params: { - :info_request => { - :public_body_id => @body.id, - :title => "What's black and white and red all over?", - :tag_string => "" + info_request: { + public_body_id: @body.id, + title: "What's black and white and red all over?", + tag_string: "" }, - :outgoing_message => { :body => "Please send info" }, - :submitted_new_request => 1, - :preview => 0 + outgoing_message: { body: "Please send info" }, + submitted_new_request: 1, + preview: 0 } expect(assigns[:render_recaptcha]).to eq(false) end @@ -1280,22 +1278,22 @@ def send_request end let(:user) { FactoryBot.create(:user, - :confirmed_not_spam => false) } + confirmed_not_spam: false) } let(:body) { FactoryBot.create(:public_body) } it 'shows an error message' do sign_in user post :new, params: { - :info_request => { - :public_body_id => body.id, - :title => "Some request text", - :tag_string => "" + info_request: { + public_body_id: body.id, + title: "Some request text", + tag_string: "" }, - :outgoing_message => { - :body => "Please supply the answer from your files." + outgoing_message: { + body: "Please supply the answer from your files." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } expect(flash[:error]) .to eq('There was an error with the reCAPTCHA. Please try again.') @@ -1304,16 +1302,16 @@ def send_request it 'renders the compose interface' do sign_in user post :new, params: { - :info_request => { - :public_body_id => body.id, - :title => "Some request text", - :tag_string => "" + info_request: { + public_body_id: body.id, + title: "Some request text", + tag_string: "" }, - :outgoing_message => { - :body => "Please supply the answer from your files." + outgoing_message: { + body: "Please supply the answer from your files." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } expect(response).to render_template("new") end @@ -1323,19 +1321,19 @@ def send_request user.save! sign_in user post :new, params: { - :info_request => { - :public_body_id => body.id, - :title => "Some request text", - :tag_string => "" + info_request: { + public_body_id: body.id, + title: "Some request text", + tag_string: "" }, - :outgoing_message => { - :body => "Please supply the answer from your files." + outgoing_message: { + body: "Please supply the answer from your files." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } expect(response) - .to redirect_to show_request_path(:url_title => 'some_request_text') + .to redirect_to show_request_path(url_title: 'some_request_text') end end @@ -1347,7 +1345,7 @@ def send_request context 'when the request subject line looks like spam' do let(:user) { FactoryBot.create(:user, - :confirmed_not_spam => false) } + confirmed_not_spam: false) } let(:body) { FactoryBot.create(:public_body) } @@ -1359,16 +1357,16 @@ def send_request sign_in user title = "▩█ -Free Ɓrazzers Password Hăck Premium Account List 2017 ᒬᒬ" post :new, params: { - :info_request => { - :public_body_id => body.id, - :title => title, - :tag_string => "" + info_request: { + public_body_id: body.id, + title: title, + tag_string: "" }, - :outgoing_message => { - :body => "Please supply the answer." + outgoing_message: { + body: "Please supply the answer." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } mail = ActionMailer::Base.deliveries.first expect(mail.subject).to match(/Spam request from user #{ user.id }/) @@ -1389,16 +1387,16 @@ def send_request sign_in user post :new, params: { - :info_request => { - :public_body_id => body.id, - :title => "[HD] Watch Jason Bourne Online free MOVIE Full-HD", - :tag_string => "" + info_request: { + public_body_id: body.id, + title: "[HD] Watch Jason Bourne Online free MOVIE Full-HD", + tag_string: "" }, - :outgoing_message => { - :body => "Please supply the answer." + outgoing_message: { + body: "Please supply the answer." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } mail = ActionMailer::Base.deliveries.first expect(mail.subject).to match(/Spam request from user #{ user.id }/) @@ -1416,16 +1414,16 @@ def send_request sign_in user post :new, params: { - :info_request => { - :public_body_id => body.id, - :title => "[HD] Watch Jason Bourne Online free MOVIE Full-HD", - :tag_string => "" + info_request: { + public_body_id: body.id, + title: "[HD] Watch Jason Bourne Online free MOVIE Full-HD", + tag_string: "" }, - :outgoing_message => { - :body => "Please supply the answer from your files." + outgoing_message: { + body: "Please supply the answer from your files." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } mail = ActionMailer::Base.deliveries.first expect(mail.subject).to match(/Spam request from user #{ user.id }/) @@ -1435,16 +1433,16 @@ def send_request sign_in user post :new, params: { - :info_request => { - :public_body_id => body.id, - :title => "[HD] Watch Jason Bourne Online free MOVIE Full-HD", - :tag_string => "" + info_request: { + public_body_id: body.id, + title: "[HD] Watch Jason Bourne Online free MOVIE Full-HD", + tag_string: "" }, - :outgoing_message => { - :body => "Please supply the answer from your files." + outgoing_message: { + body: "Please supply the answer from your files." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } expect(flash[:error]) .to eq("Sorry, we're currently unable to send your request. Please try again later.") @@ -1454,16 +1452,16 @@ def send_request sign_in user post :new, params: { - :info_request => { - :public_body_id => body.id, - :title => "[HD] Watch Jason Bourne Online free MOVIE Full-HD", - :tag_string => "" + info_request: { + public_body_id: body.id, + title: "[HD] Watch Jason Bourne Online free MOVIE Full-HD", + tag_string: "" }, - :outgoing_message => { - :body => "Please supply the answer from your files." + outgoing_message: { + body: "Please supply the answer from your files." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } expect(response).to render_template("new") end @@ -1474,19 +1472,19 @@ def send_request sign_in user post :new, params: { - :info_request => { - :public_body_id => body.id, - :title => "[HD] Watch Jason Bourne Online free MOVIE Full-HD", - :tag_string => "" + info_request: { + public_body_id: body.id, + title: "[HD] Watch Jason Bourne Online free MOVIE Full-HD", + tag_string: "" }, - :outgoing_message => { - :body => "Please supply the answer from your files." + outgoing_message: { + body: "Please supply the answer from your files." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } expect(response) - .to redirect_to show_request_path(:url_title => 'hd_watch_jason_bourne_online_fre') + .to redirect_to show_request_path(url_title: 'hd_watch_jason_bourne_online_fre') end end @@ -1501,16 +1499,16 @@ def send_request sign_in user post :new, params: { - :info_request => { - :public_body_id => body.id, - :title => "[HD] Watch Jason Bourne Online free MOVIE Full-HD", - :tag_string => "" + info_request: { + public_body_id: body.id, + title: "[HD] Watch Jason Bourne Online free MOVIE Full-HD", + tag_string: "" }, - :outgoing_message => { - :body => "Please supply the answer from your files." + outgoing_message: { + body: "Please supply the answer from your files." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } mail = ActionMailer::Base.deliveries.first expect(mail.subject).to match(/Spam request from user #{ user.id }/) @@ -1520,19 +1518,19 @@ def send_request sign_in user post :new, params: { - :info_request => { - :public_body_id => body.id, - :title => "[HD] Watch Jason Bourne Online free MOVIE Full-HD", - :tag_string => "" + info_request: { + public_body_id: body.id, + title: "[HD] Watch Jason Bourne Online free MOVIE Full-HD", + tag_string: "" }, - :outgoing_message => { - :body => "Please supply the answer from your files." + outgoing_message: { + body: "Please supply the answer from your files." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } expect(response) - .to redirect_to show_request_path(:url_title => 'hd_watch_jason_bourne_online_fre') + .to redirect_to show_request_path(url_title: 'hd_watch_jason_bourne_online_fre') end end @@ -1542,7 +1540,7 @@ def send_request describe 'when the request is from an IP address in a blocked country' do let(:user) { FactoryBot.create(:user, - :confirmed_not_spam => false) } + confirmed_not_spam: false) } let(:body) { FactoryBot.create(:public_body) } before do @@ -1560,16 +1558,16 @@ def send_request it 'sends an exception notification' do sign_in user post :new, params: { - :info_request => { - :public_body_id => body.id, - :title => "Some request content", - :tag_string => "" + info_request: { + public_body_id: body.id, + title: "Some request content", + tag_string: "" }, - :outgoing_message => { - :body => "Please supply the answer from your files." + outgoing_message: { + body: "Please supply the answer from your files." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } mail = ActionMailer::Base.deliveries.first expect(mail.subject). @@ -1579,16 +1577,16 @@ def send_request it 'shows an error message' do sign_in user post :new, params: { - :info_request => { - :public_body_id => body.id, - :title => "Some request content", - :tag_string => "" + info_request: { + public_body_id: body.id, + title: "Some request content", + tag_string: "" }, - :outgoing_message => { - :body => "Please supply the answer from your files." + outgoing_message: { + body: "Please supply the answer from your files." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } expect(flash[:error]) .to eq("Sorry, we're currently unable to send your request. Please try again later.") @@ -1597,16 +1595,16 @@ def send_request it 'renders the compose interface' do sign_in user post :new, params: { - :info_request => { - :public_body_id => body.id, - :title => "Some request content", - :tag_string => "" + info_request: { + public_body_id: body.id, + title: "Some request content", + tag_string: "" }, - :outgoing_message => { - :body => "Please supply the answer from your files." + outgoing_message: { + body: "Please supply the answer from your files." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } expect(response).to render_template("new") end @@ -1616,19 +1614,19 @@ def send_request user.save! sign_in user post :new, params: { - :info_request => { - :public_body_id => body.id, - :title => "Some request content", - :tag_string => "" + info_request: { + public_body_id: body.id, + title: "Some request content", + tag_string: "" }, - :outgoing_message => { - :body => "Please supply the answer from your files." + outgoing_message: { + body: "Please supply the answer from your files." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } expect(response) - .to redirect_to show_request_path(:url_title => 'some_request_content') + .to redirect_to show_request_path(url_title: 'some_request_content') end end @@ -1643,16 +1641,16 @@ def send_request it 'sends an exception notification' do sign_in user post :new, params: { - :info_request => { - :public_body_id => body.id, - :title => "Some request content", - :tag_string => "" + info_request: { + public_body_id: body.id, + title: "Some request content", + tag_string: "" }, - :outgoing_message => { - :body => "Please supply the answer from your files." + outgoing_message: { + body: "Please supply the answer from your files." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } mail = ActionMailer::Base.deliveries.first expect(mail.subject). @@ -1662,19 +1660,19 @@ def send_request it 'allows the request' do sign_in user post :new, params: { - :info_request => { - :public_body_id => body.id, - :title => "Some request content", - :tag_string => "" + info_request: { + public_body_id: body.id, + title: "Some request content", + tag_string: "" }, - :outgoing_message => { - :body => "Please supply the answer from your files." + outgoing_message: { + body: "Please supply the answer from your files." }, - :submitted_new_request => 1, - :preview => 0 + submitted_new_request: 1, + preview: 0 } expect(response) - .to redirect_to show_request_path(:url_title => 'some_request_content') + .to redirect_to show_request_path(url_title: 'some_request_content') end end @@ -1695,20 +1693,20 @@ def send_request allow(@user).to receive(:login_token).and_return('abc') allow(User).to receive(:find_by).with(id: @user.id, login_token: 'abc'). and_return(@user) - @body = FactoryBot.create(:public_body, :name => 'Test Quango') + @body = FactoryBot.create(:public_body, name: 'Test Quango') end it "should allow you to have one undescribed request" do allow(@user).to receive(:get_undescribed_requests).and_return([ 1 ]) sign_in @user - get :new, params: { :public_body_id => @body.id } + get :new, params: { public_body_id: @body.id } expect(response).to render_template('new') end it "should fail if more than one request undescribed" do allow(@user).to receive(:get_undescribed_requests).and_return([ 1, 2 ]) sign_in @user - get :new, params: { :public_body_id => @body.id } + get :new, params: { public_body_id: @body.id } expect(response).to render_template('new_please_describe') end @@ -1718,7 +1716,7 @@ def send_request to receive(:exceeded_limit?).with(:info_requests).and_return(false) expect(@user).to receive(:can_fail_html).and_return('FAIL!') sign_in @user - get :new, params: { :public_body_id => @body.id } + get :new, params: { public_body_id: @body.id } expect(response).to render_template('user/banned') end @@ -1732,19 +1730,19 @@ def send_request it "should link to the user who submitted it" do sign_in users(:bob_smith_user) - get :show, params: { :url_title => 'why_do_you_have_such_a_fancy_dog' } + get :show, params: { url_title: 'why_do_you_have_such_a_fancy_dog' } expect(response.body).to have_css("div#comment-1 h2") do |s| - expect(s).to contain /Silly.*left an annotation/m - expect(s).not_to contain /You.*left an annotation/m + expect(s).to have_text(/Silly.*left an annotation/m) + expect(s).not_to have_text(/You.*left an annotation/m) end end it "should link to the user who submitted to it, even if it is you" do sign_in users(:silly_name_user) - get :show, params: { :url_title => 'why_do_you_have_such_a_fancy_dog' } + get :show, params: { url_title: 'why_do_you_have_such_a_fancy_dog' } expect(response.body).to have_css("div#comment-1 h2") do |s| - expect(s).to contain /Silly.*left an annotation/m - expect(s).not_to contain /You.*left an annotation/m + expect(s).to have_text(/Silly.*left an annotation/m) + expect(s).not_to have_text(/You.*left an annotation/m) end end @@ -1756,12 +1754,12 @@ def send_request before(:each) do # domain after the @ is used for authentication of FOI officers, so to test it # we need a user which isn't at localhost. - @normal_user = User.new(:name => "Mr. Normal", :email => "normal-user@flourish.org", - :password => PostRedirect.generate_random_token) + @normal_user = User.new(name: "Mr. Normal", email: "normal-user@flourish.org", + password: PostRedirect.generate_random_token) @normal_user.save! - @foi_officer_user = User.new(:name => "The Geraldine Quango", :email => "geraldine-requests@localhost", - :password => PostRedirect.generate_random_token) + @foi_officer_user = User.new(name: "The Geraldine Quango", email: "geraldine-requests@localhost", + password: PostRedirect.generate_random_token) @foi_officer_user.save! end @@ -1770,7 +1768,7 @@ def send_request it 'raises an ActiveRecord::RecordNotFound error' do expect { - get :upload_response, params: { :url_title => embargoed_request.url_title } + get :upload_response, params: { url_title: embargoed_request.url_title } }.to raise_error(ActiveRecord::RecordNotFound) end end @@ -1790,7 +1788,7 @@ def send_request expect(@ir.public_body.is_foi_officer?(@normal_user)).to eq(false) sign_in @normal_user - get :upload_response, params: { :url_title => 'why_do_you_have_such_a_fancy_dog' } + get :upload_response, params: { url_title: 'why_do_you_have_such_a_fancy_dog' } expect(response).to render_template('user/wrong_user') end @@ -1799,7 +1797,7 @@ def send_request expect(@ir.public_body.is_foi_officer?(@foi_officer_user)).to eq(true) sign_in @foi_officer_user - get :upload_response, params: { :url_title => 'why_do_you_have_such_a_fancy_dog' } + get :upload_response, params: { url_title: 'why_do_you_have_such_a_fancy_dog' } expect(response).to render_template('request/upload_response') end @@ -1811,10 +1809,10 @@ def send_request # post up a photo of the parrot parrot_upload = fixture_file_upload('parrot.png', 'image/png') post :upload_response, params: { - :url_title => 'why_do_you_have_such_a_fancy_dog', - :body => "Find attached a picture of a parrot", - :file_1 => parrot_upload, - :submitted_upload_response => 1 + url_title: 'why_do_you_have_such_a_fancy_dog', + body: "Find attached a picture of a parrot", + file_1: parrot_upload, + submitted_upload_response: 1 } expect(response).to render_template('user/wrong_user') end @@ -1822,14 +1820,14 @@ def send_request it "should prevent entirely blank uploads" do sign_in @foi_officer_user - post :upload_response, params: { :url_title => 'why_do_you_have_such_a_fancy_dog', :body => "", :submitted_upload_response => 1 } + post :upload_response, params: { url_title: 'why_do_you_have_such_a_fancy_dog', body: "", submitted_upload_response: 1 } expect(response).to render_template('request/upload_response') expect(flash[:error]).to match(/Please type a message/) end it 'should 404 for non existent requests' do expect { - post :upload_response, params: { :url_title => 'i_dont_exist' } + post :upload_response, params: { url_title: 'i_dont_exist' } }.to raise_error(ActiveRecord::RecordNotFound) end @@ -1843,13 +1841,13 @@ def send_request # post up a photo of the parrot parrot_upload = fixture_file_upload('parrot.png', 'image/png') post :upload_response, params: { - :url_title => 'why_do_you_have_such_a_fancy_dog', - :body => "Find attached a picture of a parrot", - :file_1 => parrot_upload, - :submitted_upload_response => 1 + url_title: 'why_do_you_have_such_a_fancy_dog', + body: "Find attached a picture of a parrot", + file_1: parrot_upload, + submitted_upload_response: 1 } - expect(response).to redirect_to(:action => 'show', :url_title => 'why_do_you_have_such_a_fancy_dog') + expect(response).to redirect_to(action: 'show', url_title: 'why_do_you_have_such_a_fancy_dog') expect(flash[:notice]).to match(/Thank you for responding to this FOI request/) # check there is a new attachment @@ -1873,7 +1871,7 @@ def send_request end it "should return data in JSON form" do - get :show, params: { :url_title => 'why_do_you_have_such_a_fancy_dog', :format => 'json' } + get :show, params: { url_title: 'why_do_you_have_such_a_fancy_dog', format: 'json' } ir = JSON.parse(response.body) expect(ir.class.to_s).to eq('Hash') @@ -1892,17 +1890,17 @@ def send_request end it 'can filter search results by public body' do - get :search_typeahead, params: { :q => 'boring', :requested_from => 'dfh' } + get :search_typeahead, params: { q: 'boring', requested_from: 'dfh' } expect(assigns[:query]).to eq('requested_from:dfh boring') end it 'defaults to 25 results per page' do - get :search_typeahead, params: { :q => 'boring' } + get :search_typeahead, params: { q: 'boring' } expect(assigns[:per_page]).to eq(25) end it 'can limit the number of searches returned' do - get :search_typeahead, params: { :q => 'boring', :per_page => '1' } + get :search_typeahead, params: { q: 'boring', per_page: '1' } expect(assigns[:per_page]).to eq(1) expect(assigns[:xapian_requests].results.size).to eq(1) end @@ -1920,20 +1918,20 @@ def send_request it "renders the 'similar' template" do get :similar, params: { - :url_title => info_requests(:badger_request).url_title + url_title: info_requests(:badger_request).url_title } expect(response).to render_template("request/similar") end it 'assigns the request' do get :similar, params: { - :url_title => info_requests(:badger_request).url_title + url_title: info_requests(:badger_request).url_title } expect(assigns[:info_request]).to eq(info_requests(:badger_request)) end it "assigns a xapian object with similar requests" do - get :similar, params: { :url_title => badger_request.url_title } + get :similar, params: { url_title: badger_request.url_title } # Xapian seems to think *all* the requests are similar results = assigns[:xapian_object].results @@ -1945,7 +1943,7 @@ def send_request it "raises ActiveRecord::RecordNotFound for non-existent paths" do expect { get :similar, params: { - :url_title => "there_is_really_no_such_path_owNAFkHR" + url_title: "there_is_really_no_such_path_owNAFkHR" } }.to raise_error(ActiveRecord::RecordNotFound) end @@ -1954,16 +1952,16 @@ def send_request page we want to show" do expect { get :similar, params: { - :url_title => badger_request.url_title, - :page => 100 + url_title: badger_request.url_title, + page: 100 } }.to raise_error(ActiveRecord::RecordNotFound) end it 'raises ActiveRecord::RecordNotFound if the request is embargoed' do - badger_request.create_embargo(:publish_at => Time.zone.now + 3.days) + badger_request.create_embargo(publish_at: Time.zone.now + 3.days) expect { - get :similar, params: { :url_title => badger_request.url_title } + get :similar, params: { url_title: badger_request.url_title } }.to raise_error(ActiveRecord::RecordNotFound) end @@ -2004,23 +2002,23 @@ def send_request let(:info_request) { FactoryBot.create(:info_request) } it 'renders the details template' do - get :details, params: { :url_title => info_request.url_title } + get :details, params: { url_title: info_request.url_title } expect(response).to render_template('details') end it 'assigns the info_request' do - get :details, params: { :url_title => info_request.url_title } + get :details, params: { url_title: info_request.url_title } expect(assigns[:info_request]).to eq(info_request) end it 'assigns columns' do - get :details, params: { :url_title => info_request.url_title } - expected_columns = ['id', - 'event_type', - 'created_at', - 'described_state', - 'last_described_at', - 'calculated_state' ] + get :details, params: { url_title: info_request.url_title } + expected_columns = %w[id + event_type + created_at + described_state + last_described_at + calculated_state] expect(assigns[:columns]).to eq expected_columns end @@ -2032,12 +2030,12 @@ def send_request end it 'returns a 403' do - get :details, params: { :url_title => info_request.url_title } + get :details, params: { url_title: info_request.url_title } expect(response.code).to eq("403") end it 'shows the hidden request template' do - get :details, params: { :url_title => info_request.url_title } + get :details, params: { url_title: info_request.url_title } expect(response).to render_template("request/hidden") end @@ -2046,12 +2044,12 @@ def send_request context 'when the request is embargoed' do before do - info_request.create_embargo(:publish_at => Time.zone.now + 3.days) + info_request.create_embargo(publish_at: Time.zone.now + 3.days) end it 'raises an ActiveRecord::RecordNotFound error' do expect { - get :details, params: { :url_title => info_request.url_title } + get :details, params: { url_title: info_request.url_title } }.to raise_error(ActiveRecord::RecordNotFound) end end @@ -2075,7 +2073,7 @@ def send_request it 'raises ActiveRecord::RecordNotFound' do expect { get :download_entire_request, - params: { :url_title => info_request.url_title } + params: { url_title: info_request.url_title } }.to raise_error(ActiveRecord::RecordNotFound) end end @@ -2088,7 +2086,7 @@ def send_request it 'raises ActiveRecord::RecordNotFound' do expect { get :download_entire_request, - params: { :url_title => info_request.url_title } + params: { url_title: info_request.url_title } }.to raise_error(ActiveRecord::RecordNotFound) end end @@ -2100,7 +2098,7 @@ def send_request it 'allows the download' do get :download_entire_request, - params: { :url_title => info_request.url_title } + params: { url_title: info_request.url_title } expect(response).to be_successful end end @@ -2110,10 +2108,10 @@ def send_request it 'does not render the describe state form' do info_request = FactoryBot.create(:info_request) - info_request.update(:awaiting_description => true) + info_request.update(awaiting_description: true) info_request.expire sign_in info_request.user - get :download_entire_request, params: { :url_title => info_request.url_title } + get :download_entire_request, params: { url_title: info_request.url_title } expect(assigns[:show_top_describe_state_form]).to eq(false) expect(assigns[:show_bottom_describe_state_form]).to eq(false) expect(assigns[:show_owner_update_status_action]).to eq(false) @@ -2133,20 +2131,20 @@ def send_request let(:event) { FactoryBot.create(:response_event) } it 'returns a 301 status' do - get :show_request_event, params: { :info_request_event_id => event.id } + get :show_request_event, params: { info_request_event_id: event.id } expect(response.status).to eq(301) end it 'redirects to the incoming message path' do - get :show_request_event, params: { :info_request_event_id => event.id } + get :show_request_event, params: { info_request_event_id: event.id } expect(response) .to redirect_to(incoming_message_path(event.incoming_message)) end it 'raises ActiveRecord::RecordNotFound when the request is embargoed' do - event.info_request.create_embargo(:publish_at => Time.zone.now + 1.day) + event.info_request.create_embargo(publish_at: Time.zone.now + 1.day) expect { - get :show_request_event, params: { :info_request_event_id => event.id } + get :show_request_event, params: { info_request_event_id: event.id } }.to raise_error ActiveRecord::RecordNotFound end end @@ -2155,20 +2153,20 @@ def send_request let(:event) { FactoryBot.create(:sent_event) } it 'returns a 301 status' do - get :show_request_event, params: { :info_request_event_id => event.id } + get :show_request_event, params: { info_request_event_id: event.id } expect(response.status).to eq(301) end it 'redirects to the outgoing message path' do - get :show_request_event, params: { :info_request_event_id => event.id } + get :show_request_event, params: { info_request_event_id: event.id } expect(response) .to redirect_to(outgoing_message_path(event.outgoing_message)) end it 'raises ActiveRecord::RecordNotFound when the request is embargoed' do - event.info_request.create_embargo(:publish_at => Time.zone.now + 1.day) + event.info_request.create_embargo(publish_at: Time.zone.now + 1.day) expect { - get :show_request_event, params: { :info_request_event_id => event.id } + get :show_request_event, params: { info_request_event_id: event.id } }.to raise_error ActiveRecord::RecordNotFound end end @@ -2177,20 +2175,20 @@ def send_request let(:event) { FactoryBot.create(:info_request_event) } it 'returns a 301 status' do - get :show_request_event, params: { :info_request_event_id => event.id } + get :show_request_event, params: { info_request_event_id: event.id } expect(response.status).to eq(301) end it 'redirects to the request path' do - get :show_request_event, params: { :info_request_event_id => event.id } + get :show_request_event, params: { info_request_event_id: event.id } expect(response) .to redirect_to(show_request_path(event.info_request.url_title)) end it 'raises ActiveRecord::RecordNotFound when the request is embargoed' do - event.info_request.create_embargo(:publish_at => Time.zone.now + 1.day) + event.info_request.create_embargo(publish_at: Time.zone.now + 1.day) expect { - get :show_request_event, params: { :info_request_event_id => event.id } + get :show_request_event, params: { info_request_event_id: event.id } }.to raise_error ActiveRecord::RecordNotFound end end diff --git a/spec/controllers/request_game_controller_spec.rb b/spec/controllers/request_game_controller_spec.rb index 78596a1464..1c1a0862ee 100644 --- a/spec/controllers/request_game_controller_spec.rb +++ b/spec/controllers/request_game_controller_spec.rb @@ -48,7 +48,7 @@ render_views - let(:test_url) { help_credits_path(:anchor => "helpus") } + let(:test_url) { help_credits_path(anchor: "helpus") } it 'shows the game homepage' do get :play @@ -60,8 +60,8 @@ expect(flash.now[:notice][:partial]). to eq("request_game/game_over") expect(flash.now[:notice][:locals]).to include({ - :helpus_url => test_url, - :site_name => site_name + helpus_url: test_url, + site_name: site_name }) end @@ -71,7 +71,7 @@ expect(response.body). to have_content('All done! Thank you very much for your help') expect(response.body). - to have_link('more things you can do', :href => test_url) + to have_link('more things you can do', href: test_url) end end diff --git a/spec/controllers/services_controller_spec.rb b/spec/controllers/services_controller_spec.rb index 0c39f60594..852ca06725 100644 --- a/spec/controllers/services_controller_spec.rb +++ b/spec/controllers/services_controller_spec.rb @@ -19,7 +19,7 @@ it 'keeps the flash' do # Make two get requests to simulate the flash getting swept after the # first response. - get :other_country_message, flash: { :some_flash_key => 'abc' } + get :other_country_message, flash: { some_flash_key: 'abc' } get :other_country_message expect(flash[:some_flash_key]).to eq('abc') end diff --git a/spec/controllers/track_controller_spec.rb b/spec/controllers/track_controller_spec.rb index 08efeb21b6..92823a9088 100644 --- a/spec/controllers/track_controller_spec.rb +++ b/spec/controllers/track_controller_spec.rb @@ -6,44 +6,44 @@ describe 'GET #track_request' do let(:info_request) do FactoryBot.create(:info_request, - :title => 'My request', - :url_title => 'myrequest') + title: 'My request', + url_title: 'myrequest') end let(:track_thing) do FactoryBot.create(:request_update_track, - :info_request => info_request, - :track_medium => 'email_daily', - :track_query => 'example') + info_request: info_request, + track_medium: 'email_daily', + track_query: 'example') end - let(:user) { FactoryBot.create(:user, :locale => 'en', :name => 'bob') } + let(:user) { FactoryBot.create(:user, locale: 'en', name: 'bob') } it 'clears widget votes for the request' do allow(AlaveteliConfiguration).to receive(:enable_widgets).and_return(true) - info_request.widget_votes.create(:cookie => mock_cookie) + info_request.widget_votes.create(cookie: mock_cookie) sign_in user request.cookies['widget_vote'] = mock_cookie get :track_request, params: { - :url_title => info_request.url_title, - :feed => 'track' + url_title: info_request.url_title, + feed: 'track' } expect(info_request.reload.widget_votes).to be_empty end it "should require login when making new track" do get :track_request, params: { - :url_title => info_request.url_title, - :feed => 'track' + url_title: info_request.url_title, + feed: 'track' } expect(response) - .to redirect_to(signin_path(:token => get_last_post_redirect.token)) + .to redirect_to(signin_path(token: get_last_post_redirect.token)) end it "should set no-cache headers on the login redirect" do get :track_request, params: { - :url_title => info_request.url_title, - :feed => 'track' + url_title: info_request.url_title, + feed: 'track' } expect(response.headers["Cache-Control"]). to eq('private, no-store') @@ -56,19 +56,19 @@ allow(TrackThing).to receive(:create_track_for_request).and_return(track_thing) expect(track_thing).to receive(:save).and_call_original get :track_request, params: { - :url_title => info_request.url_title, - :feed => 'track' + url_title: info_request.url_title, + feed: 'track' } - expect(response).to redirect_to(:controller => 'request', - :action => 'show', - :url_title => info_request.url_title) + expect(response).to redirect_to(controller: 'request', + action: 'show', + url_title: info_request.url_title) end it "should 404 for non-existent requests" do sign_in user expect { - get :track_request, params: { :url_title => "hjksfdh_louytu_qqxxx", - :feed => 'track' } + get :track_request, params: { url_title: "hjksfdh_louytu_qqxxx", + feed: 'track' } }.to raise_error(ActiveRecord::RecordNotFound) end @@ -76,8 +76,8 @@ sign_in user embargoed_request = FactoryBot.create(:embargoed_request) expect { - get :track_request, params: { :url_title => embargoed_request.url_title, - :feed => 'track' } + get :track_request, params: { url_title: embargoed_request.url_title, + feed: 'track' } }.to raise_error(ActiveRecord::RecordNotFound) end @@ -93,8 +93,8 @@ track_thing = track_things(:track_fancy_dog_request) get :track_request, params: { - :feed => 'feed', - :url_title => track_thing.info_request.url_title + feed: 'feed', + url_title: track_thing.info_request.url_title } expect(response).to render_template('track/atom_feed') expect(response.media_type).to eq('application/atom+xml') @@ -114,9 +114,9 @@ track_thing = track_things(:track_fancy_dog_request) get :track_request, params: { - :feed => 'feed', - :url_title => track_thing.info_request.url_title, - :format => "json" + feed: 'feed', + url_title: track_thing.info_request.url_title, + format: "json" } a = JSON.parse(response.body) @@ -155,8 +155,8 @@ request.env['HTTP_ACCEPT'] = 'application/json,text/xml' track_thing = FactoryBot.create(:request_update_track) get :track_request, params: { - :feed => 'feed', - :url_title => track_thing.info_request.url_title + feed: 'feed', + url_title: track_thing.info_request.url_title } expect(response).to render_template('track/atom_feed') expect(response.media_type).to eq('application/atom+xml') @@ -168,36 +168,36 @@ describe "GET #track_search_query" do let(:track_thing) do FactoryBot.create(:search_track, - :track_medium => 'email_daily', - :track_query => 'example') + track_medium: 'email_daily', + track_query: 'example') end - let(:user) { FactoryBot.create(:user, :locale => 'en', :name => 'bob') } + let(:user) { FactoryBot.create(:user, locale: 'en', name: 'bob') } it "should save a search track and redirect to the right place" do sign_in user allow(TrackThing).to receive(:create_track_for_search_query).and_return(track_thing) expect(track_thing).to receive(:save).and_call_original - get :track_search_query, params: { :query_array => "bob variety:sent", - :feed => 'track' } - expect(response).to redirect_to(:controller => 'general', :action => 'search', - :combined => ["bob", "requests"]) + get :track_search_query, params: { query_array: "bob variety:sent", + feed: 'track' } + expect(response).to redirect_to(controller: 'general', action: 'search', + combined: %w[bob requests]) end it 'sets the flash message partial for a successful track' do sign_in user get :track_search_query, params: { - :query_array => 'bob variety:sent', - :feed => 'track' + query_array: 'bob variety:sent', + feed: 'track' } expected = { - :partial => 'track/track_set', - :locals => { - :user_receive_email_alerts => true, - :user_url_name => user.url_name, - :track_thing_id => TrackThing.last.id } } + partial: 'track/track_set', + locals: { + user_receive_email_alerts: true, + user_url_name: user.url_name, + track_thing_id: TrackThing.last.id } } expect(flash[:notice]).to eq(expected) end @@ -207,41 +207,41 @@ existing = FactoryBot.create(:search_track, - :tracking_user => user, - :track_medium => 'email_daily', - :track_query => 'bob variety:sent') + tracking_user: user, + track_medium: 'email_daily', + track_query: 'bob variety:sent') get :track_search_query, params: { - :query_array => 'bob variety:sent', - :feed => 'track' + query_array: 'bob variety:sent', + feed: 'track' } expected = { - :partial => 'track/already_tracking', - :locals => { :track_thing_id => existing.id } + partial: 'track/already_tracking', + locals: { track_thing_id: existing.id } } expect(flash[:notice]).to eq(expected) end it "should redirect with an error message if the query is too long" do - long_track = TrackThing.new(:track_type => 'search_query', - :track_query => "lorem ipsum " * 42) + long_track = TrackThing.new(track_type: 'search_query', + track_query: "lorem ipsum " * 42) sign_in user allow(TrackThing).to receive(:create_track_for_search_query).and_return(long_track) get :track_search_query, params: { - :query_array => "bob variety:sent", - :feed => 'track' + query_array: "bob variety:sent", + feed: 'track' } expect(flash[:error]).to match('too long') - expect(response).to redirect_to(:controller => 'general', :action => 'search', - :combined => ["bob", "requests"]) + expect(response).to redirect_to(controller: 'general', action: 'search', + combined: %w[bob requests]) end end describe "GET #track_public_body" do let(:public_body) { FactoryBot.create(:public_body) } - let(:user) { FactoryBot.create(:user, :locale => 'en', :name => 'bob') } + let(:user) { FactoryBot.create(:user, locale: 'en', name: 'bob') } before do # these tests depend on the xapian index existing, although @@ -252,28 +252,28 @@ it "should save a search track and redirect to the right place" do sign_in user - track_thing = TrackThing.new(:track_type => 'public_body_updates', - :public_body => public_body) + track_thing = TrackThing.new(track_type: 'public_body_updates', + public_body: public_body) allow(TrackThing).to receive(:create_track_for_public_body).and_return(track_thing) expect(track_thing).to receive(:save).and_call_original get :track_public_body, params: { - :url_name => public_body.url_name, - :feed => 'track', - :event_type => 'sent' + url_name: public_body.url_name, + feed: 'track', + event_type: 'sent' } expect(response).to redirect_to("/body/#{public_body.url_name}") end it "should redirect with an error message if the query is too long" do sign_in user - long_track = TrackThing.new(:track_type => 'public_body_updates', - :public_body => public_body, - :track_query => "lorem ipsum " * 42) + long_track = TrackThing.new(track_type: 'public_body_updates', + public_body: public_body, + track_query: "lorem ipsum " * 42) allow(TrackThing).to receive(:create_track_for_public_body).and_return(long_track) get :track_public_body, params: { - :url_name => public_body.url_name, - :feed => 'track', - :event_type => 'sent' + url_name: public_body.url_name, + feed: 'track', + event_type: 'sent' } expect(flash[:error]).to match('too long') expect(response).to redirect_to("/body/#{public_body.url_name}") @@ -281,8 +281,8 @@ it "should work" do get :track_public_body, params: { - :feed => 'feed', - :url_name => public_body.url_name + feed: 'feed', + url_name: public_body.url_name } expect(response).to be_successful expect(response).to render_template('track/atom_feed') @@ -294,9 +294,9 @@ it "should filter by event type" do get :track_public_body, params: { - :feed => 'feed', - :url_name => public_body.url_name, - :event_type => 'sent' + feed: 'feed', + url_name: public_body.url_name, + event_type: 'sent' } expect(response).to be_successful expect(response).to render_template('track/atom_feed') @@ -315,32 +315,32 @@ it "should save a user track and redirect to the right place" do sign_in user - track_thing = TrackThing.new(:track_type => 'user_updates', - :tracked_user => target_user, - :track_query => "requested_by:#{target_user.url_name}") + track_thing = TrackThing.new(track_type: 'user_updates', + tracked_user: target_user, + track_query: "requested_by:#{target_user.url_name}") allow(TrackThing).to receive(:create_track_for_user).and_return(track_thing) expect(track_thing).to receive(:save).and_call_original - get :track_user, params: { :url_name => target_user.url_name, - :feed => 'track' } + get :track_user, params: { url_name: target_user.url_name, + feed: 'track' } expect(response).to redirect_to("/user/#{target_user.url_name}") end it "should redirect with an error message if the query is too long" do sign_in user - long_track = TrackThing.new(:track_type => 'user_updates', - :tracked_user => target_user, - :track_query => "lorem ipsum " * 42) + long_track = TrackThing.new(track_type: 'user_updates', + tracked_user: target_user, + track_query: "lorem ipsum " * 42) allow(TrackThing).to receive(:create_track_for_user).and_return(long_track) - get :track_user, params: { :url_name => target_user.url_name, - :feed => 'track' } + get :track_user, params: { url_name: target_user.url_name, + feed: 'track' } expect(flash[:error]).to match('too long') expect(response).to redirect_to("/user/#{target_user.url_name}") end it "should return NotFound for a non-existent user" do expect { - get :track_user, params: { :feed => 'feed', - :url_name => "there_is_no_such_user" } + get :track_user, params: { feed: 'feed', + url_name: "there_is_no_such_user" } }.to raise_error(ActiveRecord::RecordNotFound) end @@ -351,22 +351,22 @@ it "should save a list track and redirect to the right place" do sign_in user - track_thing = TrackThing.new(:track_type => 'all_new_requests', - :track_query => "variety:sent") + track_thing = TrackThing.new(track_type: 'all_new_requests', + track_query: "variety:sent") allow(TrackThing).to receive(:create_track_for_all_new_requests). and_return(track_thing) expect(track_thing).to receive(:save).and_call_original - get :track_list, params: { :view => 'recent', :feed => 'track' } + get :track_list, params: { view: 'recent', feed: 'track' } expect(response).to redirect_to("/list?view=recent") end it "should redirect with an error message if the query is too long" do sign_in user - long_track = TrackThing.new(:track_type => 'all_new_requests', - :track_query => "lorem ipsum " * 42) + long_track = TrackThing.new(track_type: 'all_new_requests', + track_query: "lorem ipsum " * 42) allow(TrackThing).to receive(:create_track_for_all_new_requests). and_return(long_track) - get :track_list, params: { :view => 'recent', :feed => 'track' } + get :track_list, params: { view: 'recent', feed: 'track' } expect(flash[:error]).to match('too long') expect(response).to redirect_to("/list?view=recent") end @@ -446,11 +446,11 @@ it 'redirects to the signin page' do post :delete_all_type, params: { - :user => track_thing.tracking_user.id, - :track_type => 'search_query' + user: track_thing.tracking_user.id, + track_type: 'search_query' } expect(response). - to redirect_to(signin_path(:token => get_last_post_redirect.token)) + to redirect_to(signin_path(token: get_last_post_redirect.token)) end end @@ -460,19 +460,19 @@ it 'deletes all tracks for the user of the type passed in the params' do sign_in track_thing.tracking_user post :delete_all_type, params: { - :user => track_thing.tracking_user.id, - :track_type => 'search_query', - :r => '/' + user: track_thing.tracking_user.id, + track_type: 'search_query', + r: '/' } - expect(TrackThing.where(:id => track_thing.id)).to be_empty + expect(TrackThing.where(id: track_thing.id)).to be_empty end it 'redirects to the redirect path in the param passed' do sign_in track_thing.tracking_user post :delete_all_type, params: { - :user => track_thing.tracking_user.id, - :track_type => 'search_query', - :r => '/' + user: track_thing.tracking_user.id, + track_type: 'search_query', + r: '/' } expect(response).to redirect_to('/') end @@ -480,9 +480,9 @@ it 'shows a message telling the user what has happened' do sign_in track_thing.tracking_user post :delete_all_type, params: { - :user => track_thing.tracking_user.id, - :track_type => 'search_query', - :r => '/' + user: track_thing.tracking_user.id, + track_type: 'search_query', + r: '/' } expect(flash[:notice]).to eq("You will no longer be emailed updates for those alerts") end diff --git a/spec/controllers/user_controller_spec.rb b/spec/controllers/user_controller_spec.rb index 5023f09c37..aa33b6b755 100644 --- a/spec/controllers/user_controller_spec.rb +++ b/spec/controllers/user_controller_spec.rb @@ -7,7 +7,7 @@ let(:user) { FactoryBot.create(:user) } it 'renders the show template' do - get :show, params: { :url_name => user.url_name } + get :show, params: { url_name: user.url_name } expect(response).to render_template(:show) end @@ -666,15 +666,15 @@ def make_request context 'user is banned' do before(:each) do - @user = FactoryBot.create(:user, :ban_text => 'Causing trouble') + @user = FactoryBot.create(:user, ban_text: 'Causing trouble') sign_in @user @uploadedfile = fixture_file_upload("parrot.png") post :set_profile_photo, params: { - :id => @user.id, - :file => @uploadedfile, - :submitted_draft_profile_photo => 1, - :automatically_crop => 1 + id: @user.id, + file: @uploadedfile, + submitted_draft_profile_photo: 1, + automatically_crop: 1 } end @@ -701,11 +701,11 @@ def make_request it "should be an error if you type the password differently each time" do post :signup, params: { - :user_signup => { - :email => 'new@localhost', - :name => 'New Person', - :password => 'sillypassword', - :password_confirmation => 'sillypasswordtwo' + user_signup: { + email: 'new@localhost', + name: 'New Person', + password: 'sillypassword', + password_confirmation: 'sillypasswordtwo' } } expect(assigns[:user_signup].errors[:password_confirmation]). @@ -714,11 +714,11 @@ def make_request it "should be an error to sign up with a misformatted email" do post :signup, params: { - :user_signup => { - :email => 'malformed-email', - :name => 'Mr Malformed', - :password => 'sillypassword', - :password_confirmation => 'sillypassword' + user_signup: { + email: 'malformed-email', + name: 'Mr Malformed', + password: 'sillypassword', + password_confirmation: 'sillypassword' } } expect(assigns[:user_signup].errors[:email]). @@ -726,14 +726,14 @@ def make_request end it "should not show the 'already in use' error when trying to sign up with a duplicate email" do - existing_user = FactoryBot.create(:user, :email => 'in-use@localhost') + existing_user = FactoryBot.create(:user, email: 'in-use@localhost') post :signup, params: { - :user_signup => { - :email => 'in-use@localhost', - :name => 'Mr Suspected-Hacker', - :password => 'sillypassword', - :password_confirmation => 'mistyped' + user_signup: { + email: 'in-use@localhost', + name: 'Mr Suspected-Hacker', + password: 'sillypassword', + password_confirmation: 'mistyped' } } expect(assigns[:user_signup].errors[:password_confirmation]). @@ -743,11 +743,11 @@ def make_request it "should send confirmation mail if you fill in the form right" do post :signup, params: { - :user_signup => { - :email => 'new@localhost', - :name => 'New Person', - :password => 'sillypassword', - :password_confirmation => 'sillypassword' + user_signup: { + email: 'new@localhost', + name: 'New Person', + password: 'sillypassword', + password_confirmation: 'sillypassword' } } expect(response).to render_template('confirm') @@ -760,11 +760,11 @@ def make_request it "should send confirmation mail in other languages or different locales" do session[:locale] = "es" post :signup, params: { - :user_signup => { - :email => 'new@localhost', - :name => 'New Person', - :password => 'sillypassword', - :password_confirmation => 'sillypassword' + user_signup: { + email: 'new@localhost', + name: 'New Person', + password: 'sillypassword', + password_confirmation: 'sillypassword' } } expect(response).to render_template('confirm') @@ -777,11 +777,11 @@ def make_request context "filling in the form with an existing registered email" do it "should send special 'already signed up' mail" do post :signup, params: { - :user_signup => { - :email => 'silly@localhost', - :name => 'New Person', - :password => 'sillypassword', - :password_confirmation => 'sillypassword' + user_signup: { + email: 'silly@localhost', + name: 'New Person', + password: 'sillypassword', + password_confirmation: 'sillypassword' } } expect(response).to render_template('confirm') @@ -796,11 +796,11 @@ def make_request it "cope with trailing spaces in the email address" do post :signup, params: { - :user_signup => { - :email => 'silly@localhost ', - :name => 'New Person', - :password => 'sillypassword', - :password_confirmation => 'sillypassword' + user_signup: { + email: 'silly@localhost ', + name: 'New Person', + password: 'sillypassword', + password_confirmation: 'sillypassword' } } expect(response).to render_template('confirm') @@ -816,11 +816,11 @@ def make_request it "should create a new PostRedirect if the old one has expired" do allow(PostRedirect).to receive(:find_by_token).and_return(nil) post :signup, params: { - :user_signup => { - :email => 'silly@localhost', - :name => 'New Person', - :password => 'sillypassword', - :password_confirmation => 'sillypassword' + user_signup: { + email: 'silly@localhost', + name: 'New Person', + password: 'sillypassword', + password_confirmation: 'sillypassword' } } expect(response).to render_template('confirm') @@ -830,12 +830,12 @@ def make_request it 'accepts only whitelisted parameters' do expect { post :signup, params: { - :user_signup => { - :email => 'silly@localhost', - :name => 'New Person', - :password => 'sillypassword', - :password_confirmation => 'sillypassword', - :role_ids => Role.admin_role.id + user_signup: { + email: 'silly@localhost', + name: 'New Person', + password: 'sillypassword', + password_confirmation: 'sillypassword', + role_ids: Role.admin_role.id } } }.to raise_error(ActionController::UnpermittedParameters) @@ -867,11 +867,11 @@ def make_request it "shows the confirmation page for valid credentials" do sign_in user - post :signup, params: { :user_signup => { - :email => user.email, - :name => user.name, - :password => 'jonespassword', - :password_confirmation => 'jonespassword' + post :signup, params: { user_signup: { + email: user.email, + name: user.name, + password: 'jonespassword', + password_confirmation: 'jonespassword' } } expect(response).to render_template('confirm') @@ -897,11 +897,11 @@ def make_request it 'sends an exception notification' do post :signup, params: { - :user_signup => { - :email => 'rate-limited@localhost', - :name => 'New Person', - :password => 'sillypassword', - :password_confirmation => 'sillypassword' + user_signup: { + email: 'rate-limited@localhost', + name: 'New Person', + password: 'sillypassword', + password_confirmation: 'sillypassword' } } mail = ActionMailer::Base.deliveries.first @@ -910,23 +910,23 @@ def make_request it 'blocks the signup' do post :signup, params: { - :user_signup => { - :email => 'rate-limited@localhost', - :name => 'New Person', - :password => 'sillypassword', - :password_confirmation => 'sillypassword' + user_signup: { + email: 'rate-limited@localhost', + name: 'New Person', + password: 'sillypassword', + password_confirmation: 'sillypassword' } } - expect(User.where(:email => 'rate-limited@localhost').count).to eq(0) + expect(User.where(email: 'rate-limited@localhost').count).to eq(0) end it 're-renders the form' do post :signup, params: { - :user_signup => { - :email => 'rate-limited@localhost', - :name => 'New Person', - :password => 'sillypassword', - :password_confirmation => 'sillypassword' + user_signup: { + email: 'rate-limited@localhost', + name: 'New Person', + password: 'sillypassword', + password_confirmation: 'sillypassword' } } expect(response).to render_template('sign') @@ -934,11 +934,11 @@ def make_request it 'sets a flash error' do post :signup, params: { - :user_signup => { - :email => 'rate-limited@localhost', - :name => 'New Person', - :password => 'sillypassword', - :password_confirmation => 'sillypassword' + user_signup: { + email: 'rate-limited@localhost', + name: 'New Person', + password: 'sillypassword', + password_confirmation: 'sillypassword' } } expect(flash[:error]).to match(/unable to sign up new users/) @@ -955,11 +955,11 @@ def make_request it 'sends an exception notification' do post :signup, params: { - :user_signup => { - :email => 'rate-limited@localhost', - :name => 'New Person', - :password => 'sillypassword', - :password_confirmation => 'sillypassword' + user_signup: { + email: 'rate-limited@localhost', + name: 'New Person', + password: 'sillypassword', + password_confirmation: 'sillypassword' } } mail = ActionMailer::Base.deliveries.first @@ -968,14 +968,14 @@ def make_request it 'allows the signup' do post :signup, params: { - :user_signup => { - :email => 'rate-limited@localhost', - :name => 'New Person', - :password => 'sillypassword', - :password_confirmation => 'sillypassword' + user_signup: { + email: 'rate-limited@localhost', + name: 'New Person', + password: 'sillypassword', + password_confirmation: 'sillypassword' } } - expect(User.where(:email => 'rate-limited@localhost').count).to eq(1) + expect(User.where(email: 'rate-limited@localhost').count).to eq(1) end end @@ -1005,34 +1005,34 @@ def make_request expect(Rails.logger).to receive(:info).with(msg) post :signup, params: { - :user_signup => { - :email => 'spammer@example.com', - :name => 'Download New Person 1080p!', - :password => 'sillypassword', - :password_confirmation => 'sillypassword' + user_signup: { + email: 'spammer@example.com', + name: 'Download New Person 1080p!', + password: 'sillypassword', + password_confirmation: 'sillypassword' } } end it 'blocks the signup' do post :signup, params: { - :user_signup => { - :email => 'spammer@example.com', - :name => 'New Person', - :password => 'sillypassword', - :password_confirmation => 'sillypassword' + user_signup: { + email: 'spammer@example.com', + name: 'New Person', + password: 'sillypassword', + password_confirmation: 'sillypassword' } } - expect(User.where(:email => 'spammer@example.com').count).to eq(0) + expect(User.where(email: 'spammer@example.com').count).to eq(0) end it 're-renders the form' do post :signup, params: { - :user_signup => { - :email => 'spammer@example.com', - :name => 'New Person', - :password => 'sillypassword', - :password_confirmation => 'sillypassword' + user_signup: { + email: 'spammer@example.com', + name: 'New Person', + password: 'sillypassword', + password_confirmation: 'sillypassword' } } expect(response).to render_template('sign') @@ -1049,11 +1049,11 @@ def make_request it 'sends an exception notification' do post :signup, params: { - :user_signup => { - :email => 'spammer@example.com', - :name => 'New Person', - :password => 'sillypassword', - :password_confirmation => 'sillypassword' + user_signup: { + email: 'spammer@example.com', + name: 'New Person', + password: 'sillypassword', + password_confirmation: 'sillypassword' } } mail = ActionMailer::Base.deliveries.first @@ -1062,14 +1062,14 @@ def make_request it 'allows the signup' do post :signup, params: { - :user_signup => { - :email => 'spammer@example.com', - :name => 'New Person', - :password => 'sillypassword', - :password_confirmation => 'sillypassword' + user_signup: { + email: 'spammer@example.com', + name: 'New Person', + password: 'sillypassword', + password_confirmation: 'sillypassword' } } - expect(User.where(:email => 'spammer@example.com').count).to eq(1) + expect(User.where(email: 'spammer@example.com').count).to eq(1) end end @@ -1106,7 +1106,7 @@ def make_request it "should require login" do get :signchangeemail expect(response). - to redirect_to(signin_path(:token => get_last_post_redirect.token)) + to redirect_to(signin_path(token: get_last_post_redirect.token)) end it "should show form for changing email if logged in" do @@ -1124,12 +1124,12 @@ def make_request post :signchangeemail, params: { - :signchangeemail => { - :old_email => 'bob@localhost', - :password => 'donotknowpassword', - :new_email => 'newbob@localhost' + signchangeemail: { + old_email: 'bob@localhost', + password: 'donotknowpassword', + new_email: 'newbob@localhost' }, - :submitted_signchangeemail_do => 1 + submitted_signchangeemail_do: 1 } @user.reload @@ -1147,12 +1147,12 @@ def make_request post :signchangeemail, params: { - :signchangeemail => { - :old_email => 'bob@moo', - :password => 'jonespassword', - :new_email => 'newbob@localhost' + signchangeemail: { + old_email: 'bob@moo', + password: 'jonespassword', + new_email: 'newbob@localhost' }, - :submitted_signchangeemail_do => 1 + submitted_signchangeemail_do: 1 } @user.reload @@ -1170,12 +1170,12 @@ def make_request post :signchangeemail, params: { - :signchangeemail => { - :old_email => 'BOB@localhost', - :password => 'jonespassword', - :new_email => 'newbob@localhost' + signchangeemail: { + old_email: 'BOB@localhost', + password: 'jonespassword', + new_email: 'newbob@localhost' }, - :submitted_signchangeemail_do => 1 + submitted_signchangeemail_do: 1 } expect(response).to render_template('signchangeemail_confirm') @@ -1187,12 +1187,12 @@ def make_request post :signchangeemail, params: { - :signchangeemail => { - :old_email => 'bob@localhost', - :password => 'jonespassword', - :new_email => 'silly@localhost' + signchangeemail: { + old_email: 'bob@localhost', + password: 'jonespassword', + new_email: 'silly@localhost' }, - :submitted_signchangeemail_do => 1 + submitted_signchangeemail_do: 1 } @user.reload @@ -1222,17 +1222,17 @@ def make_request it "should not let you change profile photo if you're not logged in as the user" do post :set_profile_photo, params: { - :id => @user.id, - :file => @uploadedfile, - :submitted_draft_profile_photo => 1, - :automatically_crop => 1 + id: @user.id, + file: @uploadedfile, + submitted_draft_profile_photo: 1, + automatically_crop: 1 } end it "should return a 404 not a 500 when a profile photo has not been set" do expect(@user.profile_photo).to be_nil expect { - get :get_profile_photo, params: { :url_name => @user.url_name } + get :get_profile_photo, params: { url_name: @user.url_name } }.to raise_error(ActiveRecord::RecordNotFound) end @@ -1241,13 +1241,13 @@ def make_request sign_in @user post :set_profile_photo, params: { - :id => @user.id, - :file => @uploadedfile, - :submitted_draft_profile_photo => 1, - :automatically_crop => 1 + id: @user.id, + file: @uploadedfile, + submitted_draft_profile_photo: 1, + automatically_crop: 1 } - expect(response).to redirect_to(:controller => 'user', :action => 'show', :url_name => "bob_smith") + expect(response).to redirect_to(controller: 'user', action: 'show', url_name: "bob_smith") expect(flash[:notice]).to match(/Thank you for updating your profile photo/) @user.reload @@ -1255,21 +1255,21 @@ def make_request end context 'there is no profile text' do - let(:user) { FactoryBot.create(:user, :about_me => '') } + let(:user) { FactoryBot.create(:user, about_me: '') } it 'prompts you to add profile text when adding a photo' do sign_in user profile_photo = ProfilePhoto. - create(:data => load_file_fixture("parrot.png"), - :user => user) + create(data: load_file_fixture("parrot.png"), + user: user) post :set_profile_photo, params: { - :id => user.id, - :file => @uploadedfile, - :submitted_crop_profile_photo => 1, - :draft_profile_photo_id => profile_photo.id + id: user.id, + file: @uploadedfile, + submitted_crop_profile_photo: 1, + draft_profile_photo_id: profile_photo.id } expect(flash[:notice][:partial]). @@ -1283,21 +1283,21 @@ def make_request sign_in @user post :set_profile_photo, params: { - :id => @user.id, - :file => @uploadedfile, - :submitted_draft_profile_photo => 1, - :automatically_crop => 1 + id: @user.id, + file: @uploadedfile, + submitted_draft_profile_photo: 1, + automatically_crop: 1 } - expect(response).to redirect_to(:controller => 'user', :action => 'show', :url_name => "bob_smith") + expect(response).to redirect_to(controller: 'user', action: 'show', url_name: "bob_smith") expect(flash[:notice]).to match(/Thank you for updating your profile photo/) post :set_profile_photo, params: { - :id => @user.id, - :file => @uploadedfile_2, - :submitted_draft_profile_photo => 1, - :automatically_crop => 1 + id: @user.id, + file: @uploadedfile_2, + submitted_draft_profile_photo: 1, + automatically_crop: 1 } - expect(response).to redirect_to(:controller => 'user', :action => 'show', :url_name => "bob_smith") + expect(response).to redirect_to(controller: 'user', action: 'show', url_name: "bob_smith") expect(flash[:notice]).to match(/Thank you for updating your profile photo/) @user.reload @@ -1310,7 +1310,7 @@ def make_request RSpec.describe UserController, "when showing JSON version for API" do it "should be successful" do - get :show, params: { :url_name => "bob_smith", :format => "json" } + get :show, params: { url_name: "bob_smith", format: "json" } u = JSON.parse(response.body) expect(u.class.to_s).to eq('Hash') @@ -1334,19 +1334,19 @@ def make_request ire = info_request_events(:useless_incoming_message_event) ire.created_at = DateTime.new(2001,1,1) sign_in user - get :wall, params: { :url_name => user.url_name } + get :wall, params: { url_name: user.url_name } expect(assigns[:feed_results][0]).not_to eq(ire) ire.created_at = Time.zone.now ire.save! - get :wall, params: { :url_name => user.url_name } + get :wall, params: { url_name: user.url_name } expect(assigns[:feed_results][0]).to eq(ire) end it "should show other users' activities on their walls" do user = users(:silly_name_user) ire = info_request_events(:useless_incoming_message_event) - get :wall, params: { :url_name => user.url_name } + get :wall, params: { url_name: user.url_name } expect(assigns[:feed_results][0]).not_to eq(ire) end @@ -1355,8 +1355,8 @@ def make_request sign_in user expect(user.receive_email_alerts).to eq(true) get :set_receive_email_alerts, params: { - :receive_email_alerts => 'false', - :came_from => "/" + receive_email_alerts: 'false', + came_from: "/" } user.reload expect(user.receive_email_alerts).not_to eq(true) @@ -1365,7 +1365,7 @@ def make_request it 'should not show duplicate feed results' do user = users(:silly_name_user) sign_in user - get :wall, params: { :url_name => user.url_name } + get :wall, params: { url_name: user.url_name } expect(assigns[:feed_results].uniq).to eq(assigns[:feed_results]) end diff --git a/spec/controllers/user_profile/about_me_controller_spec.rb b/spec/controllers/user_profile/about_me_controller_spec.rb index a520da78c7..ec787ac6dc 100644 --- a/spec/controllers/user_profile/about_me_controller_spec.rb +++ b/spec/controllers/user_profile/about_me_controller_spec.rb @@ -49,7 +49,7 @@ describe 'PUT update' do it 'sets the title' do - put :update, params: { :user => { :about_me => 'My bio' } } + put :update, params: { user: { about_me: 'My bio' } } expect(assigns[:title]). to eq("Change the text about you on your profile at #{ site_name }") end @@ -58,7 +58,7 @@ it 'redirects to the sign in page' do sign_in nil - put :update, params: { :user => { :about_me => 'My bio' } } + put :update, params: { user: { about_me: 'My bio' } } expect(response).to redirect_to(frontpage_path) end @@ -66,19 +66,19 @@ context 'with a banned user' do - let(:banned_user) { FactoryBot.create(:user, :ban_text => 'banned') } + let(:banned_user) { FactoryBot.create(:user, ban_text: 'banned') } before :each do sign_in banned_user end it 'displays an error' do - put :update, params: { :user => { :about_me => 'My bio' } } + put :update, params: { user: { about_me: 'My bio' } } expect(flash[:error]).to eq('Suspended users cannot edit their profile') end it 'redirects to edit' do - put :update, params: { :user => { :about_me => 'My bio' } } + put :update, params: { user: { about_me: 'My bio' } } expect(response).to redirect_to(edit_profile_about_me_path) end @@ -93,29 +93,29 @@ end it 'assigns the currently logged in user' do - put :update, params: { :user => { :about_me => 'My bio' } } + put :update, params: { user: { about_me: 'My bio' } } expect(assigns[:user]).to eq(user) end it 'updates the user about_me' do - put :update, params: { :user => { :about_me => 'My bio' } } + put :update, params: { user: { about_me: 'My bio' } } expect(user.reload.about_me).to eq('My bio') end context 'if the user has a profile photo' do it 'sets a success message' do - user.create_profile_photo!(:data => load_file_fixture('parrot.png')) - put :update, params: { :user => { :about_me => 'My bio' } } + user.create_profile_photo!(data: load_file_fixture('parrot.png')) + put :update, params: { user: { about_me: 'My bio' } } msg = 'You have now changed the text about you on your profile.' expect(flash[:notice]).to eq(msg) end it 'redirects to the user page' do - user.create_profile_photo!(:data => load_file_fixture('parrot.png')) - put :update, params: { :user => { :about_me => 'My bio' } } + user.create_profile_photo!(data: load_file_fixture('parrot.png')) + put :update, params: { user: { about_me: 'My bio' } } expect(response). - to redirect_to(show_user_path(:url_name => user.url_name)) + to redirect_to(show_user_path(url_name: user.url_name)) end end @@ -123,12 +123,12 @@ context 'if the user does not have a profile photo' do it 'sets a message suggesting they add one' do - put :update, params: { :user => { :about_me => 'My bio' } } + put :update, params: { user: { about_me: 'My bio' } } expect(flash[:notice][:partial]).to eq("update_profile_text") end it 'redirects to the set profile photo page' do - put :update, params: { :user => { :about_me => 'My bio' } } + put :update, params: { user: { about_me: 'My bio' } } expect(response).to redirect_to(set_profile_photo_path) end @@ -138,7 +138,7 @@ context 'with invalid attributes' do - let(:user) { FactoryBot.create(:user, :about_me => 'My bio') } + let(:user) { FactoryBot.create(:user, about_me: 'My bio') } let(:invalid_text) { 'x' * 1000 } before :each do @@ -146,17 +146,17 @@ end it 'assigns the currently logged in user' do - put :update, params: { :user => { :about_me => invalid_text } } + put :update, params: { user: { about_me: invalid_text } } expect(assigns[:user]).to eq(user) end it 'does not update the user about_me' do - put :update, params: { :user => { :about_me => invalid_text } } + put :update, params: { user: { about_me: invalid_text } } expect(user.reload.about_me).to eq('My bio') end it 'renders the edit form' do - put :update, params: { :user => { :about_me => invalid_text } } + put :update, params: { user: { about_me: invalid_text } } expect(response).to render_template(:edit) end @@ -164,26 +164,26 @@ context 'with invalid parameters' do - let(:user) { FactoryBot.create(:user, :about_me => 'My bio') } + let(:user) { FactoryBot.create(:user, about_me: 'My bio') } before :each do sign_in user end it 'assigns the currently logged in user' do - put :update, params: { :about_me => 'Updated text' } + put :update, params: { about_me: 'Updated text' } expect(assigns[:user]).to eq(user) end it 'does not update the user about_me' do - put :update, params: { :about_me => 'Updated text' } + put :update, params: { about_me: 'Updated text' } expect(user.reload.about_me).to eq('My bio') end it 'redirects to the user page' do - put :update, params: { :about_me => 'Updated text' } + put :update, params: { about_me: 'Updated text' } expect(response). - to redirect_to(show_user_path(:url_name => user.url_name)) + to redirect_to(show_user_path(url_name: user.url_name)) end end @@ -198,21 +198,21 @@ it 'ignores non-whitelisted attributes' do put :update, params: { - :user => { - :about_me => 'My bio', - :role_ids => [ Role.admin_role.id ] + user: { + about_me: 'My bio', + role_ids: [ Role.admin_role.id ] } } expect(user.reload.roles).to eq([]) end it 'sets whitelisted attributes' do - user = FactoryBot.create(:user, :name => '1234567') + user = FactoryBot.create(:user, name: '1234567') sign_in user put :update, params: { - :user => { - :about_me => 'My bio', - :role_ids => [ Role.admin_role.id ] + user: { + about_me: 'My bio', + role_ids: [ Role.admin_role.id ] } } expect(user.reload.about_me).to eq('My bio') @@ -223,14 +223,14 @@ context 'with spam attributes and a non-whitelisted user' do let(:user) do - FactoryBot.create(:user, :name => 'JWahewKjWhebCd', - :confirmed_not_spam => false) + FactoryBot.create(:user, name: 'JWahewKjWhebCd', + confirmed_not_spam: false) end before :each do UserSpamScorer.spam_score_threshold = 1 UserSpamScorer.score_mappings = - { :about_me_includes_currency_symbol? => 20 } + { about_me_includes_currency_symbol?: 20 } sign_in user end @@ -238,7 +238,7 @@ it 'sets an error message' do put :update, params: { - :user => { :about_me => 'http://example.com/$£$£$' } + user: { about_me: 'http://example.com/$£$£$' } } msg = "You can't update your profile text at this time." expect(flash[:error]).to eq(msg) @@ -246,15 +246,15 @@ it 'redirects to the user page' do put :update, params: { - :user => { :about_me => 'http://example.com/$£$£$' } + user: { about_me: 'http://example.com/$£$£$' } } expect(response). - to redirect_to(show_user_path(:url_name => user.url_name)) + to redirect_to(show_user_path(url_name: user.url_name)) end it 'does not update the user about_me' do put :update, params: { - :user => { :about_me => 'http://example.com/$£$£$' } + user: { about_me: 'http://example.com/$£$£$' } } expect(user.reload.about_me).to eq('') end @@ -264,14 +264,14 @@ context 'with spam attributes and a whitelisted user' do let(:user) do - FactoryBot.create(:user, :name => 'JWahewKjWhebCd', - :confirmed_not_spam => true) + FactoryBot.create(:user, name: 'JWahewKjWhebCd', + confirmed_not_spam: true) end before :each do UserSpamScorer.spam_score_threshold = 1 UserSpamScorer.score_mappings = - { :about_me_includes_currency_symbol? => 20 } + { about_me_includes_currency_symbol?: 20 } sign_in user end @@ -280,7 +280,7 @@ it 'updates the user about_me' do # By whitelisting we're giving them the benefit of the doubt put :update, params: { - :user => { :about_me => 'http://example.com/$£$£$' } + user: { about_me: 'http://example.com/$£$£$' } } expect(user.reload.about_me).to eq('http://example.com/$£$£$') end @@ -289,7 +289,7 @@ context 'with block_spam_about_me_text? returning true, spam content and a non-whitelisted user' do - let(:user) { FactoryBot.create(:user, :confirmed_not_spam => false) } + let(:user) { FactoryBot.create(:user, confirmed_not_spam: false) } before :each do UserSpamScorer.score_mappings = {} @@ -302,8 +302,8 @@ it 'sends an exception notification' do put :update, params: { - :user => { - :about_me => '[HD] Watch Jason Bourne Online free MOVIE Full-HD' + user: { + about_me: '[HD] Watch Jason Bourne Online free MOVIE Full-HD' } } mail = ActionMailer::Base.deliveries.first @@ -313,8 +313,8 @@ it 'sets an error message' do put :update, params: { - :user => { - :about_me => '[HD] Watch Jason Bourne Online free MOVIE Full-HD' + user: { + about_me: '[HD] Watch Jason Bourne Online free MOVIE Full-HD' } } msg = "You can't update your profile text at this time." @@ -324,19 +324,19 @@ it 'redirects to the user page' do put :update, params: { - :user => { - :about_me => '[HD] Watch Jason Bourne Online free MOVIE Full-HD' + user: { + about_me: '[HD] Watch Jason Bourne Online free MOVIE Full-HD' } } expect(response). - to redirect_to(show_user_path(:url_name => user.url_name)) + to redirect_to(show_user_path(url_name: user.url_name)) end it 'does not update the user about_me' do put :update, params: { - :user => { - :about_me => '[HD] Watch Jason Bourne Online free MOVIE Full-HD' + user: { + about_me: '[HD] Watch Jason Bourne Online free MOVIE Full-HD' } } expect(user.reload.about_me).to eq('') @@ -347,7 +347,7 @@ context 'with block_spam_about_me_text? returning false, spam content and a whitelisted user' do let(:user) do - FactoryBot.create(:user, :name => '12345', :confirmed_not_spam => true) + FactoryBot.create(:user, name: '12345', confirmed_not_spam: true) end before :each do @@ -359,8 +359,8 @@ # By whitelisting we're giving them the benefit of the doubt put :update, params: { - :user => { - :about_me => '[HD] Watch Jason Bourne Online free MOVIE Full-HD' + user: { + about_me: '[HD] Watch Jason Bourne Online free MOVIE Full-HD' } } expect(user.reload.about_me).to eq('[HD] Watch Jason Bourne Online free MOVIE Full-HD') @@ -370,7 +370,7 @@ context 'with block_spam_about_me_text? returning true, spam content and a whitelisted user' do - let(:user) { FactoryBot.create(:user, :confirmed_not_spam => true) } + let(:user) { FactoryBot.create(:user, confirmed_not_spam: true) } before :each do sign_in user @@ -381,9 +381,8 @@ # By whitelisting we're giving them the benefit of the doubt put :update, params: { - :user => { - :about_me => - '[HD] Watch Jason Bourne Online free MOVIE Full-HD' + user: { + about_me: '[HD] Watch Jason Bourne Online free MOVIE Full-HD' } } expect(user.reload.about_me).to eq('[HD] Watch Jason Bourne Online free MOVIE Full-HD') diff --git a/spec/controllers/users/confirmations_controller_spec.rb b/spec/controllers/users/confirmations_controller_spec.rb index 88a11689d0..cae05aefd3 100644 --- a/spec/controllers/users/confirmations_controller_spec.rb +++ b/spec/controllers/users/confirmations_controller_spec.rb @@ -7,7 +7,7 @@ context 'if the post redirect cannot be found' do it 'renders bad_token' do - get :confirm, params: { :email_token => '' } + get :confirm, params: { email_token: '' } expect(response).to render_template(:bad_token) end @@ -88,11 +88,11 @@ before :each do @admin = FactoryBot.create(:admin_user) - @user = FactoryBot.create(:user, :email_confirmed => false) - @post_redirect = PostRedirect.create(:uri => '/', :user => @user) + @user = FactoryBot.create(:user, email_confirmed: false) + @post_redirect = PostRedirect.create(uri: '/', user: @user) sign_in @admin - get :confirm, params: { :email_token => @post_redirect.email_token } + get :confirm, params: { email_token: @post_redirect.email_token } end it 'does not confirm the post redirect user' do @@ -119,11 +119,11 @@ EOF before :each do - @user = FactoryBot.create(:user, :email_confirmed => false) - @post_redirect = PostRedirect.create(:uri => '/', :user => @user) + @user = FactoryBot.create(:user, email_confirmed: false) + @post_redirect = PostRedirect.create(uri: '/', user: @user) sign_in @user - get :confirm, params: { :email_token => @post_redirect.email_token } + get :confirm, params: { email_token: @post_redirect.email_token } end it 'confirms the post redirect user' do @@ -150,11 +150,11 @@ EOF before :each do @current_user = FactoryBot.create(:user) - @user = FactoryBot.create(:user, :email_confirmed => false) - @post_redirect = PostRedirect.create(:uri => '/', :user => @user) + @user = FactoryBot.create(:user, email_confirmed: false) + @post_redirect = PostRedirect.create(uri: '/', user: @user) sign_in @current_user - get :confirm, params: { :email_token => @post_redirect.email_token } + get :confirm, params: { email_token: @post_redirect.email_token } end it 'confirms the post redirect user' do @@ -179,10 +179,10 @@ context 'if there is no logged in user' do before :each do - @user = FactoryBot.create(:user, :email_confirmed => false) - @post_redirect = PostRedirect.create(:uri => '/', :user => @user) + @user = FactoryBot.create(:user, email_confirmed: false) + @post_redirect = PostRedirect.create(uri: '/', user: @user) - get :confirm, params: { :email_token => @post_redirect.email_token } + get :confirm, params: { email_token: @post_redirect.email_token } end it 'confirms the post redirect user' do diff --git a/spec/controllers/users/messages_controller_spec.rb b/spec/controllers/users/messages_controller_spec.rb index 88d0519a8e..999ca4a21a 100644 --- a/spec/controllers/users/messages_controller_spec.rb +++ b/spec/controllers/users/messages_controller_spec.rb @@ -9,6 +9,8 @@ before { sign_in sender } + after { ActionMailer::Base.deliveries.clear } + describe 'GET contact' do context 'when not signed in' do @@ -33,6 +35,23 @@ }.to raise_error ActiveRecord::RecordNotFound end + context 'when the recipient has opted out' do + before { recipient.update!(receive_user_messages: false) } + + it 'prevents user messages' do + get :contact, params: { url_name: recipient.url_name } + expect(response).to render_template('users/messages/opted_out') + end + end + + it 'prevents messages from users who have reached their rate limit' do + allow_any_instance_of(User). + to receive(:exceeded_limit?).with(:user_messages).and_return(true) + + get :contact, params: { url_name: recipient.url_name } + + expect(response).to render_template('users/messages/rate_limited') + end end describe 'POST contact' do @@ -49,6 +68,40 @@ expect(response).to render_template('contact') end + context 'when the recipient has opted out' do + before { recipient.update!(receive_user_messages: false) } + + it 'prevents the submission' do + post :contact, params: { + url_name: recipient.url_name, + contact: { + subject: 'Hi', + message: 'Gah' + }, + submitted_contact_form: 1 + } + + expect(ActionMailer::Base.deliveries).to be_empty + expect(response).to render_template('users/messages/opted_out') + end + end + + it 'prevents messages from users who have reached their rate limit' do + allow_any_instance_of(User). + to receive(:exceeded_limit?).with(:user_messages).and_return(true) + + post :contact, params: { + url_name: recipient.url_name, + contact: { + subject: 'Foo', + message: 'Bar' + }, + submitted_contact_form: 1 + } + + expect(response).to render_template('users/messages/rate_limited') + end + context 'the site is configured to require a captcha' do before do allow(AlaveteliConfiguration). @@ -96,6 +149,126 @@ expect(mail.header['Reply-To'].to_s).to match(sender.email) end + it 'records the message' do + post :contact, params: { + url_name: recipient.url_name, + contact: { + subject: 'Dearest you', + message: 'Just a test!' + }, + submitted_contact_form: 1 + } + + expect(UserMessage.last.user).to eq(sender) + end end + describe 'when sending a message that looks like spam' do + let(:sender) { FactoryBot.create(:user, confirmed_not_spam: false) } + let(:recipient) { FactoryBot.create(:user) } + let(:spam_content) { '[HD] Watch Jason Bourne Online free MOVIE Full-HD' } + + context 'when block_spam_user_messages? is true' do + before do + allow(@controller). + to receive(:block_spam_user_messages?).and_return(true) + sign_in(sender) + end + + it 'sends an exception notification' do + post :contact, params: { + url_name: recipient.url_name, + contact: { + subject: 'Dearest you', + message: spam_content + }, + submitted_contact_form: 1 + } + + expect(ActionMailer::Base.deliveries.first.subject). + to match(/spam user message from user #{ sender.id }/) + end + + it 'shows an error message' do + post :contact, params: { + url_name: recipient.url_name, + contact: { + subject: 'Dearest you', + message: spam_content + }, + submitted_contact_form: 1 + } + + msg = "Sorry, we're currently unable to send your message. " \ + "Please try again later." + + expect(flash[:error]).to eq(msg) + end + + it 'renders the compose interface' do + post :contact, params: { + url_name: recipient.url_name, + contact: { + subject: 'Dearest you', + message: spam_content + }, + submitted_contact_form: 1 + } + + expect(response).to render_template('contact') + end + + it 'allows the message if the sender is confirmed not spam' do + sender.update!(confirmed_not_spam: true) + + post :contact, params: { + url_name: recipient.url_name, + contact: { + subject: 'Dearest you', + message: spam_content + }, + submitted_contact_form: 1 + } + + expect(response).to redirect_to(user_url(recipient)) + expect(ActionMailer::Base.deliveries.first.subject).to match(/Dearest/) + end + end + + context 'when block_spam_user_messages? is false' do + before do + allow(@controller). + to receive(:block_spam_user_messages?).and_return(false) + sign_in(sender) + end + + it 'sends an exception notification' do + post :contact, params: { + url_name: recipient.url_name, + contact: { + subject: 'Dearest you', + message: spam_content + }, + submitted_contact_form: 1 + } + + expect(ActionMailer::Base.deliveries.first.subject). + to match(/spam user message from user #{ sender.id }/) + end + + it 'sends the message' do + post :contact, params: { + url_name: recipient.url_name, + contact: { + subject: 'Dearest you', + message: spam_content + }, + submitted_contact_form: 1 + } + + expect(response).to redirect_to(user_url(recipient)) + expect(ActionMailer::Base.deliveries.last.subject).to match(/Dearest/) + end + end + end end diff --git a/spec/controllers/users/sessions_controller_spec.rb b/spec/controllers/users/sessions_controller_spec.rb index 0a9169cf29..7a8f7f6531 100644 --- a/spec/controllers/users/sessions_controller_spec.rb +++ b/spec/controllers/users/sessions_controller_spec.rb @@ -21,7 +21,7 @@ end it "should create post redirect to /list when you click signin on /list" do - get :new, params: { :r => "/list" } + get :new, params: { r: "/list" } post_redirect = get_last_post_redirect expect(post_redirect.uri).to eq("/list") end @@ -58,11 +58,11 @@ it "should show you the sign in page again if you get the password wrong" do post_redirect = FactoryBot.create(:post_redirect, uri: '/list') post :create, params: { - :user_signin => { - :email => 'bob@localhost', - :password => 'NOTRIGHTPASSWORD' + user_signin: { + email: 'bob@localhost', + password: 'NOTRIGHTPASSWORD' }, - :token => post_redirect.token + token: post_redirect.token } expect(response).to render_template('user/sign') end @@ -70,11 +70,11 @@ it "should show you the sign in page again if you get the email wrong" do post_redirect = FactoryBot.create(:post_redirect, uri: '/list') post :create, params: { - :user_signin => { - :email => 'unknown@localhost', - :password => 'NOTRIGHTPASSWORD' + user_signin: { + email: 'unknown@localhost', + password: 'NOTRIGHTPASSWORD' }, - :token => post_redirect.token + token: post_redirect.token } expect(response).to render_template('user/sign') end @@ -83,11 +83,11 @@ post_redirect = FactoryBot.create(:post_redirect, uri: '/list') post :create, params: { - :user_signin => { - :email => 'bob@localhost', - :password => 'jonespassword' + user_signin: { + email: 'bob@localhost', + password: 'jonespassword' }, - :token => post_redirect.token + token: post_redirect.token } expect(session[:user_id]).to eq(users(:bob_smith_user).id) # response doesn't contain /en/ but redirect_to does... @@ -99,20 +99,20 @@ post_redirect = "something invalid" expect { post :create, params: { - :user_signin => { - :email => 'bob@localhost', - :password => 'jonespassword' + user_signin: { + email: 'bob@localhost', + password: 'jonespassword' }, - :token => post_redirect + token: post_redirect } }.not_to raise_error post :create, params: { - :user_signin => { - :email => 'bob@localhost', - :password => 'jonespassword' + user_signin: { + email: 'bob@localhost', + password: 'jonespassword' }, - :token => post_redirect + token: post_redirect } expect(response).to render_template('user/sign') expect(assigns[:post_redirect]).to eq(nil) @@ -120,9 +120,9 @@ it "sets a the cookie expiry to nil on next page load" do post :create, params: { - :user_signin => { - :email => user.email, - :password => 'jonespassword' + user_signin: { + email: user.email, + password: 'jonespassword' } } get :new @@ -132,11 +132,11 @@ it "does not log you in if you use an invalid PostRedirect token" do post_redirect = "something invalid" post :create, params: { - :user_signin => { - :email => 'bob@localhost', - :password => 'jonespassword' + user_signin: { + email: 'bob@localhost', + password: 'jonespassword' }, - :token => post_redirect + token: post_redirect } expect(response).to render_template('sign') expect(assigns[:post_redirect]).to eq(nil) @@ -158,17 +158,17 @@ context "checking 'remember_me'" do let(:user) do FactoryBot.create(:user, - :password => 'password1234', - :email_confirmed => true) + password: 'password1234', + email_confirmed: true) end def do_signin(email, password) post :create, params: { - :user_signin => { - :email => email, - :password => password + user_signin: { + email: email, + password: password }, - :remember_me => "1" + remember_me: "1" } end @@ -214,23 +214,23 @@ def do_signin(email, password) it "signs them in if the credentials are valid" do post :create, params: { - :user_signin => { - :email => user.email, - :password => 'jonespassword' + user_signin: { + email: user.email, + password: 'jonespassword' } }, - session: { :user_id => user.id } + session: { user_id: user.id } expect(session[:user_id]).to eq(user.id) end it 'signs them out if the credentials are not valid' do post :create, params: { - :user_signin => { - :email => user.email, - :password => 'wrongpassword' + user_signin: { + email: user.email, + password: 'wrongpassword' } }, - session: { :user_id => user.id } + session: { user_id: user.id } expect(session[:user_id]).to be_nil end @@ -247,10 +247,8 @@ def do_signin(email, password) end def do_signin(email, password) - post :create, { - params: { - :user_signin => { :email => email, :password => password } - } + post :create, params: { + user_signin: { email: email, password: password } } end @@ -315,11 +313,11 @@ def do_signin(email, password) post_redirect = FactoryBot.create(:post_redirect, uri: '/list') post :create, params: { - :user_signin => { - :email => 'unconfirmed@localhost', - :password => 'jonespassword' + user_signin: { + email: 'unconfirmed@localhost', + password: 'jonespassword' }, - :token => post_redirect.token + token: post_redirect.token } expect(response).to render_template('user/confirm') @@ -334,13 +332,13 @@ def do_signin(email, password) FactoryBot.create(:post_redirect, uri: 'http://bad.place.com/list') post :create, params: { - :user_signin => { - :email => 'unconfirmed@localhost', - :password => 'jonespassword' + user_signin: { + email: 'unconfirmed@localhost', + password: 'jonespassword' }, - :token => post_redirect.token + token: post_redirect.token } - get :confirm, params: { :email_token => post_redirect.email_token } + get :confirm, params: { email_token: post_redirect.email_token } expect(response).to redirect_to('/list?post_redirect=1') end @@ -351,11 +349,11 @@ def do_signin(email, password) post_redirect = FactoryBot.create(:post_redirect, uri: '/list') post :create, params: { - :user_signin => { - :email => 'unconfirmed@localhost', - :password => 'jonespassword' + user_signin: { + email: 'unconfirmed@localhost', + password: 'jonespassword' }, - :token => post_redirect.token + token: post_redirect.token } expect(ActionMailer::Base.deliveries).not_to be_empty @@ -369,13 +367,13 @@ def do_signin(email, password) # check is right confirmation URL expect(mail_token).to eq(post_redirect.email_token) - expect(Rails.application.routes.recognize_path(mail_path)).to eq({ :controller => 'user', :action => 'confirm', :email_token => mail_token }) + expect(Rails.application.routes.recognize_path(mail_path)).to eq({ controller: 'user', action: 'confirm', email_token: mail_token }) # check confirmation URL works expect(session[:user_id]).to be_nil - get :confirm, params: { :email_token => post_redirect.email_token } + get :confirm, params: { email_token: post_redirect.email_token } expect(session[:user_id]).to eq(users(:unconfirmed_user).id) - expect(response).to redirect_to(:controller => 'request', :action => 'list', :post_redirect => 1) + expect(response).to redirect_to(controller: 'request', action: 'list', post_redirect: 1) end # TODO: Extract to integration spec @@ -385,11 +383,11 @@ def do_signin(email, password) post_redirect = FactoryBot.create(:post_redirect, uri: '/list') post :create, params: { - :user_signin => { - :email => 'unconfirmed@localhost', - :password => 'jonespassword' + user_signin: { + email: 'unconfirmed@localhost', + password: 'jonespassword' }, - :token => post_redirect.token + token: post_redirect.token } expect(ActionMailer::Base.deliveries).not_to be_empty @@ -403,17 +401,17 @@ def do_signin(email, password) # check is right confirmation URL expect(mail_token).to eq(post_redirect.email_token) - expect(Rails.application.routes.recognize_path(mail_path)).to eq({ :controller => 'user', :action => 'confirm', :email_token => mail_token }) + expect(Rails.application.routes.recognize_path(mail_path)).to eq({ controller: 'user', action: 'confirm', email_token: mail_token }) # Log in as an admin sign_in users(:admin_user) # Get the confirmation URL, and check we’re still Joe - get :confirm, params: { :email_token => post_redirect.email_token } + get :confirm, params: { email_token: post_redirect.email_token } expect(session[:user_id]).to eq(users(:admin_user).id) # And the redirect should still work, of course - expect(response).to redirect_to(:controller => 'request', :action => 'list', :post_redirect => 1) + expect(response).to redirect_to(controller: 'request', action: 'list', post_redirect: 1) end end @@ -430,14 +428,14 @@ def do_signin(email, password) it "logs you out and redirect you to where you were" do sign_in user - get :destroy, params: { :r => '/list' } + get :destroy, params: { r: '/list' } expect(session[:user_id]).to be_nil expect(response). to redirect_to(request_list_path) end it "clears the session ttl" do - get :destroy, session: { :user_id => user.id, :ttl => Time.zone.now } + get :destroy, session: { user_id: user.id, ttl: Time.zone.now } expect(session[:ttl]).to be_nil end diff --git a/spec/controllers/widget_votes_controller_spec.rb b/spec/controllers/widget_votes_controller_spec.rb index 33dd23977d..0c57d77b91 100644 --- a/spec/controllers/widget_votes_controller_spec.rb +++ b/spec/controllers/widget_votes_controller_spec.rb @@ -12,12 +12,12 @@ end it 'should find the info request' do - post :create, params: { :request_id => info_request.id } + post :create, params: { request_id: info_request.id } expect(assigns[:info_request]).to eq(info_request) end it 'should redirect to the track path for the info request' do - post :create, params: { :request_id => info_request.id } + post :create, params: { request_id: info_request.id } track_thing = TrackThing.create_track_for_request(info_request) expect(response).to redirect_to(do_track_path(track_thing)) end @@ -26,7 +26,7 @@ it 'sets a tracking cookie' do allow(SecureRandom).to receive(:hex).and_return(mock_cookie) - post :create, params: { :request_id => info_request.id } + post :create, params: { request_id: info_request.id } expect(cookies[:widget_vote]).to eq(mock_cookie) end @@ -34,9 +34,9 @@ allow(SecureRandom).to receive(:hex).and_return(mock_cookie) votes = info_request. widget_votes. - where(:cookie => mock_cookie) + where(cookie: mock_cookie) - post :create, params: { :request_id => info_request.id } + post :create, params: { request_id: info_request.id } expect(votes.size).to eq(1) end @@ -47,7 +47,7 @@ it 'retains the existing tracking cookie' do request.cookies['widget_vote'] = mock_cookie - post :create, params: { :request_id => info_request.id } + post :create, params: { request_id: info_request.id } expect(cookies[:widget_vote]).to eq(mock_cookie) end @@ -55,9 +55,9 @@ request.cookies['widget_vote'] = mock_cookie votes = info_request. widget_votes. - where(:cookie => mock_cookie) + where(cookie: mock_cookie) - post :create, params: { :request_id => info_request.id } + post :create, params: { request_id: info_request.id } expect(votes.size).to eq(1) end @@ -69,7 +69,7 @@ it 'raises ActiveRecord::RecordNotFound' do allow(AlaveteliConfiguration).to receive(:enable_widgets).and_return(false) expect { - post :create, params: { :request_id => info_request.id } + post :create, params: { request_id: info_request.id } }.to raise_error(ActiveRecord::RecordNotFound) end @@ -80,7 +80,7 @@ it 'should return a 403' do info_request.prominence = 'hidden' info_request.save! - post :create, params: { :request_id => info_request.id } + post :create, params: { request_id: info_request.id } expect(response.code).to eq("403") end @@ -91,7 +91,7 @@ it 'should raise an ActiveRecord::RecordNotFound error' do embargoed_request = FactoryBot.create(:embargoed_request) expect { - post :create, params: { :request_id => embargoed_request.id } + post :create, params: { request_id: embargoed_request.id } }.to raise_error ActiveRecord::RecordNotFound end end diff --git a/spec/controllers/widgets_controller_spec.rb b/spec/controllers/widgets_controller_spec.rb index dd0af5f13f..d942d9ff7a 100644 --- a/spec/controllers/widgets_controller_spec.rb +++ b/spec/controllers/widgets_controller_spec.rb @@ -12,22 +12,22 @@ end it 'should render the widget template' do - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } expect(response).to render_template('show') end it 'should find the info request' do - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } expect(assigns[:info_request]).to eq(@info_request) end it 'should create a track thing for the request' do - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } expect(assigns[:track_thing].info_request).to eq(@info_request) end it 'should assign the request status' do - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } expect(assigns[:status]).to eq(@info_request.calculate_status) end @@ -41,10 +41,10 @@ track.save! 3.times do - @info_request.widget_votes.create(:cookie => SecureRandom.hex(10)) + @info_request.widget_votes.create(cookie: SecureRandom.hex(10)) end - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } # Count should be 5 # 1 for the request's owning user @@ -55,18 +55,18 @@ it 'sets user_owns_request to true if the user owns the request' do sign_in @info_request.user - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } expect(assigns[:user_owns_request]).to be true end it 'sets user_owns_request to false if the user does not own the request' do sign_in FactoryBot.create(:user) - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } expect(assigns[:user_owns_request]).to be false end it 'should not send an x-frame-options header' do - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } expect(response.headers["X-Frame-Options"]).to be_nil end @@ -74,23 +74,23 @@ it 'will not find existing tracks' do request.cookies['widget_vote'] = mock_cookie - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } expect(assigns[:existing_track]).to be_nil end it 'finds existing votes' do vote = FactoryBot.create(:widget_vote, - :info_request => @info_request, - :cookie => mock_cookie) + info_request: @info_request, + cookie: mock_cookie) request.cookies['widget_vote'] = vote.cookie - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } expect(assigns[:existing_vote]).to be true end it 'will not find any existing votes if none exist' do WidgetVote.delete_all request.cookies['widget_vote'] = mock_cookie - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } expect(assigns[:existing_vote]).to be false end @@ -100,13 +100,13 @@ it 'will not find existing tracks' do request.cookies['widget_vote'] = nil - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } expect(assigns[:existing_track]).to be_nil end it 'will not find any existing votes' do request.cookies['widget_vote'] = nil - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } expect(assigns[:existing_vote]).to be false end @@ -122,7 +122,7 @@ track.save! sign_in user - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } expect(assigns[:existing_track]).to eq(track) end @@ -136,7 +136,7 @@ user = FactoryBot.create(:user) sign_in user - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } expect(assigns[:existing_track]).to be_nil end @@ -144,12 +144,12 @@ it 'looks for an existing vote' do TrackThing.delete_all vote = FactoryBot.create(:widget_vote, - :info_request => @info_request, - :cookie => mock_cookie) + info_request: @info_request, + cookie: mock_cookie) sign_in @info_request.user request.cookies['widget_vote'] = mock_cookie - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } expect(assigns[:existing_vote]).to be true end @@ -160,7 +160,7 @@ sign_in @info_request.user request.cookies['widget_vote'] = mock_cookie - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } expect(assigns[:existing_vote]).to be false end @@ -172,7 +172,7 @@ it 'raises ActiveRecord::RecordNotFound' do allow(AlaveteliConfiguration).to receive(:enable_widgets).and_return(false) expect { - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } }.to raise_error(ActiveRecord::RecordNotFound) end @@ -183,17 +183,17 @@ it 'should return a 403' do @info_request.prominence = 'hidden' @info_request.save! - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } expect(response.code).to eq("403") end it 'does not look for an existing vote' do vote = FactoryBot.create(:widget_vote, - :info_request => @info_request, - :cookie => mock_cookie) + info_request: @info_request, + cookie: mock_cookie) sign_in @info_request.user - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } expect(assigns[:existing_vote]).to be false end @@ -210,12 +210,12 @@ end it 'should render the create widget template' do - get :new, params: { :request_id => @info_request.id } + get :new, params: { request_id: @info_request.id } expect(response).to render_template('new') end it 'should find the info request' do - get :new, params: { :request_id => @info_request.id } + get :new, params: { request_id: @info_request.id } expect(assigns[:info_request]).to eq(@info_request) end @@ -224,7 +224,7 @@ it 'raises ActiveRecord::RecordNotFound' do allow(AlaveteliConfiguration).to receive(:enable_widgets).and_return(false) expect { - get :new, params: { :request_id => @info_request.id } + get :new, params: { request_id: @info_request.id } }.to raise_error(ActiveRecord::RecordNotFound) end @@ -235,7 +235,7 @@ it 'should return a 403' do @info_request.prominence = 'hidden' @info_request.save! - get :show, params: { :request_id => @info_request.id } + get :show, params: { request_id: @info_request.id } expect(response.code).to eq("403") end diff --git a/spec/factories/alaveteli_pro/draft_info_request_batches.rb b/spec/factories/alaveteli_pro/draft_info_request_batches.rb index e660dd55f7..e34cac58b4 100644 --- a/spec/factories/alaveteli_pro/draft_info_request_batches.rb +++ b/spec/factories/alaveteli_pro/draft_info_request_batches.rb @@ -13,7 +13,7 @@ # FactoryBot.define do - factory :draft_info_request_batch, :class => AlaveteliPro::DraftInfoRequestBatch do + factory :draft_info_request_batch, class: AlaveteliPro::DraftInfoRequestBatch do user sequence(:title) { |n| "Draft: Example Title #{n}" } sequence(:body) { |n| "Do you have information about record #{n}?" } diff --git a/spec/factories/alaveteli_pro/embargo_extensions.rb b/spec/factories/alaveteli_pro/embargo_extensions.rb index 82569c900e..d8f676d946 100644 --- a/spec/factories/alaveteli_pro/embargo_extensions.rb +++ b/spec/factories/alaveteli_pro/embargo_extensions.rb @@ -11,7 +11,7 @@ # FactoryBot.define do - factory :embargo_extension, :class => AlaveteliPro::EmbargoExtension do + factory :embargo_extension, class: AlaveteliPro::EmbargoExtension do embargo extension_duration { '3_months' } end diff --git a/spec/factories/alaveteli_pro/embargoes.rb b/spec/factories/alaveteli_pro/embargoes.rb index 5bcb8ffc9f..939aabd56c 100644 --- a/spec/factories/alaveteli_pro/embargoes.rb +++ b/spec/factories/alaveteli_pro/embargoes.rb @@ -13,7 +13,7 @@ # FactoryBot.define do - factory :embargo, :class => AlaveteliPro::Embargo do + factory :embargo, class: AlaveteliPro::Embargo do info_request publish_at { AlaveteliPro::Embargo.three_months_from_now } embargo_duration { '3_months' } diff --git a/spec/factories/alaveteli_pro/request_summaries.rb b/spec/factories/alaveteli_pro/request_summaries.rb index c84e9ea072..79c33db10f 100644 --- a/spec/factories/alaveteli_pro/request_summaries.rb +++ b/spec/factories/alaveteli_pro/request_summaries.rb @@ -17,12 +17,12 @@ # FactoryBot.define do - factory :request_summary, :class => AlaveteliPro::RequestSummary do + factory :request_summary, class: AlaveteliPro::RequestSummary do sequence(:title) { |n| "Example Title #{n}" } sequence(:body) { |n| "Example request #{n}" } public_body_names { 'Example Public Body' } association :summarisable, factory: :info_request, strategy: :create - user :factory => :pro_user + user factory: :pro_user transient do # Should we fix the duplicated summarisable? (See the after(:build)) @@ -47,15 +47,15 @@ end factory :draft_request_summary do - association :summarisable , :factory => :draft_info_request + association :summarisable , factory: :draft_info_request end factory :batch_request_summary do - association :summarisable , :factory => :info_request_batch + association :summarisable , factory: :info_request_batch end factory :draft_batch_request_summary do - association :summarisable , :factory => :draft_info_request_batch + association :summarisable , factory: :draft_info_request_batch end end end diff --git a/spec/factories/alaveteli_pro/request_summary_categories.rb b/spec/factories/alaveteli_pro/request_summary_categories.rb index 87d600f91b..a96b64aa15 100644 --- a/spec/factories/alaveteli_pro/request_summary_categories.rb +++ b/spec/factories/alaveteli_pro/request_summary_categories.rb @@ -10,8 +10,8 @@ # FactoryBot.define do - factory :request_summary_category, :class => 'AlaveteliPro::RequestSummaryCategory', - :aliases => [:waiting_response_request_summary_category] do + factory :request_summary_category, class: 'AlaveteliPro::RequestSummaryCategory', + aliases: [:waiting_response_request_summary_category] do slug { 'waiting_response' } end end diff --git a/spec/factories/blog/posts.rb b/spec/factories/blog/posts.rb new file mode 100644 index 0000000000..7e9ee15704 --- /dev/null +++ b/spec/factories/blog/posts.rb @@ -0,0 +1,18 @@ +# == Schema Information +# Schema version: 20230314171033 +# +# Table name: blog_posts +# +# id :bigint not null, primary key +# title :string +# url :string +# data :jsonb +# created_at :datetime not null +# updated_at :datetime not null +# +FactoryBot.define do + factory :blog_post, class: 'Blog::Post' do + sequence(:title) { |n| "My fancy blog post - part #{n}" } + sequence(:url) { |n| "http://example.com/blog_post_#{n}" } + end +end diff --git a/spec/factories/incoming_messages.rb b/spec/factories/incoming_messages.rb index 8a2af65300..da264a5d54 100644 --- a/spec/factories/incoming_messages.rb +++ b/spec/factories/incoming_messages.rb @@ -30,7 +30,7 @@ last_parsed { 1.week.ago } sent_at { 1.week.ago } - after(:build) do |incoming_message, evaluator| + after(:build) do |incoming_message, _evaluator| incoming_message.foi_attachments << build( :body_text, incoming_message: incoming_message, @@ -54,7 +54,7 @@ last_parsed { nil } sent_at { nil } - after(:create) do |incoming_message, evaluator| + after(:create) do |incoming_message, _evaluator| data = load_file_fixture('incoming-request-plain.email') data.gsub!('EMAIL_FROM', 'Bob Responder ') incoming_message.raw_email.data = data @@ -63,7 +63,7 @@ end factory :incoming_message_with_html_attachment do - after(:build) do |incoming_message, evaluator| + after(:build) do |incoming_message, _evaluator| incoming_message.foi_attachments << build( :html_attachment, incoming_message: incoming_message, diff --git a/spec/factories/info_request_batches.rb b/spec/factories/info_request_batches.rb index 686d6fa1a2..1dae2e9ad3 100644 --- a/spec/factories/info_request_batches.rb +++ b/spec/factories/info_request_batches.rb @@ -26,7 +26,7 @@ trait :embargoed do embargo_duration { '3_months' } - after(:build) do |batch, evaluator| + after(:build) do |batch, _evaluator| batch.info_requests.each do |request| request.embargo = build(:embargo) end diff --git a/spec/factories/info_request_events.rb b/spec/factories/info_request_events.rb index e2b91825e7..3c8a2b839b 100644 --- a/spec/factories/info_request_events.rb +++ b/spec/factories/info_request_events.rb @@ -1,12 +1,11 @@ # == Schema Information -# Schema version: 20220408125559 +# Schema version: 20230127132719 # # Table name: info_request_events # # id :integer not null, primary key # info_request_id :integer not null # event_type :text not null -# params_yaml :text not null # created_at :datetime not null # described_state :string # calculated_state :string @@ -47,7 +46,7 @@ event.info_request = event.outgoing_message.info_request end - after(:create) do |evnt, evaluator| + after(:create) do |evnt, _evaluator| evnt.params = evnt.params.merge( outgoing_message_id: evnt.outgoing_message.id ) @@ -108,7 +107,7 @@ event.info_request = event.outgoing_message.info_request end - after(:create) do |evnt, evaluator| + after(:create) do |evnt, _evaluator| evnt.params = evnt.params.merge( outgoing_message_id: evnt.outgoing_message.id ) diff --git a/spec/factories/info_requests.rb b/spec/factories/info_requests.rb index 0f633142ec..41fb826f53 100644 --- a/spec/factories/info_requests.rb +++ b/spec/factories/info_requests.rb @@ -43,9 +43,9 @@ public_body user - after(:create) do |info_request, evaluator| - initial_request = create(:initial_request, :info_request => info_request, - :created_at => info_request.created_at) + after(:create) do |info_request, _evaluator| + initial_request = create(:initial_request, info_request: info_request, + created_at: info_request.created_at) initial_request.last_sent_at = info_request.created_at initial_request.save! end @@ -156,35 +156,35 @@ end trait :with_internal_review_request do - after(:create) do |info_request, evaluator| - outgoing_message = create(:internal_review_request, :info_request => info_request) + after(:create) do |info_request, _evaluator| + outgoing_message = create(:internal_review_request, info_request: info_request) end end trait :embargoed do - after(:create) do |info_request, evaluator| - create(:embargo, :info_request => info_request) + after(:create) do |info_request, _evaluator| + create(:embargo, info_request: info_request) info_request.reload end end trait :embargo_expiring do - after(:create) do |info_request, evaluator| - create(:expiring_embargo, :info_request => info_request) + after(:create) do |info_request, _evaluator| + create(:expiring_embargo, info_request: info_request) info_request.reload end end trait :re_embargoed do - after(:create) do |info_request, evaluator| + after(:create) do |info_request, _evaluator| info_request.log_event('expire_embargo', {}) - create(:embargo, :info_request => info_request) + create(:embargo, info_request: info_request) info_request end end trait :embargo_expired do - after(:create) do |info_request, evaluator| + after(:create) do |info_request, _evaluator| info_request.log_event('expire_embargo', info_request: info_request) info_request.reload end @@ -213,13 +213,13 @@ end trait :waiting_clarification do - after(:create) do |info_request, evaluator| + after(:create) do |info_request, _evaluator| info_request.set_described_state('waiting_clarification') end end trait :successful do - after(:create) do |info_request, evaluator| + after(:create) do |info_request, _evaluator| info_request.set_described_state('successful') end end @@ -244,7 +244,7 @@ trait :overdue do date_response_required_by { Time.zone.now - 1.day } - after(:create) do |info_request, evaluator| + after(:create) do |info_request, _evaluator| info_request.date_response_required_by = Time.zone.now - 1.day info_request.save! end @@ -253,7 +253,7 @@ trait :very_overdue do date_response_required_by { Time.zone.now - 21.days } date_very_overdue_after { Time.zone.now - 1.days } - after(:create) do |info_request, evaluator| + after(:create) do |info_request, _evaluator| info_request.date_response_required_by = Time.zone.now - 21.days info_request.date_very_overdue_after = Time.zone.now - 1.day info_request.save! diff --git a/spec/factories/mail_server_log_dones.rb b/spec/factories/mail_server_log_dones.rb index 9b3f480982..514aa6635c 100644 --- a/spec/factories/mail_server_log_dones.rb +++ b/spec/factories/mail_server_log_dones.rb @@ -14,11 +14,7 @@ factory :mail_server_log_done do filename { - if rails_upgrade? - "/var/log/mail/mail.log-#{ Date.current.to_fs(:number)} " - else - "/var/log/mail/mail.log-#{ Date.current.to_s(:number)} " - end + "/var/log/mail/mail.log-#{ Date.current.to_fs(:number)} " } last_stat { Time.current } end diff --git a/spec/factories/outgoing_messages.rb b/spec/factories/outgoing_messages.rb index 1fc0f61518..2d85280887 100644 --- a/spec/factories/outgoing_messages.rb +++ b/spec/factories/outgoing_messages.rb @@ -70,11 +70,11 @@ # to update it. Because after_initialize executes before assigning the # attributes, loads of stuff fails because whatever after_initialize is # doing expects some of the attributes to be there. - initialize_with { OutgoingMessage.new({ :status => status, - :message_type => message_type, - :body => body, - :what_doing => what_doing, - :prominence => prominence }) } + initialize_with { OutgoingMessage.new({ status: status, + message_type: message_type, + body: body, + what_doing: what_doing, + prominence: prominence }) } after(:create) do |outgoing_message| outgoing_message.sendable? diff --git a/spec/factories/post_redirects.rb b/spec/factories/post_redirects.rb index 73bf58f36b..2a06c0f8ff 100644 --- a/spec/factories/post_redirects.rb +++ b/spec/factories/post_redirects.rb @@ -38,7 +38,7 @@ }, "info_request" => { "title" => "Testing the post redirect to pro things", - "public_body_id" => "#{public_body.id}" + "public_body_id" => public_body.id.to_s }, "submitted_new_request" => "1", "preview" => "0", diff --git a/spec/factories/profile_photos.rb b/spec/factories/profile_photos.rb new file mode 100644 index 0000000000..b3973e7778 --- /dev/null +++ b/spec/factories/profile_photos.rb @@ -0,0 +1,23 @@ +# == Schema Information +# Schema version: 20230223145243 +# +# Table name: profile_photos +# +# id :integer not null, primary key +# data :binary not null +# user_id :integer +# draft :boolean default(FALSE), not null +# created_at :datetime +# updated_at :datetime +# +FactoryBot.define do + factory :profile_photo do + user + data { load_file_fixture('parrot.jpg') } + draft { false } + + trait :draft do + draft { true } + end + end +end diff --git a/spec/factories/public_bodies.rb b/spec/factories/public_bodies.rb index 53940d4c94..4bfcd433fd 100644 --- a/spec/factories/public_bodies.rb +++ b/spec/factories/public_bodies.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 20220210114052 +# Schema version: 20230209094128 # # Table name: public_bodies # @@ -22,7 +22,6 @@ # short_name :text # request_email :text # url_name :text -# notes :text # first_letter :string # publication_scheme :text # disclosure_log :text @@ -49,6 +48,16 @@ tag_string { 'eir_only' } end + trait :with_note do + transient do + note_body { 'This is my note' } + end + + concrete_notes do + [association(:note, body: note_body)] + end + end + factory :blank_email_public_body do request_email { '' } end diff --git a/spec/factories/track_things.rb b/spec/factories/track_things.rb index 46972de7ca..125bb499b4 100644 --- a/spec/factories/track_things.rb +++ b/spec/factories/track_things.rb @@ -21,30 +21,30 @@ track_medium { 'email_daily' } track_query { 'Example Query' } track_type { 'search_query' } - association :tracking_user, :factory => :user + association :tracking_user, factory: :user factory :search_track factory :user_track do - association :tracked_user, :factory => :user + association :tracked_user, factory: :user track_type { 'user_updates' } - after(:create) do |track_thing, evaluator| + after(:create) do |track_thing, _evaluator| track_thing.track_query = "requested_by:#{ user.url_name }" \ " OR commented_by: #{ user.url_name }" track_thing.save! end end factory :public_body_track do - association :public_body, :factory => :public_body + association :public_body, factory: :public_body track_type { 'public_body_updates' } - after(:create) do |track_thing, evaluator| + after(:create) do |track_thing, _evaluator| track_thing.track_query = "requested_from:" \ "#{ track_thing.public_body.url_name }" track_thing.save! end end factory :request_update_track do - association :info_request, :factory => :info_request + association :info_request, factory: :info_request track_type { 'request_updates' } - after(:create) do |track_thing, evaluator| + after(:create) do |track_thing, _evaluator| track_thing.track_query = "request:" \ "#{ track_thing.info_request.url_title }" track_thing.save! diff --git a/spec/factories/user_messages.rb b/spec/factories/user_messages.rb new file mode 100644 index 0000000000..b4536b5f62 --- /dev/null +++ b/spec/factories/user_messages.rb @@ -0,0 +1,15 @@ +# == Schema Information +# Schema version: 20230222154014 +# +# Table name: user_messages +# +# id :bigint not null, primary key +# user_id :bigint +# created_at :datetime not null +# updated_at :datetime not null +# +FactoryBot.define do + factory :user_message do + user + end +end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 5d2b78be9b..62315d415e 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 20220210114052 +# Schema version: 20230301110831 # # Table name: users # @@ -35,6 +35,8 @@ # daily_summary_minute :integer # closed_at :datetime # login_token :string +# receive_user_messages :boolean default(TRUE), not null +# user_messages_count :integer default(0), not null # FactoryBot.define do @@ -61,7 +63,7 @@ sequence(:name) { |n| "Pro User #{n}" } pro - after(:create) do |user, evaluator| + after(:create) do |user, _evaluator| create(:pro_account, user: user) end end @@ -85,7 +87,7 @@ end trait :enable_otp do - after(:build) { |object| object.enable_otp } + after(:build, &:enable_otp) end trait :unconfirmed do @@ -98,6 +100,7 @@ trait :closed do closed_at { Time.zone.now } + receive_email_alerts { false } end end end diff --git a/spec/fixtures/files/blog_feed.atom b/spec/fixtures/files/blog_feed.atom index a831243b4c..ea47477e7b 100644 --- a/spec/fixtures/files/blog_feed.atom +++ b/spec/fixtures/files/blog_feed.atom @@ -33,6 +33,23 @@ ]]> http://www.example.com/feed/ 2 + + + + Other Post + http://www.example.com/other-post + http://www.example.com/other-post#comments + Mon, 01 Mar 2013 12:00:00 +0000 + Example Blogger + + + http://www.example.com/?id=332 + + A blog post +

    Another example post

    +]]>
    + http://www.example.com/feed/ + 0
    diff --git a/spec/fixtures/files/yaml_compatibility_4_2.yml b/spec/fixtures/files/yaml_compatibility_4_2.yml deleted file mode 100644 index e19ea582c3..0000000000 --- a/spec/fixtures/files/yaml_compatibility_4_2.yml +++ /dev/null @@ -1,259 +0,0 @@ ---- -:user: !ruby/object:User - raw_attributes: - locale: en - name: Annie All Roles - ban_text: '' - closed_at: - email: annie@localhost - id: '8' - hashed_password: 6b7cd45a5f35fd83febc0452a799530398bfb6e8 - salt: "-6116981980.392287733335677" - created_at: '2007-10-31 10:39:15.491593' - updated_at: '2007-10-31 10:39:15.491593' - email_confirmed: t - url_name: annie_admin - last_daily_track_email: '2000-01-01 00:00:00' - about_me: All the roles - email_bounced_at: - email_bounce_message: '' - no_limit: f - receive_email_alerts: t - can_make_batch_requests: f - otp_enabled: f - otp_secret_key: - otp_counter: '1' - confirmed_not_spam: f - comments_count: '0' - info_requests_count: '1' - track_things_count: '0' - request_classifications_count: '0' - public_body_change_requests_count: '0' - info_request_batches_count: '0' - daily_summary_hour: - daily_summary_minute: - attributes: !ruby/object:ActiveRecord::AttributeSet - attributes: !ruby/object:ActiveRecord::LazyAttributeHash - types: - id: &5 !ruby/object:ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Integer - precision: - scale: - limit: - range: !ruby/range - begin: -2147483648 - end: 2147483648 - excl: true - email: &1 !ruby/object:ActiveRecord::Type::String - precision: - scale: - limit: - name: *1 - hashed_password: *1 - salt: *1 - created_at: &7 !ruby/object:ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter - subtype: &2 !ruby/object:ActiveRecord::ConnectionAdapters::PostgreSQL::OID::DateTime - precision: - scale: - limit: - updated_at: &8 !ruby/object:ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter - subtype: *2 - email_confirmed: &4 !ruby/object:ActiveRecord::Type::Boolean - precision: - scale: - limit: - url_name: &3 !ruby/object:ActiveRecord::Type::Text - precision: - scale: - limit: - last_daily_track_email: &9 !ruby/object:ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter - subtype: *2 - ban_text: *3 - about_me: *3 - locale: *1 - email_bounced_at: &10 !ruby/object:ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter - subtype: *2 - email_bounce_message: *3 - no_limit: *4 - receive_email_alerts: *4 - can_make_batch_requests: *4 - otp_enabled: *4 - otp_secret_key: *1 - otp_counter: *5 - confirmed_not_spam: *4 - comments_count: *5 - info_requests_count: *5 - track_things_count: *5 - request_classifications_count: *5 - public_body_change_requests_count: *5 - info_request_batches_count: *5 - daily_summary_hour: *5 - daily_summary_minute: *5 - closed_at: &6 !ruby/object:ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter - subtype: *2 - values: - id: '8' - email: annie@localhost - name: Annie All Roles - hashed_password: 6b7cd45a5f35fd83febc0452a799530398bfb6e8 - salt: "-6116981980.392287733335677" - created_at: '2007-10-31 10:39:15.491593' - updated_at: '2007-10-31 10:39:15.491593' - email_confirmed: t - url_name: annie_admin - last_daily_track_email: '2000-01-01 00:00:00' - ban_text: '' - about_me: All the roles - locale: en - email_bounced_at: - email_bounce_message: '' - no_limit: f - receive_email_alerts: t - can_make_batch_requests: f - otp_enabled: f - otp_secret_key: - otp_counter: '1' - confirmed_not_spam: f - comments_count: '0' - info_requests_count: '1' - track_things_count: '0' - request_classifications_count: '0' - public_body_change_requests_count: '0' - info_request_batches_count: '0' - daily_summary_hour: - daily_summary_minute: - closed_at: - additional_types: {} - materialized: true - delegate_hash: - locale: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: locale - value_before_type_cast: en - type: *1 - value: en - name: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: name - value_before_type_cast: Annie All Roles - type: *1 - value: Annie All Roles - ban_text: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: ban_text - value_before_type_cast: '' - type: *3 - value: '' - closed_at: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: closed_at - value_before_type_cast: - type: *6 - value: - email: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: email - value_before_type_cast: annie@localhost - type: *1 - value: annie@localhost - id: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: id - value_before_type_cast: '8' - type: *5 - value: 8 - hashed_password: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: hashed_password - value_before_type_cast: 6b7cd45a5f35fd83febc0452a799530398bfb6e8 - type: *1 - salt: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: salt - value_before_type_cast: "-6116981980.392287733335677" - type: *1 - created_at: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: created_at - value_before_type_cast: '2007-10-31 10:39:15.491593' - type: *7 - updated_at: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: updated_at - value_before_type_cast: '2007-10-31 10:39:15.491593' - type: *8 - email_confirmed: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: email_confirmed - value_before_type_cast: t - type: *4 - url_name: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: url_name - value_before_type_cast: annie_admin - type: *3 - last_daily_track_email: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: last_daily_track_email - value_before_type_cast: '2000-01-01 00:00:00' - type: *9 - about_me: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: about_me - value_before_type_cast: All the roles - type: *3 - email_bounced_at: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: email_bounced_at - value_before_type_cast: - type: *10 - email_bounce_message: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: email_bounce_message - value_before_type_cast: '' - type: *3 - no_limit: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: no_limit - value_before_type_cast: f - type: *4 - receive_email_alerts: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: receive_email_alerts - value_before_type_cast: t - type: *4 - can_make_batch_requests: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: can_make_batch_requests - value_before_type_cast: f - type: *4 - otp_enabled: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: otp_enabled - value_before_type_cast: f - type: *4 - otp_secret_key: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: otp_secret_key - value_before_type_cast: - type: *1 - otp_counter: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: otp_counter - value_before_type_cast: '1' - type: *5 - confirmed_not_spam: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: confirmed_not_spam - value_before_type_cast: f - type: *4 - comments_count: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: comments_count - value_before_type_cast: '0' - type: *5 - info_requests_count: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: info_requests_count - value_before_type_cast: '1' - type: *5 - track_things_count: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: track_things_count - value_before_type_cast: '0' - type: *5 - request_classifications_count: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: request_classifications_count - value_before_type_cast: '0' - type: *5 - public_body_change_requests_count: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: public_body_change_requests_count - value_before_type_cast: '0' - type: *5 - info_request_batches_count: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: info_request_batches_count - value_before_type_cast: '0' - type: *5 - daily_summary_hour: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: daily_summary_hour - value_before_type_cast: - type: *5 - daily_summary_minute: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: daily_summary_minute - value_before_type_cast: - type: *5 - new_record: false - active_record_yaml_version: 0 diff --git a/spec/fixtures/files/yaml_compatibility_5_0.yml b/spec/fixtures/files/yaml_compatibility_5_0.yml deleted file mode 100644 index 939190a94d..0000000000 --- a/spec/fixtures/files/yaml_compatibility_5_0.yml +++ /dev/null @@ -1,223 +0,0 @@ ---- -:user: !ruby/object:User - raw_attributes: - name: Annie All Roles - ban_text: '' - closed_at: - email: annie@localhost - id: 8 - hashed_password: 6b7cd45a5f35fd83febc0452a799530398bfb6e8 - salt: "-6116981980.392287733335677" - created_at: '2007-10-31 10:39:15.491593' - updated_at: '2007-10-31 10:39:15.491593' - email_confirmed: true - url_name: annie_admin - last_daily_track_email: '2000-01-01 00:00:00' - about_me: All the roles - locale: en - email_bounced_at: - email_bounce_message: '' - no_limit: false - receive_email_alerts: true - can_make_batch_requests: false - otp_enabled: false - otp_secret_key: - otp_counter: 1 - confirmed_not_spam: false - comments_count: 0 - info_requests_count: 1 - track_things_count: 0 - request_classifications_count: 0 - public_body_change_requests_count: 0 - info_request_batches_count: 0 - daily_summary_hour: - daily_summary_minute: - attributes: !ruby/object:ActiveRecord::AttributeSet - attributes: !ruby/object:ActiveRecord::LazyAttributeHash - delegate_hash: - name: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: name - value_before_type_cast: Annie All Roles - type: &1 !ruby/object:ActiveModel::Type::String - precision: - scale: - limit: - original_attribute: - value: Annie All Roles - ban_text: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: ban_text - value_before_type_cast: '' - type: &3 !ruby/object:ActiveModel::Type::Text - precision: - scale: - limit: - original_attribute: - value: '' - closed_at: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: closed_at - value_before_type_cast: - type: !ruby/object:ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter - delegate_dc_obj: &2 !ruby/object:ActiveRecord::ConnectionAdapters::PostgreSQL::OID::DateTime - precision: - scale: - limit: - original_attribute: - value: - email: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: email - value_before_type_cast: annie@localhost - type: *1 - original_attribute: - value: annie@localhost - id: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: id - value_before_type_cast: 8 - type: &5 !ruby/object:ActiveModel::Type::Integer - precision: - scale: - limit: - range: !ruby/range - begin: -2147483648 - end: 2147483648 - excl: true - original_attribute: - value: 8 - hashed_password: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: hashed_password - value_before_type_cast: 6b7cd45a5f35fd83febc0452a799530398bfb6e8 - type: *1 - original_attribute: - salt: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: salt - value_before_type_cast: "-6116981980.392287733335677" - type: *1 - original_attribute: - created_at: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: created_at - value_before_type_cast: '2007-10-31 10:39:15.491593' - type: !ruby/object:ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter - delegate_dc_obj: *2 - original_attribute: - updated_at: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: updated_at - value_before_type_cast: '2007-10-31 10:39:15.491593' - type: !ruby/object:ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter - delegate_dc_obj: *2 - original_attribute: - email_confirmed: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: email_confirmed - value_before_type_cast: true - type: &4 !ruby/object:ActiveModel::Type::Boolean - precision: - scale: - limit: - original_attribute: - url_name: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: url_name - value_before_type_cast: annie_admin - type: *3 - original_attribute: - last_daily_track_email: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: last_daily_track_email - value_before_type_cast: '2000-01-01 00:00:00' - type: !ruby/object:ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter - delegate_dc_obj: *2 - original_attribute: - about_me: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: about_me - value_before_type_cast: All the roles - type: *3 - original_attribute: - locale: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: locale - value_before_type_cast: en - type: *1 - original_attribute: - email_bounced_at: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: email_bounced_at - value_before_type_cast: - type: !ruby/object:ActiveRecord::AttributeMethods::TimeZoneConversion::TimeZoneConverter - delegate_dc_obj: *2 - original_attribute: - email_bounce_message: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: email_bounce_message - value_before_type_cast: '' - type: *3 - original_attribute: - no_limit: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: no_limit - value_before_type_cast: false - type: *4 - original_attribute: - receive_email_alerts: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: receive_email_alerts - value_before_type_cast: true - type: *4 - original_attribute: - can_make_batch_requests: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: can_make_batch_requests - value_before_type_cast: false - type: *4 - original_attribute: - otp_enabled: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: otp_enabled - value_before_type_cast: false - type: *4 - original_attribute: - otp_secret_key: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: otp_secret_key - value_before_type_cast: - type: *1 - original_attribute: - otp_counter: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: otp_counter - value_before_type_cast: 1 - type: *5 - original_attribute: - confirmed_not_spam: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: confirmed_not_spam - value_before_type_cast: false - type: *4 - original_attribute: - comments_count: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: comments_count - value_before_type_cast: 0 - type: *5 - original_attribute: - info_requests_count: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: info_requests_count - value_before_type_cast: 1 - type: *5 - original_attribute: - track_things_count: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: track_things_count - value_before_type_cast: 0 - type: *5 - original_attribute: - request_classifications_count: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: request_classifications_count - value_before_type_cast: 0 - type: *5 - original_attribute: - public_body_change_requests_count: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: public_body_change_requests_count - value_before_type_cast: 0 - type: *5 - original_attribute: - info_request_batches_count: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: info_request_batches_count - value_before_type_cast: 0 - type: *5 - original_attribute: - daily_summary_hour: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: daily_summary_hour - value_before_type_cast: - type: *5 - original_attribute: - daily_summary_minute: !ruby/object:ActiveRecord::Attribute::FromDatabase - name: daily_summary_minute - value_before_type_cast: - type: *5 - original_attribute: - new_record: false - active_record_yaml_version: 1 diff --git a/spec/fixtures/files/yaml_compatibility_5_1.yml b/spec/fixtures/files/yaml_compatibility_5_1.yml deleted file mode 100644 index b54cb5d2e1..0000000000 --- a/spec/fixtures/files/yaml_compatibility_5_1.yml +++ /dev/null @@ -1,93 +0,0 @@ ---- -:user: !ruby/object:User - concise_attributes: - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: name - value_before_type_cast: Annie All Roles - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: ban_text - value_before_type_cast: '' - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: closed_at - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: email - value_before_type_cast: annie@localhost - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: id - value_before_type_cast: 8 - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: hashed_password - value_before_type_cast: 6b7cd45a5f35fd83febc0452a799530398bfb6e8 - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: salt - value_before_type_cast: "-6116981980.392287733335677" - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: created_at - value_before_type_cast: '2007-10-31 10:39:15.491593' - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: updated_at - value_before_type_cast: '2007-10-31 10:39:15.491593' - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: email_confirmed - value_before_type_cast: true - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: url_name - value_before_type_cast: annie_admin - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: last_daily_track_email - value_before_type_cast: '2000-01-01 00:00:00' - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: about_me - value_before_type_cast: All the roles - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: locale - value_before_type_cast: en - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: email_bounced_at - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: email_bounce_message - value_before_type_cast: '' - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: no_limit - value_before_type_cast: false - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: receive_email_alerts - value_before_type_cast: true - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: can_make_batch_requests - value_before_type_cast: false - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: otp_enabled - value_before_type_cast: false - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: otp_secret_key - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: otp_counter - value_before_type_cast: 1 - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: confirmed_not_spam - value_before_type_cast: false - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: comments_count - value_before_type_cast: 0 - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: info_requests_count - value_before_type_cast: 1 - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: track_things_count - value_before_type_cast: 0 - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: request_classifications_count - value_before_type_cast: 0 - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: public_body_change_requests_count - value_before_type_cast: 0 - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: info_request_batches_count - value_before_type_cast: 0 - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: daily_summary_hour - - !ruby/object:ActiveRecord::Attribute::FromDatabase - name: daily_summary_minute - new_record: false - active_record_yaml_version: 2 diff --git a/spec/fixtures/files/yaml_compatibility_public_body_tag.yml b/spec/fixtures/files/yaml_compatibility_public_body_tag.yml deleted file mode 100644 index 29112db217..0000000000 --- a/spec/fixtures/files/yaml_compatibility_public_body_tag.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -public_body_tags: -- !ruby/object:PublicBodyTag - attributes: - name: police - public_body_id: "1" - id: "2" - attributes_cache: {} diff --git a/spec/fixtures/files/yaml_compatibility_tmail.yml b/spec/fixtures/files/yaml_compatibility_tmail.yml deleted file mode 100644 index a0e7078a19..0000000000 --- a/spec/fixtures/files/yaml_compatibility_tmail.yml +++ /dev/null @@ -1,62 +0,0 @@ ---- -email: !ruby/object:TMail::Mail - port: !ruby/object:TMail::StringPort - buffer: ! "From: \"FOI Person\" \nTo: \"Bob Smith\" \nDate: - Tue, 13 Nov 2007 11:39:55 +0000\nBcc: \nSubject: Geraldine FOI Code AZXB421\nReply-To: - \nIn-Reply-To: <471f1eae5d1cb_7347..fdbe67386163@cat.tmail>\n\nNo way! I'm not - going to tell you that in a month of Thursdays.\n\nThe Geraldine Quango\n\nOn - Wed, Oct 24, 2007 at 11:30:06AM +0100, Bob Smith wrote:\n> Why do you have such - a fancy dog?\n\n" - config: &70134848947220 !ruby/object:TMail::Config - strict_parse: false - strict_base64decode: false - header: - from: !ruby/object:TMail::AddressHeader - body: ! '"FOI Person" - - ' - config: *70134848947220 - illegal: false - parsed: false - to: !ruby/object:TMail::AddressHeader - body: ! '"Bob Smith" - - ' - config: *70134848947220 - illegal: false - parsed: false - date: !ruby/object:TMail::DateTimeHeader - body: ! 'Tue, 13 Nov 2007 11:39:55 +0000 - - ' - config: *70134848947220 - illegal: false - parsed: false - bcc: !ruby/object:TMail::AddressHeader - body: '' - config: *70134848947220 - illegal: false - parsed: false - subject: !ruby/object:TMail::UnstructuredHeader - body: ! 'Geraldine FOI Code AZXB421 - - ' - config: *70134848947220 - illegal: false - parsed: false - reply-to: !ruby/object:TMail::AddressHeader - body: '' - config: *70134848947220 - illegal: false - parsed: false - in-reply-to: !ruby/object:TMail::ReferencesHeader - body: ! '<471f1eae5d1cb_7347..fdbe67386163@cat.tmail> - - ' - config: *70134848947220 - illegal: false - parsed: false - body_port: - body_parsed: false - epilogue: '' - parts: [] diff --git a/spec/fixtures/info_request_events.yml b/spec/fixtures/info_request_events.yml index 177d4a97f7..8eb1cece3a 100644 --- a/spec/fixtures/info_request_events.yml +++ b/spec/fixtures/info_request_events.yml @@ -1,12 +1,11 @@ # == Schema Information -# Schema version: 20220408125559 +# Schema version: 20230127132719 # # Table name: info_request_events # # id :integer not null, primary key # info_request_id :integer not null # event_type :text not null -# params_yaml :text not null # created_at :datetime not null # described_state :string # calculated_state :string @@ -20,8 +19,6 @@ useless_outgoing_message_event: id: 900 - params_yaml: "--- \n\ - :outgoing_message_id: 1\n" params: outgoing_message_id: 1 info_request_id: 101 @@ -31,8 +28,6 @@ useless_outgoing_message_event: outgoing_message_id: 1 silly_outgoing_message_event: id: 901 - params_yaml: "--- \n\ - :outgoing_message_id: 2\n" params: outgoing_message_id: 2 info_request_id: 103 @@ -44,8 +39,6 @@ silly_outgoing_message_event: last_described_at: 2007-10-14 10:41:12.686264 useless_incoming_message_event: id: 902 - params_yaml: "--- \n\ - :incoming_message_id: 1\n" params: incoming_message_id: 1 info_request_id: 101 @@ -55,8 +48,6 @@ useless_incoming_message_event: incoming_message_id: 1 silly_comment_event: id: 903 - params_yaml: "--- \n\ - :comment_id: 1\n" params: comment_id: 1 incoming_message_id: @@ -70,8 +61,6 @@ silly_comment_event: created_at: 2008-08-12 23:05:12.500942 badger_outgoing_message_event: id: 904 - params_yaml: "--- \n\ - :outgoing_message_id: 3\n" params: outgoing_message_id: 3 info_request_id: 104 @@ -84,8 +73,6 @@ badger_outgoing_message_event: # These in chronological order boring_outgoing_message_event: id: 905 - params_yaml: "--- \n\ - :outgoing_message_id: 4\n" params: outgoing_message_id: 4 outgoing_message_id: 4 @@ -96,8 +83,6 @@ boring_outgoing_message_event: calculated_state: waiting_response useful_incoming_message_event: id: 906 - params_yaml: "--- \n\ - :incoming_message_id: 2\n" params: incoming_message_id: 2 incoming_message_id: 2 @@ -109,8 +94,6 @@ useful_incoming_message_event: another_boring_outgoing_message_event: id: 907 - params_yaml: "--- \n\ - :outgoing_message_id: 5\n" params: outgoing_message_id: 5 outgoing_message_id: 5 @@ -121,8 +104,6 @@ another_boring_outgoing_message_event: calculated_state: waiting_response another_useful_incoming_message_event: id: 908 - params_yaml: "--- \n\ - :incoming_message_id: 3\n" params: incoming_message_id: 3 incoming_message_id: 3 @@ -135,8 +116,6 @@ another_useful_incoming_message_event: # The spam requests were both successful spam_1_outgoing_message_event: id: 910 - params_yaml: "--- \n\ - :outgoing_message_id: 6\n" params: outgoing_message_id: 6 outgoing_message_id: 6 @@ -147,8 +126,6 @@ spam_1_outgoing_message_event: calculated_state: waiting_response spam_1_incoming_message_event: id: 911 - params_yaml: "--- \n\ - :incoming_message_id: 4\n" params: incoming_message_id: 4 incoming_message_id: 4 @@ -160,8 +137,6 @@ spam_1_incoming_message_event: spam_2_outgoing_message_event: id: 912 - params_yaml: "--- \n\ - :outgoing_message_id: 7\n" params: outgoing_message_id: 7 outgoing_message_id: 7 @@ -172,8 +147,6 @@ spam_2_outgoing_message_event: calculated_state: waiting_response spam_2_incoming_message_event: id: 913 - params_yaml: "--- \n\ - :incoming_message_id: 5\n" params: incoming_message_id: 5 incoming_message_id: 5 @@ -185,8 +158,6 @@ spam_2_incoming_message_event: external_outgoing_message_event: id: 914 - params_yaml: "--- \n\ - :outgoing_message_id: 8\n" params: outgoing_message_id: 8 outgoing_message_id: 8 @@ -198,8 +169,6 @@ external_outgoing_message_event: anonymous_external_outgoing_message_event: id: 915 - params_yaml: "--- \n\ - :outgoing_message_id: 9\n" params: outgoing_message_id: 9 outgoing_message_id: 9 @@ -211,8 +180,6 @@ anonymous_external_outgoing_message_event: other_request_outgoing_message_event: id: 916 - params_yaml: "--- \n\ - :outgoing_message_id: 10\n" params: outgoing_message_id: 10 outgoing_message_id: 10 diff --git a/spec/fixtures/note_translations.yml b/spec/fixtures/note_translations.yml new file mode 100644 index 0000000000..c55e7ff598 --- /dev/null +++ b/spec/fixtures/note_translations.yml @@ -0,0 +1,63 @@ +geraldine_es_note_translation: + id: 1 + note_id: 2 + locale: es + body: + created_at: 2007-10-24 10:51:01.161639 + updated_at: 2007-10-24 10:51:01.161639 + +geraldine_en_note_translation: + id: 2 + note_id: 2 + locale: en + body: + created_at: 2007-10-24 10:51:01.161639 + updated_at: 2007-10-24 10:51:01.161639 + +humpadink_es_note_translation: + id: 3 + note_id: 3 + locale: es + body: Baguette + created_at: 2007-10-24 10:51:01.161639 + updated_at: 2007-10-24 10:51:01.161639 + +humpadink_en_note_translation: + id: 4 + note_id: 3 + locale: en + body: An albatross told me!!! + created_at: 2007-10-24 10:51:01.161639 + updated_at: 2007-10-24 10:51:01.161639 + +silly_walks_en_note_translation: + id: 6 + note_id: 5 + locale: en + body: You know the one. + created_at: 2007-10-24 10:51:01.161639 + updated_at: 2007-10-24 10:51:01.161639 + +sensible_walks_en_note_translation: + id: 7 + note_id: 6 + locale: en + body: I bet you’ve never heard of it. + created_at: 2008-10-25 10:51:01.161639 + updated_at: 2008-10-25 10:51:01.161639 + +other_note_translation: + id: 8 + note_id: 7 + locale: en + body: More notes + created_at: 2008-10-25 10:51:01.161639 + updated_at: 2008-10-25 10:51:01.161639 + +humpadink_he_IL_note_translation: + id: 9 + note_id: 3 + locale: he_IL + body: An albatross told me!!! + created_at: 2007-10-24 10:51:01.161639 + updated_at: 2007-10-24 10:51:01.161639 diff --git a/spec/fixtures/notes.yml b/spec/fixtures/notes.yml new file mode 100644 index 0000000000..2765719141 --- /dev/null +++ b/spec/fixtures/notes.yml @@ -0,0 +1,48 @@ +# == Schema Information +# Schema version: 20220928093559 +# +# Table name: notes +# +# id :bigint not null, primary key +# notable_type :string +# notable_id :bigint +# notable_tag :string +# created_at :datetime not null +# updated_at :datetime not null +# body :text +# + +geraldine_note: + id: 2 + notable_type: PublicBody + notable_id: 2 + created_at: 2007-10-24 10:51:01.161639 + updated_at: 2007-10-24 10:51:01.161639 + +humpadink_note: + id: 3 + notable_type: PublicBody + notable_id: 3 + created_at: 2007-10-24 10:51:01.161639 + updated_at: 2007-10-24 10:51:01.161639 + +silly_walks_note: + id: 5 + notable_type: PublicBody + notable_id: 5 + created_at: 2007-10-24 10:51:01.161639 + updated_at: 2007-10-24 10:51:01.161639 + +sensible_walks_note: + id: 6 + notable_type: PublicBody + notable_id: 6 + created_at: 2008-10-25 10:51:01.161639 + updated_at: 2008-10-25 10:51:01.161639 + +other_note: + id: 7 + notable_type: PublicBody + notable_id: 7 + created_at: 2008-10-25 10:51:01.161639 + updated_at: 2008-10-25 10:51:01.161639 diff --git a/spec/fixtures/public_bodies.yml b/spec/fixtures/public_bodies.yml index bd7644915e..de6edb1960 100644 --- a/spec/fixtures/public_bodies.yml +++ b/spec/fixtures/public_bodies.yml @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 20220210114052 +# Schema version: 20230209094128 # # Table name: public_bodies # @@ -22,7 +22,6 @@ # short_name :text # request_email :text # url_name :text -# notes :text # first_letter :string # publication_scheme :text # disclosure_log :text diff --git a/spec/fixtures/public_body_translations.yml b/spec/fixtures/public_body_translations.yml index 8d645912ad..3b13fcaf72 100644 --- a/spec/fixtures/public_body_translations.yml +++ b/spec/fixtures/public_body_translations.yml @@ -7,7 +7,6 @@ geraldine_es_public_body_translation: short_name: eTGQ url_name: etgq locale: es - notes: "" publication_scheme: "" disclosure_log: "" created_at: 2007-10-24 10:51:01.161639 @@ -22,7 +21,6 @@ geraldine_en_public_body_translation: short_name: TGQ url_name: tgq locale: en - notes: "" publication_scheme: "" disclosure_log: "" created_at: 2007-10-24 10:51:01.161639 @@ -37,7 +35,6 @@ humpadink_es_public_body_translation: short_name: eDfH url_name: edfh locale: es - notes: Baguette publication_scheme: "" disclosure_log: "" created_at: 2007-10-24 10:51:01.161639 @@ -52,7 +49,6 @@ humpadink_en_public_body_translation: short_name: DfH url_name: dfh locale: en - notes: An albatross told me!!! publication_scheme: "" disclosure_log: "" created_at: 2007-10-24 10:51:01.161639 @@ -67,7 +63,6 @@ forlorn_en_public_body_translation: short_name: DoL url_name: lonely locale: en - notes: A very lonely public body that no one has corresponded with publication_scheme: "" disclosure_log: "" created_at: 2007-10-24 10:51:01.161639 @@ -82,7 +77,6 @@ silly_walks_en_public_body_translation: request_email: silly-walks-requests@localhost short_name: MSW url_name: msw - notes: You know the one. publication_scheme: "" disclosure_log: "" created_at: 2007-10-24 10:51:01.161639 @@ -97,7 +91,6 @@ sensible_walks_en_public_body_translation: request_email: sensible-walks-requests@localhost short_name: SenseWalk url_name: sensible_walks - notes: I bet you’ve never heard of it. publication_scheme: "" disclosure_log: "" created_at: 2008-10-25 10:51:01.161639 @@ -112,7 +105,6 @@ other_public_body_translation: request_email: other@localhost short_name: Another Public Body url_name: another_public_body - notes: More notes publication_scheme: "" disclosure_log: "" created_at: 2008-10-25 10:51:01.161639 @@ -127,7 +119,6 @@ humpadink_he_IL_public_body_translation: short_name: DfH url_name: dfh locale: he_IL - notes: An albatross told me!!! publication_scheme: "" disclosure_log: "" created_at: 2007-10-24 10:51:01.161639 diff --git a/spec/fixtures/public_body_versions.yml b/spec/fixtures/public_body_versions.yml index f5ede78207..e1264430b0 100644 --- a/spec/fixtures/public_body_versions.yml +++ b/spec/fixtures/public_body_versions.yml @@ -19,7 +19,6 @@ humpadink_public_body_update: request_email: humpadink-requests@localhost public_body_id: "3" id: "6" - notes: "An albatross told me!!!" version: "2" last_edit_editor: "francis" short_name: DfH @@ -33,7 +32,6 @@ geraldine_public_body_initial: request_email: geraldine-requests@localhost public_body_id: "2" id: 1 - notes: "-" version: "1" last_edit_editor: "mark" short_name: TGQ @@ -47,7 +45,6 @@ forlorn_public_body_initial: request_email: forlorn-requests@localhost public_body_id: "4" id: 2 - notes: A very lonely public body that no one has corresponded with version: "1" last_edit_editor: "robin" short_name: DoL @@ -61,7 +58,6 @@ silly_walks_public_body_intitial: request_email: silly-walks-requests@localhost public_body_id: 5 id: 3 - notes: You know the one. version: 1 last_edit_editor: robin short_name: MSW @@ -75,7 +71,6 @@ sensible_walks_public_body_initial: request_email: sensible-walks-requests@localhost public_body_id: 6 id: 4 - notes: I bet you’ve never heard of it. version: 1 last_edit_editor: robin short_name: SenseWalk @@ -89,7 +84,6 @@ other_public_body_initial: request_email: other@localhost public_body_id: 7 id: 7 - notes: More notes version: 1 last_edit_editor: louise short_name: Another Public Body diff --git a/spec/fixtures/stripe_webhooks/customer.subscription.deleted.json b/spec/fixtures/stripe_webhooks/customer.subscription.deleted.json new file mode 100644 index 0000000000..c9c3ebee2c --- /dev/null +++ b/spec/fixtures/stripe_webhooks/customer.subscription.deleted.json @@ -0,0 +1,65 @@ +{ + "created": 1326853478, + "livemode": false, + "id": "evt_00000000000000", + "type": "customer.subscription.deleted", + "object": "event", + "data": { + "object": { + "id": "su_00000000000000", + "items": { + "object": "list", + "data": [{ + "id": "si_00000000000000", + "object": "subscription_item", + "created": 1497881783, + "plan": { + "interval": "month", + "product": "pr_00000000000000", + "amount": 100, + "currency": "usd", + "id": "fkx0AFo_00000000000000", + "object": "plan", + "livemode": false, + "interval_count": 1, + "trial_period_days": null, + "metadata": {} + }, + "quantity": 1 + }, + { + "id": "si_00000000000001", + "object": "subscription_item", + "created": 1497881788, + "plan": { + "interval": "month", + "product": "pr_00000000000001", + "amount": 200, + "currency": "eur", + "id": "fkx0AFo_00000000000001", + "object": "plan", + "livemode": false, + "interval_count": 1, + "trial_period_days": null, + "metadata": {} + }, + "quantity": 5 + } + ] + }, + "object": "subscription", + "start": 1381080564, + "status": "canceled", + "customer": "cus_00000000000000", + "cancel_at_period_end": false, + "current_period_start": 1381080564, + "current_period_end": 1383758964, + "ended_at": 1381021514, + "trial_start": null, + "trial_end": null, + "canceled_at": null, + "quantity": 1, + "application_fee_percent": null + } + } +} diff --git a/spec/fixtures/stripe_webhooks/invoice.payment_failed.json b/spec/fixtures/stripe_webhooks/invoice.payment_failed.json new file mode 100644 index 0000000000..294270e46d --- /dev/null +++ b/spec/fixtures/stripe_webhooks/invoice.payment_failed.json @@ -0,0 +1,105 @@ +{ + "created": 1326853478, + "livemode": false, + "id": "evt_00000000000000", + "type": "invoice.payment_failed", + "object": "event", + "data": { + "object": { + "date": 1380674206, + "id": "in_00000000000000", + "period_start": 1378082075, + "period_end": 1380674075, + "lines": { + "object": "list", + "count": 3, + "url": "/v1/invoices/in_00000000000000/lines", + "data": [ + { + "id": "ii_00000000000000", + "object": "line_item", + "type": "invoiceitem", + "livemode": false, + "amount": 19000, + "currency": "usd", + "proration": true, + "period": { + "start": 1393765661, + "end": 1393765661 + }, + "quantity": null, + "plan": null, + "description": "Remaining time on Platinum after 02 Mar 2014", + "metadata": {} + }, + { + "id": "ii_00000000000001", + "object": "line_item", + "type": "invoiceitem", + "livemode": false, + "amount": -9000, + "currency": "usd", + "proration": true, + "period": { + "start": 1393765661, + "end": 1393765661 + }, + "quantity": null, + "plan": null, + "description": "Unused time on Gold after 05 Mar 2014", + "metadata": {} + }, + { + "id": "su_00000000000000", + "object": "line_item", + "type": "subscription", + "livemode": false, + "amount": 20000, + "currency": "usd", + "proration": false, + "period": { + "start": 1383759053, + "end": 1386351053 + }, + "quantity": 1, + "plan": { + "interval": "month", + "product": "pr_00000000000000", + "created": 1300000000, + "amount": 20000, + "currency": "usd", + "id": "platinum", + "object": "plan", + "livemode": false, + "interval_count": 1, + "trial_period_days": null, + "metadata": {} + }, + "description": null, + "metadata": null + } + ] + }, + "subtotal": 30000, + "total": 30000, + "customer": "cus_00000000000000", + "object": "invoice", + "attempted": true, + "closed": false, + "paid": false, + "livemode": false, + "attempt_count": 1, + "amount_due": 30000, + "currency": "usd", + "starting_balance": 0, + "ending_balance": 0, + "next_payment_attempt": 1380760475, + "charge": "ch_00000000000000", + "discount": null, + "application_fee": null, + "subscription": "su_00000000000000", + "metadata": {}, + "description": null + } + } +} diff --git a/spec/fixtures/stripe_webhooks/invoice.payment_succeeded.json b/spec/fixtures/stripe_webhooks/invoice.payment_succeeded.json new file mode 100644 index 0000000000..9be30439cb --- /dev/null +++ b/spec/fixtures/stripe_webhooks/invoice.payment_succeeded.json @@ -0,0 +1,112 @@ +{ + "created": 1326853478, + "livemode": false, + "id": "evt_00000000000000", + "type": "invoice.payment_succeeded", + "object": "event", + "data": { + "object": { + "id": "in_00000000000000", + "object": "invoice", + "amount_due": 999, + "application_fee": null, + "attempt_count": 1, + "attempted": true, + "charge": "ch_18EcOcLrgDIZ7iq8TaNlErVv", + "closed": true, + "currency": "eur", + "customer": "cus_00000000000000", + "created": 1464084258, + "description": null, + "discount": null, + "ending_balance": 0, + "forgiven": false, + "lines": { + "data": [{ + "id": "sub_00000000000000", + "object": "line_item", + "amount": 50, + "currency": "eur", + "description": null, + "discountable": true, + "livemode": true, + "metadata": {}, + "period": { + "start": 1500637196, + "end": 1532173196 + }, + "plan": { + "id": "platinum", + "object": "plan", + "amount": 500, + "created": 1499943145, + "currency": "eur", + "interval": "month", + "interval_count": 1, + "livemode": false, + "metadata": {}, + "name": "New Plan Test", + "statement_descriptor": null, + "trial_period_days": null + }, + "proration": false, + "quantity": 1, + "subscription": null, + "subscription_item": "si_18ZfWyLrgDIZ7iq8fSlSNGIV", + "type": "subscription" + }, + { + "id": "sub_00000000000000", + "object": "line_item", + "amount": 50, + "currency": "eur", + "description": null, + "discountable": true, + "livemode": true, + "metadata": {}, + "period": { + "start": 1500637196, + "end": 1532173196 + }, + "plan": { + "id": "gold", + "object": "plan", + "amount": 300, + "created": 1499943155, + "currency": "eur", + "interval": "month", + "interval_count": 1, + "livemode": false, + "metadata": {}, + "name": "New gold Plan Test", + "statement_descriptor": null, + "trial_period_days": null + }, + "proration": false, + "quantity": 1, + "subscription": null, + "subscription_item": "si_18ZfWyLrgDIZ7iq8fSlSNGIV", + "type": "subscription" + }], + "total_count": 1, + "object": "list", + "url": "/v1/invoices/in_18EcOcLrgDIZ7iq8zsDkunZ0/lines" + }, + "livemode": false, + "metadata": {}, + "next_payment_attempt": null, + "paid": true, + "period_end": 1464084258, + "period_start": 1464084258, + "receipt_number": null, + "starting_balance": 0, + "statement_descriptor": null, + "subscription": "sub_00000000000000", + "subtotal": 999, + "tax": null, + "tax_percent": null, + "total": 999, + "webhooks_delivered_at": 1464084258 + } + } +} diff --git a/spec/fixtures/users.yml b/spec/fixtures/users.yml index 5fb397fc70..a9eda3156c 100644 --- a/spec/fixtures/users.yml +++ b/spec/fixtures/users.yml @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 20220210114052 +# Schema version: 20230301110831 # # Table name: users # @@ -35,6 +35,8 @@ # daily_summary_minute :integer # closed_at :datetime # login_token :string +# receive_user_messages :boolean default(TRUE), not null +# user_messages_count :integer default(0), not null # # If sample data has been loaded you can log in as any of these users with their diff --git a/spec/helpers/admin/link_helper_spec.rb b/spec/helpers/admin/link_helper_spec.rb index 71fb1a423b..ed49c1fb53 100644 --- a/spec/helpers/admin/link_helper_spec.rb +++ b/spec/helpers/admin/link_helper_spec.rb @@ -88,5 +88,13 @@ it { is_expected.to include(comment_path(record)) } it { is_expected.to include(edit_admin_comment_path(record)) } end + + context 'with a Blog Post' do + let(:record) { FactoryBot.create(:blog_post) } + + it { is_expected.to include('icon-eye-open') } + it { is_expected.to include(record.url) } + it { is_expected.to include(edit_admin_blog_post_path(record)) } + end end end diff --git a/spec/helpers/admin_comments_helper_spec.rb b/spec/helpers/admin_comments_helper_spec.rb index 8796acbe64..d8d938b529 100644 --- a/spec/helpers/admin_comments_helper_spec.rb +++ b/spec/helpers/admin_comments_helper_spec.rb @@ -11,7 +11,7 @@ end it 'adds a hidden label if the comment is hidden' do - comment = Comment.new(:visible => false) + comment = Comment.new(visible: false) html = %q(hidden) expect(comment_labels(comment)).to eq(html) end diff --git a/spec/helpers/alaveteli_pro/dashboard_helpers_spec.rb b/spec/helpers/alaveteli_pro/dashboard_helpers_spec.rb index 03eb200401..c025756997 100644 --- a/spec/helpers/alaveteli_pro/dashboard_helpers_spec.rb +++ b/spec/helpers/alaveteli_pro/dashboard_helpers_spec.rb @@ -8,8 +8,8 @@ it 'renders the activity_item description with links' do user = FactoryBot.create(:user) - comment = FactoryBot.create(:comment, :user => user) - event = FactoryBot.create(:comment_event, :comment => comment) + comment = FactoryBot.create(:comment, user: user) + event = FactoryBot.create(:comment_event, comment: comment) activity = AlaveteliPro::ActivityList::Comment.new(event) expected = "#{user_link user} added a new annotation on your request " \ diff --git a/spec/helpers/analytics_helper_spec.rb b/spec/helpers/analytics_helper_spec.rb index e1d61ad577..1b6de6542c 100644 --- a/spec/helpers/analytics_helper_spec.rb +++ b/spec/helpers/analytics_helper_spec.rb @@ -20,7 +20,7 @@ expect(track_analytics_event( AnalyticsEvent::Category::OUTBOUND, AnalyticsEvent::Action::FACEBOOK_EXIT, - :label => "test label" + label: "test label" )).to eq( "if (ga) { ga('send','event'," \ "'Outbound Link','Facebook Exit','test label',1) };" @@ -31,7 +31,7 @@ expect(track_analytics_event( AnalyticsEvent::Category::OUTBOUND, AnalyticsEvent::Action::FACEBOOK_EXIT, - :label => "test label" + label: "test label" )).to eq( "if (ga) { ga('send','event'," \ "'Outbound Link','Facebook Exit','test label',1) };" @@ -42,8 +42,8 @@ expect(track_analytics_event( AnalyticsEvent::Category::OUTBOUND, AnalyticsEvent::Action::FACEBOOK_EXIT, - :label => "test label", - :value => 42 + label: "test label", + value: 42 )).to eq( "if (ga) { ga('send','event'," \ "'Outbound Link','Facebook Exit','test label',42) };" @@ -54,8 +54,8 @@ expect(track_analytics_event( AnalyticsEvent::Category::WIDGET_CLICK, AnalyticsEvent::Action::WIDGET_VOTE, - :label => "location.href", - :label_is_script => true + label: "location.href", + label_is_script: true )).to eq( "if (ga) { ga('send','event'," \ "'Widget Clicked','Vote',location.href,1) };" @@ -66,7 +66,7 @@ expect(track_analytics_event( AnalyticsEvent::Category::OUTBOUND, AnalyticsEvent::Action::FACEBOOK_EXIT, - :value => 1234567 + value: 1_234_567 )).not_to include("1234567") end @@ -75,8 +75,8 @@ track_analytics_event( AnalyticsEvent::Category::OUTBOUND, AnalyticsEvent::Action::FACEBOOK_EXIT, - :label => 'test label', - :value => "five") + label: 'test label', + value: "five") }.to raise_error( ArgumentError, ':value option must be an Integer: "five"') end diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 6ad64a6e9f..f74d073f7e 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -50,7 +50,7 @@ describe '#theme_installed?' do - let(:paths) { ['theme_path', 'app_path'] } + let(:paths) { %w[theme_path app_path] } let(:view_paths) { double(ActionView::PathSet, paths: paths) } diff --git a/spec/helpers/blog_helper_spec.rb b/spec/helpers/blog_helper_spec.rb new file mode 100644 index 0000000000..771cdeda19 --- /dev/null +++ b/spec/helpers/blog_helper_spec.rb @@ -0,0 +1,73 @@ +require 'spec_helper' + +RSpec.describe BlogHelper do + include BlogHelper + + describe '#blog_posts_for_frontpage' do + subject(:posts) { blog_posts_for_frontpage } + + before do + 4.times { FactoryBot.create(:blog_post) } + end + + it { is_expected.to all be_a(Blog::Post) } + + it 'returns maximum 4 posts' do + FactoryBot.create(:blog_post) + expect(posts.count).to eq(4) + end + + it 'includes the latest post' do + latest = FactoryBot.create(:blog_post) + expect(posts).to include(latest) + end + end + + describe '#blog_posts_for_taggable' do + let(:taggable) { FactoryBot.create(:public_body, tag_string: 'foo') } + + subject(:posts) { blog_posts_for_taggable(taggable: taggable) } + + context 'when blog disabled' do + before do + allow(Blog).to receive(:enabled?).and_return(false) + end + + let(:post) { FactoryBot.create(:blog_post, tag_string: 'foo') } + + it { is_expected.to eq([]) } + end + + context 'when blog enabled taggable' do + subject { blog_posts_for_taggable(taggable: taggable) } + + let(:post) { FactoryBot.create(:blog_post, tag_string: 'foo') } + let(:other_post) { FactoryBot.create(:blog_post, tag_string: 'bar') } + + it { is_expected.to include(post) } + it { is_expected.not_to include(other_post) } + end + + context 'without limit' do + before do + 4.times { FactoryBot.create(:blog_post, tag_string: 'foo') } + end + + it 'limits to 3 posts' do + expect(posts.count).to eq(3) + end + end + + context 'with limit' do + subject(:posts) { blog_posts_for_taggable(taggable: taggable, limit: 1) } + + before do + 2.times { FactoryBot.create(:blog_post, tag_string: 'foo') } + end + + it 'limits to specified number of posts' do + expect(posts.count).to eq(1) + end + end + end +end diff --git a/spec/helpers/currency_helper_spec.rb b/spec/helpers/currency_helper_spec.rb index ebfea16715..a0e9dcd354 100644 --- a/spec/helpers/currency_helper_spec.rb +++ b/spec/helpers/currency_helper_spec.rb @@ -10,11 +10,11 @@ end it 'formats the amount in the configured currency' do - expect(format_currency(123456)).to eq('£1,234.56') + expect(format_currency(123_456)).to eq('£1,234.56') allow(AlaveteliConfiguration).to receive(:iso_currency_code). and_return('HRK') - expect(format_currency(123456)).to eq('1.234,56 kn') + expect(format_currency(123_456)).to eq('1.234,56 kn') end it 'shows currency sub-units by default' do @@ -23,13 +23,13 @@ context 'when asked to show the amount without trailing zeros' do it 'does not show the trailing sub-unit amount when it is 00' do - expect(format_currency(123400, no_cents_if_whole: true)).to eq('£1,234') + expect(format_currency(123_400, no_cents_if_whole: true)).to eq('£1,234') end it 'does not rely on the UK currency format' do allow(AlaveteliConfiguration).to receive(:iso_currency_code). and_return('EUR') - expect(format_currency(123400, no_cents_if_whole: true)).to eq('€1.234') + expect(format_currency(123_400, no_cents_if_whole: true)).to eq('€1.234') end it 'still shows the sub-unit value if it is a non-zero amount' do diff --git a/spec/helpers/date_time_helper_spec.rb b/spec/helpers/date_time_helper_spec.rb index cbb4335f0a..07acda75a3 100644 --- a/spec/helpers/date_time_helper_spec.rb +++ b/spec/helpers/date_time_helper_spec.rb @@ -15,12 +15,12 @@ it 'formats a date in the specified format' do time = Time.utc(2012, 11, 07, 21, 30, 26) expect(self).to receive(:simple_date_text).with(time) - simple_date(time, :format => :text) + simple_date(time, format: :text) end it 'raises an argument error if given an unrecognized format' do time = Time.utc(2012, 11, 07, 21, 30, 26) - expect { simple_date(time, :format => :unknown) }.to raise_error(ArgumentError) + expect { simple_date(time, format: :unknown) }.to raise_error(ArgumentError) end end diff --git a/spec/helpers/health_checks_helper_spec.rb b/spec/helpers/health_checks_helper_spec.rb index 34c093d99e..886ba2a672 100644 --- a/spec/helpers/health_checks_helper_spec.rb +++ b/spec/helpers/health_checks_helper_spec.rb @@ -6,12 +6,12 @@ describe '#check_status' do it 'warns that the check is failing' do - check = double(:message => 'Failed', :ok? => false) + check = double(message: 'Failed', ok?: false) expect(check_status(check)).to include('red') end it 'sets style to a blank string if ok' do - check = double(:message => '', :ok? => true) + check = double(message: '', ok?: true) expect(check_status(check)).to include('style=""') end diff --git a/spec/helpers/highlight_helper_spec.rb b/spec/helpers/highlight_helper_spec.rb index c6f3cbb11e..c7e73ff679 100644 --- a/spec/helpers/highlight_helper_spec.rb +++ b/spec/helpers/highlight_helper_spec.rb @@ -68,7 +68,7 @@ assert_equal( "This is a beautiful morning, but also a beautiful day", - highlight_matches("This is a beautiful morning, but also a beautiful day", "beautiful", :highlighter => '\1') + highlight_matches("This is a beautiful morning, but also a beautiful day", "beautiful", highlighter: '\1') ) assert_equal( @@ -89,7 +89,7 @@ it 'doesnt sanitize when the sanitize option is false' do assert_equal( "This is a beautiful morning", - highlight_matches("This is a beautiful morning", "beautiful", :sanitize => false) + highlight_matches("This is a beautiful morning", "beautiful", sanitize: false) ) end @@ -116,7 +116,7 @@ end it 'highlights multiple phrases in one pass' do - assert_equal %(wow em), highlight_matches('wow em', %w(wow em), :highlighter => '\1') + assert_equal %(wow em), highlight_matches('wow em', %w(wow em), highlighter: '\1') end it 'highlights with html' do @@ -142,12 +142,12 @@ ) assert_equal( "
    abc div
    ", - highlight_matches("
    abc div
    ", "div", :highlighter => '\1') + highlight_matches("
    abc div
    ", "div", highlighter: '\1') ) end it 'doesnt modify the options hash' do - options = { :highlighter => '\1', :sanitize => false } + options = { highlighter: '\1', sanitize: false } passed_options = options.dup highlight_matches("
    abc div
    ", "div", passed_options) assert_equal options, passed_options @@ -156,7 +156,7 @@ it 'highlights with a block' do assert_equal( "one two three", - highlight_matches("one two three", ["one", "two", "three"]) { |word| "#{word}" } + highlight_matches("one two three", %w[one two three]) { |word| "#{word}" } ) end @@ -165,49 +165,49 @@ describe '#excerpt' do it 'excerpts' do - assert_equal("...is a beautiful morn...", excerpt("This is a beautiful morning", "beautiful", :radius => 5)) - assert_equal("This is a...", excerpt("This is a beautiful morning", "this", :radius => 5)) - assert_equal("...iful morning", excerpt("This is a beautiful morning", "morning", :radius => 5)) + assert_equal("...is a beautiful morn...", excerpt("This is a beautiful morning", "beautiful", radius: 5)) + assert_equal("This is a...", excerpt("This is a beautiful morning", "this", radius: 5)) + assert_equal("...iful morning", excerpt("This is a beautiful morning", "morning", radius: 5)) assert_nil excerpt("This is a beautiful morning", "day") end it 'is not html safe' do - assert !excerpt('This is a beautiful! morning', 'beautiful', :radius => 5).html_safe? + assert !excerpt('This is a beautiful! morning', 'beautiful', radius: 5).html_safe? end it 'excerpts borderline cases' do - assert_equal("", excerpt("", "", :radius => 0)) - assert_equal("a", excerpt("a", "a", :radius => 0)) - assert_equal("...b...", excerpt("abc", "b", :radius => 0)) - assert_equal("abc", excerpt("abc", "b", :radius => 1)) - assert_equal("abc...", excerpt("abcd", "b", :radius => 1)) - assert_equal("...abc", excerpt("zabc", "b", :radius => 1)) - assert_equal("...abc...", excerpt("zabcd", "b", :radius => 1)) - assert_equal("zabcd", excerpt("zabcd", "b", :radius => 2)) + assert_equal("", excerpt("", "", radius: 0)) + assert_equal("a", excerpt("a", "a", radius: 0)) + assert_equal("...b...", excerpt("abc", "b", radius: 0)) + assert_equal("abc", excerpt("abc", "b", radius: 1)) + assert_equal("abc...", excerpt("abcd", "b", radius: 1)) + assert_equal("...abc", excerpt("zabc", "b", radius: 1)) + assert_equal("...abc...", excerpt("zabcd", "b", radius: 1)) + assert_equal("zabcd", excerpt("zabcd", "b", radius: 2)) # excerpt strips the resulting string before ap-/prepending excerpt_string. # whether this behavior is meaningful when excerpt_string is not to be # appended is questionable. - assert_equal("zabcd", excerpt(" zabcd ", "b", :radius => 4)) - assert_equal("...abc...", excerpt("z abc d", "b", :radius => 1)) + assert_equal("zabcd", excerpt(" zabcd ", "b", radius: 4)) + assert_equal("...abc...", excerpt("z abc d", "b", radius: 1)) end it 'excerpts with regex' do - assert_equal('...is a beautiful! mor...', excerpt('This is a beautiful! morning', 'beautiful', :radius => 5)) - assert_equal('...is a beautiful? mor...', excerpt('This is a beautiful? morning', 'beautiful', :radius => 5)) - assert_equal('...is a beautiful? mor...', excerpt('This is a beautiful? morning', /\bbeau\w*\b/i, :radius => 5)) - assert_equal('...is a beautiful? mor...', excerpt('This is a beautiful? morning', /\b(beau\w*)\b/i, :radius => 5)) - assert_equal("...udge Allen and...", excerpt("This day was challenging for judge Allen and his colleagues.", /\ballen\b/i, :radius => 5)) - assert_equal("...judge Allen and...", excerpt("This day was challenging for judge Allen and his colleagues.", /\ballen\b/i, :radius => 1, :separator => ' ')) - assert_equal("...was challenging for...", excerpt("This day was challenging for judge Allen and his colleagues.", /\b(\w*allen\w*)\b/i, :radius => 5)) + assert_equal('...is a beautiful! mor...', excerpt('This is a beautiful! morning', 'beautiful', radius: 5)) + assert_equal('...is a beautiful? mor...', excerpt('This is a beautiful? morning', 'beautiful', radius: 5)) + assert_equal('...is a beautiful? mor...', excerpt('This is a beautiful? morning', /\bbeau\w*\b/i, radius: 5)) + assert_equal('...is a beautiful? mor...', excerpt('This is a beautiful? morning', /\b(beau\w*)\b/i, radius: 5)) + assert_equal("...udge Allen and...", excerpt("This day was challenging for judge Allen and his colleagues.", /\ballen\b/i, radius: 5)) + assert_equal("...judge Allen and...", excerpt("This day was challenging for judge Allen and his colleagues.", /\ballen\b/i, radius: 1, separator: ' ')) + assert_equal("...was challenging for...", excerpt("This day was challenging for judge Allen and his colleagues.", /\b(\w*allen\w*)\b/i, radius: 5)) end it 'excerpts with omission' do - assert_equal("[...]is a beautiful morn[...]", excerpt("This is a beautiful morning", "beautiful", :omission => "[...]",:radius => 5)) + assert_equal("[...]is a beautiful morn[...]", excerpt("This is a beautiful morning", "beautiful", omission: "[...]",radius: 5)) assert_equal( "This is the ultimate supercalifragilisticexpialidoceous very looooooooooooooooooong looooooooooooong beautiful morning with amazing sunshine and awesome tempera[...]", excerpt("This is the ultimate supercalifragilisticexpialidoceous very looooooooooooooooooong looooooooooooong beautiful morning with amazing sunshine and awesome temperatures. So what are you gonna do about it?", "very", - :omission => "[...]") + omission: "[...]") ) end @@ -215,30 +215,30 @@ assert_equal("...\357\254\203ciency could not be...".force_encoding(Encoding::UTF_8), excerpt("That's why e\357\254\203ciency could not be helped".force_encoding(Encoding::UTF_8), 'could', - :radius => 8)) + radius: 8)) end it 'doesnt modify the options hash' do - options = { :omission => "[...]",:radius => 5 } + options = { omission: "[...]",radius: 5 } passed_options = options.dup excerpt("This is a beautiful morning", "beautiful", passed_options) assert_equal options, passed_options end it 'excerpts with separator' do - options = { :separator => ' ', :radius => 1 } + options = { separator: ' ', radius: 1 } assert_equal('...a very beautiful...', excerpt('This is a very beautiful morning', 'very', options)) assert_equal('This is...', excerpt('This is a very beautiful morning', 'this', options)) assert_equal('...beautiful morning', excerpt('This is a very beautiful morning', 'morning', options)) - options = { :separator => "\n", :radius => 0 } + options = { separator: "\n", radius: 0 } assert_equal("...very long...", excerpt("my very\nvery\nvery long\nstring", 'long', options)) - options = { :separator => "\n", :radius => 1 } + options = { separator: "\n", radius: 1 } assert_equal("...very\nvery long\nstring", excerpt("my very\nvery\nvery long\nstring", 'long', options)) assert_equal excerpt('This is a beautiful morning', 'a'), - excerpt('This is a beautiful morning', 'a', :separator => nil) + excerpt('This is a beautiful morning', 'a', separator: nil) end end diff --git a/spec/helpers/info_request_helper_spec.rb b/spec/helpers/info_request_helper_spec.rb index 6844b5353e..a14bbfe689 100644 --- a/spec/helpers/info_request_helper_spec.rb +++ b/spec/helpers/info_request_helper_spec.rb @@ -289,7 +289,7 @@ "" \ "send a follow up message." - actual = status_text(info_request, :is_owning_user => true) + actual = status_text(info_request, is_owning_user: true) expect(actual).to eq(expected) end @@ -306,8 +306,8 @@ "#{ sign_in_link } to send a follow up message." actual = status_text(info_request, - :is_owning_user => false, - :redirect_to => '/request/example') + is_owning_user: false, + redirect_to: '/request/example') expect(actual).to eq(expected) end @@ -315,7 +315,7 @@ it 'does not add a followup link for external requests' do allow(info_request).to receive(:is_external?).and_return(true) expected = 'The request is waiting for clarification.' - actual = status_text(info_request, :is_owning_user => false) + actual = status_text(info_request, is_owning_user: false) expect(actual).to eq(expected) end @@ -327,7 +327,7 @@ it 'requires a redirect_to option' do expect { - status_text(info_request, :is_owning_user => false) + status_text(info_request, is_owning_user: false) }.to raise_error(KeyError) end @@ -456,10 +456,10 @@ 'so we know whether it contains useful ' \ 'information.' actual = status_text(info_request, - :new_responses_count => 1, - :is_owning_user => true, - :render_to_file => false, - :old_unclassified => false) + new_responses_count: 1, + is_owning_user: true, + render_to_file: false, + old_unclassified: false) expect(actual).to eq(expected) end end @@ -471,10 +471,10 @@ 'so we know whether they contain useful ' \ 'information.' actual = status_text(info_request, - :new_responses_count => 3, - :is_owning_user => true, - :render_to_file => false, - :old_unclassified => true) + new_responses_count: 3, + is_owning_user: true, + render_to_file: false, + old_unclassified: true) expect(actual).to eq(expected) end end @@ -489,10 +489,10 @@ "you might like to help out by doing " \ "that?" actual = status_text(info_request, - :new_responses_count => 1, - :is_owning_user => false, - :render_to_file => false, - :old_unclassified => true) + new_responses_count: 1, + is_owning_user: false, + render_to_file: false, + old_unclassified: true) expect(actual).to eq(expected) end end @@ -505,10 +505,10 @@ "you might like to help out by doing " \ "that?" actual = status_text(info_request, - :new_responses_count => 3, - :is_owning_user => false, - :render_to_file => false, - :old_unclassified => true) + new_responses_count: 3, + is_owning_user: false, + render_to_file: false, + old_unclassified: true) expect(actual).to eq(expected) end end @@ -519,17 +519,17 @@ let(:info_request) { FactoryBot.create(:external_request, awaiting_description: true) } let(:message) do status_text(info_request, - :new_responses_count => 1, - :is_owning_user => true, - :render_to_file => false, - :old_unclassified => false) + new_responses_count: 1, + is_owning_user: true, + render_to_file: false, + old_unclassified: false) end let(:plural_message) do status_text(info_request, - :new_responses_count => 3, - :is_owning_user => true, - :render_to_file => false, - :old_unclassified => false) + new_responses_count: 3, + is_owning_user: true, + render_to_file: false, + old_unclassified: false) end end end @@ -538,17 +538,17 @@ it_behaves_like "when we can't ask the user to update the status" do let(:message) do status_text(info_request, - :new_responses_count => 1, - :is_owning_user => true, - :render_to_file => true, - :old_unclassified => false) + new_responses_count: 1, + is_owning_user: true, + render_to_file: true, + old_unclassified: false) end let(:plural_message) do status_text(info_request, - :new_responses_count => 3, - :is_owning_user => true, - :render_to_file => true, - :old_unclassified => false) + new_responses_count: 3, + is_owning_user: true, + render_to_file: true, + old_unclassified: false) end end end @@ -557,17 +557,17 @@ it_behaves_like "when we can't ask the user to update the status" do let(:message) do status_text(info_request, - :new_responses_count => 1, - :is_owning_user => false, - :render_to_file => false, - :old_unclassified => false) + new_responses_count: 1, + is_owning_user: false, + render_to_file: false, + old_unclassified: false) end let(:plural_message) do status_text(info_request, - :new_responses_count => 3, - :is_owning_user => false, - :render_to_file => false, - :old_unclassified => false) + new_responses_count: 3, + is_owning_user: false, + render_to_file: false, + old_unclassified: false) end end @@ -594,8 +594,8 @@ context 'if an icon exists for the filetype' do let(:jpeg_attachment) { FactoryBot.create(:jpeg_attachment, - :incoming_message => incoming_message, - :url_part_number => 1) + incoming_message: incoming_message, + url_part_number: 1) } it 'returns a link with a specific icon' do @@ -608,8 +608,8 @@ context 'if no icon exists for the filetype' do let(:unknown_attachment) { FactoryBot.create(:unknown_attachment, - :incoming_message => incoming_message, - :url_part_number => 1) + incoming_message: incoming_message, + url_part_number: 1) } it 'returns a link with the "unknown" icon' do diff --git a/spec/helpers/link_to_helper_spec.rb b/spec/helpers/link_to_helper_spec.rb index 159f128cb1..323d400a7b 100644 --- a/spec/helpers/link_to_helper_spec.rb +++ b/spec/helpers/link_to_helper_spec.rb @@ -13,7 +13,7 @@ it 'should return a path including any extra parameters passed' do expected = "/request/#{info_request.url_title}?update_status=1" - actual = request_path(info_request, {:update_status => 1}) + actual = request_path(info_request, {update_status: 1}) expect(actual).to eq(expected) end end @@ -39,7 +39,7 @@ end it 'includes a cache busting parameter if set' do - url = incoming_message_url(incoming_message, :cachebust => true) + url = incoming_message_url(incoming_message, cachebust: true) expect(url).to include("nocache=incoming-#{incoming_message.id}") end @@ -75,8 +75,8 @@ end it 'creates a sign in url to the cachebusted incoming message url' do - msg_url = incoming_message_url(incoming_message, :cachebust => true) - expected = signin_url(:r => msg_url) + msg_url = incoming_message_url(incoming_message, cachebust: true) + expected = signin_url(r: msg_url) actual = new_response_url(info_request, incoming_message) expect(actual).to eq(expected) end @@ -87,7 +87,7 @@ let(:info_request) { incoming_message.info_request } it 'creates a cachbusted incoming message url' do - expected = incoming_message_url(incoming_message, :cachebust => true) + expected = incoming_message_url(incoming_message, cachebust: true) actual = new_response_url(info_request, incoming_message) expect(actual).to eq(expected) end @@ -115,7 +115,7 @@ end it 'includes a cache busting parameter if set' do - url = outgoing_message_url(outgoing_message, :cachebust => true) + url = outgoing_message_url(outgoing_message, cachebust: true) expect(url).to include("nocache=outgoing-#{outgoing_message.id}") end end @@ -172,7 +172,7 @@ describe 'when displaying a user link for a request' do context "for external requests" do let(:info_request) do - FactoryBot.create(:external_request, :external_user_name => nil) + FactoryBot.create(:external_request, external_user_name: nil) end it 'should return the text "Anonymous user" with a link to the privacy @@ -213,7 +213,7 @@ describe 'when displaying a user admin link for a request' do let(:info_request) do - FactoryBot.create(:external_request, :external_user_name => nil) + FactoryBot.create(:external_request, external_user_name: nil) end it 'should return the text "An anonymous user (external)" in the case diff --git a/spec/helpers/public_body_helper_spec.rb b/spec/helpers/public_body_helper_spec.rb index b9205f4821..60b0cad328 100644 --- a/spec/helpers/public_body_helper_spec.rb +++ b/spec/helpers/public_body_helper_spec.rb @@ -56,11 +56,11 @@ end it 'handles Unicode' do - category = FactoryBot.create(:public_body_category, :category_tag => 'spec', - :description => 'ünicode category') + category = FactoryBot.create(:public_body_category, category_tag: 'spec', + description: 'ünicode category') heading = FactoryBot.create(:public_body_heading) heading.add_category(category) - public_body = FactoryBot.create(:public_body, :tag_string => 'spec') + public_body = FactoryBot.create(:public_body, tag_string: 'spec') expect(type_of_authority(public_body)).to eq('Ünicode category') @@ -69,11 +69,11 @@ it 'constructs the correct string if there are tags which are not categories' do heading = FactoryBot.create(:public_body_heading) 3.times do |i| - category = FactoryBot.create(:public_body_category, :category_tag => "spec_#{i}", - :description => "spec category #{i}") + category = FactoryBot.create(:public_body_category, category_tag: "spec_#{i}", + description: "spec category #{i}") heading.add_category(category) end - public_body = FactoryBot.create(:public_body, :tag_string => 'unknown spec_0 spec_2') + public_body = FactoryBot.create(:public_body, tag_string: 'unknown spec_0 spec_2') expected = 'Spec category 0 and spec category 2' expect(type_of_authority(public_body)).to eq(expected) end @@ -82,11 +82,11 @@ context 'when associated with one category' do it 'returns the description wrapped in an anchor tag' do - category = FactoryBot.create(:public_body_category, :category_tag => 'spec', - :description => 'spec category') + category = FactoryBot.create(:public_body_category, category_tag: 'spec', + description: 'spec category') heading = FactoryBot.create(:public_body_heading) heading.add_category(category) - public_body = FactoryBot.create(:public_body, :tag_string => 'spec') + public_body = FactoryBot.create(:public_body, tag_string: 'spec') anchor = %Q(Spec category) expect(type_of_authority(public_body)).to eq(anchor) @@ -98,11 +98,11 @@ it 'joins the category descriptions and capitalizes the first letter' do heading = FactoryBot.create(:public_body_heading) 3.times do |i| - category = FactoryBot.create(:public_body_category, :category_tag => "spec_#{i}", - :description => "spec category #{i}") + category = FactoryBot.create(:public_body_category, category_tag: "spec_#{i}", + description: "spec category #{i}") heading.add_category(category) end - public_body = FactoryBot.create(:public_body, :tag_string => 'spec_0 spec_1 spec_2') + public_body = FactoryBot.create(:public_body, tag_string: 'spec_0 spec_1 spec_2') description = [ %Q(Spec category 0), @@ -122,11 +122,11 @@ it 'creates the anchor href in the correct locale' do # Activate the routing filter, normally turned off for helper tests RoutingFilter.active = true - category = FactoryBot.create(:public_body_category, :category_tag => 'spec', - :description => 'spec category') + category = FactoryBot.create(:public_body_category, category_tag: 'spec', + description: 'spec category') heading = FactoryBot.create(:public_body_heading) heading.add_category(category) - public_body = FactoryBot.create(:public_body, :tag_string => 'spec') + public_body = FactoryBot.create(:public_body, tag_string: 'spec') anchor = %Q(Spec category) AlaveteliLocalization.with_locale(:es) do diff --git a/spec/helpers/taggable_helper_spec.rb b/spec/helpers/taggable_helper_spec.rb new file mode 100644 index 0000000000..bda56b93d0 --- /dev/null +++ b/spec/helpers/taggable_helper_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +RSpec.describe TaggableHelper do + include TaggableHelper + + describe '#tags_css' do + subject { tags_css(taggable) } + + let(:taggable) { FactoryBot.build(:public_body, tag_string: tag_string) } + + context 'when the taggable has tags' do + let(:tag_string) { 'foo bar_baz' } + it { is_expected.to eq('tag--foo tag--bar_baz') } + end + + context 'when the taggable has tags with values' do + let(:tag_string) { 'foo bar:baz' } + it { is_expected.to eq('tag--foo tag--bar') } + end + + context 'when the taggable has no tags' do + let(:tag_string) { '' } + it { is_expected.to be_empty } + end + end +end diff --git a/spec/helpers/track_helper_spec.rb b/spec/helpers/track_helper_spec.rb index 96ad971e61..2f4cb7b410 100644 --- a/spec/helpers/track_helper_spec.rb +++ b/spec/helpers/track_helper_spec.rb @@ -93,7 +93,7 @@ end it 'should create a following subscription notice' do - expected = %Q(You are now following updates about this search.) + expected = %Q(You are now following updates about this search.) expect(subscribe_follow_notice(@track_thing)).to eq(expected) end @@ -121,7 +121,7 @@ end it 'should create a following subscription notice' do - expected = %Q(You are now following updates about '#{user_link(@track_thing.tracked_user)}', a person.) + expected = %Q(You are now following updates about '#{user_link(@track_thing.tracked_user)}', a person.) expect(subscribe_follow_notice(@track_thing)).to eq(expected) end @@ -149,7 +149,7 @@ end it 'should create a following subscription notice' do - expected = %Q(You are now following updates about '#{public_body_link(@track_thing.public_body)}', a public authority.) + expected = %Q(You are now following updates about '#{public_body_link(@track_thing.public_body)}', a public authority.) expect(subscribe_follow_notice(@track_thing)).to eq(expected) end @@ -176,7 +176,7 @@ end it 'should create a following subscription notice' do - expected = %Q(You are now following updates about successful requests.) + expected = %Q(You are now following updates about successful requests.) expect(subscribe_follow_notice(@track_thing)).to eq(expected) end @@ -203,7 +203,7 @@ end it 'should create a following subscription notice' do - expected = %Q(You are now following updates about new requests.) + expected = %Q(You are now following updates about new requests.) expect(subscribe_follow_notice(@track_thing)).to eq(expected) end @@ -231,7 +231,7 @@ end it 'should create a following subscription notice' do - expected = %Q(You are now following updates about '#{request_link(@track_thing.info_request)}', a request.) + expected = %Q(You are now following updates about '#{request_link(@track_thing.info_request)}', a request.) expect(subscribe_follow_notice(@track_thing)).to eq(expected) end diff --git a/spec/integration/admin_censor_rule_spec.rb b/spec/integration/admin_censor_rule_spec.rb index 4ade90214d..e8a4e8f687 100644 --- a/spec/integration/admin_censor_rule_spec.rb +++ b/spec/integration/admin_censor_rule_spec.rb @@ -2,6 +2,8 @@ require 'integration/alaveteli_dsl' RSpec.describe 'Updating censor rules' do + include ActiveJob::TestHelper + let!(:admin) do confirm(:admin_user) login(:admin_user) @@ -11,8 +13,8 @@ let(:authority) { FactoryBot.create(:public_body) } let(:request) do FactoryBot.create(:info_request, - :public_body => authority, - :user => user) + public_body: authority, + user: user) end let!(:incoming_message) do @@ -25,14 +27,14 @@ EOF incoming_message = FactoryBot.create(:incoming_message, - :info_request => request) + info_request: request) incoming_message.raw_email.data = raw_email_data incoming_message.parse_raw_email!(true) - InfoRequestEvent.create(:event_type => "response", - :incoming_message => incoming_message, - :info_request => request, - :params => { - :incoming_message_id => incoming_message.id + InfoRequestEvent.create(event_type: "response", + incoming_message: incoming_message, + info_request: request, + params: { + incoming_message_id: incoming_message.id }) incoming_message end @@ -45,19 +47,21 @@ it 'clears the cache for existing requests when a new rule is added' do url_title = request.url_title - visit show_request_path :url_title => url_title + visit show_request_path url_title: url_title expect(page).to have_content "I have a rubbish answer for you" using_session(admin) do visit new_admin_body_censor_rule_path(authority) - fill_in 'censor_rule_text', :with => 'a rubbish answer' - fill_in 'censor_rule_replacement', :with => '[REDACTED]' - fill_in 'censor_rule_last_edit_comment', :with => 'test' + fill_in 'censor_rule_text', with: 'a rubbish answer' + fill_in 'censor_rule_replacement', with: '[REDACTED]' + fill_in 'censor_rule_last_edit_comment', with: 'test' click_button 'Create' end - visit show_request_path :url_title => url_title + perform_enqueued_jobs + + visit show_request_path url_title: url_title expect(page).not_to have_content "I have a rubbish answer for you" expect(page).to have_content "I have [REDACTED] for you" end @@ -65,23 +69,25 @@ it 'clears the cache for existing requests when a rule is updated' do url_title = request.url_title rule = FactoryBot.create(:public_body_censor_rule, - :public_body => authority, - :text => "rubbish", - :replacement => "[REDACTED]") + public_body: authority, + text: "rubbish", + replacement: "[REDACTED]") - visit show_request_path :url_title => url_title + visit show_request_path url_title: url_title expect(page).to have_content "I have a [REDACTED] answer for you" using_session(admin) do visit edit_admin_censor_rule_path(rule.id) - fill_in 'censor_rule_text', :with => 'answer' - fill_in 'censor_rule_replacement', :with => '[REDACTED]' - fill_in 'censor_rule_last_edit_comment', :with => 'test' + fill_in 'censor_rule_text', with: 'answer' + fill_in 'censor_rule_replacement', with: '[REDACTED]' + fill_in 'censor_rule_last_edit_comment', with: 'test' click_button 'Save' end - visit show_request_path :url_title => url_title + perform_enqueued_jobs + + visit show_request_path url_title: url_title expect(page).not_to have_content "I have a [REDACTED] answer for you" expect(page).to have_content "I have a rubbish [REDACTED] for you" end @@ -89,11 +95,11 @@ it 'clears the cache for existing requests when a rule is deleted' do url_title = request.url_title rule = FactoryBot.create(:public_body_censor_rule, - :public_body => authority, - :text => "rubbish", - :replacement => "[REDACTED]") + public_body: authority, + text: "rubbish", + replacement: "[REDACTED]") - visit show_request_path :url_title => url_title + visit show_request_path url_title: url_title expect(page).to have_content "I have a [REDACTED] answer for you" @@ -102,7 +108,9 @@ click_link 'Destroy censor rule' end - visit show_request_path :url_title => url_title + perform_enqueued_jobs + + visit show_request_path url_title: url_title expect(page).not_to have_content "I have a [REDACTED] answer for you" expect(page).to have_content "I have a rubbish answer for you" end @@ -113,19 +121,21 @@ it 'clears the cache for existing requests when a new rule is added' do url_title = request.url_title - visit show_request_path :url_title => url_title + visit show_request_path url_title: url_title expect(page).to have_content "I have a rubbish answer for you" using_session(admin) do visit new_admin_user_censor_rule_path(user) - fill_in 'censor_rule_text', :with => 'a rubbish answer' - fill_in 'censor_rule_replacement', :with => '[REDACTED]' - fill_in 'censor_rule_last_edit_comment', :with => 'test' + fill_in 'censor_rule_text', with: 'a rubbish answer' + fill_in 'censor_rule_replacement', with: '[REDACTED]' + fill_in 'censor_rule_last_edit_comment', with: 'test' click_button 'Create' end - visit show_request_path :url_title => url_title + perform_enqueued_jobs + + visit show_request_path url_title: url_title expect(page).not_to have_content "I have a rubbish answer for you" expect(page).to have_content "I have [REDACTED] for you" end @@ -133,23 +143,25 @@ it 'clears the cache for existing requests when a rule is updated' do url_title = request.url_title rule = FactoryBot.create(:user_censor_rule, - :user => user, - :text => "rubbish", - :replacement => "[REDACTED]") + user: user, + text: "rubbish", + replacement: "[REDACTED]") - visit show_request_path :url_title => url_title + visit show_request_path url_title: url_title expect(page).to have_content "I have a [REDACTED] answer for you" using_session(admin) do visit edit_admin_censor_rule_path(rule.id) - fill_in 'censor_rule_text', :with => 'answer' - fill_in 'censor_rule_replacement', :with => '[REDACTED]' - fill_in 'censor_rule_last_edit_comment', :with => 'test' + fill_in 'censor_rule_text', with: 'answer' + fill_in 'censor_rule_replacement', with: '[REDACTED]' + fill_in 'censor_rule_last_edit_comment', with: 'test' click_button 'Save' end - visit show_request_path :url_title => url_title + perform_enqueued_jobs + + visit show_request_path url_title: url_title expect(page).not_to have_content "I have a [REDACTED] answer for you" expect(page).to have_content "I have a rubbish [REDACTED] for you" end @@ -157,11 +169,11 @@ it 'clears the cache for existing requests when a rule is deleted' do url_title = request.url_title rule = FactoryBot.create(:user_censor_rule, - :user => user, - :text => "rubbish", - :replacement => "[REDACTED]") + user: user, + text: "rubbish", + replacement: "[REDACTED]") - visit show_request_path :url_title => url_title + visit show_request_path url_title: url_title expect(page).to have_content "I have a [REDACTED] answer for you" @@ -170,7 +182,9 @@ click_link 'Destroy censor rule' end - visit show_request_path :url_title => url_title + perform_enqueued_jobs + + visit show_request_path url_title: url_title expect(page).not_to have_content "I have a [REDACTED] answer for you" expect(page).to have_content "I have a rubbish answer for you" end @@ -182,19 +196,21 @@ it 'clears the cache for existing requests when a new rule is added' do request_id = request.id url_title = request.url_title - visit show_request_path :url_title => url_title + visit show_request_path url_title: url_title expect(page).to have_content "I have a rubbish answer for you" using_session(admin) do visit new_admin_request_censor_rule_path(request_id) - fill_in 'censor_rule_text', :with => 'a rubbish answer' - fill_in 'censor_rule_replacement', :with => '[REDACTED]' - fill_in 'censor_rule_last_edit_comment', :with => 'test' + fill_in 'censor_rule_text', with: 'a rubbish answer' + fill_in 'censor_rule_replacement', with: '[REDACTED]' + fill_in 'censor_rule_last_edit_comment', with: 'test' click_button 'Create' end - visit show_request_path :url_title => url_title + perform_enqueued_jobs + + visit show_request_path url_title: url_title expect(page).not_to have_content "I have a rubbish answer for you" expect(page).to have_content "I have [REDACTED] for you" end @@ -203,23 +219,25 @@ request_id = request.id url_title = request.url_title rule = FactoryBot.create(:info_request_censor_rule, - :info_request => request, - :text => "rubbish", - :replacement => "[REDACTED]") + info_request: request, + text: "rubbish", + replacement: "[REDACTED]") - visit show_request_path :url_title => url_title + visit show_request_path url_title: url_title expect(page).to have_content "I have a [REDACTED] answer for you" using_session(admin) do visit edit_admin_censor_rule_path(rule.id) - fill_in 'censor_rule_text', :with => 'answer' - fill_in 'censor_rule_replacement', :with => '[REDACTED]' - fill_in 'censor_rule_last_edit_comment', :with => 'test' + fill_in 'censor_rule_text', with: 'answer' + fill_in 'censor_rule_replacement', with: '[REDACTED]' + fill_in 'censor_rule_last_edit_comment', with: 'test' click_button 'Save' end - visit show_request_path :url_title => url_title + perform_enqueued_jobs + + visit show_request_path url_title: url_title expect(page).not_to have_content "I have a [REDACTED] answer for you" expect(page).to have_content "I have a rubbish [REDACTED] for you" end @@ -228,11 +246,11 @@ request_id = request.id url_title = request.url_title rule = FactoryBot.create(:info_request_censor_rule, - :info_request => request, - :text => "rubbish", - :replacement => "[REDACTED]") + info_request: request, + text: "rubbish", + replacement: "[REDACTED]") - visit show_request_path :url_title => url_title + visit show_request_path url_title: url_title expect(page).to have_content "I have a [REDACTED] answer for you" @@ -241,7 +259,9 @@ click_link 'Destroy censor rule' end - visit show_request_path :url_title => url_title + perform_enqueued_jobs + + visit show_request_path url_title: url_title expect(page).not_to have_content "I have a [REDACTED] answer for you" expect(page).to have_content "I have a rubbish answer for you" end @@ -252,19 +272,21 @@ it 'clears the cache for existing requests when a new rule is added' do url_title = request.url_title - visit show_request_path :url_title => url_title + visit show_request_path url_title: url_title expect(page).to have_content "I have a rubbish answer for you" using_session(admin) do visit new_admin_censor_rule_path - fill_in 'censor_rule_text', :with => 'a rubbish answer' - fill_in 'censor_rule_replacement', :with => '[REDACTED]' - fill_in 'censor_rule_last_edit_comment', :with => 'test' + fill_in 'censor_rule_text', with: 'a rubbish answer' + fill_in 'censor_rule_replacement', with: '[REDACTED]' + fill_in 'censor_rule_last_edit_comment', with: 'test' click_button 'Create' end - visit show_request_path :url_title => url_title + perform_enqueued_jobs + + visit show_request_path url_title: url_title expect(page).not_to have_content "I have a rubbish answer for you" expect(page).to have_content "I have [REDACTED] for you" end @@ -272,22 +294,24 @@ it 'clears the cache for existing requests when a rule is updated' do url_title = request.url_title rule = FactoryBot.create(:global_censor_rule, - :text => "rubbish", - :replacement => "[REDACTED]") + text: "rubbish", + replacement: "[REDACTED]") - visit show_request_path :url_title => url_title + visit show_request_path url_title: url_title expect(page).to have_content "I have a [REDACTED] answer for you" using_session(admin) do visit edit_admin_censor_rule_path(rule.id) - fill_in 'censor_rule_text', :with => 'answer' - fill_in 'censor_rule_replacement', :with => '[REDACTED]' - fill_in 'censor_rule_last_edit_comment', :with => 'test' + fill_in 'censor_rule_text', with: 'answer' + fill_in 'censor_rule_replacement', with: '[REDACTED]' + fill_in 'censor_rule_last_edit_comment', with: 'test' click_button 'Save' end - visit show_request_path :url_title => url_title + perform_enqueued_jobs + + visit show_request_path url_title: url_title expect(page).not_to have_content "I have a [REDACTED] answer for you" expect(page).to have_content "I have a rubbish [REDACTED] for you" end @@ -295,10 +319,10 @@ it 'clears the cache for existing requests when a rule is deleted' do url_title = request.url_title rule = FactoryBot.create(:global_censor_rule, - :text => "rubbish", - :replacement => "[REDACTED]") + text: "rubbish", + replacement: "[REDACTED]") - visit show_request_path :url_title => url_title + visit show_request_path url_title: url_title expect(page).to have_content "I have a [REDACTED] answer for you" @@ -307,7 +331,9 @@ click_link 'Destroy censor rule' end - visit show_request_path :url_title => url_title + perform_enqueued_jobs + + visit show_request_path url_title: url_title expect(page).not_to have_content "I have a [REDACTED] answer for you" expect(page).to have_content "I have a rubbish answer for you" end diff --git a/spec/integration/admin_outgoing_message_edit_spec.rb b/spec/integration/admin_outgoing_message_edit_spec.rb index 8e14ebc0ba..ac64e5e019 100644 --- a/spec/integration/admin_outgoing_message_edit_spec.rb +++ b/spec/integration/admin_outgoing_message_edit_spec.rb @@ -16,7 +16,7 @@ it 'saves the updated text' do using_session(@admin) do visit edit_admin_outgoing_message_path(ogm) - fill_in 'outgoing_message_body', :with => 'Updated text' + fill_in 'outgoing_message_body', with: 'Updated text' click_button 'Save' end @@ -43,7 +43,7 @@ using_session(@admin) do visit edit_admin_outgoing_message_path(ogm) fill_in 'outgoing_message_body', - :with => 'Some information please. And a biscuit.' + with: 'Some information please. And a biscuit.' click_button 'Save' end diff --git a/spec/integration/admin_public_body_category_edit_spec.rb b/spec/integration/admin_public_body_category_edit_spec.rb index 9061414857..3028a3029e 100644 --- a/spec/integration/admin_public_body_category_edit_spec.rb +++ b/spec/integration/admin_public_body_category_edit_spec.rb @@ -13,7 +13,7 @@ it 'can edit the default locale' do using_session(@admin) do visit edit_admin_category_path(@category) - fill_in 'public_body_category_title', :with => 'New Category EN' + fill_in 'public_body_category_title', with: 'New Category EN' click_button 'Save' end @@ -26,8 +26,8 @@ using_session(@admin) do visit edit_admin_category_path(@category) - fill_in 'public_body_category_translations_attributes_fr_title', :with => 'New Category FR' - fill_in 'public_body_category_translations_attributes_fr_description', :with => 'FR Description' + fill_in 'public_body_category_translations_attributes_fr_title', with: 'New Category FR' + fill_in 'public_body_category_translations_attributes_fr_description', with: 'FR Description' click_button 'Save' end @@ -41,14 +41,14 @@ using_session(@admin) do # Add FR translation visit edit_admin_category_path(@category) - fill_in 'public_body_category_translations_attributes_fr_title', :with => 'New Category FR' - fill_in 'public_body_category_translations_attributes_fr_description', :with => 'FR Description' + fill_in 'public_body_category_translations_attributes_fr_title', with: 'New Category FR' + fill_in 'public_body_category_translations_attributes_fr_description', with: 'FR Description' click_button 'Save' # Add ES translation visit edit_admin_category_path(@category) - fill_in 'public_body_category_translations_attributes_es_title', :with => 'New Category ES' - fill_in 'public_body_category_translations_attributes_es_description', :with => 'ES Description' + fill_in 'public_body_category_translations_attributes_es_title', with: 'New Category ES' + fill_in 'public_body_category_translations_attributes_es_description', with: 'ES Description' click_button 'Save' end diff --git a/spec/integration/admin_public_body_category_new_spec.rb b/spec/integration/admin_public_body_category_new_spec.rb index 5e0e62c913..f02308a79a 100644 --- a/spec/integration/admin_public_body_category_new_spec.rb +++ b/spec/integration/admin_public_body_category_new_spec.rb @@ -13,9 +13,9 @@ AlaveteliLocalization.set_locales('en_GB es', 'en_GB') using_session(@admin) do visit new_admin_category_path - fill_in 'public_body_category_title', :with => 'New Category en_GB' - fill_in 'public_body_category_description', :with => 'Test' - fill_in 'public_body_category_category_tag', :with => 'test' + fill_in 'public_body_category_title', with: 'New Category en_GB' + fill_in 'public_body_category_description', with: 'Test' + fill_in 'public_body_category_category_tag', with: 'test' click_button 'Create' expect(page).to have_content('successfully created') diff --git a/spec/integration/admin_public_body_edit_spec.rb b/spec/integration/admin_public_body_edit_spec.rb index 6c43b1238c..083fbe4966 100644 --- a/spec/integration/admin_public_body_edit_spec.rb +++ b/spec/integration/admin_public_body_edit_spec.rb @@ -8,11 +8,11 @@ confirm(:admin_user) @admin = login(:admin_user) - PublicBody.create(:name => 'New Quango', - :short_name => '', - :request_email => 'newquango@localhost', - :last_edit_editor => 'test', - :last_edit_comment => 'testing') + PublicBody.create(name: 'New Quango', + short_name: '', + request_email: 'newquango@localhost', + last_edit_editor: 'test', + last_edit_comment: 'testing') @body = PublicBody.find_by_name('New Quango') end @@ -20,7 +20,7 @@ it 'can edit the default locale' do using_session(@admin) do visit edit_admin_body_path(@body) - fill_in 'public_body_name', :with => 'New Quango EN' + fill_in 'public_body_name', with: 'New Quango EN' click_button 'Save' end pb = @body.reload @@ -31,7 +31,7 @@ expect(@body.find_translation_by_locale('fr')).to be_nil using_session(@admin) do visit edit_admin_body_path(@body) - fill_in 'public_body_translations_attributes_fr_name', :with => 'New Quango FR' + fill_in 'public_body_translations_attributes_fr_name', with: 'New Quango FR' click_button 'Save' end pb = @body.reload @@ -43,19 +43,19 @@ it 'can add a translation for multiple locales' do using_session(@admin) do visit edit_admin_body_path(@body) - fill_in 'public_body_name', :with => 'New Quango EN' + fill_in 'public_body_name', with: 'New Quango EN' click_button 'Save' # Add FR translation expect(@body.find_translation_by_locale('fr')).to be_nil visit edit_admin_body_path(@body) - fill_in 'public_body_translations_attributes_fr_name', :with => 'New Quango FR' + fill_in 'public_body_translations_attributes_fr_name', with: 'New Quango FR' click_button 'Save' # Add ES translation expect(@body.find_translation_by_locale('es')).to be_nil visit edit_admin_body_path(@body) - fill_in 'public_body_translations_attributes_es_name', :with => 'New Quango ES' + fill_in 'public_body_translations_attributes_es_name', with: 'New Quango ES' click_button 'Save' end pb = @body.reload diff --git a/spec/integration/admin_public_body_heading_edit_spec.rb b/spec/integration/admin_public_body_heading_edit_spec.rb index 288564e03c..ca3ea9bdff 100644 --- a/spec/integration/admin_public_body_heading_edit_spec.rb +++ b/spec/integration/admin_public_body_heading_edit_spec.rb @@ -13,7 +13,7 @@ it 'can edit the default locale' do using_session(@admin) do visit edit_admin_heading_path(@heading) - fill_in 'public_body_heading_name', :with => 'New Heading EN' + fill_in 'public_body_heading_name', with: 'New Heading EN' click_button 'Save' end @heading.reload @@ -24,7 +24,7 @@ expect(@heading.find_translation_by_locale('fr')).to be_nil using_session(@admin) do visit edit_admin_heading_path(@heading) - fill_in 'public_body_heading_translations_attributes_fr_name', :with => 'New Heading FR' + fill_in 'public_body_heading_translations_attributes_fr_name', with: 'New Heading FR' click_button 'Save' end @heading.reload @@ -38,13 +38,13 @@ # Add FR translation expect(@heading.find_translation_by_locale('fr')).to be_nil visit edit_admin_heading_path(@heading) - fill_in 'public_body_heading_translations_attributes_fr_name', :with => 'New Heading FR' + fill_in 'public_body_heading_translations_attributes_fr_name', with: 'New Heading FR' click_button 'Save' # Add ES translation expect(@heading.find_translation_by_locale('es')).to be_nil visit edit_admin_heading_path(@heading) - fill_in 'public_body_heading_translations_attributes_es_name', :with => 'New Heading ES' + fill_in 'public_body_heading_translations_attributes_es_name', with: 'New Heading ES' click_button 'Save' end diff --git a/spec/integration/admin_public_body_new_spec.rb b/spec/integration/admin_public_body_new_spec.rb index ba81ced430..5cab3df891 100644 --- a/spec/integration/admin_public_body_new_spec.rb +++ b/spec/integration/admin_public_body_new_spec.rb @@ -13,7 +13,7 @@ AlaveteliLocalization.set_locales('en_GB es', 'en_GB') using_session(@admin) do visit new_admin_body_path - fill_in 'public_body_name', :with => 'New Public Body en_GB' + fill_in 'public_body_name', with: 'New Public Body en_GB' click_button 'Create' expect(page).to have_content('successfully created') diff --git a/spec/integration/admin_spec.rb b/spec/integration/admin_spec.rb index d83a788460..fb741e8cb4 100644 --- a/spec/integration/admin_spec.rb +++ b/spec/integration/admin_spec.rb @@ -3,8 +3,8 @@ RSpec.describe "When administering the site" do let(:admin_user) { FactoryBot.create(:admin_user) } - let(:bob_smith_user) { FactoryBot.create(:user, :name => 'Bob Smith') } - let(:robin_user) { FactoryBot.create(:user, :name => 'Robin') } + let(:bob_smith_user) { FactoryBot.create(:user, name: 'Bob Smith') } + let(:robin_user) { FactoryBot.create(:user, name: 'Robin') } before do allow(AlaveteliConfiguration).to receive(:skip_admin_auth).and_return(false) @@ -52,7 +52,7 @@ using_session(@admin) do visit edit_admin_incoming_message_path(new_message) fill_in('Redeliver message to one or more other requests', - :with => info_request.url_title) + with: info_request.url_title) find_button('Redeliver to another request').click expect(current_path).to eq(admin_request_path(info_request)) end @@ -86,7 +86,7 @@ using_session(@admin) do visit edit_admin_incoming_message_path(new_message) fill_in('Redeliver message to one or more other requests', - :with => "#{info_request.url_title},#{second_request.url_title}") + with: "#{info_request.url_title},#{second_request.url_title}") find_button('Redeliver to another request').click expect(current_path).to eq(admin_request_path(second_request)) end @@ -117,8 +117,8 @@ it "shows a rejection reason for an incoming message from an invalid address" do info_request = FactoryBot.create(:info_request, - :allow_new_responses_from => 'authority_only', - :handle_rejected_responses => 'holding_pen') + allow_new_responses_from: 'authority_only', + handle_rejected_responses: 'holding_pen') receive_incoming_mail('incoming-request-plain.email', info_request.incoming_email, "frob@nowhere.com") @@ -130,8 +130,8 @@ it "guesses a misdirected request" do info_request = FactoryBot.create(:info_request, - :allow_new_responses_from => 'authority_only', - :handle_rejected_responses => 'holding_pen') + allow_new_responses_from: 'authority_only', + handle_rejected_responses: 'holding_pen') mail_to = "request-#{info_request.id}-asdfg@example.com" receive_incoming_mail('incoming-request-plain.email', mail_to) interesting_email = last_holding_pen_mail @@ -155,7 +155,7 @@ authority_email = request.public_body.request_email using_session(@admin) do - visit admin_request_path :id => request.id + visit admin_request_path id: request.id find_button('Generate URL').click url = confirm_url(PostRedirect.last.email_token) @@ -165,8 +165,8 @@ "them upload a response to this request." expect(page).to have_link(authority_email, - :href => "mailto:#{authority_email}") - expect(page).to have_link(url, :href => url) + href: "mailto:#{authority_email}") + expect(page).to have_link(url, href: url) expect(page).to have_content(message) end @@ -176,12 +176,12 @@ describe 'hide and notify' do - let(:user) { FactoryBot.create(:user, :name => "Awkward > Name") } - let(:request) { FactoryBot.create(:info_request, :user => user) } + let(:user) { FactoryBot.create(:user, name: "Awkward > Name") } + let(:request) { FactoryBot.create(:info_request, user: user) } it 'sets the prominence of the request to requester_only' do using_session(@admin) do - visit admin_request_path :id => request.id + visit admin_request_path id: request.id choose('reason_not_foi_not_foi') find_button('Hide request').click end @@ -192,7 +192,7 @@ it 'renders a message to confirm the requester has been notified' do using_session(@admin) do - visit admin_request_path :id => request.id + visit admin_request_path id: request.id choose('reason_not_foi_not_foi') find_button('Hide request').click expect(page). diff --git a/spec/integration/admin_user_controller_edit_spec.rb b/spec/integration/admin_user_controller_edit_spec.rb index a17dbcfb77..91a1cf7b98 100644 --- a/spec/integration/admin_user_controller_edit_spec.rb +++ b/spec/integration/admin_user_controller_edit_spec.rb @@ -9,8 +9,8 @@ @admin = login(:admin_user) @user = FactoryBot.create(:user, - :name => 'nasty user 123', - :ban_text => 'You are banned') + name: 'nasty user 123', + ban_text: 'You are banned') end context 'when a user is banned' do @@ -18,7 +18,7 @@ it 're-editing does not change their url_name' do using_session(@admin) do visit edit_admin_user_path(@user) - fill_in 'admin_user_ban_text', :with => 'You are really banned' + fill_in 'admin_user_ban_text', with: 'You are really banned' click_button 'Save' end diff --git a/spec/integration/alaveteli_dsl.rb b/spec/integration/alaveteli_dsl.rb index f873b4bc59..98d2999b34 100644 --- a/spec/integration/alaveteli_dsl.rb +++ b/spec/integration/alaveteli_dsl.rb @@ -11,14 +11,14 @@ def browse_pro_request(url_title) def create_request(public_body) visit select_authority_path within(:css, '#search_form') do - fill_in 'query', :with => public_body.name + fill_in 'query', with: public_body.name find_button('Search').click end within(:css, '.body_listing') do find_link('Make a request').click end - fill_in 'Summary', :with => "Why is your quango called Geraldine?" - fill_in 'Your request', :with => "This is a silly letter. It is too short to be interesting." + fill_in 'Summary', with: "Why is your quango called Geraldine?" + fill_in 'Your request', with: "This is a silly letter. It is too short to be interesting." find_button('Next Step: Preview your public request').click find_button('Send and publish request').click @@ -31,12 +31,12 @@ def create_request_and_user(public_body) using_session(without_login) do create_request(public_body) # Now log in as an unconfirmed user. - visit signin_path :token => get_last_post_redirect.token + visit signin_path token: get_last_post_redirect.token within '#signup_form' do - fill_in "Your name:", :with => user.name - fill_in "Your e-mail:", :with => user.email - fill_in "Password:", :with => 'jonespassword' - fill_in "Confirm password:", :with => 'jonespassword' + fill_in "Your name:", with: user.name + fill_in "Your e-mail:", with: user.email + fill_in "Password:", with: 'jonespassword' + fill_in "Confirm password:", with: 'jonespassword' click_button "Sign up" end expect(page).to have_content('Now check your email!') @@ -73,21 +73,21 @@ def add_body_to_pro_batch(public_body) def hide_incoming_message(incoming_message, prominence, reason) visit edit_admin_incoming_message_path(incoming_message) - select prominence, :from => 'Prominence' - fill_in 'Reason for prominence', :with => reason + select prominence, from: 'Prominence' + fill_in 'Reason for prominence', with: reason find_button('Save').click end def hide_outgoing_message(outgoing_message, prominence, reason) visit edit_admin_outgoing_message_path(outgoing_message) - select prominence, :from => 'Prominence' - fill_in 'Reason for prominence', :with => reason + select prominence, from: 'Prominence' + fill_in 'Reason for prominence', with: reason find_button('Save').click end def classify_request(request, chosen_option) - visit show_request_path :url_title => request.url_title, - :update_status => 1 + visit show_request_path url_title: request.url_title, + update_status: 1 choose(chosen_option) click_button('Submit status') end @@ -112,8 +112,8 @@ def login(user) alaveteli_session(u.id) do visit 'en/profile/sign_in' within '#signin_form' do - fill_in "Your e-mail:", :with => u.email - fill_in "Password:", :with => "jonespassword" + fill_in "Your e-mail:", with: u.email + fill_in "Password:", with: "jonespassword" click_button "Sign in" end end diff --git a/spec/integration/alaveteli_pro/admin_spec.rb b/spec/integration/alaveteli_pro/admin_spec.rb index 07fdd0c423..eac0bfd799 100644 --- a/spec/integration/alaveteli_pro/admin_spec.rb +++ b/spec/integration/alaveteli_pro/admin_spec.rb @@ -18,7 +18,7 @@ context 'when the user being administered is not a pro' do let!(:public_body) do FactoryBot.create(:public_body, - :name => 'example') + name: 'example') end before do @@ -30,7 +30,7 @@ post_redirect = create_request_and_user(public_body) using_pro_session(pro_admin_user_session) do - visit confirm_path(:email_token => post_redirect.email_token) + visit confirm_path(email_token: post_redirect.email_token) expect(current_url).to match(%r(/request/(.+))) current_url =~ %r(/request/(.+)) url_title = $1 diff --git a/spec/integration/alaveteli_pro/receive_response_spec.rb b/spec/integration/alaveteli_pro/receive_response_spec.rb index 52a5ce2b2e..17013327ee 100644 --- a/spec/integration/alaveteli_pro/receive_response_spec.rb +++ b/spec/integration/alaveteli_pro/receive_response_spec.rb @@ -7,7 +7,7 @@ let!(:pro_user_session) { login(pro_user) } let!(:info_request) do FactoryBot.create(:embargo_expiring_request, - :user => pro_user) + user: pro_user) end it "appears in the request list as having received a response" do diff --git a/spec/integration/alaveteli_pro/request_creation_spec.rb b/spec/integration/alaveteli_pro/request_creation_spec.rb index 0ae2a70b94..819a7107e7 100644 --- a/spec/integration/alaveteli_pro/request_creation_spec.rb +++ b/spec/integration/alaveteli_pro/request_creation_spec.rb @@ -3,7 +3,7 @@ RSpec.describe "creating requests in alaveteli_pro" do context "when writing a new request from scratch" do - let!(:public_body) { FactoryBot.create(:public_body, :name => 'example') } + let!(:public_body) { FactoryBot.create(:public_body, name: 'example') } let!(:pro_user) { FactoryBot.create(:pro_user) } let!(:pro_user_session) { login(pro_user) } @@ -74,9 +74,9 @@ it 'does not render HTML on the preview page' do public_body.update_attribute(:name, "Test's html authority") using_pro_session(pro_user_session) do - visit show_public_body_path(:url_name => public_body.url_name) + visit show_public_body_path(url_name: public_body.url_name) click_link('Make a Freedom of Information request to this authority') - fill_in 'Subject', :with => "HTML test" + fill_in 'Subject', with: "HTML test" click_button "Preview and send" expect(page).to have_content("Dear Test's html authority") diff --git a/spec/integration/change_email_address_spec.rb b/spec/integration/change_email_address_spec.rb index 4723f506dd..61ad1464af 100644 --- a/spec/integration/change_email_address_spec.rb +++ b/spec/integration/change_email_address_spec.rb @@ -8,9 +8,9 @@ using_session(login(user)) do visit signchangeemail_path - fill_in "signchangeemail_old_email", :with => user.email - fill_in "signchangeemail_password", :with => 'jonespassword' - fill_in "signchangeemail_new_email", :with => 'newbob@localhost' + fill_in "signchangeemail_old_email", with: user.email + fill_in "signchangeemail_password", with: 'jonespassword' + fill_in "signchangeemail_new_email", with: 'newbob@localhost' click_button "Change email on Alaveteli" expect(page).to have_content('Now check your email!') diff --git a/spec/integration/create_request_spec.rb b/spec/integration/create_request_spec.rb index 58bca3ffcb..6b456751d1 100644 --- a/spec/integration/create_request_spec.rb +++ b/spec/integration/create_request_spec.rb @@ -20,7 +20,7 @@ # Now log in as an admin user, then follow the confirmation link in the # email that was sent to the unconfirmed user using_session(admin_user_session) do - visit confirm_path(:email_token => post_redirect.email_token) + visit confirm_path(email_token: post_redirect.email_token) expect(current_url).to match(%r(/request/(.+))) current_url =~ %r(/request/(.+)) @@ -45,7 +45,7 @@ it 'does not HTML escape the apostrophe in the request form' do using_session(user_session) do - visit show_public_body_path(:url_name => public_body.url_name) + visit show_public_body_path(url_name: public_body.url_name) click_link('Make a Freedom of Information request to this authority') expect(page).not_to have_content "Test's Authority" @@ -55,7 +55,7 @@ it 'appends the user name' do using_session(user_session) do - visit show_public_body_path(:url_name => public_body.url_name) + visit show_public_body_path(url_name: public_body.url_name) click_link('Make a Freedom of Information request to this authority') expect(page.source). @@ -66,7 +66,7 @@ it 'handles other special characters correctly' do public_body.update_attribute(:name, 'Test ("special" chars)') using_session(user_session) do - visit show_public_body_path(:url_name => public_body.url_name) + visit show_public_body_path(url_name: public_body.url_name) click_link('Make a Freedom of Information request to this authority') expect(page).to have_content 'Dear Test ("special" chars)' @@ -76,9 +76,9 @@ it 'does not render authority name HTML on the preview page' do public_body.update_attribute(:name, "Test's html authority") using_session(user_session) do - visit show_public_body_path(:url_name => public_body.url_name) + visit show_public_body_path(url_name: public_body.url_name) click_link('Make a Freedom of Information request to this authority') - fill_in 'Summary', :with => "HTML test" + fill_in 'Summary', with: "HTML test" find_button('Next Step: Preview your public request').click expect(page).to have_content("Dear Test's html authority") diff --git a/spec/integration/download_request_spec.rb b/spec/integration/download_request_spec.rb index 0793a816b7..e737861187 100644 --- a/spec/integration/download_request_spec.rb +++ b/spec/integration/download_request_spec.rb @@ -150,8 +150,8 @@ def sleep_and_receive_mail(name, info_request) non_owner = login(FactoryBot.create(:user)) info_request = FactoryBot.create(:info_request) FactoryBot.create(:censor_rule, - :replacement => 'REDACTED', - :text => 'information') + replacement: 'REDACTED', + text: 'information') inspect_zip_download(non_owner, info_request) do |zip| expect(zip.count).to eq(1) @@ -164,8 +164,8 @@ def sleep_and_receive_mail(name, info_request) non_owner = login(FactoryBot.create(:user)) info_request = FactoryBot.create(:info_request_with_incoming) FactoryBot.create(:censor_rule, - :replacement => 'REDACTED', - :text => 'hereisthe') + replacement: 'REDACTED', + text: 'hereisthe') inspect_zip_download(non_owner, info_request) do |zip| expect(zip.count).to eq(1) @@ -177,9 +177,9 @@ def sleep_and_receive_mail(name, info_request) non_owner = login(FactoryBot.create(:user)) info_request = FactoryBot.create(:info_request_with_plain_incoming) FactoryBot.create(:censor_rule, - :text => 'First', - :replacement => 'REDACTED', - :info_request => info_request) + text: 'First', + replacement: 'REDACTED', + info_request: info_request) sleep_and_receive_mail('incoming-request-two-same-name.email', info_request) @@ -203,7 +203,7 @@ def sleep_and_receive_mail(name, info_request) it "should update the contents of the zipfile when the request changes" do info_request = FactoryBot.create(:info_request_with_incoming, - :title => 'Example Title') + title: 'Example Title') request_owner = login(info_request.user) inspect_zip_download(request_owner, info_request) do |zip| expect(zip.count).to eq(1) # just the message @@ -232,7 +232,7 @@ def sleep_and_receive_mail(name, info_request) before do @non_owner = login(FactoryBot.create(:user)) @info_request = FactoryBot.create(:info_request_with_incoming, - :prominence => 'requester_only') + prominence: 'requester_only') @request_owner = login(@info_request.user) @admin = login(FactoryBot.create(:admin_user)) end @@ -266,7 +266,7 @@ def sleep_and_receive_mail(name, info_request) it 'should not allow a download of the request by an admin only' do @non_owner = login(FactoryBot.create(:user)) @info_request = FactoryBot.create(:info_request_with_incoming, - :prominence => 'hidden') + prominence: 'hidden') @request_owner = login(@info_request.user) @admin = login(FactoryBot.create(:admin_user)) @@ -359,8 +359,8 @@ def sleep_and_receive_mail(name, info_request) using_session(admin) do visit edit_admin_outgoing_message_path info_request.outgoing_messages.first - select 'requester_only', :from => 'Prominence' - fill_in 'Reason for prominence', :with => 'boring' + select 'requester_only', from: 'Prominence' + fill_in 'Reason for prominence', with: 'boring' find_button('Save').click end @@ -396,8 +396,8 @@ def sleep_and_receive_mail(name, info_request) non_owner = login(FactoryBot.create(:user)) info_request = FactoryBot.create(:info_request) FactoryBot.create(:censor_rule, - :text => 'information', - :replacement => 'REDACTED') + text: 'information', + replacement: 'REDACTED') inspect_zip_download(non_owner, info_request) do |zip| expect(zip.count).to eq(1) @@ -409,8 +409,8 @@ def sleep_and_receive_mail(name, info_request) non_owner = login(FactoryBot.create(:user)) info_request = FactoryBot.create(:info_request_with_incoming) FactoryBot.create(:censor_rule, - :text => 'hereisthe', - :replacement => 'REDACTED') + text: 'hereisthe', + replacement: 'REDACTED') inspect_zip_download(non_owner, info_request) do |zip| expect(zip.count).to eq(1) @@ -422,9 +422,9 @@ def sleep_and_receive_mail(name, info_request) non_owner = login(FactoryBot.create(:user)) info_request = FactoryBot.create(:info_request_with_plain_incoming) FactoryBot.create(:censor_rule, - :text => 'First', - :replacement => 'REDACTED', - :info_request => info_request) + text: 'First', + replacement: 'REDACTED', + info_request: info_request) sleep_and_receive_mail('incoming-request-two-same-name.email', info_request) diff --git a/spec/integration/errors_spec.rb b/spec/integration/errors_spec.rb index 6fb651ac8c..bdc033fbbc 100644 --- a/spec/integration/errors_spec.rb +++ b/spec/integration/errors_spec.rb @@ -38,7 +38,7 @@ end it 'should render a 404 when given an invalid page parameter' do - get '/body/list/all', params: { :page => 'xoforvfmy' } + get '/body/list/all', params: { page: 'xoforvfmy' } expect(response).to render_template('general/exception_caught') expect(response.code).to eq('404') expect(response.body).to match("Sorry, we couldn't find that page") diff --git a/spec/integration/globalize_strip_attributes_spec.rb b/spec/integration/globalize_strip_attributes_spec.rb index 990b4c2509..0ae601214d 100644 --- a/spec/integration/globalize_strip_attributes_spec.rb +++ b/spec/integration/globalize_strip_attributes_spec.rb @@ -3,18 +3,18 @@ RSpec.describe 'globalize3 and strip_attributes' do it 'strips spaces from attributes in the default locale' do - body = FactoryBot.build(:public_body, :name => ' Trailing Spaces ') - body.translations_attributes = { :es => { :locale => 'es', - :name => ' El Body ' } } + body = FactoryBot.build(:public_body, name: ' Trailing Spaces ') + body.translations_attributes = { es: { locale: 'es', + name: ' El Body ' } } body.save! body.reload expect(body.name).to eq('Trailing Spaces') end it 'strips spaces from attributes in an alternative locale' do - body = FactoryBot.build(:public_body, :name => ' Trailing Spaces ') - body.translations_attributes = { :es => { :locale => 'es', - :name => ' El Body ' } } + body = FactoryBot.build(:public_body, name: ' Trailing Spaces ') + body.translations_attributes = { es: { locale: 'es', + name: ' El Body ' } } body.save! body.reload expect(body.name(:es)).to eq('El Body') diff --git a/spec/integration/incoming_mail_spec.rb b/spec/integration/incoming_mail_spec.rb index dac78dc215..42a93d2240 100644 --- a/spec/integration/incoming_mail_spec.rb +++ b/spec/integration/incoming_mail_spec.rb @@ -12,7 +12,7 @@ mail = deliveries[0] expect(mail.to).to eq([info_request.user.email]) expect(mail.body).to match(/You have a new response to the Freedom of Information request/) - visit show_request_path :url_title => info_request.url_title + visit show_request_path url_title: info_request.url_title expect(page).to have_content("No way!") end @@ -20,20 +20,20 @@ receive_incoming_mail('incoming-request-two-same-name.email', info_request.incoming_email) visit get_attachment_path( - :incoming_message_id => info_request.incoming_messages.first.id, - :id => info_request.id, - :part => 2, - :file_name => 'hello world.txt', - :skip_cache => 1) + incoming_message_id: info_request.incoming_messages.first.id, + id: info_request.id, + part: 2, + file_name: 'hello world.txt', + skip_cache: 1) expect(page.response_headers['Content-Type']).to eq("text/plain; charset=utf-8") expect(page).to have_content "Second hello" visit get_attachment_path( - :incoming_message_id => info_request.incoming_messages.first.id, - :id => info_request.id, - :part => 3, - :file_name => 'hello world.txt', - :skip_cache => 1) + incoming_message_id: info_request.incoming_messages.first.id, + id: info_request.id, + part: 3, + file_name: 'hello world.txt', + skip_cache: 1) expect(page.response_headers['Content-Type']).to eq("text/plain; charset=utf-8") expect(page).to have_content "First hello" end @@ -41,7 +41,7 @@ it "converts message body to UTF8" do receive_incoming_mail('iso8859_2_raw_email.email', info_request.incoming_email) - visit show_request_path :url_title => info_request.url_title + visit show_request_path url_title: info_request.url_title expect(page).to have_content "tënde" end @@ -49,11 +49,11 @@ receive_incoming_mail('incoming-request-two-same-name.email', info_request.incoming_email) visit get_attachment_as_html_path( - :incoming_message_id => info_request.incoming_messages.first.id, - :id => info_request.id, - :part => 2, - :file_name => 'hello world.txt.html', - :skip_cache => 1) + incoming_message_id: info_request.incoming_messages.first.id, + id: info_request.id, + part: 2, + file_name: 'hello world.txt.html', + skip_cache: 1) expect(page.response_headers['Content-Type']).to eq("text/html; charset=utf-8") expect(page).to have_content "Second hello" end @@ -62,11 +62,11 @@ receive_incoming_mail('incoming-request-pdf-attachment.email', info_request.incoming_email) visit get_attachment_as_html_path( - :incoming_message_id => info_request.incoming_messages.first.id, - :id => info_request.id, - :part => 2, - :file_name => 'fs 50379341.pdf.html', - :skip_cache => 1) + incoming_message_id: info_request.incoming_messages.first.id, + id: info_request.id, + part: 2, + file_name: 'fs 50379341.pdf.html', + skip_cache: 1) expect(page.response_headers['Content-Type']).to eq("text/html; charset=utf-8") expect(page).to have_content "Walberswick Parish Council" end @@ -90,11 +90,11 @@ # asking for an attachment by the wrong filename should result in redirecting # back to the incoming message, but shouldn't cause a reparse: visit get_attachment_as_html_path( - :incoming_message_id => incoming_message.id, - :id => info_request.id, - :part => 2, - :file_name => 'hello world.txt.baz.html', - :skip_cache => 1 + incoming_message_id: incoming_message.id, + id: info_request.id, + part: 2, + file_name: 'hello world.txt.baz.html', + skip_cache: 1 ) attachment = IncomingMessage. @@ -107,11 +107,11 @@ # ...nor should asking for it by its correct filename... visit get_attachment_as_html_path( - :incoming_message_id => incoming_message.id, - :id => info_request.id, - :part => 2, - :file_name => 'hello world.txt.html', - :skip_cache => 1 + incoming_message_id: incoming_message.id, + id: info_request.id, + part: 2, + file_name: 'hello world.txt.html', + skip_cache: 1 ) expect(page).not_to have_content "Third hello" @@ -126,11 +126,11 @@ ) expect(attachment.body).to match "Third hello" visit get_attachment_as_html_path( - :incoming_message_id => incoming_message.id, - :id => info_request.id, - :part => 2, - :file_name => 'hello world.txt.html', - :skip_cache => 1 + incoming_message_id: incoming_message.id, + id: info_request.id, + part: 2, + file_name: 'hello world.txt.html', + skip_cache: 1 ) expect(page).to have_content "Third hello" end @@ -139,11 +139,11 @@ receive_incoming_mail('incoming-request-attachment-unknown-extension.email', info_request.incoming_email) visit get_attachment_path( - :incoming_message_id => info_request.incoming_messages.first.id, - :id => info_request.id, - :part => 2, - :file_name => 'hello.qwglhm', - :skip_cache => 1 + incoming_message_id: info_request.incoming_messages.first.id, + id: info_request.id, + part: 2, + file_name: 'hello.qwglhm', + skip_cache: 1 ) expect(page.response_headers['Content-Type']).to eq("application/octet-stream; charset=utf-8") expect(page).to have_content "an unusual sort of file" diff --git a/spec/integration/localisation_spec.rb b/spec/integration/localisation_spec.rb index 54125c17c2..c228749051 100644 --- a/spec/integration/localisation_spec.rb +++ b/spec/integration/localisation_spec.rb @@ -9,7 +9,7 @@ it "should generate URLs that include the locale when using one that includes an underscore" do AlaveteliLocalization.set_locales('es en_GB', 'es') get '/en_GB' - expect(response.body).to match /href="\/en_GB\// + expect(response.body).to match(/href="\/en_GB\//) end it "returns a 404 error if passed the locale with a hyphen instead of an underscore", local_requests: false do @@ -20,27 +20,27 @@ it "should fall back to the language if the territory is unknown" do AlaveteliLocalization.set_locales('es en', 'en') get '/', headers: { 'HTTP_ACCEPT_LANGUAGE' => 'en_US' } - expect(response.body).to match /href="\/en\// - expect(response.body).not_to match /href="\/en_US\// + expect(response.body).to match(/href="\/en\//) + expect(response.body).not_to match(/href="\/en_US\//) end it 'falls back to the default if the requested locale is unavailable' do - get '/', params: { :locale => "unknown" } - expect(response.body).to match /href="\/en\// - expect(response.body).not_to match /href="\/unknown\// + get '/', params: { locale: "unknown" } + expect(response.body).to match(/href="\/en\//) + expect(response.body).not_to match(/href="\/unknown\//) end it "should generate URLs without a locale prepended when there's only one locale set" do AlaveteliLocalization.set_locales('en', 'en') get '/' - expect(response).not_to match /#{@home_link_regex}/ + expect(response).not_to match(/#{@home_link_regex}/) end context 'when handling public body requests' do before do AlaveteliLocalization.set_locales('es en', 'en') - body = FactoryBot.create(:public_body, :short_name => 'english_short') + body = FactoryBot.create(:public_body, short_name: 'english_short') AlaveteliLocalization.with_locale('es') do body.short_name = 'spanish_short' body.save! @@ -74,7 +74,7 @@ before do @default_lang_home_link = /href=".*\/en\// - @old_include_default_locale_in_urls = AlaveteliConfiguration::include_default_locale_in_urls + @old_include_default_locale_in_urls = AlaveteliConfiguration.include_default_locale_in_urls end after do @@ -90,8 +90,8 @@ it 'should generate URLs without a locale prepended' do get '/' - expect(response.body).to match /class="current-locale">English/ - expect(response.body).not_to match /#{@default_lang_home_link}/ + expect(response.body).to match(/class="current-locale">English/) + expect(response.body).not_to match(/#{@default_lang_home_link}/) end describe "when the default url contains an underscore" do @@ -99,15 +99,15 @@ it "generates URLs without a locale prepended" do AlaveteliLocalization.set_locales('en_GB es', 'en_GB') get '/' - expect(response.body).not_to match /href="\/en_GB\// + expect(response.body).not_to match(/href="\/en_GB\//) end end it 'should render the front page in the default language when no locale param is present and the session locale is not the default' do - get '/', headers: { :locale => 'es' } - expect(response.body).to match /class="current-locale">English/ + get '/', headers: { locale: 'es' } + expect(response.body).to match(/class="current-locale">English/) end end @@ -120,8 +120,8 @@ it 'should generate URLs with a locale prepended' do get '/' - expect(response.body).to match /class="current-locale">English/ - expect(response.body).to match /#{@default_lang_home_link}/ + expect(response.body).to match(/class="current-locale">English/) + expect(response.body).to match(/#{@default_lang_home_link}/) end end diff --git a/spec/integration/public_body_change_request_spec.rb b/spec/integration/public_body_change_request_spec.rb index 6b9e67fef4..3f6c74b540 100644 --- a/spec/integration/public_body_change_request_spec.rb +++ b/spec/integration/public_body_change_request_spec.rb @@ -11,12 +11,12 @@ describe 'when not logged in' do it "should not forget which public body you are updating during login" do - visit show_public_body_path(:url_name => public_body.url_name) + visit show_public_body_path(url_name: public_body.url_name) click_link("Ask us to update FOI email") - click_link ("sign in") + click_link("sign in") - fill_in :user_signin_email, :with => user.email - fill_in :user_signin_password, :with => "jonespassword" + fill_in :user_signin_email, with: user.email + fill_in :user_signin_password, with: "jonespassword" click_button "Sign in" expect(page).to have_content "Ask us to update the email address" diff --git a/spec/integration/reports_controller_spec.rb b/spec/integration/reports_controller_spec.rb index 51c2472f5e..959a306f40 100644 --- a/spec/integration/reports_controller_spec.rb +++ b/spec/integration/reports_controller_spec.rb @@ -6,24 +6,24 @@ describe 'reporting a comment' do let(:request) { FactoryBot.create(:info_request) } - let(:comment) { FactoryBot.create(:comment, :info_request => request) } + let(:comment) { FactoryBot.create(:comment, info_request: request) } let(:user) { FactoryBot.create(:user) } describe 'when not logged in' do it "should redirect to the login page" do - visit new_request_report_path(:request_id => request.url_title, - :comment_id => comment.id) + visit new_request_report_path(request_id: request.url_title, + comment_id: comment.id) expect(page).to have_content "create an account or sign in" end it "should not lose the comment_id post login" do - visit new_request_report_path(:request_id => request.url_title, - :comment_id => comment.id) + visit new_request_report_path(request_id: request.url_title, + comment_id: comment.id) - fill_in :user_signin_email, :with => user.email - fill_in :user_signin_password, :with => "jonespassword" + fill_in :user_signin_email, with: user.email + fill_in :user_signin_password, with: "jonespassword" click_button "Sign in" expect(page).to have_content "Report annotation on request" diff --git a/spec/integration/request_controller_spec.rb b/spec/integration/request_controller_spec.rb index d1c763b9bc..690298115e 100644 --- a/spec/integration/request_controller_spec.rb +++ b/spec/integration/request_controller_spec.rb @@ -51,19 +51,19 @@ describe 'FOI officer uploading a reponse' do let(:public_body) do - FactoryBot.create(:public_body, :request_email => "foi@example.com") + FactoryBot.create(:public_body, request_email: "foi@example.com") end - let(:officer) { FactoryBot.create(:user, :email => "officer@example.com") } - let(:user) { FactoryBot.create(:user, :name => "Awkward > Name") } - let(:request) { FactoryBot.create(:info_request, :user => user) } + let(:officer) { FactoryBot.create(:user, email: "officer@example.com") } + let(:user) { FactoryBot.create(:user, name: "Awkward > Name") } + let(:request) { FactoryBot.create(:info_request, user: user) } it 'should render a message confirming the response has been published' do message = "Thank you for responding to this FOI request! " \ "Your response has been published below, and a " \ "link to your response has been emailed to Awkward > Name." using_session(login(officer)) do - visit upload_response_path :url_title => request.url_title - fill_in(:body, :with => 'Additional information') + visit upload_response_path url_title: request.url_title + fill_in(:body, with: 'Additional information') click_button("Upload FOI response") expect(page).to have_content(message) end diff --git a/spec/integration/request_game_controller_spec.rb b/spec/integration/request_game_controller_spec.rb index 1020b1dc8e..e884a40618 100644 --- a/spec/integration/request_game_controller_spec.rb +++ b/spec/integration/request_game_controller_spec.rb @@ -9,7 +9,7 @@ it 'displays a thank you message on completion' do request = FactoryBot.create(:old_unclassified_request, - :title => "Awkward > Title") + title: "Awkward > Title") using_session(login(user)) do visit categorise_play_path click_link(request.title) @@ -22,7 +22,7 @@ "'#{request.title}'. There are some more requests below " \ "for you to classify." - expect(page).to have_link(request.title, :href => request_path(request)) + expect(page).to have_link(request.title, href: request_path(request)) expect(page).to have_content(message) end end diff --git a/spec/integration/search_request_spec.rb b/spec/integration/search_request_spec.rb index 9414ea8fcc..d5265a1b6e 100644 --- a/spec/integration/search_request_spec.rb +++ b/spec/integration/search_request_spec.rb @@ -9,7 +9,7 @@ end it "should not strip quotes from quoted query" do - get "/search", params: { :query => '"mouse stilton"' } + get "/search", params: { query: '"mouse stilton"' } follow_redirect! expect(response.body).to include(""mouse stilton"") end @@ -20,7 +20,7 @@ end it "should correctly execute simple search" do - get "/search", params: { :query => 'bob' } + get "/search", params: { query: 'bob' } follow_redirect! expect(response.body).to include("FOI requests") end @@ -31,7 +31,7 @@ user_session = login(user) using_session(user_session) do visit frontpage_path - fill_in "navigation_search_button", :with => 'test' + fill_in "navigation_search_button", with: 'test' click_button "Search" expect(page.body).to include(user.name) end @@ -60,8 +60,8 @@ it "should correctly filter searches for successful requests" do get "/search/requests", params: { - :query => "bob", - :latest_status => ['successful'] + query: "bob", + latest_status: ['successful'] } n = 2 # The number of *successful* requests that contain the word "bob" somewhere # in the email text. At present this is: @@ -72,14 +72,14 @@ it "should correctly filter searches for comments" do get "/search/requests", params: { - :query => "daftest", - :request_variety => ['comments'] + query: "daftest", + request_variety: ['comments'] } expect(response.body).to include("One FOI request found") get "/search/requests", params: { - :query => "daftest", - :request_variety => ['response', 'sent'] + query: "daftest", + request_variety: %w[response sent] } expect(response.body).to include("no results matching your query") end @@ -88,7 +88,7 @@ it 'should return JSON formatted results' do get '/feed/search/chicken.json' - response_data = JSON.parse(response.body, :symbolize_names => true) + response_data = JSON.parse(response.body, symbolize_names: true) expect(response.media_type).to eq('application/json') expect(response_data.size).to eql(1) @@ -100,7 +100,7 @@ it "should search for requests made to a tagged set of public authorities" do get "/search/requests", params: { - :query => "request_public_body_tag:popular_agency" + query: "request_public_body_tag:popular_agency" } # In the fixtures there are 2 public bodies with the popular_agency tag: # - geraldine_public_body diff --git a/spec/integration/send_user_message_spec.rb b/spec/integration/send_user_message_spec.rb index 2e66dfdf58..39caf845c1 100644 --- a/spec/integration/send_user_message_spec.rb +++ b/spec/integration/send_user_message_spec.rb @@ -4,14 +4,14 @@ RSpec.describe 'Sending a message to another user' do let(:sender) { FactoryBot.create(:user) } - let(:recipient) { FactoryBot.create(:user, :name => "Awkward > Name") } + let(:recipient) { FactoryBot.create(:user, name: "Awkward > Name") } it 'renders a notice to say the message was sent' do message = "Your message to Awkward > Name has been sent!" using_session(login(sender)) do visit contact_user_path url_name: recipient.url_name - fill_in 'contact_subject', :with => "This is a test" - fill_in 'contact_message', :with => "Hello, this is a test message" + fill_in 'contact_subject', with: "This is a test" + fill_in 'contact_message', with: "Hello, this is a test message" click_button('Send message') expect(page.body).to include(message) diff --git a/spec/integration/signin_spec.rb b/spec/integration/signin_spec.rb index 259363a7a2..ebd5dbf866 100644 --- a/spec/integration/signin_spec.rb +++ b/spec/integration/signin_spec.rb @@ -5,15 +5,15 @@ let(:user) { FactoryBot.create(:user) } def try_login(user, options = {}) - default_options = { :email => user.email, - :password => 'jonespassword' } + default_options = { email: user.email, + password: 'jonespassword' } options = default_options.merge(options) login_url = 'en/profile/sign_in' login_url += "?r=#{options[:redirect]}" if options[:redirect] visit login_url within '#signin_form' do - fill_in "Your e-mail:", :with => options[:email] - fill_in "Password:", :with => options[:password] + fill_in "Your e-mail:", with: options[:email] + fill_in "Password:", with: options[:password] click_button "Sign in" end end @@ -21,13 +21,13 @@ def try_login(user, options = {}) before { update_xapian_index } it "shows you an error if you get the password wrong" do - try_login(user, { :password => 'badpassword' }) + try_login(user, { password: 'badpassword' }) expect(page). to have_content('Either the email or password was not recognised') end it "shows you an error if you get the email wrong" do - try_login(user, { :email => 'wrong@localhost' }) + try_login(user, { email: 'wrong@localhost' }) expect(page). to have_content('Either the email or password was not recognised') end @@ -35,7 +35,7 @@ def try_login(user, options = {}) context 'when you give the right credentials' do it 'logs you in' do - try_login(user, { :redirect => '/list' }) + try_login(user, { redirect: '/list' }) expect(page). to have_content user.name end @@ -53,22 +53,22 @@ def try_login(user, options = {}) end it "it redirects to the redirect path" do - try_login(user, { :redirect => '/list' }) + try_login(user, { redirect: '/list' }) expect(page). to have_current_path '/list?post_redirect=1' end it 'does not redirect to another domain' do - try_login(user, { :redirect => 'http://bad.place.com/list' }) + try_login(user, { redirect: 'http://bad.place.com/list' }) expect(page). to have_current_path('/list?post_redirect=1') end context 'if an account is not confirmed' do - let(:user) { FactoryBot.create(:user, :email_confirmed => false) } + let(:user) { FactoryBot.create(:user, email_confirmed: false) } it "sends a confirmation email_token, logs you in and redirects you" do - try_login(user, { :redirect => '/list' }) + try_login(user, { redirect: '/list' }) expect(page).to have_content 'Now check your email!' # check confirmation URL works @@ -81,7 +81,7 @@ def try_login(user, options = {}) let(:admin_user) { FactoryBot.create(:admin_user) } it "should keep you logged in if you click a confirmation link" do - try_login(user, { :redirect => '/list' }) + try_login(user, { redirect: '/list' }) expect(page).to have_content 'Now check your email!' # Log in as an admin diff --git a/spec/integration/track_alerts_spec.rb b/spec/integration/track_alerts_spec.rb index 2b31875948..8f843596e7 100644 --- a/spec/integration/track_alerts_spec.rb +++ b/spec/integration/track_alerts_spec.rb @@ -14,7 +14,7 @@ it "should send alerts" do info_request = FactoryBot.create(:info_request) - user = FactoryBot.create(:user, :last_daily_track_email => 3.days.ago) + user = FactoryBot.create(:user, last_daily_track_email: 3.days.ago) user_session = login(user) using_session(user_session) do visit "track/request/#{info_request.url_title}" @@ -24,7 +24,7 @@ other_user_session = login(other_user) using_session(other_user_session) do visit "en/annotate/request/#{info_request.url_title}" - fill_in "comment[body]", :with => 'test comment' + fill_in "comment[body]", with: 'test comment' click_button 'Preview your annotation' click_button 'Post annotation' end @@ -65,18 +65,18 @@ it "should send localised alerts" do info_request = FactoryBot.create(:info_request) - user = FactoryBot.create(:user, :last_daily_track_email => 3.days.ago, - :locale => 'es') + user = FactoryBot.create(:user, last_daily_track_email: 3.days.ago, + locale: 'es') user_session = login(user) using_session(user_session) do visit "es/track/request/#{info_request.url_title}" end - other_user = FactoryBot.create(:user, :locale => 'en') + other_user = FactoryBot.create(:user, locale: 'en') other_user_session = login(other_user) using_session(other_user_session) do visit "annotate/request/#{info_request.url_title}" - fill_in "comment[body]", :with => 'test comment' + fill_in "comment[body]", with: 'test comment' click_button 'Preview your annotation' click_button 'Post annotation' end diff --git a/spec/integration/user_profile_updates_spec.rb b/spec/integration/user_profile_updates_spec.rb index 4ba7568622..c0d4382009 100644 --- a/spec/integration/user_profile_updates_spec.rb +++ b/spec/integration/user_profile_updates_spec.rb @@ -15,7 +15,7 @@ "profile.\nNext... You can " \ "upload a profile photograph too." visit edit_profile_about_me_path - fill_in :user_about_me, :with => "I am a researcher" + fill_in :user_about_me, with: "I am a researcher" click_button "Save" expect(page).to have_content(msg) @@ -27,14 +27,14 @@ context "with profile picture set" do before do - user.create_profile_photo!(:data => load_file_fixture('parrot.png')) + user.create_profile_photo!(data: load_file_fixture('parrot.png')) end it "displays a thank you message without upload photo nudge" do using_session(login(user)) do msg = "You have now changed the text about you on your profile." visit edit_profile_about_me_path - fill_in :user_about_me, :with => "I am a researcher" + fill_in :user_about_me, with: "I am a researcher" click_button "Save" expect(page).to have_content(msg) @@ -59,14 +59,14 @@ # post the form to work around the Next button being drawn # by JavaScript profile_photo = ProfilePhoto. - create(:data => load_file_fixture("parrot.png"), - :user => user) + create(data: load_file_fixture("parrot.png"), + user: user) page.driver.post set_profile_photo_path, - :id => user.id, - :file => photo_file, - :submitted_crop_profile_photo => 1, - :draft_profile_photo_id => profile_photo.id + id: user.id, + file: photo_file, + submitted_crop_profile_photo: 1, + draft_profile_photo_id: profile_photo.id visit page.driver.response.location expect(page).to have_content(msg) diff --git a/spec/integration/view_request_spec.rb b/spec/integration/view_request_spec.rb index cc96a3bb91..350f1db628 100644 --- a/spec/integration/view_request_spec.rb +++ b/spec/integration/view_request_spec.rb @@ -20,9 +20,9 @@ browse_request("#{@info_request.url_title}?unfold=1") expected_link = "/en/request/#{@info_request.url_title}.json?unfold=1" expect(page).to have_css("head link[href='#{expected_link}']", - :visible => false) + visible: false) expect(page).not_to have_css("head link[href='#{expected_link}.json']", - :visible => false) + visible: false) end end diff --git a/spec/integration/xapian_search_highlighting_spec.rb b/spec/integration/xapian_search_highlighting_spec.rb index 90d9d16fd4..76bc505735 100644 --- a/spec/integration/xapian_search_highlighting_spec.rb +++ b/spec/integration/xapian_search_highlighting_spec.rb @@ -10,24 +10,24 @@ it 'ignores stopwords' do phrase = 'department of humpadinking' - search = ActsAsXapian::Search.new([PublicBody], phrase, :limit => 1) - matches = search.words_to_highlight(:regex => true) + search = ActsAsXapian::Search.new([PublicBody], phrase, limit: 1) + matches = search.words_to_highlight(regex: true) expect(highlight_matches(phrase, matches)).to eq('department of humpadinking') end it 'ignores case' do search_phrase = 'department of humpadinking' - search = ActsAsXapian::Search.new([PublicBody], search_phrase, :limit => 1) - matches = search.words_to_highlight(:regex => true) + search = ActsAsXapian::Search.new([PublicBody], search_phrase, limit: 1) + matches = search.words_to_highlight(regex: true) expect(highlight_matches('Department of Humpadinking', matches)).to eq('Department of Humpadinking') end it 'highlights stemmed words' do phrase = 'department' - search = ActsAsXapian::Search.new([PublicBody], phrase, :limit => 1) - matches = search.words_to_highlight(:regex => true) + search = ActsAsXapian::Search.new([PublicBody], phrase, limit: 1) + matches = search.words_to_highlight(regex: true) - expect(search.words_to_highlight(:regex => false)).to eq(['depart']) + expect(search.words_to_highlight(regex: false)).to eq(['depart']) expect(highlight_matches(phrase, matches)).to eq('department') end @@ -35,8 +35,8 @@ # Stemming returns 'bore' as the word to highlight which can't be # matched in the original phrase. phrase = 'boring' - search = ActsAsXapian::Search.new([PublicBody], phrase, :limit => 1) - matches = search.words_to_highlight(:regex => true, :include_original => true) + search = ActsAsXapian::Search.new([PublicBody], phrase, limit: 1) + matches = search.words_to_highlight(regex: true, include_original: true) expect(highlight_matches(phrase, matches)).to eq('boring') end @@ -44,8 +44,8 @@ it 'handles macrons correctly' do phrase = 'Māori' - search = ActsAsXapian::Search.new([PublicBody], phrase, :limit => 1) - matches = search.words_to_highlight(:regex => true, :include_original => true) + search = ActsAsXapian::Search.new([PublicBody], phrase, limit: 1) + matches = search.words_to_highlight(regex: true, include_original: true) expect(highlight_matches(phrase, matches)).to eq('Māori') end diff --git a/spec/jobs/info_request_expire_job_spec.rb b/spec/jobs/info_request_expire_job_spec.rb new file mode 100644 index 0000000000..ab875aafa4 --- /dev/null +++ b/spec/jobs/info_request_expire_job_spec.rb @@ -0,0 +1,51 @@ +require 'spec_helper' + +RSpec.describe InfoRequestExpireJob, type: :job do + let(:args) { [] } + subject(:perform) { described_class.new.perform(*args) } + + let(:request_1) { FactoryBot.build(:info_request) } + let(:request_2) { FactoryBot.build(:info_request) } + + context 'when called with a request' do + let(:args) { [request_1] } + + it 'calls expire on the request' do + expect(request_1).to receive(:expire) + perform + end + end + + context 'when called with an object with a info_requests association' do + let(:user) do + FactoryBot.build(:user, info_requests: [request_1, request_2]) + end + + let(:args) { [user, :info_requests] } + + it 'calls expire on the associated requests' do + association = double(klass: InfoRequest) + allow(user).to receive(:association).with(:info_requests). + and_return(association) + allow(association).to receive_message_chain(:reader, :find_each). + and_yield(request_1).and_yield(request_2) + + expect(request_1).to receive(:expire) + expect(request_2).to receive(:expire) + perform + end + end + + context 'when called with the InfoRequest class' do + let(:args) { [InfoRequest, :all] } + + it 'calls expire on the all requests' do + allow(InfoRequest).to receive_message_chain(:all, :find_each). + and_yield(request_1).and_yield(request_2) + + expect(request_1).to receive(:expire) + expect(request_2).to receive(:expire) + perform + end + end +end diff --git a/spec/lib/acts_as_xapian_spec.rb b/spec/lib/acts_as_xapian_spec.rb index a061574d59..e7496d9182 100644 --- a/spec/lib/acts_as_xapian_spec.rb +++ b/spec/lib/acts_as_xapian_spec.rb @@ -7,7 +7,7 @@ describe '.update_index' do it 'processes jobs that were queued after a job that errors' do - job1, job2 = Array.new(2) do |i| + job1, job2 = Array.new(2) do |_i| body = FactoryBot.create(:public_body) body.xapian_mark_needs_index ActsAsXapian::ActsAsXapianJob. @@ -179,52 +179,52 @@ end before do - @alice = FactoryBot.create(:public_body, :name => 'alice') + @alice = FactoryBot.create(:public_body, name: 'alice') update_xapian_index end it "should return a list of words used in the search" do - s = ActsAsXapian::Search.new([PublicBody], "albatross words", :limit => 100) - expect(s.words_to_highlight).to eq(["albatross", "word"]) + s = ActsAsXapian::Search.new([PublicBody], "albatross words", limit: 100) + expect(s.words_to_highlight).to eq(%w[albatross word]) end it "should remove any operators" do - s = ActsAsXapian::Search.new([PublicBody], "albatross words tag:mice", :limit => 100) - expect(s.words_to_highlight).to eq(["albatross", "word"]) + s = ActsAsXapian::Search.new([PublicBody], "albatross words tag:mice", limit: 100) + expect(s.words_to_highlight).to eq(%w[albatross word]) end it "should separate punctuation" do - s = ActsAsXapian::Search.new([PublicBody], "The doctor's patient", :limit => 100) - expect(s.words_to_highlight).to eq(["the", "doctor", "patient"].sort) + s = ActsAsXapian::Search.new([PublicBody], "The doctor's patient", limit: 100) + expect(s.words_to_highlight).to eq(%w[the doctor patient].sort) end it "should handle non-ascii characters" do - s = ActsAsXapian::Search.new([PublicBody], "adatigénylés words tag:mice", :limit => 100) - expect(s.words_to_highlight).to eq(["adatigénylé", "word"]) + s = ActsAsXapian::Search.new([PublicBody], "adatigénylés words tag:mice", limit: 100) + expect(s.words_to_highlight).to eq(%w[adatigénylé word]) end it "should ignore stopwords" do - s = ActsAsXapian::Search.new([PublicBody], "department of humpadinking", :limit => 100) + s = ActsAsXapian::Search.new([PublicBody], "department of humpadinking", limit: 100) expect(s.words_to_highlight).not_to include('of') end it "uses stemming" do - s = ActsAsXapian::Search.new([PublicBody], 'department of humpadinking', :limit => 100) - expect(s.words_to_highlight).to eq(["depart", "humpadink"]) + s = ActsAsXapian::Search.new([PublicBody], 'department of humpadinking', limit: 100) + expect(s.words_to_highlight).to eq(%w[depart humpadink]) end it "doesn't stem proper nouns" do - s = ActsAsXapian::Search.new([PublicBody], 'department of Humpadinking', :limit => 1) - expect(s.words_to_highlight).to eq(["depart", "humpadinking"]) + s = ActsAsXapian::Search.new([PublicBody], 'department of Humpadinking', limit: 1) + expect(s.words_to_highlight).to eq(%w[depart humpadinking]) end it "includes the original search terms if requested" do - s = ActsAsXapian::Search.new([PublicBody], 'boring', :limit => 1) - expect(s.words_to_highlight(:include_original => true)).to eq(['bore', 'boring']) + s = ActsAsXapian::Search.new([PublicBody], 'boring', limit: 1) + expect(s.words_to_highlight(include_original: true)).to eq(%w[bore boring]) end it "does not return duplicate terms" do - s = ActsAsXapian::Search.new([PublicBody], 'boring boring', :limit => 1) + s = ActsAsXapian::Search.new([PublicBody], 'boring boring', limit: 1) expect(s.words_to_highlight).to eq(['bore']) end @@ -232,14 +232,14 @@ it 'wraps each words in a regex that matches the full word' do expected = [/\b(albatross)\b/iu] - s = ActsAsXapian::Search.new([PublicBody], 'Albatross', :limit => 1) - expect(s.words_to_highlight(:regex => true)).to eq(expected) + s = ActsAsXapian::Search.new([PublicBody], 'Albatross', limit: 1) + expect(s.words_to_highlight(regex: true)).to eq(expected) end it 'wraps each stem in a regex' do expected = [/\b(depart)\w*\b/iu] - s = ActsAsXapian::Search.new([PublicBody], 'department', :limit => 1) - expect(s.words_to_highlight(:regex => true)).to eq(expected) + s = ActsAsXapian::Search.new([PublicBody], 'department', limit: 1) + expect(s.words_to_highlight(regex: true)).to eq(expected) end end @@ -253,19 +253,19 @@ end before do - @alice = FactoryBot.create(:public_body, :name => 'alice') - @bob = FactoryBot.create(:public_body, :name => 'bôbby') + @alice = FactoryBot.create(:public_body, name: 'alice') + @bob = FactoryBot.create(:public_body, name: 'bôbby') update_xapian_index end it 'returns a UTF-8 encoded string' do - s = ActsAsXapian::Search.new([PublicBody], "alece", :limit => 100) + s = ActsAsXapian::Search.new([PublicBody], "alece", limit: 100) expect(s.spelling_correction).to eq("alice") expect(s.spelling_correction.encoding.to_s).to eq('UTF-8') end it 'handles non-ASCII characters' do - s = ActsAsXapian::Search.new([PublicBody], "bobby", :limit => 100) + s = ActsAsXapian::Search.new([PublicBody], "bobby", limit: 100) expect(s.spelling_correction).to eq("bôbby") end diff --git a/spec/lib/alaveteli_localization_spec.rb b/spec/lib/alaveteli_localization_spec.rb index a259af165b..58173bb732 100644 --- a/spec/lib/alaveteli_localization_spec.rb +++ b/spec/lib/alaveteli_localization_spec.rb @@ -148,7 +148,7 @@ it 'handles being passed hyphenated strings as available_locales' do AlaveteliLocalization.set_locales('en-GB nl-BE es', :es) expect(AlaveteliLocalization.available_locales). - to eq(['en_GB', 'nl_BE', 'es']) + to eq(%w[en_GB nl_BE es]) end end @@ -265,7 +265,7 @@ it 'returns an array of available locales' do AlaveteliLocalization.set_locales('en_GB es', 'en_GB') - expect(AlaveteliLocalization.available_locales).to eq(['en_GB', 'es']) + expect(AlaveteliLocalization.available_locales).to eq(%w[en_GB es]) end end diff --git a/spec/lib/alaveteli_pro/metrics_report_spec.rb b/spec/lib/alaveteli_pro/metrics_report_spec.rb index aa39a0c0b3..7d07514455 100644 --- a/spec/lib/alaveteli_pro/metrics_report_spec.rb +++ b/spec/lib/alaveteli_pro/metrics_report_spec.rb @@ -149,7 +149,7 @@ subscription = Stripe::Subscription.create(customer: customer, plan: pro_plan.id) - # note - in later API versions, at_period_end is no longer + # NOTE: - in later API versions, at_period_end is no longer # available for delete so we'd have to call something like # this instead: # Stripe::Subscription.update(subscription.id, @@ -160,7 +160,7 @@ let!(:past_due_sub) do subscription = Stripe::Subscription.create(customer: customer, - plan: pro_plan.id,) + plan: pro_plan.id) StripeMock.mark_subscription_as_past_due(subscription) subscription end @@ -240,7 +240,7 @@ it 'returns the subscription ids for cancelled users' do expect(subject[:canceled_users][:subs]). - to eq(['su_00000000000000', 'su_00000000000000']) + to eq(%w[su_00000000000000 su_00000000000000]) end end end diff --git a/spec/lib/alaveteli_pro/post_redirect_handler_spec.rb b/spec/lib/alaveteli_pro/post_redirect_handler_spec.rb index d8bd6189e3..397685f083 100644 --- a/spec/lib/alaveteli_pro/post_redirect_handler_spec.rb +++ b/spec/lib/alaveteli_pro/post_redirect_handler_spec.rb @@ -28,7 +28,7 @@ it "overrides the uri" do expect( controller.override_post_redirect_for_pro(uri, post_redirect, user) - ).to match /#{new_alaveteli_pro_info_request_path}\?draft_id=\d+/ + ).to match(/#{new_alaveteli_pro_info_request_path}\?draft_id=\d+/) end end diff --git a/spec/lib/alaveteli_rate_limiter/backends/pstore_database_spec.rb b/spec/lib/alaveteli_rate_limiter/backends/pstore_database_spec.rb index 0347a7fb15..b24445ca9f 100644 --- a/spec/lib/alaveteli_rate_limiter/backends/pstore_database_spec.rb +++ b/spec/lib/alaveteli_rate_limiter/backends/pstore_database_spec.rb @@ -16,13 +16,13 @@ it 'initializes a PStore at the given path' do path = Pathname.new("#{ Rails.root }/tmp/custom_database.pstore") - subject = described_class.new(:path => path) + subject = described_class.new(path: path) expect(subject.pstore.path).to eq(path) end it 'converts a string path to a pathname' do path = "#{ Rails.root }/tmp/custom_database.pstore" - subject = described_class.new(:path => path) + subject = described_class.new(path: path) expect(subject.pstore.path).to eq(Pathname.new(path)) end @@ -31,7 +31,7 @@ describe '#get' do it 'returns the values for the key' do - subject = described_class.new(:path => test_path) + subject = described_class.new(path: test_path) expected = [Time.zone.parse('2016-10-21'), Time.zone.parse('2016-10-21'), @@ -43,7 +43,7 @@ end it 'only includes values recorded for the given key' do - subject = described_class.new(:path => test_path) + subject = described_class.new(path: test_path) expected = [Time.zone.parse('2016-10-21'), Time.zone.parse('2016-10-21'), @@ -62,13 +62,13 @@ describe '#set' do it 'sets a new record for the given keys' do - subject = described_class.new(:path => test_path) + subject = described_class.new(path: test_path) subject.set('key', []) expect(subject.get('key')).to eq([]) end it 'overrides the records for the given keys' do - subject = described_class.new(:path => test_path) + subject = described_class.new(path: test_path) subject.record('key') subject.record('key') @@ -84,7 +84,7 @@ describe '#record' do it 'records an event for a given IP and event' do - subject = described_class.new(:path => test_path) + subject = described_class.new(path: test_path) time = Time.zone.now.to_datetime travel_to(time) do @@ -98,14 +98,14 @@ describe '#==' do it 'is equal if the pstore paths are the same' do - subject = described_class.new(:path => test_path) + subject = described_class.new(path: test_path) expect(subject).to eq(subject.dup) end it 'is not equal if the pstore paths are different' do - subject = described_class.new(:path => test_path) + subject = described_class.new(path: test_path) path = "#{ Rails.root }/tmp/custom_database.pstore" - expect(subject).not_to eq(described_class.new(:path => path)) + expect(subject).not_to eq(described_class.new(path: path)) end end @@ -113,14 +113,14 @@ describe '#destroy' do it 'destroys the pstore' do - subject = described_class.new(:path => test_path) + subject = described_class.new(path: test_path) subject.set('1', '2') subject.destroy expect(File.exist?(test_path)).to eq(false) end it 'does not attempt to destroy the pstore if it does not yet exist' do - subject = described_class.new(:path => test_path) + subject = described_class.new(path: test_path) expect { subject.destroy }.not_to raise_error end diff --git a/spec/lib/alaveteli_rate_limiter/ip_rate_limiter/defaults_spec.rb b/spec/lib/alaveteli_rate_limiter/ip_rate_limiter/defaults_spec.rb index dd8cb3d21b..114b3ee91c 100644 --- a/spec/lib/alaveteli_rate_limiter/ip_rate_limiter/defaults_spec.rb +++ b/spec/lib/alaveteli_rate_limiter/ip_rate_limiter/defaults_spec.rb @@ -10,14 +10,14 @@ end it 'sets the whitelist if the option is nil' do - subject = described_class.new(:whitelist => nil) + subject = described_class.new(whitelist: nil) expect(subject.whitelist). to eq(AlaveteliRateLimiter::IPRateLimiter::Whitelist.new) end it 'sets the custom whitelist' do whitelist = double - subject = described_class.new(:whitelist => whitelist) + subject = described_class.new(whitelist: whitelist) expect(subject.whitelist).to eq(whitelist) end @@ -26,13 +26,13 @@ end it 'sets the event_rules if the option is nil' do - subject = described_class.new(:event_rules => nil) + subject = described_class.new(event_rules: nil) expect(subject.event_rules).to eq(described_class::EVENT_RULES) end it 'sets the custom event_rules' do event_rules = double - subject = described_class.new(:event_rules => event_rules) + subject = described_class.new(event_rules: event_rules) expect(subject.event_rules).to eq(event_rules) end @@ -78,7 +78,7 @@ describe '#==' do it 'is equal if its attributes are identical' do - opts = { :whitelist => double } + opts = { whitelist: double } subject = described_class.new(opts) expect(subject).to eq(subject.dup) end @@ -86,7 +86,7 @@ it 'is not equal if any of the attributes vary' do whitelist = AlaveteliRateLimiter::IPRateLimiter::Whitelist. new(%w(127.0.0.1 0.0.0.1)) - subject2 = described_class.new(:whitelist => whitelist) + subject2 = described_class.new(whitelist: whitelist) expect(subject).not_to eq(subject2) end diff --git a/spec/lib/alaveteli_rate_limiter/ip_rate_limiter_spec.rb b/spec/lib/alaveteli_rate_limiter/ip_rate_limiter_spec.rb index 83dc81fa34..0b00382fac 100644 --- a/spec/lib/alaveteli_rate_limiter/ip_rate_limiter_spec.rb +++ b/spec/lib/alaveteli_rate_limiter/ip_rate_limiter_spec.rb @@ -17,10 +17,10 @@ whitelist = double defaults = AlaveteliRateLimiter::IPRateLimiter::Defaults. - new(:whitelist => whitelist) + new(whitelist: whitelist) - described_class.set_defaults do |defaults| - defaults.whitelist = whitelist + described_class.set_defaults do |d| + d.whitelist = whitelist end expect(described_class.defaults).to eq(defaults) @@ -41,14 +41,14 @@ end it 'looks up a Symbol rule from the configured defaults' do - rule_attrs = { :count => 3, :window => { :value => 1, :unit => :hour } } + rule_attrs = { count: 3, window: { value: 1, unit: :hour } } described_class.set_defaults do |defaults| - defaults.event_rules = { :signup => rule_attrs } + defaults.event_rules = { signup: rule_attrs } end rule = - AlaveteliRateLimiter::Rule.from_hash(rule_attrs.merge(:name => :signup)) + AlaveteliRateLimiter::Rule.from_hash(rule_attrs.merge(name: :signup)) expect(described_class.new(:signup).rule).to eq(rule) end @@ -68,14 +68,14 @@ new(Rails.root + "tmp/#{ subject.rule.name }_ip_rate_limiter.pstore") expected = - AlaveteliRateLimiter::Backends::PStoreDatabase.new(:path => path) + AlaveteliRateLimiter::Backends::PStoreDatabase.new(path: path) expect(subject.backend).to eq(expected) end it 'allows a custom backend' do backend = double - subject = described_class.new(:signup, :backend => backend) + subject = described_class.new(:signup, backend: backend) expect(subject.backend).to eq(backend) end @@ -86,7 +86,7 @@ it 'allows a custom whitelist' do whitelist = double - subject = described_class.new(:signup, :whitelist => whitelist) + subject = described_class.new(:signup, whitelist: whitelist) expect(subject.whitelist).to eq(whitelist) end @@ -105,7 +105,7 @@ it 'returns the whitelist attribute' do whitelist = double - subject = described_class.new(:signup, :whitelist => whitelist) + subject = described_class.new(:signup, whitelist: whitelist) expect(subject.whitelist).to eq(whitelist) end @@ -115,7 +115,7 @@ it 'returns the backend attribute' do backend = double - subject = described_class.new(:signup, :backend => backend) + subject = described_class.new(:signup, backend: backend) expect(subject.backend).to eq(backend) end @@ -128,7 +128,7 @@ backend = double records = [10.days.ago, 1.day.ago].map(&:to_datetime) allow(backend).to receive(:get).with(ip).and_return(records) - subject = described_class.new(:signup, :backend => backend) + subject = described_class.new(:signup, backend: backend) expect(subject.records(ip)).to eq(records) end @@ -138,21 +138,21 @@ it 'records an event for the IP in the backend' do backend = double - subject = described_class.new(:signup, :backend => backend) + subject = described_class.new(:signup, backend: backend) expect(backend).to receive(:record).with('127.0.0.1') subject.record('127.0.0.1') end it 'converts an IPAddr to a String key' do backend = double - subject = described_class.new(:signup, :backend => backend) + subject = described_class.new(:signup, backend: backend) expect(backend).to receive(:record).with('127.0.0.1') subject.record(IPAddr.new('127.0.0.1')) end it 'cleans a poorly formatted IP' do backend = double - subject = described_class.new(:signup, :backend => backend) + subject = described_class.new(:signup, backend: backend) expect(backend).to receive(:record).with('127.0.0.1') subject.record(" 127.0.0.1\n") end @@ -167,9 +167,9 @@ describe '#record!' do it 'purges old records before recording the new event' do - attrs = { :name => :test, - :count => 20, - :window => { :value => 1, :unit => :day } } + attrs = { name: :test, + count: 20, + window: { value: 1, unit: :day } } rule = AlaveteliRateLimiter::Rule.from_hash(attrs) @@ -178,10 +178,10 @@ new(Rails.root + "tmp/#{ rule.name }_ip_rate_limiter.pstore") backend = - AlaveteliRateLimiter::Backends::PStoreDatabase.new(:path => path) + AlaveteliRateLimiter::Backends::PStoreDatabase.new(path: path) - subject = described_class.new(rule, :backend => backend) + subject = described_class.new(rule, backend: backend) ip = '127.0.0.1' @@ -206,7 +206,7 @@ it 'returns false if the IP is in the whitelist' do whitelist = AlaveteliRateLimiter::IPRateLimiter::Whitelist.new(%(0.0.0.0)) - subject = described_class.new(:signup, :whitelist => whitelist) + subject = described_class.new(:signup, whitelist: whitelist) expect(subject.limit?('0.0.0.0')).to eq(false) end diff --git a/spec/lib/alaveteli_rate_limiter/rule_spec.rb b/spec/lib/alaveteli_rate_limiter/rule_spec.rb index 8368b794bc..6e7535e332 100644 --- a/spec/lib/alaveteli_rate_limiter/rule_spec.rb +++ b/spec/lib/alaveteli_rate_limiter/rule_spec.rb @@ -5,9 +5,9 @@ describe '.from_hash' do it 'constructs a Rule with associated Window from a Hash' do - attrs = { :name => :test, - :count => 2, - :window => { :value => 1, :unit => :hour } } + attrs = { name: :test, + count: 2, + window: { value: 1, unit: :hour } } window = AlaveteliRateLimiter::Window.new(1, :hour) expected = described_class.new(:test, 2, window) expect(described_class.from_hash(attrs)).to eq(expected) @@ -18,22 +18,22 @@ end it 'requires a :count key' do - expect { described_class.from_hash(:name => :test) }. + expect { described_class.from_hash(name: :test) }. to raise_error(KeyError) end it 'requires a :window key' do - expect { described_class.from_hash(:name => :test, :count => 1) }. + expect { described_class.from_hash(name: :test, count: 1) }. to raise_error(KeyError) end it 'requires a :window hash with a :value key' do - attrs = { :name => :test, :count => 1, :window => { :unit => :hour } } + attrs = { name: :test, count: 1, window: { unit: :hour } } expect { described_class.from_hash(attrs) }.to raise_error(KeyError) end it 'requires a :window hash with a :unit key' do - attrs = { :name => :test, :count => 1, :window => { :value => 1 } } + attrs = { name: :test, count: 1, window: { value: 1 } } expect { described_class.from_hash(attrs) }.to raise_error(KeyError) end @@ -72,35 +72,35 @@ it 'returns true if the given records are over the limit' do records = [10, 5, 1].map { |i| i.minutes.ago } - attrs = { :name => :test, - :count => 2, - :window => { :value => 1, :unit => :hour } } + attrs = { name: :test, + count: 2, + window: { value: 1, unit: :hour } } subject = described_class.from_hash(attrs) expect(subject.limit?(records)).to eq(true) end it 'returns false if the given records are under the limit' do records = [10, 5, 1].map { |i| i.minutes.ago } - attrs = { :name => :test, - :count => 20, - :window => { :value => 1, :unit => :hour } } + attrs = { name: :test, + count: 20, + window: { value: 1, unit: :hour } } subject = described_class.from_hash(attrs) expect(subject.limit?(records)).to eq(false) end it 'does not matter if the records are in a different order' do records = [5, 10, 1].map { |i| i.minutes.ago } - attrs = { :name => :test, - :count => 2, - :window => { :value => 1, :unit => :hour } } + attrs = { name: :test, + count: 2, + window: { value: 1, unit: :hour } } subject = described_class.from_hash(attrs) expect(subject.limit?(records.shuffle)).to eq(true) end it 'returns false if no records are given' do - attrs = { :name => :test, - :count => 20, - :window => { :value => 1, :unit => :hour } } + attrs = { name: :test, + count: 20, + window: { value: 1, unit: :hour } } subject = described_class.from_hash(attrs) expect(subject.limit?([])).to eq(false) end @@ -111,9 +111,9 @@ it 'returns records in the window' do records = [1, 5, 10].map { |i| i.days.ago } - attrs = { :name => :test, - :count => 20, - :window => { :value => 7, :unit => :day } } + attrs = { name: :test, + count: 20, + window: { value: 7, unit: :day } } subject = described_class.from_hash(attrs) expected = records[0..1] expect(subject.records_in_window(records)).to eq(expected) diff --git a/spec/lib/alaveteli_rate_limiter/window_spec.rb b/spec/lib/alaveteli_rate_limiter/window_spec.rb index d34cd3e340..2792960e51 100644 --- a/spec/lib/alaveteli_rate_limiter/window_spec.rb +++ b/spec/lib/alaveteli_rate_limiter/window_spec.rb @@ -6,17 +6,17 @@ it 'creates a Window from a Hash' do expected = described_class.new(3, :day) - hash = { :value => 3, :unit => :day } + hash = { value: 3, unit: :day } expect(described_class.from_hash(hash)).to eq(expected) end it 'requires a :value key' do - hash = { :unit => :day } + hash = { unit: :day } expect { described_class.from_hash(hash) }.to raise_error(KeyError) end it 'requires a :unit key' do - hash = { :value => 3 } + hash = { value: 3 } expect { described_class.from_hash(hash) }.to raise_error(KeyError) end diff --git a/spec/lib/alaveteli_text_masker_spec.rb b/spec/lib/alaveteli_text_masker_spec.rb index ec1550aa2f..bbb1e5fb6a 100644 --- a/spec/lib/alaveteli_text_masker_spec.rb +++ b/spec/lib/alaveteli_text_masker_spec.rb @@ -10,15 +10,15 @@ before do @cheese_censor_rule = FactoryBot.build(:censor_rule, - :text => 'Stilton', - :replacement => 'Jarlsberg') + text: 'Stilton', + replacement: 'Jarlsberg') @colour_censor_rule = FactoryBot.build(:censor_rule, - :text => 'blue', - :replacement => 'yellow') + text: 'blue', + replacement: 'yellow') @regex_censor_rule = FactoryBot.build(:censor_rule, - :text => 'm[a-z][a-z][a-z]e', - :replacement => 'cat', - :regexp => true) + text: 'm[a-z][a-z][a-z]e', + replacement: 'cat', + regexp: true) @censor_rules = [@cheese_censor_rule, @colour_censor_rule, @regex_censor_rule] @@ -29,7 +29,7 @@ result = class_instance.apply_masks(data, "image/jpeg", - :censor_rules => @censor_rules) + censor_rules: @censor_rules) expect(result). to eq("There was a mouse called Stilton, he wished that he was blue.") @@ -39,7 +39,7 @@ data = "There was a mouse called Stilton, he wished that he was blue." result = class_instance.apply_masks(data, "application/vnd.ms-word", - :censor_rules => @censor_rules) + censor_rules: @censor_rules) expect(result). to eq("There was a xxxxx called xxxxxxx, he wished that he was xxxx.") end @@ -49,7 +49,7 @@ @regex_censor_rule.text = 'á' result = class_instance.apply_masks(data, "application/octet-stream", - :censor_rules => @censor_rules) + censor_rules: @censor_rules) expect(result).to eq('xx mouse') end @@ -57,7 +57,7 @@ data = "There was a mouse called Stilton, he wished that he was blue." result = class_instance.apply_masks(data, 'text/html', - :censor_rules => @censor_rules) + censor_rules: @censor_rules) expect(result). to eq("There was a cat called Jarlsberg, he wished that he was yellow.") end @@ -206,20 +206,20 @@ def pdf_replacement_test(use_ghostscript_compression) expected = "here is a cat" censor_rule = FactoryBot.build(:censor_rule, - :text => 'mouse', - :replacement => 'cat') + text: 'mouse', + replacement: 'cat') result = class_instance.apply_masks(data, 'text/html', - :censor_rules => [censor_rule]) + censor_rules: [censor_rule]) expect(result).to eq(expected) end it 'applies extra masks to text' do data = "here is a mouse" expected = "here is a cat" - mask = { :to_replace => 'mouse', :replacement => 'cat'} - result = class_instance.apply_masks(data, 'text/html', :masks => [mask]) + mask = { to_replace: 'mouse', replacement: 'cat'} + result = class_instance.apply_masks(data, 'text/html', masks: [mask]) expect(result).to eq(expected) end diff --git a/spec/lib/attachment_to_html/adapters/google_docs_viewer_spec.rb b/spec/lib/attachment_to_html/adapters/google_docs_viewer_spec.rb index c7400127c5..dab8a01d3d 100644 --- a/spec/lib/attachment_to_html/adapters/google_docs_viewer_spec.rb +++ b/spec/lib/attachment_to_html/adapters/google_docs_viewer_spec.rb @@ -4,7 +4,7 @@ let(:attachment) { FactoryBot.build(:pdf_attachment) } let(:adapter) do - AttachmentToHTML::Adapters::GoogleDocsViewer.new(attachment, :attachment_url => 'http://example.com/test.pdf') + AttachmentToHTML::Adapters::GoogleDocsViewer.new(attachment, attachment_url: 'http://example.com/test.pdf') end describe :title do diff --git a/spec/lib/attachment_to_html/adapters/pdf_spec.rb b/spec/lib/attachment_to_html/adapters/pdf_spec.rb index 2b14e0d0ef..7f2ecc65cc 100644 --- a/spec/lib/attachment_to_html/adapters/pdf_spec.rb +++ b/spec/lib/attachment_to_html/adapters/pdf_spec.rb @@ -12,7 +12,7 @@ end it 'allows a tmpdir to be specified to store the converted document' do - adapter = AttachmentToHTML::Adapters::PDF.new(attachment, :tmpdir => '/tmp') + adapter = AttachmentToHTML::Adapters::PDF.new(attachment, tmpdir: '/tmp') expect(adapter.tmpdir).to eq('/tmp') end @@ -38,7 +38,7 @@ end it 'operates in the context of the supplied tmpdir' do - adapter = AttachmentToHTML::Adapters::PDF.new(attachment, :tmpdir => '/tmp') + adapter = AttachmentToHTML::Adapters::PDF.new(attachment, tmpdir: '/tmp') expect(Dir).to receive(:chdir).with('/tmp').and_call_original adapter.body end diff --git a/spec/lib/attachment_to_html/adapters/rtf_spec.rb b/spec/lib/attachment_to_html/adapters/rtf_spec.rb index 756f80f52f..88dc23cc5e 100644 --- a/spec/lib/attachment_to_html/adapters/rtf_spec.rb +++ b/spec/lib/attachment_to_html/adapters/rtf_spec.rb @@ -12,7 +12,7 @@ end it 'allows a tmpdir to be specified to store the converted document' do - adapter = AttachmentToHTML::Adapters::RTF.new(attachment, :tmpdir => '/tmp') + adapter = AttachmentToHTML::Adapters::RTF.new(attachment, tmpdir: '/tmp') expect(adapter.tmpdir).to eq('/tmp') end @@ -33,7 +33,7 @@ end it 'operates in the context of the supplied tmpdir' do - adapter = AttachmentToHTML::Adapters::RTF.new(attachment, :tmpdir => '/tmp') + adapter = AttachmentToHTML::Adapters::RTF.new(attachment, tmpdir: '/tmp') expect(Dir).to receive(:chdir).with('/tmp').and_call_original adapter.body end @@ -61,7 +61,7 @@ end it 'converts empty files' do - attachment = FactoryBot.build(:rtf_attachment, :body => load_file_fixture('empty.rtf')) + attachment = FactoryBot.build(:rtf_attachment, body: load_file_fixture('empty.rtf')) adapter = AttachmentToHTML::Adapters::RTF.new(attachment) expect(adapter.body).to eq('') end diff --git a/spec/lib/attachment_to_html/adapters/text_spec.rb b/spec/lib/attachment_to_html/adapters/text_spec.rb index d4efd61f9f..6d90c2a89a 100644 --- a/spec/lib/attachment_to_html/adapters/text_spec.rb +++ b/spec/lib/attachment_to_html/adapters/text_spec.rb @@ -20,41 +20,41 @@ end it 'strips the body of trailing whitespace' do - attachment = FactoryBot.build(:body_text, :body => ' Hello ') + attachment = FactoryBot.build(:body_text, body: ' Hello ') adapter = AttachmentToHTML::Adapters::Text.new(attachment) expect(adapter.body).to eq('Hello') end it 'escapes special characters' do - attachment = FactoryBot.build(:body_text, :body => 'Usage: foo "bar" >baz<') + attachment = FactoryBot.build(:body_text, body: 'Usage: foo "bar" >baz<') adapter = AttachmentToHTML::Adapters::Text.new(attachment) expected = %Q(Usage: foo "bar" >baz<) expect(adapter.body).to eq(expected) end it 'creates hyperlinks for text that looks like a url' do - attachment = FactoryBot.build(:body_text, :body => 'http://www.whatdotheyknow.com') + attachment = FactoryBot.build(:body_text, body: 'http://www.whatdotheyknow.com') adapter = AttachmentToHTML::Adapters::Text.new(attachment) expected = %Q(http://www.whatdotheyknow.com) expect(adapter.body).to eq(expected) end it 'substitutes newlines for br tags' do - attachment = FactoryBot.build(:body_text, :body => "A\nNewline") + attachment = FactoryBot.build(:body_text, body: "A\nNewline") adapter = AttachmentToHTML::Adapters::Text.new(attachment) expected = %Q(A
    Newline) expect(adapter.body).to eq(expected) end it 'returns the body encoded as UTF-8' do - attachment = FactoryBot.build(:body_text, :body => "\xBF") + attachment = FactoryBot.build(:body_text, body: "\xBF") adapter = AttachmentToHTML::Adapters::Text.new(attachment) expect(adapter.body.encoding).to eq(Encoding.find('UTF-8')) end it 'returns the body as valid UTF-8 when the text is not valid UTF-8' do - attachment = FactoryBot.build(:body_text, :body => "\xBF") + attachment = FactoryBot.build(:body_text, body: "\xBF") adapter = AttachmentToHTML::Adapters::Text.new(attachment) expect(adapter.body).to be_valid_encoding end diff --git a/spec/lib/attachment_to_html/attachment_to_html_spec.rb b/spec/lib/attachment_to_html/attachment_to_html_spec.rb index 2c7050ddc0..813c50297e 100644 --- a/spec/lib/attachment_to_html/attachment_to_html_spec.rb +++ b/spec/lib/attachment_to_html/attachment_to_html_spec.rb @@ -19,12 +19,12 @@ end it 'passes content injections options when rendering the result' do - html = to_html(attachment, :content_for => { :body_prefix => '

    prefix

    ' }) + html = to_html(attachment, content_for: { body_prefix: '

    prefix

    ' }) expect(html).to include('

    prefix

    ') end it 'accepts a hash of options to pass to the adapter' do - options = { :wrapper => 'wrap' } + options = { wrapper: 'wrap' } expect(AttachmentToHTML::Adapters::Text).to receive(:new).with(attachment, options).and_call_original to_html(attachment, options) end @@ -38,13 +38,13 @@ end it 'converts an attachment that doesnt have an adapter, but has a google viewer' do - attachment = FactoryBot.build(:body_text, :content_type => 'application/vnd.ms-word') + attachment = FactoryBot.build(:body_text, content_type: 'application/vnd.ms-word') expect(AttachmentToHTML::Adapters::GoogleDocsViewer).to receive(:new).with(attachment, {}).and_call_original to_html(attachment) end it 'converts an attachment that has no adapter or google viewer' do - attachment = FactoryBot.build(:body_text, :content_type => 'application/json') + attachment = FactoryBot.build(:body_text, content_type: 'application/json') expect(AttachmentToHTML::Adapters::CouldNotConvert).to receive(:new).with(attachment, {}).and_call_original to_html(attachment) end diff --git a/spec/lib/attachment_to_html/view_spec.rb b/spec/lib/attachment_to_html/view_spec.rb index e86058d530..3255d3d2a4 100644 --- a/spec/lib/attachment_to_html/view_spec.rb +++ b/spec/lib/attachment_to_html/view_spec.rb @@ -4,9 +4,9 @@ let(:adapter) do double(:adapter, - :body => '

    hello

    ', - :title => 'An attachment.txt', - :success? => true) + body: '

    hello

    ', + title: 'An attachment.txt', + success?: true) end let(:view) { AttachmentToHTML::View.new(adapter) } @@ -57,7 +57,7 @@ it 'allows a template to be set through an option' do template = file_fixture_name('attachment_to_html/alternative_template.html.erb') - opts = { :template => template } + opts = { template: template } view = AttachmentToHTML::View.new(adapter, opts) expect(view.template).to eq(template) end diff --git a/spec/lib/data_export_spec.rb b/spec/lib/data_export_spec.rb index 31822c84de..1892230205 100644 --- a/spec/lib/data_export_spec.rb +++ b/spec/lib/data_export_spec.rb @@ -36,7 +36,7 @@ end it "does not include hidden requests" do - hidden = FactoryBot.create(:info_request, :prominence => 'hidden') + hidden = FactoryBot.create(:info_request, prominence: 'hidden') exportable = described_class.exportable_requests(cut_off) expect(exportable).to_not include(hidden) @@ -70,7 +70,7 @@ end it "does not include hidden messages" do - hidden = FactoryBot.create(:incoming_message, :prominence => 'hidden') + hidden = FactoryBot.create(:incoming_message, prominence: 'hidden') exportable = described_class.exportable_incoming_messages(cut_off) expect(exportable).to_not include(hidden) @@ -85,9 +85,9 @@ it "does not include messages belonging to hidden requests" do hidden_request = FactoryBot.create(:info_request, - :prominence => 'hidden') + prominence: 'hidden') message = FactoryBot.create(:incoming_message, - :info_request => hidden_request) + info_request: hidden_request) exportable = described_class.exportable_incoming_messages(cut_off) expect(exportable).to_not include(message) @@ -96,7 +96,7 @@ it "does not include messages belonging to embargoed requests" do embargoed = FactoryBot.create(:embargoed_request) message = FactoryBot.create(:incoming_message, - :info_request => embargoed) + info_request: embargoed) exportable = described_class.exportable_incoming_messages(cut_off) expect(exportable).to_not include(message) @@ -116,7 +116,7 @@ end it "does not include hidden messages" do - hidden = FactoryBot.create(:initial_request, :prominence => 'hidden') + hidden = FactoryBot.create(:initial_request, prominence: 'hidden') exportable = described_class.exportable_outgoing_messages(cut_off) expect(exportable).to_not include(hidden) @@ -131,9 +131,9 @@ it "does not include messages belonging to hidden requests" do hidden_request = FactoryBot.create(:info_request, - :prominence => 'hidden') + prominence: 'hidden') message = FactoryBot.create(:initial_request, - :info_request => hidden_request) + info_request: hidden_request) exportable = described_class.exportable_outgoing_messages(cut_off) expect(exportable).to_not include(message) @@ -142,7 +142,7 @@ it "does not include messages belonging to embargoed requests" do embargoed = FactoryBot.create(:embargoed_request) message = FactoryBot.create(:initial_request, - :info_request => embargoed) + info_request: embargoed) exportable = described_class.exportable_outgoing_messages(cut_off) expect(exportable).to_not include(message) @@ -157,16 +157,16 @@ it "includes eligible attachments" do incoming = FactoryBot.create(:incoming_message) attachment = FactoryBot.create(:html_attachment, - :incoming_message => incoming) + incoming_message: incoming) exportable = described_class.exportable_foi_attachments(cut_off) expect(exportable).to include(attachment) end it "does not include attachments of hidden messages" do - incoming = FactoryBot.create(:incoming_message, :prominence => 'hidden') + incoming = FactoryBot.create(:incoming_message, prominence: 'hidden') attachment = FactoryBot.create(:html_attachment, - :incoming_message => incoming) + incoming_message: incoming) exportable = described_class.exportable_foi_attachments(cut_off) expect(exportable).to_not include(attachment) @@ -175,7 +175,7 @@ it "does not include attachments of messages created after the cut_off" do incoming = FactoryBot.create(:incoming_message) attachment = FactoryBot.create(:html_attachment, - :incoming_message => incoming) + incoming_message: incoming) exportable = described_class.exportable_foi_attachments(Date.today) expect(exportable).to_not include(attachment) @@ -183,11 +183,11 @@ it "does not include attachments of messages belonging to hidden requests" do hidden_request = FactoryBot.create(:info_request, - :prominence => 'hidden') + prominence: 'hidden') incoming = FactoryBot.create(:incoming_message, - :info_request => hidden_request) + info_request: hidden_request) attachment = FactoryBot.create(:html_attachment, - :incoming_message => incoming) + incoming_message: incoming) exportable = described_class.exportable_foi_attachments(cut_off) expect(exportable).to_not include(attachment) @@ -196,9 +196,9 @@ it "does not include attachments related to embargoed requests" do embargoed = FactoryBot.create(:embargoed_request) incoming = FactoryBot.create(:incoming_message, - :info_request => embargoed) + info_request: embargoed) attachment = FactoryBot.create(:html_attachment, - :incoming_message => incoming) + incoming_message: incoming) exportable = described_class.exportable_foi_attachments(cut_off) expect(exportable).to_not include(attachment) diff --git a/spec/lib/database_collation_spec.rb b/spec/lib/database_collation_spec.rb index deac08baf0..d107651218 100644 --- a/spec/lib/database_collation_spec.rb +++ b/spec/lib/database_collation_spec.rb @@ -29,13 +29,13 @@ it 'does not support collation if the database is not postgresql' do database = DatabaseCollation. - new(mock_connection(:adapter_name => 'MySQL')) + new(mock_connection(adapter_name: 'MySQL')) expect(database.supports?('en_GB')).to be false end it 'does not support collation if the postgresql version is too old' do database = DatabaseCollation. - new(mock_connection(:postgresql_version => 90111)) + new(mock_connection(postgresql_version: 90111)) # rubocop:disable Style/NumericLiterals expect(database.supports?('en_GB')).to be false end @@ -65,8 +65,8 @@ def mock_connection(connection_double_opts = {}) # Connection must be PostgreSQL 90112 or greater - default_double_opts = { :adapter_name => 'PostgreSQL', - :postgresql_version => 90112 } + default_double_opts = { adapter_name: 'PostgreSQL', + postgresql_version: 90112 } # rubocop:disable Style/NumericLiterals connection_double_opts = default_double_opts.merge(connection_double_opts) diff --git a/spec/lib/graphs_spec.rb b/spec/lib/graphs_spec.rb index cb97085820..95d7eb74fa 100644 --- a/spec/lib/graphs_spec.rb +++ b/spec/lib/graphs_spec.rb @@ -54,32 +54,32 @@ end it "uses the supplied column references via the 'using' option" do - result = dummy_class.create_dataset(test_data, {:using => "1:3"}) + result = dummy_class.create_dataset(test_data, {using: "1:3"}) expect(result.using).to eq "1:3" end it "sets the key title" do - result = dummy_class.create_dataset(test_data, {:title => "Dataset Title"}) + result = dummy_class.create_dataset(test_data, {title: "Dataset Title"}) expect(result.title).to eq "Dataset Title" end it "sets the plot type for the dataset via the 'with' option" do - result = dummy_class.create_dataset(test_data, {:with => "lines"}) + result = dummy_class.create_dataset(test_data, {with: "lines"}) expect(result.with).to eq "lines" end it "sets the line colour via the 'linecolor' option" do - result = dummy_class.create_dataset(test_data, {:linecolor => 2}) + result = dummy_class.create_dataset(test_data, {linecolor: 2}) expect(result.linecolor).to eq 2 end it "sets the line width via the 'linewidth' option" do - result = dummy_class.create_dataset(test_data, {:linewidth => 10}) + result = dummy_class.create_dataset(test_data, {linewidth: 10}) expect(result.linewidth).to eq 10 end it "sets the axes width via the 'axes' option" do - result = dummy_class.create_dataset(test_data, {:axes => "x1y1"}) + result = dummy_class.create_dataset(test_data, {axes: "x1y1"}) expect(result.axes).to eq "x1y1" end end @@ -152,18 +152,18 @@ let(:graph_def_1) do Graphs::GraphParams.new( "SELECT DATE(created_at), COUNT(*) FROM users GROUP BY DATE(created_at)", - { :title => "test 1", - :with => "lines", - :linecolor => Graphs::COLOURS[:mauve] } + { title: "test 1", + with: "lines", + linecolor: Graphs::COLOURS[:mauve] } ) end let(:graph_def_2) do Graphs::GraphParams.new( "SELECT DATE(created_at), COUNT(*) FROM info_requests GROUP BY DATE(created_at)", - { :title => "test 2", - :with => "lines", - :linecolor => Graphs::COLOURS[:red] } + { title: "test 2", + with: "lines", + linecolor: Graphs::COLOURS[:red] } ) end diff --git a/spec/lib/health_checks/checks/period_check_spec.rb b/spec/lib/health_checks/checks/period_check_spec.rb index 71b9e93164..d736197154 100644 --- a/spec/lib/health_checks/checks/period_check_spec.rb +++ b/spec/lib/health_checks/checks/period_check_spec.rb @@ -38,7 +38,7 @@ end it 'includes the check subject in a custom message' do - params = { :failure_message => 'This check failed' } + params = { failure_message: 'This check failed' } subject = 2.days.ago check = HealthChecks::Checks::PeriodCheck.new(params) { subject } expect(check.failure_message).to include(subject.to_s) @@ -55,7 +55,7 @@ end it 'includes the check subject in a custom message' do - params = { :success_message => 'This check succeeded' } + params = { success_message: 'This check succeeded' } subject = Time.zone.now check = HealthChecks::Checks::PeriodCheck.new(params) { subject } expect(check.success_message).to include(subject.to_s) diff --git a/spec/lib/health_checks/health_checkable_spec.rb b/spec/lib/health_checks/health_checkable_spec.rb index 2f5d22f3d5..2b1c3b86ef 100644 --- a/spec/lib/health_checks/health_checkable_spec.rb +++ b/spec/lib/health_checks/health_checkable_spec.rb @@ -12,12 +12,12 @@ class MockCheck describe '#initialize' do it 'allows a custom failure message to be set' do - @subject = MockCheck.new(:failure_message => 'F') + @subject = MockCheck.new(failure_message: 'F') expect(@subject.failure_message).to eq('F') end it 'allows a custom success message to be set' do - @subject = MockCheck.new(:success_message => 'S') + @subject = MockCheck.new(success_message: 'S') expect(@subject.success_message).to eq('S') end @@ -78,7 +78,7 @@ class MockCheck context 'if the check succeeds' do before(:each) do - allow(@subject).to receive_messages(:ok? => true) + allow(@subject).to receive_messages(ok?: true) end it 'returns the default success message' do @@ -95,7 +95,7 @@ class MockCheck context 'if the check fails' do before(:each) do - allow(@subject).to receive_messages(:ok? => false) + allow(@subject).to receive_messages(ok?: false) end it 'returns the default failure message' do diff --git a/spec/lib/health_checks/health_checks_spec.rb b/spec/lib/health_checks/health_checks_spec.rb index c5138d213f..6e68472fdf 100644 --- a/spec/lib/health_checks/health_checks_spec.rb +++ b/spec/lib/health_checks/health_checks_spec.rb @@ -6,7 +6,7 @@ describe '#add' do it 'adds a check to the collection and returns the check' do - check = double('MockCheck', :ok? => true) + check = double('MockCheck', ok?: true) expect(add(check)).to eq(check) end @@ -20,8 +20,8 @@ describe '#all' do it 'returns all the checks' do - check1 = double('MockCheck', :ok? => true) - check2 = double('AnotherCheck', :ok? => false) + check1 = double('MockCheck', ok?: true) + check2 = double('AnotherCheck', ok?: false) add(check1) add(check2) expect(all).to include(check1, check2) @@ -41,33 +41,33 @@ it 'returns true if all checks are ok' do checks = [ - double('MockCheck', :ok? => true), - double('FakeCheck', :ok? => true), - double('TestCheck', :ok? => true) + double('MockCheck', ok?: true), + double('FakeCheck', ok?: true), + double('TestCheck', ok?: true) ] - allow(HealthChecks).to receive_messages(:all => checks) + allow(HealthChecks).to receive_messages(all: checks) expect(HealthChecks.ok?).to be true end it 'returns false if all checks fail' do checks = [ - double('MockCheck', :ok? => false), - double('FakeCheck', :ok? => false), - double('TestCheck', :ok? => false) + double('MockCheck', ok?: false), + double('FakeCheck', ok?: false), + double('TestCheck', ok?: false) ] - allow(HealthChecks).to receive_messages(:all => checks) + allow(HealthChecks).to receive_messages(all: checks) expect(HealthChecks.ok?).to be false end it 'returns false if a single check fails' do checks = [ - double('MockCheck', :ok? => true), - double('FakeCheck', :ok? => false), - double('TestCheck', :ok? => true) + double('MockCheck', ok?: true), + double('FakeCheck', ok?: false), + double('TestCheck', ok?: true) ] - allow(HealthChecks).to receive_messages(:all => checks) + allow(HealthChecks).to receive_messages(all: checks) expect(HealthChecks.ok?).to be false end diff --git a/spec/lib/i18n_interpolation_spec.rb b/spec/lib/i18n_interpolation_spec.rb index f87ce5d355..62bc0095c0 100644 --- a/spec/lib/i18n_interpolation_spec.rb +++ b/spec/lib/i18n_interpolation_spec.rb @@ -3,9 +3,9 @@ RSpec.describe "when using i18n" do it "should not complain if we're missing variables from the string" do - result = _('Hello', :dip => 'hummus') + result = _('Hello', dip: 'hummus') expect(result).to eq('Hello') - result = _('Hello {{dip}}', :dip => 'hummus') + result = _('Hello {{dip}}', dip: 'hummus') expect(result).to eq('Hello hummus') end @@ -115,13 +115,13 @@ let(:string) { "Hello {{a}}" } it "should give an unsafe result" do - result = gettext_interpolate(string, :a => "foo") + result = gettext_interpolate(string, a: "foo") expect(result).to eq("Hello foo") expect(result).not_to be_html_safe end it "should give an unsafe result" do - result = gettext_interpolate(string, :a => "foo".html_safe) + result = gettext_interpolate(string, a: "foo".html_safe) expect(result).to eq("Hello foo") expect(result).not_to be_html_safe end @@ -131,13 +131,13 @@ let(:string) { "Hello {{a}}".html_safe } it "should quote the input if it's unsafe" do - result = gettext_interpolate(string, :a => "foo&") + result = gettext_interpolate(string, a: "foo&") expect(result).to eq("Hello foo&") expect(result).to be_html_safe end it "should not quote the input if it's safe" do - result = gettext_interpolate(string, :a => "foo&".html_safe) + result = gettext_interpolate(string, a: "foo&".html_safe) expect(result).to eq("Hello foo&") expect(result).to be_html_safe end diff --git a/spec/lib/mail_handler/mail_handler_spec.rb b/spec/lib/mail_handler/mail_handler_spec.rb index eae113e67a..6bba6524e1 100644 --- a/spec/lib/mail_handler/mail_handler_spec.rb +++ b/spec/lib/mail_handler/mail_handler_spec.rb @@ -10,8 +10,8 @@ def create_message_from(from_field) it "should be able to parse a large email without raising an exception" do m = Mail.new - m.add_file(:filename => "attachment.data", :content => "a" * (8 * 1024 * 1024)) - raw_email = "From jamis_buck@byu.edu Mon May 2 16:07:05 2005\r\n#{m.to_s}" + m.add_file(filename: "attachment.data", content: "a" * (8 * 1024 * 1024)) + raw_email = "From jamis_buck@byu.edu Mon May 2 16:07:05 2005\r\n#{m}" expect { Mail::Message.new(raw_email) }.not_to raise_error end @@ -34,7 +34,7 @@ def create_message_from(from_field) it 'should convert an iso8859 email to utf8' do mail = get_fixture_mail('iso8859_2_raw_email.email') - expect(mail.subject).to match /gjatë/u + expect(mail.subject).to match(/gjatë/u) expect(MailHandler.get_part_body(mail).is_utf8?).to eq(true) end @@ -329,7 +329,7 @@ def expect_header_string(fixture_file, header, header_string) RSpec.describe "when getting the attachment text" do it "should not raise an error if the expansion of a zip file raises an error" do - mock_entry = double('Zip::File entry', :file? => true) + mock_entry = double('Zip::File entry', file?: true) mock_entries = [mock_entry] allow(mock_entries).to receive(:close) allow(mock_entry).to receive(:get_input_stream).and_raise("invalid distance too far back") @@ -474,73 +474,73 @@ def expect_header_string(fixture_file, header, header_string) mail = get_fixture_mail('many-attachments-date-header.email') attributes = MailHandler.get_attachment_attributes(mail) - expected_attributes = [ { :content_type=>"text/plain", - :url_part_number=>1, - :within_rfc822_subject=>nil, - :filename=>nil}, - { :content_type=>"text/plain", - :url_part_number=>2, - :within_rfc822_subject=>"Re: xxx", - :filename=>nil}, - { :content_type=>"text/html", - :url_part_number=>4, - :within_rfc822_subject=>"example", - :filename=>nil}, - { :content_type=>"image/gif", :url_part_number=>5, - :within_rfc822_subject=>"example", - :filename=>"image001.gif"}, - { :content_type=>"application/vnd.ms-excel", - :url_part_number=>6, - :within_rfc822_subject=>"example", - :filename=>"particpant list.xls"}, - { :content_type=>"text/plain", - :url_part_number=>7, - :within_rfc822_subject=>"RE: example", - :filename=>nil}, - { :content_type=>"text/html", - :url_part_number=>9, - :within_rfc822_subject=>"As promised - Masterclass info (example)", - :filename=>nil}, - { :content_type=>"image/gif", - :url_part_number=>10, - :within_rfc822_subject=>"As promised - Masterclass info (example)", - :filename=>"image001.gif"}, - { :content_type=>"application/vnd.ms-word", - :url_part_number=>11, - :within_rfc822_subject=>"As promised - Masterclass info (example)", - :filename=>"Participant List.doc"}, - { :content_type=>"application/vnd.ms-word", - :url_part_number=>12, - :within_rfc822_subject=>"As promised - Masterclass info (example)", - :filename=>"Information & Booking Form.doc"}, - { :content_type=>"text/plain", - :url_part_number=>13, - :within_rfc822_subject=>"Re: As promised - info (example)", - :filename=>nil}, - { :content_type=>"text/html", - :url_part_number=>15, - :within_rfc822_subject=>"Thank you from example", - :filename=>nil}, - { :content_type=>"image/gif", - :url_part_number=>16, - :within_rfc822_subject=>"Thank you from example", - :filename=>"image001.gif"}, - { :content_type=>"text/plain", - :url_part_number=>17, - :within_rfc822_subject=>"example - Meeting - Tuesday 2nd March", - :filename=>nil}, - { :content_type=>"text/plain", - :url_part_number=>18, - :within_rfc822_subject=>"example - Help needed", - :filename=>nil}, - { :content_type=>"application/pdf", - :url_part_number=>19, - :within_rfc822_subject=>"example - Help needed", - :filename=>"Information Pack.pdf"}, - { :content_type=>"text/plain", - :url_part_number=>20, - :within_rfc822_subject=>"Re: As promised - info (example)", - :filename=>nil} ] + expected_attributes = [ { content_type: "text/plain", + url_part_number: 1, + within_rfc822_subject: nil, + filename: nil}, + { content_type: "text/plain", + url_part_number: 2, + within_rfc822_subject: "Re: xxx", + filename: nil}, + { content_type: "text/html", + url_part_number: 4, + within_rfc822_subject: "example", + filename: nil}, + { content_type: "image/gif", url_part_number: 5, + within_rfc822_subject: "example", + filename: "image001.gif"}, + { content_type: "application/vnd.ms-excel", + url_part_number: 6, + within_rfc822_subject: "example", + filename: "particpant list.xls"}, + { content_type: "text/plain", + url_part_number: 7, + within_rfc822_subject: "RE: example", + filename: nil}, + { content_type: "text/html", + url_part_number: 9, + within_rfc822_subject: "As promised - Masterclass info (example)", + filename: nil}, + { content_type: "image/gif", + url_part_number: 10, + within_rfc822_subject: "As promised - Masterclass info (example)", + filename: "image001.gif"}, + { content_type: "application/vnd.ms-word", + url_part_number: 11, + within_rfc822_subject: "As promised - Masterclass info (example)", + filename: "Participant List.doc"}, + { content_type: "application/vnd.ms-word", + url_part_number: 12, + within_rfc822_subject: "As promised - Masterclass info (example)", + filename: "Information & Booking Form.doc"}, + { content_type: "text/plain", + url_part_number: 13, + within_rfc822_subject: "Re: As promised - info (example)", + filename: nil}, + { content_type: "text/html", + url_part_number: 15, + within_rfc822_subject: "Thank you from example", + filename: nil}, + { content_type: "image/gif", + url_part_number: 16, + within_rfc822_subject: "Thank you from example", + filename: "image001.gif"}, + { content_type: "text/plain", + url_part_number: 17, + within_rfc822_subject: "example - Meeting - Tuesday 2nd March", + filename: nil}, + { content_type: "text/plain", + url_part_number: 18, + within_rfc822_subject: "example - Help needed", + filename: nil}, + { content_type: "application/pdf", + url_part_number: 19, + within_rfc822_subject: "example - Help needed", + filename: "Information Pack.pdf"}, + { content_type: "text/plain", + url_part_number: 20, + within_rfc822_subject: "Re: As promised - info (example)", + filename: nil} ] attributes.each_with_index do |attr, index| attr.delete(:charset) diff --git a/spec/lib/public_body_csv_spec.rb b/spec/lib/public_body_csv_spec.rb index d070762d4f..f170bffa22 100644 --- a/spec/lib/public_body_csv_spec.rb +++ b/spec/lib/public_body_csv_spec.rb @@ -80,7 +80,7 @@ it 'allows custom fields to be set on instantiation' do custom_fields = [:name, :short_name] - csv = PublicBodyCSV.new(:fields => custom_fields) + csv = PublicBodyCSV.new(fields: custom_fields) expect(csv.fields).to eq(custom_fields) end @@ -95,7 +95,7 @@ it 'allows custom headers to be set on instantiation' do custom_headers = ['Name', 'Short Name'] - csv = PublicBodyCSV.new(:headers => custom_headers) + csv = PublicBodyCSV.new(headers: custom_headers) expect(csv.headers).to eq(custom_headers) end @@ -113,14 +113,14 @@ describe '#<<' do it 'adds an elements attributes to the rows collection' do - attrs = { :name => 'Exported to CSV', - :short_name => 'CSV', - :request_email => 'csv@localhost', - :tag_string => 'exported', - :notes => 'An exported authority', - :created_at => '2007-10-25 10:51:01 UTC', - :updated_at => '2007-10-25 10:51:01 UTC' } - body = FactoryBot.create(:public_body, attrs) + attrs = { name: 'Exported to CSV', + short_name: 'CSV', + request_email: 'csv@localhost', + tag_string: 'exported', + note_body: 'An exported authority', + created_at: '2007-10-25 10:51:01 UTC', + updated_at: '2007-10-25 10:51:01 UTC' } + body = FactoryBot.create(:public_body, :with_note, attrs) csv = PublicBodyCSV.new csv << body @@ -134,23 +134,23 @@ describe '#generate' do it 'generates the csv' do - attrs1 = { :name => 'Exported to CSV 1', - :short_name => 'CSV1', - :request_email => 'csv1@localhost', - :tag_string => 'exported', - :notes => 'An exported authority', - :created_at => '2007-10-25 10:51:01 UTC', - :updated_at => '2007-10-25 10:51:01 UTC' } - body1 = FactoryBot.create(:public_body, attrs1) - - attrs2 = { :name => 'Exported to CSV 2', - :short_name => 'CSV2', - :request_email => 'csv2@localhost', - :tag_string => 'exported', - :notes => 'Exported authority', - :created_at => '2011-01-26 14:11:02 UTC', - :updated_at => '2011-01-26 14:11:02 UTC' } - body2 = FactoryBot.create(:public_body, attrs2) + attrs1 = { name: 'Exported to CSV 1', + short_name: 'CSV1', + request_email: 'csv1@localhost', + tag_string: 'exported', + note_body: 'An exported authority', + created_at: '2007-10-25 10:51:01 UTC', + updated_at: '2007-10-25 10:51:01 UTC' } + body1 = FactoryBot.create(:public_body, :with_note, attrs1) + + attrs2 = { name: 'Exported to CSV 2', + short_name: 'CSV2', + request_email: 'csv2@localhost', + tag_string: 'exported', + note_body: 'Exported authority', + created_at: '2011-01-26 14:11:02 UTC', + updated_at: '2011-01-26 14:11:02 UTC' } + body2 = FactoryBot.create(:public_body, :with_note, attrs2) expected = <<-CSV.strip_heredoc Name,Short name,URL name,Home page,Publication scheme,Disclosure log,Notes,Created at,Updated at,Version @@ -163,7 +163,7 @@ fields = [:name, :short_name, :url_name, :calculated_home_page, :publication_scheme, :disclosure_log, :notes_as_string, :created_at, :updated_at, :version] headers = ['Name', 'Short name', 'URL name', 'Home page', 'Publication scheme', 'Disclosure log', 'Notes', 'Created at', 'Updated at', 'Version'] - csv = PublicBodyCSV.new(:fields => fields, :headers => headers) + csv = PublicBodyCSV.new(fields: fields, headers: headers) csv << body1 csv << body2 expect(csv.generate).to eq(expected) diff --git a/spec/lib/strip_empty_sessions_spec.rb b/spec/lib/strip_empty_sessions_spec.rb index 8cecdce874..2ad1273211 100644 --- a/spec/lib/strip_empty_sessions_spec.rb +++ b/spec/lib/strip_empty_sessions_spec.rb @@ -2,7 +2,7 @@ RSpec.describe StripEmptySessions do def make_response(session_data, response_headers) - app = lambda do |env| + app = ->(env) do env['rack.session'] = session_data return [200, response_headers, ['content']] end diff --git a/spec/lib/typeahead_search_spec.rb b/spec/lib/typeahead_search_spec.rb index 133d1e02a4..2c5f00eb80 100644 --- a/spec/lib/typeahead_search_spec.rb +++ b/spec/lib/typeahead_search_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' RSpec.describe TypeaheadSearch do - let(:options) { { :model => InfoRequestEvent } } + let(:options) { { model: InfoRequestEvent } } describe "#initialize" do @@ -14,7 +14,7 @@ end it 'assigns the page' do - opts = options.merge(:page => 5) + opts = options.merge(page: 5) expect(TypeaheadSearch.new("chicken", opts).page).to eq(5) end @@ -23,7 +23,7 @@ end it 'assigns per_page' do - opts = options.merge(:per_page => 10) + opts = options.merge(per_page: 10) expect(TypeaheadSearch.new("chicken", opts).per_page).to eq(10) end @@ -44,7 +44,7 @@ describe '#options' do it 'sets the offset based on the page and per_page settings' do - opts = options.merge(:page => 2, :per_page => 10) + opts = options.merge(page: 2, per_page: 10) expect(TypeaheadSearch.new("chicken", opts).options[:offset]). to eq(10) end @@ -55,19 +55,19 @@ end it 'sets collapse_by_prefix to nil for PublicBody queries' do - opts = options.merge(:model => PublicBody) + opts = options.merge(model: PublicBody) expect(TypeaheadSearch.new("chicken", opts).options[:collapse_by_prefix]). to be nil end it 'sets the limit to the per_page setting' do - opts = options.merge(:per_page => 10) + opts = options.merge(per_page: 10) expect(TypeaheadSearch.new("chicken", opts).options[:limit]). to eq(10) end it 'sets the model' do - opts = options.merge(:model => PublicBody) + opts = options.merge(model: PublicBody) expect(TypeaheadSearch.new("chicken", opts).options[:model]). to eq(PublicBody) end @@ -108,7 +108,7 @@ def search_bodies(xapian_search) end it "returns a search with results of the appropriate model type" do - opts = options.merge(:model => PublicBody) + opts = options.merge(model: PublicBody) search = TypeaheadSearch.new("geraldine", opts).xapian_search expect(search_bodies(search)). to match_array([public_bodies(:geraldine_public_body)]) @@ -116,7 +116,7 @@ def search_bodies(xapian_search) it "returns results matching the given keywords in any of their locales" do # part of the spanish notes - opts = options.merge(:model => PublicBody) + opts = options.merge(model: PublicBody) search = TypeaheadSearch.new("baguette", opts).xapian_search expect(search_bodies(search)). to match_array([public_bodies(:humpadink_public_body)]) @@ -133,7 +133,7 @@ def search_bodies(xapian_search) expect(search_info_requests(search)).to match_array([ info_requests(:fancy_dog_request), info_requests(:naughty_chicken_request), - info_requests(:another_boring_request), + info_requests(:another_boring_request) ]) end @@ -220,8 +220,8 @@ def search_bodies(xapian_search) context 'when the exclude_tags option is used' do it "returns a search excluding results with those tags" do - opts = options.merge( :model => PublicBody, - :exclude_tags => [ 'lonely_agency' ]) + opts = options.merge( model: PublicBody, + exclude_tags: [ 'lonely_agency' ]) search = TypeaheadSearch.new("lonely", opts).xapian_search expect(search.results).to match_array([]) end diff --git a/spec/lib/user_spam_scorer_spec.rb b/spec/lib/user_spam_scorer_spec.rb index 1be133e26b..d747d1d5ad 100644 --- a/spec/lib/user_spam_scorer_spec.rb +++ b/spec/lib/user_spam_scorer_spec.rb @@ -26,8 +26,8 @@ end it 'sets a custom score_mappings value' do - described_class.score_mappings = { :name_is_one_word? => 7 } - expect(described_class.score_mappings).to eq({ :name_is_one_word? => 7 }) + described_class.score_mappings = { name_is_one_word?: 7 } + expect(described_class.score_mappings).to eq({ name_is_one_word?: 7 }) end end @@ -150,7 +150,7 @@ end it 'sets a custom currency_symbols value' do - scorer = described_class.new(:currency_symbols => %w(£ $)) + scorer = described_class.new(currency_symbols: %w(£ $)) expect(scorer.currency_symbols).to eq(%w(£ $)) end @@ -159,8 +159,8 @@ end it 'sets a custom score_mappings value' do - scorer = described_class.new(:score_mappings => { :check => 1 }) - expect(scorer.score_mappings).to eq({ :check => 1 }) + scorer = described_class.new(score_mappings: { check: 1 }) + expect(scorer.score_mappings).to eq({ check: 1 }) end it 'sets a default suspicious_domains value' do @@ -169,7 +169,7 @@ end it 'sets a custom suspicious_domains value' do - scorer = described_class.new(:suspicious_domains => %w(example.com)) + scorer = described_class.new(suspicious_domains: %w(example.com)) expect(scorer.suspicious_domains).to eq(%w(example.com)) end @@ -179,7 +179,7 @@ end it 'sets a custom spam_name_formats value' do - scorer = described_class.new(:spam_name_formats => [/spam/]) + scorer = described_class.new(spam_name_formats: [/spam/]) expect(scorer.spam_name_formats).to eq([/spam/]) end @@ -189,7 +189,7 @@ end it 'sets a custom spam_about_me_formats value' do - scorer = described_class.new(:spam_about_me_formats => [/spam/]) + scorer = described_class.new(spam_about_me_formats: [/spam/]) expect(scorer.spam_about_me_formats).to eq([/spam/]) end @@ -199,7 +199,7 @@ end it 'sets a custom spam_score_threshold value' do - scorer = described_class.new(:spam_score_threshold => 1) + scorer = described_class.new(spam_score_threshold: 1) expect(scorer.spam_score_threshold).to eq(1) end @@ -208,7 +208,7 @@ end it 'sets a custom spam_tlds value' do - scorer = described_class.new(:spam_tlds => %w(com)) + scorer = described_class.new(spam_tlds: %w(com)) expect(scorer.spam_tlds).to eq(%w(com)) end @@ -217,28 +217,28 @@ describe '#spam?' do it 'returns true if the user spam score is above the threshold' do - user_attrs = { :name => 'spammer', :comments => [], :track_things => [] } + user_attrs = { name: 'spammer', comments: [], track_things: [] } user = mock_model(User, user_attrs) - attrs = { :score_mappings => { :name_is_one_word? => 100 }, - :spam_score_threshold => 5 } + attrs = { score_mappings: { name_is_one_word?: 100 }, + spam_score_threshold: 5 } scorer = described_class.new(attrs) expect(scorer.spam?(user)).to eq(true) end it 'returns false if the user spam score is equal to the threshold' do - user_attrs = { :name => 'genuine', :comments => [], :track_things => [] } + user_attrs = { name: 'genuine', comments: [], track_things: [] } user = mock_model(User, user_attrs) - attrs = { :score_mappings => { :name_is_one_word? => 5 }, - :spam_score_threshold => 5 } + attrs = { score_mappings: { name_is_one_word?: 5 }, + spam_score_threshold: 5 } scorer = described_class.new(attrs) expect(scorer.spam?(user)).to eq(false) end it 'returns false if the user spam score is below the threshold' do - user_attrs = { :name => 'genuine', :comments => [], :track_things => [] } + user_attrs = { name: 'genuine', comments: [], track_things: [] } user = mock_model(User, user_attrs) - attrs = { :score_mappings => { :name_is_one_word? => 5 }, - :spam_score_threshold => 100 } + attrs = { score_mappings: { name_is_one_word?: 5 }, + spam_score_threshold: 100 } scorer = described_class.new(attrs) expect(scorer.spam?(user)).to eq(false) end @@ -248,49 +248,49 @@ describe '#score' do it 'returns 0 if no mappings return true' do - user_attrs = { :name => 'Bob Smith', - :comments => [], - :track_things => [] } + user_attrs = { name: 'Bob Smith', + comments: [], + track_things: [] } user = mock_model(User, user_attrs) - scorer = described_class.new(:score_mappings => {}) + scorer = described_class.new(score_mappings: {}) expect(scorer.score(user)).to eq(0) end it 'returns 0 if the user has comments' do - user_attrs = { :name => 'dubious', - :comments => [double], - :track_things => [] } + user_attrs = { name: 'dubious', + comments: [double], + track_things: [] } user = mock_model(User, user_attrs) expect(subject.score(user)).to eq(0) end it 'returns 0 if the user has track_things' do - user_attrs = { :name => 'dubious', - :comments => [], - :track_things => [double] } + user_attrs = { name: 'dubious', + comments: [], + track_things: [double] } user = mock_model(User, user_attrs) expect(subject.score(user)).to eq(0) end it 'increases the score for each score mapping that returns true' do - user_attrs = { :name => 'Spammer', - :email_domain => 'mail.ru', - :comments => [], - :track_things => [] } + user_attrs = { name: 'Spammer', + email_domain: 'mail.ru', + comments: [], + track_things: [] } user = mock_model(User, user_attrs) - opts = { :score_mappings => { :name_is_all_lowercase? => 1, - :name_is_one_word? => 2, - :email_from_suspicious_domain? => 3 } } + opts = { score_mappings: { name_is_all_lowercase?: 1, + name_is_one_word?: 2, + email_from_suspicious_domain?: 3 } } scorer = described_class.new(opts) expect(scorer.score(user)).to eq(5) end it 'raises an error if a mapping is invalid' do - user_attrs = { :name => 'Bob Smith', - :comments => [], - :track_things => [] } + user_attrs = { name: 'Bob Smith', + comments: [], + track_things: [] } user = mock_model(User, user_attrs) - scorer = described_class.new(:score_mappings => { :invalid_method => 1 }) + scorer = described_class.new(score_mappings: { invalid_method: 1 }) expect { scorer.score(user) }.to raise_error(NoMethodError) end @@ -299,12 +299,12 @@ describe '#name_is_all_lowercase?' do it 'is true if the name is all lowercase' do - user = mock_model(User, :name => 'bob smith 123') + user = mock_model(User, name: 'bob smith 123') expect(subject.name_is_all_lowercase?(user)).to eq(true) end it 'is false if the name is not all lowercase' do - user = mock_model(User, :name => 'Bob smith 123') + user = mock_model(User, name: 'Bob smith 123') expect(subject.name_is_all_lowercase?(user)).to eq(false) end @@ -313,12 +313,12 @@ describe '#name_is_one_word?' do it 'is true if the name is one word' do - user = mock_model(User, :name => 'bobsmith123') + user = mock_model(User, name: 'bobsmith123') expect(subject.name_is_one_word?(user)).to eq(true) end it 'is false if the name includes a space' do - user = mock_model(User, :name => 'bob smith 123') + user = mock_model(User, name: 'bob smith 123') expect(subject.name_is_one_word?(user)).to eq(false) end @@ -327,12 +327,12 @@ describe '#name_is_garbled?' do it 'is true if the name includes 5 consecutive consonants' do - user = mock_model(User, :name => 'JWahewKjWhebCd') + user = mock_model(User, name: 'JWahewKjWhebCd') expect(subject.name_is_garbled?(user)).to eq(true) end it 'is false if the name does not include 5 consecutive consonants' do - user = mock_model(User, :name => 'Bob Smith') + user = mock_model(User, name: 'Bob Smith') expect(subject.name_is_garbled?(user)).to eq(false) end @@ -341,22 +341,22 @@ describe '#name_includes_non_alpha_characters?' do it 'is true if the name includes numbers' do - user = mock_model(User, :name => 'Bob smith 123') + user = mock_model(User, name: 'Bob smith 123') expect(subject.name_includes_non_alpha_characters?(user)).to eq(true) end it 'is true if the name includes non-word characters' do - user = mock_model(User, :name => 'Bob!!!') + user = mock_model(User, name: 'Bob!!!') expect(subject.name_includes_non_alpha_characters?(user)).to eq(true) end it 'is false if the name is English alpha characters' do - user = mock_model(User, :name => 'Bob') + user = mock_model(User, name: 'Bob') expect(subject.name_includes_non_alpha_characters?(user)).to eq(false) end it 'is false if the name is English alpha characters and whitespace' do - user = mock_model(User, :name => 'Bob smith') + user = mock_model(User, name: 'Bob smith') expect(subject.name_includes_non_alpha_characters?(user)).to eq(false) end @@ -366,17 +366,17 @@ it 'is true if the email is from a suspicious domain' do mock_suspicious_domains = %w(example.com example.net example.org) - user = mock_model(User, :email_domain => 'example.net') + user = mock_model(User, email_domain: 'example.net') scorer = described_class.new( - :suspicious_domains => mock_suspicious_domains) + suspicious_domains: mock_suspicious_domains) expect(scorer.email_from_suspicious_domain?(user)).to eq(true) end it 'is false if the email is not from a suspicious domain' do mock_suspicious_domains = %w(example.com example.org) - user = mock_model(User, :email_domain => 'example.net') + user = mock_model(User, email_domain: 'example.net') scorer = described_class.new( - :suspicious_domains => mock_suspicious_domains) + suspicious_domains: mock_suspicious_domains) expect(scorer.email_from_suspicious_domain?(user)).to eq(false) end @@ -386,15 +386,15 @@ it 'is true if the email is from a spam domain' do mock_spam_domains = %w(example.com example.net example.org) - user = mock_model(User, :email_domain => 'example.net') - scorer = described_class.new(:spam_domains => mock_spam_domains) + user = mock_model(User, email_domain: 'example.net') + scorer = described_class.new(spam_domains: mock_spam_domains) expect(scorer.email_from_spam_domain?(user)).to eq(true) end it 'is false if the email is not from a spam domain' do mock_spam_domains = %w(example.com example.org) - user = mock_model(User, :email_domain => 'example.net') - scorer = described_class.new(:spam_domains => mock_spam_domains) + user = mock_model(User, email_domain: 'example.net') + scorer = described_class.new(spam_domains: mock_spam_domains) expect(scorer.email_from_spam_domain?(user)).to eq(false) end @@ -404,15 +404,15 @@ it 'is true if the email is from a spam tld' do mock_spam_tlds = %w(com net org) - user = mock_model(User, :email_domain => 'example.net') - scorer = described_class.new(:spam_tlds => mock_spam_tlds) + user = mock_model(User, email_domain: 'example.net') + scorer = described_class.new(spam_tlds: mock_spam_tlds) expect(scorer.email_from_spam_tld?(user)).to eq(true) end it 'is false if the email is not from a spam tld' do mock_spam_tlds = %w(com org) - user = mock_model(User, :email_domain => 'example.net') - scorer = described_class.new(:spam_tlds => mock_spam_tlds) + user = mock_model(User, email_domain: 'example.net') + scorer = described_class.new(spam_tlds: mock_spam_tlds) expect(scorer.email_from_spam_tld?(user)).to eq(false) end @@ -514,15 +514,15 @@ it 'is true if the about me includes a currency symbol' do mock_currency_symbols = %w(£ $) - user = mock_model(User, :about_me => 'Spam for just $100') - scorer = described_class.new(:currency_symbols => mock_currency_symbols) + user = mock_model(User, about_me: 'Spam for just $100') + scorer = described_class.new(currency_symbols: mock_currency_symbols) expect(scorer.about_me_includes_currency_symbol?(user)).to eq(true) end it 'is false if the about me does not include a currency symbol' do mock_currency_symbols = %w(£ $) - user = mock_model(User, :about_me => 'No spam here') - scorer = described_class.new(:currency_symbols => mock_currency_symbols) + user = mock_model(User, about_me: 'No spam here') + scorer = described_class.new(currency_symbols: mock_currency_symbols) expect(scorer.about_me_includes_currency_symbol?(user)).to eq(false) end @@ -531,32 +531,32 @@ describe '#about_me_is_link_only?' do it 'is true if the about me is just a HTTP URL' do - user = mock_model(User, :about_me => 'http://example.com') + user = mock_model(User, about_me: 'http://example.com') expect(subject.about_me_is_link_only?(user)).to eq(true) end it 'is true if the about me is just a HTTPS URL' do - user = mock_model(User, :about_me => 'https://example.com') + user = mock_model(User, about_me: 'https://example.com') expect(subject.about_me_is_link_only?(user)).to eq(true) end it 'is false if the about me has text only' do - user = mock_model(User, :about_me => 'No spam here') + user = mock_model(User, about_me: 'No spam here') expect(subject.about_me_is_link_only?(user)).to eq(false) end it 'is false if the about me includes other text' do - user = mock_model(User, :about_me => "No spam at\n\nhttp://example.com") + user = mock_model(User, about_me: "No spam at\n\nhttp://example.com") expect(subject.about_me_is_link_only?(user)).to eq(false) end it 'is false if the about me includes other text' do - user = mock_model(User, :about_me => 'http://example.com no spam there') + user = mock_model(User, about_me: 'http://example.com no spam there') expect(subject.about_me_is_link_only?(user)).to eq(false) end it 'is case insensitive' do - user = mock_model(User, :about_me => 'HTTP://EXAMPLE.COM') + user = mock_model(User, about_me: 'HTTP://EXAMPLE.COM') expect(subject.about_me_is_link_only?(user)).to eq(true) end @@ -566,35 +566,35 @@ it 'is true if the about me matches a spammy format' do mock_spam_formats = [/\A.*+\n{2,}https?:\/\/[^\s]+\z/] - user = mock_model(User, :about_me => <<-EOF.strip_heredoc) + user = mock_model(User, about_me: <<-EOF.strip_heredoc) Some spam often looks like this spam http://www.example.org/ EOF - scorer = described_class.new(:spam_about_me_formats => mock_spam_formats) + scorer = described_class.new(spam_about_me_formats: mock_spam_formats) expect(scorer.about_me_is_spam_format?(user)).to eq(true) end it 'is false if the about me is not a spammy format' do mock_spam_formats = [/\A.*+\n{2,}https?:\/\/[^\s]+\z/] - user = mock_model(User, :about_me => 'No spam here') - scorer = described_class.new(:spam_about_me_formats => mock_spam_formats) + user = mock_model(User, about_me: 'No spam here') + scorer = described_class.new(spam_about_me_formats: mock_spam_formats) expect(scorer.about_me_is_spam_format?(user)).to eq(false) end it 'replaces \r\n with \n' do mock_spam_formats = [/\Aspam\nspam\z/] - user = mock_model(User, :about_me => <<-EOF.strip_heredoc) + user = mock_model(User, about_me: <<-EOF.strip_heredoc) spam\r\nspam EOF - scorer = described_class.new(:spam_about_me_formats => mock_spam_formats) + scorer = described_class.new(spam_about_me_formats: mock_spam_formats) expect(scorer.about_me_is_spam_format?(user)).to eq(true) end context 'the default spam formats' do it 'is true if it matches TEXT\n\nURL' do - user = mock_model(User, :about_me => <<-EOF.strip_heredoc) + user = mock_model(User, about_me: <<-EOF.strip_heredoc) Some spam often looks like this spam http://www.example.org/ @@ -603,7 +603,7 @@ end it 'is true if it matches URL\n\nTEXT' do - user = mock_model(User, :about_me => <<-EOF.strip_heredoc) + user = mock_model(User, about_me: <<-EOF.strip_heredoc) http://www.example.org/ Some spam often looks like this spam @@ -612,7 +612,7 @@ end it 'is true if it matches TEXT\n\nTEXT\n\nURL' do - user = mock_model(User, :about_me => <<-EOF.strip_heredoc) + user = mock_model(User, about_me: <<-EOF.strip_heredoc) Some spam often looks like this spam It even has some more spam @@ -629,12 +629,12 @@ describe '#about_me_includes_anchor_tag?' do it 'is true if the about me includes an a tag' do - user = mock_model(User, :about_me => 'Spam link here') + user = mock_model(User, about_me: 'Spam link here') expect(subject.about_me_includes_anchor_tag?(user)).to eq(true) end it 'is false if the about me does not include an a tag' do - user = mock_model(User, :about_me => 'No spam here') + user = mock_model(User, about_me: 'No spam here') expect(subject.about_me_includes_anchor_tag?(user)).to eq(false) end end @@ -642,12 +642,12 @@ describe '#about_me_already_exists?' do it 'is true if the about me already exists' do - user = mock_model(User, :about_me_already_exists? => true) + user = mock_model(User, about_me_already_exists?: true) expect(subject.about_me_already_exists?(user)).to eq(true) end it 'is false if the about me is unique to the user' do - user = mock_model(User, :about_me_already_exists? => false) + user = mock_model(User, about_me_already_exists?: false) expect(subject.about_me_already_exists?(user)).to eq(false) end @@ -659,12 +659,12 @@ after { UserSpamScorer.reset } it 'is true if the user agent matches' do - user = mock_model(User, :user_agent => 'cURL') + user = mock_model(User, user_agent: 'cURL') expect(subject.user_agent_is_suspicious?(user)).to eq(true) end it 'is false if the user agent does not match' do - user = mock_model(User, :user_agent => 'Firefox') + user = mock_model(User, user_agent: 'Firefox') expect(subject.user_agent_is_suspicious?(user)).to eq(false) end @@ -681,12 +681,12 @@ after { UserSpamScorer.reset } it 'is true if the IP address is within a suspicious range' do - user = mock_model(User, :ip => '127.0.0.1') + user = mock_model(User, ip: '127.0.0.1') expect(subject.ip_range_is_suspicious?(user)).to eq(true) end it 'is false if the IP address is not within a suspicious range' do - user = mock_model(User, :ip => '10.0.0.1') + user = mock_model(User, ip: '10.0.0.1') expect(subject.ip_range_is_suspicious?(user)).to eq(false) end diff --git a/spec/lib/user_stats_spec.rb b/spec/lib/user_stats_spec.rb index 8211bb9d41..39ed5af1b7 100644 --- a/spec/lib/user_stats_spec.rb +++ b/spec/lib/user_stats_spec.rb @@ -8,9 +8,9 @@ before do User.destroy_all - FactoryBot.create(:user, :email => "test1@localhost") - FactoryBot.create(:user, :email => "test2@localhost") - FactoryBot.create(:user, :email => "test@example.com") + FactoryBot.create(:user, email: "test1@localhost") + FactoryBot.create(:user, email: "test2@localhost") + FactoryBot.create(:user, email: "test@example.com") end let(:user_stats) { UserStats.list_user_domains } @@ -38,7 +38,7 @@ before do travel_to 1.week.ago - FactoryBot.create(:user, :email => "test@example.com") + FactoryBot.create(:user, email: "test@example.com") travel_back end @@ -47,7 +47,7 @@ { "domain" => "example.com", "count" => 1 } ] - expect(UserStats.list_user_domains(:start_date => 2.weeks.ago)). + expect(UserStats.list_user_domains(start_date: 2.weeks.ago)). to eq(expected) end @@ -56,15 +56,15 @@ context "when passed a limit" do before do - FactoryBot.create(:user, :email => "test@example.com") - FactoryBot.create(:user, :email => "test@yandex.com") - FactoryBot.create(:user, :email => "test@mail.ru") - FactoryBot.create(:user, :email => "test@hotmail.com") + FactoryBot.create(:user, email: "test@example.com") + FactoryBot.create(:user, email: "test@yandex.com") + FactoryBot.create(:user, email: "test@mail.ru") + FactoryBot.create(:user, email: "test@hotmail.com") end it "limits the length of the results" do expect(UserStats.list_user_domains.count).to eq(5) - expect(UserStats.list_user_domains(:limit => 4).count).to eq(4) + expect(UserStats.list_user_domains(limit: 4).count).to eq(4) end end @@ -74,20 +74,20 @@ describe ".count_dormant_users" do before do travel_to(2.weeks.ago) do - requester = FactoryBot.create(:user, :email => "active@example.com") - commenter = FactoryBot.create(:user, :email => "commenter@example.com") - tracker = FactoryBot.create(:user, :email => "tracker@example.com") - dormant = FactoryBot.create(:user, :email => "dormant1@example.com") - - request = FactoryBot.create(:info_request, :user => requester) - comment = FactoryBot.create(:comment, :body => "hi!", - :user => commenter, - :info_request => request) + requester = FactoryBot.create(:user, email: "active@example.com") + commenter = FactoryBot.create(:user, email: "commenter@example.com") + tracker = FactoryBot.create(:user, email: "tracker@example.com") + dormant = FactoryBot.create(:user, email: "dormant1@example.com") + + request = FactoryBot.create(:info_request, user: requester) + comment = FactoryBot.create(:comment, body: "hi!", + user: commenter, + info_request: request) track = FactoryBot.create(:search_track, - :tracking_user => tracker) + tracking_user: tracker) end - FactoryBot.create(:user, :email => "dormant2@example.com") + FactoryBot.create(:user, email: "dormant2@example.com") end it "returns the dormant user count for the domain" do @@ -108,13 +108,13 @@ describe ".unbanned_by_domain" do before do travel_to(1.month.ago) do - @user1 = FactoryBot.create(:user, :email => "test@example.com") + @user1 = FactoryBot.create(:user, email: "test@example.com") @banned = FactoryBot.create(:user, - :email => "banned@example.com", - :ban_text => "Banned") + email: "banned@example.com", + ban_text: "Banned") end - @user2 = FactoryBot.create(:user, :email => "newbie@example.com") - @admin = FactoryBot.create(:admin_user, :email => "admin@example.com") + @user2 = FactoryBot.create(:user, email: "newbie@example.com") + @admin = FactoryBot.create(:admin_user, email: "admin@example.com") end it "returns a list of eligible users" do diff --git a/spec/lib/yaml_compatability_spec.rb b/spec/lib/yaml_compatability_spec.rb deleted file mode 100644 index 96cd1ea1bc..0000000000 --- a/spec/lib/yaml_compatability_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -require 'spec_helper' -require Rails.root.join('lib/yaml_compatibility') - -RSpec.describe YAMLCompatibility do - describe '.load' do - subject(:output_hash) { described_class.load(content) } - let(:hash) { YAML.load(yaml_compatibility_fixture('5_1')) } - - context 'with Rails 4.2 YAML file' do - let(:content) { yaml_compatibility_fixture('4_2') } - - it 'correctly loads YAML file' do - is_expected.to eq hash unless rails_upgrade? - end - end - - context 'with Rails 5.0 YAML file' do - let(:content) { yaml_compatibility_fixture('5_0') } - - it 'correctly loads YAML file' do - is_expected.to eq hash - end - end - - context 'with Rails 5.1 YAML file' do - let(:content) { yaml_compatibility_fixture('5_1') } - - it 'correctly loads YAML file' do - is_expected.to eq hash - end - end - - context 'YAML file with old PublicBodyTag class' do - let(:content) { yaml_compatibility_fixture('public_body_tag') } - - it 'does not raise an error' do - expect { output_hash }.to_not raise_error - end - end - - context 'YAML file with old TMail classes' do - let(:content) { yaml_compatibility_fixture('tmail') } - - it 'does not raise an error' do - expect { output_hash }.to_not raise_error - end - end - end - - private - - def yaml_compatibility_fixture(file) - load_file_fixture("yaml_compatibility_#{file}.yml") - end -end diff --git a/spec/mailers/alaveteli_pro/embargo_mailer_spec.rb b/spec/mailers/alaveteli_pro/embargo_mailer_spec.rb index 74958b297e..c5de3f7499 100644 --- a/spec/mailers/alaveteli_pro/embargo_mailer_spec.rb +++ b/spec/mailers/alaveteli_pro/embargo_mailer_spec.rb @@ -103,7 +103,7 @@ AlaveteliPro::EmbargoMailer.alert_expiring mails = ActionMailer::Base.deliveries - mail = mails.detect { |mail| mail.to == [pro_user_3.email] } + mail = mails.detect { |m| m.to == [pro_user_3.email] } expect(mail).to be nil end end @@ -228,7 +228,7 @@ AlaveteliPro::EmbargoMailer.alert_expired mails = ActionMailer::Base.deliveries - mail = mails.detect { |mail| mail.to == [pro_user_3.email] } + mail = mails.detect { |m| m.to == [pro_user_3.email] } expect(mail).to be nil end end diff --git a/spec/mailers/alaveteli_pro/metrics_mailer_spec.rb b/spec/mailers/alaveteli_pro/metrics_mailer_spec.rb index 2bae4737b1..4e8ae6b05c 100644 --- a/spec/mailers/alaveteli_pro/metrics_mailer_spec.rb +++ b/spec/mailers/alaveteli_pro/metrics_mailer_spec.rb @@ -15,17 +15,11 @@ trialing_users: 8, past_due_users: { count: 0, subs: 0 }, pending_cancellations: - { count: 2, subs: ['sub_1234', 'sub_1235'] }, + { count: 2, subs: %w[sub_1234 sub_1235] }, unknown_users: 0, new_and_returning_users: { count: 6, - subs: - ['sub_1236', - 'sub_1237', - 'sub_1238', - 'sub_1239', - 'sub_1240', - 'sub_1241'] }, + subs: %w[sub_1236 sub_1237 sub_1238 sub_1239 sub_1240 sub_1241] }, canceled_users: { count: 0, subs: [] } } end diff --git a/spec/mailers/application_mailer_spec.rb b/spec/mailers/application_mailer_spec.rb index e615a041dc..dff823ad87 100644 --- a/spec/mailers/application_mailer_spec.rb +++ b/spec/mailers/application_mailer_spec.rb @@ -7,7 +7,7 @@ def set_base_views ApplicationMailer.class_eval do - @previous_view_paths = self.view_paths.dup + @previous_view_paths = view_paths.dup self.view_paths = [File.join(Rails.root, 'spec', 'fixtures', 'theme_views', 'core')] end end @@ -54,7 +54,7 @@ def create_multipart_method(method_name) before do set_base_views - add_mail_methods(['simple', 'theme_only', 'core_only', 'neither']) + add_mail_methods(%w[simple theme_only core_only neither]) end describe 'when a plugin prepends its mail templates to the view paths' do @@ -153,7 +153,7 @@ def create_multipart_method(method_name) after do reset_views - remove_mail_methods(['simple', 'theme_only', 'core_only', 'neither', 'multipart']) + remove_mail_methods(%w[simple theme_only core_only neither multipart]) end end diff --git a/spec/mailers/info_request_batch_mailer_spec.rb b/spec/mailers/info_request_batch_mailer_spec.rb index 57e579ba05..83e1edb89e 100644 --- a/spec/mailers/info_request_batch_mailer_spec.rb +++ b/spec/mailers/info_request_batch_mailer_spec.rb @@ -19,7 +19,7 @@ end it "does not add HTMLEntities to the subject line" do - batch = FactoryBot.create(:info_request_batch, :title => "Apostrophe's") + batch = FactoryBot.create(:info_request_batch, title: "Apostrophe's") mail = InfoRequestBatchMailer.batch_sent(batch, @unrequestable, @user) expect(mail.subject). to eq('Your batch request "Apostrophe\'s" has been sent') diff --git a/spec/mailers/notification_mailer_spec.rb b/spec/mailers/notification_mailer_spec.rb index 69d8e6c3e5..06dc28f7ec 100644 --- a/spec/mailers/notification_mailer_spec.rb +++ b/spec/mailers/notification_mailer_spec.rb @@ -380,7 +380,7 @@ it "sets the right subject line" do mail = NotificationMailer.daily_summary(user, all_notifications) expect(mail.subject). - to eq ("Your daily request summary from Alaveteli Professional") + to eq("Your daily request summary from Alaveteli Professional") end it "matches the expected message" do diff --git a/spec/mailers/outgoing_mailer_spec.rb b/spec/mailers/outgoing_mailer_spec.rb index ef7b6035a2..ea9ccf30b8 100644 --- a/spec/mailers/outgoing_mailer_spec.rb +++ b/spec/mailers/outgoing_mailer_spec.rb @@ -4,12 +4,12 @@ before do @info_request = mock_model(InfoRequest, - :recipient_name_and_email => 'test ', - :recipient_email => 'test@example.com') + recipient_name_and_email: 'test ', + recipient_email: 'test@example.com') allow(@info_request).to receive_message_chain(:public_body, :name).and_return("Test Authority") @incoming_message = mock_model(IncomingMessage, - :from_email => 'specific@example.com', - :safe_from_name => 'Specific Person') + from_email: 'specific@example.com', + safe_from_name: 'Specific Person') end describe 'if there is no incoming message being replied to' do @@ -67,14 +67,14 @@ ir = info_requests(:fancy_dog_request) im = ir.incoming_messages[0] - expect(ir.email_subject_request(:html => false)).to eq("Freedom of Information request - Why do you have & such a fancy dog?") + expect(ir.email_subject_request(html: false)).to eq("Freedom of Information request - Why do you have & such a fancy dog?") end it "should use 'Re:' and inital request subject for followups which aren't replies to particular messages" do ir = info_requests(:fancy_dog_request) om = outgoing_messages(:useless_outgoing_message) - expect(OutgoingMailer.subject_for_followup(ir, om, :html => false)).to eq("Re: Freedom of Information request - Why do you have & such a fancy dog?") + expect(OutgoingMailer.subject_for_followup(ir, om, html: false)).to eq("Re: Freedom of Information request - Why do you have & such a fancy dog?") end it "should prefix with Re: the subject of the message being replied to" do @@ -83,7 +83,7 @@ om = outgoing_messages(:useless_outgoing_message) om.incoming_message_followup = im - expect(OutgoingMailer.subject_for_followup(ir, om, :html => false)).to eq("Re: Geraldine FOI Code AZXB421") + expect(OutgoingMailer.subject_for_followup(ir, om, html: false)).to eq("Re: Geraldine FOI Code AZXB421") end it "should not add Re: prefix if there already is such a prefix" do @@ -93,7 +93,7 @@ om.incoming_message_followup = im im.raw_email.data = im.raw_email.data.sub("Subject: Geraldine FOI Code AZXB421", "Subject: Re: Geraldine FOI Code AZXB421") - expect(OutgoingMailer.subject_for_followup(ir, om, :html => false)).to eq("Re: Geraldine FOI Code AZXB421") + expect(OutgoingMailer.subject_for_followup(ir, om, html: false)).to eq("Re: Geraldine FOI Code AZXB421") end it "should not add Re: prefix if there already is a lower case re: prefix" do @@ -105,7 +105,7 @@ im.raw_email.data = im.raw_email.data.sub("Subject: Geraldine FOI Code AZXB421", "Subject: re: Geraldine FOI Code AZXB421") im.parse_raw_email! true - expect(OutgoingMailer.subject_for_followup(ir, om, :html => false)).to eq("re: Geraldine FOI Code AZXB421") + expect(OutgoingMailer.subject_for_followup(ir, om, html: false)).to eq("re: Geraldine FOI Code AZXB421") end it "should use 'Re:' and initial request subject when replying to failed delivery notifications" do @@ -118,7 +118,7 @@ im.raw_email.data = im.raw_email.data.sub("Subject: Geraldine FOI Code AZXB421", "Subject: Delivery Failed") im.parse_raw_email! true - expect(OutgoingMailer.subject_for_followup(ir, om, :html => false)).to eq("Re: Freedom of Information request - Why do you have & such a fancy dog?") + expect(OutgoingMailer.subject_for_followup(ir, om, html: false)).to eq("Re: Freedom of Information request - Why do you have & such a fancy dog?") end context "dealing with an internal review" do @@ -126,7 +126,7 @@ it "prefixes the subject of the message with 'Internal review of " \ "Freedom of Information request'" do request = FactoryBot.create(:info_request_with_internal_review_request, - :title => "Test") + title: "Test") expect(OutgoingMailer.subject_for_followup( request, request.outgoing_messages.last)). @@ -135,7 +135,7 @@ it "does not add HTMLEntities to the subject of the message" do request = FactoryBot.create(:info_request_with_internal_review_request, - :title => "Apostrophe's Test") + title: "Apostrophe's Test") expect(OutgoingMailer.subject_for_followup( request, request.outgoing_messages.last)). diff --git a/spec/mailers/previews/alaveteli_pro/metrics_mailer_preview.rb b/spec/mailers/previews/alaveteli_pro/metrics_mailer_preview.rb index e73933c7eb..ab966e3760 100644 --- a/spec/mailers/previews/alaveteli_pro/metrics_mailer_preview.rb +++ b/spec/mailers/previews/alaveteli_pro/metrics_mailer_preview.rb @@ -6,7 +6,7 @@ def weekly_report data = { new_pro_requests: 104, - estimated_total_pro_requests: 37535, + estimated_total_pro_requests: 37_535, new_batches: 3, new_signups: 5, total_accounts: 284, @@ -17,17 +17,17 @@ def weekly_report trialing_users: 8, past_due_users: { count: 0, subs: 0 }, pending_cancellations: - { count: 2, subs: ['sub_1234', 'sub_1235'] }, + { count: 2, subs: %w[sub_1234 sub_1235] }, unknown_users: 0, new_and_returning_users: { count: 6, subs: - ['sub_1236', - 'sub_1237', - 'sub_1238', - 'sub_1239', - 'sub_1240', - 'sub_1241'] }, + %w[sub_1236 + sub_1237 + sub_1238 + sub_1239 + sub_1240 + sub_1241] }, canceled_users: { count: 0, subs: [] } } diff --git a/spec/mailers/request_mailer_spec.rb b/spec/mailers/request_mailer_spec.rb index e5ae6c0cd1..0006521b2f 100644 --- a/spec/mailers/request_mailer_spec.rb +++ b/spec/mailers/request_mailer_spec.rb @@ -36,7 +36,7 @@ deliveries = ActionMailer::Base.deliveries expect(deliveries.size).to eq(1) mail = deliveries[0] - expect(mail.to).to eq([ AlaveteliConfiguration::contact_email ]) + expect(mail.to).to eq([ AlaveteliConfiguration.contact_email ]) deliveries.clear end @@ -86,7 +86,7 @@ deliveries = ActionMailer::Base.deliveries expect(deliveries.size).to eq(1) mail = deliveries[0] - expect(mail.to).to eq([ AlaveteliConfiguration::contact_email ]) + expect(mail.to).to eq([ AlaveteliConfiguration.contact_email ]) deliveries.clear end @@ -106,7 +106,7 @@ deliveries = ActionMailer::Base.deliveries expect(deliveries.size).to eq(1) mail = deliveries[0] - expect(mail.to).to eq([ AlaveteliConfiguration::contact_email ]) + expect(mail.to).to eq([ AlaveteliConfiguration.contact_email ]) deliveries.clear end @@ -126,7 +126,7 @@ deliveries = ActionMailer::Base.deliveries expect(deliveries.size).to eq(1) mail = deliveries[0] - expect(mail.to).to eq([ AlaveteliConfiguration::contact_email ]) + expect(mail.to).to eq([ AlaveteliConfiguration.contact_email ]) deliveries.clear end @@ -233,7 +233,7 @@ deliveries = ActionMailer::Base.deliveries expect(deliveries.size).to eq(1) mail = deliveries[0] - expect(mail.to).to eq([ AlaveteliConfiguration::contact_email ]) + expect(mail.to).to eq([ AlaveteliConfiguration.contact_email ]) deliveries.clear end @@ -286,7 +286,7 @@ info_request = FactoryBot.create(:info_request_with_incoming) mail = RequestMailer. fake_response(info_request, - mock_model(User, :name_and_email => "test"), + mock_model(User, name_and_email: "test"), "The body of the email...", "blah.txt", "The content of blah.txt") @@ -308,10 +308,10 @@ def send_alerts end def sent_alert_params(request, type) - {:info_request_id => request.id, - :user_id => request.user.id, - :info_request_event_id => request.get_last_public_response_event_id, - :alert_type => type} + {info_request_id: request.id, + user_id: request.user.id, + info_request_event_id: request.get_last_public_response_event_id, + alert_type: type} end it 'should raise an error if a request does not have a last response event id' do @@ -325,7 +325,7 @@ def sent_alert_params(request, type) context 'if the request is embargoed' do it 'sends the reminder' do - old_request.create_embargo(:publish_at => Time.zone.now + 3.days) + old_request.create_embargo(publish_at: Time.zone.now + 3.days) send_alerts deliveries = ActionMailer::Base.deliveries mail = deliveries[0] @@ -382,16 +382,16 @@ def sent_alert_params(request, type) describe "when sending mail when someone has updated an old unclassified request" do let(:user) do - FactoryBot.create(:user, :name => "test name", :email => "email@localhost") + FactoryBot.create(:user, name: "test name", email: "email@localhost") end - let(:public_body) { FactoryBot.create(:public_body, :name => "Test public body") } + let(:public_body) { FactoryBot.create(:public_body, name: "Test public body") } let(:info_request) do - FactoryBot.create(:info_request, :user => user, - :title => "Test request", - :public_body => public_body, - :url_title => "test_request") + FactoryBot.create(:info_request, user: user, + title: "Test request", + public_body: public_body, + url_title: "test_request") end let(:mail) { RequestMailer.old_unclassified_updated(info_request) } @@ -417,12 +417,12 @@ def sent_alert_params(request, type) describe "when generating a fake response for an upload" do before do - @foi_officer = mock_model(User, :name_and_email => "FOI officer's name and email") + @foi_officer = mock_model(User, name_and_email: "FOI officer's name and email") @request_user = mock_model(User) - @public_body = mock_model(PublicBody, :name => 'Test public body') - @info_request = mock_model(InfoRequest, :user => @request_user, - :email_subject_followup => 'Re: Freedom of Information - Test request', - :incoming_name_and_email => 'Someone ') + @public_body = mock_model(PublicBody, name: 'Test public body') + @info_request = mock_model(InfoRequest, user: @request_user, + email_subject_followup: 'Re: Freedom of Information - Test request', + incoming_name_and_email: 'Someone ') end it 'should should generate a "fake response" email with a reasonable subject line' do @@ -439,25 +439,25 @@ def sent_alert_params(request, type) describe "when sending a new response email" do let(:user) do - FactoryBot.create(:user, :name => "test name", - :email => "email@localhost") + FactoryBot.create(:user, name: "test name", + email: "email@localhost") end let(:public_body) do - FactoryBot.create(:public_body, :name => "Test public body") + FactoryBot.create(:public_body, name: "Test public body") end let(:info_request) do FactoryBot.create(:info_request, - :user => user, - :title => "Here is a character that needs quoting …", - :public_body => public_body, - :described_state => 'rejected', - :url_title => "test_request") + user: user, + title: "Here is a character that needs quoting …", + public_body: public_body, + described_state: 'rejected', + url_title: "test_request") end let(:incoming_message) do - FactoryBot.create(:incoming_message, :info_request => info_request) + FactoryBot.create(:incoming_message, info_request: info_request) end it 'should not error when sending mails requests with characters requiring quoting in the subject' do @@ -465,7 +465,7 @@ def sent_alert_params(request, type) end it 'should not create HTML entities in the subject line' do - mail = RequestMailer.new_response(FactoryBot.create(:info_request, :title => "Here's a request"), FactoryBot.create(:incoming_message)) + mail = RequestMailer.new_response(FactoryBot.create(:info_request, title: "Here's a request"), FactoryBot.create(:incoming_message)) expect(mail.subject).to eq "New response to your FOI request - Here's a request" end @@ -478,7 +478,7 @@ def sent_alert_params(request, type) mail.body.to_s =~ /(http:\/\/.*)/ mail_url = $1 - message_url = incoming_message_url(incoming_message, :cachebust => true) + message_url = incoming_message_url(incoming_message, cachebust: true) expected_url = signin_url(r: message_url) expect(mail_url).to eq expected_url end @@ -487,7 +487,7 @@ def sent_alert_params(request, type) mail = RequestMailer.new_response(info_request, incoming_message) mail.body.to_s =~ /(http:\/\/\S*)/ mail_url = $1 - expected_url = incoming_message_url(incoming_message, :cachebust => true) + expected_url = incoming_message_url(incoming_message, cachebust: true) expect(mail_url).to eq expected_url end @@ -527,15 +527,15 @@ def sent_alert_params(request, type) describe "requires_admin" do let(:user) do - FactoryBot.create(:user, :name => "Bruce Jones", - :email => "bruce@example.com") + FactoryBot.create(:user, name: "Bruce Jones", + email: "bruce@example.com") end let(:info_request) do - FactoryBot.create(:info_request, :user => user, - :title => "It's a Test request", - :url_title => "test_request", - :id => 123) + FactoryBot.create(:info_request, user: user, + title: "It's a Test request", + url_title: "test_request", + id: 123) end before do @@ -586,11 +586,11 @@ def sent_alert_params(request, type) end - describe "sending overdue request alerts", :focus => true do + describe "sending overdue request alerts", focus: true do before(:each) do @kitten_request = FactoryBot.create(:info_request, - :title => "Do you really own a kitten?") + title: "Do you really own a kitten?") end def kitten_mails @@ -599,7 +599,7 @@ def kitten_mails it 'should not create HTML entities in the subject line' do info_request = FactoryBot.create(:info_request, - :title => "Here's a request") + title: "Here's a request") mail = RequestMailer.overdue_alert(info_request, info_request.user) expect(mail.subject).to eq "Delayed response to your FOI request - Here's a request" end @@ -627,11 +627,11 @@ def kitten_mails user = @kitten_request.user user.ban_text = 'Banned' user.save! - expect(UserInfoRequestSentAlert.where(:user_id => user.id).count).to eq(0) + expect(UserInfoRequestSentAlert.where(user_id: user.id).count).to eq(0) RequestMailer.alert_overdue_requests expect(kitten_mails.size).to eq(0) - expect(UserInfoRequestSentAlert.where(:user_id => user.id).count).to be > 0 + expect(UserInfoRequestSentAlert.where(user_id: user.id).count).to be > 0 end end @@ -652,11 +652,11 @@ def kitten_mails @kitten_request.set_described_state('waiting_clarification') # Followup message is sent - outgoing_message = OutgoingMessage.new(:status => 'ready', - :message_type => 'followup', - :info_request_id => @kitten_request.id, - :body => 'Some text', - :what_doing => 'normal_sort') + outgoing_message = OutgoingMessage.new(status: 'ready', + message_type: 'followup', + info_request_id: @kitten_request.id, + body: 'Some text', + what_doing: 'normal_sort') outgoing_message.sendable? mail_message = OutgoingMailer.followup( @@ -710,7 +710,7 @@ def kitten_mails it 'should not create HTML entities in the subject line' do info_request = FactoryBot.create(:info_request, - :title => "Here's a request") + title: "Here's a request") mail = RequestMailer.very_overdue_alert(info_request, info_request.user) expect(mail.subject).to eq "You're long overdue a response " \ @@ -769,7 +769,7 @@ def kitten_mails describe "not_clarified_alert" do it 'should not create HTML entities in the subject line' do - mail = RequestMailer.not_clarified_alert(FactoryBot.create(:info_request, :title => "Here's a request"), FactoryBot.create(:incoming_message)) + mail = RequestMailer.not_clarified_alert(FactoryBot.create(:info_request, title: "Here's a request"), FactoryBot.create(:incoming_message)) expect(mail.subject).to eq "Clarify your FOI request - Here's a request" end @@ -778,7 +778,7 @@ def kitten_mails describe "comment_on_alert" do it 'should not create HTML entities in the subject line' do - mail = RequestMailer.comment_on_alert(FactoryBot.create(:info_request, :title => "Here's a request"), FactoryBot.create(:comment)) + mail = RequestMailer.comment_on_alert(FactoryBot.create(:info_request, title: "Here's a request"), FactoryBot.create(:comment)) expect(mail.subject).to eq "Somebody added a note to your FOI request - Here's a request" end @@ -787,7 +787,7 @@ def kitten_mails describe "comment_on_alert_plural" do it 'should not create HTML entities in the subject line' do - mail = RequestMailer.comment_on_alert_plural(FactoryBot.create(:info_request, :title => "Here's a request"), 2, FactoryBot.create(:comment)) + mail = RequestMailer.comment_on_alert_plural(FactoryBot.create(:info_request, title: "Here's a request"), 2, FactoryBot.create(:comment)) expect(mail.subject).to eq "Some notes have been added to your FOI request - Here's a request" end @@ -819,8 +819,8 @@ def force_updated_at_to_past(request) mail_url = $1 expect(mail_url). - to match(new_request_incoming_followup_path(:request_id => ir.id, - :incoming_message_id => ir.incoming_messages.last.id)) + to match(new_request_incoming_followup_path(request_id: ir.id, + incoming_message_id: ir.incoming_messages.last.id)) end it "skips requests that don't have a public last response" do diff --git a/spec/mailers/track_mailer_spec.rb b/spec/mailers/track_mailer_spec.rb index fcb7f8344f..4d4d9195fd 100644 --- a/spec/mailers/track_mailer_spec.rb +++ b/spec/mailers/track_mailer_spec.rb @@ -74,31 +74,31 @@ before do @track_things_sent_emails_array = [] allow(@track_things_sent_emails_array).to receive(:where).and_return([]) # this is for the date range find (created in last 14 days) - @track_thing = mock_model(TrackThing, :track_query => 'test query', - :track_things_sent_emails => @track_things_sent_emails_array, - :created_at => Time.utc(2007, 11, 9, 23, 59)) + @track_thing = mock_model(TrackThing, track_query: 'test query', + track_things_sent_emails: @track_things_sent_emails_array, + created_at: Time.utc(2007, 11, 9, 23, 59)) allow(TrackThing).to receive(:where).and_return([@track_thing]) @track_things_sent_email = mock_model(TrackThingsSentEmail, :save! => true, :track_thing_id= => true, :info_request_event_id= => true) allow(TrackThingsSentEmail).to receive(:new).and_return(@track_things_sent_email) - @xapian_search = double('xapian search', :results => []) - @found_event = mock_model(InfoRequestEvent, :described_at => @track_thing.created_at + 1.day) - @search_result = {:model => @found_event} + @xapian_search = double('xapian search', results: []) + @found_event = mock_model(InfoRequestEvent, described_at: @track_thing.created_at + 1.day) + @search_result = {model: @found_event} allow(ActsAsXapian::Search).to receive(:new).and_return(@xapian_search) end it 'should ask for the events returned by the tracking query' do expect(ActsAsXapian::Search).to receive(:new).with([InfoRequestEvent], 'test query', - :sort_by_prefix => 'described_at', - :sort_by_ascending => true, - :collapse_by_prefix => nil, - :limit => 100).and_return(@xapian_search) + sort_by_prefix: 'described_at', + sort_by_ascending: true, + collapse_by_prefix: nil, + limit: 100).and_return(@xapian_search) TrackMailer.alert_tracks end it 'should not include in the email any events that the user has already been sent a tracking email about' do - sent_email = mock_model(TrackThingsSentEmail, :info_request_event_id => @found_event.id) + sent_email = mock_model(TrackThingsSentEmail, info_request_event_id: @found_event.id) allow(@track_things_sent_emails_array).to receive(:where).and_return([sent_email]) # this is for the date range find (created in last 14 days) allow(@xapian_search).to receive(:results).and_return([@search_result]) expect(TrackMailer).not_to receive(:event_digest) @@ -120,7 +120,7 @@ end it 'should raise an error if a non-event class is returned by the tracking query' do - allow(@xapian_search).to receive(:results).and_return([{:model => 'string class'}]) + allow(@xapian_search).to receive(:results).and_return([{model: 'string class'}]) expect { TrackMailer.alert_tracks }.to raise_error('need to add other types to TrackMailer.alert_tracks (unalerted)') end @@ -186,13 +186,13 @@ before :each do allow(AlaveteliConfiguration).to receive(:site_name). and_return("L'information") - @post_redirect = mock_model(PostRedirect, :save! => true, - :email_token => "token") + @post_redirect = mock_model(PostRedirect, save!: true, + email_token: "token") allow(PostRedirect).to receive(:new).and_return(@post_redirect) ActionMailer::Base.deliveries = [] @user = mock_model(User, - :name_and_email => MailHandler.address_from_name_and_email('Tippy Test', 'tippy@localhost'), - :url_name => 'tippy_test' + name_and_email: MailHandler.address_from_name_and_email('Tippy Test', 'tippy@localhost'), + url_name: 'tippy_test' ) TrackMailer.event_digest(@user, []).deliver_now # no items in it email for minimal test end diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index a6e547d36f..293184420a 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -1404,7 +1404,7 @@ context "when the comment's request is embargoed" do let(:info_request) { FactoryBot.create(:embargoed_request) } let(:comment) { FactoryBot.create(:comment, - :info_request => info_request) } + info_request: info_request) } it 'allows a pro admin user to administer' do with_feature_enabled(:alaveteli_pro) do @@ -1446,7 +1446,7 @@ context 'when the request is not embargoed' do let(:info_request) { FactoryBot.create(:info_request) } let(:comment) { FactoryBot.create(:comment, - :info_request => info_request) } + info_request: info_request) } it 'allows a pro admin user to administer' do with_feature_enabled(:alaveteli_pro) do diff --git a/spec/models/alaveteli_pro/activity_list/comment_spec.rb b/spec/models/alaveteli_pro/activity_list/comment_spec.rb index 5715617175..4602cc5094 100644 --- a/spec/models/alaveteli_pro/activity_list/comment_spec.rb +++ b/spec/models/alaveteli_pro/activity_list/comment_spec.rb @@ -4,8 +4,8 @@ include Rails.application.routes.url_helpers let!(:user) { FactoryBot.create(:user) } - let!(:comment) { FactoryBot.create(:comment, :user => user) } - let!(:event) { FactoryBot.create(:comment_event, :comment => comment) } + let!(:comment) { FactoryBot.create(:comment, user: user) } + let!(:event) { FactoryBot.create(:comment_event, comment: comment) } let!(:activity) { described_class.new(event) } describe '#description' do @@ -33,15 +33,12 @@ :info_request_title' do expected_urls = { - :commenter_name => - { :text => user.name, - :url => user_path(user) }, - :public_body_name => - { :text => event.info_request.public_body.name, - :url => public_body_path(event.info_request.public_body) }, - :info_request_title => - { :text => event.info_request.title, - :url => request_path(event.info_request) } + commenter_name: { text: user.name, + url: user_path(user) }, + public_body_name: { text: event.info_request.public_body.name, + url: public_body_path(event.info_request.public_body) }, + info_request_title: { text: event.info_request.title, + url: request_path(event.info_request) } } expect(activity.description_urls). to eq expected_urls diff --git a/spec/models/alaveteli_pro/activity_list/embargo_expiry_spec.rb b/spec/models/alaveteli_pro/activity_list/embargo_expiry_spec.rb index 78808626ec..dae38eec68 100644 --- a/spec/models/alaveteli_pro/activity_list/embargo_expiry_spec.rb +++ b/spec/models/alaveteli_pro/activity_list/embargo_expiry_spec.rb @@ -4,8 +4,8 @@ include Rails.application.routes.url_helpers let!(:user) { FactoryBot.create(:user) } - let!(:info_request) { FactoryBot.create(:info_request, :user => user) } - let!(:event) { FactoryBot.create(:expire_embargo_event, :info_request => info_request) } + let!(:info_request) { FactoryBot.create(:info_request, user: user) } + let!(:event) { FactoryBot.create(:expire_embargo_event, info_request: info_request) } let!(:activity) { described_class.new(event) } describe '#description' do diff --git a/spec/models/alaveteli_pro/activity_list/list_spec.rb b/spec/models/alaveteli_pro/activity_list/list_spec.rb index 6f6c36184b..4b317973d6 100644 --- a/spec/models/alaveteli_pro/activity_list/list_spec.rb +++ b/spec/models/alaveteli_pro/activity_list/list_spec.rb @@ -37,9 +37,9 @@ it "returns the user's info_request_events if included in the event types" do user = FactoryBot.create(:user) - info_request = FactoryBot.create(:info_request, :user => user) + info_request = FactoryBot.create(:info_request, user: user) edit_event = FactoryBot.create(:edit_event, - :info_request => info_request) + info_request: info_request) list = described_class.new(user, 1, 10) expect(list.events). to eq([info_request.last_event_forming_initial_request]) @@ -51,13 +51,13 @@ it 'returns an array of items representing the current page of events' do user = FactoryBot.create(:user) - info_request = FactoryBot.create(:info_request, :user => user) + info_request = FactoryBot.create(:info_request, user: user) response_event = FactoryBot.create(:response_event, - :info_request => info_request) + info_request: info_request) comment_event = FactoryBot.create(:comment_event, - :info_request => info_request) + info_request: info_request) resent_event = FactoryBot.create(:resent_event, - :info_request => info_request) + info_request: info_request) list = described_class.new(user, 1, 2) expect(list.current_items.first). to be_a(AlaveteliPro::ActivityList::RequestResent) diff --git a/spec/models/alaveteli_pro/activity_list/overdue_spec.rb b/spec/models/alaveteli_pro/activity_list/overdue_spec.rb index 13ee30dcef..f106a02c5c 100644 --- a/spec/models/alaveteli_pro/activity_list/overdue_spec.rb +++ b/spec/models/alaveteli_pro/activity_list/overdue_spec.rb @@ -30,8 +30,8 @@ it 'returns the url of the info_request' do expect(activity.call_to_action_url). - to eq new_request_followup_path(:request_id => event.info_request.id, - :anchor => 'followup') + to eq new_request_followup_path(request_id: event.info_request.id, + anchor: 'followup') end end diff --git a/spec/models/alaveteli_pro/activity_list/very_overdue_spec.rb b/spec/models/alaveteli_pro/activity_list/very_overdue_spec.rb index 516e7559a2..625a504d92 100644 --- a/spec/models/alaveteli_pro/activity_list/very_overdue_spec.rb +++ b/spec/models/alaveteli_pro/activity_list/very_overdue_spec.rb @@ -30,9 +30,9 @@ it 'returns the url of the info_request' do expect(activity.call_to_action_url). - to eq new_request_followup_path(:request_id => event.info_request.id, - :anchor => 'followup', - :internal_review => 1) + to eq new_request_followup_path(request_id: event.info_request.id, + anchor: 'followup', + internal_review: 1) end end diff --git a/spec/models/alaveteli_pro/draft_info_request_batch_spec.rb b/spec/models/alaveteli_pro/draft_info_request_batch_spec.rb index 1271a1bd65..f1aaeb2ecf 100644 --- a/spec/models/alaveteli_pro/draft_info_request_batch_spec.rb +++ b/spec/models/alaveteli_pro/draft_info_request_batch_spec.rb @@ -35,13 +35,13 @@ end it "it imposes an alphabetical sort order on associated public bodies" do - public_body1 = FactoryBot.create(:public_body, :name => "Body 1") - public_body2 = FactoryBot.create(:public_body, :name => "A Public Body") + public_body1 = FactoryBot.create(:public_body, name: "Body 1") + public_body2 = FactoryBot.create(:public_body, name: "A Public Body") draft = FactoryBot.create(:draft_info_request_batch, - :public_bodies => [public_body1, public_body2], - :user => pro_user) + public_bodies: [public_body1, public_body2], + user: pro_user) draft.reload - expect(draft.public_bodies).to eq ([public_body2, public_body1]) + expect(draft.public_bodies).to eq([public_body2, public_body1]) end it 'returns a distinct list of associated public bodies' do diff --git a/spec/models/alaveteli_pro/embargo_spec.rb b/spec/models/alaveteli_pro/embargo_spec.rb index b5aeff5720..288f12d182 100644 --- a/spec/models/alaveteli_pro/embargo_spec.rb +++ b/spec/models/alaveteli_pro/embargo_spec.rb @@ -14,7 +14,7 @@ require 'spec_helper' -RSpec.describe AlaveteliPro::Embargo, :type => :model do +RSpec.describe AlaveteliPro::Embargo, type: :model do let(:embargo) { FactoryBot.create(:embargo) } it 'belongs to an info_request' do @@ -143,12 +143,12 @@ describe 'expiring scope' do it 'includes embargoes expiring in less than a week' do - embargo = FactoryBot.create(:embargo, :publish_at => Time.now + 6.days) + embargo = FactoryBot.create(:embargo, publish_at: Time.now + 6.days) expect(AlaveteliPro::Embargo.expiring.include?(embargo)).to be true end it 'excludes embargoes expiring in more than a week' do - embargo = FactoryBot.create(:embargo, :publish_at => Time.now + 8.days) + embargo = FactoryBot.create(:embargo, publish_at: Time.now + 8.days) expect(AlaveteliPro::Embargo.expiring.include?(embargo)).to be false end @@ -158,25 +158,25 @@ it 'returns true if the embargo expires in less than a week' do embargo = FactoryBot.build(:embargo, - :publish_at => Time.zone.now + 6.days) + publish_at: Time.zone.now + 6.days) expect(embargo.expiring_soon?).to be true end it 'returns true if the embargo expires in a week' do embargo = FactoryBot.build(:embargo, - :publish_at => Time.zone.now + 7.days) + publish_at: Time.zone.now + 7.days) expect(embargo.expiring_soon?).to be true end it 'returns false if the embargo expires in more than a week' do embargo = FactoryBot.build(:embargo, - :publish_at => Time.zone.now + 8.days) + publish_at: Time.zone.now + 8.days) expect(embargo.expiring_soon?).to be false end it 'returns false if the embargo has already expired' do embargo = FactoryBot.build(:embargo, - :publish_at => Time.zone.now.beginning_of_day) + publish_at: Time.zone.now.beginning_of_day) expect(embargo.expiring_soon?).to be false end @@ -186,18 +186,18 @@ it 'returns false if the publication date is in the future' do embargo = FactoryBot.build(:embargo, - :publish_at => Time.zone.now + 1.day) + publish_at: Time.zone.now + 1.day) expect(embargo.expired?).to be false end it 'returns true if the publication date is in the past' do embargo = FactoryBot.build(:embargo, - :publish_at => Time.zone.now - 1.day) + publish_at: Time.zone.now - 1.day) expect(embargo.expired?).to be true end it 'returns true on the publication date' do - embargo = FactoryBot.build(:embargo, :publish_at => Time.zone.now) + embargo = FactoryBot.build(:embargo, publish_at: Time.zone.now) expect(embargo.expired?).to be true end @@ -217,7 +217,7 @@ expiry_events = info_request. reload. info_request_events. - where(:event_type => 'expire_embargo') + where(event_type: 'expire_embargo') expect(expiry_events.size).to eq 1 end diff --git a/spec/models/alaveteli_pro/request_filter_spec.rb b/spec/models/alaveteli_pro/request_filter_spec.rb index 8082f2656f..046cadfdc3 100644 --- a/spec/models/alaveteli_pro/request_filter_spec.rb +++ b/spec/models/alaveteli_pro/request_filter_spec.rb @@ -6,25 +6,25 @@ it 'assigns the filter' do request_filter = described_class.new - request_filter.update(:filter => 'awaiting_response') + request_filter.update(filter: 'awaiting_response') expect(request_filter.filter).to eq 'awaiting_response' end it 'assigns the search' do request_filter = described_class.new - request_filter.update(:search => 'lazy dog') + request_filter.update(search: 'lazy dog') expect(request_filter.search).to eq 'lazy dog' end it 'assigns the order' do request_filter = described_class.new - request_filter.update(:order => 'created_at_asc') + request_filter.update(order: 'created_at_asc') expect(request_filter.order).to eq 'created_at_asc' end it 'does not assign an empty filter' do request_filter = described_class.new - request_filter.update(:filter => '') + request_filter.update(filter: '') expect(request_filter.filter).to be nil end @@ -34,7 +34,7 @@ def expect_label(label, filter) request_filter = described_class.new - request_filter.update(:filter => filter) + request_filter.update(filter: filter) expect(request_filter.filter_capital_label).to eq label end @@ -76,7 +76,7 @@ def expect_label(label, filter) def expect_label(label, filter) request_filter = described_class.new - request_filter.update(:filter => filter) + request_filter.update(filter: filter) expect(request_filter.filter_label).to eq label end @@ -138,8 +138,8 @@ def expect_label(label, filter) context 'when no attributes are supplied' do it 'sorts the requests by most recently updated' do - first_request = FactoryBot.create(:info_request, :user => user) - second_request = FactoryBot.create(:info_request, :user => user) + first_request = FactoryBot.create(:info_request, user: user) + second_request = FactoryBot.create(:info_request, user: user) request_filter = described_class.new expected = [second_request.request_summary, diff --git a/spec/models/alaveteli_pro/request_summary_spec.rb b/spec/models/alaveteli_pro/request_summary_spec.rb index d6b159511c..30da118b53 100644 --- a/spec/models/alaveteli_pro/request_summary_spec.rb +++ b/spec/models/alaveteli_pro/request_summary_spec.rb @@ -96,7 +96,7 @@ expect(updated_summary.title).to eq batch.title expect(updated_summary.body).to eq batch.body expect(updated_summary.public_body_names). - to match /.*#{public_body.name}.*/ + to match(/.*#{public_body.name}.*/) expect(updated_summary.summarisable).to eq batch expect(updated_summary.user).to eq batch.user expected_categories = [ diff --git a/spec/models/alaveteli_pro/to_do_list/expiring_embargo_spec.rb b/spec/models/alaveteli_pro/to_do_list/expiring_embargo_spec.rb index e4b6732483..8e85ecd316 100644 --- a/spec/models/alaveteli_pro/to_do_list/expiring_embargo_spec.rb +++ b/spec/models/alaveteli_pro/to_do_list/expiring_embargo_spec.rb @@ -18,7 +18,7 @@ end it 'gives a description for multiple expiring embargoes' do - embargo2 = FactoryBot.create(:expiring_embargo, :user => user) + embargo2 = FactoryBot.create(:expiring_embargo, user: user) AlaveteliPro::RequestSummary.create_or_update_from(embargo2.info_request) expect(@expiring_embargo.description).to eq "2 requests will be made public this week." end @@ -46,7 +46,7 @@ context 'when there is more than one item' do it 'returns a link to the info request list with a "embargoed" filter' do - embargo2 = FactoryBot.create(:expiring_embargo, :user => user) + embargo2 = FactoryBot.create(:expiring_embargo, user: user) AlaveteliPro::RequestSummary. create_or_update_from(embargo2.info_request) expect(@expiring_embargo.url) @@ -71,7 +71,7 @@ context 'when there is more than one item' do it 'returns an appropriate text' do - embargo2 = FactoryBot.create(:expiring_embargo, :user => user) + embargo2 = FactoryBot.create(:expiring_embargo, user: user) AlaveteliPro::RequestSummary. create_or_update_from(embargo2.info_request) expect(@expiring_embargo.call_to_action). diff --git a/spec/models/alaveteli_pro/to_do_list/list_spec.rb b/spec/models/alaveteli_pro/to_do_list/list_spec.rb index e269496c65..e1f00b09da 100644 --- a/spec/models/alaveteli_pro/to_do_list/list_spec.rb +++ b/spec/models/alaveteli_pro/to_do_list/list_spec.rb @@ -31,9 +31,9 @@ it 'returns items whose count is greater than zero' do user = FactoryBot.create(:user) - new_response = double('new_response', :count => 1) - expiring_embargo = double('expiring_embargo', :count => 0) - overdue_request = double('overdue_request', :count => 2) + new_response = double('new_response', count: 1) + expiring_embargo = double('expiring_embargo', count: 0) + overdue_request = double('overdue_request', count: 2) allow(AlaveteliPro::ToDoList::NewResponse).to receive(:new) .and_return(new_response) allow(AlaveteliPro::ToDoList::ExpiringEmbargo).to receive(:new) diff --git a/spec/models/alaveteli_pro/to_do_list/new_response_spec.rb b/spec/models/alaveteli_pro/to_do_list/new_response_spec.rb index 7f8a5393bd..3e440a281f 100644 --- a/spec/models/alaveteli_pro/to_do_list/new_response_spec.rb +++ b/spec/models/alaveteli_pro/to_do_list/new_response_spec.rb @@ -19,7 +19,7 @@ end it 'gives a description for multiple responses' do - request = FactoryBot.create(:old_unclassified_request, :user => user) + request = FactoryBot.create(:old_unclassified_request, user: user) AlaveteliPro::RequestSummary.create_or_update_from(request) expect(@new_response.description). to eq "2 requests have received a response." @@ -48,7 +48,7 @@ context 'when there is more than one item' do it 'returns a link to the info request list with a "response_received" filter' do - request = FactoryBot.create(:old_unclassified_request, :user => user) + request = FactoryBot.create(:old_unclassified_request, user: user) AlaveteliPro::RequestSummary.create_or_update_from(request) expect(@new_response.url) .to eq alaveteli_pro_info_requests_path('alaveteli_pro_request_filter[filter]' => @@ -72,7 +72,7 @@ context 'when there is more than one item' do it 'returns an appropriate text' do - request = FactoryBot.create(:old_unclassified_request, :user => user) + request = FactoryBot.create(:old_unclassified_request, user: user) AlaveteliPro::RequestSummary.create_or_update_from(request) expect(@new_response.call_to_action).to eq 'Update statuses.' end diff --git a/spec/models/alaveteli_pro/to_do_list/overdue_request_spec.rb b/spec/models/alaveteli_pro/to_do_list/overdue_request_spec.rb index d9d308e7d4..e4a8711d1c 100644 --- a/spec/models/alaveteli_pro/to_do_list/overdue_request_spec.rb +++ b/spec/models/alaveteli_pro/to_do_list/overdue_request_spec.rb @@ -23,7 +23,7 @@ it 'gives a description for multiple responses' do request = travel_to(Time.zone.parse('2015-11-01')) do - FactoryBot.create(:info_request, :user => user) + FactoryBot.create(:info_request, user: user) end travel_to(Time.zone.parse('2015-12-01')) do AlaveteliPro::RequestSummary.create_or_update_from(info_request) @@ -60,7 +60,7 @@ it 'returns a link to the info request list with a "overdue" filter' do request = travel_to(Time.zone.parse('2015-11-01')) do - FactoryBot.create(:info_request, :user => user) + FactoryBot.create(:info_request, user: user) end travel_to(Time.zone.parse('2015-12-01')) do AlaveteliPro::RequestSummary.create_or_update_from(info_request) @@ -94,7 +94,7 @@ it 'returns an appropriate text' do travel_to(Time.zone.parse('2015-11-01')) do - FactoryBot.create(:info_request, :user => user) + FactoryBot.create(:info_request, user: user) end travel_to(Time.zone.parse('2015-12-01')) do expect(@overdue_request.call_to_action) diff --git a/spec/models/alaveteli_pro/to_do_list/very_overdue_request_spec.rb b/spec/models/alaveteli_pro/to_do_list/very_overdue_request_spec.rb index 31381e9f5b..374be5288e 100644 --- a/spec/models/alaveteli_pro/to_do_list/very_overdue_request_spec.rb +++ b/spec/models/alaveteli_pro/to_do_list/very_overdue_request_spec.rb @@ -22,7 +22,7 @@ it 'gives a description for multiple responses' do request = travel_to(Time.zone.parse('2015-11-01')) do - FactoryBot.create(:info_request, :user => user) + FactoryBot.create(:info_request, user: user) end travel_to(Time.zone.parse('2016-01-01')) do AlaveteliPro::RequestSummary.create_or_update_from(request) @@ -58,7 +58,7 @@ it 'returns a link to the info request list with a "very_overdue" filter' do request = travel_to(Time.zone.parse('2015-11-01')) do - FactoryBot.create(:info_request, :user => user) + FactoryBot.create(:info_request, user: user) end travel_to(Time.zone.parse('2016-01-01')) do AlaveteliPro::RequestSummary.create_or_update_from(info_request) @@ -91,7 +91,7 @@ it 'returns an appropriate text' do request = travel_to(Time.zone.parse('2015-11-01')) do - FactoryBot.create(:info_request, :user => user) + FactoryBot.create(:info_request, user: user) end travel_to(Time.zone.parse('2016-01-01')) do AlaveteliPro::RequestSummary.create_or_update_from(request) diff --git a/spec/models/blog/post_spec.rb b/spec/models/blog/post_spec.rb new file mode 100644 index 0000000000..c3fa7abe0b --- /dev/null +++ b/spec/models/blog/post_spec.rb @@ -0,0 +1,64 @@ +# == Schema Information +# Schema version: 20230314171033 +# +# Table name: blog_posts +# +# id :bigint not null, primary key +# title :string +# url :string +# data :jsonb +# created_at :datetime not null +# updated_at :datetime not null +# +require 'spec_helper' +require 'models/concerns/taggable' + +RSpec.describe Blog::Post, type: :model do + it_behaves_like 'concerns/taggable', :blog_post + + let(:post) { FactoryBot.build(:blog_post) } + + describe 'validations' do + specify { expect(post).to be_valid } + + it 'requires title' do + post.title = nil + expect(post).not_to be_valid + end + + it 'requires url' do + post.url = nil + expect(post).not_to be_valid + end + + it 'requires unique url' do + FactoryBot.create(:blog_post, url: 'http://example.com/blog_post_1') + post.url = 'http://example.com/blog_post_1' + expect(post).not_to be_valid + end + end + + describe '#description' do + subject { post.description } + + let(:description) { 'Post description' } + + let(:post) do + FactoryBot.build( + :blog_post, data: { 'description' => [description, 'secondary'] } + ) + end + + it 'returns first description from data' do + is_expected.to eq('Post description') + end + + context 'when description contains escaped HTML entities' do + let(:description) { 'Foo & Bar' } + + it 'unescapes HTML entities' do + is_expected.to eq('Foo & Bar') + end + end + end +end diff --git a/spec/models/blog_spec.rb b/spec/models/blog_spec.rb new file mode 100644 index 0000000000..6df1fb241e --- /dev/null +++ b/spec/models/blog_spec.rb @@ -0,0 +1,137 @@ +require 'spec_helper' + +RSpec.describe Blog do + describe '.enabled?' do + subject { described_class.enabled? } + + context 'when feed is configured' do + before do + allow(AlaveteliConfiguration).to receive(:blog_feed). + and_return('http://blog.example.com') + end + + it { is_expected.to eq(true) } + end + + context 'when feed is not configured' do + before do + allow(AlaveteliConfiguration).to receive(:blog_feed).and_return('') + end + + it { is_expected.to eq(false) } + end + end + + describe '#posts' do + let(:blog) { described_class.new } + subject(:posts) { blog.posts } + + context 'when feed is fetched successfully' do + before do + allow(AlaveteliConfiguration).to receive(:blog_feed). + and_return('http://blog.example.com') + + allow(blog).to receive(:quietly_try_to_open). + and_return(load_file_fixture('blog_feed.atom')) + end + + it 'parses an item from an example feed' do + expect(posts.count).to eq(2) + end + + it 'returns Blog::Post objects' do + expect(posts).to all be_a(Blog::Post) + end + + it 'maps feed title to model title' do + expect(posts.first.title).to eq('Example Post') + end + + it 'maps feed link to model url' do + expect(posts.first.url).to eq('http://www.example.com/example-post') + end + + it 'maps feed to model data' do + expect(posts.first.data).to include( + 'category' => ['FOI'], + 'creator' => ['Example Blogger'], + 'comments' => ['http://www.example.com/example-post#comments', '2'], + 'pubDate' => ['Mon, 01 Apr 2013 19:26:08 +0000'] + ) + end + + it 'updates existing Blog::Post object when URL matches' do + existing = FactoryBot.create( + :blog_post, + title: 'My fancy blog post', + url: 'http://www.example.com/example-post' + ) + expect { posts }.to change { existing.reload.title }. + from('My fancy blog post'). + to('Example Post') + end + + it 'returns BLog::Post in the same order as the feed' do + expect(posts.first.title).to eq('Example Post') + expect(posts.second.title).to eq('Other Post') + end + end + + context 'when feed returns an error' do + before do + allow(AlaveteliConfiguration).to receive(:blog_feed). + and_return('http://blog.example.com') + stub_request(:get, %r|blog.example.com|).to_return(status: 500) + end + + it 'should fail silently if the blog is returning an error' do + expect(posts.count).to eq(0) + end + end + end + + describe '#feeds' do + let(:blog) { described_class.new } + subject(:feeds) { blog.feeds } + + before do + allow(AlaveteliConfiguration).to receive(:blog_feed). + and_return('http://blog.example.com') + allow(AlaveteliConfiguration).to receive(:site_name). + and_return('My site') + end + + it 'returns an array with a url (with lang query param) and title hash' do + is_expected.to include( + { url: 'http://blog.example.com?lang=en', title: 'My site blog' } + ) + end + end + + describe '#feed_url' do + let(:blog) { described_class.new } + subject(:feed_url) { blog.feed_url } + + context 'when feed is configured' do + before do + allow(AlaveteliConfiguration).to receive(:blog_feed). + and_return('http://blog.example.com') + end + + it 'add lang query param correctly' do + is_expected.to eq('http://blog.example.com?lang=en') + end + end + + context 'when feed is configured with existing query param' do + before do + allow(AlaveteliConfiguration).to receive(:blog_feed). + and_return('http://blog.example.com?alt=rss') + end + + it 'adds lang query param correctly' do + is_expected.to eq('http://blog.example.com?alt=rss&lang=en') + end + end + end +end diff --git a/spec/models/censor_rule_spec.rb b/spec/models/censor_rule_spec.rb index 20cac4a89e..7ca697f288 100644 --- a/spec/models/censor_rule_spec.rb +++ b/spec/models/censor_rule_spec.rb @@ -23,28 +23,28 @@ describe '#apply_to_text' do it 'applies the rule to the text' do - rule = FactoryBot.build(:censor_rule, :text => 'secret') + rule = FactoryBot.build(:censor_rule, text: 'secret') text = 'Some secret text' expect(rule.apply_to_text(text)).to eq('Some [REDACTED] text') end it 'does not mutate the input' do - rule = FactoryBot.build(:censor_rule, :text => 'secret') + rule = FactoryBot.build(:censor_rule, text: 'secret') text = 'Some secret text' rule.apply_to_text(text) expect(text).to eq('Some secret text') end it 'returns the text if the rule is unmatched' do - rule = FactoryBot.build(:censor_rule, :text => 'secret') + rule = FactoryBot.build(:censor_rule, text: 'secret') text = 'Some text' expect(rule.apply_to_text(text)).to eq('Some text') end it 'replaces the regexp with the replacement text when applied to text' do - attrs = { :text => '--PRIVATE.*--PRIVATE', - :replacement => "--REMOVED\nHidden private info\n--REMOVED", - :regexp => true } + attrs = { text: '--PRIVATE.*--PRIVATE', + replacement: "--REMOVED\nHidden private info\n--REMOVED", + regexp: true } rule = FactoryBot.build(:censor_rule, attrs) text = <<-EOF.strip_heredoc Some public information @@ -66,13 +66,13 @@ describe '#apply_to_binary' do it 'applies the rule to the text' do - rule = FactoryBot.build(:censor_rule, :text => 'secret') + rule = FactoryBot.build(:censor_rule, text: 'secret') text = 'Some secret text' expect(rule.apply_to_binary(text)).to eq('Some xxxxxx text') end it 'does not modify the size of the string' do - rule = FactoryBot.build(:censor_rule, :text => 'secret') + rule = FactoryBot.build(:censor_rule, text: 'secret') text = 'Some secret text' original_text = text.dup redacted = rule.apply_to_binary(text) @@ -88,14 +88,14 @@ end it 'does not mutate the input' do - rule = FactoryBot.build(:censor_rule, :text => 'secret') + rule = FactoryBot.build(:censor_rule, text: 'secret') text = 'Some secret text' rule.apply_to_binary(text) expect(text).to eq('Some secret text') end it 'returns the text if the rule is unmatched' do - rule = FactoryBot.build(:censor_rule, :text => 'secret') + rule = FactoryBot.build(:censor_rule, text: 'secret') text = 'Some text' expect(rule.apply_to_binary(text)).to eq('Some text') end @@ -108,7 +108,7 @@ end it 'handles a UTF-8 rule and ASCII-8BIT text' do - rule = FactoryBot.build(:censor_rule, :text => 'sécret') + rule = FactoryBot.build(:censor_rule, text: 'sécret') text = 'Some sécret text' text.force_encoding('ASCII-8BIT') expect(rule.apply_to_binary(text)).to eq("Some xxxxxxx text") @@ -116,9 +116,9 @@ it "replaces the regexp with the same number of 'x' characters as the text replaced when applied to binary" do - attrs = { :text => '--PRIVATE.*--PRIVATE', - :replacement => "--REMOVED\nHidden private info\n--REMOVED", - :regexp => true } + attrs = { text: '--PRIVATE.*--PRIVATE', + replacement: "--REMOVED\nHidden private info\n--REMOVED", + regexp: true } rule = FactoryBot.build(:censor_rule, attrs) text = <<-EOF.strip_heredoc Some public information @@ -136,9 +136,9 @@ end it 'handles a UTF-8 rule with ASCII-8BIT text' do - attrs = { :text => '--PRIVATE.*--P‘RIVATE', - :replacement => "--REMOVED\nHidden private info\n--REMOVED", - :regexp => true } + attrs = { text: '--PRIVATE.*--P‘RIVATE', + replacement: "--REMOVED\nHidden private info\n--REMOVED", + regexp: true } rule = FactoryBot.build(:censor_rule, attrs) text = <<-EOF.strip_heredoc Some public information @@ -160,37 +160,34 @@ describe '#expire_requests' do - it 'calls expire on the request if it is a request rule' do + it 'create expire job for the request if it is a request rule' do request = FactoryBot.create(:info_request) rule = FactoryBot.create(:info_request_censor_rule, - :info_request => request) - expect(request).to receive(:expire) + info_request: request) + expect(InfoRequestExpireJob).to receive(:perform_later).with(request) rule.expire_requests end - it 'calls expire_requests on the user if it is a user rule' do + it 'create expire job for the user if it is a user rule' do user = FactoryBot.create(:user) - rule = FactoryBot.create(:user_censor_rule, :user => user) - expect(user).to receive(:expire_requests) + rule = FactoryBot.create(:user_censor_rule, user: user) + expect(InfoRequestExpireJob).to receive(:perform_later). + with(user, :info_requests) rule.expire_requests end - it 'calls expire_requests on the public body if it is a public body rule' do + it 'create expire job for the public body if it is a public body rule' do body = FactoryBot.create(:public_body) - rule = FactoryBot.create(:public_body_censor_rule, :public_body => body) - expect(body).to receive(:expire_requests) + rule = FactoryBot.create(:public_body_censor_rule, public_body: body) + expect(InfoRequestExpireJob).to receive(:perform_later). + with(body, :info_requests) rule.expire_requests end - it 'calls expire on all public requests if it is a global rule' do + it 'create expire job for all requests if it is a global rule' do rule = FactoryBot.build(:global_censor_rule) - requests = [double, double] - expect(InfoRequest).to receive(:find_in_batches).and_yield(requests) - - requests.each do |request| - expect(request).to receive(:expire) - end - + expect(InfoRequestExpireJob).to receive(:perform_later). + with(InfoRequest, :all) rule.expire_requests end @@ -284,11 +281,11 @@ describe 'when validating a regexp rule' do before do - @censor_rule = CensorRule.new(:regexp => true, - :text => '*', - :replacement => '---', - :last_edit_comment => 'test', - :last_edit_editor => 'rspec') + @censor_rule = CensorRule.new(regexp: true, + text: '*', + replacement: '---', + last_edit_comment: 'test', + last_edit_editor: 'rspec') end it 'should try to create a regexp from the text' do @@ -351,15 +348,15 @@ describe '.global' do before do - @global_rule = CensorRule.create!(:text => 'hide me', - :replacement => 'nothing to see here', - :last_edit_editor => 1, - :last_edit_comment => 'comment') - @user_rule = CensorRule.create!(:user_id => 1, - :text => 'hide me', - :replacement => 'nothing to see here', - :last_edit_editor => 1, - :last_edit_comment => 'comment') + @global_rule = CensorRule.create!(text: 'hide me', + replacement: 'nothing to see here', + last_edit_editor: 1, + last_edit_comment: 'comment') + @user_rule = CensorRule.create!(user_id: 1, + text: 'hide me', + replacement: 'nothing to see here', + last_edit_editor: 1, + last_edit_comment: 'comment') end it 'should include an instance without user_id, request_id or public_body_id' do diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index 6b7f5b5c9b..608793c437 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -23,22 +23,22 @@ describe '.visible' do before(:each) do - @visible_request = FactoryBot.create(:info_request, :prominence => "normal") - @hidden_request = FactoryBot.create(:info_request, :prominence => "hidden") + @visible_request = FactoryBot.create(:info_request, prominence: "normal") + @hidden_request = FactoryBot.create(:info_request, prominence: "hidden") end it 'should treat new comments to be visible by default' do - comment = FactoryBot.create(:comment, :info_request => @visible_request) + comment = FactoryBot.create(:comment, info_request: @visible_request) expect(@visible_request.comments.visible).to eq([comment]) end it 'should treat comments which have be hidden as not visible' do - comment = FactoryBot.create(:hidden_comment, :info_request => @visible_request) + comment = FactoryBot.create(:hidden_comment, info_request: @visible_request) expect(@visible_request.comments.visible).to eq([]) end it 'should treat visible comments attached to a hidden request as not visible' do - comment = FactoryBot.create(:comment, :info_request => @hidden_request) + comment = FactoryBot.create(:comment, info_request: @hidden_request) expect(comment.visible).to eq(true) expect(@hidden_request.comments.visible).to eq([]) end @@ -50,10 +50,10 @@ before(:each) do @info_request = FactoryBot.create(:info_request) @request_comment = FactoryBot.create(:comment, - :info_request => @info_request) + info_request: @info_request) @embargoed_request = FactoryBot.create(:embargoed_request) @embargoed_comment = FactoryBot.create(:comment, - :info_request => @embargoed_request) + info_request: @embargoed_request) end it 'includes comments on embargoed requests' do @@ -71,10 +71,10 @@ before(:each) do @info_request = FactoryBot.create(:info_request) @request_comment = FactoryBot.create(:comment, - :info_request => @info_request) + info_request: @info_request) @embargoed_request = FactoryBot.create(:embargoed_request) @embargoed_comment = FactoryBot.create(:comment, - :info_request => @embargoed_request) + info_request: @embargoed_request) end it 'does not include comments on embargoed requests' do @@ -87,6 +87,107 @@ end + # rubocop:disable Layout/FirstArrayElementIndentation + describe '.exceeded_creation_rate?' do + subject { described_class.exceeded_creation_rate?(comments) } + + context 'when there are no comments' do + let(:comments) { described_class.where(id: nil) } + it { is_expected.to eq(false) } + end + + context 'when the last comment was created in the last 2 seconds' do + let(:comments) do + described_class.where(id: [ + FactoryBot.create(:comment, created_at: 1.second.ago) + ]) + end + + it { is_expected.to eq(true) } + end + + context 'when the last comment was created a few seconds ago' do + let(:comments) do + described_class.where(id: [ + FactoryBot.create(:comment, created_at: 3.seconds.ago) + ]) + end + + it { is_expected.to eq(false) } + end + + context 'when the last 2 comments were created in the last 5 minutes' do + let(:comments) do + described_class.where(id: [ + FactoryBot.create(:comment, created_at: 1.second.ago), + FactoryBot.create(:comment, created_at: 2.minutes.ago), + FactoryBot.create(:comment, created_at: 3.days.ago) + ]) + end + + it { is_expected.to eq(true) } + end + + context 'when the last 4 comments were created in the last 30 minutes' do + let(:comments) do + described_class.where(id: [ + FactoryBot.create(:comment, created_at: 1.second.ago), + FactoryBot.create(:comment, created_at: 2.minutes.ago), + FactoryBot.create(:comment, created_at: 5.minutes.ago), + FactoryBot.create(:comment, created_at: 10.minutes.ago), + FactoryBot.create(:comment, created_at: 3.days.ago) + ]) + end + + it { is_expected.to eq(true) } + end + + context 'when the last 6 comments were created in the last hour' do + let(:comments) do + described_class.where(id: [ + FactoryBot.create(:comment, created_at: 1.second.ago), + FactoryBot.create(:comment, created_at: 2.minutes.ago), + FactoryBot.create(:comment, created_at: 5.minutes.ago), + FactoryBot.create(:comment, created_at: 10.minutes.ago), + FactoryBot.create(:comment, created_at: 40.minutes.ago), + FactoryBot.create(:comment, created_at: 50.minutes.ago), + FactoryBot.create(:comment, created_at: 3.days.ago) + ]) + end + + it { is_expected.to eq(true) } + end + + context 'when the comments are reasonably spaced' do + let(:comments) do + described_class.where(id: [ + FactoryBot.create(:comment, created_at: 15.minutes.ago), + FactoryBot.create(:comment, created_at: 12.minutes.ago), + FactoryBot.create(:comment, created_at: 40.minutes.ago), + FactoryBot.create(:comment, created_at: 3.hours.ago), + FactoryBot.create(:comment, created_at: 8.hours.ago), + FactoryBot.create(:comment, created_at: 1.day.ago), + FactoryBot.create(:comment, created_at: 3.days.ago) + ]) + end + + it { is_expected.to eq(false) } + end + + context 'when the comments are provided out of order' do + let(:comments) do + described_class.where(id: [ + FactoryBot.create(:comment, created_at: 3.days.ago), + FactoryBot.create(:comment, created_at: 2.minutes.ago), + FactoryBot.create(:comment, created_at: 1.second.ago) + ]).order(created_at: :asc) + end + + it { is_expected.to eq(true) } + end + end + # rubocop:enable Layout/FirstArrayElementIndentation + describe '#prominence' do subject { comment.prominence } @@ -104,12 +205,12 @@ describe '#hidden?' do it 'returns true if the comment is not visible' do - comment = Comment.new(:visible => false) + comment = Comment.new(visible: false) expect(comment.hidden?).to eq(true) end it 'returns false if the comment is visible' do - comment = Comment.new(:visible => true) + comment = Comment.new(visible: true) expect(comment.hidden?).to eq(false) end @@ -165,7 +266,7 @@ it "includes a note about the comment in the admin email" do expected = "The user wishes to draw attention to the comment: " \ - "#{comment_url(comment, :host => AlaveteliConfiguration.domain)}" + "#{comment_url(comment, host: AlaveteliConfiguration.domain)}" comment.report!("Vexatious comment", "Comment is bad, please hide", user) notification = ActionMailer::Base.deliveries.last expect(notification.body).to match(expected) @@ -173,16 +274,16 @@ it 'logs the report_comment event' do comment.info_request_events. - where(:event_type => 'report_comment').destroy_all + where(event_type: 'report_comment').destroy_all comment.report!("Vexatious comment", "Comment is bad, please hide", user) comment.reload most_recent_event = comment.info_request_events.last expect(most_recent_event.event_type).to eq('report_comment') expect(most_recent_event.params). - to include(:reason => "Vexatious comment") + to include(reason: "Vexatious comment") expect(most_recent_event.params). - to include(:message => "Comment is bad, please hide") + to include(message: "Comment is bad, please hide") end end diff --git a/spec/models/customstates.rb b/spec/models/customstates.rb index 6f2f9045fd..da8bb2e8c3 100644 --- a/spec/models/customstates.rb +++ b/spec/models/customstates.rb @@ -6,28 +6,28 @@ def self.included(base) # Mixin methods for InfoRequest def theme_calculate_status - return 'waiting_classification' if self.awaiting_description - waiting_response = self.described_state == "waiting_response" || self.described_state == "deadline_extended" - return self.described_state unless waiting_response - if self.described_state == 'deadline_extended' + return 'waiting_classification' if awaiting_description + waiting_response = described_state == "waiting_response" || described_state == "deadline_extended" + return described_state unless waiting_response + if described_state == 'deadline_extended' return 'deadline_extended' if - Time.zone.now.strftime("%Y-%m-%d") < self.date_deadline_extended.strftime("%Y-%m-%d") + Time.zone.now.strftime("%Y-%m-%d") < date_deadline_extended.strftime("%Y-%m-%d") return 'waiting_response_very_overdue' if - Time.zone.now.strftime("%Y-%m-%d") > Holiday.due_date_from_working_days(self.date_deadline_extended, 15).strftime("%Y-%m-%d") + Time.zone.now.strftime("%Y-%m-%d") > Holiday.due_date_from_working_days(date_deadline_extended, 15).strftime("%Y-%m-%d") return 'waiting_response_overdue' end return 'waiting_response_very_overdue' if - Time.zone.now.strftime("%Y-%m-%d") > self.date_very_overdue_after.strftime("%Y-%m-%d") + Time.zone.now.strftime("%Y-%m-%d") > date_very_overdue_after.strftime("%Y-%m-%d") return 'waiting_response_overdue' if - Time.zone.now.strftime("%Y-%m-%d") > self.date_response_required_by.strftime("%Y-%m-%d") - return 'waiting_response' + Time.zone.now.strftime("%Y-%m-%d") > date_response_required_by.strftime("%Y-%m-%d") + 'waiting_response' end def date_deadline_extended # TODO: shouldn't this be 15 days after the date the status was # changed to "deadline extended"? Or perhaps 15 days ater the # initial request due date? - return Holiday.due_date_from_working_days(self.date_response_required_by, 15) + Holiday.due_date_from_working_days(date_response_required_by, 15) end module ClassMethods @@ -37,7 +37,7 @@ def theme_display_status(status) elsif status == 'wrong_response' _("Wrong Response.") else - raise _("unknown status {{status}}", :status => status) + raise _("unknown status {{status}}", status: status) end end @@ -47,13 +47,12 @@ def theme_short_description(status) elsif status == 'wrong_response' _("Wrong Response") else - raise _("unknown status {{status}}", :status => status) + raise _("unknown status {{status}}", status: status) end end def theme_extra_states - return ['deadline_extended', - 'wrong_response'] + %w[deadline_extended wrong_response] end end end diff --git a/spec/models/holiday_import_spec.rb b/spec/models/holiday_import_spec.rb index 3d0e4a8c2c..f6a6c2f0e9 100644 --- a/spec/models/holiday_import_spec.rb +++ b/spec/models/holiday_import_spec.rb @@ -3,25 +3,25 @@ RSpec.describe HolidayImport do it 'validates the presence of a feed if the source is a feed' do - holiday_import = HolidayImport.new(:source => 'feed') + holiday_import = HolidayImport.new(source: 'feed') expect(holiday_import.valid?).to be false expect(holiday_import.errors[:ical_feed_url]).to eq(["can't be blank"]) end it 'does not validate the presence of a feed if the source is suggestions' do - holiday_import = HolidayImport.new(:source => 'suggestions') + holiday_import = HolidayImport.new(source: 'suggestions') expect(holiday_import.valid?).to be true end it 'validates that the source is either "feed" or "suggestions"' do - holiday_import = HolidayImport.new(:source => 'something') + holiday_import = HolidayImport.new(source: 'something') expect(holiday_import.valid?).to be false expect(holiday_import.errors[:source]).to eq(["is not included in the list"]) end it 'validates that all holidays create from attributes are valid' do - holiday_import = HolidayImport.new(:source => 'suggestions', - :holidays_attributes => {"0" => {:description => '', + holiday_import = HolidayImport.new(source: 'suggestions', + holidays_attributes: {"0" => {:description => '', "day(1i)"=>"", "day(2i)"=>"", "day(3i)"=>""}}) @@ -43,13 +43,13 @@ end it 'allows the start and end year to be set' do - holiday_import = HolidayImport.new(:start_year => 2011, :end_year => 2012) + holiday_import = HolidayImport.new(start_year: 2011, end_year: 2012) expect(holiday_import.start_year).to eq(2011) expect(holiday_import.end_year).to eq(2012) end it 'sets the start and end dates to the beginning and end of the year' do - holiday_import = HolidayImport.new(:start_year => 2011, :end_year => 2012) + holiday_import = HolidayImport.new(start_year: 2011, end_year: 2012) expect(holiday_import.start_date).to eq(Date.new(2011, 1, 1)) expect(holiday_import.end_date).to eq(Date.new(2012, 12, 31)) end @@ -60,12 +60,12 @@ end it 'allows the source to be set' do - holiday_import = HolidayImport.new(:source => 'feed') + holiday_import = HolidayImport.new(source: 'feed') expect(holiday_import.source).to eq('feed') end it 'allows an iCal feed URL to be set' do - holiday_import = HolidayImport.new(:ical_feed_url => 'http://www.example.com') + holiday_import = HolidayImport.new(ical_feed_url: 'http://www.example.com') expect(holiday_import.ical_feed_url).to eq('http://www.example.com') end @@ -75,11 +75,11 @@ end it 'returns a readable description of the period for multiple years' do - expect(HolidayImport.new(:start_year => 2011, :end_year => 2012).period).to eq('2011-2012') + expect(HolidayImport.new(start_year: 2011, end_year: 2012).period).to eq('2011-2012') end it 'returns a readable description of the period for a single year' do - expect(HolidayImport.new(:start_year => 2011, :end_year => 2011).period).to eq('2011') + expect(HolidayImport.new(start_year: 2011, end_year: 2011).period).to eq('2011') end it 'returns the country name for which suggestions are generated' do @@ -89,11 +89,11 @@ describe 'when populating a set of holidays to import from suggestions' do it 'should populate holidays from the suggestions' do - holidays = [ { :date => Date.new(2014, 1, 1), - :name => "New Year's Day", - :regions => [:gb] } ] + holidays = [ { date: Date.new(2014, 1, 1), + name: "New Year's Day", + regions: [:gb] } ] allow(Holidays).to receive(:between).and_return(holidays) - @holiday_import = HolidayImport.new(:source => 'suggestions') + @holiday_import = HolidayImport.new(source: 'suggestions') @holiday_import.populate expect(@holiday_import.holidays.size).to eq(1) @@ -104,17 +104,17 @@ it 'returns an empty array for an unknown country code' do allow(AlaveteliConfiguration).to receive(:iso_country_code).and_return('UNKNOWN_COUNTRY_CODE') - @holiday_import = HolidayImport.new(:source => 'suggestions') + @holiday_import = HolidayImport.new(source: 'suggestions') @holiday_import.populate expect(@holiday_import.holidays).to be_empty end it 'should return a flag that it has been populated' do - holidays = [ { :date => Date.new(2014, 1, 1), - :name => "New Year's Day", - :regions => [:gb] } ] + holidays = [ { date: Date.new(2014, 1, 1), + name: "New Year's Day", + regions: [:gb] } ] allow(Holidays).to receive(:between).and_return(holidays) - @holiday_import = HolidayImport.new(:source => 'suggestions') + @holiday_import = HolidayImport.new(source: 'suggestions') @holiday_import.populate expect(@holiday_import.populated).to eq(true) @@ -125,10 +125,10 @@ describe 'when populating a set of holidays to import from a feed' do before do - @holiday_import = HolidayImport.new(:source => 'feed', - :ical_feed_url => 'http://www.example.com', - :start_year => 2014, - :end_year => 2014) + @holiday_import = HolidayImport.new(source: 'feed', + ical_feed_url: 'http://www.example.com', + start_year: 2014, + end_year: 2014) end it 'should populate holidays from the feed that are between the dates' do diff --git a/spec/models/incoming_message_error_spec.rb b/spec/models/incoming_message_error_spec.rb index 5cf41999a7..fcfbbcec19 100644 --- a/spec/models/incoming_message_error_spec.rb +++ b/spec/models/incoming_message_error_spec.rb @@ -19,7 +19,7 @@ it 'requres a unique ID' do expect(IncomingMessageError.new).not_to be_valid - expect(IncomingMessageError.new(:unique_id => 'xxx')).to be_valid + expect(IncomingMessageError.new(unique_id: 'xxx')).to be_valid end end diff --git a/spec/models/incoming_message_spec.rb b/spec/models/incoming_message_spec.rb index 3e0e9983ef..cd5f967caf 100644 --- a/spec/models/incoming_message_spec.rb +++ b/spec/models/incoming_message_spec.rb @@ -131,8 +131,8 @@ message.parse_raw_email!(true) message.reload FactoryBot.create(:censor_rule, - :text => 'Person', - :info_request => message.info_request) + text: 'Person', + info_request: message.info_request) expect(message.safe_from_name).to eq('FOI [REDACTED]') end @@ -327,8 +327,8 @@ before(:each) do @im = incoming_messages(:useless_incoming_message) - @default_opts = { :last_edit_editor => 'unknown', - :last_edit_comment => 'none' } + @default_opts = { last_edit_editor: 'unknown', + last_edit_comment: 'none' } load_raw_emails_data end @@ -337,8 +337,8 @@ data = 'There was a mouse called Stilton, he wished that he was blue' expected = 'There was a mouse called Stilton, he said that he was blue' - opts = { :text => 'wished', - :replacement => 'said' }.merge(@default_opts) + opts = { text: 'wished', + replacement: 'said' }.merge(@default_opts) CensorRule.create!(opts) result = @im.apply_masks(data, 'text/plain') @@ -351,8 +351,8 @@ expected = 'There was a cat called Jarlsberg.' rules = [ - { :text => 'Stilton', :replacement => 'Jarlsberg' }, - { :text => 'm[a-z][a-z][a-z]e', :regexp => true, :replacement => 'cat' } + { text: 'Stilton', replacement: 'Jarlsberg' }, + { text: 'm[a-z][a-z][a-z]e', regexp: true, replacement: 'cat' } ] rules.each do |rule| @@ -368,8 +368,8 @@ expected = 'There was a cat called Jarlsberg.' rules = [ - { :text => 'Stilton', :replacement => 'Jarlsberg' }, - { :text => 'm[a-z][a-z][a-z]e', :regexp => true, :replacement => 'cat' } + { text: 'Stilton', replacement: 'Jarlsberg' }, + { text: 'm[a-z][a-z][a-z]e', regexp: true, replacement: 'cat' } ] rules.each do |rule| @@ -443,7 +443,7 @@ it 'strips null bytes from the extracted clipped text' do message = FactoryBot.create(:incoming_message) FactoryBot. - create(:body_text, :body => "hi\u0000", :incoming_message => message) + create(:body_text, body: "hi\u0000", incoming_message: message) message.reload expect(message.get_attachment_text_clipped).to eq("hi\n\n") end @@ -455,13 +455,13 @@ it 'does not generate incompatible character encodings' do message = FactoryBot.create(:incoming_message) FactoryBot.create(:body_text, - :body => 'hí', - :incoming_message => message, - :url_part_number => 2) + body: 'hí', + incoming_message: message, + url_part_number: 2) FactoryBot.create(:pdf_attachment, - :body => load_file_fixture('pdf-with-utf8-characters.pdf'), - :incoming_message => message, - :url_part_number => 3) + body: load_file_fixture('pdf-with-utf8-characters.pdf'), + incoming_message: message, + url_part_number: 3) message.reload expect { message._extract_text }. @@ -544,11 +544,11 @@ let(:request) { FactoryBot.create(:info_request) } it "updates the info_request's last_public_response_at to nil when hidden" do - im = FactoryBot.create(:incoming_message, :info_request => request) + im = FactoryBot.create(:incoming_message, info_request: request) response_event = FactoryBot. - create(:info_request_event, :event_type => 'response', - :info_request => request, - :incoming_message => im) + create(:info_request_event, event_type: 'response', + info_request: request, + incoming_message: im) im.prominence = 'hidden' im.save! expect(request.last_public_response_at).to be_nil @@ -556,12 +556,12 @@ it "updates the info_request's last_public_response_at to a timestamp \ when unhidden" do - im = FactoryBot.create(:incoming_message, :prominence => 'hidden', - :info_request => request) + im = FactoryBot.create(:incoming_message, prominence: 'hidden', + info_request: request) response_event = FactoryBot. - create(:info_request_event, :event_type => 'response', - :info_request => request, - :incoming_message => im) + create(:info_request_event, event_type: 'response', + info_request: request, + incoming_message: im) im.prominence = 'normal' im.save! expect(request.last_public_response_at).to be_within(1.second). @@ -575,7 +575,7 @@ it 'destroys the incoming message' do incoming_message.destroy - expect(IncomingMessage.where(:id => incoming_message.id)).to be_empty + expect(IncomingMessage.where(id: incoming_message.id)).to be_empty end it 'should destroy the related info_request_event' do @@ -586,28 +586,28 @@ ) incoming_message.reload incoming_message.destroy - expect(InfoRequestEvent.where(:incoming_message_id => incoming_message.id)). + expect(InfoRequestEvent.where(incoming_message_id: incoming_message.id)). to be_empty end it 'should nullify outgoing_message_followups' do outgoing_message = FactoryBot. create(:initial_request, - :info_request => incoming_message.info_request, - :incoming_message_followup_id => incoming_message.id) + info_request: incoming_message.info_request, + incoming_message_followup_id: incoming_message.id) incoming_message.reload incoming_message.destroy expect(OutgoingMessage. - where(:incoming_message_followup_id => incoming_message.id)).to be_empty - expect(OutgoingMessage.where(:id => outgoing_message.id)). + where(incoming_message_followup_id: incoming_message.id)).to be_empty + expect(OutgoingMessage.where(id: outgoing_message.id)). to eq([outgoing_message]) end it 'destroys the associated raw email' do raw_email = incoming_message.raw_email incoming_message.destroy - expect(RawEmail.where(:id => raw_email.id)).to be_empty + expect(RawEmail.where(id: raw_email.id)).to be_empty end context 'with attachments' do @@ -617,14 +617,14 @@ it 'destroys the incoming message' do incoming_with_attachment.destroy - expect(IncomingMessage.where(:id => incoming_with_attachment.id)). + expect(IncomingMessage.where(id: incoming_with_attachment.id)). to be_empty end it 'should destroy associated attachments' do incoming_with_attachment.destroy expect( - FoiAttachment.where(:incoming_message_id => incoming_with_attachment.id) + FoiAttachment.where(incoming_message_id: incoming_with_attachment.id) ).to be_empty end end @@ -704,7 +704,7 @@ "foo\n--------\nbar - confidential" => "foo\nFOLDED_QUOTED_SECTION\n", # allow scorechar inside folded section "foo\n--------\nbar\n--------\nconfidential" => "foo\n--------\nbar\nFOLDED_QUOTED_SECTION\n", # don't assume that anything after a score is a folded section "foo\n--------\nbar\n--------\nconfidential\n--------\nrest" => "foo\n--------\nbar\nFOLDED_QUOTED_SECTION\nrest", # don't assume that a folded section continues to the end of the message - "foo\n--------\nbar\n- - - - - - - -\nconfidential\n--------\nrest" => "foo\n--------\nbar\nFOLDED_QUOTED_SECTION\nrest", # allow spaces in the score + "foo\n--------\nbar\n- - - - - - - -\nconfidential\n--------\nrest" => "foo\n--------\nbar\nFOLDED_QUOTED_SECTION\nrest" # allow spaces in the score }.each do |input,output| expect(IncomingMessage.remove_quoted_sections(input)).to eq(output) end @@ -899,7 +899,7 @@ def populate_raw_email(fixture) im.extract_attachments! expect(im.get_attachments_for_display.map(&:display_filename)).to eq([ - 'bah.txt', + 'bah.txt' ]) end @@ -946,7 +946,7 @@ def populate_raw_email(fixture) expect(attachments.map(&:display_filename)).to eq([ 'Same attachment twice.txt', 'hello.txt', - 'hello.txt', + 'hello.txt' ]) end @@ -985,7 +985,7 @@ def populate_raw_email(fixture) expect(im.get_attachments_for_display.map(&:display_filename)).to eq([ 'test.html', # picks HTML rather than text by default, as likely to render better - 'attach.txt', + 'attach.txt' ]) end end @@ -1011,7 +1011,7 @@ def populate_raw_email(fixture) expect(im.get_attachments_for_display.map(&:display_filename)).to eq([ 'FOI 09 02976i.doc', - 'FOI 09 02976iii.doc', + 'FOI 09 02976iii.doc' ]) end @@ -1035,17 +1035,17 @@ def populate_raw_email(fixture) it 'handles the case where reparsing changes the body of the main part and the cached attachment has been deleted' do # original set of attachment attributes - attachment_attributes = { :url_part_number => 1, - :within_rfc822_subject => nil, - :content_type => "text/plain", - :charset => nil, - :body => "No way!\n", - :hexdigest => "0c8b1b0f5cb9c94ed15a180e73b5c7d1", - :filename => nil } + attachment_attributes = { url_part_number: 1, + within_rfc822_subject: nil, + content_type: "text/plain", + charset: nil, + body: "No way!\n", + hexdigest: "0c8b1b0f5cb9c94ed15a180e73b5c7d1", + filename: nil } # Make a small change in the body returned for the attachment - new_attachment_attributes = attachment_attributes.merge(:body => "No way!", - :hexdigest => "74d2c0a41e074f9cebe49324d5b47414") + new_attachment_attributes = attachment_attributes.merge(body: "No way!", + hexdigest: "74d2c0a41e074f9cebe49324d5b47414") # Simulate parsing with the original attachments @@ -1138,9 +1138,9 @@ def populate_raw_email(fixture) incoming_message = FactoryBot.build(:incoming_message) # This character is 2 bytes so the string should get sliced unless # we are handling multibyte chars correctly - multibyte_string = "å" * 500002 + multibyte_string = "å" * 500_002 allow(incoming_message).to receive(:_get_attachment_text_internal).and_return(multibyte_string) - expect(incoming_message.get_attachment_text_clipped.length).to eq(500002) + expect(incoming_message.get_attachment_text_clipped.length).to eq(500_002) end end @@ -1152,7 +1152,7 @@ def populate_raw_email(fixture) before do @incoming_message = FactoryBot.create(:incoming_message) allow(@incoming_message).to receive(:get_main_body_text_internal). - and_return("x" * 1000010) + and_return("x" * 1_000_010) end it 'raises an exception' do diff --git a/spec/models/info_request/batch_pagination.rb b/spec/models/info_request/batch_pagination.rb new file mode 100644 index 0000000000..08b7249441 --- /dev/null +++ b/spec/models/info_request/batch_pagination.rb @@ -0,0 +1,47 @@ +RSpec.shared_examples 'info_request/batch_pagination' do + describe '#next_in_batch' do + subject { info_request.next_in_batch } + + let(:batch) do + FactoryBot.create(:info_request_batch, :sent, public_body_count: 2) + end + + context 'the request is not part of a batch' do + let(:info_request) { FactoryBot.build(:info_request) } + it { is_expected.to be_nil } + end + + context 'the request is part of a batch' do + let(:info_request) { batch.info_requests.first } + it { is_expected.to eq(batch.info_requests.last) } + end + + context 'the request is the last of a batch' do + let(:info_request) { batch.info_requests.last } + it { is_expected.to eq(batch.info_requests.first) } + end + end + + describe '#prev_in_batch' do + subject { info_request.prev_in_batch } + + let(:batch) do + FactoryBot.create(:info_request_batch, :sent, public_body_count: 2) + end + + context 'the request is not part of a batch' do + let(:info_request) { FactoryBot.build(:info_request) } + it { is_expected.to be_nil } + end + + context 'the request is part of a batch' do + let(:info_request) { batch.info_requests.last } + it { is_expected.to eq(batch.info_requests.first) } + end + + context 'the request is the first of a batch' do + let(:info_request) { batch.info_requests.first } + it { is_expected.to eq(batch.info_requests.last) } + end + end +end diff --git a/spec/models/info_request/pro_query_spec.rb b/spec/models/info_request/pro_query_spec.rb index 6f2db42272..d26998a8f6 100644 --- a/spec/models/info_request/pro_query_spec.rb +++ b/spec/models/info_request/pro_query_spec.rb @@ -6,7 +6,7 @@ it 'includes requests made by pro users' do pro_user = FactoryBot.create(:pro_user) - info_request = FactoryBot.create(:info_request, :user => pro_user) + info_request = FactoryBot.create(:info_request, user: pro_user) expect(described_class.new.call.include?(info_request)).to be true end diff --git a/spec/models/info_request/prominence/embargo_expired_today_query_spec.rb b/spec/models/info_request/prominence/embargo_expired_today_query_spec.rb index 22dbafacd8..7fca8db55a 100644 --- a/spec/models/info_request/prominence/embargo_expired_today_query_spec.rb +++ b/spec/models/info_request/prominence/embargo_expired_today_query_spec.rb @@ -7,7 +7,7 @@ it 'excludes requests that are currently under embargo' do embargo = FactoryBot.create(:embargo, - :publish_at => Time.now + 4.days) + publish_at: Time.now + 4.days) expect(described_class.new.call).not_to include embargo.info_request end diff --git a/spec/models/info_request/prominence/embargo_expiring_query_spec.rb b/spec/models/info_request/prominence/embargo_expiring_query_spec.rb index 589666c8e8..d0df8d6a89 100644 --- a/spec/models/info_request/prominence/embargo_expiring_query_spec.rb +++ b/spec/models/info_request/prominence/embargo_expiring_query_spec.rb @@ -6,13 +6,13 @@ it 'includes requests that have embargoes expiring within a week' do embargo = FactoryBot.create(:embargo, - :publish_at => Time.now + 4.days) + publish_at: Time.now + 4.days) expect(described_class.new.call).to include embargo.info_request end it 'excludes requests that have embargoes expiring in over a week' do embargo = FactoryBot.create(:embargo, - :publish_at => Time.now + 8.days) + publish_at: Time.now + 8.days) expect(described_class.new.call).not_to include embargo.info_request end diff --git a/spec/models/info_request/prominence/public_query_spec.rb b/spec/models/info_request/prominence/public_query_spec.rb index dd9d067ffb..24ef44582e 100644 --- a/spec/models/info_request/prominence/public_query_spec.rb +++ b/spec/models/info_request/prominence/public_query_spec.rb @@ -6,8 +6,8 @@ it 'returns only results with a normal or backpaged prominence' do normal_request = FactoryBot.create(:info_request) - backpaged_request = FactoryBot.create(:info_request, :prominence => 'backpage') - hidden_request = FactoryBot.create(:info_request, :prominence => 'hidden') + backpaged_request = FactoryBot.create(:info_request, prominence: 'backpage') + hidden_request = FactoryBot.create(:info_request, prominence: 'hidden') requests = described_class.new.call expect(requests).to include(normal_request) expect(requests).to include(backpaged_request) diff --git a/spec/models/info_request/prominence/searchable_query_spec.rb b/spec/models/info_request/prominence/searchable_query_spec.rb index dee48488b3..7c03c0c721 100644 --- a/spec/models/info_request/prominence/searchable_query_spec.rb +++ b/spec/models/info_request/prominence/searchable_query_spec.rb @@ -6,7 +6,7 @@ it 'returns only results with a normal prominence' do normal_request = FactoryBot.create(:info_request) - hidden_request = FactoryBot.create(:info_request, :prominence => 'hidden') + hidden_request = FactoryBot.create(:info_request, prominence: 'hidden') expect(described_class.new.call).to include(normal_request) expect(described_class.new.call).not_to include(hidden_request) end diff --git a/spec/models/info_request/response_gatekeeper/base_spec.rb b/spec/models/info_request/response_gatekeeper/base_spec.rb index dcacc681bf..f443067b47 100644 --- a/spec/models/info_request/response_gatekeeper/base_spec.rb +++ b/spec/models/info_request/response_gatekeeper/base_spec.rb @@ -57,7 +57,7 @@ it 'delegates to the info_request' do info_request = FactoryBot. - build(:info_request, :handle_rejected_responses => 'holding_pen') + build(:info_request, handle_rejected_responses: 'holding_pen') gatekeeper = described_class.new(info_request) expect(gatekeeper.rejection_action).to eq('holding_pen') end diff --git a/spec/models/info_request/response_gatekeeper/spam_checker_spec.rb b/spec/models/info_request/response_gatekeeper/spam_checker_spec.rb index 395418f0f5..dd35def57d 100644 --- a/spec/models/info_request/response_gatekeeper/spam_checker_spec.rb +++ b/spec/models/info_request/response_gatekeeper/spam_checker_spec.rb @@ -10,7 +10,7 @@ end it 'allows a custom spam_action' do - expect(described_class.new(:spam_action => 'x').spam_action).to eq('x') + expect(described_class.new(spam_action: 'x').spam_action).to eq('x') end it 'sets a default spam_header' do @@ -19,7 +19,7 @@ end it 'allows a custom spam_header' do - expect(described_class.new(:spam_header => 'x').spam_header).to eq('x') + expect(described_class.new(spam_header: 'x').spam_header).to eq('x') end it 'sets a default spam_threshold' do @@ -28,7 +28,7 @@ end it 'allows a custom spam_threshold' do - expect(described_class.new(:spam_threshold => 'x').spam_threshold). + expect(described_class.new(spam_threshold: 'x').spam_threshold). to eq('x') end @@ -37,7 +37,7 @@ describe '#spam_action' do it 'returns the spam_action' do - expect(described_class.new(:spam_action => 'x').spam_action).to eq('x') + expect(described_class.new(spam_action: 'x').spam_action).to eq('x') end end @@ -54,7 +54,7 @@ describe '#spam_header' do it 'returns the spam_header' do - expect(described_class.new(:spam_header => 'x').spam_header).to eq('x') + expect(described_class.new(spam_header: 'x').spam_header).to eq('x') end end @@ -62,7 +62,7 @@ describe '#spam_threshold' do it 'returns the spam_threshold' do - expect(described_class.new(:spam_threshold => 'x').spam_threshold). + expect(described_class.new(spam_threshold: 'x').spam_threshold). to eq('x') end @@ -79,8 +79,8 @@ Plz buy my spam EOF email = MailHandler.mail_from_raw_email(spam_email) - attrs = { :spam_header => nil, - :spam_threshold => 100 } + attrs = { spam_header: nil, + spam_threshold: 100 } gatekeeper = described_class.new(attrs) expect(gatekeeper.allow?(email)).to eq(true) end @@ -94,9 +94,9 @@ Hello, World EOF email = MailHandler.mail_from_raw_email(raw_email) - attrs = { :spam_header => 'X-Spam-Score', - :spam_threshold => 100, - :spam_action => 'discard' } + attrs = { spam_header: 'X-Spam-Score', + spam_threshold: 100, + spam_action: 'discard' } gatekeeper = described_class.new(attrs) expect(gatekeeper.allow?(email)).to eq(true) end @@ -110,9 +110,9 @@ Plz buy my spam EOF email = MailHandler.mail_from_raw_email(spam_email) - attrs = { :spam_header => 'X-Spam-Score', - :spam_threshold => 100, - :spam_action => 'discard' } + attrs = { spam_header: 'X-Spam-Score', + spam_threshold: 100, + spam_action: 'discard' } gatekeeper = described_class.new(attrs) expect(gatekeeper.allow?(email)).to eq(false) end @@ -121,7 +121,7 @@ describe '#reason' do it 'returns the reason that the email was rejected' do - gatekeeper = described_class.new(:spam_threshold => 10.0) + gatekeeper = described_class.new(spam_threshold: 10.0) message = 'Incoming message has a spam score above the configured ' \ 'threshold (10.0).' expect(gatekeeper.reason).to eq(message) @@ -140,8 +140,8 @@ Plz buy my spam EOF email = MailHandler.mail_from_raw_email(spam_email) - attrs = { :spam_header => 'X-Spam-Score', - :spam_threshold => 100 } + attrs = { spam_header: 'X-Spam-Score', + spam_threshold: 100 } gatekeeper = described_class.new(attrs) expect(gatekeeper.spam?(email)).to eq(true) end @@ -155,8 +155,8 @@ Hello, World EOF email = MailHandler.mail_from_raw_email(spam_email) - attrs = { :spam_header => 'X-Spam-Score', - :spam_threshold => 100 } + attrs = { spam_header: 'X-Spam-Score', + spam_threshold: 100 } gatekeeper = described_class.new(attrs) expect(gatekeeper.spam?(email)).to eq(false) end @@ -169,8 +169,8 @@ Hello, World EOF email = MailHandler.mail_from_raw_email(spam_email) - attrs = { :spam_header => 'X-Spam-Score', - :spam_threshold => 100 } + attrs = { spam_header: 'X-Spam-Score', + spam_threshold: 100 } gatekeeper = described_class.new(attrs) expect(gatekeeper.spam?(email)).to eq(false) end @@ -188,7 +188,7 @@ Plz buy my spam EOF email = MailHandler.mail_from_raw_email(spam_email) - gatekeeper = described_class.new(:spam_header => 'X-Spam-Score') + gatekeeper = described_class.new(spam_header: 'X-Spam-Score') expect(gatekeeper.spam_score(email)).to eq(1000.4) end @@ -209,24 +209,24 @@ describe '#configured?' do it 'requires a spam_action to be configured' do - gatekeeper = described_class.new(:spam_action => nil) + gatekeeper = described_class.new(spam_action: nil) expect(gatekeeper).to_not be_configured end it 'requires a spam_header to be configured' do - gatekeeper = described_class.new(:spam_header => nil) + gatekeeper = described_class.new(spam_header: nil) expect(gatekeeper).to_not be_configured end it 'requires a spam_threshold to be configured' do - gatekeeper = described_class.new(:spam_threshold => nil) + gatekeeper = described_class.new(spam_threshold: nil) expect(gatekeeper).to_not be_configured end it 'is configured if a spam_action, spam_header and spam_threshold exist' do - attrs = { :spam_action => 'discard', - :spam_header => 'X-Spam-Score', - :spam_threshold => 10.0 } + attrs = { spam_action: 'discard', + spam_header: 'X-Spam-Score', + spam_threshold: 10.0 } expect(described_class.new(attrs)).to be_configured end diff --git a/spec/models/info_request/response_rejection/bounce_spec.rb b/spec/models/info_request/response_rejection/bounce_spec.rb index 8d6669d561..a682f9e705 100644 --- a/spec/models/info_request/response_rejection/bounce_spec.rb +++ b/spec/models/info_request/response_rejection/bounce_spec.rb @@ -24,7 +24,7 @@ it 'does nothing and returns true if the mail is from the ' \ 'request address' do info_request = object_double(InfoRequest.new, - :incoming_email => 'request-333-xxx@example.com') + incoming_email: 'request-333-xxx@example.com') raw_email = <<-EOF.strip_heredoc To: Requester From: Bad person @@ -40,7 +40,7 @@ it 'does nothing and returns true if the mail is from the ' \ 'request address regardless of case' do info_request = object_double(InfoRequest.new, - :incoming_email => 'request-333-xxx@example.com') + incoming_email: 'request-333-xxx@example.com') raw_email = <<-EOF.strip_heredoc To: Requester From: Bad person @@ -55,8 +55,8 @@ it 'does nothing and returns true if the info_request is external' do info_request = object_double(InfoRequest.new, - :is_external? => true, - :incoming_email => 'request-333-xxx@example.com') + is_external?: true, + incoming_email: 'request-333-xxx@example.com') raw_email = <<-EOF.strip_heredoc From: sender@example.com To: Requester diff --git a/spec/models/info_request/state/calculator_spec.rb b/spec/models/info_request/state/calculator_spec.rb index b7d1788a92..7b109ebca8 100644 --- a/spec/models/info_request/state/calculator_spec.rb +++ b/spec/models/info_request/state/calculator_spec.rb @@ -56,7 +56,7 @@ } end - let(:admin_states) { ['not_foi', 'vexatious'] } + let(:admin_states) { %w[not_foi vexatious] } it "always returns an empty hash" do admin_states.each do |state| @@ -106,7 +106,7 @@ "rejected" => "My request has been refused" }, other: { - "error_message" => "I've received an error message", + "error_message" => "I've received an error message" } } end @@ -171,13 +171,13 @@ context "and the user is the owner" do it_behaves_like( "#transitions for an owner", - ['waiting_response', 'waiting_clarification', 'gone_postal']) + %w[waiting_response waiting_clarification gone_postal]) end context "and the user is some other user" do it_behaves_like( "#transitions for some other user", - ['waiting_response', 'waiting_clarification', 'gone_postal']) + %w[waiting_response waiting_clarification gone_postal]) end end @@ -185,13 +185,13 @@ context "and the user is the owner" do it_behaves_like( "#transitions for an owner", - ['not_held', 'partially_successful', 'successful', 'rejected']) + %w[not_held partially_successful successful rejected]) end context "and the user is some other user" do it_behaves_like( "#transitions for some other user", - ['not_held', 'partially_successful', 'successful', 'rejected']) + %w[not_held partially_successful successful rejected]) end end @@ -205,7 +205,7 @@ transitions = calculator.transitions( is_owning_user: true, user_asked_to_update_status: false) - expected = ["internal_review", "gone_postal"] + expected = %w[internal_review gone_postal] expect(transitions[:pending].keys).to eq(expected) end @@ -223,7 +223,7 @@ transitions = calculator.transitions( is_owning_user: false, user_asked_to_update_status: false) - expected = ["internal_review", "gone_postal"] + expected = %w[internal_review gone_postal] expect(transitions[:pending].keys).to eq(expected) end @@ -241,13 +241,13 @@ context "and the user is the owner" do it_behaves_like( "#transitions for an owner", - ['waiting_response', 'waiting_clarification', 'gone_postal']) + %w[waiting_response waiting_clarification gone_postal]) end context "and the user is some other user" do it_behaves_like( "#transitions for some other user", - ['waiting_response', 'waiting_clarification', 'gone_postal']) + %w[waiting_response waiting_clarification gone_postal]) end end end diff --git a/spec/models/info_request/state_spec.rb b/spec/models/info_request/state_spec.rb index b1d990fd08..8e330c0556 100644 --- a/spec/models/info_request/state_spec.rb +++ b/spec/models/info_request/state_spec.rb @@ -86,13 +86,13 @@ it 'returns hyphenised versions of the phases' do expect(InfoRequest::State.phase_params) - .to eq({ :awaiting_response => "awaiting-response", - :overdue => "overdue", - :very_overdue => "very-overdue", - :response_received => "response-received", - :clarification_needed => "clarification-needed", - :complete => "complete", - :other => "other" }) + .to eq({ awaiting_response: "awaiting-response", + overdue: "overdue", + very_overdue: "very-overdue", + response_received: "response-received", + clarification_needed: "clarification-needed", + complete: "complete", + other: "other" }) end end diff --git a/spec/models/info_request_batch_spec.rb b/spec/models/info_request_batch_spec.rb index 3cc96db7cb..ba53794930 100644 --- a/spec/models/info_request_batch_spec.rb +++ b/spec/models/info_request_batch_spec.rb @@ -64,6 +64,16 @@ end end + describe '.not_embargoed' do + subject { described_class.not_embargoed } + + let(:not_embargoed) { FactoryBot.create(:info_request_batch) } + let(:embargoed) { FactoryBot.create(:info_request_batch, :embargoed) } + + it { is_expected.to include(not_embargoed) } + it { is_expected.not_to include(embargoed) } + end + context '.with_body' do let(:batch) do FactoryBot.create(:info_request_batch, body: "foo\n\nbar") @@ -92,9 +102,9 @@ let(:first_body) { FactoryBot.create(:public_body) } let(:second_body) { FactoryBot.create(:public_body) } let(:info_request_batch) do - FactoryBot.create(:info_request_batch, :title => 'Matched title', - :body => 'Matched body', - :public_bodies => [first_body, + FactoryBot.create(:info_request_batch, title: 'Matched title', + body: 'Matched body', + public_bodies: [first_body, second_body]) end @@ -215,8 +225,8 @@ let(:info_request_batch) do FactoryBot.create( :info_request_batch, - :body => "Dear [Authority name],\nA message\nYours faithfully,\nRequester", - :public_bodies => [first_public_body, second_public_body]) + body: "Dear [Authority name],\nA message\nYours faithfully,\nRequester", + public_bodies: [first_public_body, second_public_body]) end it 'should substitute authority name for the placeholder in each request' do @@ -251,13 +261,13 @@ it "it imposes an alphabetical sort order on associated public bodies" do third_public_body = FactoryBot.create(:public_body, - :name => "Another Body") + name: "Another Body") batch = FactoryBot.create( :info_request_batch, - :public_bodies => [first_public_body, + public_bodies: [first_public_body, third_public_body]) batch.reload - expect(batch.public_bodies).to eq ([third_public_body, + expect(batch.public_bodies).to eq([third_public_body, first_public_body]) end @@ -305,8 +315,8 @@ let!(:sent_batch) do FactoryBot.create( :info_request_batch, - :public_bodies => [first_public_body, second_public_body], - :sent_at => Time.zone.now) + public_bodies: [first_public_body, second_public_body], + sent_at: Time.zone.now) end it 'should send requests and notifications for only unsent batch requests' do @@ -362,7 +372,7 @@ let(:draft) do FactoryBot.create( :draft_info_request_batch, - :public_bodies => [first_public_body, second_public_body]) + public_bodies: [first_public_body, second_public_body]) end it "copies across all of the attributes from the draft" do @@ -401,8 +411,8 @@ let(:info_request_batch) do FactoryBot.create( :info_request_batch, - :public_bodies => [first_public_body, second_public_body], - :embargo_duration => "3_months") + public_bodies: [first_public_body, second_public_body], + embargo_duration: "3_months") end let(:example) { info_request_batch.example_request } @@ -437,7 +447,7 @@ let(:info_request_batch) do FactoryBot.create( :info_request_batch, - :public_bodies => [first_public_body, second_public_body]) + public_bodies: [first_public_body, second_public_body]) end let(:example) { info_request_batch.example_request } @@ -493,7 +503,7 @@ let(:info_request_batch) do FactoryBot.create( :info_request_batch, - :public_bodies => [first_public_body, second_public_body]) + public_bodies: [first_public_body, second_public_body]) end before do @@ -549,7 +559,7 @@ describe "#request_phases" do let(:public_bodies) { FactoryBot.create_list(:public_body, 3) } let(:info_request_batch) do - FactoryBot.create(:info_request_batch, :public_bodies => public_bodies) + FactoryBot.create(:info_request_batch, public_bodies: public_bodies) end before do @@ -571,7 +581,7 @@ describe "#request_phases_summary" do let(:public_bodies) { FactoryBot.create_list(:public_body, 10) } let(:info_request_batch) do - FactoryBot.create(:info_request_batch, :public_bodies => public_bodies) + FactoryBot.create(:info_request_batch, public_bodies: public_bodies) end before do @@ -592,21 +602,21 @@ it "returns summarised counts of each request phase grouping" do expected = { - :in_progress => { - :label => _('In progress'), - :count => 4 + in_progress: { + label: _('In progress'), + count: 4 }, - :action_needed => { - :label => _('Action needed'), - :count => 3 + action_needed: { + label: _('Action needed'), + count: 3 }, - :complete => { - :label => _('Complete'), - :count => 2 + complete: { + label: _('Complete'), + count: 2 }, - :other => { - :label => _('Other'), - :count => 1 + other: { + label: _('Other'), + count: 1 } } expect(info_request_batch.request_phases_summary).to eq expected @@ -729,7 +739,7 @@ describe "#log_event" do let(:public_bodies) { FactoryBot.create_list(:public_body, 3) } let(:info_request_batch) do - FactoryBot.create(:info_request_batch, :public_bodies => public_bodies) + FactoryBot.create(:info_request_batch, public_bodies: public_bodies) end before do diff --git a/spec/models/info_request_event_spec.rb b/spec/models/info_request_event_spec.rb index 7bc84b7f58..94549ccacf 100644 --- a/spec/models/info_request_event_spec.rb +++ b/spec/models/info_request_event_spec.rb @@ -1,12 +1,11 @@ # == Schema Information -# Schema version: 20220408125559 +# Schema version: 20230127132719 # # Table name: info_request_events # # id :integer not null, primary key # info_request_id :integer not null # event_type :text not null -# params_yaml :text not null # created_at :datetime not null # described_state :string # calculated_state :string @@ -21,15 +20,24 @@ require 'spec_helper' RSpec.describe InfoRequestEvent do + describe 'event_type scopes' do + described_class::EVENT_TYPES.each do |event_type| + it "for '#{event_type}' events" do + expect(described_class.public_send("#{event_type}_events").to_sql). + to eq(described_class.where(event_type: event_type).to_sql) + end + end + end + describe "when checking for a valid state" do it 'should add an error message for described_state if it is not valid' do - ire = InfoRequestEvent.new(:described_state => 'nope') + ire = InfoRequestEvent.new(described_state: 'nope') ire.valid? expect(ire.errors.messages[:described_state]).to eq ["is not a valid state"] end it 'should not add an error message for described_state if it is valid' do - ire = InfoRequestEvent.new(:described_state => 'waiting_response') + ire = InfoRequestEvent.new(described_state: 'waiting_response') ire.valid? expect(ire.errors.messages[:described_state]).to be_blank end @@ -39,23 +47,16 @@ let(:ire) { InfoRequestEvent.new } it "should convert event parameters into YAML and back successfully" do - example_params = { :foo => 'this is stuff', :bar => 83, :humbug => "yikes!!!" } + example_params = { foo: 'this is stuff', bar: 83, humbug: "yikes!!!" } ire.params = example_params - expect(ire.params_yaml).to eq(example_params.to_yaml) expect(ire.params).to eq(example_params) end - it "should restore UTF8-heavy params stored under ruby 1.8 as UTF-8" do - utf8_params = "--- \n:foo: !binary |\n 0KLQvtCz0LDRiCDR\n" - ire.params_yaml = utf8_params - expect(ire.params[:foo].encoding.to_s).to eq('UTF-8') - end - it "should store the incoming_message, outgoing_messsage and comment ids" do comment = FactoryBot.create(:comment) - example_params = {:incoming_message_id => 1, - :outgoing_message_id => 2, - :comment_id => comment.id} + example_params = {incoming_message_id: 1, + outgoing_message_id: 2, + comment_id: comment.id} ire.params = example_params expect(ire.incoming_message_id).to eq(1) expect(ire.outgoing_message_id).to eq(2) @@ -90,70 +91,6 @@ ire.params = { foo_id: 4 } expect(ire.params).to include(foo_id: 4) end - - it "should allow params_yaml to be blank" do - ire.params_yaml = '' - - expect(ire.params).to eql({}) - end - end - - describe 'when deciding if it is indexed by search' do - - it 'returns a falsey value for a comment that is not visible' do - comment = FactoryBot.create(:hidden_comment) - comment_event = FactoryBot.build(:comment_event, :comment => comment) - expect(comment_event.indexed_by_search?).to be_falsey - end - - it 'returns a truthy value for a comment that is visible' do - comment = FactoryBot.create(:comment) - comment_event = FactoryBot.build(:comment_event, :comment => comment) - expect(comment_event.indexed_by_search?).to be_truthy - end - - it 'returns a falsey value for an incoming message that is not indexed by search' do - incoming_message = FactoryBot.create(:incoming_message, :hidden) - response_event = FactoryBot.build(:response_event, - :incoming_message => incoming_message) - expect(response_event.indexed_by_search?).to be_falsey - end - - it 'returns a truthy value for an incoming message that is indexed by search' do - incoming_message = FactoryBot.create(:incoming_message) - response_event = FactoryBot.build(:response_event, - :incoming_message => incoming_message) - expect(response_event.indexed_by_search?).to be_truthy - end - - it 'returns a falsey value for an outgoing message that is not indexed by search' do - outgoing_message = FactoryBot.create(:hidden_followup) - followup_event = FactoryBot.build(:followup_sent_event, - :outgoing_message => outgoing_message) - expect(followup_event.indexed_by_search?).to be_falsey - end - - it 'returns a truthy value for an outgoing message that is indexed by search' do - outgoing_message = FactoryBot.create(:new_information_followup) - followup_event = FactoryBot.build(:followup_sent_event, - :outgoing_message => outgoing_message) - expect(followup_event.indexed_by_search?).to be_truthy - end - - it 'returns a falsey value for an overdue event' do - overdue_event = FactoryBot.build(:overdue_event) - expect(overdue_event.indexed_by_search?).to be_falsey - end - - it 'returns a falsey value for a very overdue event' do - very_overdue_event = FactoryBot.build(:very_overdue_event) - expect(very_overdue_event.indexed_by_search?).to be_falsey - end - - it 'returns a falsey value for an embargo expiry event' do - expire_embargo_event = FactoryBot.build(:expire_embargo_event) - expect(expire_embargo_event.indexed_by_search?).to be_falsey - end end describe '.count_of_hides_by_week' do @@ -186,80 +123,13 @@ end end - describe '#requested_by' do - it "should return the slug of the associated request's user" do - ire = FactoryBot.create(:info_request_event) - expect(ire.requested_by).to eq(ire.info_request.user_name_slug) - end - end - - describe '#requested_from' do - it "should return an array of translated public body url_name values" do - ire = FactoryBot.create(:info_request_event) - public_body = ire.info_request.public_body - expect(ire.requested_from).to eq([public_body.url_name]) - end - end - - describe '#commented_by' do - context 'if it is a comment event' do - it "should return the commenter's url_name" do - user = FactoryBot.create(:user) - comment = FactoryBot.create(:comment, :user => user) - ire = FactoryBot.create(:info_request_event, - :event_type => 'comment', - :comment => comment) - expect(ire.commented_by).to eq(user.url_name) - end - end - - context 'if it is not a comment event' do - it 'should return a blank string' do - ire = FactoryBot.create(:info_request_event) - expect(ire.commented_by).to eq('') - end - end - end - - describe '#variety' do - it 'should be an alias for event_type' do - ire = FactoryBot.create(:info_request_event) - expect(ire.variety).to eq(ire.event_type) - end - end - - describe '#latest_variety' do - it 'should return the variety for the most recent event of the related request' do - ire = FactoryBot.create(:info_request_event) - request = ire.info_request - new_event = FactoryBot.create(:info_request_event, - :event_type => 'comment', - :info_request => request) - request.reload - expect(ire.latest_variety).to eq('comment') - end - end - - describe '#latest_status' do - it 'should return the calculated_state of the most recent event of the related request' do - ire = FactoryBot.create(:info_request_event) - request = ire.info_request - new_event = FactoryBot.create(:info_request_event, - :event_type => 'comment', - :info_request => request) - new_event.set_calculated_state!('internal_review') - request.reload - expect(ire.latest_status).to eq('internal_review') - end - end - describe '#title' do context 'a sent event' do it 'should return the related info_request title' do - info_request = FactoryBot.create(:info_request, :title => "Hi!") + info_request = FactoryBot.create(:info_request, title: "Hi!") ire = FactoryBot.create(:info_request_event, - :info_request => info_request, - :event_type => 'sent') + info_request: info_request, + event_type: 'sent') expect(ire.title).to eq("Hi!") end @@ -273,45 +143,13 @@ end end - describe '#filetype' do - context 'a response event' do - let(:ire) { ire = FactoryBot.create(:response_event) } - - it 'should raise an error if there is not incoming_message' do - ire.incoming_message = nil - expect { ire.filetype }.to raise_error. - with_message(/event type is 'response' but no incoming message for event/) - end - - it 'should return a blank string if there are no attachments' do - info_request = ire.info_request - expect(ire.filetype).to eq('') - end - - it 'should return a space separated list of the attachment file types' do - info_request = ire.info_request - incoming = FactoryBot.create(:incoming_message_with_attachments, - :info_request => info_request) - ire.incoming_message = incoming - expect(ire.filetype).to eq('pdf') - end - end - - context 'not a response event' do - it 'should return a blank string' do - ire = FactoryBot.create(:info_request_event, :event_type => 'comment') - expect(ire.filetype).to eq('') - end - end - end - describe '#visible' do context 'is a comment' do it 'should return the visibility of the comment' do - comment = FactoryBot.create(:comment, :visible => false) + comment = FactoryBot.create(:comment, visible: false) ire = FactoryBot.create(:info_request_event, - :event_type => 'comment', - :comment => comment) + event_type: 'comment', + comment: comment) expect(ire.visible).to eq(false) end end @@ -324,20 +162,11 @@ end end - describe '#params' do - it 'should not error with Rails 5.0 params' do - ire = InfoRequestEvent.new( - params_yaml: load_file_fixture('yaml_compatibility_5_0.yml') - ) - expect { ire.params }.to_not raise_error - end - end - describe '#params_diff' do let(:ire) { InfoRequestEvent.new } it "should return old, new and other params" do - ire.params = {:old_foo => 'this is stuff', :foo => 'stuff', :bar => 84} + ire.params = {old_foo: 'this is stuff', foo: 'stuff', bar: 84} expected_hash = { new: { foo: 'stuff' }, old: { foo: 'this is stuff' }, @@ -347,14 +176,14 @@ end it 'should drop matching old and new values' do - ire.params = {:old_foo => 'stuff', :foo => 'stuff', :bar => 84} + ire.params = {old_foo: 'stuff', foo: 'stuff', bar: 84} expected_hash = { new: {}, old: {}, other: { bar: 84 } } expect(ire.params_diff).to eq(expected_hash) end it 'returns a url_name if passed a User' do user = FactoryBot.create(:user) - ire.params = {:old_foo => "", :foo => user} + ire.params = {old_foo: "", foo: user} expected_hash = { new: { foo: { gid: user.to_global_id.to_s } }, old: { foo: '' }, @@ -368,9 +197,9 @@ let(:request) { FactoryBot.create(:info_request) } it 'should mark the model for reindexing in xapian if there is no no_xapian_reindex flag on the object' do - event = InfoRequestEvent.new(:info_request => request, - :event_type => 'sent', - :params => {}) + event = InfoRequestEvent.new(info_request: request, + event_type: 'sent', + params: {}) expect(event).to receive(:xapian_mark_needs_index) event.run_callbacks(:save) end @@ -380,9 +209,9 @@ it "updates the parent info_request's last_public_response_at value" do im = FactoryBot.create(:incoming_message) response_event = FactoryBot. - create(:info_request_event, :event_type => 'response', - :info_request => request, - :incoming_message => im) + create(:info_request_event, event_type: 'response', + info_request: request, + incoming_message: im) expect(request.last_public_response_at).to be_within(1.second). of response_event.created_at end @@ -393,8 +222,8 @@ it "does not update the info_request's last_public_response_at value" do expect_any_instance_of(InfoRequestEvent).not_to receive(:update_request) - event = FactoryBot.create(:info_request_event, :event_type => 'comment', - :info_request => request) + event = FactoryBot.create(:info_request_event, event_type: 'comment', + info_request: request) expect(request.last_public_response_at).to be_nil end @@ -403,11 +232,11 @@ context "the incoming_message is hidden" do it "sets the parent info_request's last_public_response_at to nil" do - im = FactoryBot.create(:incoming_message, :prominence => 'hidden') + im = FactoryBot.create(:incoming_message, prominence: 'hidden') response_event = FactoryBot. - create(:info_request_event, :event_type => 'response', - :info_request => request, - :incoming_message => im) + create(:info_request_event, event_type: 'response', + info_request: request, + incoming_message: im) expect(request.last_public_response_at).to be_nil end @@ -424,14 +253,14 @@ describe "should know" do it "that it's an incoming message" do - event = InfoRequestEvent.new(:incoming_message => mock_model(IncomingMessage)) + event = InfoRequestEvent.new(incoming_message: mock_model(IncomingMessage)) expect(event.is_incoming_message?).to be_truthy expect(event.is_outgoing_message?).to be_falsey expect(event.is_comment?).to be_falsey end it "that it's an outgoing message" do - event = InfoRequestEvent.new(:outgoing_message => mock_model(OutgoingMessage)) + event = InfoRequestEvent.new(outgoing_message: mock_model(OutgoingMessage)) event.id = 1 expect(event.is_incoming_message?).to be_falsey expect(event.is_outgoing_message?).to be_truthy @@ -439,7 +268,7 @@ end it "that it's a comment" do - event = InfoRequestEvent.new(:comment => mock_model(Comment)) + event = InfoRequestEvent.new(comment: mock_model(Comment)) event.id = 1 expect(event.is_incoming_message?).to be_falsey expect(event.is_outgoing_message?).to be_falsey @@ -483,32 +312,32 @@ end it 'should return false if one email address exists and the other does not' do - allow(info_request_event).to receive(:params).and_return(:email => 'test@example.com') + allow(info_request_event).to receive(:params).and_return(email: 'test@example.com') allow(info_request_event).to receive_message_chain(:info_request, :get_previous_email_sent_to).and_return(nil) expect(info_request_event.same_email_as_previous_send?).to be false end it 'should return true if the addresses are identical' do - allow(info_request_event).to receive(:params).and_return(:email => 'test@example.com') + allow(info_request_event).to receive(:params).and_return(email: 'test@example.com') allow(info_request_event).to receive_message_chain(:info_request, :get_previous_email_sent_to).and_return('test@example.com') expect(info_request_event.same_email_as_previous_send?).to be true end it 'should return false if the addresses are different' do - allow(info_request_event).to receive(:params).and_return(:email => 'test@example.com') + allow(info_request_event).to receive(:params).and_return(email: 'test@example.com') allow(info_request_event).to receive_message_chain(:info_request, :get_previous_email_sent_to).and_return('different@example.com') expect(info_request_event.same_email_as_previous_send?).to be false end it 'should return true if the addresses have different formats' do - allow(info_request_event).to receive(:params).and_return(:email => 'A Test ') + allow(info_request_event).to receive(:params).and_return(email: 'A Test ') allow(info_request_event).to receive_message_chain(:info_request, :get_previous_email_sent_to).and_return('test@example.com') expect(info_request_event.same_email_as_previous_send?).to be true end it 'should handle non-ascii characters in the name input' do address = "\"Someone’s name\" " - allow(info_request_event).to receive(:params).and_return(:email => address) + allow(info_request_event).to receive(:params).and_return(email: address) allow(info_request_event).to receive_message_chain(:info_request, :get_previous_email_sent_to).and_return(address) expect(info_request_event.same_email_as_previous_send?).to be true end @@ -543,36 +372,36 @@ end describe '#destroy' do - let (:info_request) { FactoryBot.create(:info_request) } - let (:event) { InfoRequestEvent.create(:info_request => info_request, - :event_type => 'sent', - :params => {}) + let(:info_request) { FactoryBot.create(:info_request) } + let(:event) { InfoRequestEvent.create(info_request: info_request, + event_type: 'sent', + params: {}) } it 'should destroy the info_request_event' do event.destroy - expect(InfoRequestEvent.where(:id => event.id)).to be_empty + expect(InfoRequestEvent.where(id: event.id)).to be_empty end it 'should destroy associated user_info_request_sent_alerts' do user = FactoryBot.create(:user) - UserInfoRequestSentAlert.create(:info_request_event_id => event.id, - :alert_type => 'overdue_1', - :user => user, - :info_request => info_request) + UserInfoRequestSentAlert.create(info_request_event_id: event.id, + alert_type: 'overdue_1', + user: user, + info_request: info_request) event.destroy - expect(UserInfoRequestSentAlert.where(:info_request_event_id => event.id)). + expect(UserInfoRequestSentAlert.where(info_request_event_id: event.id)). to be_empty end it 'should destroy associated track_things_sent_emails' do track_thing = FactoryBot.create(:search_track, - :info_request => info_request) - TrackThingsSentEmail.create(:track_thing => track_thing, - :info_request_event => event) + info_request: info_request) + TrackThingsSentEmail.create(track_thing: track_thing, + info_request_event: event) event.reload event.destroy - expect(TrackThingsSentEmail.where(:info_request_event_id => event.id)). + expect(TrackThingsSentEmail.where(info_request_event_id: event.id)). to be_empty end @@ -580,157 +409,54 @@ describe "editing requests" do let(:unchanged_params) do - { :editor => "henare", - :old_title => "How much wood does a woodpecker peck?", - :title => "How much wood does a woodpecker peck?", - :old_described_state => "rejected", - :described_state => "rejected", - :old_awaiting_description => false, - :awaiting_description => false, - :old_allow_new_responses_from => "anybody", - :allow_new_responses_from => "anybody", - :old_handle_rejected_responses => "bounce", - :handle_rejected_responses => "bounce", - :old_tag_string => "", - :tag_string => "", - :old_comments_allowed => true, - :comments_allowed => true } + { editor: "henare", + old_title: "How much wood does a woodpecker peck?", + title: "How much wood does a woodpecker peck?", + old_described_state: "rejected", + described_state: "rejected", + old_awaiting_description: false, + awaiting_description: false, + old_allow_new_responses_from: "anybody", + allow_new_responses_from: "anybody", + old_handle_rejected_responses: "bounce", + handle_rejected_responses: "bounce", + old_tag_string: "", + tag_string: "", + old_comments_allowed: true, + comments_allowed: true } end it "should change type to hidden when only editing prominence to hidden" do - params = unchanged_params.merge({:old_prominence => "normal", :prominence => "hidden"}) + params = unchanged_params.merge({old_prominence: "normal", prominence: "hidden"}) - ire = InfoRequestEvent.create!(:info_request => FactoryBot.create(:info_request), - :event_type => "edit", - :params => params) + ire = InfoRequestEvent.create!(info_request: FactoryBot.create(:info_request), + event_type: "edit", + params: params) expect(ire.event_type).to eql "hide" end it "should change type to hidden when only editing prominence to requester_only" do - params = unchanged_params.merge({:old_prominence => "normal", :prominence => "requester_only"}) + params = unchanged_params.merge({old_prominence: "normal", prominence: "requester_only"}) - ire = InfoRequestEvent.create!(:info_request => FactoryBot.create(:info_request), - :event_type => "edit", - :params => params) + ire = InfoRequestEvent.create!(info_request: FactoryBot.create(:info_request), + event_type: "edit", + params: params) expect(ire.event_type).to eql "hide" end it "should change type to hidden when only editing prominence to backpage" do - params = unchanged_params.merge({:old_prominence => "normal", :prominence => "backpage"}) + params = unchanged_params.merge({old_prominence: "normal", prominence: "backpage"}) - ire = InfoRequestEvent.create!(:info_request => FactoryBot.create(:info_request), - :event_type => "edit", - :params => params) + ire = InfoRequestEvent.create!(info_request: FactoryBot.create(:info_request), + event_type: "edit", + params: params) expect(ire.event_type).to eql "hide" end end - describe "#only_editing_prominence_to_hide?" do - let(:unchanged_params) do - { :editor => "henare", - :old_title => "How much wood does a woodpecker peck?", - :title => "How much wood does a woodpecker peck?", - :old_described_state => "rejected", - :described_state => "rejected", - :old_awaiting_description => false, - :awaiting_description => false, - :old_allow_new_responses_from => "anybody", - :allow_new_responses_from => "anybody", - :old_handle_rejected_responses => "bounce", - :handle_rejected_responses => "bounce", - :old_tag_string => "", - :tag_string => "", - :old_comments_allowed => true, - :comments_allowed => true } - end - - it "should be false if it's not an edit" do - ire = InfoRequestEvent.new(:event_type => "resent") - - expect(ire.only_editing_prominence_to_hide?).to be false - end - - it "should be false if it's already a hide event" do - ire = InfoRequestEvent.new(:event_type => "hide") - - expect(ire.only_editing_prominence_to_hide?).to be false - end - - it "should be false if editing multiple conditions" do - params = unchanged_params.merge({ :old_prominence => "normal", - :prominence => "backpage", - :old_comments_allowed => true, - :comments_allowed => false }) - - ire = InfoRequestEvent.new(:event_type => "edit", :params => params) - - expect(ire.only_editing_prominence_to_hide?).to be false - end - - context "when only editing prominence to hidden" do - let(:params) { unchanged_params.merge({:old_prominence => "normal", :prominence => "hidden"}) } - - it do - ire = InfoRequestEvent.new(:event_type => "edit", :params => params) - - expect(ire.only_editing_prominence_to_hide?).to be true - end - end - - context "when only editing prominence to requester_only" do - let(:params) { unchanged_params.merge({:old_prominence => "normal", :prominence => "requester_only"}) } - - it "should be true if only editing prominence to requester_only" do - ire = InfoRequestEvent.new(:event_type => "edit", :params => params) - - expect(ire.only_editing_prominence_to_hide?).to be true - end - end - - context "when only editing prominence to backpage" do - let(:params) { unchanged_params.merge({:old_prominence => "normal", :prominence => "backpage"}) } - - it "should be true if only editing prominence to backpage" do - ire = InfoRequestEvent.new(:event_type => "edit", :params => params) - - expect(ire.only_editing_prominence_to_hide?).to be true - end - end - - context "when the old prominence was hidden" do - let(:params) { unchanged_params.merge({:old_prominence => "hidden", :prominence => "requester_only"}) } - - it do - ire = InfoRequestEvent.new(:event_type => "edit", :params => params) - - expect(ire.only_editing_prominence_to_hide?).to be false - end - end - - context "when the old prominence was requester_only" do - let(:params) { unchanged_params.merge({:old_prominence => "requester_only", :prominence => "hidden"}) } - - it do - ire = InfoRequestEvent.new(:event_type => "edit", :params => params) - - expect(ire.only_editing_prominence_to_hide?).to be false - end - end - - context "when the old prominence was backpage" do - let(:params) { unchanged_params.merge({:old_prominence => "backpage", :prominence => "hidden"}) } - - it do - ire = InfoRequestEvent.new(:event_type => "edit", :params => params) - - expect(ire.only_editing_prominence_to_hide?).to be false - end - end - end - describe '#resets_due_dates?' do it 'returns true if the event is a sending of the request' do @@ -854,7 +580,7 @@ context 'if there is a subsequent followup' do let!(:followup) do FactoryBot.create(:followup_sent_event, - :info_request => response_event.info_request) + info_request: response_event.info_request) end it 'resets the due dates on the request' do @@ -885,4 +611,272 @@ end + # Testing a private callback helper + describe "#only_editing_prominence_to_hide?" do + let(:unchanged_params) do + { editor: "henare", + old_title: "How much wood does a woodpecker peck?", + title: "How much wood does a woodpecker peck?", + old_described_state: "rejected", + described_state: "rejected", + old_awaiting_description: false, + awaiting_description: false, + old_allow_new_responses_from: "anybody", + allow_new_responses_from: "anybody", + old_handle_rejected_responses: "bounce", + handle_rejected_responses: "bounce", + old_tag_string: "", + tag_string: "", + old_comments_allowed: true, + comments_allowed: true } + end + + it "should be false if it's not an edit" do + ire = InfoRequestEvent.new(event_type: "resent") + + expect(ire.send(:only_editing_prominence_to_hide?)).to be false + end + + it "should be false if it's already a hide event" do + ire = InfoRequestEvent.new(event_type: "hide") + + expect(ire.send(:only_editing_prominence_to_hide?)).to be false + end + + it "should be false if editing multiple conditions" do + params = unchanged_params.merge({ old_prominence: "normal", + prominence: "backpage", + old_comments_allowed: true, + comments_allowed: false }) + + ire = InfoRequestEvent.new(event_type: "edit", params: params) + + expect(ire.send(:only_editing_prominence_to_hide?)).to be false + end + + context "when only editing prominence to hidden" do + let(:params) { unchanged_params.merge({old_prominence: "normal", prominence: "hidden"}) } + + it do + ire = InfoRequestEvent.new(event_type: "edit", params: params) + + expect(ire.send(:only_editing_prominence_to_hide?)).to be true + end + end + + context "when only editing prominence to requester_only" do + let(:params) { unchanged_params.merge({old_prominence: "normal", prominence: "requester_only"}) } + + it "should be true if only editing prominence to requester_only" do + ire = InfoRequestEvent.new(event_type: "edit", params: params) + + expect(ire.send(:only_editing_prominence_to_hide?)).to be true + end + end + + context "when only editing prominence to backpage" do + let(:params) { unchanged_params.merge({old_prominence: "normal", prominence: "backpage"}) } + + it "should be true if only editing prominence to backpage" do + ire = InfoRequestEvent.new(event_type: "edit", params: params) + + expect(ire.send(:only_editing_prominence_to_hide?)).to be true + end + end + + context "when the old prominence was hidden" do + let(:params) { unchanged_params.merge({old_prominence: "hidden", prominence: "requester_only"}) } + + it do + ire = InfoRequestEvent.new(event_type: "edit", params: params) + + expect(ire.send(:only_editing_prominence_to_hide?)).to be false + end + end + + context "when the old prominence was requester_only" do + let(:params) { unchanged_params.merge({old_prominence: "requester_only", prominence: "hidden"}) } + + it do + ire = InfoRequestEvent.new(event_type: "edit", params: params) + + expect(ire.send(:only_editing_prominence_to_hide?)).to be false + end + end + + context "when the old prominence was backpage" do + let(:params) { unchanged_params.merge({old_prominence: "backpage", prominence: "hidden"}) } + + it do + ire = InfoRequestEvent.new(event_type: "edit", params: params) + + expect(ire.send(:only_editing_prominence_to_hide?)).to be false + end + end + end + + + # INDEXING HELPERS + # + # Technically don't need to test because these are private, but we want to + # ensure we're populating the search index with the correct values so these + # currently call the method via `send`. + + describe 'when deciding if it is indexed by search' do + it 'returns a falsey value for a comment that is not visible' do + comment = FactoryBot.create(:hidden_comment) + comment_event = FactoryBot.build(:comment_event, comment: comment) + expect(comment_event.send(:indexed_by_search?)).to be_falsey + end + + it 'returns a truthy value for a comment that is visible' do + comment = FactoryBot.create(:comment) + comment_event = FactoryBot.build(:comment_event, comment: comment) + expect(comment_event.send(:indexed_by_search?)).to be_truthy + end + + it 'returns a falsey value for an incoming message that is not indexed by search' do + incoming_message = FactoryBot.create(:incoming_message, :hidden) + response_event = FactoryBot.build(:response_event, + incoming_message: incoming_message) + expect(response_event.send(:indexed_by_search?)).to be_falsey + end + + it 'returns a truthy value for an incoming message that is indexed by search' do + incoming_message = FactoryBot.create(:incoming_message) + response_event = FactoryBot.build(:response_event, + incoming_message: incoming_message) + expect(response_event.send(:indexed_by_search?)).to be_truthy + end + + it 'returns a falsey value for an outgoing message that is not indexed by search' do + outgoing_message = FactoryBot.create(:hidden_followup) + followup_event = FactoryBot.build(:followup_sent_event, + outgoing_message: outgoing_message) + expect(followup_event.send(:indexed_by_search?)).to be_falsey + end + + it 'returns a truthy value for an outgoing message that is indexed by search' do + outgoing_message = FactoryBot.create(:new_information_followup) + followup_event = FactoryBot.build(:followup_sent_event, + outgoing_message: outgoing_message) + expect(followup_event.send(:indexed_by_search?)).to be_truthy + end + + it 'returns a falsey value for an overdue event' do + overdue_event = FactoryBot.build(:overdue_event) + expect(overdue_event.send(:indexed_by_search?)).to be_falsey + end + + it 'returns a falsey value for a very overdue event' do + very_overdue_event = FactoryBot.build(:very_overdue_event) + expect(very_overdue_event.send(:indexed_by_search?)).to be_falsey + end + + it 'returns a falsey value for an embargo expiry event' do + expire_embargo_event = FactoryBot.build(:expire_embargo_event) + expect(expire_embargo_event.send(:indexed_by_search?)).to be_falsey + end + end + + describe '#requested_by' do + it "should return the slug of the associated request's user" do + ire = FactoryBot.create(:info_request_event) + expect(ire.send(:requested_by)).to eq(ire.info_request.user_name_slug) + end + end + + + describe '#requested_from' do + it "should return an array of translated public body url_name values" do + ire = FactoryBot.create(:info_request_event) + public_body = ire.info_request.public_body + expect(ire.send(:requested_from)).to eq([public_body.url_name]) + end + end + + describe '#commented_by' do + context 'if it is a comment event' do + it "should return the commenter's url_name" do + user = FactoryBot.create(:user) + comment = FactoryBot.create(:comment, user: user) + ire = FactoryBot.create(:info_request_event, + event_type: 'comment', + comment: comment) + expect(ire.send(:commented_by)).to eq(user.url_name) + end + end + + context 'if it is not a comment event' do + it 'should return a blank string' do + ire = FactoryBot.create(:info_request_event) + expect(ire.send(:commented_by)).to eq('') + end + end + end + + describe '#variety' do + it 'should be an alias for event_type' do + ire = FactoryBot.create(:info_request_event) + expect(ire.send(:variety)).to eq(ire.event_type) + end + end + + describe '#latest_variety' do + it 'should return the variety for the most recent event of the related request' do + ire = FactoryBot.create(:info_request_event) + request = ire.info_request + new_event = FactoryBot.create(:info_request_event, + event_type: 'comment', + info_request: request) + request.reload + expect(ire.send(:latest_variety)).to eq('comment') + end + end + + describe '#latest_status' do + it 'should return the calculated_state of the most recent event of the related request' do + ire = FactoryBot.create(:info_request_event) + request = ire.info_request + new_event = FactoryBot.create(:info_request_event, + event_type: 'comment', + info_request: request) + new_event.set_calculated_state!('internal_review') + request.reload + expect(ire.send(:latest_status)).to eq('internal_review') + end + end + + describe '#filetype' do + context 'a response event' do + let(:ire) { ire = FactoryBot.create(:response_event) } + + it 'should raise an error if there is not incoming_message' do + ire.incoming_message = nil + expect { ire.send(:filetype) }.to raise_error. + with_message(/event type is 'response' but no incoming message for event/) + end + + it 'should return a blank string if there are no attachments' do + info_request = ire.info_request + expect(ire.send(:filetype)).to eq('') + end + + it 'should return a space separated list of the attachment file types' do + info_request = ire.info_request + incoming = FactoryBot.create(:incoming_message_with_attachments, + info_request: info_request) + ire.incoming_message = incoming + expect(ire.send(:filetype)).to eq('pdf') + end + end + + context 'not a response event' do + it 'should return a blank string' do + ire = FactoryBot.create(:info_request_event, event_type: 'comment') + expect(ire.send(:filetype)).to eq('') + end + end + end + end diff --git a/spec/models/info_request_spec.rb b/spec/models/info_request_spec.rb index 2f3accff7c..01553af038 100644 --- a/spec/models/info_request_spec.rb +++ b/spec/models/info_request_spec.rb @@ -41,12 +41,14 @@ require 'models/concerns/notable' require 'models/concerns/notable_and_taggable' require 'models/concerns/taggable' +require 'models/info_request/batch_pagination' RSpec.describe InfoRequest do it_behaves_like 'concerns/info_request/title_validation', :info_request it_behaves_like 'concerns/notable', :info_request it_behaves_like 'concerns/notable_and_taggable', :info_request it_behaves_like 'concerns/taggable', :info_request + it_behaves_like 'info_request/batch_pagination' describe '.internal' do subject { described_class.internal } @@ -82,6 +84,30 @@ end end + describe '.requests_old_after_months' do + subject { described_class.requests_old_after_months } + + before do + allow(AlaveteliConfiguration). + to receive(:restrict_new_responses_on_old_requests_after_months). + and_return(1) + end + + it { is_expected.to eq(1) } + end + + describe '.requests_very_old_after_months' do + subject { described_class.requests_very_old_after_months } + + before do + allow(AlaveteliConfiguration). + to receive(:restrict_new_responses_on_old_requests_after_months). + and_return(1) + end + + it { is_expected.to eq(4) } + end + describe '#foi_attachments' do subject { info_request.foi_attachments } @@ -136,31 +162,31 @@ describe 'creating a new request' do it "sets the url_title from the supplied title" do - info_request = FactoryBot.create(:info_request, :title => "Test title") + info_request = FactoryBot.create(:info_request, title: "Test title") expect(info_request.url_title).to eq("test_title") end it "ignores any supplied url_title and sets it from the title instead" do - info_request = FactoryBot.create(:info_request, :title => "Real title", - :url_title => "ignore_me") + info_request = FactoryBot.create(:info_request, title: "Real title", + url_title: "ignore_me") expect(info_request.url_title).to eq("real_title") end it "adds the next sequential number to the url_title to make it unique" do - 2.times { FactoryBot.create(:info_request, :title => 'Test title') } - info_request = InfoRequest.new(:title => "Test title") + 2.times { FactoryBot.create(:info_request, title: 'Test title') } + info_request = InfoRequest.new(title: "Test title") expect(info_request.url_title).to eq("test_title_3") end it "strips line breaks from the title" do info_request = FactoryBot.create(:info_request, - :title => "Title\rwith\nline\r\nbreaks") + title: "Title\rwith\nline\r\nbreaks") expect(info_request.title).to eq("Title with line breaks") end it "strips extra spaces from the title" do info_request = FactoryBot.create(:info_request, - :title => "Title\rwith\nline\r\n breaks") + title: "Title\rwith\nline\r\n breaks") expect(info_request.title).to eq("Title with line breaks") end @@ -171,10 +197,10 @@ it "picks the next available url_title instead of failing" do public_body = FactoryBot.create(:public_body) user = FactoryBot.create(:user) - first_request = InfoRequest.new(:title => "Test title", - :user => user, - :public_body => public_body) - second_request = FactoryBot.create(:info_request, :title => "Test title") + first_request = InfoRequest.new(title: "Test title", + user: user, + public_body: public_body) + second_request = FactoryBot.create(:info_request, title: "Test title") first_request.save! expect(first_request.url_title).to eq("test_title_2") end @@ -245,7 +271,7 @@ array << FactoryBot.create(:info_request) end - emails = requests.map { |request| request.incoming_email } + emails = requests.map(&:incoming_email) expect(described_class.matching_incoming_email(emails)).to match(requests) end @@ -283,7 +309,7 @@ context 'when the holding pen exists' do it 'finds a request with title "Holding pen"' do - holding_pen = FactoryBot.create(:info_request, :title => 'Holding pen') + holding_pen = FactoryBot.create(:info_request, title: 'Holding pen') expect(InfoRequest.holding_pen_request).to eq(holding_pen) end @@ -292,7 +318,7 @@ context 'when no holding pen exists' do before do - InfoRequest.where(:title => 'Holding pen').destroy_all + InfoRequest.where(title: 'Holding pen').destroy_all @holding_pen = InfoRequest.holding_pen_request end @@ -329,16 +355,16 @@ before do @request = FactoryBot.create(:info_request) - @request.update(:updated_at => 6.months.ago, - :rejected_incoming_count => 3, - :allow_new_responses_from => 'nobody') - @options = {:rejection_threshold => 2, - :age_in_months => 5, - :dryrun => true} + @request.update(updated_at: 6.months.ago, + rejected_incoming_count: 3, + allow_new_responses_from: 'nobody') + @options = {rejection_threshold: 2, + age_in_months: 5, + dryrun: true} end it 'returns an count of requests updated ' do - expect(InfoRequest.reject_incoming_at_mta(@options.merge(:dryrun => false))). + expect(InfoRequest.reject_incoming_at_mta(@options.merge(dryrun: false))). to eq(1) end @@ -348,14 +374,14 @@ end it 'sets reject_incoming_at_mta on a request meeting the criteria passed' do - InfoRequest.reject_incoming_at_mta(@options.merge(:dryrun => false)) + InfoRequest.reject_incoming_at_mta(@options.merge(dryrun: false)) expect(InfoRequest.find(@request.id).reject_incoming_at_mta).to be true end it 'does not set reject_incoming_at_mta on a request not meeting the criteria passed' do - InfoRequest.reject_incoming_at_mta(@options.merge(:dryrun => false, - :age_in_months => 7)) + InfoRequest.reject_incoming_at_mta(@options.merge(dryrun: false, + age_in_months: 7)) expect(InfoRequest.find(@request.id).reject_incoming_at_mta).to be false end @@ -483,7 +509,7 @@ it 'does not mark requests marked as withdrawn as awaiting description' do info_request = FactoryBot.create(:info_request, - :awaiting_description => false) + awaiting_description: false) info_request.described_state = "user_withdrawn" info_request.save! email, raw_email = email_and_raw_email @@ -507,7 +533,7 @@ info_request. receive(email, raw_email, - :rejected_reason => 'rejected for testing') + rejected_reason: 'rejected for testing') expect(info_request.info_request_events.last.params[:rejected_reason]). to eq('rejected for testing') end @@ -586,7 +612,7 @@ it 'processes mail from the poller' do with_feature_enabled(:accept_mail_from_anywhere) do email, raw_email = email_and_raw_email - info_request.receive(email, raw_email, :source => :poller) + info_request.receive(email, raw_email, source: :poller) expect(info_request.incoming_messages.count).to eq(1) expect(info_request.incoming_messages.last).to be_persisted end @@ -595,7 +621,7 @@ it 'processes mail from mailin' do with_feature_enabled(:accept_mail_from_anywhere) do email, raw_email = email_and_raw_email - info_request.receive(email, raw_email, :source => :poller) + info_request.receive(email, raw_email, source: :poller) expect(info_request.incoming_messages.count).to eq(1) expect(info_request.incoming_messages.last).to be_persisted end @@ -619,14 +645,14 @@ it 'processes mail from the poller' do email, raw_email = email_and_raw_email - info_request.receive(email, raw_email, :source => :poller) + info_request.receive(email, raw_email, source: :poller) expect(info_request.incoming_messages.count).to eq(1) expect(info_request.incoming_messages.last).to be_persisted end it 'ignores mail from mailin' do email, raw_email = email_and_raw_email - info_request.receive(email, raw_email, :source => :mailin) + info_request.receive(email, raw_email, source: :mailin) expect(info_request.incoming_messages.count).to eq(0) end @@ -637,13 +663,13 @@ it 'ignores mail from the poller' do email, raw_email = email_and_raw_email - info_request.receive(email, raw_email, :source => :poller) + info_request.receive(email, raw_email, source: :poller) expect(info_request.incoming_messages.count).to eq(0) end it 'processes mail from mailin' do email, raw_email = email_and_raw_email - info_request.receive(email, raw_email, :source => :mailin) + info_request.receive(email, raw_email, source: :mailin) expect(info_request.incoming_messages.count).to eq(1) expect(info_request.incoming_messages.last).to be_persisted end @@ -657,8 +683,8 @@ it 'from nobody' do travel_to(5.days.ago) - attrs = { :allow_new_responses_from => 'nobody', - :handle_rejected_responses => 'holding_pen' } + attrs = { allow_new_responses_from: 'nobody', + handle_rejected_responses: 'holding_pen' } info_request = FactoryBot.create(:info_request, attrs) travel_back @@ -680,8 +706,8 @@ end it 'from anybody' do - attrs = { :allow_new_responses_from => 'anybody', - :handle_rejected_responses => 'holding_pen' } + attrs = { allow_new_responses_from: 'anybody', + handle_rejected_responses: 'holding_pen' } info_request = FactoryBot.create(:info_request, attrs) email, raw_email = email_and_raw_email info_request.receive(email, raw_email) @@ -689,10 +715,10 @@ end it 'from authority_only receives if the mail is from the authority' do - attrs = { :allow_new_responses_from => 'authority_only', - :handle_rejected_responses => 'holding_pen' } + attrs = { allow_new_responses_from: 'authority_only', + handle_rejected_responses: 'holding_pen' } info_request = FactoryBot.create(:info_request_with_incoming, attrs) - email, raw_email = email_and_raw_email(:from => 'bob@example.com') + email, raw_email = email_and_raw_email(from: 'bob@example.com') info_request.receive(email, raw_email) expect(info_request.reload.incoming_messages.count).to eq(2) end @@ -700,14 +726,14 @@ it 'from authority_only rejects if there is no from address' do travel_to(5.days.ago) - attrs = { :allow_new_responses_from => 'authority_only', - :handle_rejected_responses => 'holding_pen' } + attrs = { allow_new_responses_from: 'authority_only', + handle_rejected_responses: 'holding_pen' } info_request = FactoryBot.create(:info_request, attrs) travel_back updated_at = info_request.updated_at - email, raw_email = email_and_raw_email(:from => '') + email, raw_email = email_and_raw_email(from: '') info_request.receive(email, raw_email) expect(info_request.reload.incoming_messages.count).to eq(0) holding_pen = InfoRequest.holding_pen_request @@ -724,14 +750,14 @@ it 'from authority_only rejects if the mail is not from the authority' do travel_to(5.days.ago) - attrs = { :allow_new_responses_from => 'authority_only', - :handle_rejected_responses => 'holding_pen' } + attrs = { allow_new_responses_from: 'authority_only', + handle_rejected_responses: 'holding_pen' } info_request = FactoryBot.create(:info_request, attrs) travel_back updated_at = info_request.updated_at - email, raw_email = email_and_raw_email(:from => 'spam@example.net') + email, raw_email = email_and_raw_email(from: 'spam@example.net') info_request.receive(email, raw_email) expect(info_request.reload.incoming_messages.count).to eq(0) holding_pen = InfoRequest.holding_pen_request @@ -755,21 +781,21 @@ end it 'can override the stop new responses status of a request' do - attrs = { :allow_new_responses_from => 'nobody', - :handle_rejected_responses => 'holding_pen' } + attrs = { allow_new_responses_from: 'nobody', + handle_rejected_responses: 'holding_pen' } info_request = FactoryBot.create(:info_request, attrs) email, raw_email = email_and_raw_email info_request.receive(email, raw_email, - :override_stop_new_responses => true) + override_stop_new_responses: true) expect(info_request.incoming_messages.count).to eq(1) end it 'does not check spam when overriding the stop new responses status of a request' do mocked_default_config = { - :spam_action => 'holding_pen', - :spam_header => 'X-Spam-Score', - :spam_threshold => 100 + spam_action: 'holding_pen', + spam_header: 'X-Spam-Score', + spam_threshold: 100 } const = 'InfoRequest::' \ @@ -786,13 +812,13 @@ Plz buy my spam EOF - attrs = { :allow_new_responses_from => 'nobody', - :handle_rejected_responses => 'holding_pen' } + attrs = { allow_new_responses_from: 'nobody', + handle_rejected_responses: 'holding_pen' } info_request = FactoryBot.create(:info_request, attrs) - email, raw_email = email_and_raw_email(:raw_email => spam_email) + email, raw_email = email_and_raw_email(raw_email: spam_email) info_request.receive(email, raw_email, - :override_stop_new_responses => true) + override_stop_new_responses: true) expect(info_request.incoming_messages.count).to eq(1) end @@ -801,10 +827,10 @@ context 'handling rejected responses' do it 'bounces rejected responses if the mail has a from address' do - attrs = { :allow_new_responses_from => 'nobody', - :handle_rejected_responses => 'bounce' } + attrs = { allow_new_responses_from: 'nobody', + handle_rejected_responses: 'bounce' } info_request = FactoryBot.create(:info_request, attrs) - email, raw_email = email_and_raw_email(:from => 'bounce@example.com') + email, raw_email = email_and_raw_email(from: 'bounce@example.com') info_request.receive(email, raw_email) bounce = ActionMailer::Base.deliveries.first expect(bounce.to).to include('bounce@example.com') @@ -813,25 +839,25 @@ it 'does not bounce responses to external requests' do info_request = FactoryBot.create(:external_request) - email, raw_email = email_and_raw_email(:from => 'bounce@example.com') + email, raw_email = email_and_raw_email(from: 'bounce@example.com') info_request.receive(email, raw_email) expect(ActionMailer::Base.deliveries).to be_empty ActionMailer::Base.deliveries.clear end it 'discards rejected responses if the mail has no from address' do - attrs = { :allow_new_responses_from => 'nobody', - :handle_rejected_responses => 'bounce' } + attrs = { allow_new_responses_from: 'nobody', + handle_rejected_responses: 'bounce' } info_request = FactoryBot.create(:info_request, attrs) - email, raw_email = email_and_raw_email(:from => '') + email, raw_email = email_and_raw_email(from: '') info_request.receive(email, raw_email) expect(ActionMailer::Base.deliveries).to be_empty ActionMailer::Base.deliveries.clear end it 'sends rejected responses to the holding pen' do - attrs = { :allow_new_responses_from => 'nobody', - :handle_rejected_responses => 'holding_pen' } + attrs = { allow_new_responses_from: 'nobody', + handle_rejected_responses: 'holding_pen' } info_request = FactoryBot.create(:info_request, attrs) email, raw_email = email_and_raw_email info_request.receive(email, raw_email) @@ -843,8 +869,8 @@ end it 'discards rejected responses' do - attrs = { :allow_new_responses_from => 'nobody', - :handle_rejected_responses => 'blackhole' } + attrs = { allow_new_responses_from: 'nobody', + handle_rejected_responses: 'blackhole' } info_request = FactoryBot.create(:info_request, attrs) email, raw_email = email_and_raw_email info_request.receive(email, raw_email) @@ -854,7 +880,7 @@ end it 'raises an error if there is an unknown handle_rejected_responses' do - attrs = { :allow_new_responses_from => 'nobody' } + attrs = { allow_new_responses_from: 'nobody' } info_request = FactoryBot.create(:info_request, attrs) info_request.update_attribute(:handle_rejected_responses, 'unknown_value') email, raw_email = email_and_raw_email @@ -867,8 +893,8 @@ it "uses instance-specific spam handling first" do info_request = FactoryBot.create(:info_request) - info_request.update!(:handle_rejected_responses => 'bounce', - :allow_new_responses_from => 'nobody') + info_request.update!(handle_rejected_responses: 'bounce', + allow_new_responses_from: 'nobody') allow(AlaveteliConfiguration). to receive(:incoming_email_spam_action).and_return('holding_pen') allow(AlaveteliConfiguration). @@ -893,9 +919,9 @@ info_request = FactoryBot.create(:info_request) mocked_default_config = { - :spam_action => 'holding_pen', - :spam_header => 'X-Spam-Score', - :spam_threshold => 100 + spam_action: 'holding_pen', + spam_header: 'X-Spam-Score', + spam_threshold: 100 } const = 'InfoRequest::' \ @@ -922,9 +948,9 @@ info_request = FactoryBot.create(:info_request) mocked_default_config = { - :spam_action => 'discard', - :spam_header => 'X-Spam-Score', - :spam_threshold => 10 + spam_action: 'discard', + spam_header: 'X-Spam-Score', + spam_threshold: 10 } const = 'InfoRequest::' \ @@ -998,14 +1024,14 @@ end describe "#url_title" do - let(:request) { FactoryBot.create(:info_request, :title => "Test 101") } + let(:request) { FactoryBot.create(:info_request, title: "Test 101") } it "returns the url_title" do expect(request.url_title).to eq('test_101') end it "collapses the url title if requested" do - expect(request.url_title(:collapse => true)).to eq("test") + expect(request.url_title(collapse: true)).to eq("test") end end @@ -1029,7 +1055,7 @@ request = FactoryBot.create(:info_request) new_body = FactoryBot.create(:public_body) editor = FactoryBot.create(:user) - request.move_to_public_body(new_body, :editor => editor) + request.move_to_public_body(new_body, editor: editor) request.reload expect(request.public_body).to eq(new_body) end @@ -1039,7 +1065,7 @@ old_body = request.public_body new_body = FactoryBot.create(:public_body) editor = FactoryBot.create(:user) - request.move_to_public_body(new_body, :editor => editor) + request.move_to_public_body(new_body, editor: editor) request.reload event = request.info_request_events.last @@ -1065,14 +1091,14 @@ request = FactoryBot.create(:info_request) new_body = FactoryBot.create(:public_body) editor = FactoryBot.create(:user) - expect(request.move_to_public_body(new_body, :editor => editor)).to eq(new_body) + expect(request.move_to_public_body(new_body, editor: editor)).to eq(new_body) end it 'retains the existing body if the new body does not exist' do request = FactoryBot.create(:info_request) editor = FactoryBot.create(:user) existing_body = request.public_body - request.move_to_public_body(nil, :editor => editor) + request.move_to_public_body(nil, editor: editor) request.reload expect(request.public_body).to eq(existing_body) end @@ -1082,7 +1108,7 @@ new_body = FactoryBot.build(:public_body) editor = FactoryBot.create(:user) existing_body = request.public_body - request.move_to_public_body(new_body, :editor => editor) + request.move_to_public_body(new_body, editor: editor) request.reload expect(request.public_body).to eq(existing_body) end @@ -1090,7 +1116,7 @@ it 'returns nil if the body cannot be updated' do request = FactoryBot.create(:info_request) editor = FactoryBot.create(:user) - expect(request.move_to_public_body(nil, :editor => editor)).to eq(nil) + expect(request.move_to_public_body(nil, editor: editor)).to eq(nil) end it 'reindexes the info request' do @@ -1098,14 +1124,14 @@ new_body = FactoryBot.create(:public_body) editor = FactoryBot.create(:user) reindex_job = ActsAsXapian::ActsAsXapianJob. - where(:model => 'InfoRequestEvent'). + where(model: 'InfoRequestEvent'). delete_all - request.move_to_public_body(new_body, :editor => editor) + request.move_to_public_body(new_body, editor: editor) request.reload reindex_job = ActsAsXapian::ActsAsXapianJob. - where(:model => 'InfoRequestEvent'). + where(model: 'InfoRequestEvent'). last expect(reindex_job.model_id).to eq(request.info_request_events.last.id) end @@ -1118,65 +1144,65 @@ let(:editor) { FactoryBot.create(:user) } it "increments the new authority's info_requests_count " do - expect { request.move_to_public_body(new_body, :editor => editor) }. + expect { request.move_to_public_body(new_body, editor: editor) }. to change { new_body.reload.info_requests_count }.from(0).to(1) end it "decrements the old authority's info_requests_count " do - expect { request.move_to_public_body(new_body, :editor => editor) }. + expect { request.move_to_public_body(new_body, editor: editor) }. to change { old_body.reload.info_requests_count }.from(1).to(0) end it "increments the new authority's info_requests_visible_count " do - expect { request.move_to_public_body(new_body, :editor => editor) }. + expect { request.move_to_public_body(new_body, editor: editor) }. to change { new_body.reload.info_requests_visible_count }. from(0).to(1) end it "decrements the old authority's info_requests_visible_count " do - expect { request.move_to_public_body(new_body, :editor => editor) }. + expect { request.move_to_public_body(new_body, editor: editor) }. to change { old_body.reload.info_requests_visible_count }. from(1).to(0) end it "increments the new authority's info_requests_successful_count " do - request.update!(:described_state => 'successful') - expect { request.move_to_public_body(new_body, :editor => editor) }. + request.update!(described_state: 'successful') + expect { request.move_to_public_body(new_body, editor: editor) }. to change { new_body.reload.info_requests_successful_count }. from(nil).to(1) end it "decrements the old authority's info_requests_successful_count " do - request.update!(:described_state => 'successful') - expect { request.move_to_public_body(new_body, :editor => editor) }. + request.update!(described_state: 'successful') + expect { request.move_to_public_body(new_body, editor: editor) }. to change { old_body.reload.info_requests_successful_count }. from(1).to(0) end it "increments the new authority's info_requests_not_held_count " do - request.update!(:described_state => 'not_held') - expect { request.move_to_public_body(new_body, :editor => editor) }. + request.update!(described_state: 'not_held') + expect { request.move_to_public_body(new_body, editor: editor) }. to change { new_body.reload.info_requests_not_held_count }. from(nil).to(1) end it "decrements the old authority's info_requests_not_held_count " do - request.update!(:described_state => 'not_held') - expect { request.move_to_public_body(new_body, :editor => editor) }. + request.update!(described_state: 'not_held') + expect { request.move_to_public_body(new_body, editor: editor) }. to change { old_body.reload.info_requests_not_held_count }. from(1).to(0) end it "increments the new authority's info_requests_visible_classified_count " do - request.update!(:awaiting_description => false) - expect { request.move_to_public_body(new_body, :editor => editor) }. + request.update!(awaiting_description: false) + expect { request.move_to_public_body(new_body, editor: editor) }. to change { new_body.reload.info_requests_visible_classified_count }. from(nil).to(1) end it "decrements the old authority's info_requests_visible_classified_count " do - request.update!(:awaiting_description => false) - expect { request.move_to_public_body(new_body, :editor => editor) }. + request.update!(awaiting_description: false) + expect { request.move_to_public_body(new_body, editor: editor) }. to change { old_body.reload.info_requests_visible_classified_count }. from(1).to(0) end @@ -1207,7 +1233,7 @@ request = FactoryBot.create(:info_request) new_user = FactoryBot.create(:user) editor = FactoryBot.create(:user) - request.move_to_user(new_user, :editor => editor) + request.move_to_user(new_user, editor: editor) request.reload expect(request.user).to eq(new_user) end @@ -1217,7 +1243,7 @@ old_user = request.user new_user = FactoryBot.create(:user) editor = FactoryBot.create(:user) - request.move_to_user(new_user, :editor => editor) + request.move_to_user(new_user, editor: editor) request.reload event = request.info_request_events.last @@ -1233,7 +1259,7 @@ request = FactoryBot.create(:info_request) new_user = FactoryBot.create(:user) editor = FactoryBot.create(:user) - expect(request.move_to_user(new_user, :editor => editor)). + expect(request.move_to_user(new_user, editor: editor)). to eq(new_user) end @@ -1241,7 +1267,7 @@ request = FactoryBot.create(:info_request) editor = FactoryBot.create(:user) existing_user = request.user - request.move_to_user(nil, :editor => editor) + request.move_to_user(nil, editor: editor) request.reload expect(request.user).to eq(existing_user) end @@ -1251,7 +1277,7 @@ new_user = FactoryBot.build(:user) editor = FactoryBot.create(:user) existing_user = request.user - request.move_to_user(new_user, :editor => editor) + request.move_to_user(new_user, editor: editor) request.reload expect(request.user).to eq(existing_user) end @@ -1259,7 +1285,7 @@ it 'returns nil if the user cannot be updated' do request = FactoryBot.create(:info_request) editor = FactoryBot.create(:user) - expect(request.move_to_user(nil, :editor => editor)).to eq(nil) + expect(request.move_to_user(nil, editor: editor)).to eq(nil) end it 'reindexes the info request' do @@ -1267,14 +1293,14 @@ new_user = FactoryBot.create(:user) editor = FactoryBot.create(:user) reindex_job = ActsAsXapian::ActsAsXapianJob. - where(:model => 'InfoRequestEvent'). + where(model: 'InfoRequestEvent'). delete_all - request.move_to_user(new_user, :editor => editor) + request.move_to_user(new_user, editor: editor) request.reload reindex_job = ActsAsXapian::ActsAsXapianJob. - where(:model => 'InfoRequestEvent'). + where(model: 'InfoRequestEvent'). last expect(reindex_job.model_id).to eq(request.info_request_events.last.id) end @@ -1286,7 +1312,7 @@ new_user = FactoryBot.create(:user) editor = FactoryBot.create(:user) - expect { request.move_to_user(new_user, :editor => editor) }. + expect { request.move_to_user(new_user, editor: editor) }. to change { new_user.reload.info_requests_count }.from(0).to(1) end @@ -1296,7 +1322,7 @@ new_user = FactoryBot.create(:user) editor = FactoryBot.create(:user) - expect { request.move_to_user(new_user, :editor => editor) }. + expect { request.move_to_user(new_user, editor: editor) }. to change { old_user.reload.info_requests_count }.from(1).to(0) end @@ -1321,62 +1347,62 @@ end it 'destroys associated widget_votes' do - info_request.widget_votes.create(:cookie => 'x' * 20) + info_request.widget_votes.create(cookie: 'x' * 20) info_request.destroy - expect(WidgetVote.where(:info_request_id => info_request.id)).to be_empty + expect(WidgetVote.where(info_request_id: info_request.id)).to be_empty end it 'destroys associated censor_rules' do - censor_rule = FactoryBot.create(:censor_rule, :info_request => info_request) + censor_rule = FactoryBot.create(:censor_rule, info_request: info_request) info_request.reload info_request.destroy - expect(CensorRule.where(:info_request_id => info_request.id)).to be_empty + expect(CensorRule.where(info_request_id: info_request.id)).to be_empty end it 'destroys associated comments' do - comment = FactoryBot.create(:comment, :info_request => info_request) + comment = FactoryBot.create(:comment, info_request: info_request) info_request.reload info_request.destroy - expect(Comment.where(:info_request_id => info_request.id)).to be_empty + expect(Comment.where(info_request_id: info_request.id)).to be_empty end it 'destroys associated info_request_events' do info_request.destroy - expect(InfoRequestEvent.where(:info_request_id => info_request.id)).to be_empty + expect(InfoRequestEvent.where(info_request_id: info_request.id)).to be_empty end it 'destroys associated outgoing_messages' do info_request.destroy - expect(OutgoingMessage.where(:info_request_id => info_request.id)).to be_empty + expect(OutgoingMessage.where(info_request_id: info_request.id)).to be_empty end it 'destroys associated incoming_messages' do ir_with_incoming = FactoryBot.create(:info_request_with_incoming) ir_with_incoming.destroy - expect(IncomingMessage.where(:info_request_id => ir_with_incoming.id)).to be_empty + expect(IncomingMessage.where(info_request_id: ir_with_incoming.id)).to be_empty end it 'destroys associated mail_server_logs' do - MailServerLog.create(:line => 'hi!', :order => 1, :info_request => info_request) + MailServerLog.create(line: 'hi!', order: 1, info_request: info_request) info_request.destroy - expect(MailServerLog.where(:info_request_id => info_request.id)).to be_empty + expect(MailServerLog.where(info_request_id: info_request.id)).to be_empty end it 'destroys associated track_things' do FactoryBot.create(:request_update_track, - :track_medium => 'email_daily', - :info_request => info_request, - :track_query => 'Example Query') + track_medium: 'email_daily', + info_request: info_request, + track_query: 'Example Query') info_request.destroy - expect(TrackThing.where(:info_request_id => info_request.id)).to be_empty + expect(TrackThing.where(info_request_id: info_request.id)).to be_empty end it 'destroys associated user_info_request_sent_alerts' do - UserInfoRequestSentAlert.create(:info_request => info_request, - :user => info_request.user, - :alert_type => 'comment_1') + UserInfoRequestSentAlert.create(info_request: info_request, + user: info_request.user, + alert_type: 'comment_1') info_request.destroy - expect(UserInfoRequestSentAlert.where(:info_request_id => info_request.id)).to be_empty + expect(UserInfoRequestSentAlert.where(info_request_id: info_request.id)).to be_empty end it 'destroys associated embargoes' do @@ -1398,7 +1424,7 @@ it "does not clear the database caches if passed the preserve_database_cache option" do expect(info_request).not_to receive(:clear_in_database_caches!) - info_request.expire(:preserve_database_cache => true) + info_request.expire(preserve_database_cache: true) end it 'updates the search index' do @@ -1490,12 +1516,12 @@ describe '#is_external?' do it 'returns true if there is an external url' do - info_request = InfoRequest.new(:external_url => "demo_url") + info_request = InfoRequest.new(external_url: "demo_url") expect(info_request.is_external?).to eq(true) end it 'returns false if there is not an external url' do - info_request = InfoRequest.new(:external_url => nil) + info_request = InfoRequest.new(external_url: nil) expect(info_request.is_external?).to eq(false) end @@ -1518,7 +1544,7 @@ let(:message_without_reply_to) { FactoryBot.create(:incoming_message) } let(:valid_request) { FactoryBot.create(:info_request) } - let(:unfollowupable_body) { FactoryBot.create(:public_body, :request_email => "") } + let(:unfollowupable_body) { FactoryBot.create(:public_body, request_email: "") } context "it is possible to reply to the public body" do @@ -1538,7 +1564,7 @@ context "the message has a valid reply address" do let(:request) do - FactoryBot.create(:info_request, :public_body => unfollowupable_body) + FactoryBot.create(:info_request, public_body: unfollowupable_body) end let(:dummy_message) { double(IncomingMessage) } @@ -1559,7 +1585,7 @@ context "an external request" do - let(:info_request) { InfoRequest.new(:external_url => "demo_url") } + let(:info_request) { InfoRequest.new(external_url: "demo_url") } it "returns false" do expect(info_request.is_followupable?(message_without_reply_to)). @@ -1576,7 +1602,7 @@ context "belongs to an unfollowupable PublicBody" do let(:request) do - FactoryBot.create(:info_request, :public_body => unfollowupable_body) + FactoryBot.create(:info_request, public_body: unfollowupable_body) end it "returns false" do @@ -1700,7 +1726,7 @@ end it 'rejects an invalid prominence' do - info_request = InfoRequest.new(:prominence => 'something') + info_request = InfoRequest.new(prominence: 'something') info_request.valid? expect(info_request.errors[:prominence]).to include("is not included in the list") end @@ -1789,8 +1815,8 @@ end context 'email with an id mistyped using letters and missing punctuation' do - before { InfoRequest.where(id: 1231014).destroy_all } - let!(:info_request) { FactoryBot.create(:info_request, id: 1231014) } + before { InfoRequest.where(id: 1_231_014).destroy_all } + let!(:info_request) { FactoryBot.create(:info_request, id: 1_231_014) } let(:email) { 'request-123loL4abcdefgh@example.com' } let(:guess) { described_class::Guess.new(info_request, email, :id) } it { is_expected.to include(guess) } @@ -2136,7 +2162,7 @@ it "copes with indexing after item is deleted" do load_raw_emails_data - IncomingMessage.find_each { |message| message.parse_raw_email! } + IncomingMessage.find_each(&:parse_raw_email!) destroy_and_rebuild_xapian_index # delete event from underneath indexing; shouldn't cause error info_request_events(:useless_incoming_message_event).save! @@ -2149,13 +2175,13 @@ describe "#postal_email" do let(:public_body) do - FactoryBot.create(:public_body, :request_email => "test@localhost") + FactoryBot.create(:public_body, request_email: "test@localhost") end context "there is no list of incoming messages to followup" do it "returns the public body's request_email" do - request = FactoryBot.create(:info_request, :public_body => public_body) + request = FactoryBot.create(:info_request, public_body: public_body) expect(request.postal_email).to eq("test@localhost") end @@ -2164,9 +2190,9 @@ context "there is a list of incoming messages to followup" do it "returns the email address from the last message in the chain" do - request = FactoryBot.create(:info_request, :public_body => public_body) + request = FactoryBot.create(:info_request, public_body: public_body) incoming_message = FactoryBot.create(:plain_incoming_message, - :info_request => request) + info_request: request) request.log_event( 'response', incoming_message_id: incoming_message.id @@ -2180,12 +2206,12 @@ describe "#postal_email_name" do - let(:public_body) { FactoryBot.create(:public_body, :name => "Ministry of Test") } + let(:public_body) { FactoryBot.create(:public_body, name: "Ministry of Test") } context "there is no list of incoming messages to followup" do it "returns the public body name" do - request = FactoryBot.create(:info_request, :public_body => public_body) + request = FactoryBot.create(:info_request, public_body: public_body) expect(request.postal_email_name).to eq("Ministry of Test") end @@ -2194,9 +2220,9 @@ context "there is a list of incoming messages to followup" do it "returns the email name from the last message in the chain" do - request = FactoryBot.create(:info_request, :public_body => public_body) + request = FactoryBot.create(:info_request, public_body: public_body) incoming_message = FactoryBot.create(:plain_incoming_message, - :info_request => request) + info_request: request) request.log_event( 'response', incoming_message_id: incoming_message.id @@ -2359,7 +2385,7 @@ before do @mock_user = mock_model(User) - @info_request = InfoRequest.new(:user => @mock_user) + @info_request = InfoRequest.new(user: @mock_user) @other_mock_user = mock_model(User) end @@ -2414,71 +2440,71 @@ let(:user) { FactoryBot.create(:user) } def create_recent_unclassified_request - request = FactoryBot.create(:info_request, :user => user, - :created_at => recent_date) - message = FactoryBot.create(:incoming_message, :created_at => recent_date, - :info_request => request) - FactoryBot.create(:info_request_event, :incoming_message => message, - :event_type => "response", - :info_request => request, - :created_at => recent_date) + request = FactoryBot.create(:info_request, user: user, + created_at: recent_date) + message = FactoryBot.create(:incoming_message, created_at: recent_date, + info_request: request) + FactoryBot.create(:info_request_event, incoming_message: message, + event_type: "response", + info_request: request, + created_at: recent_date) request.awaiting_description = true request.save! request end def create_old_unclassified_request - request = FactoryBot.create(:info_request, :user => user, - :created_at => old_date) - message = FactoryBot.create(:incoming_message, :created_at => old_date, - :info_request => request) - FactoryBot.create(:info_request_event, :incoming_message => message, - :event_type => "response", - :info_request => request, - :created_at => old_date) + request = FactoryBot.create(:info_request, user: user, + created_at: old_date) + message = FactoryBot.create(:incoming_message, created_at: old_date, + info_request: request) + FactoryBot.create(:info_request_event, incoming_message: message, + event_type: "response", + info_request: request, + created_at: old_date) request.awaiting_description = true request.save! request end def create_old_unclassified_described - request = FactoryBot.create(:info_request, :user => user, - :created_at => old_date) - message = FactoryBot.create(:incoming_message, :created_at => old_date, - :info_request => request) - FactoryBot.create(:info_request_event, :incoming_message => message, - :event_type => "response", - :info_request => request, - :created_at => old_date) + request = FactoryBot.create(:info_request, user: user, + created_at: old_date) + message = FactoryBot.create(:incoming_message, created_at: old_date, + info_request: request) + FactoryBot.create(:info_request_event, incoming_message: message, + event_type: "response", + info_request: request, + created_at: old_date) request end def create_old_unclassified_no_user - request = FactoryBot.create(:info_request, :user => nil, - :external_user_name => 'test_user', - :external_url => 'test', - :created_at => old_date) - message = FactoryBot.create(:incoming_message, :created_at => old_date, - :info_request => request) - FactoryBot.create(:info_request_event, :incoming_message => message, - :event_type => "response", - :info_request => request, - :created_at => old_date) + request = FactoryBot.create(:info_request, user: nil, + external_user_name: 'test_user', + external_url: 'test', + created_at: old_date) + message = FactoryBot.create(:incoming_message, created_at: old_date, + info_request: request) + FactoryBot.create(:info_request_event, incoming_message: message, + event_type: "response", + info_request: request, + created_at: old_date) request.awaiting_description = true request.save! request end def create_old_unclassified_holding_pen - request = FactoryBot.create(:info_request, :user => user, - :title => 'Holding pen', - :created_at => old_date) - message = FactoryBot.create(:incoming_message, :created_at => old_date, - :info_request => request) - FactoryBot.create(:info_request_event, :incoming_message => message, - :event_type => "response", - :info_request => request, - :created_at => old_date) + request = FactoryBot.create(:info_request, user: user, + title: 'Holding pen', + created_at: old_date) + message = FactoryBot.create(:incoming_message, created_at: old_date, + info_request: request) + FactoryBot.create(:info_request_event, incoming_message: message, + event_type: "response", + info_request: request, + created_at: old_date) request.awaiting_description = true request.save! request @@ -2524,20 +2550,20 @@ def create_old_unclassified_holding_pen dog_request = info_requests(:fancy_dog_request) old_unclassified = InfoRequest.where_old_unclassified. - where(:prominence => 'normal').limit(1).order(Arel.sql('random()')) + where(prominence: 'normal').limit(1).order(Arel.sql('random()')) expect(old_unclassified.length).to eq(1) expect(old_unclassified.first).to eq(dog_request) dog_request.prominence = 'requester_only' dog_request.save! old_unclassified = InfoRequest.where_old_unclassified. - where(:prominence => 'normal').limit(1).order(Arel.sql('random()')) + where(prominence: 'normal').limit(1).order(Arel.sql('random()')) expect(old_unclassified.length).to eq(0) dog_request.prominence = 'hidden' dog_request.save! old_unclassified = InfoRequest.where_old_unclassified. - where(:prominence => 'normal').limit(1).order(Arel.sql('random()')) + where(prominence: 'normal').limit(1).order(Arel.sql('random()')) expect(old_unclassified.length).to eq(0) end @@ -2548,17 +2574,17 @@ def create_old_unclassified_holding_pen it "does not return requests that don't have normal prominence" do dog_request = info_requests(:fancy_dog_request) old_unclassified = InfoRequest.where_old_unclassified. - where(:prominence => 'normal').count + where(prominence: 'normal').count expect(old_unclassified).to eq(1) dog_request.prominence = 'requester_only' dog_request.save! old_unclassified = InfoRequest.where_old_unclassified. - where(:prominence => 'normal').count + where(prominence: 'normal').count expect(old_unclassified).to eq(0) dog_request.prominence = 'hidden' dog_request.save! old_unclassified = InfoRequest.where_old_unclassified. - where(:prominence => 'normal').count + where(prominence: 'normal').count expect(old_unclassified).to eq(0) end @@ -2569,20 +2595,20 @@ def create_old_unclassified_holding_pen before do allow(Time).to receive(:now).and_return(Time.utc(2007, 11, 9, 23, 59)) @info_request = FactoryBot.create(:info_request, - :prominence => 'normal', - :awaiting_description => true) + prominence: 'normal', + awaiting_description: true) @comment_event = FactoryBot.create(:info_request_event, - :created_at => Time.zone.now - 23.days, - :event_type => 'comment', - :info_request => @info_request) + created_at: Time.zone.now - 23.days, + event_type: 'comment', + info_request: @info_request) @incoming_message = FactoryBot.create(:incoming_message, - :prominence => 'normal', - :info_request => @info_request) + prominence: 'normal', + info_request: @info_request) @response_event = FactoryBot.create(:info_request_event, - :info_request => @info_request, - :created_at => Time.zone.now - 22.days, - :event_type => 'response', - :incoming_message => @incoming_message) + info_request: @info_request, + created_at: Time.zone.now - 22.days, + event_type: 'response', + incoming_message: @incoming_message) @info_request.update_attribute(:awaiting_description, true) end @@ -2610,8 +2636,8 @@ def create_old_unclassified_holding_pen describe '#apply_censor_rules_to_text' do it 'applies each censor rule to the text' do - rule_1 = FactoryBot.build(:censor_rule, :text => '1') - rule_2 = FactoryBot.build(:censor_rule, :text => '2') + rule_1 = FactoryBot.build(:censor_rule, text: '1') + rule_2 = FactoryBot.build(:censor_rule, text: '2') info_request = FactoryBot.build(:info_request) allow(info_request). to receive(:applicable_censor_rules).and_return([rule_1, rule_2]) @@ -2626,8 +2652,8 @@ def create_old_unclassified_holding_pen describe '#apply_censor_rules_to_binary' do it 'applies each censor rule to the text' do - rule_1 = FactoryBot.build(:censor_rule, :text => '1') - rule_2 = FactoryBot.build(:censor_rule, :text => '2') + rule_1 = FactoryBot.build(:censor_rule, text: '1') + rule_2 = FactoryBot.build(:censor_rule, text: '2') info_request = FactoryBot.build(:info_request) allow(info_request). to receive(:applicable_censor_rules).and_return([rule_1, rule_2]) @@ -2645,16 +2671,16 @@ def create_old_unclassified_holding_pen before(:each) do @request = FactoryBot.create(:info_request) - @default_opts = { :last_edit_editor => 'unknown', - :last_edit_comment => 'none' } + @default_opts = { last_edit_editor: 'unknown', + last_edit_comment: 'none' } end it 'replaces text with global censor rules' do data = 'There was a mouse called Stilton, he wished that he was blue' expected = 'There was a mouse called Stilton, he said that he was blue' - opts = { :text => 'wished', - :replacement => 'said' }.merge(@default_opts) + opts = { text: 'wished', + replacement: 'said' }.merge(@default_opts) CensorRule.create!(opts) result = @request.apply_masks(data, 'text/plain') @@ -2667,8 +2693,8 @@ def create_old_unclassified_holding_pen expected = 'There was a cat called Jarlsberg.' rules = [ - { :text => 'Stilton', :replacement => 'Jarlsberg' }, - { :text => 'm[a-z][a-z][a-z]e', :regexp => true, :replacement => 'cat' } + { text: 'Stilton', replacement: 'Jarlsberg' }, + { text: 'm[a-z][a-z][a-z]e', regexp: true, replacement: 'cat' } ] rules.each do |rule| @@ -2684,8 +2710,8 @@ def create_old_unclassified_holding_pen expected = 'There was a cat called Jarlsberg.' rules = [ - { :text => 'Stilton', :replacement => 'Jarlsberg' }, - { :text => 'm[a-z][a-z][a-z]e', :regexp => true, :replacement => 'cat' } + { text: 'Stilton', replacement: 'Jarlsberg' }, + { text: 'm[a-z][a-z][a-z]e', regexp: true, replacement: 'cat' } ] rules.each do |rule| @@ -2730,7 +2756,7 @@ def create_old_unclassified_holding_pen context ':decorate option is true' do it 'returns a prominence calculator' do - expect(InfoRequest.new.prominence(:decorate => true)) + expect(InfoRequest.new.prominence(decorate: true)) .to be_a(InfoRequest::Prominence::Calculator) end @@ -2775,37 +2801,37 @@ def create_old_unclassified_holding_pen end it 'sets last_public_response_at when a public response is added' do - request = FactoryBot.create(:info_request, :user => user) - message = FactoryBot.create(:incoming_message, :info_request => request) + request = FactoryBot.create(:info_request, user: user) + message = FactoryBot.create(:incoming_message, info_request: request) event = - FactoryBot.create(:info_request_event, :info_request => request, - :incoming_message => message, - :event_type => 'response') + FactoryBot.create(:info_request_event, info_request: request, + incoming_message: message, + event_type: 'response') expect(request.last_public_response_at). to be_within(1.second).of(event.created_at) end it 'does not set last_public_response_at when a hidden response is added' do - request = FactoryBot.create(:info_request, :user => user) - message = FactoryBot.create(:incoming_message, :info_request => request, - :prominence => 'hidden') + request = FactoryBot.create(:info_request, user: user) + message = FactoryBot.create(:incoming_message, info_request: request, + prominence: 'hidden') event = - FactoryBot.create(:info_request_event, :info_request => request, - :incoming_message => message, - :event_type => 'response') + FactoryBot.create(:info_request_event, info_request: request, + incoming_message: message, + event_type: 'response') expect(request.last_public_response_at).to be_nil end it 'sets last_public_response_at to nil when the only response is hidden' do - request = FactoryBot.create(:info_request, :user => user) - message = FactoryBot.create(:incoming_message, :info_request => request) - FactoryBot.create(:info_request_event, :info_request => request, - :incoming_message => message, - :event_type => 'response') + request = FactoryBot.create(:info_request, user: user) + message = FactoryBot.create(:incoming_message, info_request: request) + FactoryBot.create(:info_request_event, info_request: request, + incoming_message: message, + event_type: 'response') - message.update(:prominence => 'hidden') + message.update(prominence: 'hidden') expect(request.last_public_response_at).to be_nil end @@ -2813,39 +2839,39 @@ def create_old_unclassified_holding_pen it 'reverts last_public_response_at when the latest response is hidden' do travel_to(21.days.ago) - request = FactoryBot.create(:info_request, :user => user) - message1 = FactoryBot.create(:incoming_message, :info_request => request) + request = FactoryBot.create(:info_request, user: user) + message1 = FactoryBot.create(:incoming_message, info_request: request) event1 = - FactoryBot.create(:info_request_event, :info_request => request, - :incoming_message => message1, - :event_type => 'response') + FactoryBot.create(:info_request_event, info_request: request, + incoming_message: message1, + event_type: 'response') travel_back travel_to(2.days.ago) - message2 = FactoryBot.create(:incoming_message, :info_request => request) + message2 = FactoryBot.create(:incoming_message, info_request: request) event2 = - FactoryBot.create(:info_request_event, :info_request => request, - :incoming_message => message2, - :event_type => 'response') + FactoryBot.create(:info_request_event, info_request: request, + incoming_message: message2, + event_type: 'response') travel_back expect(request.last_public_response_at). to be_within(1.second).of(event2.created_at) - message2.update(:prominence => 'hidden') + message2.update(prominence: 'hidden') expect(request.last_public_response_at). to be_within(1.second).of(event1.created_at) end it 'sets last_public_response_at to nil when the only response is destroyed' do - request = FactoryBot.create(:info_request, :user => user) - message = FactoryBot.create(:incoming_message, :info_request => request) - FactoryBot.create(:info_request_event, :info_request => request, - :incoming_message => message, - :event_type => 'response') + request = FactoryBot.create(:info_request, user: user) + message = FactoryBot.create(:incoming_message, info_request: request) + FactoryBot.create(:info_request_event, info_request: request, + incoming_message: message, + event_type: 'response') message.destroy expect(request.last_public_response_at).to be_nil end @@ -2853,21 +2879,21 @@ def create_old_unclassified_holding_pen it 'reverts last_public_response_at when the latest response is destroyed' do travel_to(21.days.ago) - request = FactoryBot.create(:info_request, :user => user) - message1 = FactoryBot.create(:incoming_message, :info_request => request) + request = FactoryBot.create(:info_request, user: user) + message1 = FactoryBot.create(:incoming_message, info_request: request) event1 = - FactoryBot.create(:info_request_event, :info_request => request, - :incoming_message => message1, - :event_type => 'response') + FactoryBot.create(:info_request_event, info_request: request, + incoming_message: message1, + event_type: 'response') travel_back travel_to(2.days.ago) - message2 = FactoryBot.create(:incoming_message, :info_request => request) + message2 = FactoryBot.create(:incoming_message, info_request: request) event2 = - FactoryBot.create(:info_request_event, :info_request => request, - :incoming_message => message2, - :event_type => 'response') + FactoryBot.create(:info_request_event, info_request: request, + incoming_message: message2, + event_type: 'response') travel_back @@ -2883,16 +2909,16 @@ def create_old_unclassified_holding_pen it 'sets last_public_response_at when a hidden response is unhidden' do travel_to(21.days.ago) - request = FactoryBot.create(:info_request, :user => user) - message = FactoryBot.create(:incoming_message, :info_request => request, - :prominence => 'hidden') + request = FactoryBot.create(:info_request, user: user) + message = FactoryBot.create(:incoming_message, info_request: request, + prominence: 'hidden') event = - FactoryBot.create(:info_request_event, :info_request => request, - :incoming_message => message, - :event_type => 'response') + FactoryBot.create(:info_request_event, info_request: request, + incoming_message: message, + event_type: 'response') travel_back - message.update(:prominence => 'normal') + message.update(prominence: 'normal') expect(request.last_public_response_at). to be_within(1.second).of(event.created_at) @@ -2982,20 +3008,20 @@ def create_old_unclassified_holding_pen describe 'when generating json for the api' do before do - @user = mock_model(User, :json_for_api => { :id => 20, - :url_name => 'alaveteli_user', - :name => 'Alaveteli User', - :ban_text => '', - :about_me => 'Hi' }) + @user = mock_model(User, json_for_api: { id: 20, + url_name: 'alaveteli_user', + name: 'Alaveteli User', + ban_text: '', + about_me: 'Hi' }) end it 'returns full user info for an internal request' do - @info_request = InfoRequest.new(:user => @user) - expect(@info_request.user_json_for_api).to eq({ :id => 20, - :url_name => 'alaveteli_user', - :name => 'Alaveteli User', - :ban_text => '', - :about_me => 'Hi' }) + @info_request = InfoRequest.new(user: @user) + expect(@info_request.user_json_for_api).to eq({ id: 20, + url_name: 'alaveteli_user', + name: 'Alaveteli User', + ban_text: '', + about_me: 'Hi' }) end end @@ -3015,21 +3041,21 @@ def create_old_unclassified_holding_pen it "is not confused by an nil subject in the incoming message" do ir = info_requests(:fancy_dog_request) im = mock_model(IncomingMessage, - :subject => nil, - :valid_to_reply_to? => true) - subject = ir.email_subject_followup(:incoming_message => im, :html => false) + subject: nil, + valid_to_reply_to?: true) + subject = ir.email_subject_followup(incoming_message: im, html: false) expect(subject).to match(/^Re: Freedom of Information request.*fancy dog/) end it "returns a hash with the user's name for an external request" do - @info_request = InfoRequest.new(:external_url => 'http://www.example.com', - :external_user_name => 'External User') - expect(@info_request.user_json_for_api).to eq({:name => 'External User'}) + @info_request = InfoRequest.new(external_url: 'http://www.example.com', + external_user_name: 'External User') + expect(@info_request.user_json_for_api).to eq({name: 'External User'}) end it 'returns "Anonymous user" for an anonymous external user' do - @info_request = InfoRequest.new(:external_url => 'http://www.example.com') - expect(@info_request.user_json_for_api).to eq({:name => 'Anonymous user'}) + @info_request = InfoRequest.new(external_url: 'http://www.example.com') + expect(@info_request.user_json_for_api).to eq({name: 'Anonymous user'}) end end @@ -3038,9 +3064,9 @@ def create_old_unclassified_holding_pen context "a request" do - let(:request) { InfoRequest.create!(:title => "My request", - :public_body => public_bodies(:geraldine_public_body), - :user => users(:bob_smith_user)) } + let(:request) { InfoRequest.create!(title: "My request", + public_body: public_bodies(:geraldine_public_body), + user: users(:bob_smith_user)) } context "a series of events on a request" do @@ -3321,11 +3347,11 @@ def create_old_unclassified_holding_pen old_successful_count = pb.info_requests_successful_count old_not_held_count = pb.info_requests_not_held_count old_visible_count = pb.info_requests_visible_count - ir = InfoRequest.new(:external_url => 'http://www.example.com', - :external_user_name => 'Example User', - :title => 'Some request or other', - :described_state => 'partially_successful', - :public_body => pb) + ir = InfoRequest.new(external_url: 'http://www.example.com', + external_user_name: 'Example User', + title: 'Some request or other', + described_state: 'partially_successful', + public_body: pb) ir.save! expect(pb.info_requests_successful_count).to eq(old_successful_count + 1) expect(pb.info_requests_visible_count).to eq(old_visible_count + 1) @@ -3357,11 +3383,11 @@ def create_old_unclassified_holding_pen old_successful_count = pb.info_requests_successful_count old_not_held_count = pb.info_requests_not_held_count old_visible_count = pb.info_requests_visible_count - ir = InfoRequest.new(:external_url => 'http://www.example.com', - :external_user_name => 'Example User', - :title => 'Some request or other', - :described_state => 'partially_successful', - :public_body => pb) + ir = InfoRequest.new(external_url: 'http://www.example.com', + external_user_name: 'Example User', + title: 'Some request or other', + described_state: 'partially_successful', + public_body: pb) ir.save! expect(pb.info_requests_successful_count).to eq(old_successful_count + 1) expect(pb.info_requests_visible_count).to eq(old_visible_count + 1) @@ -3431,12 +3457,10 @@ def create_old_unclassified_holding_pen request_events, request_events_all_successful = InfoRequest.recent_requests previous = nil request_events.each do |event| - if previous - expect(previous.created_at).to be >= event.created_at - end - expect(['sent', 'response'].include?(event.event_type)).to be true + expect(previous.created_at).to be >= event.created_at if previous + expect(%w[sent response].include?(event.event_type)).to be true if event.event_type == 'response' - expect(['successful', 'partially_successful'].include?(event.calculated_state)).to be true + expect(%w[successful partially_successful].include?(event.calculated_state)).to be true end previous = event end @@ -3465,7 +3489,7 @@ def apply_filters(filters) end it "filters requests" do - expect(apply_filters(:latest_status => 'all')).to match_array(InfoRequest.all) + expect(apply_filters(latest_status: 'all')).to match_array(InfoRequest.all) # default sort order is the request with the most recently created event first order_sql = <<-EOF.strip_heredoc @@ -3474,7 +3498,7 @@ def apply_filters(filters) WHERE info_request_events.info_request_id = info_requests.id) DESC EOF - expect(apply_filters(:latest_status => 'all')). + expect(apply_filters(latest_status: 'all')). to eq(InfoRequest.all.order(Arel.sql(order_sql))) conditions = <<-EOF.strip_heredoc @@ -3492,14 +3516,14 @@ def apply_filters(filters) IN ('successful', 'partially_successful') ) EOF - expect(apply_filters(:latest_status => 'successful')). + expect(apply_filters(latest_status: 'successful')). to match_array(InfoRequest.where(conditions)) end it "filters requests by date" do # The semantics of the search are that it finds any InfoRequest # that has any InfoRequestEvent created in the specified range - filters = {:latest_status => 'all', :request_date_before => '13/10/2007'} + filters = {latest_status: 'all', request_date_before: '13/10/2007'} conditions1 = <<-EOF id IN (SELECT info_request_id FROM info_request_events @@ -3508,7 +3532,7 @@ def apply_filters(filters) expect(apply_filters(filters)). to match_array(InfoRequest.where(conditions1)) - filters = {:latest_status => 'all', :request_date_after => '13/10/2007'} + filters = {latest_status: 'all', request_date_after: '13/10/2007'} conditions2 = <<-EOF id IN (SELECT info_request_id FROM info_request_events @@ -3517,9 +3541,9 @@ def apply_filters(filters) expect(apply_filters(filters)). to match_array(InfoRequest.where(conditions2)) - filters = {:latest_status => 'all', - :request_date_after => '13/10/2007', - :request_date_before => '01/11/2007'} + filters = {latest_status: 'all', + request_date_after: '13/10/2007', + request_date_before: '01/11/2007'} conditions3 = <<-EOF id IN (SELECT info_request_id FROM info_request_events @@ -3534,7 +3558,7 @@ def apply_filters(filters) # This doesn’t precisely duplicate the logic of the actual # query, but it is close enough to give the same result with # the current set of test data. - results = apply_filters(:latest_status => 'awaiting') + results = apply_filters(latest_status: 'awaiting') conditions = <<-EOF id IN ( SELECT info_request_id @@ -3561,7 +3585,7 @@ def apply_filters(filters) event.described_state = event.calculated_state = "internal_review" event.save! destroy_and_rebuild_xapian_index - results = apply_filters(:latest_status => 'awaiting') + results = apply_filters(latest_status: 'awaiting') expect(results.include?(info_requests(:fancy_dog_request))).to eq(true) end @@ -3590,28 +3614,28 @@ def apply_filters(filters) shared_examples_for "a situation when everything is public" do it "doesn't add a suffix for anyone" do - expect(request.make_zip_cache_path(nil)).to eq (path) - expect(request.make_zip_cache_path(non_owner)).to eq (path) - expect(request.make_zip_cache_path(admin)).to eq (path) - expect(request.make_zip_cache_path(owner)).to eq (path) + expect(request.make_zip_cache_path(nil)).to eq(path) + expect(request.make_zip_cache_path(non_owner)).to eq(path) + expect(request.make_zip_cache_path(admin)).to eq(path) + expect(request.make_zip_cache_path(owner)).to eq(path) end end shared_examples_for "a situation when anything is not public" do it "doesn't add a suffix for anonymous users" do - expect(request.make_zip_cache_path(nil)).to eq (path) + expect(request.make_zip_cache_path(nil)).to eq(path) end it "doesn't add a suffix for non owner users" do - expect(request.make_zip_cache_path(non_owner)).to eq (path) + expect(request.make_zip_cache_path(non_owner)).to eq(path) end it "adds a _hidden suffix for admin users" do - expect(request.make_zip_cache_path(admin)).to eq (hidden_path) + expect(request.make_zip_cache_path(admin)).to eq(hidden_path) end it "adds a requester_only suffix for owner users" do - expect(request.make_zip_cache_path(owner)).to eq (requester_only_path) + expect(request.make_zip_cache_path(owner)).to eq(requester_only_path) end end @@ -3669,7 +3693,7 @@ def apply_filters(filters) context "when the request is public" do let(:request) do - FactoryBot.create(:info_request_with_incoming, id: 123456, + FactoryBot.create(:info_request_with_incoming, id: 123_456, title: "Test") end @@ -3682,7 +3706,7 @@ def apply_filters(filters) context "when the request is hidden" do let(:request) do - FactoryBot.create(:info_request_with_incoming, id: 123456, + FactoryBot.create(:info_request_with_incoming, id: 123_456, title: "Test", prominence: "hidden") end @@ -3694,7 +3718,7 @@ def apply_filters(filters) let(:request) do FactoryBot.create( :info_request_with_incoming, - id: 123456, + id: 123_456, title: "Test", prominence: "requester_only" ) @@ -4135,11 +4159,11 @@ def email_and_raw_email(opts = {}) info_request.set_described_state('waiting_clarification') # Followup message is sent - outgoing_message = OutgoingMessage.new(:status => 'ready', - :message_type => 'followup', - :info_request_id => info_request.id, - :body => 'Some text', - :what_doing => 'normal_sort') + outgoing_message = OutgoingMessage.new(status: 'ready', + message_type: 'followup', + info_request_id: info_request.id, + body: 'Some text', + what_doing: 'normal_sort') outgoing_message.record_email_delivery('', '') followup_event = info_request. info_request_events.reload. @@ -4265,7 +4289,7 @@ def email_and_raw_email(opts = {}) info_request.log_event('resent', param: 'value') event = info_request.info_request_events.reload.last expect(event.event_type).to eq 'resent' - expect(event.params).to eq :param => 'value' + expect(event.params).to eq param: 'value' end context 'if options are passed' do @@ -4383,7 +4407,7 @@ def email_and_raw_email(opts = {}) InfoRequest.log_overdue_events overdue_events = info_request. info_request_events.reload. - where(:event_type => 'overdue') + where(event_type: 'overdue') expect(overdue_events.size).to eq 0 end end @@ -4400,7 +4424,7 @@ def email_and_raw_email(opts = {}) InfoRequest.log_overdue_events overdue_events = info_request. info_request_events.reload. - where(:event_type => 'overdue') + where(event_type: 'overdue') expect(overdue_events.size).to eq 1 overdue_event = overdue_events.first expect(overdue_event.created_at).to eq Time.zone.parse('2015-01-29').beginning_of_day @@ -4451,7 +4475,7 @@ def email_and_raw_email(opts = {}) InfoRequest.log_overdue_events overdue_events = info_request. info_request_events.reload. - where(:event_type => 'overdue') + where(event_type: 'overdue') expect(overdue_events.size).to eq 2 overdue_event = overdue_events.first expect(overdue_event.created_at) @@ -4484,7 +4508,7 @@ def email_and_raw_email(opts = {}) InfoRequest.log_very_overdue_events very_overdue_events = info_request. info_request_events.reload. - where(:event_type => 'very_overdue') + where(event_type: 'very_overdue') expect(very_overdue_events.size).to eq 0 end end @@ -4500,7 +4524,7 @@ def email_and_raw_email(opts = {}) InfoRequest.log_very_overdue_events very_overdue_events = info_request. info_request_events.reload. - where(:event_type => 'very_overdue') + where(event_type: 'very_overdue') expect(very_overdue_events.size).to eq 1 very_overdue_event = very_overdue_events.first expect(very_overdue_event.created_at). @@ -4552,7 +4576,7 @@ def email_and_raw_email(opts = {}) InfoRequest.log_very_overdue_events very_overdue_events = info_request. info_request_events.reload. - where(:event_type => 'very_overdue') + where(event_type: 'very_overdue') expect(very_overdue_events.size).to eq 2 very_overdue_event = very_overdue_events.first expect(very_overdue_event.created_at). diff --git a/spec/models/mail_server_log/delivery_status_spec.rb b/spec/models/mail_server_log/delivery_status_spec.rb index e2e81abdea..6f10924724 100644 --- a/spec/models/mail_server_log/delivery_status_spec.rb +++ b/spec/models/mail_server_log/delivery_status_spec.rb @@ -56,7 +56,7 @@ it 'returns the default format' do subject = described_class.new(:delivered) - obj_id = "0x00%x" % (subject.object_id << 1) + obj_id = format("0x00%x", (subject.object_id << 1)) expected = %Q(#<#{described_class}:#{obj_id} @status=:delivered>) expect(subject.inspect).to eq(expected) diff --git a/spec/models/mail_server_log/exim_line_spec.rb b/spec/models/mail_server_log/exim_line_spec.rb index fac905057b..290805b5ae 100644 --- a/spec/models/mail_server_log/exim_line_spec.rb +++ b/spec/models/mail_server_log/exim_line_spec.rb @@ -41,7 +41,7 @@ it 'returns the default format' do subject = described_class.new('log line') - obj_id = "0x00%x" % (subject.object_id << 1) + obj_id = format("0x00%x", (subject.object_id << 1)) expected = %Q(#<#{described_class}:#{obj_id} @line="log line">) expect(subject.inspect).to eq(expected) diff --git a/spec/models/mail_server_log/postfix_line_spec.rb b/spec/models/mail_server_log/postfix_line_spec.rb index 51f9930f66..63cd2654cc 100644 --- a/spec/models/mail_server_log/postfix_line_spec.rb +++ b/spec/models/mail_server_log/postfix_line_spec.rb @@ -23,7 +23,7 @@ it 'returns the default format' do subject = described_class.new('log line') - obj_id = "0x00%x" % (subject.object_id << 1) + obj_id = format("0x00%x", (subject.object_id << 1)) expected = %Q(#<#{described_class}:#{obj_id} @line="log line">) expect(subject.inspect).to eq(expected) diff --git a/spec/models/mail_server_log_spec.rb b/spec/models/mail_server_log_spec.rb index 68b2122f29..4a90d64790 100644 --- a/spec/models/mail_server_log_spec.rb +++ b/spec/models/mail_server_log_spec.rb @@ -143,8 +143,8 @@ # things go wrong. fixture_path = file_fixture_name('exim-bad-utf8-exim-log') log = File.open(fixture_path, 'r') - done = MailServerLogDone.new(:filename => "foo", - :last_stat => DateTime.new(2012, 10, 10)) + done = MailServerLogDone.new(filename: "foo", + last_stat: DateTime.new(2012, 10, 10)) expect(ir.mail_server_logs.count).to eq 0 # This will error if we don't sanitize the lines @@ -179,7 +179,7 @@ info_request = FactoryBot.create(:info_request) allow(info_request).to receive(:incoming_email). and_return('foi+request-331612-13811a2b@example.com') - info_request.mail_server_logs.create!(:line => line, :order => 1) + info_request.mail_server_logs.create!(line: line, order: 1) expect(MailServerLog.request_exim_sent?(info_request)).to be true end @@ -195,7 +195,7 @@ info_request = FactoryBot.create(:info_request) allow(info_request).to receive(:incoming_email). and_return('foi+request-331612-13811a2b@example.com') - info_request.mail_server_logs.create!(:line => line, :order => 1) + info_request.mail_server_logs.create!(line: line, order: 1) expect(MailServerLog.request_exim_sent?(info_request)).to be false end @@ -215,7 +215,7 @@ "Oct 3 16:39:35 host postfix/qmgr[15615]: CB55836EE58C: from=, size=1695, nrcpt=1 (queue active)", "Oct 3 16:39:38 host postfix/smtp[7676]: CB55836EE58C: to=, relay=aspmx.l.google.com[74.125.25.27]:25, delay=2.5, delays=0.13/0.02/1.7/0.59, dsn=2.0.0, status=sent (250 2.0.0 OK 1349246383 j9si1676296paw.328)", "Oct 3 16:39:38 host postfix/smtp[1681]: 9634B16F7F7: to=, relay=none, delay=46, status=deferred (connect to 216.150.150.131[216.150.150.131]: No route to host)", - "Oct 3 16:39:38 host postfix/qmgr[15615]: CB55836EE58C: removed", + "Oct 3 16:39:38 host postfix/qmgr[15615]: CB55836EE58C: removed" ]} describe ".load_postfix_log_data" do @@ -229,7 +229,7 @@ ir2 = info_requests(:naughty_chicken_request) allow(InfoRequest).to receive(:find_by_incoming_email).with("foi+request-14-e0e09f97@example.com").and_return(ir1) allow(InfoRequest).to receive(:find_by_incoming_email).with("foi+request-10-1234@example.com").and_return(ir2) - MailServerLog.load_postfix_log_data(log, MailServerLogDone.new(:filename => "foo", :last_stat => Time.zone.now)) + MailServerLog.load_postfix_log_data(log, MailServerLogDone.new(filename: "foo", last_stat: Time.zone.now)) # TODO: Check that each log line is attached to the correct request expect(ir1.mail_server_logs.count).to eq(5) expect(ir1.mail_server_logs[0].order).to eq(1) @@ -269,13 +269,13 @@ describe ".request_postfix_sent?" do it "returns true when the logs say the message was sent" do ir = info_requests(:fancy_dog_request) - ir.mail_server_logs.create!(:line => "Oct 10 16:58:38 kedumba postfix/smtp[26358]: A664436F218D: to=, relay=aspmx.l.google.com[74.125.25.26]:25, delay=2.7, delays=0.16/0.02/1.8/0.67, dsn=2.0.0, status=sent (250 2.0.0 OK 1349848723 e6si653316paw.346)", :order => 1) + ir.mail_server_logs.create!(line: "Oct 10 16:58:38 kedumba postfix/smtp[26358]: A664436F218D: to=, relay=aspmx.l.google.com[74.125.25.26]:25, delay=2.7, delays=0.16/0.02/1.8/0.67, dsn=2.0.0, status=sent (250 2.0.0 OK 1349848723 e6si653316paw.346)", order: 1) expect(MailServerLog.request_postfix_sent?(ir)).to be true end it "returns false when the logs say the message hasn't been sent" do ir = info_requests(:fancy_dog_request) - ir.mail_server_logs.create!(:line => "Oct 10 13:22:49 kedumba postfix/smtp[11876]: 6FB9036F1307: to=, relay=mta7.am0.yahoodns.net[74.6.136.244]:25, delay=1.5, delays=0.03/0/0.48/1, dsn=5.0.0, status=bounced (host mta7.am0.yahoodns.net[74.6.136.244] said: 554 delivery error: dd Sorry your message to foo@example.com cannot be delivered. This account has been disabled or discontinued [#102]. - mta1272.mail.sk1.yahoo.com (in reply to end of DATA command))", :order => 1) + ir.mail_server_logs.create!(line: "Oct 10 13:22:49 kedumba postfix/smtp[11876]: 6FB9036F1307: to=, relay=mta7.am0.yahoodns.net[74.6.136.244]:25, delay=1.5, delays=0.03/0/0.48/1, dsn=5.0.0, status=bounced (host mta7.am0.yahoodns.net[74.6.136.244] said: 554 delivery error: dd Sorry your message to foo@example.com cannot be delivered. This account has been disabled or discontinued [#102]. - mta1272.mail.sk1.yahoo.com (in reply to end of DATA command))", order: 1) expect(MailServerLog.request_postfix_sent?(ir)).to be false end end @@ -284,7 +284,7 @@ describe '#line' do it 'returns the line attribute' do - log = MailServerLog.new(:line => 'log line') + log = MailServerLog.new(line: 'log line') expect(log.line).to eq('log line') end @@ -293,8 +293,8 @@ context 'using the :exim MTA' do it 'returns an EximLine containing the line attribute' do - log = MailServerLog.new(:line => 'log line') - expect(log.line(:decorate => true)). + log = MailServerLog.new(line: 'log line') + expect(log.line(decorate: true)). to eq(MailServerLog::EximLine.new('log line')) end @@ -307,8 +307,8 @@ end it 'returns a PostfixLine containing the line attribute' do - log = MailServerLog.new(:line => 'log line') - expect(log.line(:decorate => true)). + log = MailServerLog.new(line: 'log line') + expect(log.line(decorate: true)). to eq(MailServerLog::PostfixLine.new('log line')) end @@ -322,62 +322,62 @@ log = FactoryBot.create(:mail_server_log) line = log.line += " #{ log.info_request.incoming_email }" idhash = log.info_request.idhash - log.update!(:line => line) - expect(log.line(:redact => true)).to_not include(idhash) + log.update!(line: line) + expect(log.line(redact: true)).to_not include(idhash) end it 'redacts the info request id when decorated' do log = FactoryBot.create(:mail_server_log) line = log.line += " #{ log.info_request.incoming_email }" idhash = log.info_request.idhash - log.update!(:line => line) - expect(log.line(:redact => true, :decorate => true).to_s). + log.update!(line: line) + expect(log.line(redact: true, decorate: true).to_s). to_not include(idhash) end it 'handles not having an associated info request' do - log = MailServerLog.new(:line => 'log line') - expect(log.line(:redact => true)).to eq('log line') + log = MailServerLog.new(line: 'log line') + expect(log.line(redact: true)).to eq('log line') end it 'handles the info request not having an idhash' do request = FactoryBot.build(:info_request) - log = MailServerLog.new(:line => 'log line', :info_request => request) - expect(log.line(:redact => true)).to eq('log line') + log = MailServerLog.new(line: 'log line', info_request: request) + expect(log.line(redact: true)).to eq('log line') end it 'redacts the hostname if the router is sent_to_smarthost' do - log = MailServerLog.new(:line => <<-EOF.squish) + log = MailServerLog.new(line: <<-EOF.squish) R=send_to_smarthost H=secret.ukcod.org.uk [127.0.0.1]:25 EOF - redacted = log.line(:redact => true) + redacted = log.line(redact: true) expect(redacted).to match(/H\=\[REDACTED\]/) expect(redacted).to_not include('secret.ukcod.org.uk [127.0.0.1]:25') end it 'does not redact the hostname unless the router is sent_to_smarthost' do - log = MailServerLog.new(:line => <<-EOF.squish) + log = MailServerLog.new(line: <<-EOF.squish) R=dnslookup_returnpath_dkim H=notsecret.ukcod.org.uk [127.0.0.1]:25 EOF - redacted = log.line(:redact => true) + redacted = log.line(redact: true) expect(redacted).to include('secret.ukcod.org.uk [127.0.0.1]:25') end it 'strips syslog prefixes' do - log = MailServerLog.new(:line => <<-EOF.squish) + log = MailServerLog.new(line: <<-EOF.squish) Jan 1 16:26:57 secret exim[15407]: 2017-01-01 16:26:57 [15407] 1cNiyG-00040U-Ls => body@example.com… EOF - expect(log.line(:redact => true)).to eq(<<-EOF.squish) + expect(log.line(redact: true)).to eq(<<-EOF.squish) 2017-01-01 16:26:57 [15407] 1cNiyG-00040U-Ls => body@example.com… EOF end it 'strips syslog prefixes when the line ends in a newline' do - log = MailServerLog.new(:line => <<-EOF.squish) + log = MailServerLog.new(line: <<-EOF.squish) Jan 1 16:26:57 secret exim[15407]: 2017-01-01 16:26:57 [15407] 1cNiyG-00040U-Ls => body@example.com… EOF @@ -387,7 +387,7 @@ expected = "2017-01-01 16:26:57 [15407] 1cNiyG-00040U-Ls => body@example.com…\n" - expect(log.line(:redact => true)).to eq(expected) + expect(log.line(redact: true)).to eq(expected) end end end @@ -396,7 +396,7 @@ context 'if there is a stored value' do let(:log) do - FactoryBot.create(:mail_server_log, :line => "log text **") + FactoryBot.create(:mail_server_log, line: "log text **") end it 'returns the stored value' do @@ -425,7 +425,7 @@ # statuses context 'if there is a stored value from an MTA-specific status' do let(:log) do - FactoryBot.create(:mail_server_log, :line => "log text <=") + FactoryBot.create(:mail_server_log, line: "log text <=") end it 'recalculates the value' do @@ -459,7 +459,7 @@ context 'there is not a stored value' do it 'parses the line text' do - log = MailServerLog.new(:line => "…<=…") + log = MailServerLog.new(line: "…<=…") expect(log.delivery_status). to eq(MailServerLog::DeliveryStatus.new(:sent)) end @@ -476,7 +476,7 @@ end it 'returns a delivery status for the log line' do - log = MailServerLog.new(:line => line) + log = MailServerLog.new(line: line) status = MailServerLog::DeliveryStatus.new(:sent) expect(log.delivery_status).to eq(status) end @@ -498,7 +498,7 @@ end it 'returns a delivery status for the log line' do - log = MailServerLog.new(:line => line) + log = MailServerLog.new(line: line) status = MailServerLog::DeliveryStatus.new(:delivered) expect(log.delivery_status).to eq(status) end @@ -513,14 +513,14 @@ it 'returns true if the user is the owning user of the info request' do log = FactoryBot.build(:mail_server_log) - request = mock_model(InfoRequest, :is_owning_user? => true) + request = mock_model(InfoRequest, is_owning_user?: true) allow(log).to receive(:info_request).and_return(request) expect(log.is_owning_user?(double(:user))).to eq(true) end it 'returns false if the user is not the owning user of the info request' do log = FactoryBot.build(:mail_server_log) - request = mock_model(InfoRequest, :is_owning_user? => false) + request = mock_model(InfoRequest, is_owning_user?: false) allow(log).to receive(:info_request).and_return(request) expect(log.is_owning_user?(double(:user))).to eq(false) end @@ -533,7 +533,7 @@ it 'returns true' do info_request = FactoryBot.create(:info_request, - :created_at => Time.zone.now - 5.days) + created_at: Time.zone.now - 5.days) allow(MailServerLog).to receive(:request_sent?).with(info_request). and_return(true) expect(MailServerLog.check_recent_requests_have_been_sent).to eq(true) @@ -545,7 +545,7 @@ it 'returns false' do info_request = FactoryBot.create(:info_request, - :created_at => Time.zone.now - 5.days) + created_at: Time.zone.now - 5.days) allow(MailServerLog).to receive(:request_sent?).with(info_request). and_return(false) allow($stderr).to receive(:puts) @@ -554,7 +554,7 @@ it 'outputs a message to stderr' do info_request = FactoryBot.create(:info_request, - :created_at => Time.zone.now - 5.days) + created_at: Time.zone.now - 5.days) allow(MailServerLog).to receive(:request_sent?).with(info_request). and_return(false) expected_message = "failed to find request sending in MTA logs for request " \ diff --git a/spec/models/outgoing_message/template/batch_request_spec.rb b/spec/models/outgoing_message/template/batch_request_spec.rb index c064ba5623..9f4bc0ac77 100644 --- a/spec/models/outgoing_message/template/batch_request_spec.rb +++ b/spec/models/outgoing_message/template/batch_request_spec.rb @@ -19,7 +19,7 @@ end it 'allows a custom message letter' do - opts = { :letter => 'A custom letter' } + opts = { letter: 'A custom letter' } expected = "Dear [Authority name],\n\nA custom letter\n\n\n\nYours faithfully,\n\n" expect(subject.body(opts)).to eq(expected) end @@ -41,7 +41,7 @@ end it 'returns a custom letter' do - expect(subject.letter(:letter => 'custom')).to eq("\n\ncustom") + expect(subject.letter(letter: 'custom')).to eq("\n\ncustom") end end diff --git a/spec/models/outgoing_message/template/incoming_message_followup_spec.rb b/spec/models/outgoing_message/template/incoming_message_followup_spec.rb index aeebf81d95..21be1cde5d 100644 --- a/spec/models/outgoing_message/template/incoming_message_followup_spec.rb +++ b/spec/models/outgoing_message/template/incoming_message_followup_spec.rb @@ -11,12 +11,12 @@ it 'returns the expected template text' do expected = "Dear A body,\n\n\n\nYours sincerely,\n\n" - expect(subject.body(:public_body_name => 'A body')).to eq(expected) + expect(subject.body(public_body_name: 'A body')).to eq(expected) end it 'allows a custom message letter' do - opts = { :public_body_name => 'A body', - :letter => 'A custom letter' } + opts = { public_body_name: 'A body', + letter: 'A custom letter' } expected = "Dear A body,\n\nA custom letter\n\n\n\nYours sincerely,\n\n" expect(subject.body(opts)).to eq(expected) end @@ -26,7 +26,7 @@ describe '#salutation' do it 'returns the salutation' do - expect(subject.salutation(:public_body_name => 'A body')). + expect(subject.salutation(public_body_name: 'A body')). to eq('Dear A body,') end @@ -39,7 +39,7 @@ end it 'returns a custom letter' do - expect(subject.letter(:letter => 'custom')).to eq("\n\ncustom") + expect(subject.letter(letter: 'custom')).to eq("\n\ncustom") end end diff --git a/spec/models/outgoing_message/template/initial_request_spec.rb b/spec/models/outgoing_message/template/initial_request_spec.rb index a86ac30a5e..33170a9921 100644 --- a/spec/models/outgoing_message/template/initial_request_spec.rb +++ b/spec/models/outgoing_message/template/initial_request_spec.rb @@ -11,12 +11,12 @@ it 'returns the expected template text' do expected = "Dear A body,\n\n\n\nYours faithfully,\n\n" - expect(subject.body(:public_body_name => 'A body')).to eq(expected) + expect(subject.body(public_body_name: 'A body')).to eq(expected) end it 'allows a custom message letter' do - opts = { :public_body_name => 'A body', - :letter => 'A custom letter' } + opts = { public_body_name: 'A body', + letter: 'A custom letter' } expected = "Dear A body,\n\nA custom letter\n\n\n\nYours faithfully,\n\n" expect(subject.body(opts)).to eq(expected) end @@ -27,7 +27,7 @@ context 'when a public_body_name is given' do it 'returns the salutation' do - expect(subject.salutation(:public_body_name => 'A body')). + expect(subject.salutation(public_body_name: 'A body')). to eq('Dear A body,') end end @@ -47,7 +47,7 @@ end it 'returns a custom letter' do - expect(subject.letter(:letter => 'custom')).to eq("\n\ncustom") + expect(subject.letter(letter: 'custom')).to eq("\n\ncustom") end end diff --git a/spec/models/outgoing_message/template/internal_review_spec.rb b/spec/models/outgoing_message/template/internal_review_spec.rb index 8e2497df6f..a9ed1b8b60 100644 --- a/spec/models/outgoing_message/template/internal_review_spec.rb +++ b/spec/models/outgoing_message/template/internal_review_spec.rb @@ -14,27 +14,27 @@ describe '#body' do it 'requires a :public_body_name key' do - attrs = { :info_request_title => 'a', :url => 'b' } + attrs = { info_request_title: 'a', url: 'b' } msg = 'Missing required key: public_body_name' expect { subject.body(attrs) }.to raise_error(ArgumentError, msg) end it 'requires an :info_request_title key' do - attrs = { :public_body_name => 'a', :url => 'b' } + attrs = { public_body_name: 'a', url: 'b' } msg = 'Missing required key: info_request_title' expect { subject.body(attrs) }.to raise_error(ArgumentError, msg) end it 'requires a :url key' do - attrs = { :public_body_name => 'a', :info_request_title => 'b' } + attrs = { public_body_name: 'a', info_request_title: 'b' } msg = 'Missing required key: url' expect { subject.body(attrs) }.to raise_error(ArgumentError, msg) end it 'returns the expected template text' do - attrs = { :public_body_name => 'A body', - :info_request_title => 'a test title', - :url => 'http://test.host/request/a_test_title' } + attrs = { public_body_name: 'A body', + info_request_title: 'a test title', + url: 'http://test.host/request/a_test_title' } expected = <<-EOF.strip_heredoc Dear A body, @@ -60,10 +60,10 @@ end it 'allows a custom message letter' do - attrs = { :public_body_name => 'A body', - :info_request_title => 'a test title', - :url => 'http://test.host/request/a_test_title', - :letter => 'A custom letter' } + attrs = { public_body_name: 'A body', + info_request_title: 'a test title', + url: 'http://test.host/request/a_test_title', + letter: 'A custom letter' } expected = "Dear A body,\n\nA custom letter\n\n\nYours faithfully,\n\n" expect(subject.body(attrs)).to eq(expected) end @@ -73,7 +73,7 @@ describe '#salutation' do it 'returns the salutation' do - expect(subject.salutation(:public_body_name => 'A body')). + expect(subject.salutation(public_body_name: 'A body')). to eq('Dear A body,') end @@ -82,9 +82,9 @@ describe '#letter' do it 'returns the letter' do - attrs = { :public_body_name => 'A body', - :info_request_title => 'a test title', - :url => 'http://test.host/request/a_test_title' } + attrs = { public_body_name: 'A body', + info_request_title: 'a test title', + url: 'http://test.host/request/a_test_title' } expected = <<-EOF.strip_heredoc @@ -107,7 +107,7 @@ end it 'returns a custom letter' do - expect(subject.letter(:letter => 'custom')).to eq("\n\ncustom") + expect(subject.letter(letter: 'custom')).to eq("\n\ncustom") end end diff --git a/spec/models/outgoing_message_spec.rb b/spec/models/outgoing_message_spec.rb index 09d9e2b813..55e12ff775 100644 --- a/spec/models/outgoing_message_spec.rb +++ b/spec/models/outgoing_message_spec.rb @@ -112,10 +112,10 @@ class TestError < StandardError; end describe '#initialize' do it 'does not censor the #body' do - attrs = { :status => 'ready', - :message_type => 'initial_request', - :body => 'abc', - :what_doing => 'normal_sort' } + attrs = { status: 'ready', + message_type: 'initial_request', + body: 'abc', + what_doing: 'normal_sort' } message = FactoryBot.create(:outgoing_message, attrs) @@ -129,14 +129,14 @@ class TestError < StandardError; end it 'reloads the default body when set after initialization' do req = FactoryBot.build(:info_request) - message = described_class.new(:info_request => req) + message = described_class.new(info_request: req) message.default_letter = 'test' expect(message.body).to include('test') end it 'does not replace the body if it has already been changed' do req = FactoryBot.build(:info_request) - message = described_class.new(:info_request => req) + message = described_class.new(info_request: req) message.body = 'toast' message.default_letter = 'test' expect(message.body).not_to include('test') @@ -148,30 +148,30 @@ class TestError < StandardError; end it 'allows a value of normal_sort' do message = - FactoryBot.build(:initial_request, :what_doing => 'normal_sort') + FactoryBot.build(:initial_request, what_doing: 'normal_sort') expect(message).to be_valid end it 'allows a value of internal_review' do message = - FactoryBot.build(:initial_request, :what_doing => 'internal_review') + FactoryBot.build(:initial_request, what_doing: 'internal_review') expect(message).to be_valid end it 'allows a value of external_review' do message = - FactoryBot.build(:initial_request, :what_doing => 'external_review') + FactoryBot.build(:initial_request, what_doing: 'external_review') expect(message).to be_valid end it 'allows a value of new_information' do message = - FactoryBot.build(:initial_request, :what_doing => 'new_information') + FactoryBot.build(:initial_request, what_doing: 'new_information') expect(message).to be_valid end it 'adds an error to :what_doing_dummy if an invalid value is provided' do - message = FactoryBot.build(:initial_request, :what_doing => 'invalid') + message = FactoryBot.build(:initial_request, what_doing: 'invalid') message.valid? expect(message.errors[:what_doing_dummy]). to eq(['Please choose what sort of reply you are making.']) @@ -181,29 +181,29 @@ class TestError < StandardError; end describe '#destroy' do it 'should destroy the outgoing message' do - attrs = { :status => 'ready', - :message_type => 'initial_request', - :body => 'abc', - :what_doing => 'normal_sort' } + attrs = { status: 'ready', + message_type: 'initial_request', + body: 'abc', + what_doing: 'normal_sort' } outgoing_message = FactoryBot.create(:outgoing_message, attrs) outgoing_message.destroy - expect(OutgoingMessage.where(:id => outgoing_message.id)).to be_empty + expect(OutgoingMessage.where(id: outgoing_message.id)).to be_empty end it 'should destroy the associated info_request_events' do info_request = FactoryBot.create(:info_request) outgoing_message = info_request.outgoing_messages.first outgoing_message.destroy - expect(InfoRequestEvent.where(:outgoing_message_id => outgoing_message.id)).to be_empty + expect(InfoRequestEvent.where(outgoing_message_id: outgoing_message.id)).to be_empty end end describe '#from' do it 'uses the user name and request magic email' do - user = FactoryBot.create(:user, :name => 'Spec User 862') - request = FactoryBot.create(:info_request, :user => user) - message = FactoryBot.build(:initial_request, :info_request => request) + user = FactoryBot.create(:user, name: 'Spec User 862') + request = FactoryBot.create(:info_request, user: user) + message = FactoryBot.build(:initial_request, info_request: request) expected = "Spec User 862 " expect(message.from).to eq(expected) end @@ -215,10 +215,10 @@ class TestError < StandardError; end context 'when sending an initial request' do it 'uses the public body name and email' do - body = FactoryBot.create(:public_body, :name => 'Example Public Body', - :short_name => 'EPB') - request = FactoryBot.create(:info_request, :public_body => body) - message = FactoryBot.build(:initial_request, :info_request => request) + body = FactoryBot.create(:public_body, name: 'Example Public Body', + short_name: 'EPB') + request = FactoryBot.create(:info_request, public_body: body) + message = FactoryBot.build(:initial_request, info_request: request) expected = 'FOI requests at EPB ' expect(message.to).to eq(expected) end @@ -231,9 +231,9 @@ class TestError < StandardError; end message = FactoryBot.build(:internal_review_request) followup = - mock_model(IncomingMessage, :from_email => 'specific@example.com', - :safe_from_name => 'Specific Person', - :valid_to_reply_to? => true) + mock_model(IncomingMessage, from_email: 'specific@example.com', + safe_from_name: 'Specific Person', + valid_to_reply_to?: true) allow(message).to receive(:incoming_message_followup).and_return(followup) expected = 'Specific Person ' @@ -241,16 +241,16 @@ class TestError < StandardError; end end it 'uses the public body address if the incoming message has an invalid address' do - body = FactoryBot.create(:public_body, :name => 'Example Public Body', - :short_name => 'EPB') - request = FactoryBot.create(:info_request, :public_body => body) + body = FactoryBot.create(:public_body, name: 'Example Public Body', + short_name: 'EPB') + request = FactoryBot.create(:info_request, public_body: body) message = FactoryBot.build(:new_information_followup, - :info_request => request) + info_request: request) followup = - mock_model(IncomingMessage, :from_email => 'invalid@example', - :safe_from_name => 'Specific Person', - :valid_to_reply_to? => false) + mock_model(IncomingMessage, from_email: 'invalid@example', + safe_from_name: 'Specific Person', + valid_to_reply_to?: false) allow(message).to receive(:incoming_message_followup).and_return(followup) expected = 'FOI requests at EPB ' @@ -266,8 +266,8 @@ class TestError < StandardError; end context 'when sending an initial request' do it 'uses the request title with the law prefixed' do - request = FactoryBot.create(:info_request, :title => 'Example Request') - message = FactoryBot.build(:initial_request, :info_request => request) + request = FactoryBot.create(:info_request, title: 'Example Request') + message = FactoryBot.build(:initial_request, info_request: request) expected = 'Freedom of Information request - Example Request' expect(message.subject).to eq(expected) end @@ -277,9 +277,9 @@ class TestError < StandardError; end context 'when sending a followup that is not a reply to an incoming message' do it 'prefixes the initial request subject with Re:' do - request = FactoryBot.create(:info_request, :title => 'Example Request') + request = FactoryBot.create(:info_request, title: 'Example Request') message = FactoryBot.build(:new_information_followup, - :info_request => request) + info_request: request) allow(message).to receive(:incoming_message_followup).and_return(nil) expected = 'Re: Freedom of Information request - Example Request' expect(message.subject).to eq(expected) @@ -290,12 +290,12 @@ class TestError < StandardError; end context 'when following up to an incoming message' do it 'uses the request title prefixed with Re: if the incoming message does not have a valid reply address' do - request = FactoryBot.create(:info_request, :title => 'Example Request') + request = FactoryBot.create(:info_request, title: 'Example Request') message = FactoryBot.build(:new_information_followup, - :info_request => request) + info_request: request) followup = - mock_model(IncomingMessage, :valid_to_reply_to? => false) + mock_model(IncomingMessage, valid_to_reply_to?: false) allow(message). to receive(:incoming_message_followup).and_return(followup) @@ -304,12 +304,12 @@ class TestError < StandardError; end end it 'uses the request title prefixed with Re: if the incoming message does not have a subject' do - request = FactoryBot.create(:info_request, :title => 'Example Request') + request = FactoryBot.create(:info_request, title: 'Example Request') message = FactoryBot.build(:new_information_followup, - :info_request => request) + info_request: request) - followup = mock_model(IncomingMessage, :subject => nil, - :valid_to_reply_to? => true) + followup = mock_model(IncomingMessage, subject: nil, + valid_to_reply_to?: true) allow(message). to receive(:incoming_message_followup).and_return(followup) @@ -318,13 +318,13 @@ class TestError < StandardError; end end it 'uses the incoming message subject if it is already prefixed with Re:' do - request = FactoryBot.create(:info_request, :title => 'Example Request') + request = FactoryBot.create(:info_request, title: 'Example Request') message = FactoryBot.build(:new_information_followup, - :info_request => request) + info_request: request) followup = - mock_model(IncomingMessage, :valid_to_reply_to? => true, - :subject => 'Re: FOI REF#123456789') + mock_model(IncomingMessage, valid_to_reply_to?: true, + subject: 'Re: FOI REF#123456789') allow(message). to receive(:incoming_message_followup).and_return(followup) @@ -332,13 +332,13 @@ class TestError < StandardError; end end it 'prefixes the incoming message subject if it is not prefixed with Re:' do - request = FactoryBot.create(:info_request, :title => 'Example Request') + request = FactoryBot.create(:info_request, title: 'Example Request') message = FactoryBot.build(:new_information_followup, - :info_request => request) + info_request: request) followup = - mock_model(IncomingMessage, :valid_to_reply_to? => true, - :subject => 'FOI REF#123456789') + mock_model(IncomingMessage, valid_to_reply_to?: true, + subject: 'FOI REF#123456789') allow(message). to receive(:incoming_message_followup).and_return(followup) @@ -350,8 +350,8 @@ class TestError < StandardError; end context 'when requesting an internal review' do it 'prefixes the request title with the internal review message' do - request = FactoryBot.create(:info_request, :title => 'Example Request') - message = FactoryBot.build(:internal_review_request, :info_request => request) + request = FactoryBot.create(:info_request, title: 'Example Request') + message = FactoryBot.build(:internal_review_request, info_request: request) expected = 'Internal review of Freedom of Information request - Example Request' expect(message.subject).to eq(expected) end @@ -363,44 +363,44 @@ class TestError < StandardError; end describe '#body' do it 'returns the body attribute' do - attrs = { :status => 'ready', - :message_type => 'initial_request', - :body => 'abc', - :what_doing => 'normal_sort' } + attrs = { status: 'ready', + message_type: 'initial_request', + body: 'abc', + what_doing: 'normal_sort' } message = FactoryBot.build(:outgoing_message, attrs) expect(message.body).to eq('abc') end it 'strips the body of leading and trailing whitespace' do - attrs = { :status => 'ready', - :message_type => 'initial_request', - :body => ' abc ', - :what_doing => 'normal_sort' } + attrs = { status: 'ready', + message_type: 'initial_request', + body: ' abc ', + what_doing: 'normal_sort' } message = FactoryBot.build(:outgoing_message, attrs) expect(message.body).to eq('abc') end it 'removes excess linebreaks that unnecessarily space it out' do - attrs = { :status => 'ready', - :message_type => 'initial_request', - :body => "ab\n\nc\n\n", - :what_doing => 'normal_sort' } + attrs = { status: 'ready', + message_type: 'initial_request', + body: "ab\n\nc\n\n", + what_doing: 'normal_sort' } message = FactoryBot.build(:outgoing_message, attrs) expect(message.body).to eq("ab\n\nc") end it "applies the associated request's censor rules to the text" do - attrs = { :status => 'ready', - :message_type => 'initial_request', - :body => 'This sensitive text contains secret info!', - :what_doing => 'normal_sort' } + attrs = { status: 'ready', + message_type: 'initial_request', + body: 'This sensitive text contains secret info!', + what_doing: 'normal_sort' } message = FactoryBot.build(:outgoing_message, attrs) - rules = [FactoryBot.build(:censor_rule, :text => 'secret'), - FactoryBot.build(:censor_rule, :text => 'sensitive')] + rules = [FactoryBot.build(:censor_rule, text: 'secret'), + FactoryBot.build(:censor_rule, text: 'sensitive')] allow_any_instance_of(InfoRequest).to receive(:censor_rules).and_return(rules) expected = 'This [REDACTED] text contains [REDACTED] info!' @@ -408,41 +408,41 @@ class TestError < StandardError; end end it "applies the given censor rules to the text" do - attrs = { :status => 'ready', - :message_type => 'initial_request', - :body => 'This sensitive text contains secret info!', - :what_doing => 'normal_sort' } + attrs = { status: 'ready', + message_type: 'initial_request', + body: 'This sensitive text contains secret info!', + what_doing: 'normal_sort' } message = FactoryBot.build(:outgoing_message, attrs) - request_rules = [FactoryBot.build(:censor_rule, :text => 'secret'), - FactoryBot.build(:censor_rule, :text => 'sensitive')] + request_rules = [FactoryBot.build(:censor_rule, text: 'secret'), + FactoryBot.build(:censor_rule, text: 'sensitive')] allow_any_instance_of(InfoRequest).to receive(:censor_rules).and_return(request_rules) - censor_rules = [FactoryBot.build(:censor_rule, :text => 'text'), - FactoryBot.build(:censor_rule, :text => 'contains')] + censor_rules = [FactoryBot.build(:censor_rule, text: 'text'), + FactoryBot.build(:censor_rule, text: 'contains')] expected = 'This sensitive [REDACTED] [REDACTED] secret info!' - expect(message.body(:censor_rules => censor_rules)).to eq(expected) + expect(message.body(censor_rules: censor_rules)).to eq(expected) end context "validation" do let(:public_body) do - FactoryBot.create(:public_body, :name => 'a test public body') + FactoryBot.create(:public_body, name: 'a test public body') end let(:info_request) do FactoryBot.create(:info_request, - :public_body => public_body, - :url_title => 'a_test_title', - :title => 'A test title') + public_body: public_body, + url_title: 'a_test_title', + title: 'A test title') end it "adds an error message if the text has not been changed" do outgoing_message = - OutgoingMessage.new(:status => 'ready', - :message_type => 'initial_request', - :what_doing => 'normal_sort', - :info_request => info_request) + OutgoingMessage.new(status: 'ready', + message_type: 'initial_request', + what_doing: 'normal_sort', + info_request: info_request) outgoing_message.valid? expect(outgoing_message.errors.messages[:body]). @@ -451,10 +451,10 @@ class TestError < StandardError; end it "adds an error message if the signature block is incomplete" do outgoing_message = - OutgoingMessage.new(:status => 'ready', - :message_type => 'initial_request', - :what_doing => 'normal_sort', - :info_request => info_request) + OutgoingMessage.new(status: 'ready', + message_type: 'initial_request', + what_doing: 'normal_sort', + info_request: info_request) outgoing_message.valid? expect(outgoing_message.errors.messages[:body]). @@ -464,10 +464,10 @@ class TestError < StandardError; end it "does not add the 'enter your letter' error if the text has been changed" do outgoing_message = - OutgoingMessage.new(:status => 'ready', - :message_type => 'initial_request', - :what_doing => 'normal_sort', - :info_request => info_request) + OutgoingMessage.new(status: 'ready', + message_type: 'initial_request', + what_doing: 'normal_sort', + info_request: info_request) outgoing_message.body = "Dear a test public body,\n\nI would like some information please.\n\nYours faithfully,\n\n" @@ -478,18 +478,18 @@ class TestError < StandardError; end it "can cope with HTML entities in the message body" do test_body = FactoryBot.create(:public_body, - :name => "D's Test Authority") + name: "D's Test Authority") info_request = FactoryBot.create(:info_request, - :public_body => test_body, - :url_title => 'a_test_title', - :title => 'A test title') + public_body: test_body, + url_title: 'a_test_title', + title: 'A test title') outgoing_message = - OutgoingMessage.new(:status => 'ready', - :message_type => 'initial_request', - :what_doing => 'normal_sort', - :info_request => info_request) + OutgoingMessage.new(status: 'ready', + message_type: 'initial_request', + what_doing: 'normal_sort', + info_request: info_request) outgoing_message.valid? expect(outgoing_message.errors.messages[:body]). @@ -503,10 +503,10 @@ class TestError < StandardError; end end let(:outgoing_message) do - OutgoingMessage.new(:status => 'ready', - :message_type => 'initial_request', - :what_doing => 'normal_sort', - :info_request => info_request) + OutgoingMessage.new(status: 'ready', + message_type: 'initial_request', + what_doing: 'normal_sort', + info_request: info_request) end it "adds the default_letter text to the message body" do @@ -539,10 +539,10 @@ class TestError < StandardError; end context "when a censor rule changes the default text" do before do - opts = { :text => 'Regulation 1049/2001', - :replacement => 'the law', - :last_edit_editor => 'unknown', - :last_edit_comment => 'none' } + opts = { text: 'Regulation 1049/2001', + replacement: 'the law', + last_edit_editor: 'unknown', + last_edit_comment: 'none' } CensorRule.create!(opts) outgoing_message.apply_masks(outgoing_message.body, 'text/plain') @@ -555,10 +555,10 @@ class TestError < StandardError; end end it "copes with a global censor rule that affects the signature text" do - opts = { :text => 'Yours faithfully,', - :replacement => 'Cheers!', - :last_edit_editor => 'unknown', - :last_edit_comment => 'none' } + opts = { text: 'Yours faithfully,', + replacement: 'Cheers!', + last_edit_editor: 'unknown', + last_edit_comment: 'none' } CensorRule.create!(opts) outgoing_message.apply_masks(outgoing_message.body, 'text/plain') @@ -576,10 +576,10 @@ class TestError < StandardError; end it "adds an error message if the text has not been changed" do outgoing_message = - OutgoingMessage.new(:status => 'ready', - :message_type => 'followup', - :what_doing => 'internal_review', - :info_request => info_request) + OutgoingMessage.new(status: 'ready', + message_type: 'followup', + what_doing: 'internal_review', + info_request: info_request) outgoing_message.valid? expect(outgoing_message.errors.messages[:body]). @@ -588,10 +588,10 @@ class TestError < StandardError; end it 'includes a all correspondence being available online' do outgoing_message = - OutgoingMessage.new(:status => 'ready', - :message_type => 'followup', - :what_doing => 'internal_review', - :info_request => info_request) + OutgoingMessage.new(status: 'ready', + message_type: 'followup', + what_doing: 'internal_review', + info_request: info_request) expect(outgoing_message.body). to include("A full history of my FOI request and all " \ @@ -600,13 +600,13 @@ class TestError < StandardError; end end it 'removes the all correspondence line if the message is embargoed' do - FactoryBot.create(:embargo, :info_request => info_request) + FactoryBot.create(:embargo, info_request: info_request) info_request.reload outgoing_message = - OutgoingMessage.new(:status => 'ready', - :message_type => 'followup', - :what_doing => 'internal_review', - :info_request => info_request) + OutgoingMessage.new(status: 'ready', + message_type: 'followup', + what_doing: 'internal_review', + info_request: info_request) expect(outgoing_message.body). not_to include("A full history of my FOI request and all " \ @@ -620,10 +620,10 @@ class TestError < StandardError; end it "adds an error message if the text has not been changed" do outgoing_message = - OutgoingMessage.new(:status => 'ready', - :message_type => 'followup', - :what_doing => 'normal_sort', - :info_request => info_request) + OutgoingMessage.new(status: 'ready', + message_type: 'followup', + what_doing: 'normal_sort', + info_request: info_request) outgoing_message.valid? expect(outgoing_message.errors.messages[:body]). @@ -641,8 +641,8 @@ class TestError < StandardError; end before(:each) do @message = FactoryBot.create(:initial_request) - @default_opts = { :last_edit_editor => 'unknown', - :last_edit_comment => 'none' } + @default_opts = { last_edit_editor: 'unknown', + last_edit_comment: 'none' } end @@ -650,8 +650,8 @@ class TestError < StandardError; end data = 'There was a mouse called Stilton, he wished that he was blue' expected = 'There was a mouse called Stilton, he said that he was blue' - opts = { :text => 'wished', - :replacement => 'said' }.merge(@default_opts) + opts = { text: 'wished', + replacement: 'said' }.merge(@default_opts) CensorRule.create!(opts) result = @message.apply_masks(data, 'text/plain') @@ -664,8 +664,8 @@ class TestError < StandardError; end expected = 'There was a cat called Jarlsberg.' rules = [ - { :text => 'Stilton', :replacement => 'Jarlsberg' }, - { :text => 'm[a-z][a-z][a-z]e', :regexp => true, :replacement => 'cat' } + { text: 'Stilton', replacement: 'Jarlsberg' }, + { text: 'm[a-z][a-z][a-z]e', regexp: true, replacement: 'cat' } ] rules.each do |rule| @@ -681,8 +681,8 @@ class TestError < StandardError; end expected = 'There was a cat called Jarlsberg.' rules = [ - { :text => 'Stilton', :replacement => 'Jarlsberg' }, - { :text => 'm[a-z][a-z][a-z]e', :regexp => true, :replacement => 'cat' } + { text: 'Stilton', replacement: 'Jarlsberg' }, + { text: 'm[a-z][a-z][a-z]e', regexp: true, replacement: 'cat' } ] rules.each do |rule| @@ -727,10 +727,10 @@ class TestError < StandardError; end title: 'A test title', public_body: public_body) outgoing_message = - OutgoingMessage.new(:status => 'ready', - :message_type => 'initial_request', - :what_doing => 'normal_sort', - :info_request => info_request) + OutgoingMessage.new(status: 'ready', + message_type: 'initial_request', + what_doing: 'normal_sort', + info_request: info_request) expected_text = "Dear a test public body,\n\n\n\nYours faithfully,\n\n" expect(outgoing_message.get_default_message).to eq(expected_text) @@ -747,10 +747,10 @@ class TestError < StandardError; end title: 'A test title', public_body: public_body) outgoing_message = - OutgoingMessage.new(:status => 'ready', - :message_type => 'followup', - :what_doing => 'normal_sort', - :info_request => info_request) + OutgoingMessage.new(status: 'ready', + message_type: 'followup', + what_doing: 'normal_sort', + info_request: info_request) expected_text = "Dear a test public body,\n\n\n\nYours faithfully,\n\n" expect(outgoing_message.get_default_message).to eq(expected_text) @@ -763,14 +763,14 @@ class TestError < StandardError; end title: 'A test title', public_body: public_body) incoming_message = - mock_model(IncomingMessage, :safe_from_name => 'helpdesk', - :valid_to_reply_to? => true) + mock_model(IncomingMessage, safe_from_name: 'helpdesk', + valid_to_reply_to?: true) outgoing_message = - OutgoingMessage.new(:status => 'ready', - :message_type => 'followup', - :what_doing => 'normal_sort', - :info_request => info_request, - :incoming_message_followup => incoming_message) + OutgoingMessage.new(status: 'ready', + message_type: 'followup', + what_doing: 'normal_sort', + info_request: info_request, + incoming_message_followup: incoming_message) expected_text = "Dear helpdesk,\n\n\n\nYours sincerely,\n\n" expect(outgoing_message.get_default_message).to eq(expected_text) @@ -787,10 +787,10 @@ class TestError < StandardError; end title: 'a test title', public_body: public_body) outgoing_message = - OutgoingMessage.new(:status => 'ready', - :message_type => 'followup', - :what_doing => 'internal_review', - :info_request => info_request) + OutgoingMessage.new(status: 'ready', + message_type: 'followup', + what_doing: 'internal_review', + info_request: info_request) expected_text = <<-EOF.strip_heredoc Dear a test public body, @@ -823,11 +823,11 @@ class TestError < StandardError; end before do @outgoing_message = OutgoingMessage.new({ - :status => 'ready', - :message_type => 'initial_request', - :body => 'This request contains a foo@bar.com email address', - :last_sent_at => Time.zone.now, - :what_doing => 'normal_sort' + status: 'ready', + message_type: 'initial_request', + body: 'This request contains a foo@bar.com email address', + last_sent_at: Time.zone.now, + what_doing: 'normal_sort' }) end @@ -913,14 +913,14 @@ class TestError < StandardError; end it 'returns true if the user is the owning user of the info request' do request = FactoryBot.build(:info_request) - message = FactoryBot.build(:initial_request, :info_request => request) + message = FactoryBot.build(:initial_request, info_request: request) expect(message.is_owning_user?(request.user)).to eq(true) end it 'returns false if the user is not the owning user of the info request' do user = FactoryBot.create(:user) request = FactoryBot.create(:info_request) - message = FactoryBot.build(:initial_request, :info_request => request) + message = FactoryBot.build(:initial_request, info_request: request) expect(message.is_owning_user?(user)).to eq(false) end @@ -943,13 +943,13 @@ class TestError < StandardError; end message. info_request_events. first. - update(:params => { :smtp_message_id => old_format_smtp_id }) + update(params: { smtp_message_id: old_format_smtp_id }) expect(message.smtp_message_ids).to eq([smtp_id]) end it 'returns an empty array if the smtp_message_id was not logged' do message = FactoryBot.create(:initial_request) - message.info_request_events.first.update(:params => {}) + message.info_request_events.first.update(params: {}) expect(message.smtp_message_ids).to be_empty end @@ -1051,7 +1051,7 @@ class TestError < StandardError; end message = FactoryBot.create(:initial_request) body_email = message.info_request.public_body.request_email request_email = message.info_request.incoming_email - request_subject = message.info_request.email_subject_request(:html => false) + request_subject = message.info_request.email_subject_request(html: false) smtp_message_id = 'ogm-14+537f69734b97c-1ebd@localhost' load_mail_server_logs <<-EOF.strip_heredoc @@ -1067,7 +1067,7 @@ class TestError < StandardError; end message = FactoryBot.create(:initial_request) body_email = message.info_request.public_body.request_email request_email = message.info_request.incoming_email - request_subject = message.info_request.email_subject_request(:html => false) + request_subject = message.info_request.email_subject_request(html: false) smtp_message_id = 'ogm-14+537f69734b97c-1ebd@localhost' load_mail_server_logs <<-EOF.strip_heredoc @@ -1103,7 +1103,7 @@ class TestError < StandardError; end message = FactoryBot.create(:initial_request) body_email = message.info_request.public_body.request_email request_email = message.info_request.incoming_email - request_subject = message.info_request.email_subject_request(:html => false) + request_subject = message.info_request.email_subject_request(html: false) smtp_message_id = 'ogm-14+537f69734b97c-1ebd@localhost' load_mail_server_logs <<-EOF.strip_heredoc @@ -1165,7 +1165,7 @@ class TestError < StandardError; end message = FactoryBot.create(:initial_request) body_email = message.info_request.public_body.request_email request_email = message.info_request.incoming_email - request_subject = message.info_request.email_subject_request(:html => false) + request_subject = message.info_request.email_subject_request(html: false) smtp_message_id = 'ogm-14+537f69734b97c-1ebd@localhost' load_mail_server_logs <<-EOF.strip_heredoc @@ -1227,7 +1227,7 @@ class TestError < StandardError; end message = FactoryBot.create(:initial_request) body_email = message.info_request.public_body.request_email request_email = message.info_request.incoming_email - request_subject = message.info_request.email_subject_request(:html => false) + request_subject = message.info_request.email_subject_request(html: false) smtp_message_id = 'ogm-14+537f69734b97c-1ebd@localhost' load_mail_server_logs <<-EOF.strip_heredoc @@ -1267,7 +1267,7 @@ class TestError < StandardError; end message = FactoryBot.create(:initial_request) body_email = message.info_request.public_body.request_email request_email = message.info_request.incoming_email - request_subject = message.info_request.email_subject_request(:html => false) + request_subject = message.info_request.email_subject_request(html: false) smtp_message_id = 'ogm-14+537f69734b97c-1ebd@localhost' load_mail_server_logs <<-EOF.strip_heredoc @@ -1335,7 +1335,7 @@ class TestError < StandardError; end message = FactoryBot.create(:initial_request) body_email = message.info_request.public_body.request_email request_email = message.info_request.incoming_email - request_subject = message.info_request.email_subject_request(:html => false) + request_subject = message.info_request.email_subject_request(html: false) smtp_message_id = 'ogm-14+537f69734b97c-1ebd@localhost' load_mail_server_logs <<-EOF.strip_heredoc @@ -1406,7 +1406,7 @@ class TestError < StandardError; end message = FactoryBot.create(:initial_request) body_email = message.info_request.public_body.request_email request_email = message.info_request.incoming_email - request_subject = message.info_request.email_subject_request(:html => false) + request_subject = message.info_request.email_subject_request(html: false) smtp_message_id = 'ogm-14+537f69734b97c-1ebd@localhost' load_mail_server_logs <<-EOF.strip_heredoc @@ -1445,7 +1445,7 @@ class TestError < StandardError; end message = FactoryBot.create(:internal_review_request) body_email = message.info_request.public_body.request_email request_email = message.info_request.incoming_email - request_subject = message.info_request.email_subject_request(:html => false) + request_subject = message.info_request.email_subject_request(html: false) smtp_message_id = 'ogm-14+537f69734b97c-1ebd@localhost' message.prepare_message_for_resend @@ -1502,7 +1502,7 @@ class TestError < StandardError; end message = FactoryBot.create(:initial_request) body_email = message.info_request.public_body.request_email request_email = message.info_request.incoming_email - request_subject = message.info_request.email_subject_request(:html => false) + request_subject = message.info_request.email_subject_request(html: false) smtp_message_id = 'ogm-14+537f69734b97c-1ebd@localhost' load_mail_server_logs <<-EOF.strip_heredoc @@ -1532,7 +1532,7 @@ class TestError < StandardError; end message = FactoryBot.create(:initial_request) body_email = message.info_request.public_body.request_email request_email = message.info_request.incoming_email - request_subject = message.info_request.email_subject_request(:html => false) + request_subject = message.info_request.email_subject_request(html: false) smtp_message_id = 'ogm-14+537f69734b97c-1ebd@localhost' load_mail_server_logs <<-EOF.strip_heredoc @@ -1566,7 +1566,7 @@ class TestError < StandardError; end message = FactoryBot.create(:initial_request) body_email = message.info_request.public_body.request_email request_email = message.info_request.incoming_email - request_subject = message.info_request.email_subject_request(:html => false) + request_subject = message.info_request.email_subject_request(html: false) smtp_message_id = 'ogm-14+537f69734b97c-1ebd@localhost' load_mail_server_logs <<-EOF.strip_heredoc @@ -1608,7 +1608,7 @@ class TestError < StandardError; end message = FactoryBot.create(:internal_review_request) body_email = message.info_request.public_body.request_email request_email = message.info_request.incoming_email - request_subject = message.info_request.email_subject_request(:html => false) + request_subject = message.info_request.email_subject_request(html: false) smtp_message_id = 'ogm-14+537f69734b97c-1ebd@localhost' message.prepare_message_for_resend @@ -1690,7 +1690,7 @@ class TestError < StandardError; end junk garbage EOF - logs = log_lines.map { |line| MailServerLog.new(:line => line) } + logs = log_lines.map { |line| MailServerLog.new(line: line) } message = FactoryBot.create(:initial_request) allow(message).to receive(:mail_server_logs).and_return(logs) status = MailServerLog::DeliveryStatus.new(:unknown) @@ -1710,7 +1710,7 @@ class TestError < StandardError; end 2015-10-30 19:24:16 [17817] 1ZsFHb-0004dK-SM => authority@example.com F= P= R=dnslookup T=remote_smtp S=2297 H=cluster2.gsi.messagelabs.com [127.0.0.1]:25 X=TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128 CV=no DN="C=US,ST=California,L=Mountain View,O=Symantec Corporation,OU=Symantec.cloud,CN=mail221.messagelabs.com" C="250 ok 1446233056 qp 26062 server-4.tower-221.messagelabs.com!1446233056!7679409!1" QT=1s DT=0s 2015-10-30 19:24:16 [17817] 1ZsFHb-0004dK-SM junk EOF - logs = log_lines.map { |line| MailServerLog.new(:line => line) } + logs = log_lines.map { |line| MailServerLog.new(line: line) } message = FactoryBot.create(:initial_request) allow(message).to receive(:mail_server_logs).and_return(logs) status = MailServerLog::DeliveryStatus.new(:delivered) @@ -1726,7 +1726,7 @@ class TestError < StandardError; end 2016-04-22 13:13:03 [24970] 1atZxH-0006Uk-KF <= request-326806-hk82iwn7@localhost U=alaveteli P=local S=1923 id=ogm-531356+571a154f7b7c5-2a7e@localhost T="Freedom of Information request - Some Information" from for foi@example.net foi@example.net 2016-04-22 13:24:41 [29720] 1atZxH-0006Uk-KF => foi@example.net F= P= R=dnslookup T=remote_smtp S=1975 H=mail.example.net [213.161.89.103]:25 X=TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256 CV=no DN="ST=CA,L=CU,O=TREND,OU=IMSVA,CN=IMSVA.TREND" C="250 2.0.0 Ok: queued as 8D6E6AA66C" QT=11m38s DT=0s EOF - logs = log_lines.map { |line| MailServerLog.new(:line => line) } + logs = log_lines.map { |line| MailServerLog.new(line: line) } message = FactoryBot.create(:initial_request) allow(message).to receive(:mail_server_logs).and_return(logs) status = MailServerLog::DeliveryStatus.new(:delivered) @@ -1740,7 +1740,7 @@ class TestError < StandardError; end 2016-04-06 12:01:08 [14933] 1anlCt-0003sm-LG ** foi@authority.net F=: all relevant MX records point to non-existent hosts 2016-04-06 12:01:08 [14935] 1anlCu-0003st-1p <= <> R=1anlCt-0003sm-LG U=Debian-exim P=local S=2934 T="Mail delivery failed: returning message to sender" from <> for request-326806-hk82iwn7@localhost EOF - logs = log_lines.map { |line| MailServerLog.new(:line => line) } + logs = log_lines.map { |line| MailServerLog.new(line: line) } message = FactoryBot.create(:initial_request) allow(message).to receive(:mail_server_logs).and_return(logs) status = MailServerLog::DeliveryStatus.new(:failed) @@ -1768,7 +1768,7 @@ class TestError < StandardError; end Oct 3 16:39:38 host postfix/smtp[1681]: 9634B16F7F7: to=, relay=none, delay=46, status=deferred (connect to 216.150.150.131[216.150.150.131]: No route to host) Oct 3 16:39:38 host postfix/qmgr[15615]: CB55836EE58C: removed EOF - logs = log_lines.map { |line| MailServerLog.new(:line => line) } + logs = log_lines.map { |line| MailServerLog.new(line: line) } message = FactoryBot.create(:initial_request) allow(message).to receive(:mail_server_logs).and_return(logs) status = MailServerLog::DeliveryStatus.new(:sent) @@ -1784,7 +1784,7 @@ class TestError < StandardError; end Nov 19 22:56:04 host postfix/cleanup[26052]: 3742D3602065: message-id= Nov 19 22:56:04 host postfix/pickup[27268]: 3742D3602065: uid=1003 from= EOF - logs = log_lines.map { |line| MailServerLog.new(:line => line) } + logs = log_lines.map { |line| MailServerLog.new(line: line) } message = FactoryBot.create(:initial_request) allow(message).to receive(:mail_server_logs).and_return(logs) status = MailServerLog::DeliveryStatus.new(:failed) @@ -1799,7 +1799,7 @@ class TestError < StandardError; end Oct 3 16:39:38 host postfix/smtp[7676]: CB55836EE58C: to=, relay=aspmx.l.google.com[74.125.25.27]:25, delay=2.5, delays=0.13/0.02/1.7/0.59, dsn=2.0.0, status=sent (250 2.0.0 OK 1349246383 j9si1676296paw.328) Oct 3 16:39:38 host postfix/qmgr[15615]: CB55836EE58C: removed EOF - logs = log_lines.map { |line| MailServerLog.new(:line => line) } + logs = log_lines.map { |line| MailServerLog.new(line: line) } message = FactoryBot.create(:initial_request) allow(message).to receive(:mail_server_logs).and_return(logs) status = MailServerLog::DeliveryStatus.new(:delivered) @@ -1820,7 +1820,7 @@ class TestError < StandardError; end Nov 20 16:39:38 host postfix/smtp[7676]: CB55836EE58C: to=, relay=aspmx.l.google.com[74.125.25.27]:25, delay=2.5, delays=0.13/0.02/1.7/0.59, dsn=2.0.0, status=sent (250 2.0.0 OK 1349246383 j9si1676296paw.328) Nov 20 16:39:38 host postfix/qmgr[15615]: CB55836EE58C: removed EOF - logs = log_lines.map { |line| MailServerLog.new(:line => line) } + logs = log_lines.map { |line| MailServerLog.new(line: line) } message = FactoryBot.create(:initial_request) allow(message).to receive(:mail_server_logs).and_return(logs) status = MailServerLog::DeliveryStatus.new(:delivered) @@ -1891,11 +1891,11 @@ class TestError < StandardError; end before do @om = outgoing_messages(:useless_outgoing_message) @outgoing_message = OutgoingMessage.new({ - :status => 'ready', - :message_type => 'initial_request', - :body => 'This request contains a foo@bar.com email address', - :last_sent_at => Time.zone.now, - :what_doing => 'normal_sort' + status: 'ready', + message_type: 'initial_request', + body: 'This request contains a foo@bar.com email address', + last_sent_at: Time.zone.now, + what_doing: 'normal_sort' }) end @@ -1915,10 +1915,10 @@ class TestError < StandardError; end title: 'A test title', public_body: public_body) outgoing_message = OutgoingMessage.new({ - :status => 'ready', - :message_type => 'followup', - :what_doing => 'internal_review', - :info_request => info_request + status: 'ready', + message_type: 'followup', + what_doing: 'internal_review', + info_request: info_request }) expected_text = "Dear A test public body,\n\nPlease pass this on to the person who conducts Freedom of Information reviews.\n\nI am writing to request an internal review of A test public body's handling of my FOI request 'A test title'.\n\n[ GIVE DETAILS ABOUT YOUR COMPLAINT HERE ]\n\nA full history of my FOI request and all correspondence is available on the Internet at this address: http://test.host/request/a_test_title\n\nYours faithfully," expect(outgoing_message.body).to eq(expected_text) diff --git a/spec/models/post_redirect_spec.rb b/spec/models/post_redirect_spec.rb index 1ec4089ba5..cac55bd3dd 100644 --- a/spec/models/post_redirect_spec.rb +++ b/spec/models/post_redirect_spec.rb @@ -46,7 +46,7 @@ describe '#valid?' do it 'is false if an invalid circumstance is provided' do - pr = PostRedirect.new(:circumstance => 'invalid') + pr = PostRedirect.new(circumstance: 'invalid') expect(pr).to_not be_valid end @@ -122,12 +122,12 @@ it "should generate a URL friendly token" do pr = PostRedirect.new - expect(pr.token).to match(/[a-z0-9]+/); + expect(pr.token).to match(/[a-z0-9]+/) end it "should generate an email friendly email token" do pr = PostRedirect.new - expect(pr.email_token).to match(/[a-z0-9]+/); + expect(pr.email_token).to match(/[a-z0-9]+/) end context 'when normal circumstance' do @@ -159,7 +159,7 @@ it "should convert post parameters into YAML and back successfully" do pr = PostRedirect.new - example_post_params = { :foo => 'this is stuff', :bar => 83, :humbug => "yikes!!!" } + example_post_params = { foo: 'this is stuff', bar: 83, humbug: "yikes!!!" } pr.post_params = example_post_params expect(pr.post_params_yaml).to eq(example_post_params.to_yaml) expect(pr.post_params).to eq(example_post_params) @@ -167,7 +167,7 @@ it "should convert reason parameters into YAML and back successfully" do pr = PostRedirect.new - example_reason_params = { :foo => 'this is stuff', :bar => 83, :humbug => "yikes!!!" } + example_reason_params = { foo: 'this is stuff', bar: 83, humbug: "yikes!!!" } pr.reason_params = example_reason_params expect(pr.reason_params_yaml).to eq(example_reason_params.to_yaml) expect(pr.reason_params).to eq(example_reason_params) diff --git a/spec/models/profile_photo_spec.rb b/spec/models/profile_photo_spec.rb index d681212ea1..3eb7888d93 100644 --- a/spec/models/profile_photo_spec.rb +++ b/spec/models/profile_photo_spec.rb @@ -20,18 +20,18 @@ end it 'should take no image as invalid' do - profile_photo = ProfilePhoto.new(:data => nil, :user => @mock_user) + profile_photo = ProfilePhoto.new(data: nil, user: @mock_user) expect(profile_photo.valid?).to eq(false) end it 'should take bad binary data as invalid' do - profile_photo = ProfilePhoto.new(:data => 'blahblahblah', :user => @mock_user) + profile_photo = ProfilePhoto.new(data: 'blahblahblah', user: @mock_user) expect(profile_photo.valid?).to eq(false) end it 'should translate a no image error message' do AlaveteliLocalization.with_locale(:es) do - profile_photo = ProfilePhoto.new(:data => nil, :user => @mock_user) + profile_photo = ProfilePhoto.new(data: nil, user: @mock_user) expect(profile_photo.valid?).to eq(false) expect(profile_photo.errors[:data]).to eq(['Por favor elige el fichero que contiene tu foto']) end @@ -39,7 +39,7 @@ it 'should accept and convert a PNG to right size' do data = load_file_fixture("parrot.png") - profile_photo = ProfilePhoto.new(:data => data, :user => @mock_user) + profile_photo = ProfilePhoto.new(data: data, user: @mock_user) expect(profile_photo.valid?).to eq(true) expect(profile_photo.image.type).to eq('PNG') expect(profile_photo.image.width).to eq(96) @@ -48,7 +48,7 @@ it 'should accept and convert a JPEG to right format and size' do data = load_file_fixture("parrot.jpg") - profile_photo = ProfilePhoto.new(:data => data, :user => @mock_user) + profile_photo = ProfilePhoto.new(data: data, user: @mock_user) expect(profile_photo.valid?).to eq(true) expect(profile_photo.image.type).to eq('PNG') expect(profile_photo.image.width).to eq(96) @@ -57,7 +57,7 @@ it 'should accept a draft PNG and not resize it' do data = load_file_fixture("parrot.png") - profile_photo = ProfilePhoto.new(:data => data, :draft => true) + profile_photo = ProfilePhoto.new(data: data, draft: true) expect(profile_photo.valid?).to eq(true) expect(profile_photo.image.type).to eq('PNG') expect(profile_photo.image.width).to eq(198) diff --git a/spec/models/project/export_spec.rb b/spec/models/project/export_spec.rb index c458d8b18c..e693226024 100644 --- a/spec/models/project/export_spec.rb +++ b/spec/models/project/export_spec.rb @@ -11,11 +11,11 @@ let(:info_request_b) { instance_double('InfoRequest') } before do - allow(project).to receive_message_chain(:info_requests, :extracted). + allow(project).to receive_message_chain(:info_requests). and_return([info_request_a, info_request_b]) end - it 'individualy exports info requests' do + it 'individually exports info requests' do expect(Project::Export::InfoRequest).to receive(:new). with(project, info_request_a). and_return(double(data: { header: 'DATA A' })) diff --git a/spec/models/project/leaderboard_spec.rb b/spec/models/project/leaderboard_spec.rb new file mode 100644 index 0000000000..9153eb23c3 --- /dev/null +++ b/spec/models/project/leaderboard_spec.rb @@ -0,0 +1,114 @@ +require 'spec_helper' + +RSpec.describe Project::Leaderboard do + let(:project) { instance_double('Project') } + let(:instance) { described_class.new(project) } + + shared_context 'project submissions' do + let(:project) { FactoryBot.create(:project, contributors_count: 2) } + let(:user_1) { project.members[1] } # member 0 is the project owner + let(:user_2) { project.members[2] } + + before do + FactoryBot.create( + :project_submission, :for_classification, project: project, user: user_1 + ) + FactoryBot.create( + :project_submission, :for_extraction, project: project, user: user_1 + ) + + travel_to 28.days.ago + FactoryBot.create( + :project_submission, :for_extraction, project: project, user: user_2 + ) + travel_back + end + end + + describe '#all_time' do + include_context 'project submissions' + + subject(:data) { instance.all_time } + + it 'returns the data that we would expect' do + is_expected.to include( + classifications: 1, extractions: 1, total_contributions: 2, user: user_1 + ) + is_expected.to include( + classifications: 0, extractions: 1, total_contributions: 1, user: user_2 + ) + end + + it 'orders the data by descending total contributions' do + expect(data[0][:total_contributions]).to eq(2) + expect(data[1][:total_contributions]).to eq(1) + expect(data[2][:total_contributions]).to eq(0) + end + + context 'when project has more than 5 members' do + let(:project) { FactoryBot.create(:project, contributors_count: 10) } + + it 'returns a maximum of 5 rows' do + expect(data.count).to eq(5) + end + end + end + + describe '#twenty_eight_days' do + include_context 'project submissions' + + subject(:data) { instance.twenty_eight_days } + + it 'returns the data that we would expect from the last 28 days' do + is_expected.to include( + classifications: 1, extractions: 1, total_contributions: 2, user: user_1 + ) + is_expected.to include( + classifications: 0, extractions: 0, total_contributions: 0, user: user_2 + ) + end + + it 'orders the data by descending total contributions' do + expect(data[0][:total_contributions]).to eq(2) + expect(data[1][:total_contributions]).to eq(0) + end + + context 'when project has more than 5 members' do + let(:project) { FactoryBot.create(:project, contributors_count: 10) } + + it 'returns a maximum of 5 rows' do + expect(data.count).to eq(5) + end + end + end + + describe '#name' do + let(:project) { instance_double('Project', id: 1, title: 'Test Project') } + subject { instance.name } + + it 'returns a useful filename' do + travel_to Time.utc(2019, 11, 18, 10, 30) + is_expected.to( + eq 'project-leaderboard-1-test_project-2019-11-18-103000.csv' + ) + travel_back + end + end + + describe '#to_csv' do + subject { instance.to_csv } + + let(:user) { instance_double('User', name: 'Bob') } + + it 'returns CSV string from leaderboard' do + allow(instance).to receive(:data).and_return( + [{ foo: 'Foo', bar: 'Bar', user: user }] + ) + + is_expected.to eq <<~CSV + foo,bar,user + Foo,Bar,Bob + CSV + end + end +end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 9f15598b18..0d59ac252a 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -34,7 +34,15 @@ let(:project) do FactoryBot.create( :project, requests: [ - unclassified_request, classified_request, extracted_request + unclassified_request, classified_request, extracted_request, + other_project_extracted_request, both_projects_extracted_request + ] + ) + end + let(:other_project) do + FactoryBot.create( + :project, requests: [ + other_project_extracted_request, both_projects_extracted_request ] ) end @@ -47,7 +55,27 @@ described_state: 'successful' ) end - let(:extracted_request) { FactoryBot.build(:info_request) } + let(:extracted_request) do + FactoryBot.build( + :info_request, + awaiting_description: false, + described_state: 'successful' + ) + end + let(:other_project_extracted_request) do + FactoryBot.build( + :info_request, + awaiting_description: false, + described_state: 'successful' + ) + end + let(:both_projects_extracted_request) do + FactoryBot.build( + :info_request, + awaiting_description: false, + described_state: 'successful' + ) + end before do FactoryBot.create( @@ -58,6 +86,18 @@ :project_submission, :for_extraction, project: project, info_request: extracted_request ) + FactoryBot.create( + :project_submission, :for_extraction, + project: other_project, info_request: other_project_extracted_request + ) + FactoryBot.create( + :project_submission, :for_extraction, + project: project, info_request: both_projects_extracted_request + ) + FactoryBot.create( + :project_submission, :for_extraction, + project: other_project, info_request: both_projects_extracted_request + ) end end @@ -335,6 +375,14 @@ it 'excludes extracted requests' do is_expected.not_to include extracted_request end + + it 'includes requests extracted in other projects' do + is_expected.to include other_project_extracted_request + end + + it 'excludes requests extracted in both projects' do + is_expected.not_to include both_projects_extracted_request + end end describe '#info_requests.extracted' do @@ -357,6 +405,10 @@ it 'includes extracted requests' do is_expected.to include extracted_request end + + it 'excludes requests extracted in different projects' do + is_expected.not_to include other_project_extracted_request + end end describe '#extraction_progress' do diff --git a/spec/models/public_body_category/category_collection_spec.rb b/spec/models/public_body_category/category_collection_spec.rb index 230935d0f5..da7e067837 100644 --- a/spec/models/public_body_category/category_collection_spec.rb +++ b/spec/models/public_body_category/category_collection_spec.rb @@ -7,7 +7,7 @@ data = [ "Local and regional", [ "local_council", "Local councils", "a local council" ], "Miscellaneous", - [ "other", "Miscellaneous", "miscellaneous" ] ] + %w[other Miscellaneous miscellaneous] ] @categories = PublicBodyCategory::CategoryCollection.new data.each { |item| @categories << item } end @@ -27,9 +27,9 @@ expected_categories = ["Local and regional", ["local_council", "Local councils", "a local council"], - "Miscellaneous", ["other", - "Miscellaneous", - "miscellaneous"]] + "Miscellaneous", %w[other + Miscellaneous + miscellaneous]] expect(@categories.with_headings).to eq(expected_categories) end end @@ -56,7 +56,7 @@ describe 'when asked for tags' do it 'should return a list of tags' do - expect(@categories.tags).to eq(["local_council", "other"]) + expect(@categories.tags).to eq(%w[local_council other]) end end diff --git a/spec/models/public_body_category_link_spec.rb b/spec/models/public_body_category_link_spec.rb index a671a059f8..4cdbb54dbb 100644 --- a/spec/models/public_body_category_link_spec.rb +++ b/spec/models/public_body_category_link_spec.rb @@ -18,8 +18,8 @@ it 'should set a default display order based on the next available display order' do heading = FactoryBot.create(:public_body_heading) category = FactoryBot.create(:public_body_category) - category_link = PublicBodyCategoryLink.new(:public_body_heading => heading, - :public_body_category => category) + category_link = PublicBodyCategoryLink.new(public_body_heading: heading, + public_body_category: category) category_link.valid? expect(category_link.category_display_order).to eq(PublicBodyCategoryLink.next_display_order(heading)) end @@ -77,8 +77,8 @@ it 'should return one more than the highest display order if there are public body headings' do heading = FactoryBot.create(:public_body_heading) category = FactoryBot.create(:public_body_category) - category_link = PublicBodyCategoryLink.create(:public_body_heading_id => heading.id, - :public_body_category_id => category.id) + category_link = PublicBodyCategoryLink.create(public_body_heading_id: heading.id, + public_body_category_id: category.id) expect(PublicBodyCategoryLink.next_display_order(heading)).to eq(1) end diff --git a/spec/models/public_body_category_spec.rb b/spec/models/public_body_category_spec.rb index 0a114089c7..b3409747eb 100644 --- a/spec/models/public_body_category_spec.rb +++ b/spec/models/public_body_category_spec.rb @@ -31,7 +31,7 @@ it 'should require a unique tag' do existing = FactoryBot.create(:public_body_category) - expect(PublicBodyCategory.new(:category_tag => existing.category_tag)). + expect(PublicBodyCategory.new(category_tag: existing.category_tag)). not_to be_valid end @@ -49,8 +49,8 @@ it 'uses the base model validation for the default locale' do category = PublicBodyCategory.new - translation = category.translations.build(:locale => 'en', - :description => 'No title') + translation = category.translations.build(locale: 'en', + description: 'No title') category.valid? translation.valid? expect(category.errors[:title].size).to eq(1) @@ -63,9 +63,9 @@ it 'saves translations' do category = FactoryBot.build(:public_body_category) - category.translations_attributes = { :es => { :locale => 'es', - :title => 'El Category', - :description => 'Spanish description' } } + category.translations_attributes = { es: { locale: 'es', + title: 'El Category', + description: 'Spanish description' } } category.save! expect(PublicBodyCategory.find(category.id).translations.size).to eq(2) @@ -79,18 +79,18 @@ it 'does not persist translations' do category = FactoryBot.create(:public_body_category) - category.translations_attributes = { :es => { :locale => 'es', - :title => 'El Category', - :description => 'Spanish description' } } + category.translations_attributes = { es: { locale: 'es', + title: 'El Category', + description: 'Spanish description' } } expect(PublicBodyCategory.find(category.id).translations.size).to eq(1) end it 'creates a new translation' do category = FactoryBot.create(:public_body_category) - category.translations_attributes = { :es => { :locale => 'es', - :title => 'El Category', - :description => 'Spanish description' } } + category.translations_attributes = { es: { locale: 'es', + title: 'El Category', + description: 'Spanish description' } } category.save! category.reload expect(category.title(:es)).to eq('El Category') @@ -98,33 +98,33 @@ it 'updates an existing translation' do category = FactoryBot.create(:public_body_category) - category.translations_attributes = { 'es' => { :locale => 'es', - :title => 'Name', - :description => 'Desc' } } + category.translations_attributes = { 'es' => { locale: 'es', + title: 'Name', + description: 'Desc' } } category.save! - category.translations_attributes = { 'es' => { :id => category.translation_for(:es).id, - :locale => 'es', - :title => 'Renamed', - :description => 'Desc' } } + category.translations_attributes = { 'es' => { id: category.translation_for(:es).id, + locale: 'es', + title: 'Renamed', + description: 'Desc' } } category.save! expect(category.title(:es)).to eq('Renamed') end it 'updates an existing translation and creates a new translation' do category = FactoryBot.create(:public_body_category) - category.translations.create(:locale => 'es', - :title => 'Los Category', - :description => 'ES Description') + category.translations.create(locale: 'es', + title: 'Los Category', + description: 'ES Description') expect(category.translations.size).to eq(2) category.translations_attributes = { - 'es' => { :id => category.translation_for(:es).id, - :locale => 'es', - :title => 'Renamed' }, - 'fr' => { :locale => 'fr', - :title => 'Le Category' } + 'es' => { id: category.translation_for(:es).id, + locale: 'es', + title: 'Renamed' }, + 'fr' => { locale: 'fr', + title: 'Le Category' } } expect(category.translations.size).to eq(3) @@ -138,17 +138,17 @@ it 'skips empty translations' do category = FactoryBot.create(:public_body_category) - category.translations.create(:locale => 'es', - :title => 'Los Category', - :description => 'ES Description') + category.translations.create(locale: 'es', + title: 'Los Category', + description: 'ES Description') expect(category.translations.size).to eq(2) category.translations_attributes = { - 'es' => { :id => category.translation_for(:es).id, - :locale => 'es', - :title => 'Renamed' }, - 'fr' => { :locale => 'fr' } + 'es' => { id: category.translation_for(:es).id, + locale: 'es', + title: 'Renamed' }, + 'fr' => { locale: 'fr' } } expect(category.translations.size).to eq(2) @@ -169,18 +169,18 @@ it 'is valid if no required attributes are assigned' do translation = PublicBodyCategory::Translation. - new(:locale => AlaveteliLocalization.default_locale) + new(locale: AlaveteliLocalization.default_locale) expect(translation).to be_valid end it 'requires a title if another required attribute is assigned' do - translation = PublicBodyCategory::Translation.new(:description => 'spec') + translation = PublicBodyCategory::Translation.new(description: 'spec') translation.valid? expect(translation.errors[:title]).to eq(["Title can't be blank"]) end it 'requires a description if another required attribute is assigned' do - translation = PublicBodyCategory::Translation.new(:title => 'spec') + translation = PublicBodyCategory::Translation.new(title: 'spec') translation.valid? expect(translation.errors[:description]).to eq(["Description can't be blank"]) end @@ -188,7 +188,7 @@ describe '#default_locale?' do it 'returns true if the locale is the default locale' do - translation = PublicBodyCategory::Translation.new(:locale => "en") + translation = PublicBodyCategory::Translation.new(locale: "en") expect(translation.default_locale?).to be true end @@ -196,7 +196,7 @@ it 'returns true if the locale is the default locale' do AlaveteliLocalization.set_locales('en_GB es', 'en_GB') - translation = PublicBodyCategory::Translation.new(:locale => "en_GB") + translation = PublicBodyCategory::Translation.new(locale: "en_GB") expect(translation.default_locale?).to be true end @@ -204,7 +204,7 @@ end it 'returns false if the locale is not the default locale' do - translation = PublicBodyCategory::Translation.new(:locale => "es") + translation = PublicBodyCategory::Translation.new(locale: "es") expect(translation.default_locale?).to be false end diff --git a/spec/models/public_body_change_request_spec.rb b/spec/models/public_body_change_request_spec.rb index a346b7eef0..5975c974d9 100644 --- a/spec/models/public_body_change_request_spec.rb +++ b/spec/models/public_body_change_request_spec.rb @@ -67,34 +67,34 @@ end it 'should not be valid without a user name if there is no user' do - change_request = PublicBodyChangeRequest.new(:public_body_name => 'New Body') + change_request = PublicBodyChangeRequest.new(public_body_name: 'New Body') expect(change_request.valid?).to be false expect(change_request.errors[:user_name]).to eq(['Please enter your name']) end it 'should not be valid without a user email address if there is no user' do - change_request = PublicBodyChangeRequest.new(:public_body_name => 'New Body') + change_request = PublicBodyChangeRequest.new(public_body_name: 'New Body') expect(change_request.valid?).to be false expect(change_request.errors[:user_email]).to eq(['Please enter your email address']) end it 'should be valid with a user and no name or email address' do user = FactoryBot.build(:user) - change_request = PublicBodyChangeRequest.new(:user => user, - :public_body_name => 'New Body') + change_request = PublicBodyChangeRequest.new(user: user, + public_body_name: 'New Body') expect(change_request.valid?).to be true end it 'should validate the format of a user email address entered' do - change_request = PublicBodyChangeRequest.new(:public_body_name => 'New Body', - :user_email => '@example.com') + change_request = PublicBodyChangeRequest.new(public_body_name: 'New Body', + user_email: '@example.com') expect(change_request.valid?).to be false expect(change_request.errors[:user_email]).to eq(["Your email doesn't look like a valid address"]) end it 'should validate the format of a public body email address entered' do - change_request = PublicBodyChangeRequest.new(:public_body_name => 'New Body', - :public_body_email => '@example.com') + change_request = PublicBodyChangeRequest.new(public_body_name: 'New Body', + public_body_email: '@example.com') expect(change_request.valid?).to be false expect(change_request.errors[:public_body_email]).to eq(["The authority email doesn't look like a valid address"]) end @@ -104,13 +104,13 @@ RSpec.describe PublicBodyChangeRequest, 'get_user_name' do it 'should return the user_name field if there is no user association' do - change_request = PublicBodyChangeRequest.new(:user_name => 'Test User') + change_request = PublicBodyChangeRequest.new(user_name: 'Test User') expect(change_request.get_user_name).to eq('Test User') end it 'should return the name of the associated user if there is one' do user = FactoryBot.build(:user) - change_request = PublicBodyChangeRequest.new(:user => user) + change_request = PublicBodyChangeRequest.new(user: user) expect(change_request.get_user_name).to eq(user.name) end @@ -120,13 +120,13 @@ RSpec.describe PublicBodyChangeRequest, 'get_user_email' do it 'should return the user_email field if there is no user association' do - change_request = PublicBodyChangeRequest.new(:user_email => 'user@example.com') + change_request = PublicBodyChangeRequest.new(user_email: 'user@example.com') expect(change_request.get_user_email).to eq('user@example.com') end it 'should return the email of the associated user if there is one' do user = FactoryBot.build(:user) - change_request = PublicBodyChangeRequest.new(:user => user) + change_request = PublicBodyChangeRequest.new(user: user) expect(change_request.get_user_email).to eq(user.email) end @@ -153,11 +153,11 @@ RSpec.describe PublicBodyChangeRequest, '.open' do let(:open_request) do - FactoryBot.create(:update_body_request, :is_open => true) + FactoryBot.create(:update_body_request, is_open: true) end let(:closed_request) do - FactoryBot.create(:update_body_request, :is_open => false) + FactoryBot.create(:update_body_request, is_open: false) end it "returns requests where the is_open is true" do @@ -168,13 +168,13 @@ RSpec.describe PublicBodyChangeRequest, 'get_public_body_name' do it 'should return the public_body_name field if there is no public body association' do - change_request = PublicBodyChangeRequest.new(:public_body_name => 'Test Authority') + change_request = PublicBodyChangeRequest.new(public_body_name: 'Test Authority') expect(change_request.get_public_body_name).to eq('Test Authority') end it 'should return the name of the associated public body if there is one' do public_body = FactoryBot.build(:public_body) - change_request = PublicBodyChangeRequest.new(:public_body => public_body) + change_request = PublicBodyChangeRequest.new(public_body: public_body) expect(change_request.get_public_body_name).to eq(public_body.name) end @@ -183,10 +183,10 @@ RSpec.describe PublicBodyChangeRequest, 'when creating a comment for the associated public body' do it 'should include requesting user, source_url and notes' do - change_request = PublicBodyChangeRequest.new(:user_name => 'Test User', - :user_email => 'test@example.com', - :source_url => 'http://www.example.com', - :notes => 'Some notes') + change_request = PublicBodyChangeRequest.new(user_name: 'Test User', + user_email: 'test@example.com', + source_url: 'http://www.example.com', + notes: 'Some notes') expected = "Requested by: Test User (test@example.com)\nSource URL: http://www.example.com\nNotes: Some notes" expect(change_request.comment_for_public_body).to eq(expected) end @@ -198,21 +198,21 @@ context 'requesting a new authority' do it 'returns an appropriate subject line' do - change_request = PublicBodyChangeRequest.new(:public_body_name => 'Test') + change_request = PublicBodyChangeRequest.new(public_body_name: 'Test') expect(change_request.request_subject). to eq('Add authority - Test') end it 'does not HTML escape the authority name' do change_request = - PublicBodyChangeRequest.new(:public_body_name => "Test's") + PublicBodyChangeRequest.new(public_body_name: "Test's") expect(change_request.request_subject). to eq('Add authority - Test\'s') end it 'does not mark subject line with unescaped text as html_safe' do change_request = - PublicBodyChangeRequest.new(:public_body_name => "Test's") + PublicBodyChangeRequest.new(public_body_name: "Test's") expect(change_request.request_subject.html_safe?).to eq(false) end @@ -222,14 +222,14 @@ it 'returns an appropriate subject line' do public_body = FactoryBot.build(:public_body) - change_request = PublicBodyChangeRequest.new(:public_body => public_body) + change_request = PublicBodyChangeRequest.new(public_body: public_body) expect(change_request.request_subject). to eq("Update email address - #{public_body.name}") end it 'does not HTML escape the authority name' do public_body = FactoryBot.build(:public_body, name: "Test's") - change_request = PublicBodyChangeRequest.new(:public_body => public_body) + change_request = PublicBodyChangeRequest.new(public_body: public_body) expect(change_request.request_subject). to eq('Update email address - Test\'s') end @@ -242,12 +242,12 @@ it 'returns false if there is an associated public_body' do public_body = FactoryBot.build(:public_body) - change_request = PublicBodyChangeRequest.new(:public_body => public_body) + change_request = PublicBodyChangeRequest.new(public_body: public_body) expect(change_request.add_body_request?).to eq(false) end it 'returns true if there is no associated public_body' do - change_request = PublicBodyChangeRequest.new(:public_body_name => 'Test') + change_request = PublicBodyChangeRequest.new(public_body_name: 'Test') expect(change_request.add_body_request?).to eq(true) end @@ -256,14 +256,14 @@ RSpec.describe PublicBodyChangeRequest, 'when creating a default subject for a response email' do it 'should create an appropriate subject for a request to add a body' do - change_request = PublicBodyChangeRequest.new(:public_body_name => 'Test Body') + change_request = PublicBodyChangeRequest.new(public_body_name: 'Test Body') expect(change_request.default_response_subject). to eq('Re: Add authority - Test Body') end it 'should create an appropriate subject for a request to update an email address' do public_body = FactoryBot.build(:public_body) - change_request = PublicBodyChangeRequest.new(:public_body => public_body) + change_request = PublicBodyChangeRequest.new(public_body: public_body) expect(change_request.default_response_subject). to eq("Re: Update email address - #{public_body.name}") end diff --git a/spec/models/public_body_heading_spec.rb b/spec/models/public_body_heading_spec.rb index ebd2d43ae7..5044d412fd 100644 --- a/spec/models/public_body_heading_spec.rb +++ b/spec/models/public_body_heading_spec.rb @@ -24,7 +24,7 @@ it 'should require a unique name' do heading = FactoryBot.create(:public_body_heading) - new_heading = PublicBodyHeading.new(:name => heading.name) + new_heading = PublicBodyHeading.new(name: heading.name) expect(new_heading).not_to be_valid expect(new_heading.errors[:name]).to eq(["Name is already taken"]) end @@ -61,8 +61,8 @@ it 'saves translations' do heading = FactoryBot.build(:public_body_heading) - heading.translations_attributes = { :es => { :locale => 'es', - :name => 'El Heading' } } + heading.translations_attributes = { es: { locale: 'es', + name: 'El Heading' } } heading.save! expect(PublicBodyHeading.find(heading.id).translations.size).to eq(2) @@ -76,16 +76,16 @@ it 'does not persist translations' do heading = FactoryBot.create(:public_body_heading) - heading.translations_attributes = { :es => { :locale => 'es', - :name => 'El Heading' } } + heading.translations_attributes = { es: { locale: 'es', + name: 'El Heading' } } expect(PublicBodyHeading.find(heading.id).translations.size).to eq(1) end it 'creates a new translation' do heading = FactoryBot.create(:public_body_heading) - heading.translations_attributes = { :es => { :locale => 'es', - :name => 'El Heading' } } + heading.translations_attributes = { es: { locale: 'es', + name: 'El Heading' } } heading.save! heading.reload expect(heading.name(:es)).to eq('El Heading') @@ -93,30 +93,30 @@ it 'updates an existing translation' do heading = FactoryBot.create(:public_body_heading) - heading.translations_attributes = { 'es' => { :locale => 'es', - :name => 'Name' } } + heading.translations_attributes = { 'es' => { locale: 'es', + name: 'Name' } } heading.save! - heading.translations_attributes = { 'es' => { :id => heading.translation_for(:es).id, - :locale => 'es', - :name => 'Renamed' } } + heading.translations_attributes = { 'es' => { id: heading.translation_for(:es).id, + locale: 'es', + name: 'Renamed' } } heading.save! expect(heading.name(:es)).to eq('Renamed') end it 'updates an existing translation and creates a new translation' do heading = FactoryBot.create(:public_body_heading) - heading.translations.create(:locale => 'es', - :name => 'Los Heading') + heading.translations.create(locale: 'es', + name: 'Los Heading') expect(heading.translations.size).to eq(2) heading.translations_attributes = { - 'es' => { :id => heading.translation_for(:es).id, - :locale => 'es', - :name => 'Renamed' }, - 'fr' => { :locale => 'fr', - :name => 'Le Heading' } + 'es' => { id: heading.translation_for(:es).id, + locale: 'es', + name: 'Renamed' }, + 'fr' => { locale: 'fr', + name: 'Le Heading' } } expect(heading.translations.size).to eq(3) @@ -130,16 +130,16 @@ it 'skips empty translations' do heading = FactoryBot.create(:public_body_heading) - heading.translations.create(:locale => 'es', - :name => 'Los Heading') + heading.translations.create(locale: 'es', + name: 'Los Heading') expect(heading.translations.size).to eq(2) heading.translations_attributes = { - 'es' => { :id => heading.translation_for(:es).id, - :locale => 'es', - :name => 'Renamed' }, - 'fr' => { :locale => 'fr' } + 'es' => { id: heading.translation_for(:es).id, + locale: 'es', + name: 'Renamed' }, + 'fr' => { locale: 'fr' } } expect(heading.translations.size).to eq(2) @@ -158,7 +158,7 @@ it 'is valid if all required attributes are assigned' do translation = PublicBodyHeading::Translation.new( - :locale => AlaveteliLocalization.default_locale + locale: AlaveteliLocalization.default_locale ) expect(translation).to be_valid end diff --git a/spec/models/public_body_spec.rb b/spec/models/public_body_spec.rb index e27207fc76..6d708f06d2 100644 --- a/spec/models/public_body_spec.rb +++ b/spec/models/public_body_spec.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 20220210114052 +# Schema version: 20230209094128 # # Table name: public_bodies # @@ -22,7 +22,6 @@ # short_name :text # request_email :text # url_name :text -# notes :text # first_letter :string # publication_scheme :text # disclosure_log :text @@ -66,7 +65,10 @@ it 'update with translated name' do body = FactoryBot.create(:public_body) - AlaveteliLocalization.with_locale(:es) { body.name = 'hola'; body.save! } + AlaveteliLocalization.with_locale(:es) do + body.name = 'hola' + body.save! + end body.reload expect(body.update('name' => nil)).to eq(false) @@ -96,7 +98,10 @@ it 'blank string update with translated name' do body = FactoryBot.create(:public_body) - AlaveteliLocalization.with_locale(:es) { body.name = 'hola'; body.save! } + AlaveteliLocalization.with_locale(:es) do + body.name = 'hola' + body.save! + end body.reload expect(body.update('name' => '')).to eq(false) @@ -235,20 +240,20 @@ describe '#name' do it 'is invalid when nil' do - subject = described_class.new(:name => nil) + subject = described_class.new(name: nil) subject.valid? expect(subject.errors[:name]).to eq(["Name can't be blank"]) end it 'is invalid when blank' do - subject = described_class.new(:name => '') + subject = described_class.new(name: '') subject.valid? expect(subject.errors[:name]).to eq(["Name can't be blank"]) end it 'is invalid when not unique' do existing = FactoryBot.create(:public_body) - subject = described_class.new(:name => existing.name) + subject = described_class.new(name: existing.name) subject.valid? expect(subject.errors[:name]).to eq(["Name is already taken"]) end @@ -258,14 +263,14 @@ describe '#short_name' do it 'is invalid when not unique' do - existing = FactoryBot.create(:public_body, :short_name => 'xyz') - subject = described_class.new(:short_name => existing.short_name) + existing = FactoryBot.create(:public_body, short_name: 'xyz') + subject = described_class.new(short_name: existing.short_name) subject.valid? expect(subject.errors[:short_name]).to eq(["Short name is already taken"]) end it 'is valid when blank' do - subject = described_class.new(:short_name => '') + subject = described_class.new(short_name: '') subject.valid? expect(subject.errors[:short_name]).to be_empty end @@ -275,7 +280,7 @@ describe '#request_email' do it 'is invalid when nil' do - subject = described_class.new(:request_email => nil) + subject = described_class.new(request_email: nil) subject.valid? expect(subject.errors[:request_email]). to eq(["Request email can't be nil"]) @@ -285,7 +290,7 @@ subject(:public_body) do FactoryBot.build(:public_body, - :request_email => "request@example.com") + request_email: "request@example.com") end it "should return the set email address" do @@ -304,7 +309,7 @@ context "when no email is set" do subject(:public_body) do - FactoryBot.build(:public_body, :request_email => "") + FactoryBot.build(:public_body, request_email: "") end it "should return a blank email address" do @@ -321,14 +326,14 @@ end it 'is invalid with an unrequestable email' do - subject = PublicBody.new(:request_email => 'invalid@') + subject = PublicBody.new(request_email: 'invalid@') subject.valid? expect(subject.errors[:request_email]). to eq(["Request email doesn't look like a valid email address"]) end it 'is valid with a requestable email' do - subject = PublicBody.new(:request_email => 'valid@example.com') + subject = PublicBody.new(request_email: 'valid@example.com') subject.valid? expect(subject.errors[:request_email]).to be_empty end @@ -338,7 +343,7 @@ describe '#version' do it 'ignores manually set attributes' do - subject = FactoryBot.build(:public_body, :version => 21) + subject = FactoryBot.build(:public_body, version: 21) subject.save! expect(subject.version).to eq(1) end @@ -348,31 +353,31 @@ describe '#url_name' do it 'is invalid when nil' do - subject = PublicBody.new(:url_name => nil) + subject = PublicBody.new(url_name: nil) subject.valid? expect(subject.errors[:url_name]).to eq(["URL name can't be blank"]) end it 'is invalid when blank' do - subject = PublicBody.new(:url_name => '') + subject = PublicBody.new(url_name: '') subject.valid? expect(subject.errors[:url_name]).to eq(["URL name can't be blank"]) end it 'is invalid when not unique' do - existing = FactoryBot.create(:public_body, :url_name => 'xyz') - subject = described_class.new(:url_name => existing.url_name) + existing = FactoryBot.create(:public_body, url_name: 'xyz') + subject = described_class.new(url_name: existing.url_name) subject.valid? expect(subject.errors[:url_name]).to eq(["URL name is already taken"]) end it 'replaces spaces and makes lower case' do - subject = PublicBody.new(:name => 'Some Authority') + subject = PublicBody.new(name: 'Some Authority') expect(subject.url_name).to eq('some_authority') end it 'does not allow a numeric name' do - subject = PublicBody.new(:name => '1234') + subject = PublicBody.new(name: '1234') expect(subject.url_name).to eq('body') end @@ -395,13 +400,13 @@ context 'short_name has been set' do it 'does not update the url_name when name is changed' do - subject = PublicBody.new(:short_name => 'Test Name') + subject = PublicBody.new(short_name: 'Test Name') subject.name = 'Some Authority' expect(subject.url_name).to eq('test_name') end it 'updates the url_name when short_name is changed' do - subject = PublicBody.new(:short_name => 'Test Name') + subject = PublicBody.new(short_name: 'Test Name') subject.short_name = 'Short Name' expect(subject.url_name).to eq('short_name') end @@ -418,13 +423,13 @@ end it 'gets set on save' do - subject = FactoryBot.build(:public_body, :name => 'Body') + subject = FactoryBot.build(:public_body, name: 'Body') subject.save! expect(subject.first_letter).to eq('B') end it 'gets updated on save' do - subject = FactoryBot.create(:public_body, :name => 'Body') + subject = FactoryBot.create(:public_body, name: 'Body') subject.name = 'Authority' expect(subject.first_letter).to eq('B') subject.save! @@ -432,13 +437,13 @@ end it 'sets the first letter to a multibyte character' do - subject = FactoryBot.build(:public_body, :name => 'åccents') + subject = FactoryBot.build(:public_body, name: 'åccents') subject.save! expect(subject.first_letter).to eq('Å') end it 'should save the first letter of a translation' do - subject = FactoryBot.build(:public_body, :name => 'Body') + subject = FactoryBot.build(:public_body, name: 'Body') AlaveteliLocalization.with_locale(:es) do subject.name = 'Prueba body' subject.save! @@ -448,7 +453,7 @@ it 'saves the first letter of a translation, even when it is the same as the first letter in the default locale' do - subject = FactoryBot.build(:public_body, :name => 'Body') + subject = FactoryBot.build(:public_body, name: 'Body') AlaveteliLocalization.with_locale(:es) do subject.name = 'Body ES' subject.save! @@ -483,28 +488,28 @@ describe '#last_edit_editor' do it 'is invalid when nil' do - subject = PublicBody.new(:last_edit_editor => nil) + subject = PublicBody.new(last_edit_editor: nil) subject.valid? expect(subject.errors[:last_edit_editor]). to eq(["Last edit editor can't be blank"]) end it 'is invalid when blank' do - subject = PublicBody.new(:last_edit_editor => '') + subject = PublicBody.new(last_edit_editor: '') subject.valid? expect(subject.errors[:last_edit_editor]). to eq(["Last edit editor can't be blank"]) end it 'is invalid when over 255 characters' do - subject = PublicBody.new(:last_edit_editor => 'x' * 256) + subject = PublicBody.new(last_edit_editor: 'x' * 256) subject.valid? expect(subject.errors[:last_edit_editor]). to eq(["Last edit editor can't be longer than 255 characters"]) end it 'is valid up to 255 characters' do - subject = PublicBody.new(:last_edit_editor => 'x' * 255) + subject = PublicBody.new(last_edit_editor: 'x' * 255) subject.valid? expect(subject.errors[:last_edit_editor]).to be_empty end @@ -514,13 +519,13 @@ describe '#last_edit_comment' do it 'is valid when nil' do - subject = PublicBody.new(:last_edit_comment => nil) + subject = PublicBody.new(last_edit_comment: nil) subject.valid? expect(subject.errors[:last_edit_comment]).to be_empty end it 'strips blank attributes' do - subject = FactoryBot.create(:public_body, :last_edit_comment => '') + subject = FactoryBot.create(:public_body, last_edit_comment: '') expect(subject.last_edit_comment).to be_nil end @@ -529,13 +534,13 @@ describe '#home_page' do it 'is valid when nil' do - subject = PublicBody.new(:home_page => nil) + subject = PublicBody.new(home_page: nil) subject.valid? expect(subject.errors[:home_page]).to be_empty end it 'strips blank attributes' do - subject = FactoryBot.create(:public_body, :home_page => '') + subject = FactoryBot.create(:public_body, home_page: '') expect(subject.home_page).to be_nil end @@ -545,7 +550,7 @@ subject(:notes) { public_body.notes } let(:public_body) do - FactoryBot.build(:public_body, notes: 'foo', tag_string: 'important') + FactoryBot.build(:public_body, tag_string: 'important') end let!(:concrete_note) do @@ -558,13 +563,12 @@ it 'returns an array' do is_expected.to be_an Array - expect(notes.count).to eq 3 + expect(notes.count).to eq 2 end it 'combined notable notes with legacy note' do - expect(notes[0].body).to eq 'foo' - expect(notes[1]).to eq concrete_note - expect(notes[2]).to eq tagged_note + expect(notes[0]).to eq concrete_note + expect(notes[1]).to eq tagged_note end end @@ -572,7 +576,7 @@ subject(:notes) { public_body.notes_as_string } let(:public_body) do - FactoryBot.build(:public_body, notes: 'foo', tag_string: 'important') + FactoryBot.build(:public_body, tag_string: 'important') end let!(:concrete_note) do @@ -585,56 +589,28 @@ end it 'concaterates note bodies' do - is_expected.to eq('foo bar baz') - end - end - - describe '#legacy_note' do - subject(:legacy_note) { public_body.legacy_note } - - context 'without legacy translated attributes' do - let(:public_body) { FactoryBot.build(:public_body) } - it { is_expected.to be_nil } - end - - context 'with legacy translated attributes' do - let(:public_body) do - FactoryBot.build( - :public_body, - notes: 'foo', - translations_attributes: { es: { locale: 'es', notes: 'bar' } } - ) - end - - it 'builds new note instance' do - is_expected.to be_a Note - expect(legacy_note.body).to eq 'foo' - AlaveteliLocalization.with_locale('es') do - expect(legacy_note.body).to eq 'bar' - end - end - - it 'assigns body as notable' do - expect(legacy_note.notable).to eq public_body - end + is_expected.to eq('bar baz') end end describe '#has_notes?' do + subject { public_body.has_notes? } + let(:public_body) { PublicBody.new } + it 'returns false if notes is nil' do - subject = PublicBody.new(:notes => nil) - expect(subject.has_notes?).to eq(false) + allow(public_body).to receive(:notes).and_return(nil) + is_expected.to eq(false) end - it 'returns false if notes is blank' do - subject = PublicBody.new(:notes => '') - expect(subject.has_notes?).to eq(false) + it 'returns false if notes is empty' do + allow(public_body).to receive(:notes).and_return([]) + is_expected.to eq(false) end it 'returns true if notes are present' do - subject = PublicBody.new(:notes => 'x') - expect(subject.has_notes?).to eq(true) + allow(public_body).to receive(:notes).and_return([double(:note)]) + is_expected.to eq(true) end end @@ -642,13 +618,13 @@ describe '#publication_scheme' do it 'is valid when nil' do - subject = PublicBody.new(:publication_scheme => nil) + subject = PublicBody.new(publication_scheme: nil) subject.valid? expect(subject.errors[:publication_scheme]).to be_empty end it 'strips blank attributes' do - subject = FactoryBot.create(:public_body, :publication_scheme => '') + subject = FactoryBot.create(:public_body, publication_scheme: '') expect(subject.publication_scheme).to be_nil end @@ -657,13 +633,13 @@ describe '#disclosure_log' do it 'is valid when nil' do - subject = PublicBody.new(:disclosure_log => nil) + subject = PublicBody.new(disclosure_log: nil) subject.valid? expect(subject.errors[:disclosure_log]).to be_empty end it 'strips blank attributes' do - subject = FactoryBot.create(:public_body, :disclosure_log => '') + subject = FactoryBot.create(:public_body, disclosure_log: '') expect(subject.disclosure_log).to be_nil end @@ -675,16 +651,16 @@ it 'does not persist translations' do body = FactoryBot.create(:public_body) - body.translations_attributes = { :es => { :locale => 'es', - :name => 'El Body' } } + body.translations_attributes = { es: { locale: 'es', + name: 'El Body' } } expect(PublicBody.find(body.id).translations.size).to eq(1) end it 'creates a new translation' do body = FactoryBot.create(:public_body) - body.translations_attributes = { :es => { :locale => 'es', - :name => 'El Body' } } + body.translations_attributes = { es: { locale: 'es', + name: 'El Body' } } body.save! body.reload expect(body.name(:es)).to eq('El Body') @@ -692,30 +668,30 @@ it 'updates an existing translation' do body = FactoryBot.create(:public_body) - body.translations_attributes = { 'es' => { :locale => 'es', - :name => 'El Body' } } + body.translations_attributes = { 'es' => { locale: 'es', + name: 'El Body' } } body.save! - body.translations_attributes = { 'es' => { :id => body.translation_for(:es).id, - :locale => 'es', - :name => 'Renamed' } } + body.translations_attributes = { 'es' => { id: body.translation_for(:es).id, + locale: 'es', + name: 'Renamed' } } body.save! expect(body.name(:es)).to eq('Renamed') end it 'updates an existing translation and creates a new translation' do body = FactoryBot.create(:public_body) - body.translations.create(:locale => 'es', - :name => 'El Body') + body.translations.create(locale: 'es', + name: 'El Body') expect(body.translations.size).to eq(2) body.translations_attributes = { - 'es' => { :id => body.translation_for(:es).id, - :locale => 'es', - :name => 'Renamed' }, - 'fr' => { :locale => 'fr', - :name => 'Le Body' } + 'es' => { id: body.translation_for(:es).id, + locale: 'es', + name: 'Renamed' }, + 'fr' => { locale: 'fr', + name: 'Le Body' } } expect(body.translations.size).to eq(3) @@ -729,16 +705,16 @@ it 'skips empty translations' do body = FactoryBot.create(:public_body) - body.translations.create(:locale => 'es', - :name => 'El Body') + body.translations.create(locale: 'es', + name: 'El Body') expect(body.translations.size).to eq(2) body.translations_attributes = { - 'es' => { :id => body.translation_for(:es).id, - :locale => 'es', - :name => 'Renamed' }, - 'fr' => { :locale => 'fr' } + 'es' => { id: body.translation_for(:es).id, + locale: 'es', + name: 'Renamed' }, + 'fr' => { locale: 'fr' } } expect(body.translations.size).to eq(2) @@ -757,7 +733,7 @@ it 'does not overwrite an existing API key' do allow(SecureRandom).to receive(:base64).and_return('APIKEY') - body = PublicBody.new(:api_key => 'EXISTING') + body = PublicBody.new(api_key: 'EXISTING') body.set_api_key expect(body.api_key).to eq('EXISTING') end @@ -775,7 +751,7 @@ it 'overwrites an existing API key' do allow(SecureRandom).to receive(:base64).and_return('APIKEY') - body = PublicBody.new(:api_key => 'EXISTING') + body = PublicBody.new(api_key: 'EXISTING') body.set_api_key! expect(body.api_key).to eq('APIKEY') end @@ -783,17 +759,10 @@ end describe '#expire_requests' do - it 'calls expire on all associated requests' do + it 'create expire job for the public body' do public_body = FactoryBot.build(:public_body) - - request_1, request_2 = double(:info_request), double(:info_request) - - allow(public_body).to receive_message_chain(:info_requests, :find_each). - and_yield(request_1).and_yield(request_2) - - expect(request_1).to receive(:expire) - expect(request_2).to receive(:expire) - + expect(InfoRequestExpireJob).to receive(:perform_later). + with(public_body, :info_requests) public_body.expire_requests end end @@ -801,12 +770,12 @@ describe '#short_or_long_name' do it 'returns the short_name if it has been set' do - public_body = PublicBody.new(:name => 'Test Name', :short_name => "Test") + public_body = PublicBody.new(name: 'Test Name', short_name: "Test") expect(public_body.short_or_long_name).to eq('Test') end it 'returns the name if short_name has not been set' do - public_body = PublicBody.new(:name => 'Test Name') + public_body = PublicBody.new(name: 'Test Name') expect(public_body.short_or_long_name).to eq('Test Name') end @@ -815,7 +784,7 @@ describe '#set_first_letter' do it 'sets first_letter to the first letter of the name if the name is set' do - public_body = PublicBody.new(:name => 'Test Name') + public_body = PublicBody.new(name: 'Test Name') public_body.set_first_letter expect(public_body.first_letter).to eq('T') end @@ -827,13 +796,13 @@ end it 'handles mutlibyte characters correctly' do - public_body = PublicBody.new(:name => 'Åccented') + public_body = PublicBody.new(name: 'Åccented') public_body.set_first_letter expect(public_body.first_letter).to eq('Å') end it 'upcases the first character' do - public_body = PublicBody.new(:name => 'åccented') + public_body = PublicBody.new(name: 'åccented') public_body.set_first_letter expect(public_body.first_letter).to eq('Å') end @@ -983,38 +952,38 @@ let(:public_body) do FactoryBot.create(:public_body, - :name => 'Marmot Appreciation Society', - :short_name => 'MAS', - :request_email => 'marmots@flourish.org', - :last_edit_editor => 'test', - :last_edit_comment => '', - :info_requests_count => 10, - :info_requests_successful_count => 2, - :info_requests_not_held_count => 2, - :info_requests_overdue_count => 3, - :info_requests_visible_classified_count => 3) + name: 'Marmot Appreciation Society', + short_name: 'MAS', + request_email: 'marmots@flourish.org', + last_edit_editor: 'test', + last_edit_comment: '', + info_requests_count: 10, + info_requests_successful_count: 2, + info_requests_not_held_count: 2, + info_requests_overdue_count: 3, + info_requests_visible_classified_count: 3) end it 'should return info about request counts' do expect(public_body.json_for_api). to eq( { - :name => 'Marmot Appreciation Society', - :notes => "", - :publication_scheme => "", - :short_name => "MAS", - :tags => [], - :updated_at => public_body.updated_at, - :url_name => "mas", - :created_at => public_body.created_at, - :home_page => "http://www.flourish.org", - :id => public_body.id, - :info => { - :requests_count => 10, - :requests_successful_count => 2, - :requests_not_held_count => 2, - :requests_overdue_count => 3, - :requests_visible_classified_count => 3, + name: 'Marmot Appreciation Society', + notes: "", + publication_scheme: "", + short_name: "MAS", + tags: [], + updated_at: public_body.updated_at, + url_name: "mas", + created_at: public_body.created_at, + home_page: "http://www.flourish.org", + id: public_body.id, + info: { + requests_count: 10, + requests_successful_count: 2, + requests_not_held_count: 2, + requests_overdue_count: 3, + requests_visible_classified_count: 3 } }) end @@ -1025,11 +994,11 @@ RSpec.describe PublicBody, " using tags" do before do - @public_body = PublicBody.new(:name => 'Aardvark Monitoring Service', - :short_name => 'AMS', - :request_email => 'foo@flourish.org', - :last_edit_editor => 'test', - :last_edit_comment => '') + @public_body = PublicBody.new(name: 'Aardvark Monitoring Service', + short_name: 'AMS', + request_email: 'foo@flourish.org', + last_edit_editor: 'test', + last_edit_comment: '') end it 'should correctly convert a tag string into tags' do @@ -1081,11 +1050,11 @@ RSpec.describe PublicBody, " using machine tags" do before do - @public_body = PublicBody.new(:name => 'Aardvark Monitoring Service', - :short_name => 'AMS', - :request_email => 'foo@flourish.org', - :last_edit_editor => 'test', - :last_edit_comment => '') + @public_body = PublicBody.new(name: 'Aardvark Monitoring Service', + short_name: 'AMS', + request_email: 'foo@flourish.org', + last_edit_editor: 'test', + last_edit_comment: '') end it 'should parse machine tags' do @@ -1097,7 +1066,7 @@ expect(@public_body.get_tag_values('cheese')).to eq(['green']) expect(@public_body.get_tag_values('wondrous')).to eq([]) - lambda { + -> { expect(@public_body.get_tag_values('notthere')).to raise_error(PublicBody::TagNotFound) } end @@ -1138,6 +1107,8 @@ end RSpec.describe PublicBody, " when saving" do + include ActiveJob::TestHelper + before do @public_body = PublicBody.new end @@ -1167,9 +1138,9 @@ def set_default_attributes(public_body) end it 'should create a url_name for a translation' do - existing = FactoryBot.create(:public_body, :first_letter => 'T', :short_name => 'Test body') + existing = FactoryBot.create(:public_body, first_letter: 'T', short_name: 'Test body') AlaveteliLocalization.with_locale(:es) do - existing.update :short_name => 'Prueba', :name => 'Prueba body' + existing.update short_name: 'Prueba', name: 'Prueba body' expect(existing.url_name).to eq('prueba') end end @@ -1220,6 +1191,7 @@ def set_default_attributes(public_body) ActsAsXapian::ActsAsXapianJob.destroy_all body.update!(url_name: 'baz-bar-foo') + perform_enqueued_jobs expected_events = ActsAsXapian::ActsAsXapianJob. @@ -1234,7 +1206,7 @@ def set_default_attributes(public_body) ActsAsXapian::ActsAsXapianJob.destroy_all - body.update!(notes: 'test') + body.update!(request_email: 'other@localhost') expected_events = ActsAsXapian::ActsAsXapianJob. @@ -1306,22 +1278,22 @@ def set_default_attributes(public_body) it 'should destroy the public_body' do public_body.destroy - expect(PublicBody.where(:id => public_body.id)).to be_empty + expect(PublicBody.where(id: public_body.id)).to be_empty end it 'should destroy the associated track_things' do FactoryBot.create(:public_body_track, - :public_body => public_body, - :track_medium => 'email_daily', - :track_query => 'test') + public_body: public_body, + track_medium: 'email_daily', + track_query: 'test') public_body.destroy - expect(TrackThing.where(:public_body_id => public_body.id)).to be_empty + expect(TrackThing.where(public_body_id: public_body.id)).to be_empty end it 'should destroy the associated censor_rules' do - FactoryBot.create(:censor_rule, :public_body => public_body) + FactoryBot.create(:censor_rule, public_body: public_body) public_body.destroy - expect(CensorRule.where(:public_body_id => public_body.id)).to be_empty + expect(CensorRule.where(public_body_id: public_body.id)).to be_empty end it 'destroys associated translations' do @@ -1329,15 +1301,15 @@ def set_default_attributes(public_body) public_body.name = 'El Translation' public_body.save! end - expect(PublicBody::Translation.where(:public_body_id => public_body.id)). + expect(PublicBody::Translation.where(public_body_id: public_body.id)). to_not be_empty public_body.destroy - expect(PublicBody::Translation.where(:public_body_id => public_body.id)). + expect(PublicBody::Translation.where(public_body_id: public_body.id)). to be_empty end it 'should raise an error if there are associated info_requests' do - FactoryBot.create(:info_request, :public_body => public_body) + FactoryBot.create(:info_request, public_body: public_body) public_body.reload expect { public_body.destroy }.to raise_error(ActiveRecord::InvalidForeignKey) end @@ -1425,7 +1397,7 @@ def set_default_attributes(public_body) expect(notes[0..2]).to eq([ "line 2: creating new authority 'North West Fake Authority' (locale: en):\n\t\{\"name\":\"North West Fake Authority\",\"request_email\":\"north_west_foi@localhost\",\"home_page\":\"http://northwest.org\"\}", "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t\{\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\",\"tag_string\":\"scottish\"\}", - "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t\{\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\",\"tag_string\":\"fake aTag\"\}", + "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t\{\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\",\"tag_string\":\"fake aTag\"\}" ]) expect(notes[3]).to match(/Notes: Some bodies are in database, but not in CSV file:\n( .+\n)*You may want to delete them manually.\n/) @@ -1438,7 +1410,7 @@ def set_default_attributes(public_body) expect(PublicBody.find_by_name('North West Fake Authority').tag_array_for_search).to eq([]) expect(PublicBody.find_by_name('Scottish Fake Authority').tag_array_for_search).to eq(['scottish']) - expect(PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search).to eq(['aTag', 'fake']) + expect(PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search).to eq(%w[aTag fake]) # Import again to check the 'add' tag functionality works new_tags_file = load_file_fixture('fake-authority-add-tags.csv') @@ -1446,8 +1418,8 @@ def set_default_attributes(public_body) # Check tags were added successfully expect(PublicBody.find_by_name('North West Fake Authority').tag_array_for_search).to eq(['aTag']) - expect(PublicBody.find_by_name('Scottish Fake Authority').tag_array_for_search).to eq(['aTag', 'scottish']) - expect(PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search).to eq(['aTag', 'fake']) + expect(PublicBody.find_by_name('Scottish Fake Authority').tag_array_for_search).to eq(%w[aTag scottish]) + expect(PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search).to eq(%w[aTag fake]) end it "should import tags successfully when the import tag is set" do @@ -1456,17 +1428,17 @@ def set_default_attributes(public_body) # Check new bodies were imported successfully expect(PublicBody.find_by_name('North West Fake Authority').tag_array_for_search).to eq(['fake']) - expect(PublicBody.find_by_name('Scottish Fake Authority').tag_array_for_search).to eq(['fake', 'scottish']) - expect(PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search).to eq(['aTag', 'fake']) + expect(PublicBody.find_by_name('Scottish Fake Authority').tag_array_for_search).to eq(%w[fake scottish]) + expect(PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search).to eq(%w[aTag fake]) # Import again to check the 'replace' tag functionality works new_tags_file = load_file_fixture('fake-authority-add-tags.csv') errors, notes = PublicBody.import_csv(new_tags_file, 'fake', 'replace', false, 'someadmin') # false means real run # Check tags were added successfully - expect(PublicBody.find_by_name('North West Fake Authority').tag_array_for_search).to eq(['aTag', 'fake']) - expect(PublicBody.find_by_name('Scottish Fake Authority').tag_array_for_search).to eq(['aTag', 'fake']) - expect(PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search).to eq(['aTag', 'fake']) + expect(PublicBody.find_by_name('North West Fake Authority').tag_array_for_search).to eq(%w[aTag fake]) + expect(PublicBody.find_by_name('Scottish Fake Authority').tag_array_for_search).to eq(%w[aTag fake]) + expect(PublicBody.find_by_name('Fake Authority of Northern Ireland').tag_array_for_search).to eq(%w[aTag fake]) end @@ -1483,7 +1455,7 @@ def set_default_attributes(public_body) # csv, tag, tag_behaviour, dry_run, editor PublicBody.import_csv(csv, 'imported', 'add', false, 'someadmin') - expected = %W(imported) + expected = %w(imported) expect(PublicBody.find_by_name('Quango').tag_array_for_search).to eq(expected) end @@ -1496,7 +1468,7 @@ def set_default_attributes(public_body) # csv, tag, tag_behaviour, dry_run, editor PublicBody.import_csv(csv, 'imported', 'add', false, 'someadmin') - expected = %W(first_tag imported second_tag) + expected = %w(first_tag imported second_tag) expect(PublicBody.find_by_name('Quango').tag_array_for_search).to eq(expected) end @@ -1509,7 +1481,7 @@ def set_default_attributes(public_body) # csv, tag, tag_behaviour, dry_run, editor PublicBody.import_csv(csv, 'imported', 'replace', false, 'someadmin') - expected = %W(imported) + expected = %w(imported) expect(PublicBody.find_by_name('Quango').tag_array_for_search).to eq(expected) end @@ -1522,7 +1494,7 @@ def set_default_attributes(public_body) # csv, tag, tag_behaviour, dry_run, editor PublicBody.import_csv(csv, 'imported', 'replace', false, 'someadmin') - expected = %W(first_tag imported second_tag) + expected = %w(first_tag imported second_tag) expect(PublicBody.find_by_name('Quango').tag_array_for_search).to eq(expected) end @@ -1531,7 +1503,7 @@ def set_default_attributes(public_body) context 'an existing body without tags' do before do - @body = FactoryBot.create(:public_body, :name => 'Existing Body') + @body = FactoryBot.create(:public_body, name: 'Existing Body') end it 'will not import if there is an existing body without the tag' do @@ -1543,7 +1515,7 @@ def set_default_attributes(public_body) # csv, tag, tag_behaviour, dry_run, editor errors, notes = PublicBody.import_csv(csv, 'imported', 'add', false, 'someadmin') - expected = %W(imported) + expected = %w(imported) expect(errors).to include("error: line 2: Name Name is already taken for authority 'Existing Body'") end @@ -1552,7 +1524,7 @@ def set_default_attributes(public_body) context 'an existing body with tags' do before do - @body = FactoryBot.create(:public_body, :tag_string => 'imported first_tag second_tag') + @body = FactoryBot.create(:public_body, tag_string: 'imported first_tag second_tag') end it 'created with tags, different tags in csv, add import tag' do @@ -1563,7 +1535,7 @@ def set_default_attributes(public_body) # csv, tag, tag_behaviour, dry_run, editor PublicBody.import_csv(csv, 'imported', 'add', false, 'someadmin') - expected = %W(first_tag imported new_tag second_tag) + expected = %w(first_tag imported new_tag second_tag) expect(PublicBody.find(@body.id).tag_array_for_search).to eq(expected) end @@ -1576,7 +1548,7 @@ def set_default_attributes(public_body) # csv, tag, tag_behaviour, dry_run, editor PublicBody.import_csv(csv, 'imported', 'replace', false, 'someadmin') - expected = %W(first_tag imported new_tag) + expected = %w(first_tag imported new_tag) expect(PublicBody.find(@body.id).tag_array_for_search).to eq(expected) end @@ -1610,7 +1582,7 @@ def set_default_attributes(public_body) # csv, tag, tag_behaviour, dry_run, editor PublicBody.import_csv(csv, '', 'add', false, 'someadmin') - expected = %W(first_tag) + expected = %w(first_tag) expect(PublicBody.find_by_name('Quango').tag_array_for_search).to eq(expected) end @@ -1636,7 +1608,7 @@ def set_default_attributes(public_body) # csv, tag, tag_behaviour, dry_run, editor PublicBody.import_csv(csv, '', 'replace', false, 'someadmin') - expected = %W(first_tag) + expected = %w(first_tag) expect(PublicBody.find_by_name('Quango').tag_array_for_search).to eq(expected) end @@ -1670,7 +1642,7 @@ def set_default_attributes(public_body) # csv, tag, tag_behaviour, dry_run, editor PublicBody.import_csv(csv, '', 'add', false, 'someadmin') - expected = %W(new_tag) + expected = %w(new_tag) expect(PublicBody.find(@body.id).tag_array_for_search).to eq(expected) end @@ -1696,7 +1668,7 @@ def set_default_attributes(public_body) # csv, tag, tag_behaviour, dry_run, editor PublicBody.import_csv(csv, '', 'replace', false, 'someadmin') - expected = %W(new_tag) + expected = %w(new_tag) expect(PublicBody.find(@body.id).tag_array_for_search).to eq(expected) end @@ -1705,7 +1677,7 @@ def set_default_attributes(public_body) describe 'with an existing body with tags' do before do - @body = FactoryBot.create(:public_body, :tag_string => 'first_tag second_tag') + @body = FactoryBot.create(:public_body, tag_string: 'first_tag second_tag') end it 'created with tags, different tags in csv, add tags' do @@ -1717,7 +1689,7 @@ def set_default_attributes(public_body) # csv, tag, tag_behaviour, dry_run, editor PublicBody.import_csv(csv, '', 'add', false, 'someadmin') - expected = %W(first_tag new_tag second_tag) + expected = %w(first_tag new_tag second_tag) expect(PublicBody.find(@body.id).tag_array_for_search).to eq(expected) end @@ -1730,7 +1702,7 @@ def set_default_attributes(public_body) # csv, tag, tag_behaviour, dry_run, editor PublicBody.import_csv(csv, '', 'replace', false, 'someadmin') - expected = %W(first_tag new_tag) + expected = %w(first_tag new_tag) expect(PublicBody.find(@body.id).tag_array_for_search).to eq(expected) end @@ -1751,7 +1723,7 @@ def set_default_attributes(public_body) "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t{\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\",\"tag_string\":\"scottish\"}", "line 3: creating new authority 'Scottish Fake Authority' (locale: es):\n\t{\"name\":\"Autoridad Escocesa\"}", "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t{\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\",\"tag_string\":\"fake aTag\"}", - "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: es):\n\t{\"name\":\"Autoridad Irlandesa\"}", + "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: es):\n\t{\"name\":\"Autoridad Irlandesa\"}" ]) expect(notes[6]).to match(/Notes: Some bodies are in database, but not in CSV file:\n( .+\n)*You may want to delete them manually.\n/) @@ -1761,7 +1733,7 @@ def set_default_attributes(public_body) # the way categories are loaded every time from the PublicBody class. For now we just # test some translation was done. body = PublicBody.find_by_name('North West Fake Authority') - expect(body.translated_locales.map { |l|l.to_s }.sort).to eq(["en", "es"]) + expect(body.translated_locales.map(&:to_s).sort).to eq(%w[en es]) end it "should not fail if a locale is not found in the input file" do @@ -1777,7 +1749,7 @@ def set_default_attributes(public_body) expect(notes[0..2]).to eq([ "line 2: creating new authority 'North West Fake Authority' (locale: en):\n\t{\"name\":\"North West Fake Authority\",\"request_email\":\"north_west_foi@localhost\",\"home_page\":\"http://northwest.org\"}", "line 3: creating new authority 'Scottish Fake Authority' (locale: en):\n\t{\"name\":\"Scottish Fake Authority\",\"request_email\":\"scottish_foi@localhost\",\"home_page\":\"http://scottish.org\",\"tag_string\":\"scottish\"}", - "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t{\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\",\"tag_string\":\"fake aTag\"}", + "line 4: creating new authority 'Fake Authority of Northern Ireland' (locale: en):\n\t{\"name\":\"Fake Authority of Northern Ireland\",\"request_email\":\"ni_foi@localhost\",\"tag_string\":\"fake aTag\"}" ]) expect(notes[3]).to match(/Notes: Some bodies are in database, but not in CSV file:\n( .+\n)*You may want to delete them manually.\n/) @@ -1847,7 +1819,7 @@ def set_default_attributes(public_body) ['publication_scheme', '(i18n)'], ['disclosure_log', '(i18n)'], ['home_page', ''], - ['tag_string', '(tags separated by spaces)'], + ['tag_string', '(tags separated by spaces)'] ] expect(PublicBody.csv_import_fields).to eq(expected_fields) @@ -1857,7 +1829,7 @@ def set_default_attributes(public_body) old_csv_import_fields = PublicBody.csv_import_fields.clone expected_fields = [ ['name', '(i18n)Existing records cannot be renamed'], - ['short_name', '(i18n)'], + ['short_name', '(i18n)'] ] PublicBody.csv_import_fields = expected_fields @@ -1878,7 +1850,7 @@ def set_default_attributes(public_body) ['disclosure_log', '(i18n)'], ['home_page', ''], ['tag_string', '(tags separated by spaces)'], - ['a_new_field', ''], + ['a_new_field', ''] ] PublicBody.csv_import_fields << ['a_new_field', ''] @@ -1894,12 +1866,12 @@ def set_default_attributes(public_body) csv_contents = load_file_fixture("multiple-locales-same-name.csv") - errors, notes = PublicBody.import_csv(csv_contents, '', 'replace', true, 'someadmin', ['en', 'es']) # true means dry run + errors, notes = PublicBody.import_csv(csv_contents, '', 'replace', true, 'someadmin', %w[en es]) # true means dry run expect(errors).to eq([]) expect(notes.size).to eq(3) expect(notes[0..1]).to eq([ "line 2: creating new authority 'Test' (locale: en):\n\t{\"name\":\"Test\",\"request_email\":\"test@test.es\",\"home_page\":\"http://www.test.es/\",\"tag_string\":\"37\"}", - "line 2: creating new authority 'Test' (locale: es):\n\t{\"name\":\"Test\"}", + "line 2: creating new authority 'Test' (locale: es):\n\t{\"name\":\"Test\"}" ]) expect(notes[2]).to match(/Notes: Some bodies are in database, but not in CSV file:\n( .+\n)*You may want to delete them manually.\n/) @@ -1969,7 +1941,7 @@ def set_default_attributes(public_body) describe '#site_administration?' do it 'is true when the body has the site_administration tag' do - p = FactoryBot.build(:public_body, :tag_string => 'site_administration') + p = FactoryBot.build(:public_body, tag_string: 'site_administration') expect(p.site_administration?).to be true end @@ -1983,7 +1955,7 @@ def set_default_attributes(public_body) describe '#has_request_email?' do before do - @body = PublicBody.new(:request_email => 'test@example.com') + @body = PublicBody.new(request_email: 'test@example.com') end it 'should return false if request_email is nil' do @@ -2164,7 +2136,7 @@ def set_default_attributes(public_body) describe '#is_requestable?' do before do - @body = PublicBody.new(:request_email => 'test@example.com') + @body = PublicBody.new(request_email: 'test@example.com') end it 'should return false if the body is defunct' do @@ -2222,7 +2194,7 @@ def set_default_attributes(public_body) describe '#is_followupable?' do before do - @body = PublicBody.new(:request_email => 'test@example.com') + @body = PublicBody.new(request_email: 'test@example.com') end it 'should return false there is no request_email' do @@ -2239,7 +2211,7 @@ def set_default_attributes(public_body) describe '#not_requestable_reason' do before do - @body = PublicBody.new(:request_email => 'test@example.com') + @body = PublicBody.new(request_email: 'test@example.com') end it 'should return "defunct" if the body is defunct' do @@ -2367,7 +2339,7 @@ def set_default_attributes(public_body) it 'is valid if all required attributes are assigned' do translation = PublicBody::Translation.new( - :locale => AlaveteliLocalization.default_locale + locale: AlaveteliLocalization.default_locale ) expect(translation).to be_valid end @@ -2408,9 +2380,9 @@ def set_default_attributes(public_body) public_body.request_email = 'new@example.com' public_body.save! current = public_body.versions.latest - expected = { :name => "Request email", - :from => "request@example.com", - :to => "new@example.com" } + expected = { name: "Request email", + from: "request@example.com", + to: "new@example.com" } expect(current.compare(current.previous)).to eq([ expected ]) end @@ -2449,9 +2421,9 @@ def set_default_attributes(public_body) public_body.request_email = 'new@example.com' public_body.save! current = public_body.versions.latest - expected = { :name => "Request email", - :from => "request@example.com", - :to => "new@example.com" } + expected = { name: "Request email", + from: "request@example.com", + to: "new@example.com" } expect { |b| current.compare(current.previous, &b) }. to yield_with_args(expected) end diff --git a/spec/models/raw_email_spec.rb b/spec/models/raw_email_spec.rb index 1bfad2c6ac..bcd0829eb8 100644 --- a/spec/models/raw_email_spec.rb +++ b/spec/models/raw_email_spec.rb @@ -19,22 +19,11 @@ def roundtrip_data(raw_email, data) raw_email.data end - describe 'before destroy callbacks' do - let(:raw_email) { FactoryBot.create(:incoming_message).raw_email } - - it 'should only delete the directory if it exists' do - expect(File).to receive(:delete).once.and_call_original - raw_email.run_callbacks(:destroy) - expect { raw_email.run_callbacks(:destroy) }. - not_to raise_error - end - end - describe '#valid_to_reply_to?' do def test_email(result, email, empty_return_path, autosubmitted = nil) - stubs = { :from_email => email, - :empty_return_path? => empty_return_path, - :auto_submitted? => autosubmitted } + stubs = { from_email: email, + empty_return_path?: empty_return_path, + auto_submitted?: autosubmitted } raw_email = RawEmail.new stubs.each do |method, value| allow(raw_email).to receive(method).and_return(value) diff --git a/spec/models/request_classification_spec.rb b/spec/models/request_classification_spec.rb index eae832a122..e754bba676 100644 --- a/spec/models/request_classification_spec.rb +++ b/spec/models/request_classification_spec.rb @@ -19,9 +19,9 @@ before do @user_one = FactoryBot.create(:user) @user_two = FactoryBot.create(:user) - FactoryBot.create(:request_classification, :user => @user_one) - FactoryBot.create(:request_classification, :user => @user_one) - FactoryBot.create(:request_classification, :user => @user_two) + FactoryBot.create(:request_classification, user: @user_one) + FactoryBot.create(:request_classification, user: @user_one) + FactoryBot.create(:request_classification, user: @user_two) end it "returns a list of users' classifications with counts in descending order" do diff --git a/spec/models/role_spec.rb b/spec/models/role_spec.rb index 54e0a07c98..6ca880e350 100644 --- a/spec/models/role_spec.rb +++ b/spec/models/role_spec.rb @@ -16,14 +16,14 @@ RSpec.describe Role do it 'validates the role name is in the allowed roles' do - role = Role.new(:name => 'test') + role = Role.new(name: 'test') role.valid? expect(role.errors[:name]).to eq(["is not included in the list"]) end it 'validates the role is unique within the context of a resource_type' do with_feature_enabled(:alaveteli_pro) do - role = Role.new(:name => 'pro') + role = Role.new(name: 'pro') role.valid? expect(role.errors[:name]).to eq(["has already been taken"]) end diff --git a/spec/models/spam_address_spec.rb b/spec/models/spam_address_spec.rb index 31fce00479..fdc744b668 100644 --- a/spec/models/spam_address_spec.rb +++ b/spec/models/spam_address_spec.rb @@ -18,12 +18,12 @@ it 'requres an email address' do expect(SpamAddress.new).not_to be_valid - expect(SpamAddress.new(:email => 'spam@example.org')).to be_valid + expect(SpamAddress.new(email: 'spam@example.org')).to be_valid end it 'must have a unique email address' do existing = FactoryBot.create(:spam_address) - expect(SpamAddress.new(:email => existing.email)).not_to be_valid + expect(SpamAddress.new(email: existing.email)).not_to be_valid end end diff --git a/spec/models/statistics_spec.rb b/spec/models/statistics_spec.rb index 92ae3e6dff..830d40ecd4 100644 --- a/spec/models/statistics_spec.rb +++ b/spec/models/statistics_spec.rb @@ -25,19 +25,19 @@ percentages=false, {} ) expect(to_draw['public_bodies'][0].class).to eq(Hash) - expect(to_draw['public_bodies'][0].has_key?('request_email')).to be false + expect(to_draw['public_bodies'][0].key?('request_email')).to be false end it "should generate the expected id" do to_draw = Statistics.simplify_stats_for_graphs(raw_count_data, column='blah_blah', percentages=false, - {:highest => true} ) + {highest: true} ) expect(to_draw['id']).to eq("blah_blah-highest") to_draw = Statistics.simplify_stats_for_graphs(raw_count_data, column='blah_blah', percentages=false, - {:highest => false} ) + {highest: false} ) expect(to_draw['id']).to eq("blah_blah-lowest") end @@ -46,20 +46,20 @@ column='blah_blah', percentages=false, {} ) - expect(to_draw.keys.sort).to eq(["errorbars", "id", "public_bodies", - "title", "tooltips", "totals", - "x_axis", "x_ticks", "x_values", - "y_axis", "y_max", "y_values"]) + expect(to_draw.keys.sort).to eq(%w[errorbars id public_bodies + title tooltips totals + x_axis x_ticks x_values + y_axis y_max y_values]) to_draw = Statistics.simplify_stats_for_graphs(percentages_data, column='whatever', percentages=true, {}) - expect(to_draw.keys.sort).to eq(["cis_above", "cis_below", - "errorbars", "id", "public_bodies", - "title", "tooltips", "totals", - "x_axis", "x_ticks", "x_values", - "y_axis", "y_max", "y_values"]) + expect(to_draw.keys.sort).to eq(%w[cis_above cis_below + errorbars id public_bodies + title tooltips totals + x_axis x_ticks x_values + y_axis y_max y_values]) end it "should have values of the expected class and length" do @@ -71,12 +71,12 @@ column='whatever', percentages=true, {})].each do |to_draw| - per_pb_keys = ["cis_above", "cis_below", "public_bodies", - "tooltips", "totals", "x_ticks", "x_values", - "y_values"] + per_pb_keys = %w[cis_above cis_below public_bodies + tooltips totals x_ticks x_values + y_values] # These should be all be arrays with one element per public body: per_pb_keys.each do |key| - if to_draw.has_key? key + if to_draw.key? key expect(to_draw[key].class).to eq(Array) expect(to_draw[key].length).to eq(3), "for key #{key}" end diff --git a/spec/models/track_thing_spec.rb b/spec/models/track_thing_spec.rb index 5b061c8eed..8a70ca0426 100644 --- a/spec/models/track_thing_spec.rb +++ b/spec/models/track_thing_spec.rb @@ -84,12 +84,12 @@ it "should destroy the track_thing" do track_thing.destroy - expect(TrackThing.where(:id => track_thing.id)).to be_empty + expect(TrackThing.where(id: track_thing.id)).to be_empty end it "should destroy related track_things_sent_emails" do - TrackThingsSentEmail.create(:track_thing => track_thing) + TrackThingsSentEmail.create(track_thing: track_thing) track_thing.destroy - expect(TrackThingsSentEmail.where(:track_thing_id => track_thing.id)).to be_empty + expect(TrackThingsSentEmail.where(track_thing_id: track_thing.id)).to be_empty end end diff --git a/spec/models/user/transaction_calculator_spec.rb b/spec/models/user/transaction_calculator_spec.rb index 31ab53aa70..390a43cf11 100644 --- a/spec/models/user/transaction_calculator_spec.rb +++ b/spec/models/user/transaction_calculator_spec.rb @@ -19,14 +19,14 @@ it 'allows a list of custom transaction associations' do list = [:comments, :info_requests] - calc = described_class.new(user, :transaction_associations => list) + calc = described_class.new(user, transaction_associations: list) expect(calc.transaction_associations).to eq(list) end it 'raises an error if a transaction association is invalid' do list = [:invalid_method, :info_requests] expect { - described_class.new(user, :transaction_associations => list) + described_class.new(user, transaction_associations: list) }.to raise_error(NoMethodError) end @@ -46,8 +46,8 @@ it 'sums the total transactions made by the user' do 3.times do - FactoryBot.create(:comment, :user => user) - FactoryBot.create(:info_request, :user => user) + FactoryBot.create(:comment, user: user) + FactoryBot.create(:info_request, user: user) end expect(subject.total).to eq(6) end @@ -58,16 +58,16 @@ it 'sums the total transactions made by the user during the range' do travel_to(1.year.ago) do - FactoryBot.create(:comment, :user => user) - FactoryBot.create(:info_request, :user => user) + FactoryBot.create(:comment, user: user) + FactoryBot.create(:info_request, user: user) end travel_to(3.days.ago) do - FactoryBot.create(:comment, :user => user) - FactoryBot.create(:info_request, :user => user) + FactoryBot.create(:comment, user: user) + FactoryBot.create(:info_request, user: user) end - FactoryBot.create(:comment, :user => user) + FactoryBot.create(:comment, user: user) expect(subject.total(10.days.ago..1.day.ago)).to eq(2) end @@ -78,15 +78,15 @@ it ':last_7_days sums the total transactions made by the user in the last 7 days' do travel_to(8.days.ago) do - FactoryBot.create(:comment, :user => user) + FactoryBot.create(:comment, user: user) end travel_to(7.days.ago) do - FactoryBot.create(:comment, :user => user) + FactoryBot.create(:comment, user: user) end travel_to(6.days.ago) do - FactoryBot.create(:comment, :user => user) + FactoryBot.create(:comment, user: user) end expect(subject.total(:last_7_days)).to eq(2) @@ -94,15 +94,15 @@ it ':last_30_days sums the total transactions made by the user in the last 30 days' do travel_to(31.days.ago) do - FactoryBot.create(:comment, :user => user) + FactoryBot.create(:comment, user: user) end travel_to(30.days.ago) do - FactoryBot.create(:comment, :user => user) + FactoryBot.create(:comment, user: user) end travel_to(29.days.ago) do - FactoryBot.create(:comment, :user => user) + FactoryBot.create(:comment, user: user) end expect(subject.total(:last_30_days)).to eq(2) @@ -110,19 +110,19 @@ it ':last_quarter sums the total transactions made by the user in the last quarter' do travel_to(Time.zone.parse('2014-12-31')) do - FactoryBot.create(:comment, :user => user) + FactoryBot.create(:comment, user: user) end travel_to(Time.zone.parse('2015-01-01')) do - FactoryBot.create(:comment, :user => user) + FactoryBot.create(:comment, user: user) end travel_to(Time.zone.parse('2015-03-31')) do - FactoryBot.create(:comment, :user => user) + FactoryBot.create(:comment, user: user) end travel_to(Time.zone.parse('2015-04-01')) do - FactoryBot.create(:comment, :user => user) + FactoryBot.create(:comment, user: user) end travel_to(Time.zone.parse('2015-04-01')) do @@ -147,19 +147,19 @@ it 'returns a hash containing the total transactions grouped by month' do travel_to(Time.zone.parse('2016-01-05')) do - FactoryBot.create(:comment, :user => user) + FactoryBot.create(:comment, user: user) end travel_to(Time.zone.parse('2016-01-05')) do - FactoryBot.create(:info_request, :user => user) + FactoryBot.create(:info_request, user: user) end travel_to(Time.zone.parse('2016-01-05') + 1.hour) do - FactoryBot.create(:info_request, :user => user) + FactoryBot.create(:info_request, user: user) end travel_to(Time.zone.parse('2016-03-06')) do - FactoryBot.create(:comment, :user => user) + FactoryBot.create(:comment, user: user) end expect(subject.total_per_month). @@ -176,11 +176,11 @@ travel_back travel_to(Time.zone.parse('2016-02-01')) do - 3.times { FactoryBot.create(:comment, :user => user) } + 3.times { FactoryBot.create(:comment, user: user) } end travel_to(Time.zone.parse('2016-04-01')) do - 3.times { FactoryBot.create(:comment, :user => user) } + 3.times { FactoryBot.create(:comment, user: user) } end subject = described_class.new(user) @@ -201,8 +201,8 @@ it 'returns true if the transactions are in a different order' do list1 = [:comments, :info_requests] list2 = [:info_requests, :comments] - calc1 = described_class.new(user, :transaction_associations => list1) - calc2 = described_class.new(user, :transaction_associations => list2) + calc1 = described_class.new(user, transaction_associations: list1) + calc2 = described_class.new(user, transaction_associations: list2) expect(calc1).to eq(calc2) end @@ -213,8 +213,8 @@ it 'returns false if the transactions are different' do list1 = [:comments, :info_requests] list2 = [:comments] - calc1 = described_class.new(user, :transaction_associations => list1) - calc2 = described_class.new(user, :transaction_associations => list2) + calc1 = described_class.new(user, transaction_associations: list1) + calc2 = described_class.new(user, transaction_associations: list2) expect(calc1).not_to eq(calc2) end diff --git a/spec/models/user_message_spec.rb b/spec/models/user_message_spec.rb new file mode 100644 index 0000000000..658d635b68 --- /dev/null +++ b/spec/models/user_message_spec.rb @@ -0,0 +1,14 @@ +# == Schema Information +# Schema version: 20230222154014 +# +# Table name: user_messages +# +# id :bigint not null, primary key +# user_id :bigint +# created_at :datetime not null +# updated_at :datetime not null +# +require 'spec_helper' + +RSpec.describe UserMessage, type: :model do +end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index c4f771ea9a..4dc429bbf6 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,5 +1,5 @@ # == Schema Information -# Schema version: 20220210114052 +# Schema version: 20230301110831 # # Table name: users # @@ -35,6 +35,8 @@ # daily_summary_minute :integer # closed_at :datetime # login_token :string +# receive_user_messages :boolean default(TRUE), not null +# user_messages_count :integer default(0), not null # require 'spec_helper' @@ -62,19 +64,19 @@ RSpec.describe User, "banning the user" do it 'does not change the URL name' do - user = FactoryBot.create(:user, :name => 'nasty user 123') - user.update(:ban_text => 'You are banned') + user = FactoryBot.create(:user, name: 'nasty user 123') + user.update(ban_text: 'You are banned') expect(user.url_name).to eq('nasty_user_123') end it 'does not change the stored name' do - user = FactoryBot.create(:user, :name => 'nasty user 123') - user.update(:ban_text => 'You are banned') + user = FactoryBot.create(:user, name: 'nasty user 123') + user.update(ban_text: 'You are banned') expect(user.read_attribute(:name)).to eq('nasty user 123') end it 'appends a message to the name' do - user = FactoryBot.build(:user, :name => 'nasty user', :ban_text => 'banned') + user = FactoryBot.build(:user, name: 'nasty user', ban_text: 'banned') expect(user.name).to eq('nasty user (Account suspended)') end @@ -458,7 +460,7 @@ def create_user(options = {}) it "should attach it to the user" do data = load_file_fixture("parrot.png") - profile_photo = ProfilePhoto.new(:data => data) + profile_photo = ProfilePhoto.new(data: data) @user.set_profile_photo(profile_photo) expect(profile_photo.user).to eq(@user) end @@ -649,12 +651,12 @@ def create_user(options = {}) end it 'is true if the user is an admin' do - admin = double(:is_admin? => true) + admin = double(is_admin?: true) expect(User.stay_logged_in_on_redirect?(admin)).to eq(true) end it 'is false if the user is not an admin' do - user = double(:is_admin? => false) + user = double(is_admin?: false) expect(User.stay_logged_in_on_redirect?(user)).to eq(false) end @@ -701,7 +703,7 @@ def create_user(options = {}) user = User.new calculator = User::TransactionCalculator. - new(user, :transaction_associations => [:comments, :info_requests]) + new(user, transaction_associations: [:comments, :info_requests]) expect(user.transactions(:comments, :info_requests)).to eq(calculator) end @@ -724,82 +726,75 @@ def create_user(options = {}) it 'destroys any associated info_requests' do info_request = FactoryBot.create(:info_request) info_request.user.reload.destroy - expect(InfoRequest.where(:id => info_request.id)).to be_empty + expect(InfoRequest.where(id: info_request.id)).to be_empty end it 'destroys any associated user_info_request_sent_alerts' do info_request = FactoryBot.create(:info_request) - alert = user.user_info_request_sent_alerts.build(:info_request => info_request, - :alert_type => 'overdue_1') + alert = user.user_info_request_sent_alerts.build(info_request: info_request, + alert_type: 'overdue_1') user.destroy - expect(UserInfoRequestSentAlert.where(:id => alert.id)).to be_empty + expect(UserInfoRequestSentAlert.where(id: alert.id)).to be_empty end it 'destroys any associated post_redirects' do - post_redirect = PostRedirect.create(:uri => '/', - :user_id => user.id) + post_redirect = PostRedirect.create(uri: '/', + user_id: user.id) user.destroy - expect(PostRedirect.where(:id => post_redirect.id)).to be_empty + expect(PostRedirect.where(id: post_redirect.id)).to be_empty end it 'destroys any associated track_things' do track_thing = FactoryBot.create(:search_track) track_thing.tracking_user.destroy - expect(TrackThing.where(:id => track_thing.id)).to be_empty + expect(TrackThing.where(id: track_thing.id)).to be_empty end it 'destroys any associated comments' do comment = FactoryBot.create(:comment) comment.user.destroy - expect(Comment.where(:id => comment.id)).to be_empty + expect(Comment.where(id: comment.id)).to be_empty end it 'destroys any associated public_body_change_requests' do change_request = FactoryBot.create(:add_body_request) change_request.user.destroy - expect(PublicBodyChangeRequest.where(:id => change_request.id)) + expect(PublicBodyChangeRequest.where(id: change_request.id)) .to be_empty end it 'destroys any associated profile_photos' do - profile_photo = user.create_profile_photo(:data => 'xxx') + profile_photo = user.create_profile_photo(data: 'xxx') user.destroy - expect(ProfilePhoto.where(:id => profile_photo.id)).to be_empty + expect(ProfilePhoto.where(id: profile_photo.id)).to be_empty end it 'destroys any associated censor_rules' do censor_rule = FactoryBot.create(:user_censor_rule) censor_rule.user.destroy - expect(CensorRule.where(:id => censor_rule.id)).to be_empty + expect(CensorRule.where(id: censor_rule.id)).to be_empty end it 'destroys any associated info_request_batches' do info_request_batch = FactoryBot.create(:info_request_batch) info_request_batch.user.destroy - expect(InfoRequestBatch.where(:id => info_request_batch.id)).to be_empty + expect(InfoRequestBatch.where(id: info_request_batch.id)).to be_empty end it 'destroys any associated request_classifications' do request_classification = FactoryBot.create(:request_classification) request_classification.user.destroy - expect(RequestClassification.where(:id => request_classification.id)) + expect(RequestClassification.where(id: request_classification.id)) .to be_empty end end describe '#expire_requests' do - it 'calls expire on all associated requests' do + it 'create expire job for the user' do user = FactoryBot.build(:user) - - request_1, request_2 = double(:info_request), double(:info_request) - - allow(user).to receive_message_chain(:info_requests, :find_each). - and_yield(request_1).and_yield(request_2) - - expect(request_1).to receive(:expire) - expect(request_2).to receive(:expire) - + expect(InfoRequestExpireJob).to receive(:perform_later). + with(user, :info_requests) user.expire_requests end end @@ -808,7 +803,8 @@ def create_user(options = {}) it 'calls reindex_request_events on all associated requests' do user = FactoryBot.build(:user) - comment_1, comment_2 = double(:comment), double(:comment) + comment_1 = double(:comment) + comment_2 = double(:comment) allow(user).to receive_message_chain(:comments, :find_each). and_yield(comment_1).and_yield(comment_2) @@ -900,7 +896,7 @@ def create_user(options = {}) end it 'can be enabled on initialization' do - user = User.new(:otp_enabled => true) + user = User.new(otp_enabled: true) expect(user.otp_enabled).to eq(true) end @@ -915,33 +911,33 @@ def create_user(options = {}) describe '#otp_enabled?' do it 'requires an otp_secret_key to be enabled' do - attrs = { :otp_enabled => true, - :otp_secret_key => nil, - :otp_counter => 1 } + attrs = { otp_enabled: true, + otp_secret_key: nil, + otp_counter: 1 } user = User.new(attrs) expect(user.otp_enabled?).to eq(false) end it 'requires an otp_counter to be enabled' do - attrs = { :otp_enabled => true, - :otp_secret_key => '123', - :otp_counter => nil } + attrs = { otp_enabled: true, + otp_secret_key: '123', + otp_counter: nil } user = User.new(attrs) expect(user.otp_enabled?).to eq(false) end it 'requires an otp_enabled to be true to be enabled' do - attrs = { :otp_enabled => false, - :otp_secret_key => '123', - :otp_counter => 1 } + attrs = { otp_enabled: false, + otp_secret_key: '123', + otp_counter: 1 } user = User.new(attrs) expect(user.otp_enabled?).to eq(false) end it 'requires otp_enabled, otp_secret_key and otp_counter to be enabled' do - attrs = { :otp_enabled => true, - :otp_secret_key => '123', - :otp_counter => 1 } + attrs = { otp_enabled: true, + otp_secret_key: '123', + otp_counter: 1 } user = User.new(attrs) expect(user.otp_enabled?).to eq(true) end @@ -951,13 +947,13 @@ def create_user(options = {}) describe '#enable_otp' do it 'resets the otp_counter' do - user = User.new(:otp_counter => 200) + user = User.new(otp_counter: 200) user.enable_otp expect(user.otp_counter).to eq(1) end it 'regenerates the otp_secret_key' do - user = User.new(:otp_secret_key => '123') + user = User.new(otp_secret_key: '123') user.enable_otp expect(user.otp_secret_key.length).to eq(32) end @@ -978,13 +974,13 @@ def create_user(options = {}) describe '#disable_otp' do it 'sets otp_enabled to false' do - user = User.new(:otp_enabled => true) + user = User.new(otp_enabled: true) user.disable_otp expect(user.otp_enabled?).to eq(false) end it 'sets require_otp to false' do - user = User.new(:otp_enabled => true) + user = User.new(otp_enabled: true) user.require_otp = true user.disable_otp expect(user.require_otp?).to eq(false) @@ -1005,7 +1001,7 @@ def create_user(options = {}) end it 'returns the assigned boolean' do - user = User.new(:require_otp => true) + user = User.new(require_otp: true) expect(user.require_otp?).to eq(true) end @@ -1035,7 +1031,7 @@ def create_user(options = {}) end it 'can be set on initialization' do - user = User.new(:otp_counter => 200) + user = User.new(otp_counter: 200) expect(user.otp_counter).to eq(200) end @@ -1051,7 +1047,7 @@ def create_user(options = {}) it 'can be set on initialization' do key = User.otp_random_secret - user = User.new(:otp_secret_key => key) + user = User.new(otp_secret_key: key) expect(user.otp_secret_key).to eq(key) end @@ -1067,7 +1063,7 @@ def create_user(options = {}) describe '#entered_otp_code' do it 'gets the virtual attribue for use in validation' do - user = User.new(:entered_otp_code => '123456') + user = User.new(entered_otp_code: '123456') expect(user.entered_otp_code).to eq('123456') end @@ -1086,12 +1082,12 @@ def create_user(options = {}) describe '#banned?' do it 'is banned if the user has ban_text' do - user = FactoryBot.build(:user, :ban_text => 'banned') + user = FactoryBot.build(:user, ban_text: 'banned') expect(user).to be_banned end it 'is not banned if the user has no ban_text' do - user = FactoryBot.build(:user, :ban_text => '') + user = FactoryBot.build(:user, ban_text: '') expect(user).to_not be_banned end @@ -1102,7 +1098,8 @@ def create_user(options = {}) before do allow(Digest::SHA1).to receive(:hexdigest).and_return('1234') - allow(MySociety::Util).to receive(:generate_token).and_return('ABCD') + allow(MySociety::Util). + to receive(:generate_token).and_return('r@nd0m-pa$$w0rd') allow(AlaveteliConfiguration). to receive(:user_sign_in_activity_retention_days).and_return(1) FactoryBot.create(:user_sign_in, user: user) @@ -1114,7 +1111,7 @@ def create_user(options = {}) user.close_and_anonymise censor_rule = user.censor_rules.last expect(censor_rule.text).to eq(user_name) - expect(censor_rule.replacement).to eq ('[Name Removed]') + expect(censor_rule.replacement).to eq('[Name Removed]') end it 'does not create a censor rule for user name if the user does not have info requests' do @@ -1149,7 +1146,7 @@ def create_user(options = {}) it 'should anonymise user password' do expect { user.close_and_anonymise }. - to change(user, :password).to('ABCD') + to change(user, :password).to('r@nd0m-pa$$w0rd') end it 'should set user to not receive email alerts' do @@ -1165,11 +1162,66 @@ def create_user(options = {}) end describe '#close' do + subject { user.close } + let(:user) { FactoryBot.build(:user) } - it 'closes the user account' do - user.close - expect(user).to be_closed + context 'the update is successful' do + before do + expect(user).to receive(:close!).and_call_original + subject + end + + it { is_expected.to eq(true) } + + it 'closes the account' do + expect(user).to be_closed + end + end + + context 'the update is unsuccessful' do + before do + expect(user).to receive(:close!).and_raise(ActiveRecord::RecordInvalid) + subject + end + + it { is_expected.to eq(false) } + + it 'does not close the account' do + expect(user).not_to be_closed + end + end + end + + describe '#close!' do + subject { user.close! } + + let(:user) { FactoryBot.build(:user) } + + context 'the update is successful' do + before { subject } + + it 'closes the account' do + expect(user).to be_closed + end + + it 'sets closed_at' do + expect(user.closed_at).to be_present + end + + it 'disables email alerts' do + expect(user.receive_email_alerts).to eq(false) + end + end + + context 'the update is unsuccessful' do + before do + expect(user).to receive(:update!).and_raise(ActiveRecord::RecordInvalid) + end + + it 'raises an ActiveRecord::RecordInvalid error' do + expect { subject }.to raise_error(ActiveRecord::RecordInvalid) + end end end @@ -1188,6 +1240,138 @@ def create_user(options = {}) end + describe '#erase' do + subject { user.erase } + + let(:user) { FactoryBot.build(:user) } + + context 'the update is successful' do + before do + user.close! + expect(user).to receive(:erase!).and_call_original + subject + end + + it { is_expected.to eq(true) } + + it 'erases the account' do + expect(user.name).to match(/Name Removed/) + end + end + + context 'the update is unsuccessful' do + before do + expect(user).to receive(:erase!).and_raise(ActiveRecord::RecordInvalid) + subject + end + + it { is_expected.to eq(false) } + + it 'does not erase the account' do + expect(user.name).not_to match(/Name Removed/) + end + end + end + + describe '#erase!' do + subject { user.erase! } + + context 'the user account is not closed' do + let(:user) { FactoryBot.build(:user, about_me: 'Hi') } + + it 'raises an ActiveRecord::RecordInvalid' do + expect { subject }.to raise_error(ActiveRecord::RecordInvalid) + end + end + + context 'the update is successful' do + let(:user) { FactoryBot.build(:user, :closed, about_me: 'Hi') } + + before do + allow(AlaveteliConfiguration). + to receive(:user_sign_in_activity_retention_days).and_return(1) + FactoryBot.create(:user_sign_in, user: user) + FactoryBot.create(:profile_photo, user: user) + + allow(Digest::SHA1).to receive(:hexdigest).and_return('a1b2c3d4') + allow(MySociety::Util). + to receive(:generate_token).and_return('r@nd0m-pa$$w0rd') + + subject + + user.reload + end + + it 'erases the name' do + # #name currently appends "(Account suspended)". Here we specifically + # only care about the data we hold. + expect(user.read_attribute(:name)).to eq('[Name Removed]') + end + + it 'erases the url_name' do + expect(user.url_name).to eq('a1b2c3d4') + end + + it 'erases the email' do + expect(user.email).to eq('a1b2c3d4@invalid') + end + + it 'erases the password' do + expect(user.password).to eq('r@nd0m-pa$$w0rd') + end + + it 'erases the about_me' do + expect(user.about_me).to be_empty + end + + it 'destroys any sign_ins' do + expect(user.sign_ins).to be_empty + end + + it 'destroys any profile photo' do + expect(user.profile_photo).to be_nil + end + end + + context 'the update is unsuccessful' do + let(:user) { FactoryBot.build(:user, :closed, about_me: 'Hi') } + + before do + expect(user).to receive(:update!).and_raise(ActiveRecord::RecordInvalid) + end + + it 'raises an ActiveRecord::RecordInvalid error' do + expect { subject }.to raise_error(ActiveRecord::RecordInvalid) + end + end + end + + describe '#anonymise!' do + subject { user.anonymise! } + + let(:user) { FactoryBot.build(:user, name: 'Bob Smith') } + + context 'when the user has info requests' do + before { FactoryBot.create(:info_request, user: user) } + + it 'creates a censor rule for user name if the user has info requests' do + subject + censor_rule = user.censor_rules.last + expect(censor_rule.text).to eq(user.name) + expect(censor_rule.replacement).to eq('[Name Removed]') + expect(censor_rule.last_edit_editor).to eq('User#anonymise!') + expect(censor_rule.last_edit_comment).to eq('User#anonymise!') + end + end + + context 'when the user has no info requests' do + it 'does not create a censor rule' do + subject + expect(user.censor_rules).to be_empty + end + end + end + describe '.closed' do it 'should not return users with closed_at timestamp' do @@ -1324,25 +1508,25 @@ def create_user(options = {}) describe '#confirm' do it 'confirms an unconfirmed user' do - user = FactoryBot.build(:user, :email_confirmed => false) + user = FactoryBot.build(:user, email_confirmed: false) user.confirm expect(user.email_confirmed).to be(true) end it 'no-ops a confirmed user' do - user = FactoryBot.build(:user, :email_confirmed => true) + user = FactoryBot.build(:user, email_confirmed: true) user.confirm expect(user.email_confirmed).to be(true) end it 'does not save by default' do - user = FactoryBot.build(:user, :email_confirmed => false) + user = FactoryBot.build(:user, email_confirmed: false) user.confirm expect(user).to be_new_record end it 'saves the record if passed an argument' do - user = FactoryBot.build(:user, :email_confirmed => false) + user = FactoryBot.build(:user, email_confirmed: false) user.confirm(true) expect(user).to be_persisted end @@ -1352,25 +1536,25 @@ def create_user(options = {}) describe '#confirm!' do it 'confirms an unconfirmed user' do - user = FactoryBot.build(:user, :email_confirmed => false) + user = FactoryBot.build(:user, email_confirmed: false) user.confirm! expect(user.reload.email_confirmed).to be(true) end it 'no-ops a confirmed user' do - user = FactoryBot.build(:user, :email_confirmed => true) + user = FactoryBot.build(:user, email_confirmed: true) user.confirm! expect(user.reload.email_confirmed).to be(true) end it 'saves the record' do - user = FactoryBot.build(:user, :email_confirmed => false) + user = FactoryBot.build(:user, email_confirmed: false) user.confirm! expect(user).to be_persisted end it 'it raises an error on save if the record is invalid' do - user = FactoryBot.build(:user, :email => nil, :email_confirmed => false) + user = FactoryBot.build(:user, email: nil, email_confirmed: false) expect { user.confirm! }.to raise_error(ActiveRecord::RecordInvalid) end @@ -1405,14 +1589,14 @@ def create_user(options = {}) describe '#about_me_already_exists?' do it 'is true if the about_me text already exists for another user' do - FactoryBot.create(:user, :about_me => '123') - user = FactoryBot.build(:user, :about_me => '123') + FactoryBot.create(:user, about_me: '123') + user = FactoryBot.build(:user, about_me: '123') expect(user.about_me_already_exists?).to eq(true) end it 'is false if the about_me text is unique to the user' do - User.update_all(:about_me => '') - user = FactoryBot.build(:user, :about_me => '123') + User.update_all(about_me: '') + user = FactoryBot.build(:user, about_me: '123') expect(user.about_me_already_exists?).to eq(false) end @@ -1433,17 +1617,17 @@ def create_user(options = {}) describe '#indexed_by_search?' do it 'is false if the user is unconfirmed' do - user = User.new(:email_confirmed => false, :ban_text => '') + user = User.new(email_confirmed: false, ban_text: '') expect(user.indexed_by_search?).to eq(false) end it 'is false if the user is banned' do - user = User.new(:email_confirmed => true, :ban_text => 'banned') + user = User.new(email_confirmed: true, ban_text: 'banned') expect(user.indexed_by_search?).to eq(false) end it 'is true if the user is confirmed and not banned' do - user = User.new(:email_confirmed => true, :ban_text => '') + user = User.new(email_confirmed: true, ban_text: '') expect(user.indexed_by_search?).to eq(true) end @@ -1504,15 +1688,15 @@ def create_user(options = {}) describe '.info_request_events' do let(:user) { FactoryBot.create(:user) } - let(:info_request) { FactoryBot.create(:info_request, :user => user) } + let(:info_request) { FactoryBot.create(:info_request, user: user) } let!(:response_event) do - FactoryBot.create(:response_event, :info_request => info_request) + FactoryBot.create(:response_event, info_request: info_request) end let!(:comment_event) do - FactoryBot.create(:comment_event, :info_request => info_request) + FactoryBot.create(:comment_event, info_request: info_request) end let!(:resent_event) do - FactoryBot.create(:resent_event, :info_request => info_request) + FactoryBot.create(:resent_event, info_request: info_request) end it "returns events in descending created_at order" do @@ -1522,7 +1706,7 @@ def create_user(options = {}) end it "returns all of the user's events" do - # Note: there is a fourth "sent" event created automatically + # NOTE: there is a fourth "sent" event created automatically expect(user.info_request_events.count).to eq 4 end end @@ -1907,7 +2091,41 @@ def create_user(options = {}) it { is_expected.to eq(false) } end - context 'when the user has reached their rate limit' do + context 'when the user is an admin' do + let(:user) { FactoryBot.create(:user, :admin) } + + # Irrespective of how many comments they've made + before do + allow(user). + to receive(:exceeded_limit?).with(:comments).and_return(true) + + allow(Comment). + to receive(:exceeded_creation_rate?). + with(user.comments). + and_return(true) + end + + it { is_expected.to eq(true) } + end + + context 'when the user is a pro_admin' do + let(:user) { FactoryBot.create(:user, :pro_admin) } + + # Irrespective of how many comments they've made + before do + allow(user). + to receive(:exceeded_limit?).with(:comments).and_return(true) + + allow(Comment). + to receive(:exceeded_creation_rate?). + with(user.comments). + and_return(true) + end + + it { is_expected.to eq(true) } + end + + context 'when the user has reached their daily limit' do let(:user) { FactoryBot.build(:user) } before do @@ -1917,6 +2135,32 @@ def create_user(options = {}) it { is_expected.to eq(false) } end + + context 'when the user has not reached their rate limit' do + let(:user) { FactoryBot.build(:user) } + + before do + allow(Comment). + to receive(:exceeded_creation_rate?). + with(user.comments). + and_return(false) + end + + it { is_expected.to eq(true) } + end + + context 'when the user has reached their rate limit' do + let(:user) { FactoryBot.build(:user) } + + before do + allow(Comment). + to receive(:exceeded_creation_rate?). + with(user.comments). + and_return(true) + end + + it { is_expected.to eq(false) } + end end describe '#exceeded_limit?' do @@ -1980,5 +2224,20 @@ def create_user(options = {}) expect(subject).to eq(true) end end + + context 'limiting user messages' do + let(:content) { :user_messages } + before { FactoryBot.create(:user_message, user: user) } + + it 'returns false if the user has not submitted more than the limit' do + allow(user).to receive(:content_limit).with(content).and_return(2) + expect(subject).to eq(false) + end + + it 'returns true if the user has submitted more than the limit' do + allow(user).to receive(:content_limit).with(content).and_return(0) + expect(subject).to eq(true) + end + end end end diff --git a/spec/models/widget_vote_spec.rb b/spec/models/widget_vote_spec.rb index 7575c1820e..faa2f6da65 100644 --- a/spec/models/widget_vote_spec.rb +++ b/spec/models/widget_vote_spec.rb @@ -35,8 +35,8 @@ it 'enforces uniqueness of cookie per info request' do info_request = FactoryBot.create(:info_request) - widget_vote = info_request.widget_votes.create(:cookie => 'x' * 20) - duplicate_vote = info_request.widget_votes.build(:cookie => 'x' * 20) + widget_vote = info_request.widget_votes.create(cookie: 'x' * 20) + duplicate_vote = info_request.widget_votes.build(cookie: 'x' * 20) expect(duplicate_vote).not_to be_valid expect(duplicate_vote.errors[:cookie]).to eq(["has already been taken"]) end @@ -44,8 +44,8 @@ it 'allows the same cookie to be used across info requests' do info_request = FactoryBot.create(:info_request) second_info_request = FactoryBot.create(:info_request) - widget_vote = info_request.widget_votes.create(:cookie => 'x' * 20) - second_request_vote = second_info_request.widget_votes.build(:cookie => 'x' * 20) + widget_vote = info_request.widget_votes.create(cookie: 'x' * 20) + second_request_vote = second_info_request.widget_votes.build(cookie: 'x' * 20) expect(second_request_vote).to be_valid end diff --git a/spec/models/xapian_spec.rb b/spec/models/xapian_spec.rb index 8b6c3fb1c7..60773b98b6 100644 --- a/spec/models/xapian_spec.rb +++ b/spec/models/xapian_spec.rb @@ -8,7 +8,7 @@ end it "should search by name" do - xapian_object = ActsAsXapian::Search.new([User], "Silly", :limit => 100) + xapian_object = ActsAsXapian::Search.new([User], "Silly", limit: 100) expect(xapian_object.results.size).to eq(1) expect(xapian_object.results[0][:model]).to eq(users(:silly_name_user)) end @@ -16,7 +16,7 @@ it "should search by 'about me' text" do user = users(:bob_smith_user) - xapian_object = ActsAsXapian::Search.new([User], "stuff", :limit => 100) + xapian_object = ActsAsXapian::Search.new([User], "stuff", limit: 100) expect(xapian_object.results.size).to eq(1) expect(xapian_object.results[0][:model]).to eq(user) @@ -24,10 +24,10 @@ user.save! update_xapian_index - xapian_object = ActsAsXapian::Search.new([User], "stuff", :limit => 100) + xapian_object = ActsAsXapian::Search.new([User], "stuff", limit: 100) expect(xapian_object.results.size).to eq(0) - xapian_object = ActsAsXapian::Search.new([User], "aardvark", :limit => 100) + xapian_object = ActsAsXapian::Search.new([User], "aardvark", limit: 100) expect(xapian_object.results.size).to eq(1) expect(xapian_object.results[0][:model]).to eq(user) end @@ -40,26 +40,26 @@ end it "should search index the main name field" do - xapian_object = ActsAsXapian::Search.new([PublicBody], "humpadinking", :limit => 100) + xapian_object = ActsAsXapian::Search.new([PublicBody], "humpadinking", limit: 100) expect(xapian_object.results.size).to eq(1) expect(xapian_object.results[0][:model]).to eq(public_bodies(:humpadink_public_body)) end it "should search index the notes field" do - xapian_object = ActsAsXapian::Search.new([PublicBody], "albatross", :limit => 100) + xapian_object = ActsAsXapian::Search.new([PublicBody], "albatross", limit: 100) expect(xapian_object.results.size).to eq(1) expect(xapian_object.results[0][:model]).to eq(public_bodies(:humpadink_public_body)) end it "should delete public bodies from the index when they are destroyed" do - xapian_object = ActsAsXapian::Search.new([PublicBody], "albatross", :limit => 100) + xapian_object = ActsAsXapian::Search.new([PublicBody], "albatross", limit: 100) expect(xapian_object.results.size).to eq(1) expect(xapian_object.results[0][:model]).to eq(public_bodies(:humpadink_public_body)) public_bodies(:forlorn_public_body).destroy update_xapian_index - xapian_object = ActsAsXapian::Search.new([PublicBody], "lonely", :limit => 100) + xapian_object = ActsAsXapian::Search.new([PublicBody], "lonely", limit: 100) expect(xapian_object.results).to eq([]) end @@ -67,19 +67,21 @@ RSpec.describe PublicBody, " when indexing requests by body they are to" do + include ActiveJob::TestHelper + before(:each) do load_raw_emails_data update_xapian_index end it "should find requests to the body" do - xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "requested_from:tgq", :limit => 100) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "requested_from:tgq", limit: 100) expect(xapian_object.results.size).to eq(PublicBody.find_by_url_name("tgq").info_requests.map(&:info_request_events).flatten.size) end it "should update index correctly when URL name of body changes" do # initial search - xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "requested_from:tgq", :limit => 100) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "requested_from:tgq", limit: 100) expect(xapian_object.results.size).to eq(PublicBody.find_by_url_name("tgq").info_requests.map(&:info_request_events).flatten.size) models_found_before = xapian_object.results.map { |x| x[:model] } @@ -88,12 +90,13 @@ body.short_name = 'GQ' body.save! expect(body.url_name).to eq('gq') + perform_enqueued_jobs update_xapian_index # check we get results expected - xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "requested_from:tgq", :limit => 100) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "requested_from:tgq", limit: 100) expect(xapian_object.results.size).to eq(0) - xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "requested_from:gq", :limit => 100) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "requested_from:gq", limit: 100) expect(xapian_object.results.size).to eq(PublicBody.find_by_url_name("gq").info_requests.map(&:info_request_events).flatten.size) models_found_after = xapian_object.results.map { |x| x[:model] } @@ -108,29 +111,32 @@ body.short_name = 'The Uncensored, Complete Name of the Quasi-Autonomous Public Body Also Known As Geraldine' body.save! expect(body.url_name.size).to be > 70 + perform_enqueued_jobs update_xapian_index # check we get results expected - xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "requested_from:tgq", :limit => 100) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "requested_from:tgq", limit: 100) expect(xapian_object.results.size).to eq(0) - xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "requested_from:gq", :limit => 100) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "requested_from:gq", limit: 100) expect(xapian_object.results.size).to eq(0) - xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "requested_from:#{body.url_name}", :limit => 100) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "requested_from:#{body.url_name}", limit: 100) expect(xapian_object.results.size).to eq(public_bodies(:geraldine_public_body).info_requests.map(&:info_request_events).flatten.size) models_found_after = xapian_object.results.map { |x| x[:model] } end end RSpec.describe User, " when indexing requests by user they are from" do + include ActiveJob::TestHelper + before(:each) do load_raw_emails_data update_xapian_index end it "should find requests from the user" do - options = { :sort_by_prefix => 'created_at', - :sort_by_ascending => true, - :limit => 100} + options = { sort_by_prefix: 'created_at', + sort_by_ascending: true, + limit: 100} xapian_object = ActsAsXapian::Search. @@ -148,9 +154,9 @@ end it "should find just the sent message events from a particular user" do - options = { :sort_by_prefix => 'created_at', - :sort_by_ascending => true, - :limit => 100 } + options = { sort_by_prefix: 'created_at', + sort_by_ascending: true, + limit: 100 } xapian_object = ActsAsXapian::Search. @@ -180,10 +186,10 @@ update_xapian_index - options = { :sort_by_prefix => 'created_at', - :sort_by_ascending => true, - :collapse_by_prefix => 'request_collapse', - :limit => 100 } + options = { sort_by_prefix: 'created_at', + sort_by_ascending: true, + collapse_by_prefix: 'request_collapse', + limit: 100 } xapian_object = ActsAsXapian::Search. @@ -192,7 +198,7 @@ results = xapian_object.results.map { |x| x[:model].info_request } expect(results). - to match_array(InfoRequest.where(:user_id => users(:bob_smith_user).id)) + to match_array(InfoRequest.where(user_id: users(:bob_smith_user).id)) end it "should not get confused searching for requests when one user has a name which has same stem as another" do @@ -212,16 +218,16 @@ update_xapian_index - xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "requested_by:john_k", :limit => 100) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "requested_by:john_k", limit: 100) expect(xapian_object.results.size).to eq(1) expect(xapian_object.results[0][:model]).to eq(info_request_events(:silly_outgoing_message_event)) end it "should update index correctly when URL name of user changes" do # initial search - options = { :sort_by_prefix => 'created_at', - :sort_by_ascending => true, - :limit => 100 } + options = { sort_by_prefix: 'created_at', + sort_by_ascending: true, + limit: 100 } xapian_object = ActsAsXapian::Search. new([InfoRequestEvent], "requested_by:bob_smith", options) @@ -243,13 +249,14 @@ u.name = 'Robert Smith' u.save! expect(u.url_name).to eq('robert_smith') + perform_enqueued_jobs update_xapian_index # check we get results expected - xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "requested_by:bob_smith", :limit => 100) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "requested_by:bob_smith", limit: 100) expect(xapian_object.results.size).to eq(0) xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "requested_by:robert_smith", - :sort_by_prefix => 'created_at', :sort_by_ascending => true, :limit => 100) + sort_by_prefix: 'created_at', sort_by_ascending: true, limit: 100) models_found_after = xapian_object.results.map { |x| x[:model] } expect(models_found_before).to eq(models_found_after) end @@ -262,13 +269,13 @@ end it "should find requests from the user" do - xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "commented_by:silly_emnameem", :limit => 100) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "commented_by:silly_emnameem", limit: 100) expect(xapian_object.results.size).to eq(1) end it "should update index correctly when URL name of user changes" do # initial search - xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "commented_by:silly_emnameem", :limit => 100) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "commented_by:silly_emnameem", limit: 100) expect(xapian_object.results.size).to eq(1) models_found_before = xapian_object.results.map { |x| x[:model] } @@ -280,9 +287,9 @@ update_xapian_index # check we get results expected - xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "commented_by:silly_emnameem", :limit => 100) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "commented_by:silly_emnameem", limit: 100) expect(xapian_object.results.size).to eq(0) - xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "commented_by:silly_name", :limit => 100) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "commented_by:silly_name", limit: 100) expect(xapian_object.results.size).to eq(1) models_found_after = xapian_object.results.map { |x| x[:model] } @@ -297,7 +304,7 @@ end it "should find events for the request" do - xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "request:how_much_public_money_is_wasted_o", :limit => 100) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "request:how_much_public_money_is_wasted_o", limit: 100) expect(xapian_object.results.size).to eq(1) xapian_object.results[0][:model] == info_request_events(:silly_outgoing_message_event) end @@ -311,9 +318,9 @@ update_xapian_index # check we get results expected - xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "request:how_much_public_money_is_wasted_o", :limit => 100) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "request:how_much_public_money_is_wasted_o", limit: 100) expect(xapian_object.results.size).to eq(0) - xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "request:really_naughty", :limit => 100) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "request:really_naughty", limit: 100) expect(xapian_object.results.size).to eq(1) xapian_object.results[0][:model] == info_request_events(:silly_outgoing_message_event) end @@ -331,11 +338,11 @@ ir.save! update_xapian_index - xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "tag:bunnyrabbit", :limit => 100) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "tag:bunnyrabbit", limit: 100) expect(xapian_object.results.size).to eq(1) xapian_object.results[0][:model] == info_request_events(:silly_outgoing_message_event) - xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "tag:orangeaardvark", :limit => 100) + xapian_object = ActsAsXapian::Search.new([InfoRequestEvent], "tag:orangeaardvark", limit: 100) expect(xapian_object.results.size).to eq(0) end end @@ -352,14 +359,14 @@ body.save! update_xapian_index - xapian_object = ActsAsXapian::Search.new([PublicBody], "tag:mice", :limit => 100) + xapian_object = ActsAsXapian::Search.new([PublicBody], "tag:mice", limit: 100) expect(xapian_object.results.size).to eq(1) xapian_object.results[0][:model] == public_bodies(:geraldine_public_body) - xapian_object = ActsAsXapian::Search.new([PublicBody], "tag:mice:3", :limit => 100) + xapian_object = ActsAsXapian::Search.new([PublicBody], "tag:mice:3", limit: 100) expect(xapian_object.results.size).to eq(1) xapian_object.results[0][:model] == public_bodies(:geraldine_public_body) - xapian_object = ActsAsXapian::Search.new([PublicBody], "tag:orangeaardvark", :limit => 100) + xapian_object = ActsAsXapian::Search.new([PublicBody], "tag:orangeaardvark", limit: 100) expect(xapian_object.results.size).to eq(0) end end @@ -381,11 +388,11 @@ values = false texts = false destroy_and_rebuild_xapian_index(terms, values, texts, dropfirst) - xapian_object = ActsAsXapian::Search.new([PublicBody], "tag:mice", :limit => 100) + xapian_object = ActsAsXapian::Search.new([PublicBody], "tag:mice", limit: 100) expect(xapian_object.results.size).to eq(0) - xapian_object = ActsAsXapian::Search.new([PublicBody], "frobzn", :limit => 100) + xapian_object = ActsAsXapian::Search.new([PublicBody], "frobzn", limit: 100) expect(xapian_object.results.size).to eq(0) - xapian_object = ActsAsXapian::Search.new([PublicBody], "variety:authority", :limit => 100) + xapian_object = ActsAsXapian::Search.new([PublicBody], "variety:authority", limit: 100) expect(xapian_object.results.map { |x|x[:model] }).to match_array(PublicBody.all) # only reindex 'tag' and text dropfirst = true @@ -393,31 +400,31 @@ values = false texts = true destroy_and_rebuild_xapian_index(terms, values, texts, dropfirst) - xapian_object = ActsAsXapian::Search.new([PublicBody], "tag:mice", :limit => 100) + xapian_object = ActsAsXapian::Search.new([PublicBody], "tag:mice", limit: 100) expect(xapian_object.results.size).to eq(1) - xapian_object = ActsAsXapian::Search.new([PublicBody], "frobzn", :limit => 100) + xapian_object = ActsAsXapian::Search.new([PublicBody], "frobzn", limit: 100) expect(xapian_object.results.size).to eq(1) - xapian_object = ActsAsXapian::Search.new([PublicBody], "variety:authority", :limit => 100) + xapian_object = ActsAsXapian::Search.new([PublicBody], "variety:authority", limit: 100) expect(xapian_object.results.size).to eq(0) # only reindex 'variety' term, but keeping the existing data in-place dropfirst = false terms = "V" texts = false destroy_and_rebuild_xapian_index(terms, values, texts, dropfirst) - xapian_object = ActsAsXapian::Search.new([PublicBody], "tag:mice", :limit => 100) + xapian_object = ActsAsXapian::Search.new([PublicBody], "tag:mice", limit: 100) expect(xapian_object.results.size).to eq(1) - xapian_object = ActsAsXapian::Search.new([PublicBody], "frobzn", :limit => 100) + xapian_object = ActsAsXapian::Search.new([PublicBody], "frobzn", limit: 100) expect(xapian_object.results.size).to eq(1) - xapian_object = ActsAsXapian::Search.new([PublicBody], "variety:authority", :limit => 100) + xapian_object = ActsAsXapian::Search.new([PublicBody], "variety:authority", limit: 100) expect(xapian_object.results.map { |x|x[:model] }).to match_array(PublicBody.all) # only reindex 'variety' term, blowing away existing data dropfirst = true destroy_and_rebuild_xapian_index(terms, values, texts, dropfirst) - xapian_object = ActsAsXapian::Search.new([PublicBody], "tag:mice", :limit => 100) + xapian_object = ActsAsXapian::Search.new([PublicBody], "tag:mice", limit: 100) expect(xapian_object.results.size).to eq(0) - xapian_object = ActsAsXapian::Search.new([PublicBody], "frobzn", :limit => 100) + xapian_object = ActsAsXapian::Search.new([PublicBody], "frobzn", limit: 100) expect(xapian_object.results.size).to eq(0) - xapian_object = ActsAsXapian::Search.new([PublicBody], "variety:authority", :limit => 100) + xapian_object = ActsAsXapian::Search.new([PublicBody], "variety:authority", limit: 100) expect(xapian_object.results.map { |x|x[:model] }).to match_array(PublicBody.all) end end diff --git a/spec/script/handle-mail-replies_spec.rb b/spec/script/handle-mail-replies_spec.rb index bb331da102..71663a3ba7 100644 --- a/spec/script/handle-mail-replies_spec.rb +++ b/spec/script/handle-mail-replies_spec.rb @@ -4,7 +4,7 @@ def mail_reply_test(email_filename) Dir.chdir Rails.root do xc = ExternalCommand.new("script/handle-mail-replies", "--test", - :stdin_string => load_file_fixture(email_filename)) + stdin_string: load_file_fixture(email_filename)) xc.run expect(xc.err).to eq("") return xc @@ -17,14 +17,14 @@ def mail_reply_test(email_filename) it "should not fail handling a bounce mail" do xc = ExternalCommand.new("script/handle-mail-replies", - { :stdin_string => load_file_fixture("track-response-exim-bounce.email") }) + { stdin_string: load_file_fixture("track-response-exim-bounce.email") }) xc.run expect(xc.err).to eq("") end it 'should not fail handling a UTF8 encoded mail' do xc = ExternalCommand.new("script/handle-mail-replies", - { :stdin_string => load_file_fixture("russian.email") }) + { stdin_string: load_file_fixture("russian.email") }) xc.run expect(xc.err).to eq("") end diff --git a/spec/script/mailin_spec.rb b/spec/script/mailin_spec.rb index 6f0b6c98a7..420542f8bc 100644 --- a/spec/script/mailin_spec.rb +++ b/spec/script/mailin_spec.rb @@ -8,7 +8,7 @@ def mailin_test(email_filename) ir = info_requests(:other_request) mail.gsub!('EMAIL_TO', ir.incoming_email) mail.gsub!('EMAIL_FROM', 'responder@localhost') - xc = ExternalCommand.new("script/mailin", :stdin_string => mail).run + xc = ExternalCommand.new("script/mailin", stdin_string: mail).run expect(xc.err).to eq("") return xc end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2e0a2d9bb4..3ca05cebfe 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -19,8 +19,8 @@ # Use test-specific translations locale_path = File.join(File.dirname(__FILE__), 'fixtures', 'locale') repos = [ FastGettext::TranslationRepository.build('app', - :path => locale_path, - :type => :po) ] + path: locale_path, + type: :po) ] AlaveteliLocalization.set_default_text_domain('app', repos) RSpec.configure do |config| @@ -35,7 +35,7 @@ config.infer_spec_type_from_file_location! config.include ActiveSupport::Testing::TimeHelpers - config.include Capybara::DSL, :type => :request + config.include Capybara::DSL, type: :request config.include ConfigHelper config.include LinkToHelper config.include StripAttributes::Matchers @@ -63,7 +63,9 @@ :public_body_category_translations, :public_body_headings, :public_body_heading_translations, - :public_body_category_links + :public_body_category_links, + :notes, + :note_translations # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false @@ -84,9 +86,7 @@ # Clean up raw emails directory config.after(:suite) do raw_email_dir = File.join(Rails.root, 'files/raw_email_test') - if File.directory?(raw_email_dir) - FileUtils.rm_rf(raw_email_dir) - end + FileUtils.rm_rf(raw_email_dir) if File.directory?(raw_email_dir) FileUtils.rm_rf(Rails.root.join('tmp', 'storage')) end @@ -99,9 +99,7 @@ config.before(:suite) do if ENV['ALAVETELI_USE_OINK'] oink_log = Rails.root + 'log/oink.log' - if File.exist?(oink_log) - File.write(oink_log, '') - end + File.write(oink_log, '') if File.exist?(oink_log) end BCrypt::Engine.cost = 1 @@ -120,18 +118,22 @@ # the locale in your tests and not even realising it. So, let's make things easier for # ourselves and just always restore the locale for all tests. config.after(:each) do - AlaveteliLocalization.set_locales(AlaveteliConfiguration::available_locales, - AlaveteliConfiguration::default_locale) + AlaveteliLocalization.set_locales(AlaveteliConfiguration.available_locales, + AlaveteliConfiguration.default_locale) end # Turn routing-filter off in functional and unit tests as per # https://github.com/svenfuchs/routing-filter/blob/master/README.markdown#testing config.before(:each) do |example| - RoutingFilter.active = false if [:controller, :helper, :model].include? example.metadata[:type] + if [:controller, :helper, :model].include? example.metadata[:type] + RoutingFilter.active = false + end end config.after(:each) do |example| - RoutingFilter.active = true if [:controller, :helper, :model].include? example.metadata[:type] + if [:controller, :helper, :model].include? example.metadata[:type] + RoutingFilter.active = true + end end # This section makes the garbage collector run less often to speed up tests @@ -165,9 +167,9 @@ def with_duplicate_xapian_job_creation InfoRequestEvent.module_eval do def xapian_before_create_job_hook(action, model, model_id) - ActsAsXapian::ActsAsXapianJob.create!(:model => model, - :model_id => model_id, - :action => action) + ActsAsXapian::ActsAsXapianJob.create!(model: model, + model_id: model_id, + action: action) end end yield @@ -179,14 +181,16 @@ def xapian_before_create_job_hook(action, model, model_id) end def with_env_tz(new_tz = 'US/Eastern') - old_tz, ENV['TZ'] = ENV['TZ'], new_tz + old_tz = ENV['TZ'] + ENV['TZ'] = new_tz yield ensure old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ') end def with_active_record_default_timezone(zone) - old_zone, ActiveRecord::Base.default_timezone = ActiveRecord::Base.default_timezone, zone + old_zone = ActiveRecord::Base.default_timezone + ActiveRecord::Base.default_timezone = zone yield ensure ActiveRecord::Base.default_timezone = old_zone @@ -231,9 +235,9 @@ def with_default_locale(locale) end def basic_auth_login(request, username = nil, password = nil) - username = AlaveteliConfiguration::admin_username if username.nil? - password = AlaveteliConfiguration::admin_password if password.nil? - request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64::encode64("#{username}:#{password}") + username = AlaveteliConfiguration.admin_username if username.nil? + password = AlaveteliConfiguration.admin_password if password.nil? + request.env["HTTP_AUTHORIZATION"] = "Basic " + Base64.encode64("#{username}:#{password}") end FactoryBot.definition_file_paths = [ Rails.root.join('spec', 'factories') ] @@ -241,8 +245,7 @@ def basic_auth_login(request, username = nil, password = nil) def normalise_whitespace(s) s = s.gsub(/\A\s+|\s+\Z/, "") - s = s.gsub(/\s+/, " ") - return s + s.gsub(/\s+/, " ") end def get_last_post_redirect diff --git a/spec/support/email_helpers.rb b/spec/support/email_helpers.rb index 0627e4c7a9..64f6bf5fc9 100644 --- a/spec/support/email_helpers.rb +++ b/spec/support/email_helpers.rb @@ -1,8 +1,8 @@ def load_raw_emails_data raw_emails_yml = File.join(RSpec.configuration.fixture_path, "raw_emails.yml") - for raw_email_id in YAML::load_file(raw_emails_yml).map { |k,v| v["id"] } do + YAML.load_file(raw_emails_yml).map { |_k,v| v["id"] }.each do |raw_email_id| raw_email = RawEmail.find(raw_email_id) - raw_email.data = load_file_fixture("raw_emails/%d.email" % [raw_email_id]) + raw_email.data = load_file_fixture(format("raw_emails/%d.email", raw_email_id)) end end @@ -20,11 +20,11 @@ def get_fixture_mail(filename, email_to = nil, email_from = nil) end def parse_all_incoming_messages - IncomingMessage.find_each { |message| message.parse_raw_email! } + IncomingMessage.find_each(&:parse_raw_email!) end def load_mail_server_logs(log) - batch = MailServerLogDone.create(:filename => 'spec', :last_stat => Time.zone.now) + batch = MailServerLogDone.create(filename: 'spec', last_stat: Time.zone.now) mta_log_type = AlaveteliConfiguration.mta_log_type.to_sym io_stream = StringIO.new(log) case mta_log_type diff --git a/spec/support/load_file_fixtures.rb b/spec/support/load_file_fixtures.rb index bbe699aaaf..af5b672a27 100644 --- a/spec/support/load_file_fixtures.rb +++ b/spec/support/load_file_fixtures.rb @@ -4,7 +4,7 @@ def file_fixture_name(file_name) def load_file_fixture(file_name, mode = 'rb') file_name = file_fixture_name(file_name) - File.open(file_name, mode) { |f| f.read } if File.exist?(file_name) + File.open(file_name, mode, &:read) if File.exist?(file_name) end def read_described_class_fixture(fixture) diff --git a/spec/support/mock_pop3.rb b/spec/support/mock_pop3.rb index bef1a2127e..4a3b18716f 100644 --- a/spec/support/mock_pop3.rb +++ b/spec/support/mock_pop3.rb @@ -13,22 +13,22 @@ def self.popmails @@popmails.clone end - def each_mail(*args) + def each_mail(*_args) @@popmails.each do |popmail| yield popmail end end - def mails(*args) + def mails(*_args) @@popmails.clone end - def start(*args) + def start(*_args) @@start = true block_given? ? yield(self) : self end - def enable_ssl(*args) + def enable_ssl(*_args) true end diff --git a/spec/support/mock_pop_mail.rb b/spec/support/mock_pop_mail.rb index 0abbce5f6e..5c9d08d746 100644 --- a/spec/support/mock_pop_mail.rb +++ b/spec/support/mock_pop_mail.rb @@ -9,9 +9,7 @@ def pop @rfc2822 end - def number - @number - end + attr_reader :number def to_s "#{number}: #{pop}" diff --git a/spec/support/shared_examples_for_activity_list_items.rb b/spec/support/shared_examples_for_activity_list_items.rb index 6d6b2a927b..da90875c2e 100644 --- a/spec/support/shared_examples_for_activity_list_items.rb +++ b/spec/support/shared_examples_for_activity_list_items.rb @@ -15,12 +15,10 @@ describe '#description_urls' do it 'returns a hash of :public_body_name and :info_request_title' do - expected_urls = { :public_body_name => - { :text => event.info_request.public_body.name, - :url => public_body_path(event.info_request.public_body) }, - :info_request_title => - { :text => event.info_request.title, - :url => request_path(event.info_request) } } + expected_urls = { public_body_name: { text: event.info_request.public_body.name, + url: public_body_path(event.info_request.public_body) }, + info_request_title: { text: event.info_request.title, + url: request_path(event.info_request) } } expect(activity.description_urls). to eq expected_urls end diff --git a/spec/support/shared_examples_for_viewing_requests.rb b/spec/support/shared_examples_for_viewing_requests.rb index 781d76a70b..bd76640831 100644 --- a/spec/support/shared_examples_for_viewing_requests.rb +++ b/spec/support/shared_examples_for_viewing_requests.rb @@ -65,7 +65,7 @@ before do incoming_message = FactoryBot.create(:plain_incoming_message, - :info_request => info_request) + info_request: info_request) info_request.log_event( 'response', incoming_message_id: incoming_message.id @@ -122,7 +122,7 @@ click_button("Update") end expect(info_request.reload.described_state). - to eq ("partially_successful") + to eq("partially_successful") expect(page).to have_content("Your request has been updated!") # The form should still be there to allow us to go back if we # updated by mistake diff --git a/spec/support/xml_matchers.rb b/spec/support/xml_matchers.rb index 2d34fd2959..498c37c4c1 100644 --- a/spec/support/xml_matchers.rb +++ b/spec/support/xml_matchers.rb @@ -17,7 +17,7 @@ "expected to find xml tag #{xpath} in:\n#{body}" end - failure_message_when_negated do |response| + failure_message_when_negated do |_response| "expected not to find xml tag #{xpath} in:\n#{body}" end diff --git a/spec/validators/change_email_validator_spec.rb b/spec/validators/change_email_validator_spec.rb index 3acc15f717..1b8ee578e0 100644 --- a/spec/validators/change_email_validator_spec.rb +++ b/spec/validators/change_email_validator_spec.rb @@ -13,10 +13,10 @@ def validator_with_user_and_params(user, params = {}) describe '#old_email' do it 'must have an old email' do - params = { :old_email => nil, - :new_email => 'new@example.com', - :user_circumstance => 'change_email', - :password => 'jonespassword' } + params = { old_email: nil, + new_email: 'new@example.com', + user_circumstance: 'change_email', + password: 'jonespassword' } validator = validator_with_user_and_params(user, params) msg = 'Please enter your old email address' @@ -25,10 +25,10 @@ def validator_with_user_and_params(user, params = {}) end it 'must be a valid email' do - params = { :old_email => 'old', - :new_email => 'new@example.com', - :user_circumstance => 'change_email', - :password => 'jonespassword' } + params = { old_email: 'old', + new_email: 'new@example.com', + user_circumstance: 'change_email', + password: 'jonespassword' } validator = validator_with_user_and_params(user, params) validator.valid? msg = "Old email doesn't look like a valid address" @@ -36,10 +36,10 @@ def validator_with_user_and_params(user, params = {}) end it 'must have the same email as the logged in user' do - params = { :old_email => user.email, - :new_email => 'new@example.com', - :user_circumstance => 'change_email', - :password => 'jonespassword' } + params = { old_email: user.email, + new_email: 'new@example.com', + user_circumstance: 'change_email', + password: 'jonespassword' } validator = validator_with_user_and_params(user, params) validator.logged_in_user = FactoryBot.build(:user) validator.valid? @@ -52,10 +52,10 @@ def validator_with_user_and_params(user, params = {}) describe '#new_email' do it 'must have a new email' do - params = { :old_email => user.email, - :new_email => nil, - :user_circumstance => 'change_email', - :password => 'jonespassword' } + params = { old_email: user.email, + new_email: nil, + user_circumstance: 'change_email', + password: 'jonespassword' } validator = validator_with_user_and_params(user, params) validator.valid? msg = 'Please enter your new email address' @@ -63,10 +63,10 @@ def validator_with_user_and_params(user, params = {}) end it 'must be a valid email' do - params = { :old_email => user.email, - :new_email => 'new', - :user_circumstance => 'change_email', - :password => 'jonespassword' } + params = { old_email: user.email, + new_email: 'new', + user_circumstance: 'change_email', + password: 'jonespassword' } validator = validator_with_user_and_params(user, params) validator.valid? msg = "New email doesn't look like a valid address" @@ -78,9 +78,9 @@ def validator_with_user_and_params(user, params = {}) describe '#password' do it 'password_and_format_of_email validation fails when password is nil' do - params = { :old_email => user.email, - :new_email => 'new@example.com', - :password => nil } + params = { old_email: user.email, + new_email: 'new@example.com', + password: nil } validator = validator_with_user_and_params(user, params) validator.valid? msg = 'Please enter your password' @@ -88,20 +88,20 @@ def validator_with_user_and_params(user, params = {}) end it 'does not require a password if changing email' do - params = { :old_email => user.email, - :new_email => 'new@example.com', - :user_circumstance => 'change_email', - :password => '' } + params = { old_email: user.email, + new_email: 'new@example.com', + user_circumstance: 'change_email', + password: '' } validator = validator_with_user_and_params(user, params) validator.valid? expect(validator.errors[:password].size).to eq(0) end it 'must have a password if not changing email' do - params = { :old_email => user.email, - :new_email => 'new@example.com', - :user_circumstance => 'unknown', - :password => '' } + params = { old_email: user.email, + new_email: 'new@example.com', + user_circumstance: 'unknown', + password: '' } validator = validator_with_user_and_params(user, params) validator.valid? msg = 'Please enter your password' @@ -109,9 +109,9 @@ def validator_with_user_and_params(user, params = {}) end it 'must be the correct password' do - params = { :old_email => user.email, - :new_email => 'new@example.com', - :password => 'incorrectpass' } + params = { old_email: user.email, + new_email: 'new@example.com', + password: 'incorrectpass' } validator = validator_with_user_and_params(user, params) validator.valid? msg = 'Password is not correct' diff --git a/spec/validators/contact_validator_spec.rb b/spec/validators/contact_validator_spec.rb index 56c015dd90..befd7408a5 100644 --- a/spec/validators/contact_validator_spec.rb +++ b/spec/validators/contact_validator_spec.rb @@ -5,10 +5,10 @@ describe '.new' do let(:valid_params) do - { :name => "Vinny Vanilli", - :email => "vinny@localhost", - :subject => "Why do I have such an ace name?", - :message => "You really should know!!!\n\nVinny" } + { name: "Vinny Vanilli", + email: "vinny@localhost", + subject: "Why do I have such an ace name?", + message: "You really should know!!!\n\nVinny" } end it 'validates specified attributes' do @@ -31,7 +31,7 @@ end it 'validates email format' do - valid_params.merge!({:email => 'not-an-email'}) + valid_params.merge!({email: 'not-an-email'}) validator = ContactValidator.new(valid_params) validator.valid? expect(validator.errors[:email]).to include("Email doesn't look like a valid address") diff --git a/spec/validators/not_nil_validator_spec.rb b/spec/validators/not_nil_validator_spec.rb index 9b53c623d8..c334b0ebea 100644 --- a/spec/validators/not_nil_validator_spec.rb +++ b/spec/validators/not_nil_validator_spec.rb @@ -6,7 +6,7 @@ class Validatable attr_accessor :subject_attr - validates :subject_attr, :not_nil => true + validates :subject_attr, not_nil: true end class ValidatableCustomMessage @@ -15,34 +15,34 @@ class ValidatableCustomMessage attr_accessor :subject_attr - validates :subject_attr, :not_nil => { :message => 'Custom message' } + validates :subject_attr, not_nil: { message: 'Custom message' } end RSpec.describe NotNilValidator do it 'is valid when the subject_attr is not blank' do - subject = Validatable.new(:subject_attr => 'xyz') + subject = Validatable.new(subject_attr: 'xyz') expect(subject).to be_valid end it 'is valid when the subject_attr is blank' do - subject = Validatable.new(:subject_attr => '') + subject = Validatable.new(subject_attr: '') expect(subject).to be_valid end it 'is invalid when the subject_attr is nil' do - subject = Validatable.new(:subject_attr => nil) + subject = Validatable.new(subject_attr: nil) expect(subject).to_not be_valid end it 'sets a default error message' do - subject = Validatable.new(:subject_attr => nil) + subject = Validatable.new(subject_attr: nil) subject.valid? expect(subject.errors[:subject_attr]).to eq(["can't be nil"]) end it 'supports a custom error message' do - subject = ValidatableCustomMessage.new(:subject_attr => nil) + subject = ValidatableCustomMessage.new(subject_attr: nil) subject.valid? expect(subject.errors[:subject_attr]).to eq(['Custom message']) end diff --git a/spec/validators/reply_to_address_validator_spec.rb b/spec/validators/reply_to_address_validator_spec.rb index 09e3fcf88a..0745c6194d 100644 --- a/spec/validators/reply_to_address_validator_spec.rb +++ b/spec/validators/reply_to_address_validator_spec.rb @@ -37,7 +37,7 @@ described_class::DEFAULT_INVALID_REPLY_ADDRESSES end - it { is_expected.to eq(%W(a@example.com)) } + it { is_expected.to eq(%w(a@example.com)) } end end diff --git a/spec/views/admin_public_body/show.html.erb_spec.rb b/spec/views/admin_public_body/show.html.erb_spec.rb index b9cc3d95dc..b37574ef54 100644 --- a/spec/views/admin_public_body/show.html.erb_spec.rb +++ b/spec/views/admin_public_body/show.html.erb_spec.rb @@ -18,7 +18,7 @@ it 'does not display the API key' do with_feature_enabled(:alaveteli_pro) do allow(controller).to receive(:current_user).and_return(current_user) - render :template => 'admin_public_body/show', :locals => { :current_user => current_user } + render template: 'admin_public_body/show', locals: { current_user: current_user } expect(rendered).not_to match(Regexp.escape(public_body.api_key)) end end @@ -31,7 +31,7 @@ it 'displays the API key' do with_feature_enabled(:alaveteli_pro) do allow(controller).to receive(:current_user).and_return(current_user) - render :template => 'admin_public_body/show', :locals => { :current_user => current_user } + render template: 'admin_public_body/show', locals: { current_user: current_user } expect(rendered).to match(Regexp.escape(public_body.api_key)) end end diff --git a/spec/views/admin_request/_params.html.erb_spec.rb b/spec/views/admin_request/_params.html.erb_spec.rb index 7b97da6ab4..d0c88da634 100644 --- a/spec/views/admin_request/_params.html.erb_spec.rb +++ b/spec/views/admin_request/_params.html.erb_spec.rb @@ -2,26 +2,26 @@ RSpec.describe 'when showing diffs in info_request params' do def do_render(params) - render :partial => 'admin_request/params', :locals => {:params => params} + render partial: 'admin_request/params', locals: {params: params} end it 'should differentiate between old, new and other' do ire = InfoRequestEvent.new - ire.params = { :old_foo => 'this is stuff', :foo => 'stuff', :bar => 84 } + ire.params = { old_foo: 'this is stuff', foo: 'stuff', bar: 84 } do_render(ire.params_diff) expect(response.body.squish).to match("foo: this is stuff => stuff
    bar: 84
    ") end it "should convert linebreaks to '
    's" do ire = InfoRequestEvent.new - ire.params = { :old_foo => 'this\nis\nstuff', :foo => 'this\nstuff', :bar => 84 } + ire.params = { old_foo: 'this\nis\nstuff', foo: 'this\nstuff', bar: 84 } do_render(ire.params_diff) expect(response.body.squish).to match("foo: this
    is
    stuff => this
    stuff
    bar: 84
    ") end it 'should not report unchanged values as new' do ire = InfoRequestEvent.new - ire.params = { :old_foo => 'this is stuff', :foo => 'this is stuff', :bar => 84 } + ire.params = { old_foo: 'this is stuff', foo: 'this is stuff', bar: 84 } do_render(ire.params_diff) expect(response.body.squish).to match("bar: 84
    ") end diff --git a/spec/views/admin_user/show.html.erb_spec.rb b/spec/views/admin_user/show.html.erb_spec.rb index e6e42ba7f6..ce7aaa6515 100644 --- a/spec/views/admin_user/show.html.erb_spec.rb +++ b/spec/views/admin_user/show.html.erb_spec.rb @@ -6,6 +6,7 @@ info_requests = [] allow(info_requests).to receive(:total_pages).and_return(0) assign :info_requests, info_requests + assign :info_request_batches, [] assign :admin_user, user_being_viewed assign :comments, [] end @@ -17,7 +18,7 @@ it 'should not show the list of post redirects' do with_feature_enabled(:alaveteli_pro) do allow(controller).to receive(:current_user).and_return(current_user) - render :template => 'admin_user/show', :locals => { :current_user => current_user } + render template: 'admin_user/show', locals: { current_user: current_user } expect(rendered).not_to match('Post redirects') end end @@ -31,7 +32,7 @@ it 'should show the list of post redirects' do with_feature_enabled(:alaveteli_pro) do allow(controller).to receive(:current_user).and_return(current_user) - render :template => 'admin_user/show', :locals => { :current_user => current_user } + render template: 'admin_user/show', locals: { current_user: current_user } expect(rendered).to match('Post redirects') end end diff --git a/spec/views/alaveteli_pro/batch_request_authority_searches/_search_results.html.erb_spec.rb b/spec/views/alaveteli_pro/batch_request_authority_searches/_search_results.html.erb_spec.rb index 610c3ca2bd..5dc31ae3d3 100644 --- a/spec/views/alaveteli_pro/batch_request_authority_searches/_search_results.html.erb_spec.rb +++ b/spec/views/alaveteli_pro/batch_request_authority_searches/_search_results.html.erb_spec.rb @@ -4,8 +4,8 @@ let(:draft_batch_request) { AlaveteliPro::DraftInfoRequestBatch.new } def render_view(locals) - render(:partial => "alaveteli_pro/batch_request_authority_searches/search_results", - :locals => locals) + render(partial: "alaveteli_pro/batch_request_authority_searches/search_results", + locals: locals) end describe "when a search has been performed" do @@ -20,20 +20,20 @@ def render_view(locals) end describe "and there are some results" do - let(:search) { ActsAsXapian::Search.new([PublicBody], authority_1.name, :limit => 3 ) } + let(:search) { ActsAsXapian::Search.new([PublicBody], authority_1.name, limit: 3 ) } it "renders search results" do # TODO: This fails, as the view doesn't render anything, but I # can't figure out why. It passes if this example runs first! expect(search).to be_present expect(search.results).to be_present - render_view(:search => search, - :query => authority_1.name, - :draft_batch_request => draft_batch_request, - :body_ids_added => [], - :page => 1, - :per_page => 25, - :result_limit => 3) + render_view(search: search, + query: authority_1.name, + draft_batch_request: draft_batch_request, + body_ids_added: [], + page: 1, + per_page: 25, + result_limit: 3) expect(rendered).to have_text(authority_1.name) end end diff --git a/spec/views/alaveteli_pro/info_request_batches/_authority_list.html.erb_spec.rb b/spec/views/alaveteli_pro/info_request_batches/_authority_list.html.erb_spec.rb index 7869f2568d..795efdf0e9 100644 --- a/spec/views/alaveteli_pro/info_request_batches/_authority_list.html.erb_spec.rb +++ b/spec/views/alaveteli_pro/info_request_batches/_authority_list.html.erb_spec.rb @@ -15,7 +15,7 @@ def render_html_partial(public_bodies) it "escapes HTMLEntities in public body names" do render_html_partial(public_bodies) - # Note: using include not have_text to test the html entity is there + # NOTE: using include not have_text to test the html entity is there expect(response).to include("One & Two") expect(response).not_to include("One & Two") end diff --git a/spec/views/alaveteli_pro/info_request_batches/_authority_list.text.erb_spec.rb b/spec/views/alaveteli_pro/info_request_batches/_authority_list.text.erb_spec.rb index 94d04d3f97..cdf6ef3d08 100644 --- a/spec/views/alaveteli_pro/info_request_batches/_authority_list.text.erb_spec.rb +++ b/spec/views/alaveteli_pro/info_request_batches/_authority_list.text.erb_spec.rb @@ -17,7 +17,7 @@ def render_text_partial(public_bodies) it "doesn't escape HTMLEntities in public body names" do render_text_partial(public_bodies) - # Note: using include not have_text to test the html entity is not there + # NOTE: using include not have_text to test the html entity is not there expect(response).to include("One & Two") expect(response).not_to include("One & Two") end diff --git a/spec/views/alaveteli_pro/public_bodies/_search_result.html.erb_spec.rb b/spec/views/alaveteli_pro/public_bodies/_search_result.html.erb_spec.rb index 8fa17817d0..b3f587455d 100644 --- a/spec/views/alaveteli_pro/public_bodies/_search_result.html.erb_spec.rb +++ b/spec/views/alaveteli_pro/public_bodies/_search_result.html.erb_spec.rb @@ -1,9 +1,12 @@ require 'spec_helper' RSpec.describe 'alaveteli_pro/public_bodies/_search_result' do + let(:note) { 'Some notes about the body' } + let(:public_body) do - FactoryBot.create(:public_body, notes: "Some notes about the body", - info_requests_visible_count: 1) + FactoryBot.create(:public_body, :with_note, + note_body: note, + info_requests_visible_count: 1) end let(:result) do @@ -28,17 +31,21 @@ def render_view expect(rendered).to have_text public_body.notes_as_string end - it "truncates the body notes to 150 chars" do - public_body.notes = "This are some extravagantly long notes about a " \ - "body which will need to be trimmed down somewhat " \ - "before they're suitable for inclusion in a small " \ - "amount of space." - render_view - expected_notes = "This are some extravagantly long notes about a body " \ - "which will need to be trimmed down somewhat before " \ - "they're suitable for inclusion in a small am..." - expect(rendered).not_to have_text public_body.notes_as_string - expect(rendered).to have_text expected_notes + context 'long note' do + let(:note) do + "This are some extravagantly long notes about a body which will need " \ + "to be trimmed down somewhat before they're suitable for inclusion in " \ + "a small amount of space." + end + + it "truncates the body notes to 150 chars" do + render_view + expected_notes = "This are some extravagantly long notes about a body " \ + "which will need to be trimmed down somewhat before " \ + "they're suitable for inclusion in a small am..." + expect(rendered).not_to have_text public_body.notes_as_string + expect(rendered).to have_text expected_notes + end end it "includes the number of requests made" do diff --git a/spec/views/alaveteli_pro/subscriptions/_cancel_subscription.html.erb_spec.rb b/spec/views/alaveteli_pro/subscriptions/_cancel_subscription.html.erb_spec.rb index 4334e5969d..6dfa8b0019 100644 --- a/spec/views/alaveteli_pro/subscriptions/_cancel_subscription.html.erb_spec.rb +++ b/spec/views/alaveteli_pro/subscriptions/_cancel_subscription.html.erb_spec.rb @@ -13,7 +13,7 @@ def render_view let(:subscription) do double(id: 'sub_BWb9jBSSO0nafs', cancel_at_period_end: false, - current_period_end: 1509882971) + current_period_end: 1_509_882_971) end it 'sets the section heading' do @@ -47,7 +47,7 @@ def render_view let(:subscription) do double(id: 'sub_BWb9jBSSO0nafs', cancel_at_period_end: true, - current_period_end: 1509882971) + current_period_end: 1_509_882_971) end it 'sets the section heading' do diff --git a/spec/views/contact_mailer/user_message.text.erb_spec.rb b/spec/views/contact_mailer/user_message.text.erb_spec.rb index 9f1b5a8777..6d69176681 100644 --- a/spec/views/contact_mailer/user_message.text.erb_spec.rb +++ b/spec/views/contact_mailer/user_message.text.erb_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' RSpec.describe "contact_mailer/user_message" do - let(:user) { FactoryBot.create(:user, :name => "Test Us'r") } + let(:user) { FactoryBot.create(:user, name: "Test Us'r") } before do allow(AlaveteliConfiguration).to receive(:site_name). diff --git a/spec/views/general/_log_in_bar.html.erb_spec.rb b/spec/views/general/_log_in_bar.html.erb_spec.rb index 92d7c3f244..e917f89065 100644 --- a/spec/views/general/_log_in_bar.html.erb_spec.rb +++ b/spec/views/general/_log_in_bar.html.erb_spec.rb @@ -5,7 +5,7 @@ let(:pro_user) { FactoryBot.create(:pro_user) } def render_view - render :partial => 'general/log_in_bar' + render partial: 'general/log_in_bar' end describe 'user menu links', feature: :alaveteli_pro do diff --git a/spec/views/general/_opengraph_tags.html.erb_spec.rb b/spec/views/general/_opengraph_tags.html.erb_spec.rb index 8cfdaf752b..173e0bd1ca 100644 --- a/spec/views/general/_opengraph_tags.html.erb_spec.rb +++ b/spec/views/general/_opengraph_tags.html.erb_spec.rb @@ -3,7 +3,7 @@ RSpec.describe 'general/_opengraph_tags' do def render_view - render :partial => 'general/opengraph_tags' + render partial: 'general/opengraph_tags' end describe 'displaying the opengraph logo', feature: :alaveteli_pro do diff --git a/spec/views/general/_responsive_topnav.html.erb_spec.rb b/spec/views/general/_responsive_topnav.html.erb_spec.rb index 924aa89915..bfeee796b6 100644 --- a/spec/views/general/_responsive_topnav.html.erb_spec.rb +++ b/spec/views/general/_responsive_topnav.html.erb_spec.rb @@ -5,7 +5,7 @@ let(:pro_user) { FactoryBot.create(:pro_user) } def render_view - render :partial => 'general/responsive_topnav' + render partial: 'general/responsive_topnav' end describe 'showing the Dashboard link', feature: :alaveteli_pro do diff --git a/spec/views/general/blog.html.erb_spec.rb b/spec/views/general/blog.html.erb_spec.rb index ccc583ac2c..48bfd9ff06 100644 --- a/spec/views/general/blog.html.erb_spec.rb +++ b/spec/views/general/blog.html.erb_spec.rb @@ -4,39 +4,51 @@ subject { rendered } before do - assign :blog_items, blog_items + assign :blog, double(posts: [double(blog_post_attributes)]) assign :twitter_user, double.as_null_object assign :facebook_user, double.as_null_object render end context 'with a creator and date' do - let(:blog_items) do - [{ 'title' => 'foo', - 'link' => 'https://www.example.com/foo', - 'creator' => ['Bob'], - 'pubDate' => ['Mon, 01 Apr 2013 19:26:08 +0000'] }] + let(:blog_post_attributes) do + { + title: 'foo', + url: 'https://www.example.com/foo', + data: { + 'creator' => ['Bob'], + 'pubDate' => ['Mon, 01 Apr 2013 19:26:08 +0000'] + } + } end it { is_expected.to match(/Posted on.*April 01, 2013.*by Bob/) } end context 'with an author and date' do - let(:blog_items) do - [{ 'title' => 'foo', - 'link' => 'https://www.example.com/foo', - 'author' => ['Bob'], - 'pubDate' => ['Mon, 01 Apr 2013 19:26:08 +0000'] }] + let(:blog_post_attributes) do + { + title: 'foo', + url: 'https://www.example.com/foo', + data: { + 'author' => ['Bob'], + 'pubDate' => ['Mon, 01 Apr 2013 19:26:08 +0000'] + } + } end it { is_expected.to match(/Posted on.*April 01, 2013.*by Bob/) } end context 'with a date and no author or creator' do - let(:blog_items) do - [{ 'title' => 'foo', - 'link' => 'https://www.example.com/foo', - 'pubDate' => ['Mon, 01 Apr 2013 19:26:08 +0000'] }] + let(:blog_post_attributes) do + { + title: 'foo', + url: 'https://www.example.com/foo', + data: { + 'pubDate' => ['Mon, 01 Apr 2013 19:26:08 +0000'] + } + } end it { is_expected.to match(/Posted on.*April 01, 2013/) } diff --git a/spec/views/general/frontpage.html.erb_spec.rb b/spec/views/general/frontpage.html.erb_spec.rb index c207c180b8..1ff0f356b5 100644 --- a/spec/views/general/frontpage.html.erb_spec.rb +++ b/spec/views/general/frontpage.html.erb_spec.rb @@ -3,14 +3,14 @@ RSpec.describe "general/frontpage" do before do @pb = mock_model(PublicBody, - :name => 'Test Quango', - :short_name => 'tq', - :url_name => 'testquango', - :created_at => Time.now.utc, - :tags => [], - :special_not_requestable_reason? => false, - :eir_only? => nil, - :publication_scheme => '') + name: 'Test Quango', + short_name: 'tq', + url_name: 'testquango', + created_at: Time.now.utc, + tags: [], + special_not_requestable_reason?: false, + eir_only?: nil, + publication_scheme: '') pb_info_requests = [1, 2, 3, 4] allow(pb_info_requests).to receive(:visible).and_return([2, 3, 4]) @@ -38,7 +38,7 @@ it "should show the body's name" do render - expect(response).to have_css('a', :text => "Test Quango") + expect(response).to have_css('a', text: "Test Quango") end it "should show total number visible of requests" do diff --git a/spec/views/info_request_batch_mailer/batch_sent.text.spec_erb.rb b/spec/views/info_request_batch_mailer/batch_sent.text.spec_erb.rb index cd9e9a6941..80f6894786 100644 --- a/spec/views/info_request_batch_mailer/batch_sent.text.spec_erb.rb +++ b/spec/views/info_request_batch_mailer/batch_sent.text.spec_erb.rb @@ -4,7 +4,7 @@ let(:batch) do FactoryBot.create( :info_request_batch, - :title => "Request apostrophe's data") + title: "Request apostrophe's data") end before do @@ -28,8 +28,8 @@ end it "does not add HTMLEntities to unrequestable public body names" do - body_1 = FactoryBot.create(:public_body, :name => "Dave's Test Authority") - body_2 = FactoryBot.create(:public_body, :name => "Jo's Test Authority") + body_1 = FactoryBot.create(:public_body, name: "Dave's Test Authority") + body_2 = FactoryBot.create(:public_body, name: "Jo's Test Authority") assign(:info_request_batch, batch) assign(:unrequestable, [body_1, body_2]) render diff --git a/spec/views/notification_mailer/info_request_batches/messages/_response.text.erb_spec.rb b/spec/views/notification_mailer/info_request_batches/messages/_response.text.erb_spec.rb index a2734e01b0..73bbc9cf47 100644 --- a/spec/views/notification_mailer/info_request_batches/messages/_response.text.erb_spec.rb +++ b/spec/views/notification_mailer/info_request_batches/messages/_response.text.erb_spec.rb @@ -54,7 +54,7 @@ info_request = notification.info_request_event.info_request public_body_name = info_request.public_body.name incoming_message = notification.info_request_event.incoming_message - expected_url = incoming_message_url(incoming_message, :cachebust => true) + expected_url = incoming_message_url(incoming_message, cachebust: true) expected_text = "#{public_body_name}: #{expected_url}" expect(response).to have_text(expected_text) end diff --git a/spec/views/notification_mailer/overdue_notification.text.erb_spec.rb b/spec/views/notification_mailer/overdue_notification.text.erb_spec.rb index a358668dfd..dacafc3d2a 100644 --- a/spec/views/notification_mailer/overdue_notification.text.erb_spec.rb +++ b/spec/views/notification_mailer/overdue_notification.text.erb_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' RSpec.describe "notification_mailer/overdue_notification" do - let(:body) { FactoryBot.create(:public_body, :name => "Apostrophe's") } + let(:body) { FactoryBot.create(:public_body, name: "Apostrophe's") } let(:request) do FactoryBot.create(:info_request, - :public_body => body, - :title => "Request apostrophe's data") + public_body: body, + title: "Request apostrophe's data") end before do diff --git a/spec/views/notification_mailer/very_overdue_notification.text.erb_spec.rb b/spec/views/notification_mailer/very_overdue_notification.text.erb_spec.rb index 39ceefed4e..c77e12fd85 100644 --- a/spec/views/notification_mailer/very_overdue_notification.text.erb_spec.rb +++ b/spec/views/notification_mailer/very_overdue_notification.text.erb_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' RSpec.describe "notification_mailer/very_overdue_notification" do - let(:body) { FactoryBot.create(:public_body, :name => "Apostrophe's") } + let(:body) { FactoryBot.create(:public_body, name: "Apostrophe's") } let(:request) do FactoryBot.create(:info_request, - :public_body => body, - :title => "Request apostrophe's data") + public_body: body, + title: "Request apostrophe's data") end before do diff --git a/spec/views/public_body/list.html.erb_spec.rb b/spec/views/public_body/list.html.erb_spec.rb index cc2a29767f..da9196c594 100644 --- a/spec/views/public_body/list.html.erb_spec.rb +++ b/spec/views/public_body/list.html.erb_spec.rb @@ -3,15 +3,15 @@ RSpec.describe "public_body/list" do before do @pb = mock_model(PublicBody, - :name => 'Test Quango', - :short_name => 'tq', - :url_name => 'testquango', - :has_notes? => false, - :created_at => Time.now.utc, - :tags => [], - :special_not_requestable_reason? => false, - :eir_only? => nil, - :publication_scheme => '') + name: 'Test Quango', + short_name: 'tq', + url_name: 'testquango', + has_notes?: false, + created_at: Time.now.utc, + tags: [], + special_not_requestable_reason?: false, + eir_only?: nil, + publication_scheme: '') pb_info_requests = [1, 2, 3, 4] allow(pb_info_requests).to receive(:is_searchable).and_return([2, 3, 4]) @@ -35,7 +35,7 @@ it "should show the body's name" do render - expect(response).to have_css('div.head', :text => "Test Quango") + expect(response).to have_css('div.head', text: "Test Quango") end it "should show total number visible of requests" do diff --git a/spec/views/public_body/show.html.erb_spec.rb b/spec/views/public_body/show.html.erb_spec.rb index 66ab975a63..b2b692829f 100644 --- a/spec/views/public_body/show.html.erb_spec.rb +++ b/spec/views/public_body/show.html.erb_spec.rb @@ -3,16 +3,16 @@ RSpec.describe "public_body/show" do before do @pb = mock_model(PublicBody, - :name => 'Test Quango', - :short_name => 'tq', - :url_name => 'testquango', - :notes => '', - :tags => [], - :eir_only? => nil, - :info_requests => [1, 2, 3, 4], # out of sync with Xapian - :publication_scheme => '', - :disclosure_log => '', - :calculated_home_page => '') + name: 'Test Quango', + short_name: 'tq', + url_name: 'testquango', + notes: '', + tags: [], + eir_only?: nil, + info_requests: [1, 2, 3, 4], # out of sync with Xapian + publication_scheme: '', + disclosure_log: '', + calculated_home_page: '') allow(@pb).to receive(:not_subject_to_law?).and_return(false) allow(@pb).to receive(:is_requestable?).and_return(true) allow(@pb).to receive(:special_not_requestable_reason?).and_return(false) @@ -20,18 +20,18 @@ allow(@pb).to receive(:has_tag?).and_return(false) allow(@pb).to receive(:tag_string).and_return('') allow(@pb).to receive(:legislation).and_return(Legislation.default) - @xap = double(ActsAsXapian::Search, :matches_estimated => 2) + @xap = double(ActsAsXapian::Search, matches_estimated: 2) allow(@xap).to receive(:results).and_return([ - { :model => mock_event }, - { :model => mock_event } + { model: mock_event }, + { model: mock_event } ]) assign(:public_body, @pb) assign(:track_thing, mock_model(TrackThing, - :track_type => 'public_body_updates', - :public_body => @pb, - :params => {}) + track_type: 'public_body_updates', + public_body: @pb, + params: {}) ) assign(:xapian_requests, @xap) assign(:page, 1) @@ -46,7 +46,7 @@ it "should show the body's name" do render - expect(response).to have_css('h1', :text => "Test Quango") + expect(response).to have_css('h1', text: "Test Quango") end it "should tell total number of requests" do @@ -146,27 +146,27 @@ def mock_event mock_model( InfoRequestEvent, - :info_request => mock_model( + info_request: mock_model( InfoRequest, - :title => 'Title', - :url_title => 'title', - :display_status => 'waiting_response', - :calculate_status => 'waiting_response', - :public_body => @pb, - :is_external? => false, - :user => mock_model( + title: 'Title', + url_title: 'title', + display_status: 'waiting_response', + calculate_status: 'waiting_response', + public_body: @pb, + is_external?: false, + user: mock_model( User, - :name => 'Test User', - :url_name => 'testuser') + name: 'Test User', + url_name: 'testuser') ), - :incoming_message => nil, - :is_incoming_message? => false, - :outgoing_message => nil, - :is_outgoing_message? => false, - :comment => nil, - :is_comment? => false, - :event_type => 'sent', - :created_at => Time.zone.now - 4.days, - :search_text_main => '' + incoming_message: nil, + is_incoming_message?: false, + outgoing_message: nil, + is_outgoing_message?: false, + comment: nil, + is_comment?: false, + event_type: 'sent', + created_at: Time.zone.now - 4.days, + search_text_main: '' ) end diff --git a/spec/views/reports/new.erb_spec.rb b/spec/views/reports/new.erb_spec.rb index 162e53caf4..f30d79f7d8 100644 --- a/spec/views/reports/new.erb_spec.rb +++ b/spec/views/reports/new.erb_spec.rb @@ -24,7 +24,7 @@ context "reporting a comment" do let(:comment) do - FactoryBot.build(:comment, :info_request => info_request) + FactoryBot.build(:comment, info_request: info_request) end before :each do diff --git a/spec/views/request/_after_actions.html.erb_spec.rb b/spec/views/request/_after_actions.html.erb_spec.rb index c7d42fac5f..567a65c66e 100644 --- a/spec/views/request/_after_actions.html.erb_spec.rb +++ b/spec/views/request/_after_actions.html.erb_spec.rb @@ -18,7 +18,7 @@ end context 'if show_owner_update_status_action is true' do - before { locals.merge(show_owner_update_status_action: true) } + before { locals.merge!(show_owner_update_status_action: true) } it 'displays a link for the request owner to update the status of the request' do render partial: 'request/after_actions', locals: locals @@ -30,7 +30,7 @@ end context 'if show_owner_update_status_action is false' do - before { locals.merge(show_owner_update_status_action: false) } + before { locals.merge!(show_owner_update_status_action: false) } it 'does not display a link for the request owner to update the status of the request' do render partial: 'request/after_actions', locals: locals @@ -43,7 +43,7 @@ end context 'if show_other_user_update_status_action is true' do - before { locals.merge(show_other_user_update_status_action: true) } + before { locals.merge!(show_other_user_update_status_action: true) } it 'displays a link for anyone to update the status of the request' do render partial: 'request/after_actions', locals: locals @@ -55,7 +55,7 @@ end context 'if show_other_user_update_status_action is false' do - before { locals.merge(show_other_user_update_status_action: false) } + before { locals.merge!(show_other_user_update_status_action: false) } it 'does not display a link for anyone to update the status of the request' do render partial: 'request/after_actions', locals: locals @@ -90,8 +90,7 @@ render partial: 'request/after_actions', locals: locals expect(response.body).to have_css('ul.anyone_actions') do |div| - text = 'Add an annotation (to help the requester or others)' - expect(div).to have_css('a', text: text) + expect(div).to have_css('a', text: 'Add an annotation') end end end @@ -103,8 +102,7 @@ render partial: 'request/after_actions', locals: locals expect(response.body).to have_css('ul.anyone_actions') do |div| - text = 'Add an annotation (to help the requester or others)' - expect(div).not_to have_css('a', text: text) + expect(div).not_to have_css('a', text: 'Add an annotation') end end end @@ -114,8 +112,7 @@ render partial: 'request/after_actions', locals: locals expect(response.body).to have_css('ul.anyone_actions') do |div| - text = 'Add an annotation (to help the requester or others)' - expect(div).not_to have_css('a', text: text) + expect(div).not_to have_css('a', text: 'Add an annotation') end end end diff --git a/spec/views/request/_describe_state.html.erb_spec.rb b/spec/views/request/_describe_state.html.erb_spec.rb index f6df890701..f4902e91c2 100644 --- a/spec/views/request/_describe_state.html.erb_spec.rb +++ b/spec/views/request/_describe_state.html.erb_spec.rb @@ -15,7 +15,7 @@ def expect_no_radio_button(value) end def do_render - render :partial => 'request/describe_state', :locals => {:id_suffix => '1'} + render partial: 'request/describe_state', locals: {id_suffix: '1'} end before do @@ -34,12 +34,12 @@ def do_render describe 'if the request is not old and unclassified' do it 'should not show the form' do do_render - expect(response.body).not_to have_css('h2', :text => 'What best describes the status of this request now?') + expect(response.body).not_to have_css('h2', text: 'What best describes the status of this request now?') end it 'should give a link to login' do do_render - expect(response.body).to have_css('a', :text => 'sign in') + expect(response.body).to have_css('a', text: 'sign in') end end @@ -50,17 +50,17 @@ def do_render it 'should not show the form' do do_render - expect(response.body).not_to have_css('h2', :text => 'What best describes the status of this request now?') + expect(response.body).not_to have_css('h2', text: 'What best describes the status of this request now?') end it 'should show the form for someone else to classify the request' do do_render - expect(response.body).to have_css('h2', :text => 'We need your help') + expect(response.body).to have_css('h2', text: 'We need your help') end it 'should not give a link to login' do do_render - expect(response.body).not_to have_css('a', :text => 'sign in') + expect(response.body).not_to have_css('a', text: 'sign in') end end end @@ -129,7 +129,7 @@ def do_render it 'should show the text "The review has finished and overall:"' do do_render - expect(response).to have_css('p', :text => 'The review has finished and overall:') + expect(response).to have_css('p', text: 'The review has finished and overall:') end end diff --git a/spec/views/request/show.html.erb_spec.rb b/spec/views/request/show.html.erb_spec.rb index 74ba78978e..5e94b0cac0 100644 --- a/spec/views/request/show.html.erb_spec.rb +++ b/spec/views/request/show.html.erb_spec.rb @@ -2,25 +2,25 @@ RSpec.describe "request/show" do - let(:mock_body) { FactoryBot.create(:public_body, :name => "test body") } + let(:mock_body) { FactoryBot.create(:public_body, name: "test body") } let(:mock_user) do - FactoryBot.create(:user, :name => "test user", - :url_name => "test_user", - :profile_photo => nil) + FactoryBot.create(:user, name: "test user", + url_name: "test_user", + profile_photo: nil) end let(:admin_user) { FactoryBot.create(:admin_user) } let(:mock_request) do - FactoryBot.create(:info_request, :title => "Test request", - :public_body => mock_body, - :user => mock_user) + FactoryBot.create(:info_request, title: "Test request", + public_body: mock_body, + user: mock_user) end let(:mock_track) do - mock_model(TrackThing, :track_type => 'request_updates', - :info_request => mock_request) + mock_model(TrackThing, track_type: 'request_updates', + info_request: mock_request) end def request_page @@ -41,7 +41,7 @@ def request_page it "should show the request" do request_page - expect(rendered).to have_css("h1",:text => "Test request") + expect(rendered).to have_css("h1",text: "Test request") end describe "when told to show the top describe state form" do @@ -86,12 +86,12 @@ def request_page and_return(mock_response) request_page expected_url = new_request_incoming_followup_path( - :request_id => mock_request.id, - :incoming_message_id => mock_response.id) + request_id: mock_request.id, + incoming_message_id: mock_response.id) expect(response.body). to have_css( "a[href='#{expected_url}']", - :text => "send a follow up message") + text: "send a follow up message") end end @@ -102,11 +102,11 @@ def request_page it "should show a link to follow up the request without reference to a specific response" do request_page - expected_url = new_request_followup_path(:request_id => mock_request.id) + expected_url = new_request_followup_path(request_id: mock_request.id) expect(response.body). to have_css( "a[href='#{expected_url}']", - :text => "send a follow up message") + text: "send a follow up message") end end end @@ -130,7 +130,7 @@ def request_page it "should give a link to requesting an internal review" do expect(response.body).to have_css( "div#request_status", - :text => "requesting an internal review") + text: "requesting an internal review") end end @@ -144,7 +144,7 @@ def request_page it "should give a link to make a followup" do expect(response.body).to have_css( "div#request_status a", - :text => "send a follow up message") + text: "send a follow up message") end end end @@ -179,7 +179,7 @@ def request_page it 'should not give a link to requesting an internal review' do expect(rendered).not_to have_css( 'p#request_status', - :text => "requesting an internal review") + text: "requesting an internal review") end end @@ -193,13 +193,13 @@ def request_page it 'should not give a link to make a followup' do expect(rendered).not_to have_css( 'p#request_status a', - :text => "send a follow up message") + text: "send a follow up message") end it 'should not give a link to sign in (in the request status

    )' do expect(rendered).not_to have_css( 'p#request_status a', - :text => "sign in") + text: "sign in") end end end @@ -277,7 +277,7 @@ def request_page assign :track_thing, TrackThing.create_track_for_request(request_with_attachment) render expect(rendered).to have_css(".attachment .attachment__name") do |s| - expect(s).to contain /interesting.pdf/m + expect(s).to have_text(/interesting.html/m) end end end @@ -285,10 +285,10 @@ def request_page context "when there is a censor rule" do it "should replace the attachment name" do request_with_attachment.censor_rules.create!( - :text => "interesting.pdf", - :replacement => "Mouse.pdf", - :last_edit_editor => "unknown", - :last_edit_comment => "none") + text: "interesting.html", + replacement: "Mouse.html", + last_edit_editor: "unknown", + last_edit_comment: "none") assign :info_request, request_with_attachment assign :info_request_events, request_with_attachment.info_request_events assign :status, request_with_attachment.calculate_status @@ -300,7 +300,7 @@ def request_page # Note that the censor rule applies to the original filename, # not the display_filename: expect(rendered).to have_css(".attachment .attachment__name") do |s| - expect(s).to contain /Mouse.pdf/m + expect(s).to have_text(/Mouse.html/m) end end end diff --git a/spec/views/request_game/play.html.erb_spec.rb b/spec/views/request_game/play.html.erb_spec.rb index f69f9d4e82..ad58341bb3 100644 --- a/spec/views/request_game/play.html.erb_spec.rb +++ b/spec/views/request_game/play.html.erb_spec.rb @@ -3,24 +3,24 @@ RSpec.describe 'request_game/play' do before do - @mock_body = mock_model(PublicBody, :name => 'test body', - :url_name => 'test_body') - @mock_user = mock_model(User, :name => 'test user', - :url_name => 'test_user', - :profile_photo => nil) - @mock_request = mock_model(InfoRequest, :title => 'test request', - :awaiting_description => false, - :law_used_with_a => 'A Freedom of Information request', - :law_used_full => 'Freedom of Information', - :public_body => @mock_body, - :url_title => 'a_test_request', - :user => @mock_user, - :calculate_status => 'waiting_response', - :date_response_required_by => Date.current, - :prominence => 'normal', - :initial_request_text => 'hi there', - :display_status => 'Awaiting categorisation', - :created_at => Time.zone.now) + @mock_body = mock_model(PublicBody, name: 'test body', + url_name: 'test_body') + @mock_user = mock_model(User, name: 'test user', + url_name: 'test_user', + profile_photo: nil) + @mock_request = mock_model(InfoRequest, title: 'test request', + awaiting_description: false, + law_used_with_a: 'A Freedom of Information request', + law_used_full: 'Freedom of Information', + public_body: @mock_body, + url_title: 'a_test_request', + user: @mock_user, + calculate_status: 'waiting_response', + date_response_required_by: Date.current, + prominence: 'normal', + initial_request_text: 'hi there', + display_status: 'Awaiting categorisation', + created_at: Time.zone.now) assign :league_table_28_days, [] assign :league_table_all_time, [] assign :requests, [@mock_request] diff --git a/spec/views/request_mailer/comment_on_alert.text.erb_spec.rb b/spec/views/request_mailer/comment_on_alert.text.erb_spec.rb index ab082ede33..f037c2094b 100644 --- a/spec/views/request_mailer/comment_on_alert.text.erb_spec.rb +++ b/spec/views/request_mailer/comment_on_alert.text.erb_spec.rb @@ -2,8 +2,8 @@ RSpec.describe "request_mailer/comment_on_alert" do let(:request) { FactoryBot.create(:info_request) } - let(:user) { FactoryBot.create(:user, :name => "Test Us'r") } - let(:comment) { FactoryBot.create(:comment, :user => user) } + let(:user) { FactoryBot.create(:user, name: "Test Us'r") } + let(:comment) { FactoryBot.create(:comment, user: user) } before do allow(AlaveteliConfiguration).to receive(:site_name). diff --git a/spec/views/request_mailer/new_response_reminder_alert.text.erb_spec.rb b/spec/views/request_mailer/new_response_reminder_alert.text.erb_spec.rb index 4dbf666e9b..2b06a877d6 100644 --- a/spec/views/request_mailer/new_response_reminder_alert.text.erb_spec.rb +++ b/spec/views/request_mailer/new_response_reminder_alert.text.erb_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' RSpec.describe "request_mailer/new_response_reminder_alert" do - let(:request) { FactoryBot.create(:info_request, :title => "Apostrophe's") } + let(:request) { FactoryBot.create(:info_request, title: "Apostrophe's") } before do allow(AlaveteliConfiguration).to receive(:site_name). diff --git a/spec/views/request_mailer/not_clarified_alert.text.erb_spec.rb b/spec/views/request_mailer/not_clarified_alert.text.erb_spec.rb index 3a7fa57834..bfb3c94f77 100644 --- a/spec/views/request_mailer/not_clarified_alert.text.erb_spec.rb +++ b/spec/views/request_mailer/not_clarified_alert.text.erb_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' RSpec.describe "request_mailer/not_clarified_alert" do - let(:body) { FactoryBot.create(:public_body, :name => "Apostrophe's") } - let(:request) { FactoryBot.create(:info_request, :public_body => body) } + let(:body) { FactoryBot.create(:public_body, name: "Apostrophe's") } + let(:request) { FactoryBot.create(:info_request, public_body: body) } before do allow(AlaveteliConfiguration).to receive(:site_name). diff --git a/spec/views/request_mailer/old_unclassified_updated.text.erb_spec.rb b/spec/views/request_mailer/old_unclassified_updated.text.erb_spec.rb index 251ba3c4e5..309862bfa4 100644 --- a/spec/views/request_mailer/old_unclassified_updated.text.erb_spec.rb +++ b/spec/views/request_mailer/old_unclassified_updated.text.erb_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' RSpec.describe "request_mailer/old_unclassified_updated" do - let(:body) { FactoryBot.create(:public_body, :name => "Apostrophe's") } + let(:body) { FactoryBot.create(:public_body, name: "Apostrophe's") } let(:request) do FactoryBot.create(:info_request, - :public_body => body, - :title => "Request apostrophe's data") + public_body: body, + title: "Request apostrophe's data") end before do diff --git a/spec/views/request_mailer/overdue_alert.text.erb_spec.rb b/spec/views/request_mailer/overdue_alert.text.erb_spec.rb index c11053a699..3650abfaa7 100644 --- a/spec/views/request_mailer/overdue_alert.text.erb_spec.rb +++ b/spec/views/request_mailer/overdue_alert.text.erb_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' RSpec.describe "request_mailer/overdue_alert" do - let(:body) { FactoryBot.create(:public_body, :name => "Apostrophe's") } + let(:body) { FactoryBot.create(:public_body, name: "Apostrophe's") } let(:request) do FactoryBot.create(:info_request, - :public_body => body, - :title => "Request apostrophe's data") + public_body: body, + title: "Request apostrophe's data") end before do diff --git a/spec/views/request_mailer/stopped_responses.text.erb_spec.rb b/spec/views/request_mailer/stopped_responses.text.erb_spec.rb index 6d69b3d408..85ba074e51 100644 --- a/spec/views/request_mailer/stopped_responses.text.erb_spec.rb +++ b/spec/views/request_mailer/stopped_responses.text.erb_spec.rb @@ -1,13 +1,13 @@ require 'spec_helper' RSpec.describe "request_mailer/stopped_responses" do - let(:user) { FactoryBot.create(:user, :name => "Test Us'r") } - let(:body) { FactoryBot.create(:public_body, :name => "Apostrophe's") } + let(:user) { FactoryBot.create(:user, name: "Test Us'r") } + let(:body) { FactoryBot.create(:public_body, name: "Apostrophe's") } let(:request) do FactoryBot.create(:info_request, - :public_body => body, - :user => user, - :title => "Request apostrophe's data") + public_body: body, + user: user, + title: "Request apostrophe's data") end before do diff --git a/spec/views/request_mailer/very_overdue_alert.text.erb_spec.rb b/spec/views/request_mailer/very_overdue_alert.text.erb_spec.rb index c9f2b2e33d..b05b07257f 100644 --- a/spec/views/request_mailer/very_overdue_alert.text.erb_spec.rb +++ b/spec/views/request_mailer/very_overdue_alert.text.erb_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper' RSpec.describe "request_mailer/very_overdue_alert" do - let(:body) { FactoryBot.create(:public_body, :name => "Apostrophe's") } + let(:body) { FactoryBot.create(:public_body, name: "Apostrophe's") } let(:request) do FactoryBot.create(:info_request, - :public_body => body, - :title => "Request apostrophe's data") + public_body: body, + title: "Request apostrophe's data") end before do diff --git a/spec/views/track_mailer/event_digest.text.erb_spec.rb b/spec/views/track_mailer/event_digest.text.erb_spec.rb index f859c6b87d..b25c0132db 100644 --- a/spec/views/track_mailer/event_digest.text.erb_spec.rb +++ b/spec/views/track_mailer/event_digest.text.erb_spec.rb @@ -1,17 +1,17 @@ require 'spec_helper' RSpec.describe "track_mailer/event_digest" do - let(:user) { FactoryBot.create(:user, :name => "Test Us'r") } - let(:body) { FactoryBot.create(:public_body, :name => "Apostrophe's") } + let(:user) { FactoryBot.create(:user, name: "Test Us'r") } + let(:body) { FactoryBot.create(:public_body, name: "Apostrophe's") } let(:request) do FactoryBot.create(:info_request_with_incoming, - :public_body => body, - :user => user, - :title => "Request apostrophe's data") + public_body: body, + user: user, + title: "Request apostrophe's data") end - let(:track) { FactoryBot.create(:search_track, :tracking_user => user) } + let(:track) { FactoryBot.create(:search_track, tracking_user: user) } let(:xapian_search) do - double('xapian search', :results => [event], :words_to_highlight => 'test') + double('xapian search', results: [event], words_to_highlight: 'test') end before do @@ -22,26 +22,26 @@ describe "tracking a response" do let(:event) do FactoryBot.create(:response_event, - :incoming_message => request.incoming_messages.last, - :info_request => request) + incoming_message: request.incoming_messages.last, + info_request: request) end it "does not add HTMLEntities to the request title" do - result = { :model => event } + result = { model: event } assign(:email_about_things, [[track, [result], xapian_search]]) render expect(response).to match("-- Request apostrophe's data --") end it "does not add HTMLEntities to the public body name" do - result = { :model => event } + result = { model: event } assign(:email_about_things, [[track, [result], xapian_search]]) render expect(response).to match("Apostrophe's sent a response") end it "does not add HTMLEntities to the user name" do - result = { :model => event } + result = { model: event } assign(:email_about_things, [[track, [result], xapian_search]]) render expect(response).to match("sent a response to Test Us'r") @@ -62,27 +62,27 @@ describe "tracking a followup" do let(:event) do FactoryBot.create(:response_event, - :outgoing_message => request.outgoing_messages.last, - :info_request => request, - :event_type => 'followup_sent') + outgoing_message: request.outgoing_messages.last, + info_request: request, + event_type: 'followup_sent') end it "does not add HTMLEntities to the request title" do - result = { :model => event } + result = { model: event } assign(:email_about_things, [[track, [result], xapian_search]]) render expect(response).to match("-- Request apostrophe's data --") end it "does not add HTMLEntities to the public body name" do - result = { :model => event } + result = { model: event } assign(:email_about_things, [[track, [result], xapian_search]]) render expect(response).to match("message to Apostrophe's") end it "does not add HTMLEntities to the user name" do - result = { :model => event } + result = { model: event } assign(:email_about_things, [[track, [result], xapian_search]]) render expect(response).to match("Test Us'r sent a follow up message") @@ -91,24 +91,24 @@ describe "tracking a comment" do let(:comment) do - FactoryBot.create(:comment, :info_request => request, :user => user) + FactoryBot.create(:comment, info_request: request, user: user) end let(:event) do FactoryBot.create(:info_request_event, - :comment => comment, - :info_request => request, - :event_type => 'comment') + comment: comment, + info_request: request, + event_type: 'comment') end it "does not add HTMLEntities to the request title" do - result = { :model => event } + result = { model: event } assign(:email_about_things, [[track, [result], xapian_search]]) render expect(response).to match("-- Request apostrophe's data --") end it "does not add HTMLEntities to the user name" do - result = { :model => event } + result = { model: event } assign(:email_about_things, [[track, [result], xapian_search]]) render expect(response).to match("Test Us'r added an annotation") @@ -119,27 +119,27 @@ describe "tracking a sent event" do let(:event) do FactoryBot.create(:info_request_event, - :outgoing_message => request.outgoing_messages.last, - :info_request => request, - :event_type => 'sent') + outgoing_message: request.outgoing_messages.last, + info_request: request, + event_type: 'sent') end it "does not add HTMLEntities to the request title" do - result = { :model => event } + result = { model: event } assign(:email_about_things, [[track, [result], xapian_search]]) render expect(response).to match("-- Request apostrophe's data --") end it "does not add HTMLEntities to the public body name" do - result = { :model => event } + result = { model: event } assign(:email_about_things, [[track, [result], xapian_search]]) render expect(response).to match("request to Apostrophe's") end it "does not add HTMLEntities to the user name" do - result = { :model => event } + result = { model: event } assign(:email_about_things, [[track, [result], xapian_search]]) render expect(response).to match("Test Us'r sent a request") diff --git a/spec/views/user/_user_listing_single.html.erb_spec.rb b/spec/views/user/_user_listing_single.html.erb_spec.rb index 8964cec8f2..19bf862b50 100644 --- a/spec/views/user/_user_listing_single.html.erb_spec.rb +++ b/spec/views/user/_user_listing_single.html.erb_spec.rb @@ -9,24 +9,24 @@ end def render_view - render :partial => 'user/user_listing_single', - :locals => { :display_user => user } + render partial: 'user/user_listing_single', + locals: { display_user: user } end it 'displays a normal request' do - FactoryBot.create(:info_request, :user => user) + FactoryBot.create(:info_request, user: user) render_view expect(rendered).to have_text '1 request made' end it 'does not display an embargoed request' do - FactoryBot.create(:embargoed_request, :user => user) + FactoryBot.create(:embargoed_request, user: user) render_view expect(rendered).to have_text '0 requests made' end it 'does not display a hidden request' do - FactoryBot.create(:hidden_request, :user => user) + FactoryBot.create(:hidden_request, user: user) render_view expect(rendered).to have_text '0 requests made' end diff --git a/spec/views/user/sign.html.erb_spec.rb b/spec/views/user/sign.html.erb_spec.rb index c90100d472..9909772456 100644 --- a/spec/views/user/sign.html.erb_spec.rb +++ b/spec/views/user/sign.html.erb_spec.rb @@ -5,14 +5,14 @@ before do html_title = "test's \"title\" of many HTML tags &c" @rendered_title = 'test's "title" of many HTML tags &c' - request = FactoryBot.create(:info_request, :title => html_title) + request = FactoryBot.create(:info_request, title: html_title) tracker = FactoryBot.create(:request_update_track, - :info_request => request, - :track_medium => 'email_daily', - :track_query => 'test') - redirect = PostRedirect.create(:uri => '/request/test', - :post_params => {}, - :reason_params => tracker.params) + info_request: request, + track_medium: 'email_daily', + track_query: 'test') + redirect = PostRedirect.create(uri: '/request/test', + post_params: {}, + reason_params: tracker.params) assign :post_redirect, redirect end @@ -25,11 +25,11 @@ describe 'when the requested URI is for an admin page and an emergency user exists' do before do - redirect = PostRedirect.create(:uri => 'http://bad.place.com/admin', - :post_params => {'controller' => 'admin_general'}, - :reason_params => {:web => '', - :user_name => 'Admin user', - :user_url => 'users/admin_user'}) + redirect = PostRedirect.create(uri: 'http://bad.place.com/admin', + post_params: {'controller' => 'admin_general'}, + reason_params: {web: '', + user_name: 'Admin user', + user_url: 'users/admin_user'}) receive(:disable_emergency_user).and_return(false) assign :post_redirect, redirect end diff --git a/spec/views/user_mailer/already_registered.text.erb_spec.rb b/spec/views/user_mailer/already_registered.text.erb_spec.rb index 064ce6cfa1..40add5c964 100644 --- a/spec/views/user_mailer/already_registered.text.erb_spec.rb +++ b/spec/views/user_mailer/already_registered.text.erb_spec.rb @@ -8,7 +8,7 @@ end it "does not add HTMLEntities to the site name" do - assign(:reasons, { :email => "mailto:nospam@example.com" } ) + assign(:reasons, { email: "mailto:nospam@example.com" } ) render expect(response).to match("the l'Information team") expect(response).to match("You just tried to sign up to l'Information") diff --git a/spec/views/user_mailer/confirm_login.text.erb_spec.rb b/spec/views/user_mailer/confirm_login.text.erb_spec.rb index c550105fd0..23813edb4c 100644 --- a/spec/views/user_mailer/confirm_login.text.erb_spec.rb +++ b/spec/views/user_mailer/confirm_login.text.erb_spec.rb @@ -8,7 +8,7 @@ end it "does not add HTMLEntities to the site name" do - assign(:reasons, { :email => "nospam@example.com" } ) + assign(:reasons, { email: "nospam@example.com" } ) render expect(response).to match("the l'Information team") end