]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/2423'
authorTom Hughes <tom@compton.nu>
Sun, 24 Nov 2019 11:37:48 +0000 (11:37 +0000)
committerTom Hughes <tom@compton.nu>
Sun, 24 Nov 2019 11:37:48 +0000 (11:37 +0000)
27 files changed:
Gemfile
Gemfile.lock
app/mailers/notifier.rb
app/views/oauth_clients/index.html.erb
bin/setup
config/environments/development.rb
config/environments/production.rb
config/environments/test.rb
config/initializers/active_storage.rb
config/initializers/assets.rb
config/initializers/content_security_policy.rb
config/initializers/cors.rb
config/initializers/field_error.rb
config/initializers/new_framework_defaults_5_2.rb [new file with mode: 0644]
config/initializers/new_framework_defaults_6_0.rb [new file with mode: 0644]
config/initializers/wrap_parameters.rb
config/puma.rb
db/structure.sql
lib/redactable.rb
test/controllers/api/notes_controller_test.rb
test/controllers/api/traces_controller_test.rb
test/controllers/api/user_preferences_controller_test.rb
test/controllers/api/users_controller_test.rb
test/controllers/changeset_comments_controller_test.rb
test/controllers/changesets_controller_test.rb
test/controllers/traces_controller_test.rb
test/integration/cors_test.rb

diff --git a/Gemfile b/Gemfile
index 45402e5f1c4fa12fdc040e64ce0e84621b601037..8ccc5026b4ecb1b15a74eca2bd1a7a2de5a7840a 100644 (file)
--- a/Gemfile
+++ b/Gemfile
@@ -1,7 +1,7 @@
 source "https://rubygems.org"
 
 # Require rails
-gem "rails", "5.2.3"
+gem "rails", "6.0.1"
 
 # Require things which have moved to gems in ruby 1.9
 gem "bigdecimal", "~> 1.1.0", :platforms => :ruby_19
@@ -21,9 +21,6 @@ gem "sassc-rails"
 # Use Uglifier as compressor for JavaScript assets
 gem "uglifier", ">= 1.3.0"
 
-# Use CoffeeScript for .js.coffee assets and views
-gem "coffee-rails", "~> 4.2"
-
 # Use jquery as the JavaScript library
 gem "jquery-rails"
 
@@ -31,7 +28,7 @@ gem "jquery-rails"
 gem "jbuilder", "~> 2.7"
 
 # Reduces boot times through caching; required in config/boot.rb
-gem "bootsnap", ">= 1.1.0", :require => false
+gem "bootsnap", ">= 1.4.2", :require => false
 
 # Use R2 for RTL conversion
 gem "r2", "~> 0.2.7"
@@ -46,7 +43,7 @@ gem "image_optim_rails"
 gem "active_record_union"
 gem "activerecord-import"
 gem "cancancan"
-gem "composite_primary_keys", "~> 11.1.0"
+gem "composite_primary_keys", "~> 12.0.0"
 gem "config"
 gem "delayed_job_active_record"
 gem "dynamic_form"
@@ -57,7 +54,6 @@ gem "openstreetmap-actionpack-page_caching", ">= 1.1.2", :require => "actionpack
 gem "openstreetmap-deadlock_retry", ">= 1.3.0", :require => "deadlock_retry"
 gem "rack-cors"
 gem "rails-i18n", "~> 4.0.0"
-gem "record_tag_helper"
 gem "rinku", ">= 2.0.6", :require => "rails_rinku"
 gem "strong_migrations"
 gem "validates_email_format_of", ">= 1.5.1"
@@ -152,10 +148,11 @@ end
 
 # Needed in development as well so rake can see konacha tasks
 group :development, :test do
-  gem "capybara", "~> 2.13"
+  gem "capybara", ">= 2.15"
   gem "coveralls", :require => false
   gem "erb_lint", :require => false
   gem "factory_bot_rails"
   gem "poltergeist"
-  gem "puma", "~> 3.7"
+  gem "puma", "~> 3.11"
+  gem "selenium-webdriver"
 end
index 96aae1d6910bd49b9e35c0bb0aa84d8ef4893935..e9dd8af4b1443787d343840ce90d4d1b26050b34 100644 (file)
@@ -4,57 +4,70 @@ GEM
     SystemTimer (1.2.3)
     aasm (5.0.6)
       concurrent-ruby (~> 1.0)
-    actioncable (5.2.3)
-      actionpack (= 5.2.3)
+    actioncable (6.0.1)
+      actionpack (= 6.0.1)
       nio4r (~> 2.0)
       websocket-driver (>= 0.6.1)
-    actionmailer (5.2.3)
-      actionpack (= 5.2.3)
-      actionview (= 5.2.3)
-      activejob (= 5.2.3)
+    actionmailbox (6.0.1)
+      actionpack (= 6.0.1)
+      activejob (= 6.0.1)
+      activerecord (= 6.0.1)
+      activestorage (= 6.0.1)
+      activesupport (= 6.0.1)
+      mail (>= 2.7.1)
+    actionmailer (6.0.1)
+      actionpack (= 6.0.1)
+      actionview (= 6.0.1)
+      activejob (= 6.0.1)
       mail (~> 2.5, >= 2.5.4)
       rails-dom-testing (~> 2.0)
-    actionpack (5.2.3)
-      actionview (= 5.2.3)
-      activesupport (= 5.2.3)
+    actionpack (6.0.1)
+      actionview (= 6.0.1)
+      activesupport (= 6.0.1)
       rack (~> 2.0)
       rack-test (>= 0.6.3)
       rails-dom-testing (~> 2.0)
-      rails-html-sanitizer (~> 1.0, >= 1.0.2)
-    actionview (5.2.3)
-      activesupport (= 5.2.3)
+      rails-html-sanitizer (~> 1.0, >= 1.2.0)
+    actiontext (6.0.1)
+      actionpack (= 6.0.1)
+      activerecord (= 6.0.1)
+      activestorage (= 6.0.1)
+      activesupport (= 6.0.1)
+      nokogiri (>= 1.8.5)
+    actionview (6.0.1)
+      activesupport (= 6.0.1)
       builder (~> 3.1)
       erubi (~> 1.4)
       rails-dom-testing (~> 2.0)
-      rails-html-sanitizer (~> 1.0, >= 1.0.3)
+      rails-html-sanitizer (~> 1.1, >= 1.2.0)
     active_record_union (1.3.0)
       activerecord (>= 4.0)
-    activejob (5.2.3)
-      activesupport (= 5.2.3)
+    activejob (6.0.1)
+      activesupport (= 6.0.1)
       globalid (>= 0.3.6)
-    activemodel (5.2.3)
-      activesupport (= 5.2.3)
-    activerecord (5.2.3)
-      activemodel (= 5.2.3)
-      activesupport (= 5.2.3)
-      arel (>= 9.0)
+    activemodel (6.0.1)
+      activesupport (= 6.0.1)
+    activerecord (6.0.1)
+      activemodel (= 6.0.1)
+      activesupport (= 6.0.1)
     activerecord-import (1.0.3)
       activerecord (>= 3.2)
-    activestorage (5.2.3)
-      actionpack (= 5.2.3)
-      activerecord (= 5.2.3)
+    activestorage (6.0.1)
+      actionpack (= 6.0.1)
+      activejob (= 6.0.1)
+      activerecord (= 6.0.1)
       marcel (~> 0.3.1)
-    activesupport (5.2.3)
+    activesupport (6.0.1)
       concurrent-ruby (~> 1.0, >= 1.0.2)
       i18n (>= 0.7, < 2)
       minitest (~> 5.1)
       tzinfo (~> 1.1)
