From: Tom Hughes Date: Mon, 18 Jun 2018 19:46:00 +0000 (+0100) Subject: Update to rails 5.2.0 X-Git-Tag: live~2924 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/98de681e4711ad3bf5526e511002c8f0e91860a8 Update to rails 5.2.0 --- diff --git a/.rubocop.yml b/.rubocop.yml index e12437e08..24d57fb37 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -63,6 +63,11 @@ Style/HashSyntax: - 'lib/tasks/testing.rake' - 'config/initializers/wrap_parameters.rb' +Style/MixinUsage: + Exclude: + - 'bin/setup' + - 'bin/update' + Style/StringLiterals: EnforcedStyle: double_quotes diff --git a/Gemfile b/Gemfile index 4a403e251..90b3d6f2d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source "https://rubygems.org" # Require rails -gem "rails", "5.1.6" +gem "rails", "5.2.0" # Require things which have moved to gems in ruby 1.9 gem "bigdecimal", "~> 1.1.0", :platforms => :ruby_19 @@ -31,6 +31,9 @@ gem "jquery-rails" # gem 'jbuilder', '~> 2.0' gem "jsonify-rails" +# Reduces boot times through caching; required in config/boot.rb +gem 'bootsnap', '>= 1.1.0', require: false + # Use R2 for RTL conversion gem "r2", "~> 0.2.7" @@ -42,7 +45,7 @@ gem "image_optim_rails" # Load rails plugins gem "actionpack-page_caching" -gem "composite_primary_keys", "~> 10.0.4" +gem "composite_primary_keys", "~> 11.0.0" gem "dynamic_form" gem "http_accept_language", "~> 2.0.0" gem "i18n-js", ">= 3.0.0" diff --git a/Gemfile.lock b/Gemfile.lock index 6ee99f7c7..c4e40333a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,41 +4,45 @@ GEM SystemTimer (1.2.3) aasm (4.12.3) concurrent-ruby (~> 1.0) - actioncable (5.1.6) - actionpack (= 5.1.6) + actioncable (5.2.0) + actionpack (= 5.2.0) nio4r (~> 2.0) - websocket-driver (~> 0.6.1) - actionmailer (5.1.6) - actionpack (= 5.1.6) - actionview (= 5.1.6) - activejob (= 5.1.6) + websocket-driver (>= 0.6.1) + actionmailer (5.2.0) + actionpack (= 5.2.0) + actionview (= 5.2.0) + activejob (= 5.2.0) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.1.6) - actionview (= 5.1.6) - activesupport (= 5.1.6) + actionpack (5.2.0) + actionview (= 5.2.0) + activesupport (= 5.2.0) rack (~> 2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) actionpack-page_caching (1.1.0) actionpack (>= 4.0.0, < 6) - actionview (5.1.6) - activesupport (= 5.1.6) + actionview (5.2.0) + activesupport (= 5.2.0) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.1.6) - activesupport (= 5.1.6) + activejob (5.2.0) + activesupport (= 5.2.0) globalid (>= 0.3.6) - activemodel (5.1.6) - activesupport (= 5.1.6) - activerecord (5.1.6) - activemodel (= 5.1.6) - activesupport (= 5.1.6) - arel (~> 8.0) - activesupport (5.1.6) + activemodel (5.2.0) + activesupport (= 5.2.0) + activerecord (5.2.0) + activemodel (= 5.2.0) + activesupport (= 5.2.0) + arel (>= 9.0) + activestorage (5.2.0) + actionpack (= 5.2.0) + activerecord (= 5.2.0) + marcel (~> 0.3.1) + activesupport (5.2.0) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -48,9 +52,9 @@ GEM annotate (2.7.4) activerecord (>= 3.2, < 6.0) rake (>= 10.4, < 13.0) - arel (8.0.0) + arel (9.0.0) ast (2.4.0) - autoprefixer-rails (8.6.2) + autoprefixer-rails (8.6.3) execjs better_errors (2.4.0) coderay (>= 1.0.0) @@ -59,6 +63,8 @@ GEM bigdecimal (1.1.0) binding_of_caller (0.8.0) debug_inspector (>= 0.0.1) + bootsnap (1.3.0) + msgpack (~> 1.0) builder (3.2.3) canonical-rails (0.2.3) rails (>= 4.1, < 5.3) @@ -79,8 +85,8 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - composite_primary_keys (10.0.4) - activerecord (~> 5.1.0, >= 5.1.6) + composite_primary_keys (11.0.0) + activerecord (~> 5.2.0) concurrent-ruby (1.0.5) coveralls (0.8.21) json (>= 1.8, < 3) @@ -163,6 +169,8 @@ GEM nokogiri (>= 1.5.9) mail (2.7.0) mini_mime (>= 0.1.1) + marcel (0.3.2) + mimemagic (~> 0.3.2) method_source (0.9.0) mime-types (3.1) mime-types-data (~> 3.2015) @@ -171,6 +179,7 @@ GEM mini_mime (1.0.0) mini_portile2 (2.3.0) minitest (5.11.3) + msgpack (1.2.4) multi_json (1.13.1) multi_xml (0.6.0) multipart-post (2.0.0) @@ -248,17 +257,18 @@ GEM rack-test (1.0.0) rack (>= 1.0, < 3) rack-uri_sanitizer (0.0.2) - rails (5.1.6) - actioncable (= 5.1.6) - actionmailer (= 5.1.6) - actionpack (= 5.1.6) - actionview (= 5.1.6) - activejob (= 5.1.6) - activemodel (= 5.1.6) - activerecord (= 5.1.6) - activesupport (= 5.1.6) + rails (5.2.0) + actioncable (= 5.2.0) + actionmailer (= 5.2.0) + actionpack (= 5.2.0) + actionview (= 5.2.0) + activejob (= 5.2.0) + activemodel (= 5.2.0) + activerecord (= 5.2.0) + activestorage (= 5.2.0) + activesupport (= 5.2.0) bundler (>= 1.3.0) - railties (= 5.1.6) + railties (= 5.2.0) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.2) actionpack (~> 5.x, >= 5.0.1) @@ -272,9 +282,9 @@ GEM rails-i18n (4.0.2) i18n (~> 0.6) rails (>= 4.0) - railties (5.1.6) - actionpack (= 5.1.6) - activesupport (= 5.1.6) + railties (5.2.0) + actionpack (= 5.2.0) + activesupport (= 5.2.0) method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) @@ -354,7 +364,7 @@ GEM addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff - websocket-driver (0.6.5) + websocket-driver (0.7.0) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.3) xpath (3.1.0) @@ -372,10 +382,11 @@ DEPENDENCIES better_errors bigdecimal (~> 1.1.0) binding_of_caller + bootsnap (>= 1.1.0) canonical-rails capybara (~> 2.13) coffee-rails (~> 4.2) - composite_primary_keys (~> 10.0.4) + composite_primary_keys (~> 11.0.0) coveralls dalli dynamic_form @@ -413,7 +424,7 @@ DEPENDENCIES r2 (~> 0.2.7) rack-cors rack-uri_sanitizer - rails (= 5.1.6) + rails (= 5.2.0) rails-controller-testing rails-i18n (~> 4.0.0) record_tag_helper diff --git a/app/models/user.rb b/app/models/user.rb index aaa00169f..de5529e02 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -211,7 +211,7 @@ class User < ActiveRecord::Base .where("id != ?", id) .where(sql_for_area) .where("#{sql_for_distance} <= ?", radius) - .order(sql_for_distance) + .order(Arel.sql(sql_for_distance)) .limit(num) else nearby = [] diff --git a/app/views/layouts/_head.html.erb b/app/views/layouts/_head.html.erb index fbc9037fa..1d294dc82 100644 --- a/app/views/layouts/_head.html.erb +++ b/app/views/layouts/_head.html.erb @@ -36,5 +36,6 @@ <%= yield :head %> <%= yield :auto_discovery_link_tag %> <%= csrf_meta_tag %> + <%= csp_meta_tag %> <%= @title + ' | ' if @title %><%= t 'layouts.project_name.title' %> <% end %> diff --git a/bin/bundle b/bin/bundle new file mode 100755 index 000000000..67efc37fb --- /dev/null +++ b/bin/bundle @@ -0,0 +1,3 @@ +#!/usr/bin/env ruby +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) +load Gem.bin_path("bundler", "bundle") diff --git a/bin/rails b/bin/rails new file mode 100755 index 000000000..efc037749 --- /dev/null +++ b/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path("../config/application", __dir__) +require_relative "../config/boot" +require "rails/commands" diff --git a/bin/rake b/bin/rake new file mode 100755 index 000000000..4fbf10b96 --- /dev/null +++ b/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative "../config/boot" +require "rake" +Rake.application.run diff --git a/bin/setup b/bin/setup new file mode 100755 index 000000000..ebdfd0277 --- /dev/null +++ b/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require "fileutils" +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path("..", __dir__) + +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. + # 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 + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! "bin/rails db:setup" + + puts "\n== Removing old logs and tempfiles ==" + system! "bin/rails log:clear tmp:clear" + + puts "\n== Restarting application server ==" + system! "bin/rails restart" +end diff --git a/bin/update b/bin/update new file mode 100755 index 000000000..7bf318b63 --- /dev/null +++ b/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require "fileutils" +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path("..", __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts "== Installing dependencies ==" + system! "gem install bundler --conservative" + system("bundle check") || system!("bundle install") + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! "bin/rails db:migrate" + + puts "\n== Removing old logs and tempfiles ==" + system! "bin/rails log:clear tmp:clear" + + puts "\n== Restarting application server ==" + system! "bin/rails restart" +end diff --git a/bin/yarn b/bin/yarn new file mode 100755 index 000000000..38f278aa0 --- /dev/null +++ b/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path("..", __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg", *ARGV + rescue Errno::ENOENT + warn "Yarn executable was not detected in the system." + warn "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/config/application.rb b/config/application.rb index b6e2ba467..0a137abae 100644 --- a/config/application.rb +++ b/config/application.rb @@ -19,8 +19,9 @@ Bundler.require(*Rails.groups) module OpenStreetMap class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. # Custom directories with classes and modules you want to be autoloadable. config.autoload_paths += %W[#{config.root}/lib] diff --git a/config/boot.rb b/config/boot.rb index 282011619..988a5ddc4 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,4 @@ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) require "bundler/setup" # Set up gems listed in the Gemfile. +require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 000000000..c1ae78f92 --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: openstreetmap_production diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc new file mode 100644 index 000000000..e5cfef61e --- /dev/null +++ b/config/credentials.yml.enc @@ -0,0 +1 @@ +E6VWa9zDZ3CNpJ+ztv1UbvGamyL3N+U7DepOApwj4YE4NNvH2eYr4dqw6hALKKpp2O9OoPmwAzoJy9WarOnAHo67iwkU1ZdxRGoJNPlavsNgmAwFkEMH2AgBT4AkNzAhdHq9+wM32SvwOpxzvfLx9wJ439b0hY4QR3SBgPmp69LrOLjjLgIyUn3SVTendPBJ1fZxyHSxoKjQmmpT6+2YQA94ynfAy/m/6IY9VGbz9sinZBPdwx4krg+AG7qUqx3PDgZ388bl2g8uA35BPIpGnMNBkqQXjuRrFSi1ZkkJdj6NFDqZRkLNsDUDcOfxmYIRWgx3JSDekU8/24NkGeJ1/tOw2xILlQRASi6vdfHXYIqVmbHSrEdXsLQFUqv7FNHzfUtzdTDms6g3+bYhy+ZGpLdsD3maXm36p7/Z--i03uonfXALIIhWbt--6AuvcDUvj0AL5xl8DPeU7g== \ No newline at end of file diff --git a/config/daemons.yml b/config/daemons.yml deleted file mode 100644 index c9f78f583..000000000 --- a/config/daemons.yml +++ /dev/null @@ -1,5 +0,0 @@ -dir_mode: script -dir: ../../log -multiple: false -backtrace: true -monitor: true \ No newline at end of file diff --git a/config/environments/development.rb b/config/environments/development.rb index 97226480c..9065ed8e3 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -13,12 +13,13 @@ Rails.application.configure do config.consider_all_requests_local = true # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. if Rails.root.join("tmp", "caching-dev.txt").exist? config.action_controller.perform_caching = true config.cache_store = :memory_store config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{2.days.seconds.to_i}" + "Cache-Control" => "public, max-age=#{2.days.to_i}" } else config.action_controller.perform_caching = false @@ -26,6 +27,9 @@ Rails.application.configure do config.cache_store = :null_store end + # 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. config.action_mailer.raise_delivery_errors = false @@ -37,6 +41,9 @@ Rails.application.configure do # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load unless STATUS == :database_offline + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. diff --git a/config/environments/production.rb b/config/environments/production.rb index 56bd22881..430032143 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -14,10 +14,9 @@ Rails.application.configure do config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Attempt to read encrypted secrets from `config/secrets.yml.enc`. - # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or - # `config/secrets.yml.key`. - config.read_encrypted_secrets = true + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. @@ -39,6 +38,9 @@ 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) + config.active_storage.service = :local + # Mount Action Cable outside main process or domain # config.action_cable.mount_path = nil # config.action_cable.url = 'wss://example.com/cable' diff --git a/config/environments/test.rb b/config/environments/test.rb index 2dfea4ea4..482b1fb4c 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -15,7 +15,7 @@ Rails.application.configure do # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { - "Cache-Control" => "public, max-age=#{1.hour.seconds.to_i}" + "Cache-Control" => "public, max-age=#{1.hour.to_i}" } # Show full error reports and disable caching. @@ -27,6 +27,10 @@ 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 + config.active_storage.service = :test + config.action_mailer.perform_caching = false # Tell Action Mailer not to deliver emails to the real world. diff --git a/config/initializers/action_dispatch.rb b/config/initializers/action_dispatch.rb deleted file mode 100644 index 687ce3fb1..000000000 --- a/config/initializers/action_dispatch.rb +++ /dev/null @@ -1,2 +0,0 @@ -# Stop rails from automatically parsing XML in request bodies -Rails.configuration.middleware.delete ActionDispatch::ParamsParser diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb new file mode 100644 index 000000000..89d2efab2 --- /dev/null +++ b/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 161097530..cbd93c1d8 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -6,11 +6,12 @@ Rails.application.config.assets.version = "1.0" # Location of manifest file. Rails.application.config.assets.manifest = Rails.root.join("tmp", "manifest.json") -# Add additional assets to the asset load path +# Add additional assets to the asset load path. Rails.application.config.assets.paths << Rails.root.join("config") # Precompile additional assets. -# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. Rails.application.config.assets.precompile += %w[index.js browse.js welcome.js fixthemap.js] Rails.application.config.assets.precompile += %w[user.js login.js diary_entry.js messages.js edit/*.js] Rails.application.config.assets.precompile += %w[screen-ltr.css print-ltr.css] diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb new file mode 100644 index 000000000..d3bcaa5ec --- /dev/null +++ b/config/initializers/content_security_policy.rb @@ -0,0 +1,25 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy +# For further information see the following documentation +# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy + +# Rails.application.config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https + +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end + +# If you are using UJS then enable automatic nonce generation +# Rails.application.config.content_security_policy_nonce_generator = -> request { SecureRandom.base64(16) } + +# 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 +# Rails.application.config.content_security_policy_report_only = true diff --git a/config/master.key b/config/master.key new file mode 100644 index 000000000..bfcb1791c --- /dev/null +++ b/config/master.key @@ -0,0 +1 @@ +a895530f14add56693da9a6dbfd3cf97 \ No newline at end of file diff --git a/config/mongrel_cluster.yml b/config/mongrel_cluster.yml deleted file mode 100644 index d6c477b9a..000000000 --- a/config/mongrel_cluster.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- -log_file: log/mongrel.log -port: 8000 -pid_file: tmp/mongrel.pid -servers: 8 \ No newline at end of file diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 000000000..a5eccf816 --- /dev/null +++ b/config/puma.rb @@ -0,0 +1,34 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# 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 + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver 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). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. +# +# preload_app! + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/config/secrets.yml b/config/secrets.yml deleted file mode 100644 index 4704fad44..000000000 --- a/config/secrets.yml +++ /dev/null @@ -1,32 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Your secret key is used for verifying the integrity of signed cookies. -# If you change this key, all old signed cookies will become invalid! - -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -# You can use `rails secret` to generate a secure secret key. - -# Make sure the secrets in this file are kept private -# if you're sharing your code publicly. - -# Shared secrets are available across all environments. - -# shared: -# api_key: a1B2c3D4e5F6 - -# Environmental secrets are only available for that specific environment. - -development: - secret_key_base: 1ce5ed17771b4fdc3f755c5b98459d67816f99ec5889ec2fa7bf2bd3cba3ad5cc453693ce3c5d121669be478fb811136f4f483e6f39ac1f0e34ba66e8acab574 - -test: - secret_key_base: 10d52b1bf88c429e73ffbc5e5f58b037db21f38ea88b8b454e55d52ed8bcc6e7fe3b48a79b2f36eb78a4685224d707767d083f79c51f7d81a9d4a06d1c1e2534 - -# Do not keep production secrets in the unencrypted secrets file. -# Instead, either read values from the environment. -# Or, use `bin/rails secrets:setup` to configure encrypted secrets -# and move the `production:` environment over there. - -production: - secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> diff --git a/config/spring.rb b/config/spring.rb new file mode 100644 index 000000000..9fa7863f9 --- /dev/null +++ b/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/config/storage.yml b/config/storage.yml new file mode 100644 index 000000000..d32f76e8f --- /dev/null +++ b/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/script/rails b/script/rails deleted file mode 100755 index 4cea4ea17..000000000 --- a/script/rails +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env ruby -# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. - -APP_PATH = File.expand_path("../config/application", __dir__) -require File.expand_path("../config/boot", __dir__) -require "rails/commands" diff --git a/storage/.keep b/storage/.keep new file mode 100644 index 000000000..e69de29bb diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index 176f4903d..f39fc8d1d 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -8,9 +8,11 @@ WebMock.disable_net_connect!(:allow_localhost => true) # https://github.com/ariya/phantomjs/issues/14376 ENV["QT_QPA_PLATFORM"] = "phantom" if IO.popen(["phantomjs", "--version"], :err => :close).read.empty? -class ApplicationSystemTestCase < ActionDispatch::SystemTestCase +ActiveSupport.on_load(:action_dispatch_system_test_case) do ActionDispatch::SystemTesting::Server.silence_puma = true +end +class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :poltergeist, :screen_size => [1400, 1400] def initialize(*args) diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb index 80613a81a..89e5a3893 100644 --- a/test/helpers/application_helper_test.rb +++ b/test/helpers/application_helper_test.rb @@ -39,12 +39,12 @@ class ApplicationHelperTest < ActionView::TestCase def test_rss_link_to link = rss_link_to(:controller => :diary_entry, :action => :rss) - assert_dom_equal "\"Rss\"", link + assert_dom_equal "", link end def test_atom_link_to link = atom_link_to(:controller => :changeset, :action => :feed) - assert_dom_equal "\"Rss\"", link + assert_dom_equal "", link end def test_richtext_area diff --git a/test/test_helper.rb b/test/test_helper.rb index 7198519a7..f68c8e666 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,7 +2,7 @@ require "coveralls" Coveralls.wear!("rails") ENV["RAILS_ENV"] = "test" -require File.expand_path("../config/environment", __dir__) +require_relative "../config/environment" require "rails/test_help" require "webmock/minitest" @@ -130,7 +130,7 @@ module ActiveSupport end def stub_gravatar_request(email, status = 200, body = nil) - hash = Digest::MD5.hexdigest(email.downcase) + hash = ::Digest::MD5.hexdigest(email.downcase) url = "https://www.gravatar.com/avatar/#{hash}?d=404" stub_request(:get, url).and_return(:status => status, :body => body) end