diff --git a/.rubocop.yml b/.rubocop.yml index ed46718de37..50fcdb8f327 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -244,6 +244,7 @@ Rails/CreateTableWithTimestamps: Exclude: - "db/migrate/201[5-8]*" - "db/migrate/*install_audited.rb" + - "db/migrate/*create_active_storage_variant_records.active_storage.rb" Rails/Date: Enabled: true diff --git a/Gemfile b/Gemfile index 8288f259d9c..f820141c6d6 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,6 @@ source "https://rubygems.org" -gem "rails", "6.0.6.1" +gem "rails", "6.1.7.4" gem "acts-as-taggable-on", "~> 9.0.1" gem "acts_as_votable", "~> 0.13.2" @@ -84,14 +84,13 @@ group :development, :test do end group :test do - gem "capybara", "~> 3.37.1" + gem "capybara", "~> 3.39.2" gem "capybara-webmock", "~> 0.7.0" gem "email_spec", "~> 2.2.0" gem "rspec-rails", "~> 5.1.2" - gem "selenium-webdriver", "~> 4.0.0" + gem "selenium-webdriver", "~> 4.11.0" gem "simplecov", "~> 0.21.2", require: false gem "simplecov-lcov", "~> 0.8.0", require: false - gem "webdrivers", "~> 4.7.0" end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index c9a8a8833c2..3975e1b6d50 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,61 +6,65 @@ GEM GEM remote: https://rubygems.org/ specs: - actioncable (6.0.6.1) - actionpack (= 6.0.6.1) + actioncable (6.1.7.4) + actionpack (= 6.1.7.4) + activesupport (= 6.1.7.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.0.6.1) - actionpack (= 6.0.6.1) - activejob (= 6.0.6.1) - activerecord (= 6.0.6.1) - activestorage (= 6.0.6.1) - activesupport (= 6.0.6.1) + actionmailbox (6.1.7.4) + actionpack (= 6.1.7.4) + activejob (= 6.1.7.4) + activerecord (= 6.1.7.4) + activestorage (= 6.1.7.4) + activesupport (= 6.1.7.4) mail (>= 2.7.1) - actionmailer (6.0.6.1) - actionpack (= 6.0.6.1) - actionview (= 6.0.6.1) - activejob (= 6.0.6.1) + actionmailer (6.1.7.4) + actionpack (= 6.1.7.4) + actionview (= 6.1.7.4) + activejob (= 6.1.7.4) + activesupport (= 6.1.7.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.0.6.1) - actionview (= 6.0.6.1) - activesupport (= 6.0.6.1) - rack (~> 2.0, >= 2.0.8) + actionpack (6.1.7.4) + actionview (= 6.1.7.4) + activesupport (= 6.1.7.4) + rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.0.6.1) - actionpack (= 6.0.6.1) - activerecord (= 6.0.6.1) - activestorage (= 6.0.6.1) - activesupport (= 6.0.6.1) + actiontext (6.1.7.4) + actionpack (= 6.1.7.4) + activerecord (= 6.1.7.4) + activestorage (= 6.1.7.4) + activesupport (= 6.1.7.4) nokogiri (>= 1.8.5) - actionview (6.0.6.1) - activesupport (= 6.0.6.1) + actionview (6.1.7.4) + activesupport (= 6.1.7.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.0.6.1) - activesupport (= 6.0.6.1) + activejob (6.1.7.4) + activesupport (= 6.1.7.4) globalid (>= 0.3.6) - activemodel (6.0.6.1) - activesupport (= 6.0.6.1) - activerecord (6.0.6.1) - activemodel (= 6.0.6.1) - activesupport (= 6.0.6.1) - activestorage (6.0.6.1) - actionpack (= 6.0.6.1) - activejob (= 6.0.6.1) - activerecord (= 6.0.6.1) + activemodel (6.1.7.4) + activesupport (= 6.1.7.4) + activerecord (6.1.7.4) + activemodel (= 6.1.7.4) + activesupport (= 6.1.7.4) + activestorage (6.1.7.4) + actionpack (= 6.1.7.4) + activejob (= 6.1.7.4) + activerecord (= 6.1.7.4) + activesupport (= 6.1.7.4) marcel (~> 1.0) - activesupport (6.0.6.1) + mini_mime (>= 1.1.0) + activesupport (6.1.7.4) concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 0.7, < 2) - minitest (~> 5.1) - tzinfo (~> 1.1) - zeitwerk (~> 2.2, >= 2.2.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) acts-as-taggable-on (9.0.1) activerecord (>= 6.0, < 7.1) acts_as_votable (0.13.2) @@ -125,7 +129,7 @@ GEM capistrano (~> 3.7) capistrano-bundler puma (>= 4.0, < 6.0) - capybara (3.37.1) + capybara (3.39.2) addressable matrix mini_mime (>= 0.1.3) @@ -150,7 +154,6 @@ GEM actionpack (>= 3.1) caxlsx (>= 3.0) chef-utils (16.4.41) - childprocess (4.1.0) chronic (0.10.2) ckeditor (4.3.0) orm_adapter (~> 0.5.0) @@ -450,20 +453,20 @@ GEM rack rack-test (2.1.0) rack (>= 1.3) - rails (6.0.6.1) - actioncable (= 6.0.6.1) - actionmailbox (= 6.0.6.1) - actionmailer (= 6.0.6.1) - actionpack (= 6.0.6.1) - actiontext (= 6.0.6.1) - actionview (= 6.0.6.1) - activejob (= 6.0.6.1) - activemodel (= 6.0.6.1) - activerecord (= 6.0.6.1) - activestorage (= 6.0.6.1) - activesupport (= 6.0.6.1) - bundler (>= 1.3.0) - railties (= 6.0.6.1) + rails (6.1.7.4) + actioncable (= 6.1.7.4) + actionmailbox (= 6.1.7.4) + actionmailer (= 6.1.7.4) + actionpack (= 6.1.7.4) + actiontext (= 6.1.7.4) + actionview (= 6.1.7.4) + activejob (= 6.1.7.4) + activemodel (= 6.1.7.4) + activerecord (= 6.1.7.4) + activestorage (= 6.1.7.4) + activesupport (= 6.1.7.4) + bundler (>= 1.15.0) + railties (= 6.1.7.4) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) @@ -473,12 +476,12 @@ GEM rails-i18n (6.0.0) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 7) - railties (6.0.6.1) - actionpack (= 6.0.6.1) - activesupport (= 6.0.6.1) + railties (6.1.7.4) + actionpack (= 6.1.7.4) + activesupport (= 6.1.7.4) method_source - rake (>= 0.8.7) - thor (>= 0.20.3, < 2.0) + rake (>= 12.2) + thor (~> 1.0) rainbow (3.1.1) rake (13.0.6) rb-fsevent (0.10.4) @@ -578,10 +581,10 @@ GEM faraday (>= 0.17.3, < 3) scss_lint (0.59.0) sass (~> 3.5, >= 3.5.5) - selenium-webdriver (4.0.3) - childprocess (>= 0.5, < 5.0) + selenium-webdriver (4.11.0) rexml (~> 3.2, >= 3.2.5) - rubyzip (>= 1.2.2) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) simplecov (0.21.2) docile (~> 1.1) simplecov-html (~> 0.11) @@ -617,7 +620,6 @@ GEM terrapin (0.6.0) climate_control (>= 0.0.3, < 1.0) thor (1.2.1) - thread_safe (0.3.6) tilt (2.0.10) tomlrb (1.3.0) turbolinks (5.2.1) @@ -628,8 +630,8 @@ GEM rack (>= 1.3, < 3) rack-accept (~> 0.4) tilt (>= 1.4, < 3) - tzinfo (1.2.11) - thread_safe (~> 0.1) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) unicode-display_width (2.2.0) @@ -650,11 +652,8 @@ GEM activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webdrivers (4.7.0) - nokogiri (~> 1.6) - rubyzip (>= 1.3.0) - selenium-webdriver (> 3.141, < 5.0) webrick (1.8.1) + websocket (1.2.9) websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) @@ -687,7 +686,7 @@ DEPENDENCIES capistrano-rails (~> 1.6.2) capistrano3-delayed-job (~> 1.7.6) capistrano3-puma (~> 5.2.0) - capybara (~> 3.37.1) + capybara (~> 3.39.2) capybara-webmock (~> 0.7.0) caxlsx (~> 3.2.0) caxlsx_rails (~> 0.6.3) @@ -739,7 +738,7 @@ DEPENDENCIES pronto-rubocop (~> 0.11.2) pronto-scss (~> 0.11.0) puma (~> 4.3.12) - rails (= 6.0.6.1) + rails (= 6.1.7.4) rails-assets-markdown-it (~> 9.0.1)! recipient_interceptor (~> 0.3.1) redcarpet (~> 3.5.1) @@ -755,7 +754,7 @@ DEPENDENCIES sassc-rails (~> 2.1.2) savon (~> 2.13.0) scss_lint (~> 0.59.0) - selenium-webdriver (~> 4.0.0) + selenium-webdriver (~> 4.11.0) simplecov (~> 0.21.2) simplecov-lcov (~> 0.8.0) sitemap_generator (~> 6.3.0) @@ -769,7 +768,6 @@ DEPENDENCIES uuidtools (~> 2.2.0) view_component (~> 2.78.0) web-console (~> 4.2.0) - webdrivers (~> 4.7.0) whenever (~> 1.0.0) wicked_pdf (~> 2.6.3) wkhtmltopdf-binary (~> 0.12.6) diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb index f67f1be0c59..88ac41b0f25 100644 --- a/app/controllers/account_controller.rb +++ b/app/controllers/account_controller.rb @@ -10,7 +10,7 @@ def update if @account.update(account_params) redirect_to account_path, notice: t("flash.actions.save_changes.notice") else - @account.errors.messages.delete(:organization) + @account.errors.delete(:organization) render :show end end diff --git a/app/controllers/organizations/registrations_controller.rb b/app/controllers/organizations/registrations_controller.rb index 7b37ee7c246..544432a84d1 100644 --- a/app/controllers/organizations/registrations_controller.rb +++ b/app/controllers/organizations/registrations_controller.rb @@ -13,7 +13,7 @@ def create if resource.valid? super do |user| # Removes unuseful "organization is invalid" error message - user.errors.messages.delete(:organization) + user.errors.delete(:organization) end else render :new diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index d33854784a6..bc997297b55 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -11,7 +11,7 @@ def show @cards = @custom_page.cards render action: :custom_page else - render action: params[:id] + render action: params[:id].split(".").first end rescue ActionView::MissingTemplate head :not_found, content_type: "text/html" diff --git a/bin/setup b/bin/setup index 5635f8ec152..50fe751989f 100755 --- a/bin/setup +++ b/bin/setup @@ -9,8 +9,8 @@ def system!(*args) end FileUtils.chdir APP_ROOT do - # This script is a way to setup or update your development environment automatically. - # This script is idempotent, so that you can run it at anytime and get an expectable outcome. + # This script is a way to set up or update your development environment automatically. + # This script is idempotent, so that you can run it at any time and get an expectable outcome. # Add necessary setup steps to this file. puts "== Installing dependencies ==" diff --git a/config.ru b/config.ru index 193e5fed8d6..4a3c09a6889 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,6 @@ # This file is used by Rack-based servers to start the application. -require ::File.expand_path("../config/environment", __FILE__) +require_relative "config/environment" + run Rails.application +Rails.application.load_server diff --git a/config/application.rb b/config/application.rb index 9391b39fa9f..0aa2faf58df 100644 --- a/config/application.rb +++ b/config/application.rb @@ -21,15 +21,12 @@ module Consul class Application < Rails::Application - config.load_defaults 6.0 + config.load_defaults 6.1 # Keep belongs_to fields optional by default, because that's the way # Rails 4 models worked config.active_record.belongs_to_required_by_default = false - # Use local forms with `form_with`, so it works like `form_for` - config.action_view.form_with_generates_remote_forms = false - # Keep using AES-256-CBC for message encryption in case it's used # in any CONSUL DEMOCRACY installations config.active_support.use_authenticated_message_encryption = false @@ -38,10 +35,9 @@ class Application < Rails::Application # should work with zeitwerk config.autoloader = :classic - # Use the default queue for ActiveStorage like we were doing with Rails 5.2 - # because it will also be the default in Rails 6.1. - config.active_storage.queues.analysis = nil - config.active_storage.queues.purge = nil + # Don't enable has_many_inversing because it doesn't seem to currently + # work with the _count database columns we use for caching purposes + config.active_record.has_many_inversing = false # Keep reading existing data in the legislation_annotations ranges column config.active_record.yaml_column_permitted_classes = [ActiveSupport::HashWithIndifferentAccess, Symbol] @@ -55,7 +51,7 @@ class Application < Rails::Application # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - # config.time_zone = 'Central Time (US & Canada)' + config.time_zone = "Madrid" # 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] @@ -123,7 +119,6 @@ class Application < Rails::Application # Add lib to the autoload path config.autoload_paths << Rails.root.join("lib") - config.time_zone = "Madrid" config.active_job.queue_adapter = :delayed_job # CONSUL DEMOCRACY specific custom overrides diff --git a/config/environments/development.rb b/config/environments/development.rb index d3adf353f15..704a1e63e57 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,10 +1,11 @@ Warning[:deprecated] = true +require "active_support/core_ext/integer/time" Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # In the development environment your application's code is reloaded on - # every request. This slows down response time but is perfect for development + # In the development environment your application's code is reloaded any time + # it changes. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false @@ -45,6 +46,12 @@ # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load @@ -60,7 +67,10 @@ config.assets.quiet = true # Raises error for missing translations. - # config.action_view.raise_on_missing_translations = true + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true config.action_mailer.preview_path = "#{Rails.root}/spec/mailers/previews" @@ -81,6 +91,9 @@ # 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 end require Rails.root.join("config", "environments", "custom", "development") diff --git a/config/environments/production.rb b/config/environments/production.rb index 47c8ac22ad1..4f0bc2fa3aa 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,3 +1,5 @@ +require "active_support/core_ext/integer/time" + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. @@ -35,7 +37,7 @@ config.assets.compile = false # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = "http://assets.example.com" + # config.asset_host = "http://assets.example.com" # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache @@ -50,8 +52,8 @@ # Configure force_ssl in secrets.yml config.force_ssl = Rails.application.secrets.force_ssl - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. + # Include generic and useful information about system operation, but avoid logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). config.log_level = :warn # Prepend all log lines with the following tags. @@ -84,6 +86,12 @@ # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify + # Log disallowed deprecations. + config.active_support.disallowed_deprecation = :log + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new diff --git a/config/environments/staging.rb b/config/environments/staging.rb index 87c57f36d52..947d33ed050 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -1,3 +1,5 @@ +require "active_support/core_ext/integer/time" + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. @@ -35,7 +37,7 @@ config.assets.compile = false # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = "http://assets.example.com" + # config.asset_host = "http://assets.example.com" # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache @@ -50,8 +52,8 @@ # Configure force_ssl in secrets.yml config.force_ssl = Rails.application.secrets.force_ssl - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. + # Include generic and useful information about system operation, but avoid logging too much + # information to avoid inadvertent exposure of personally identifiable information (PII). config.log_level = :debug # Prepend all log lines with the following tags. @@ -63,6 +65,7 @@ # Use a real queuing backend for Active Job (and separate queues per environment). # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "consul_#{Rails.env}" + config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. @@ -83,6 +86,12 @@ # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify + # Log disallowed deprecations. + config.active_support.disallowed_deprecation = :log + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new diff --git a/config/environments/test.rb b/config/environments/test.rb index 64c8b75199e..5787afca2e1 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,3 +1,5 @@ +require "active_support/core_ext/integer/time" + # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped @@ -51,8 +53,17 @@ # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr + # Raise exceptions for disallowed deprecations. + config.active_support.disallowed_deprecation = :raise + + # Tell Active Support which deprecation messages to disallow. + config.active_support.disallowed_deprecation_warnings = [] + # Raises error for missing translations. - # config.action_view.raise_on_missing_translations = true + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true # Limit size of local logs # TODO: replace with config.log_file_size after upgrading to Rails 7.1 diff --git a/config/initializers/acts_as_taggable_on.rb b/config/initializers/acts_as_taggable_on.rb index a3ebeb85374..d661338bba1 100644 --- a/config/initializers/acts_as_taggable_on.rb +++ b/config/initializers/acts_as_taggable_on.rb @@ -5,8 +5,7 @@ module ActsAsTaggableOn scope :public_for_api, -> do where( - # TODO: remove default_scoped after upgrading to Rails 6.1 - tag: Tag.default_scoped.where(kind: [nil, "category"]), + tag: Tag.where(kind: [nil, "category"]), taggable: [Debate.public_for_api, Proposal.public_for_api] ) end diff --git a/config/initializers/backtrace_silencers.rb b/config/initializers/backtrace_silencers.rb index 59385cdf379..33699c30910 100644 --- a/config/initializers/backtrace_silencers.rb +++ b/config/initializers/backtrace_silencers.rb @@ -1,7 +1,8 @@ # Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. -# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } +# Rails.backtrace_cleaner.add_silencer { |line| /my_noisy_library/.match?(line) } -# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. -# Rails.backtrace_cleaner.remove_silencers! +# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code +# by setting BACKTRACE=1 before calling your invocation, like "BACKTRACE=1 ./bin/rails runner 'MyClass.perform'". +Rails.backtrace_cleaner.remove_silencers! if ENV["BACKTRACE"] diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 4a994e1e7bb..4b34a036689 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,4 +1,6 @@ # Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. -Rails.application.config.filter_parameters += [:password] +Rails.application.config.filter_parameters += [ + :passw, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn +] diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb new file mode 100644 index 00000000000..00f64d71b03 --- /dev/null +++ b/config/initializers/permissions_policy.rb @@ -0,0 +1,11 @@ +# Define an application-wide HTTP permissions policy. For further +# information see https://developers.google.com/web/updates/2018/06/feature-policy +# +# Rails.application.config.permissions_policy do |f| +# f.camera :none +# f.gyroscope :none +# f.microphone :none +# f.usb :none +# f.fullscreen :self +# f.payment :self, "https://secure.example.com" +# end diff --git a/config/initializers/wicked_pdf.rb b/config/initializers/wicked_pdf.rb index 6befcabeb47..8a4ead8eebd 100644 --- a/config/initializers/wicked_pdf.rb +++ b/config/initializers/wicked_pdf.rb @@ -1,27 +1,3 @@ -class WickedPdf - # Wicked Pdf magic breaks ViewComponent - # https://github.com/mileszs/wicked_pdf/pull/925 - module PdfHelper - def render(*args) - options = args.first - if options.is_a?(Hash) && options.key?(:pdf) - render_with_wicked_pdf(options) - else - super - end - end - - def render_to_string(*args) - options = args.first - if options.is_a?(Hash) && options.key?(:pdf) - render_to_string_with_wicked_pdf(options) - else - super - end - end - end -end - # WickedPDF Global Configuration # # Use this to set up shared configuration options for your entire application. diff --git a/db/migrate/20210924190647_add_service_name_to_active_storage_blobs.active_storage.rb b/db/migrate/20210924190647_add_service_name_to_active_storage_blobs.active_storage.rb new file mode 100644 index 00000000000..9967a132370 --- /dev/null +++ b/db/migrate/20210924190647_add_service_name_to_active_storage_blobs.active_storage.rb @@ -0,0 +1,18 @@ +# This migration comes from active_storage (originally 20190112182829) +class AddServiceNameToActiveStorageBlobs < ActiveRecord::Migration[6.0] + def up + unless column_exists?(:active_storage_blobs, :service_name) + add_column :active_storage_blobs, :service_name, :string + + if configured_service = ActiveStorage::Blob.service.name + ActiveStorage::Blob.unscoped.update_all(service_name: configured_service) + end + + change_column :active_storage_blobs, :service_name, :string, null: false + end + end + + def down + remove_column :active_storage_blobs, :service_name + end +end diff --git a/db/migrate/20210924190648_create_active_storage_variant_records.active_storage.rb b/db/migrate/20210924190648_create_active_storage_variant_records.active_storage.rb new file mode 100644 index 00000000000..fb6e2b01758 --- /dev/null +++ b/db/migrate/20210924190648_create_active_storage_variant_records.active_storage.rb @@ -0,0 +1,12 @@ +# This migration comes from active_storage (originally 20191206030411) +class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0] + def change + create_table :active_storage_variant_records do |t| + t.belongs_to :blob, null: false, index: false + t.string :variation_digest, null: false + + t.index %i[blob_id variation_digest], name: "index_active_storage_variant_records_uniqueness", unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 165b1ffa762..11ebacaa945 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -2,8 +2,8 @@ # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # -# This file is the source Rails uses to define your schema when running `rails -# db:schema:load`. When creating a new database, `rails db:schema:load` tends to +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to # be faster and is potentially less error prone than running all of your # migrations from scratch. Old migrations may fail to apply correctly if those # migrations use external dependencies or application code. @@ -50,9 +50,16 @@ t.bigint "byte_size", null: false t.string "checksum", null: false t.datetime "created_at", null: false + t.string "service_name", null: false t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true end + create_table "active_storage_variant_records", force: :cascade do |t| + t.bigint "blob_id", null: false + t.string "variation_digest", null: false + t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true + end + create_table "activities", id: :serial, force: :cascade do |t| t.integer "user_id" t.string "action" @@ -1776,6 +1783,7 @@ end add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" + add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" add_foreign_key "administrators", "users" add_foreign_key "budget_administrators", "administrators" add_foreign_key "budget_administrators", "budgets" diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 170c2e78aea..1b8180aa7c5 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -54,22 +54,20 @@ def within(...) FactoryBot.use_parent_strategy = false Capybara.register_driver :headless_chrome do |app| - capabilities = Selenium::WebDriver::Remote::Capabilities.chrome( - "goog:chromeOptions" => { - args: %W[headless no-sandbox window-size=1200,800 proxy-server=#{Capybara.app_host}:#{Capybara::Webmock.port_number}] - } - ) + options = Selenium::WebDriver::Chrome::Options.new.tap do |opts| + opts.add_argument "--headless" + opts.add_argument "--no-sandbox" + opts.add_argument "--window-size=1200,800" + opts.add_argument "--proxy-server=#{Capybara.app_host}:#{Capybara::Webmock.port_number}" + end - Capybara::Selenium::Driver.new( - app, - browser: :chrome, - capabilities: capabilities - ) + Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) end Capybara.exact = true Capybara.enable_aria_label = true Capybara.disable_animation = true +Capybara.app_host ||= "http://127.0.0.1" OmniAuth.config.test_mode = true diff --git a/spec/shared/system/relationable.rb b/spec/shared/system/relationable.rb index 4b744fe3535..bfbba3868d6 100644 --- a/spec/shared/system/relationable.rb +++ b/spec/shared/system/relationable.rb @@ -4,9 +4,7 @@ let(:related2) { create([:proposal, :debate, :budget_investment].sample) } let(:user) { create(:user) } - before do - integration_session.host = Capybara.app_host # TODO: remove after upgrading to Rails 6.1 - end + before { integration_session.host = Capybara.app_host } scenario "related contents are listed" do create(:related_content, parent_relationable: relationable, child_relationable: related1, author: build(:user)) diff --git a/spec/views/welcome/index.html.erb_spec.rb b/spec/views/welcome/index.html.erb_spec.rb index c0c2d4086c8..1583730d90e 100644 --- a/spec/views/welcome/index.html.erb_spec.rb +++ b/spec/views/welcome/index.html.erb_spec.rb @@ -4,7 +4,7 @@ it "Display images on orbit carrousel when we have defined image_default" do debate = create(:debate) - render template: "welcome/_recommended_carousel.html.erb", + render template: "welcome/_recommended_carousel", locals: { key: "debates", recommendeds: [debate], image_field: nil, @@ -22,7 +22,7 @@ it "Not display images on orbit carrousel when we have not defined image_default" do debate = create(:debate) - render template: "welcome/_recommended_carousel.html.erb", + render template: "welcome/_recommended_carousel", locals: { key: "debates", recommendeds: [debate], image_field: nil,