+      zeitwerk (~> 2.2)
     addressable (2.7.0)
       public_suffix (>= 2.0.2, < 5.0)
     annotate (3.0.3)
       activerecord (>= 3.2, < 7.0)
       rake (>= 10.4, < 14.0)
-    arel (9.0.0)
     ast (2.4.0)
     autoprefixer-rails (8.6.5)
       execjs
@@ -98,24 +111,19 @@ GEM
     cancancan (3.0.1)
     canonical-rails (0.2.6)
       rails (>= 4.1, < 6.1)
-    capybara (2.18.0)
+    capybara (3.29.0)
       addressable
       mini_mime (>= 0.1.3)
-      nokogiri (>= 1.3.3)
-      rack (>= 1.0.0)
-      rack-test (>= 0.5.4)
-      xpath (>= 2.0, < 4.0)
+      nokogiri (~> 1.8)
+      rack (>= 1.6.0)
+      rack-test (>= 0.6.3)
+      regexp_parser (~> 1.5)
+      xpath (~> 3.2)
+    childprocess (3.0.0)
     cliver (0.3.2)
     coderay (1.1.2)
-    coffee-rails (4.2.2)
-      coffee-script (>= 2.2.0)
-      railties (>= 4.0.0)
-    coffee-script (2.4.1)
-      coffee-script-source
-      execjs
-    coffee-script-source (1.12.2)
-    composite_primary_keys (11.1.0)
-      activerecord (~> 5.2.1)
+    composite_primary_keys (12.0.0)
+      activerecord (~> 6.0.0)
     concurrent-ruby (1.1.5)
     config (2.0.0)
       activesupport (>= 4.2)
@@ -326,18 +334,20 @@ GEM
     rack-test (1.1.0)
       rack (>= 1.0, < 3)
     rack-uri_sanitizer (0.0.2)
-    rails (5.2.3)
-      actioncable (= 5.2.3)
-      actionmailer (= 5.2.3)
-      actionpack (= 5.2.3)
-      actionview (= 5.2.3)
-      activejob (= 5.2.3)
-      activemodel (= 5.2.3)
-      activerecord (= 5.2.3)
-      activestorage (= 5.2.3)
-      activesupport (= 5.2.3)
+    rails (6.0.1)
+      actioncable (= 6.0.1)
+      actionmailbox (= 6.0.1)
+      actionmailer (= 6.0.1)
+      actionpack (= 6.0.1)
+      actiontext (= 6.0.1)
+      actionview (= 6.0.1)
+      activejob (= 6.0.1)
+      activemodel (= 6.0.1)
+      activerecord (= 6.0.1)
+      activestorage (= 6.0.1)
+      activesupport (= 6.0.1)
       bundler (>= 1.3.0)
-      railties (= 5.2.3)
+      railties (= 6.0.1)
       sprockets-rails (>= 2.0.0)
     rails-controller-testing (1.0.4)
       actionpack (>= 5.0.1.x)
@@ -351,19 +361,18 @@ GEM
     rails-i18n (4.0.2)
       i18n (~> 0.6)
       rails (>= 4.0)
-    railties (5.2.3)
-      actionpack (= 5.2.3)
-      activesupport (= 5.2.3)
+    railties (6.0.1)
+      actionpack (= 6.0.1)
+      activesupport (= 6.0.1)
       method_source
       rake (>= 0.8.7)
-      thor (>= 0.19.0, < 2.0)
+      thor (>= 0.20.3, < 2.0)
     rainbow (3.0.0)
     rake (13.0.1)
     rb-fsevent (0.10.3)
     rb-inotify (0.10.0)
       ffi (~> 1.0)
-    record_tag_helper (1.0.0)
-      actionview (~> 5.x)
+    regexp_parser (1.6.0)
     request_store (1.4.1)
       rack (>= 1.4)
     rinku (2.0.6)
@@ -383,6 +392,7 @@ GEM
       rubocop (>= 0.72.0)
     ruby-openid (2.9.2)
     ruby-progressbar (1.10.1)
+    rubyzip (2.0.0)
     safe_yaml (1.0.5)
     sanitize (5.1.0)
       crass (~> 1.0.2)
@@ -397,6 +407,9 @@ GEM
       sprockets-rails
       tilt
     secure_headers (6.1.1)
+    selenium-webdriver (3.142.6)
+      childprocess (>= 0.5, < 4.0)
+      rubyzip (>= 1.2.2)
     simplecov (0.16.1)
       docile (~> 1.1)
       json (>= 1.8, < 3)
@@ -435,6 +448,7 @@ GEM
     websocket-extensions (0.1.4)
     xpath (3.2.0)
       nokogiri (~> 1.8)
+    zeitwerk (2.2.1)
 
 PLATFORMS
   ruby
@@ -450,14 +464,13 @@ DEPENDENCIES
   better_errors
   bigdecimal (~> 1.1.0)
   binding_of_caller
-  bootsnap (>= 1.1.0)
+  bootsnap (>= 1.4.2)
   browser
   bzip2-ffi
   cancancan
   canonical-rails
-  capybara (~> 2.13)
-  coffee-rails (~> 4.2)
-  composite_primary_keys (~> 11.1.0)
+  capybara (>= 2.15)
+  composite_primary_keys (~> 12.0.0)
   config
   coveralls
   dalli
@@ -498,15 +511,14 @@ DEPENDENCIES
   pg
   poltergeist
   psych
-  puma (~> 3.7)
+  puma (~> 3.11)
   quad_tile (~> 1.0.1)
   r2 (~> 0.2.7)
   rack-cors
   rack-uri_sanitizer
-  rails (= 5.2.3)
+  rails (= 6.0.1)
   rails-controller-testing
   rails-i18n (~> 4.0.0)
-  record_tag_helper
   rinku (>= 2.0.6)
   rotp
   rubocop
@@ -515,6 +527,7 @@ DEPENDENCIES
   sanitize
   sassc-rails
   secure_headers
+  selenium-webdriver
   strong_migrations
   uglifier (>= 1.3.0)
   validates_email_format_of (>= 1.5.1)
index 4509f10114bec03308da57e7744426389caf1a1b..6e0c81a39177337b6f6ad57ddeb6b2d11e36644a 100644 (file)
@@ -1,6 +1,8 @@
 class Notifier < ActionMailer::Base
   include ActionView::Helpers::AssetUrlHelper
 
+  self.delivery_job = ActionMailer::MailDeliveryJob
+
   default :from => Settings.email_from,
           :return_path => Settings.email_return_path,
           :auto_submitted => "auto-generated"
index 80cae9a6d3439135d9701ec4c2dd3d245e53eff3..41e1e144660cf59f063ace779677c987b79d5456 100644 (file)
@@ -28,9 +28,9 @@
 <% else %>
 <p><%= t ".registered_apps" %></p>
 <% @client_applications.each do |client| %>
-  <%= div_for client do %>
+  <div class="client_application">
     <%= link_to client.name, :action => :show, :id => client.id %>
-  <% end %>
+  </div>
 <% end %>
 <% end %>
 <h3><%= link_to t(".register_new"), :action => :new %></h3>
index ebdfd0277c784e92604855de13adda30c32203f5..9944e82a33e1e1b5e4739905632d745da75b3ab1 100755 (executable)
--- a/bin/setup
+++ b/bin/setup
@@ -1,6 +1,5 @@
 #!/usr/bin/env ruby
 require "fileutils"
