# HG changeset patch # User nanaya # Date 1463081541 -32400 # Node ID 257910c60eb357776af86b07d5179d730cd43ffe # Parent e4cc80d729267fb9bacc9b8e63975c9d016e12d7 Rails 5 \o/ diff -r e4cc80d72926 -r 257910c60eb3 Gemfile --- a/Gemfile Tue Mar 01 16:34:29 2016 +0900 +++ b/Gemfile Fri May 13 04:32:21 2016 +0900 @@ -1,6 +1,6 @@ source "https://rubygems.org" -rails_ver = "~> 4.2.0" +rails_ver = "~> 5.0.0.rc1" gem "actionview", rails_ver gem "railties", rails_ver gem "actionpack", rails_ver diff -r e4cc80d72926 -r 257910c60eb3 Gemfile.lock --- a/Gemfile.lock Tue Mar 01 16:34:29 2016 +0900 +++ b/Gemfile.lock Fri May 13 04:32:21 2016 +0900 @@ -1,36 +1,37 @@ GEM remote: https://rubygems.org/ specs: - actionpack (4.2.5.2) - actionview (= 4.2.5.2) - activesupport (= 4.2.5.2) - rack (~> 1.6) - rack-test (~> 0.6.2) + actionpack (5.0.0.rc1) + actionview (= 5.0.0.rc1) + activesupport (= 5.0.0.rc1) + rack (~> 2.x) + rack-test (~> 0.6.3) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.5.2) - activesupport (= 4.2.5.2) + actionview (5.0.0.rc1) + activesupport (= 5.0.0.rc1) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - activesupport (4.2.5.2) + activesupport (5.0.0.rc1) + concurrent-ruby (~> 1.0, >= 1.0.2) i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.4.0) buftok (0.2.0) builder (3.2.2) + concurrent-ruby (1.0.2) + concurrent-ruby (1.0.2-java) dalli (2.7.6) - domain_name (0.5.20160216) + domain_name (0.5.20160310) unf (>= 0.0.5, < 1.0.0) equalizer (0.0.10) erubis (2.7.0) faraday (0.9.2) multipart-post (>= 1.2, < 3) - http (1.0.2) + http (1.0.4) addressable (~> 2.3) http-cookie (~> 1.0) http-form_data (~> 1.0.1) @@ -47,17 +48,19 @@ nokogiri (>= 1.5.9) memoizable (0.4.2) thread_safe (~> 0.3, >= 0.3.1) + method_source (0.8.2) mini_portile2 (2.0.0) minitest (5.8.4) multipart-post (2.0.0) naught (1.1.0) - newrelic_rpm (3.15.0.314) + newrelic_rpm (3.15.2.317) nokogiri (1.6.7.2) mini_portile2 (~> 2.0.0.rc2) nokogiri (1.6.7.2-java) nokogiri (1.6.7.2-x86-mingw32) mini_portile2 (~> 2.0.0.rc2) - rack (1.6.4) + rack (2.0.0.rc1) + json rack-test (0.6.3) rack (>= 1.0) rails-deprecated_sanitizer (1.0.3) @@ -68,12 +71,13 @@ rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.3) loofah (~> 2.0) - railties (4.2.5.2) - actionpack (= 4.2.5.2) - activesupport (= 4.2.5.2) + railties (5.0.0.rc1) + actionpack (= 5.0.0.rc1) + activesupport (= 5.0.0.rc1) + method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.5.0) + rake (11.1.2) simple_oauth (0.3.1) thor (0.19.1) thread_safe (0.3.5) @@ -89,7 +93,7 @@ memoizable (~> 0.4.0) naught (~> 1.0) simple_oauth (~> 0.3.0) - twitter-text (1.13.3) + twitter-text (1.13.4) unf (~> 0.1.0) tzinfo (1.2.2) thread_safe (~> 0.1) @@ -105,11 +109,11 @@ x86-mingw32 DEPENDENCIES - actionpack (~> 4.2.0) - actionview (~> 4.2.0) + actionpack (~> 5.0.0.rc1) + actionview (~> 5.0.0.rc1) dalli newrelic_rpm - railties (~> 4.2.0) + railties (~> 5.0.0.rc1) twitter twitter-text diff -r e4cc80d72926 -r 257910c60eb3 bin/rails --- a/bin/rails Tue Mar 01 16:34:29 2016 +0900 +++ b/bin/rails Fri May 13 04:32:21 2016 +0900 @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path('../../config/application', __FILE__) +APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff -r e4cc80d72926 -r 257910c60eb3 bin/setup --- a/bin/setup Tue Mar 01 16:34:29 2016 +0900 +++ b/bin/setup Fri May 13 04:32:21 2016 +0900 @@ -1,29 +1,34 @@ #!/usr/bin/env ruby require "pathname" +require "fileutils" +include FileUtils # path to your application root. -APP_ROOT = Pathname.new File.expand_path("../../", __FILE__) +APP_ROOT = Pathname.new File.expand_path("../../", __FILE__) -Dir.chdir APP_ROOT do +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: + # Add necessary setup steps to this file. puts "== Installing dependencies ==" - system "gem install bundler --conservative" - system "bundle check || bundle install" + system! "gem install bundler --conservative" + system("bundle check") || system!("bundle install") # puts "\n== Copying sample files ==" - # unless File.exist?("config/database.yml") - # system "cp config/database.yml.sample config/database.yml" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' # end puts "\n== Preparing database ==" - system "bin/rake db:setup" + system! "bin/rails db:setup" puts "\n== Removing old logs and tempfiles ==" - system "rm -f log/*" - system "rm -rf tmp/cache" + system! "bin/rails log:clear tmp:clear" puts "\n== Restarting application server ==" - system "touch tmp/restart.txt" + system! "bin/rails restart" end diff -r e4cc80d72926 -r 257910c60eb3 bin/update --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/update Fri May 13 04:32:21 2016 +0900 @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +require "pathname" +require "fileutils" +include FileUtils + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path("../../", __FILE__) + +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") + + 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 -r e4cc80d72926 -r 257910c60eb3 config.ru --- a/config.ru Tue Mar 01 16:34:29 2016 +0900 +++ b/config.ru Fri May 13 04:32:21 2016 +0900 @@ -1,4 +1,4 @@ # This file is used by Rack-based servers to start the application. -require ::File.expand_path('../config/environment', __FILE__) +require ::File.expand_path("../config/environment", __FILE__) run Rails.application diff -r e4cc80d72926 -r 257910c60eb3 config/application.rb --- a/config/application.rb Tue Mar 01 16:34:29 2016 +0900 +++ b/config/application.rb Fri May 13 04:32:21 2016 +0900 @@ -1,4 +1,4 @@ -require File.expand_path("../boot", __FILE__) +require_relative "boot" # Pick the frameworks you want: # require "active_model/railtie" @@ -9,7 +9,7 @@ # require "sprockets/railtie" require "rails/test_unit/railtie" -require File.expand_path("../config_init", __FILE__) +require_relative "config_init" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. @@ -28,7 +28,7 @@ # 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] # config.i18n.default_locale = :de - config.middleware.delete "ActionDispatch::Cookies" + config.middleware.delete ActionDispatch::Cookies # this isn't actually used but railties checks this variable during boot. config.secret_key_base = "herp a derp" diff -r e4cc80d72926 -r 257910c60eb3 config/boot.rb --- a/config/boot.rb Tue Mar 01 16:34:29 2016 +0900 +++ b/config/boot.rb Fri May 13 04:32:21 2016 +0900 @@ -1,4 +1,3 @@ -# Set up gems listed in the Gemfile. -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", __FILE__) +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) -require "bundler/setup" if File.exist?(ENV["BUNDLE_GEMFILE"]) +require "bundler/setup" # Set up gems listed in the Gemfile. diff -r e4cc80d72926 -r 257910c60eb3 config/environment.rb --- a/config/environment.rb Tue Mar 01 16:34:29 2016 +0900 +++ b/config/environment.rb Fri May 13 04:32:21 2016 +0900 @@ -1,5 +1,5 @@ # Load the Rails application. -require File.expand_path("../application", __FILE__) +require_relative "application" # Initialize the Rails application. Rails.application.initialize! diff -r e4cc80d72926 -r 257910c60eb3 config/environments/development.rb --- a/config/environments/development.rb Tue Mar 01 16:34:29 2016 +0900 +++ b/config/environments/development.rb Fri May 13 04:32:21 2016 +0900 @@ -9,16 +9,43 @@ # Do not eager load code on boot. config.eager_load = false - # Show full error reports and disable caching. - config.consider_all_requests_local = true - config.action_controller.perform_caching = false + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + 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=172800" + } + else + config.action_controller.perform_caching = false + + # config.cache_store = :null_store + end # Don't care if the mailer can't send. # config.action_mailer.raise_delivery_errors = false + # config.action_mailer.perform_caching = false + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log + # Raise an error on page load if there are pending migrations. + # config.active_record.migration_error = :page_load + + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + # config.assets.debug = true + # 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, + # routes, locales, etc. This feature depends on the listen gem. + # config.file_watcher = ActiveSupport::EventedFileUpdateChecker end diff -r e4cc80d72926 -r 257910c60eb3 config/environments/production.rb --- a/config/environments/production.rb Tue Mar 01 16:34:29 2016 +0900 +++ b/config/environments/production.rb Fri May 13 04:32:21 2016 +0900 @@ -14,42 +14,50 @@ config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Enable Rack::Cache to put a simple HTTP cache in front of your application - # Add `rack-cache` to your Gemfile before enabling this. - # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. - # config.action_dispatch.rack_cache = true + # Disable serving static files from the `/public` folder by default since + # 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 + # config.assets.css_compressor = :sass - # Disable Rails's static asset server (Apache or nginx will already do this). - config.serve_static_files = false + # 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' # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + + # Action Cable endpoint configuration + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + + # Don't mount Action Cable in the main server process. + # config.action_cable.mount_path = nil # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new - - # Set to :debug to see everything in the log. - config.log_level = :warn - config.logger = ::Logger.new(STDOUT) - - # Recommended by http://help.papertrailapp.com/kb/configuration/unicorn - config.logger.level = Logger.const_get("WARN") + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug # Prepend all log lines with the following tags. - # config.log_tags = [ :subdomain, :uuid ] - - # Use a different logger for distributed setups. - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + config.log_tags = [:request_id] # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = "http://assets.example.com" + # 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 = "rsstweet_#{Rails.env}" + # config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. @@ -62,6 +70,19 @@ # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify - # Disable automatic flushing of the log to improve performance. - # config.autoflush_log = false + # Use default logging formatter so that PID and timestamp are not suppressed. + config.log_formatter = ::Logger::Formatter.new + + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + # if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + # end + + # Do not dump schema after migrations. + # config.active_record.dump_schema_after_migration = false end diff -r e4cc80d72926 -r 257910c60eb3 config/environments/test.rb --- a/config/environments/test.rb Tue Mar 01 16:34:29 2016 +0900 +++ b/config/environments/test.rb Fri May 13 04:32:21 2016 +0900 @@ -12,9 +12,11 @@ # preloads Rails for running tests, you may have to set it to true. config.eager_load = false - # Configure static asset server for tests with Cache-Control for performance. - config.serve_static_files = true - config.static_cache_control = "public, max-age=3600" + # 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=3600" + } # Show full error reports and disable caching. config.consider_all_requests_local = true @@ -25,6 +27,7 @@ # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false + # config.action_mailer.perform_caching = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the @@ -36,6 +39,4 @@ # Raises error for missing translations # config.action_view.raise_on_missing_translations = true - - config.active_support.test_order = :random end diff -r e4cc80d72926 -r 257910c60eb3 config/initializers/application_controller_renderer.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/initializers/application_controller_renderer.rb Fri May 13 04:32:21 2016 +0900 @@ -0,0 +1,6 @@ +# Be sure to restart your server when you modify this file. + +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) diff -r e4cc80d72926 -r 257910c60eb3 config/initializers/assets.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/initializers/assets.rb Fri May 13 04:32:21 2016 +0900 @@ -0,0 +1,11 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +# Rails.application.config.assets.version = "1.0" + +# Add additional assets to the asset load path +# Rails.application.config.assets.paths << Emoji.images_path + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff -r e4cc80d72926 -r 257910c60eb3 config/initializers/backtrace_silencers.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/initializers/backtrace_silencers.rb Fri May 13 04:32:21 2016 +0900 @@ -0,0 +1,7 @@ +# 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/ } + +# 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! diff -r e4cc80d72926 -r 257910c60eb3 config/initializers/cache_logging.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/initializers/cache_logging.rb Fri May 13 04:32:21 2016 +0900 @@ -0,0 +1,1 @@ +ActiveSupport::Cache::Store.logger = Rails.logger if Rails.env.development? diff -r e4cc80d72926 -r 257910c60eb3 config/initializers/cookies_serializer.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/initializers/cookies_serializer.rb Fri May 13 04:32:21 2016 +0900 @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :marshal diff -r e4cc80d72926 -r 257910c60eb3 config/initializers/filter_parameter_logging.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/initializers/filter_parameter_logging.rb Fri May 13 04:32:21 2016 +0900 @@ -0,0 +1,4 @@ +# 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] diff -r e4cc80d72926 -r 257910c60eb3 config/initializers/inflections.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/initializers/inflections.rb Fri May 13 04:32:21 2016 +0900 @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym 'RESTful' +# end diff -r e4cc80d72926 -r 257910c60eb3 config/initializers/mime_types.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/initializers/mime_types.rb Fri May 13 04:32:21 2016 +0900 @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf diff -r e4cc80d72926 -r 257910c60eb3 config/initializers/per_form_csrf_tokens.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/initializers/per_form_csrf_tokens.rb Fri May 13 04:32:21 2016 +0900 @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Enable per-form CSRF tokens. +Rails.application.config.action_controller.per_form_csrf_tokens = true diff -r e4cc80d72926 -r 257910c60eb3 config/initializers/request_forgery_protection.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/initializers/request_forgery_protection.rb Fri May 13 04:32:21 2016 +0900 @@ -0,0 +1,4 @@ +# Be sure to restart your server when you modify this file. + +# Enable origin-checking CSRF mitigation. +Rails.application.config.action_controller.forgery_protection_origin_check = true diff -r e4cc80d72926 -r 257910c60eb3 config/initializers/session_store.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/initializers/session_store.rb Fri May 13 04:32:21 2016 +0900 @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.session_store :cookie_store, :key => "_rsstweet_session" diff -r e4cc80d72926 -r 257910c60eb3 config/initializers/wrap_parameters.rb --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/config/initializers/wrap_parameters.rb Fri May 13 04:32:21 2016 +0900 @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# This file contains settings for ActionController::ParamsWrapper which +# is enabled by default. + +# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. +ActiveSupport.on_load(:action_controller) do + wrap_parameters :format => [:json] +end + +# To enable root element in JSON for ActiveRecord objects. +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff -r e4cc80d72926 -r 257910c60eb3 test/controllers/tweets_controller_test.rb --- a/test/controllers/tweets_controller_test.rb Tue Mar 01 16:34:29 2016 +0900 +++ b/test/controllers/tweets_controller_test.rb Fri May 13 04:32:21 2016 +0900 @@ -2,17 +2,17 @@ class TweetsControllerTest < ActionController::TestCase test "should get show" do - get :show, :id => "2791517370/edogawa_test", :format => :atom + get :show, :params => { :id => "2791517370/edogawa_test", :format => :atom } assert_response :success end test "does not explode on empty timeline" do - get :show, :id => "3168319146/nanaya_t_empty", :format => :atom + get :show, :params => { :id => "3168319146/nanaya_t_empty", :format => :atom } assert_response :success end test "redirect on @handle access" do - get :show, :id => "edogawa_test", :format => :atom + get :show, :params => { :id => "edogawa_test", :format => :atom } assert_redirected_to "/2791517370/edogawa_test" end