-include FileUtils
 
 # path to your application root.
 APP_ROOT = File.expand_path("..", __dir__)
@@ -9,24 +8,25 @@ def system!(*args)
   system(*args) || abort("\n== Command #{args} failed ==")
 end
 
-chdir APP_ROOT do
-  # This script is a starting point to setup your application.
+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.
   # Add necessary setup steps to this file.
 
   puts "== Installing dependencies =="
   system! "gem install bundler --conservative"
   system("bundle check") || system!("bundle install")
 
-  # Install JavaScript dependencies if using Yarn
+  # Install JavaScript dependencies
   # system('bin/yarn')
 
   # puts "\n== Copying sample files =="
   # unless File.exist?('config/database.yml')
-  #   cp 'config/database.yml.sample', 'config/database.yml'
+  #   FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
   # end
 
   puts "\n== Preparing database =="
-  system! "bin/rails db:setup"
+  system! "bin/rails db:prepare"
 
   puts "\n== Removing old logs and tempfiles =="
   system! "bin/rails log:clear tmp:clear"
index 9a3976f76dd83f20c6754a8f2334b108a008f5da..e54e3bf06a18a988faa6dd7dddd2c8d9edce5cd8 100644 (file)
@@ -16,6 +16,7 @@ Rails.application.configure do
   # Run rails dev:cache to toggle caching.
   if Rails.root.join("tmp", "caching-dev.txt").exist?
     config.action_controller.perform_caching = true
+    config.action_controller.enable_fragment_cache_logging = true
 
     config.cache_store = :memory_store
     config.public_file_server.headers = {
@@ -27,7 +28,7 @@ Rails.application.configure do
     config.cache_store = :null_store
   end
 
-  # Store uploaded files on the local file system (see config/storage.yml for options)
+  # Store uploaded files on the local file system (see config/storage.yml for options).
   config.active_storage.service = :local
 
   # Don't care if the mailer can't send.
@@ -52,10 +53,10 @@ Rails.application.configure do
   # Suppress logger output for asset requests.
   config.assets.quiet = true
 
-  # Export translations automatically
+  # Export translations automatically.
   config.middleware.use I18n::JS::Middleware
 
-  # Raises error for missing translations
+  # Raises error for missing translations.
   # config.action_view.raise_on_missing_translations = true
 
   # Use an evented file watcher to asynchronously detect changes in source code,
index ba781e5af68ef5d91d8b26faa328634e4dbb06e7..4016be615f300a88036e6266e3cf6864da5ac6d3 100644 (file)
@@ -22,15 +22,12 @@ Rails.application.configure do
   # Apache or NGINX already handles this.
   config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
 
-  # Compress JavaScripts and CSS.
-  config.assets.js_compressor = :uglifier
+  # Compress CSS using a preprocessor.
   # config.assets.css_compressor = :sass
 
   # Do not fallback to assets pipeline if a precompiled asset is missed.
   config.assets.compile = false
 
-  # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
-
   # Enable serving of images, stylesheets, and JavaScripts from an asset server.
   # config.action_controller.asset_host = 'http://assets.example.com'
 
@@ -38,10 +35,10 @@ Rails.application.configure do
   # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
   # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
 
-  # Store uploaded files on the local file system (see config/storage.yml for options)
+  # Store uploaded files on the local file system (see config/storage.yml for options).
   config.active_storage.service = Settings.storage_service.to_sym
 
-  # Mount Action Cable outside main process or domain
+  # Mount Action Cable outside main process or domain.
   # config.action_cable.mount_path = nil
   # config.action_cable.url = 'wss://example.com/cable'
   # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
@@ -62,9 +59,10 @@ Rails.application.configure do
   # Use a different cache store in production.
   # config.cache_store = :mem_cache_store
 
-  # Use a real queuing backend for Active Job (and separate queues per environment)
+  # 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 = "openstreetmap_#{Rails.env}"
+  # config.active_job.queue_name_prefix = "openstreetmap_production"
+
   config.action_mailer.perform_caching = false
 
   # Configure caching of static assets
@@ -97,6 +95,27 @@ Rails.application.configure do
   # Do not dump schema after migrations.
   config.active_record.dump_schema_after_migration = false unless Settings.status == "database_offline"
 
+  # Inserts middleware to perform automatic connection switching.
+  # The `database_selector` hash is used to pass options to the DatabaseSelector
+  # middleware. The `delay` is used to determine how long to wait after a write
+  # to send a subsequent read to the primary.
+  #
+  # The `database_resolver` class is used by the middleware to determine which
+  # database is appropriate to use based on the time delay.
+  #
+  # The `database_resolver_context` class is used by the middleware to set
+  # timestamps for the last write to the primary. The resolver uses the context
+  # class timestamps to determine how long to wait before reading from the
+  # replica.
+  #
+  # By default Rails will store a last write timestamp in the session. The
+  # DatabaseSelector middleware is designed as such you can define your own
+  # strategy for connection switching and pass that into the middleware through
+  # these configuration options.
+  # config.active_record.database_selector = { delay: 2.seconds }
+  # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
+  # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
+
   # Enable autoloading of dependencies.
   config.enable_dependency_loading = true
 
index 38975deef664b54cb6332be608fb142fa7c3fe8a..fad06fe51cd83e9510843b365d39fcd6bd0c8422 100644 (file)
@@ -1,10 +1,11 @@
+# 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
+# and recreated between test runs. Don't rely on the data there!
+
 Rails.application.configure do
   # Settings specified here will take precedence over those in config/application.rb.
 
-  # 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
-  # and recreated between test runs. Don't rely on the data there!
   config.cache_classes = true
 
   # Do not eager load code on boot. This avoids loading your whole application
@@ -21,6 +22,7 @@ Rails.application.configure do
   # Show full error reports and disable caching.
   config.consider_all_requests_local       = true
   config.action_controller.perform_caching = false
+  config.cache_store = :null_store
 
   # Raise exceptions instead of rendering exception templates.
   config.action_dispatch.show_exceptions = false
@@ -28,7 +30,7 @@ Rails.application.configure do
   # Disable request forgery protection in test environment.
   config.action_controller.allow_forgery_protection = false
 
-  # Store uploaded files on the local file system in a temporary directory
+  # Store uploaded files on the local file system in a temporary directory.
   config.active_storage.service = :test
 
   config.action_mailer.perform_caching = false
@@ -41,12 +43,12 @@ Rails.application.configure do
   # Print deprecation notices to the stderr.
   config.active_support.deprecation = :stderr
 
-  # Export translations automatically
+  # Export translations automatically.
   config.middleware.use I18n::JS::Middleware
 
-  # Raises error for missing translations
+  # Raises error for missing translations.
   config.action_view.raise_on_missing_translations = true
 
-  # Use the test adapter for ActiveJob during testing
+  # Use the test adapter for ActiveJob during testing.
   config.active_job.queue_adapter = :test
 end
index bc909108058cf927dc623dab7b515aead9aedd8d..361e2edee8a8bfd2820c2e6ce1f1d2f0340d9150 100644 (file)
@@ -1,5 +1,5 @@
-Rails.application.config.active_storage.queue = :storage
-Rails.application.config.active_storage.variable_content_types << "image/bmp"
+Rails.application.config.active_storage.queues.analysis = :storage
+Rails.application.config.active_storage.queues.purge = :storage
 
 Rails.configuration.after_initialize do
   require "active_storage/service/s3_service"
@@ -32,5 +32,5 @@ Rails.configuration.after_initialize do
     ActiveStorage::Variant.prepend(OpenStreetMap::ActiveStorage::Variant)
   end
 
-  ActiveStorage::Service.url_expires_in = 1.week
+  ActiveStorage.service_urls_expire_in = 1.week
 end
index 255ae108e2a96b5eade11fcbb11d041dd608f5bf..15644963510fff77f0782ad83745b64362a8f937 100644 (file)
@@ -9,8 +9,6 @@ Rails.application.config.assets.manifest = Rails.root.join("tmp", "manifest.json
 # Add additional assets to the asset load path.
 Rails.application.config.assets.paths << Rails.root.join("config")
 
-# Add additional assets to the asset load path.
-# Rails.application.config.assets.paths << Emoji.images_path
 # Add Yarn node_modules folder to the asset load path.
 Rails.application.config.assets.paths << Rails.root.join("node_modules")
 
index d3bcaa5ec84ac0761911dcdc0a7bf1c67f44a392..35d0f26fcdc9416ca1e1ae6501393c7154853250 100644 (file)
@@ -11,6 +11,8 @@
 #   policy.object_src  :none
 #   policy.script_src  :self, :https
 #   policy.style_src   :self, :https
+#   # If you are using webpack-dev-server then specify webpack-dev-server host
+#   policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
 
 #   # Specify URI for violation reports
 #   # policy.report_uri "/csp-violation-report-endpoint"
@@ -19,6 +21,9 @@
 # If you are using UJS then enable automatic nonce generation
 # Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) }
 
+# Set the nonce only to specific directives
+# Rails.application.config.content_security_policy_nonce_directives = %w(script-src)
+
 # Report CSP violations to a specified URI
 # For further information see the following documentation:
 # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy-Report-Only
index 2bd558d2f3f24ec4f4f9884cb9b1cf4c815505dc..7992ecdce015631749f425209dd83802b54ede21 100644 (file)
@@ -1,4 +1,4 @@
-require "rack/cors"
+# Be sure to restart your server when you modify this file.
 
 # Mark CORS responses as uncacheable as we don't want a browser to
 # try and reuse a response that had a different origin, even with
@@ -18,7 +18,7 @@ end
 # so browser-requests should be similarly permitted. (Though the API does not
 # require any custom headers, Ajax frameworks may automatically add headers
 # such as X-Requested-By to requests.)
-Rails.configuration.middleware.use OpenStreetMap::Cors do
+Rails.application.config.middleware.insert_before 0, OpenStreetMap::Cors do
   allow do
     origins "*"
     resource "/oauth/*", :headers => :any, :methods => [:get, :post]
index a3e3d3aaceb3a25845a8763bfbee8d4630e9d636..34b224296cce6506a9f4240fc33083867a2fc404 100644 (file)
@@ -4,6 +4,6 @@ ActionView::Base.field_error_proc = proc do |html_tag, _instance|
   if class_attr_index
     html_tag.insert class_attr_index + 7, "field_with_errors "
   else
-    html_tag.insert html_tag.index(%r{/?>}), ' class="field_with_errors"'
+    html_tag.insert html_tag.index(%r{/?>}), ' class="field_with_errors"'.html_safe
   end
 end
diff --git a/config/initializers/new_framework_defaults_5_2.rb b/config/initializers/new_framework_defaults_5_2.rb
new file mode 100644 (file)
index 0000000..c383d07
--- /dev/null
@@ -0,0 +1,38 @@
+# Be sure to restart your server when you modify this file.
+#
+# This file contains migration options to ease your Rails 5.2 upgrade.
+#
+# Once upgraded flip defaults one by one to migrate to the new default.
+#
+# Read the Guide for Upgrading Ruby on Rails for more info on each option.
+
+# Make Active Record use stable #cache_key alongside new #cache_version method.
+# This is needed for recyclable cache keys.
+# Rails.application.config.active_record.cache_versioning = true
+
+# Use AES-256-GCM authenticated encryption for encrypted cookies.
+# Also, embed cookie expiry in signed or encrypted cookies for increased security.
+#
+# This option is not backwards compatible with earlier Rails versions.
+# It's best enabled when your entire app is migrated and stable on 5.2.
+#
+# Existing cookies will be converted on read then written with the new scheme.
+# Rails.application.config.action_dispatch.use_authenticated_cookie_encryption = true
+
+# Use AES-256-GCM authenticated encryption as default cipher for encrypting messages
+# instead of AES-256-CBC, when use_authenticated_message_encryption is set to true.
+# Rails.application.config.active_support.use_authenticated_message_encryption = true
+
+# Add default protection from forgery to ActionController::Base instead of in
+# ApplicationController.
+# Rails.application.config.action_controller.default_protect_from_forgery = true
+
+# Store boolean values are in sqlite3 databases as 1 and 0 instead of 't' and
+# 'f' after migrating old data.
+# Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
+
+# Use SHA-1 instead of MD5 to generate non-sensitive digests, such as the ETag header.
+# Rails.application.config.active_support.use_sha1_digests = true
+
+# Make `form_with` generate id attributes for any generated HTML tags.
+# Rails.application.config.action_view.form_with_generates_ids = true
diff --git a/config/initializers/new_framework_defaults_6_0.rb b/config/initializers/new_framework_defaults_6_0.rb
new file mode 100644 (file)
index 0000000..92240ef
--- /dev/null
@@ -0,0 +1,45 @@
+# Be sure to restart your server when you modify this file.
+#
+# This file contains migration options to ease your Rails 6.0 upgrade.
+#
+# Once upgraded flip defaults one by one to migrate to the new default.
+#
+# Read the Guide for Upgrading Ruby on Rails for more info on each option.
+
+# Don't force requests from old versions of IE to be UTF-8 encoded.
+# Rails.application.config.action_view.default_enforce_utf8 = false
+
+# Embed purpose and expiry metadata inside signed and encrypted
+# cookies for increased security.
+#
+# This option is not backwards compatible with earlier Rails versions.
+# It's best enabled when your entire app is migrated and stable on 6.0.
+# Rails.application.config.action_dispatch.use_cookies_with_metadata = true
+
+# Change the return value of `ActionDispatch::Response#content_type` to Content-Type header without modification.
+# Rails.application.config.action_dispatch.return_only_media_type_on_content_type = false
+
+# Return false instead of self when enqueuing is aborted from a callback.
+# Rails.application.config.active_job.return_false_on_aborted_enqueue = true
+
+# Send Active Storage analysis and purge jobs to dedicated queues.
+# Rails.application.config.active_storage.queues.analysis = :active_storage_analysis
+# Rails.application.config.active_storage.queues.purge    = :active_storage_purge
+
+# When assigning to a collection of attachments declared via `has_many_attached`, replace existing
+# attachments instead of appending. Use #attach to add new attachments without replacing existing ones.
+# Rails.application.config.active_storage.replace_on_assign_to_many = true
+
+# Use ActionMailer::MailDeliveryJob for sending parameterized and normal mail.
+#
+# The default delivery jobs (ActionMailer::Parameterized::DeliveryJob, ActionMailer::DeliveryJob),
+# will be removed in Rails 6.1. This setting is not backwards compatible with earlier Rails versions.
+# If you send mail in the background, job workers need to have a copy of
+# MailDeliveryJob to ensure all delivery jobs are processed properly.
+# Make sure your entire app is migrated and stable on 6.0 before using this setting.
+# Rails.application.config.action_mailer.delivery_job = "ActionMailer::MailDeliveryJob"
+
+# Enable the same cache key to be reused when the object being cached of type
+# `ActiveRecord::Relation` changes by moving the volatile information (max updated at and count)
+# of the relation's cache key into the cache version to support recycling cache key.
+# Rails.application.config.active_record.collection_cache_versioning = true
index cf733efd119893abd444b9d75c53b3f09e77d4a4..bbfc3961bffef15dabb35fe0de4c409d6efb58c5 100644 (file)
@@ -10,5 +10,5 @@ end
 
 # To enable root element in JSON for ActiveRecord objects.
 # ActiveSupport.on_load(:active_record) do
-#  self.include_root_in_json = true
+#   self.include_root_in_json = true
 # end
index a5eccf816b2f63b7022c72adeeb2fa79b6f6f1c3..5ed44377449e9c5102f0ac5ab01c646097886a70 100644 (file)
@@ -4,8 +4,9 @@
 # the maximum value specified for Puma. Default is set to 5 threads for minimum
 # and maximum; this matches the default thread size of Active Record.
 #
-threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
-threads threads_count, threads_count
+max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
+min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
+threads min_threads_count, max_threads_count
 
 # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
 #
@@ -15,8 +16,11 @@ port        ENV.fetch("PORT") { 3000 }
 #
 environment ENV.fetch("RAILS_ENV") { "development" }
 
+# Specifies the `pidfile` that Puma will use.
+pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
+
 # Specifies the number of `workers` to boot in clustered mode.
-# Workers are forked webserver processes. If using threads and workers together
+# Workers are forked web server processes. If using threads and workers together
 # the concurrency of the application would be max `threads` * `workers`.
 # Workers do not work on JRuby or Windows (both of which do not support
 # processes).
index 78e58d4be5ba0b3394b42232cf3d62ebdb2d5ece..d0e8c21e3ba32f4213835b506e57efb9b523608a 100644 (file)
@@ -320,8 +320,8 @@ ALTER SEQUENCE public.active_storage_blobs_id_seq OWNED BY public.active_storage
 CREATE TABLE public.ar_internal_metadata (
     key character varying NOT NULL,
     value character varying,
-    created_at timestamp without time zone NOT NULL,
-    updated_at timestamp without time zone NOT NULL
+    created_at timestamp(6) without time zone NOT NULL,
+    updated_at timestamp(6) without time zone NOT NULL
 );
 
 
index d827cfd7462aa318a11c4754434ccd311dab4a7f..6efdae0efd4b2dfeb8bf91c3969c88af54df8594 100644 (file)
@@ -4,7 +4,7 @@ module Redactable
   def self.included(base)
     # this is used to extend activerecord bases, as these aren't
     # in scope for the module itself.
-    base.scope :unredacted, -> { base.where(:redaction_id => nil) }
+    base.scope :unredacted, -> { where(:redaction_id => nil) }
   end
 
   def redacted?
index 54a20028de33846cfee627ca23769708d280e9b0..0e4a6f35747ee0b93a2df68a2529b7c9f85388d5 100644 (file)
@@ -479,7 +479,7 @@ module Api
 
       get :show, :params => { :id => open_note.id, :format => "xml" }
       assert_response :success
-      assert_equal "application/xml", @response.content_type
+      assert_equal "application/xml", @response.media_type
       assert_select "osm", :count => 1 do
         assert_select "note[lat='#{open_note.lat}'][lon='#{open_note.lon}']", :count => 1 do
           assert_select "id", open_note.id.to_s
@@ -496,7 +496,7 @@ module Api
 
       get :show, :params => { :id => open_note.id, :format => "rss" }
       assert_response :success
-      assert_equal "application/rss+xml", @response.content_type
+      assert_equal "application/rss+xml", @response.media_type
       assert_select "rss", :count => 1 do
         assert_select "channel", :count => 1 do
           assert_select "item", :count => 1 do
@@ -512,7 +512,7 @@ module Api
 
       get :show, :params => { :id => open_note.id, :format => "json" }
       assert_response :success
-      assert_equal "application/json", @response.content_type
+      assert_equal "application/json", @response.media_type
       js = ActiveSupport::JSON.decode(@response.body)
       assert_not_nil js
       assert_equal "Feature", js["type"]
@@ -528,7 +528,7 @@ module Api
 
       get :show, :params => { :id => open_note.id, :format => "gpx" }
       assert_response :success
-      assert_equal "application/gpx+xml", @response.content_type
+      assert_equal "application/gpx+xml", @response.media_type
       assert_select "gpx", :count => 1 do
         assert_select "wpt[lat='#{open_note.lat}'][lon='#{open_note.lon}']", :count => 1 do
           assert_select "time", :count => 1
@@ -636,7 +636,7 @@ module Api
 
       get :index, :params => { :bbox => "1,1,1.2,1.2", :format => "rss" }
       assert_response :success
-      assert_equal "application/rss+xml", @response.content_type
+      assert_equal "application/rss+xml", @response.media_type
       assert_select "rss", :count => 1 do
         assert_select "channel", :count => 1 do
           assert_select "item", :count => 2
@@ -645,7 +645,7 @@ module Api
 
       get :index, :params => { :bbox => "1,1,1.2,1.2", :format => "json" }
       assert_response :success
-      assert_equal "application/json", @response.content_type
+      assert_equal "application/json", @response.media_type
       js = ActiveSupport::JSON.decode(@response.body)
       assert_not_nil js
       assert_equal "FeatureCollection", js["type"]
@@ -653,14 +653,14 @@ module Api
 
       get :index, :params => { :bbox => "1,1,1.2,1.2", :format => "xml" }
       assert_response :success
-      assert_equal "application/xml", @response.content_type
+      assert_equal "application/xml", @response.media_type
       assert_select "osm", :count => 1 do
         assert_select "note", :count => 2
       end
 
       get :index, :params => { :bbox => "1,1,1.2,1.2", :format => "gpx" }
       assert_response :success
-      assert_equal "application/gpx+xml", @response.content_type
+      assert_equal "application/gpx+xml", @response.media_type
       assert_select "gpx", :count => 1 do
         assert_select "wpt", :count => 2
       end
@@ -673,7 +673,7 @@ module Api
 
       get :index, :params => { :bbox => "1,1,1.2,1.2", :limit => 1, :format => "rss" }
       assert_response :success
-      assert_equal "application/rss+xml", @response.content_type
+      assert_equal "application/rss+xml", @response.media_type
       assert_select "rss", :count => 1 do
         assert_select "channel", :count => 1 do
           assert_select "item", :count => 1
@@ -682,7 +682,7 @@ module Api
 
       get :index, :params => { :bbox => "1,1,1.2,1.2", :limit => 1, :format => "json" }
       assert_response :success
-      assert_equal "application/json", @response.content_type
+      assert_equal "application/json", @response.media_type
       js = ActiveSupport::JSON.decode(@response.body)
       assert_not_nil js
       assert_equal "FeatureCollection", js["type"]
@@ -690,14 +690,14 @@ module Api
 
       get :index, :params => { :bbox => "1,1,1.2,1.2", :limit => 1, :format => "xml" }
       assert_response :success
-      assert_equal "application/xml", @response.content_type
+      assert_equal "application/xml", @response.media_type
       assert_select "osm", :count => 1 do
         assert_select "note", :count => 1
       end
 
       get :index, :params => { :bbox => "1,1,1.2,1.2", :limit => 1, :format => "gpx" }
       assert_response :success
-      assert_equal "application/gpx+xml", @response.content_type
+      assert_equal "application/gpx+xml", @response.media_type
       assert_select "gpx", :count => 1 do
         assert_select "wpt", :count => 1
       end
@@ -706,7 +706,7 @@ module Api
     def test_index_empty_area
       get :index, :params => { :bbox => "5,5,5.1,5.1", :format => "rss" }
       assert_response :success
-      assert_equal "application/rss+xml", @response.content_type
+      assert_equal "application/rss+xml", @response.media_type
       assert_select "rss", :count => 1 do
         assert_select "channel", :count => 1 do
           assert_select "item", :count => 0
@@ -715,7 +715,7 @@ module Api
 
       get :index, :params => { :bbox => "5,5,5.1,5.1", :format => "json" }
       assert_response :success
-      assert_equal "application/json", @response.content_type
+      assert_equal "application/json", @response.media_type
       js = ActiveSupport::JSON.decode(@response.body)
       assert_not_nil js
       assert_equal "FeatureCollection", js["type"]
@@ -723,14 +723,14 @@ module Api
 
       get :index, :params => { :bbox => "5,5,5.1,5.1", :format => "xml" }
       assert_response :success
-      assert_equal "application/xml", @response.content_type
+      assert_equal "application/xml", @response.media_type
       assert_select "osm", :count => 1 do
         assert_select "note", :count => 0
       end
 
       get :index, :params => { :bbox => "5,5,5.1,5.1", :format => "gpx" }
       assert_response :success
-      assert_equal "application/gpx+xml", @response.content_type
+      assert_equal "application/gpx+xml", @response.media_type
       assert_select "gpx", :count => 1 do
         assert_select "wpt", :count => 0
       end
@@ -739,19 +739,19 @@ module Api
     def test_index_large_area
       get :index, :params => { :bbox => "-2.5,-2.5,2.5,2.5", :format => :json }
       assert_response :success
-      assert_equal "application/json", @response.content_type
+      assert_equal "application/json", @response.media_type
 
       get :index, :params => { :l => "-2.5", :b => "-2.5", :r => "2.5", :t => "2.5", :format => :json }
       assert_response :success
-      assert_equal "application/json", @response.content_type
+      assert_equal "application/json", @response.media_type
 
       get :index, :params => { :bbox => "-10,-10,12,12", :format => :json }
       assert_response :bad_request
-      assert_equal "application/json", @response.content_type
+      assert_equal "text/plain", @response.media_type
 
       get :index, :params => { :l => "-10", :b => "-10", :r => "12", :t => "12", :format => :json }
       assert_response :bad_request
-      assert_equal "application/json", @response.content_type
+      assert_equal "text/plain", @response.media_type
     end
 
     def test_index_closed
@@ -763,7 +763,7 @@ module Api
       # Open notes + closed in last 7 days
       get :index, :params => { :bbox => "1,1,1.7,1.7", :closed => "7", :format => "json" }
       assert_response :success
-      assert_equal "application/json", @response.content_type
+      assert_equal "application/json", @response.media_type
       js = ActiveSupport::JSON.decode(@response.body)
       assert_not_nil js
       assert_equal "FeatureCollection", js["type"]
@@ -772,7 +772,7 @@ module Api
       # Only open notes
       get :index, :params => { :bbox => "1,1,1.7,1.7", :closed => "0", :format => "json" }
       assert_response :success
-      assert_equal "application/json", @response.content_type
+      assert_equal "application/json", @response.media_type
       js = ActiveSupport::JSON.decode(@response.body)
       assert_not_nil js
       assert_equal "FeatureCollection", js["type"]
@@ -781,7 +781,7 @@ module Api
       # Open notes + all closed notes
       get :index, :params => { :bbox => "1,1,1.7,1.7", :closed => "-1", :format => "json" }
       assert_response :success
-      assert_equal "application/json", @response.content_type
+      assert_equal "application/json", @response.media_type
       js = ActiveSupport::JSON.decode(@response.body)
       assert_not_nil js
       assert_equal "FeatureCollection", js["type"]
@@ -819,14 +819,14 @@ module Api
 
       get :search, :params => { :q => "note comment", :format => "xml" }
       assert_response :success
-      assert_equal "application/xml", @response.content_type
+      assert_equal "application/xml", @response.media_type
       assert_select "osm", :count => 1 do
         assert_select "note", :count => 1
       end
 
       get :search, :params => { :q => "note comment", :format => "json" }
       assert_response :success
-      assert_equal "application/json", @response.content_type
+      assert_equal "application/json", @response.media_type
       js = ActiveSupport::JSON.decode(@response.body)
       assert_not_nil js
       assert_equal "FeatureCollection", js["type"]
@@ -834,7 +834,7 @@ module Api
 
       get :search, :params => { :q => "note comment", :format => "rss" }
       assert_response :success
-      assert_equal "application/rss+xml", @response.content_type
+      assert_equal "application/rss+xml", @response.media_type
       assert_select "rss", :count => 1 do
         assert_select "channel", :count => 1 do
           assert_select "item", :count => 1
@@ -843,7 +843,7 @@ module Api
 
       get :search, :params => { :q => "note comment", :format => "gpx" }
       assert_response :success
-      assert_equal "application/gpx+xml", @response.content_type
+      assert_equal "application/gpx+xml", @response.media_type
       assert_select "gpx", :count => 1 do
         assert_select "wpt", :count => 1
       end
@@ -858,14 +858,14 @@ module Api
 
       get :search, :params => { :display_name => user.display_name, :format => "xml" }
       assert_response :success
-      assert_equal "application/xml", @response.content_type
+      assert_equal "application/xml", @response.media_type
       assert_select "osm", :count => 1 do
         assert_select "note", :count => 1
       end
 
       get :search, :params => { :display_name => user.display_name, :format => "json" }
       assert_response :success
-      assert_equal "application/json", @response.content_type
+      assert_equal "application/json", @response.media_type
       js = ActiveSupport::JSON.decode(@response.body)
       assert_not_nil js
       assert_equal "FeatureCollection", js["type"]
@@ -873,7 +873,7 @@ module Api
 
       get :search, :params => { :display_name => user.display_name, :format => "rss" }
       assert_response :success
-      assert_equal "application/rss+xml", @response.content_type
+      assert_equal "application/rss+xml", @response.media_type
       assert_select "rss", :count => 1 do
         assert_select "channel", :count => 1 do
           assert_select "item", :count => 1
@@ -882,7 +882,7 @@ module Api
 
       get :search, :params => { :display_name => user.display_name, :format => "gpx" }
       assert_response :success
-      assert_equal "application/gpx+xml", @response.content_type
+      assert_equal "application/gpx+xml", @response.media_type
       assert_select "gpx", :count => 1 do
         assert_select "wpt", :count => 1
       end
@@ -897,14 +897,14 @@ module Api
 
       get :search, :params => { :user => user.id, :format => "xml" }
       assert_response :success
-      assert_equal "application/xml", @response.content_type
+      assert_equal "application/xml", @response.media_type
       assert_select "osm", :count => 1 do
         assert_select "note", :count => 1
       end
 
       get :search, :params => { :user => user.id, :format => "json" }
       assert_response :success
-      assert_equal "application/json", @response.content_type
+      assert_equal "application/json", @response.media_type
       js = ActiveSupport::JSON.decode(@response.body)
       assert_not_nil js
       assert_equal "FeatureCollection", js["type"]
@@ -912,7 +912,7 @@ module Api
 
       get :search, :params => { :user => user.id, :format => "rss" }
       assert_response :success
-      assert_equal "application/rss+xml", @response.content_type
+      assert_equal "application/rss+xml", @response.media_type
       assert_select "rss", :count => 1 do
         assert_select "channel", :count => 1 do
           assert_select "item", :count => 1
@@ -921,7 +921,7 @@ module Api
 
       get :search, :params => { :user => user.id, :format => "gpx" }
       assert_response :success
-      assert_equal "application/gpx+xml", @response.content_type
+      assert_equal "application/gpx+xml", @response.media_type
       assert_select "gpx", :count => 1 do
         assert_select "wpt", :count => 1
       end
@@ -932,14 +932,14 @@ module Api
 
       get :search, :params => { :q => "no match", :format => "xml" }
       assert_response :success
-      assert_equal "application/xml", @response.content_type
+      assert_equal "application/xml", @response.media_type
       assert_select "osm", :count => 1 do
         assert_select "note", :count => 0
       end
 
       get :search, :params => { :q => "no match", :format => "json" }
       assert_response :success
-      assert_equal "application/json", @response.content_type
+      assert_equal "application/json", @response.media_type
       js = ActiveSupport::JSON.decode(@response.body)
       assert_not_nil js
       assert_equal "FeatureCollection", js["type"]
@@ -947,7 +947,7 @@ module Api
 
       get :search, :params => { :q => "no match", :format => "rss" }
       assert_response :success
-      assert_equal "application/rss+xml", @response.content_type
+      assert_equal "application/rss+xml", @response.media_type
       assert_select "rss", :count => 1 do
         assert_select "channel", :count => 1 do
           assert_select "item", :count => 0
@@ -956,7 +956,7 @@ module Api
 
       get :search, :params => { :q => "no match", :format => "gpx" }
       assert_response :success
-      assert_equal "application/gpx+xml", @response.content_type
+      assert_equal "application/gpx+xml", @response.media_type
       assert_select "gpx", :count => 1 do
         assert_select "wpt", :count => 0
       end
@@ -967,14 +967,14 @@ module Api
 
       get :search, :params => { :from => "01.01.2010", :to => "01.10.2010", :format => "xml" }
       assert_response :success
-      assert_equal "application/xml", @response.content_type
+      assert_equal "application/xml", @response.media_type
       assert_select "osm", :count => 1 do
         assert_select "note", :count => 0
       end
 
       get :search, :params => { :from => "01.01.2010", :to => "01.10.2010", :format => "json" }
       assert_response :success
-      assert_equal "application/json", @response.content_type
+      assert_equal "application/json", @response.media_type
       js = ActiveSupport::JSON.decode(@response.body)
       assert_not_nil js
       assert_equal "FeatureCollection", js["type"]
@@ -982,7 +982,7 @@ module Api
 
       get :search, :params => { :from => "01.01.2010", :to => "01.10.2010", :format => "rss" }
       assert_response :success
-      assert_equal "application/rss+xml", @response.content_type
+      assert_equal "application/rss+xml", @response.media_type
       assert_select "rss", :count => 1 do
         assert_select "channel", :count => 1 do
           assert_select "item", :count => 0
@@ -991,7 +991,7 @@ module Api
 
       get :search, :params => { :from => "01.01.2010", :to => "01.10.2010", :format => "gpx" }
       assert_response :success
-      assert_equal "application/gpx+xml", @response.content_type
+      assert_equal "application/gpx+xml", @response.media_type
       assert_select "gpx", :count => 1 do
         assert_select "wpt", :count => 0
       end
@@ -1027,7 +1027,7 @@ module Api
 
       get :feed, :params => { :format => "rss" }
       assert_response :success
-      assert_equal "application/rss+xml", @response.content_type
+      assert_equal "application/rss+xml", @response.media_type
       assert_select "rss", :count => 1 do
         assert_select "channel", :count => 1 do
           assert_select "item", :count => 4
@@ -1036,7 +1036,7 @@ module Api
 
       get :feed, :params => { :bbox => "1,1,1.2,1.2", :format => "rss" }
       assert_response :success
-      assert_equal "application/rss+xml", @response.content_type
+      assert_equal "application/rss+xml", @response.media_type
       assert_select "rss", :count => 1 do
         assert_select "channel", :count => 1 do
           assert_select "item", :count => 2
index 820829aadc6f21a79e230bd3207867834262a53e..80b9d1a8458a445e2719c2059a8c2eefe72d49d9 100644 (file)
@@ -336,8 +336,8 @@ module Api
     def check_trace_data(trace, digest, content_type = "application/gpx+xml", extension = "gpx")
       assert_response :success
       assert_equal digest, Digest::MD5.hexdigest(response.body)
-      assert_equal content_type, response.content_type
-      assert_equal "attachment; filename=\"#{trace.id}.#{extension}\"", @response.header["Content-Disposition"]
+      assert_equal content_type, response.media_type
+      assert_equal "attachment; filename=\"#{trace.id}.#{extension}\"; filename*=UTF-8''#{trace.id}.#{extension}", @response.header["Content-Disposition"]
     end
 
     ##
index ac377848c9332d5afe66df800219059c8041db8e..3223eb5ddf29fa3b725195af64930d02ae481d81 100644 (file)
@@ -54,7 +54,7 @@ module Api
       # try the read again
       get :index
       assert_response :success
-      assert_equal "application/xml", @response.content_type
+      assert_equal "application/xml", @response.media_type
       assert_select "osm" do
         assert_select "preferences", :count => 1 do
           assert_select "preference", :count => 2
@@ -80,7 +80,7 @@ module Api
       # try the read again
       get :show, :params => { :preference_key => "key" }
       assert_response :success
-      assert_equal "text/plain", @response.content_type
+      assert_equal "text/plain", @response.media_type
       assert_equal "value", @response.body
 
       # try the read again for a non-existent key
@@ -114,7 +114,7 @@ module Api
         put :update_all, :body => "<osm><preferences><preference k='key' v='new_value'/><preference k='new_key' v='value'/></preferences></osm>"
       end
       assert_response :success
-      assert_equal "text/plain", @response.content_type
+      assert_equal "text/plain", @response.media_type
       assert_equal "", @response.body
       assert_equal "new_value", UserPreference.find([user.id, "key"]).v
       assert_equal "value", UserPreference.find([user.id, "new_key"]).v
@@ -127,7 +127,7 @@ module Api
         put :update_all, :body => "<osm><preferences><preference k='key' v='value'/><preference k='key' v='newer_value'/></preferences></osm>"
       end
       assert_response :bad_request
-      assert_equal "text/plain", @response.content_type
+      assert_equal "text/plain", @response.media_type
       assert_equal "Duplicate preferences with key key", @response.body
       assert_equal "new_value", UserPreference.find([user.id, "key"]).v
 
@@ -161,7 +161,7 @@ module Api
         put :update, :params => { :preference_key => "new_key" }, :body => "new_value"
       end
       assert_response :success
-      assert_equal "text/plain", @response.content_type
+      assert_equal "text/plain", @response.media_type
       assert_equal "", @response.body
       assert_equal "new_value", UserPreference.find([user.id, "new_key"]).v
 
@@ -170,7 +170,7 @@ module Api
         put :update, :params => { :preference_key => "new_key" }, :body => "newer_value"
       end
       assert_response :success
-      assert_equal "text/plain", @response.content_type
+      assert_equal "text/plain", @response.media_type
       assert_equal "", @response.body
       assert_equal "newer_value", UserPreference.find([user.id, "new_key"]).v
     end
@@ -196,7 +196,7 @@ module Api
         get :destroy, :params => { :preference_key => "key" }
       end
       assert_response :success
-      assert_equal "text/plain", @response.content_type
+      assert_equal "text/plain", @response.media_type
       assert_equal "", @response.body
       assert_raises ActiveRecord::RecordNotFound do
         UserPreference.find([user.id, "key"])
index de402ebf8ea80080c6c1fe8bdbcbd44d98fb5b0b..cc9d932bcb3e705b726a19e1a5a276bd572cdf1e 100644 (file)
@@ -34,7 +34,7 @@ module Api
       # check that a visible user is returned properly
       get :show, :params => { :id => user.id }
       assert_response :success
-      assert_equal "text/xml", response.content_type
+      assert_equal "text/xml", response.media_type
 
       # check the data that is returned
       assert_select "description", :count => 1, :text => "test"
@@ -90,7 +90,7 @@ module Api
       basic_authorization user.email, "test"
       get :details
       assert_response :success
-      assert_equal "text/xml", response.content_type
+      assert_equal "text/xml", response.media_type
 
       # check the data that is returned
       assert_select "description", :count => 1, :text => "test"
@@ -136,7 +136,7 @@ module Api
 
       get :index, :params => { :users => user1.id }
       assert_response :success
-      assert_equal "text/xml", response.content_type
+      assert_equal "text/xml", response.media_type
       assert_select "user", :count => 1 do
         assert_select "user[id='#{user1.id}']", :count => 1
         assert_select "user[id='#{user2.id}']", :count => 0
@@ -145,7 +145,7 @@ module Api
 
       get :index, :params => { :users => user2.id }
       assert_response :success
-      assert_equal "text/xml", response.content_type
+      assert_equal "text/xml", response.media_type
       assert_select "user", :count => 1 do
         assert_select "user[id='#{user1.id}']", :count => 0
         assert_select "user[id='#{user2.id}']", :count => 1
@@ -154,7 +154,7 @@ module Api
 
       get :index, :params => { :users => "#{user1.id},#{user3.id}" }
       assert_response :success
-      assert_equal "text/xml", response.content_type
+      assert_equal "text/xml", response.media_type
       assert_select "user", :count => 2 do
         assert_select "user[id='#{user1.id}']", :count => 1
         assert_select "user[id='#{user2.id}']", :count => 0
@@ -187,7 +187,7 @@ module Api
       basic_authorization user.email, "test"
       get :gpx_files
       assert_response :success
-      assert_equal "application/xml", response.content_type
+      assert_equal "application/xml", response.media_type
 
       # check the data that is returned
       assert_select "gpx_file[id='#{trace1.id}']", 1 do
index 2d13bd92bbbc614d1ecd6d9d267569d234c0167d..a1a00c5dc7d70f09314cbe2998668a9fc71d17c4 100644 (file)
@@ -22,7 +22,7 @@ class ChangesetCommentsControllerTest < ActionController::TestCase
 
     get :index, :params => { :format => "rss" }
     assert_response :success
-    assert_equal "application/rss+xml", @response.content_type
+    assert_equal "application/rss+xml", @response.media_type
     assert_select "rss", :count => 1 do
       assert_select "channel", :count => 1 do
         assert_select "item", :count => 3
@@ -31,7 +31,7 @@ class ChangesetCommentsControllerTest < ActionController::TestCase
 
     get :index, :params => { :format => "rss", :limit => 2 }
     assert_response :success
-    assert_equal "application/rss+xml", @response.content_type
+    assert_equal "application/rss+xml", @response.media_type
     assert_select "rss", :count => 1 do
       assert_select "channel", :count => 1 do
         assert_select "item", :count => 2
@@ -40,7 +40,7 @@ class ChangesetCommentsControllerTest < ActionController::TestCase
 
     get :index, :params => { :id => changeset.id, :format => "rss" }
     assert_response :success
-    assert_equal "application/rss+xml", @response.content_type
+    assert_equal "application/rss+xml", @response.media_type
     assert_select "rss", :count => 1 do
       assert_select "channel", :count => 1 do
         assert_select "item", :count => 3
index caf7721cd4ab425e483e7720f9147fc62cc41450..e754e32b71dac1ed67829c099b98596cf0f61c3f 100644 (file)
@@ -214,7 +214,7 @@ class ChangesetsControllerTest < ActionController::TestCase
     get :feed, :params => { :format => :atom }
     assert_response :success
     assert_template "index"
-    assert_equal "application/atom+xml", response.content_type
+    assert_equal "application/atom+xml", response.media_type
 
     check_feed_result([changeset, closed_changeset])
   end
@@ -232,7 +232,7 @@ class ChangesetsControllerTest < ActionController::TestCase
     get :feed, :params => { :format => :atom, :bbox => "4.5,4.5,5.5,5.5" }
     assert_response :success
     assert_template "index"
-    assert_equal "application/atom+xml", response.content_type
+    assert_equal "application/atom+xml", response.media_type
 
     check_feed_result([changeset, closed_changeset])
   end
@@ -250,7 +250,7 @@ class ChangesetsControllerTest < ActionController::TestCase
 
     assert_response :success
     assert_template "index"
-    assert_equal "application/atom+xml", response.content_type
+    assert_equal "application/atom+xml", response.media_type
 
     check_feed_result(changesets)
   end
index 84a6557946eb598d6be0e1a1d2de212bfbd32148..45b0358f5f957538ff2bd0b77ade2cf0a088810a 100644 (file)
@@ -681,7 +681,7 @@ class TracesControllerTest < ActionController::TestCase
   def check_trace_feed(traces)
     assert_response :success
     assert_template "georss"
-    assert_equal "application/rss+xml", @response.content_type
+    assert_equal "application/rss+xml", @response.media_type
     assert_select "rss", :count => 1 do
       assert_select "channel", :count => 1 do
         assert_select "title"
@@ -736,19 +736,19 @@ class TracesControllerTest < ActionController::TestCase
   def check_trace_data(trace, digest, content_type = "application/gpx+xml", extension = "gpx")
     assert_response :success
     assert_equal digest, Digest::MD5.hexdigest(response.body)
-    assert_equal content_type, response.content_type
-    assert_equal "attachment; filename=\"#{trace.id}.#{extension}\"", @response.header["Content-Disposition"]
+    assert_equal content_type, response.media_type
+    assert_equal "attachment; filename=\"#{trace.id}.#{extension}\"; filename*=UTF-8''#{trace.id}.#{extension}", @response.header["Content-Disposition"]
   end
 
   def check_trace_picture(trace)
     assert_response :success
-    assert_equal "image/gif", response.content_type
+    assert_equal "image/gif", response.media_type
     assert_equal trace.large_picture, response.body
   end
 
   def check_trace_icon(trace)
     assert_response :success
-    assert_equal "image/gif", response.content_type
+    assert_equal "image/gif", response.media_type
     assert_equal trace.icon_picture, response.body
   end
 end
index 82e8346469cff7828e221fff90faada2164a8e12..c35f73d349d7c90f415d73c6e7935feabafeb8c2 100644 (file)
@@ -9,7 +9,7 @@ class CORSTest < ActionDispatch::IntegrationTest
 
     assert_response :success
     assert_equal "*", response.headers["Access-Control-Allow-Origin"]
-    assert_nil response.content_type
+    assert_nil response.media_type
     assert_equal "", response.body
   end
 
@@ -21,7 +21,7 @@ class CORSTest < ActionDispatch::IntegrationTest
 
     assert_response :success
     assert_nil response.headers["Access-Control-Allow-Origin"]
-    assert_nil response.content_type
+    assert_nil response.media_type
     assert_equal "", response.body
   end
 end