From 8c852d689d47ba257de032285b2b276bd7c83617 Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Tue, 26 Nov 2019 17:09:28 +0900 Subject: [PATCH 01/21] Exec bundle update --- Gemfile.lock | 6 +++--- gemfiles/Gemfile.jruby.lock | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 15cd304f3..573fe3c16 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -98,8 +98,8 @@ GEM railties (>= 3.2, < 6.1) erubis (2.7.0) execjs (2.7.0) - fabrication (2.20.2) - ffi (1.11.2) + fabrication (2.21.0) + ffi (1.11.3) formatador (0.2.5) gherkin (5.1.0) globalid (0.4.2) @@ -165,7 +165,7 @@ GEM listen (3.2.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - loofah (2.3.1) + loofah (2.4.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) lumberjack (1.0.13) diff --git a/gemfiles/Gemfile.jruby.lock b/gemfiles/Gemfile.jruby.lock index 059db7ece..6a1c05e72 100644 --- a/gemfiles/Gemfile.jruby.lock +++ b/gemfiles/Gemfile.jruby.lock @@ -73,9 +73,9 @@ GEM railties (>= 3.2, < 6.1) erubis (2.7.0) execjs (2.7.0) - fabrication (2.20.2) - ffi (1.11.2) - ffi (1.11.2-java) + fabrication (2.21.0) + ffi (1.11.3) + ffi (1.11.3-java) globalid (0.4.2) activesupport (>= 4.2.0) haml (5.1.2) @@ -128,7 +128,7 @@ GEM launchy (2.4.3-java) addressable (~> 2.3) spoon (~> 0.0.1) - loofah (2.3.1) + loofah (2.4.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) From 94db4c7b3c3909efdb977fcc48959957240cdbde Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Thu, 28 Nov 2019 17:25:07 +0900 Subject: [PATCH 02/21] Update rails --- Gemfile | 10 ++-- Gemfile.lock | 157 ++++++++++++++++++++++++++------------------------- 2 files changed, 87 insertions(+), 80 deletions(-) diff --git a/Gemfile b/Gemfile index 7a9135c07..598c3f27f 100644 --- a/Gemfile +++ b/Gemfile @@ -7,7 +7,7 @@ source 'http://rubygems.org' ### Please see gemfiles/Gemfile.jruby for JRuby env ### -gem 'rails', '~> 4.2.11' +gem 'rails', '~> 5.2.1' # Use unicorn as the web server # gem 'unicorn' @@ -35,6 +35,7 @@ group :test do gem 'capybara-webkit', '>= 1.0.0' gem 'cucumber-rails', require: false gem 'growl' + gem 'rails-controller-testing' gem 'rb-fsevent' gem 'simplecov' gem 'spork' @@ -56,8 +57,8 @@ group :production do gem 'redis-store', '>= 1.4.0' end -gem 'capistrano', '~> 2.0' -gem 'rvm-capistrano' +# gem 'capistrano', '~> 2.0' +# gem 'rvm-capistrano' gem 'mysql2' # for AR-4.2 @@ -65,7 +66,8 @@ gem 'pg', '~> 0.21' # for AR-4.2 gem 'sqlite3', '~> 1.3.11' -gem 'coffee-rails', '~> 4.1.0' +gem 'bootsnap', require: false +gem 'coffee-rails' #, '~> 4.1.0' gem 'haml', '>= 5.0.0' gem 'haml-rails' gem 'i18n' diff --git a/Gemfile.lock b/Gemfile.lock index a920d64e6..a23cbfa0f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,53 +1,56 @@ GEM remote: http://rubygems.org/ specs: - actionmailer (4.2.11.1) - actionpack (= 4.2.11.1) - actionview (= 4.2.11.1) - activejob (= 4.2.11.1) + actioncable (5.2.1) + actionpack (= 5.2.1) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.1) + actionpack (= 5.2.1) + actionview (= 5.2.1) + activejob (= 5.2.1) mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.11.1) - actionview (= 4.2.11.1) - activesupport (= 4.2.11.1) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) + rails-dom-testing (~> 2.0) + actionpack (5.2.1) + actionview (= 5.2.1) + activesupport (= 5.2.1) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.11.1) - activesupport (= 4.2.11.1) + actionview (5.2.1) + activesupport (= 5.2.1) builder (~> 3.1) - erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (4.2.11.1) - activesupport (= 4.2.11.1) - globalid (>= 0.3.0) - activemodel (4.2.11.1) - activesupport (= 4.2.11.1) - builder (~> 3.1) - activerecord (4.2.11.1) - activemodel (= 4.2.11.1) - activesupport (= 4.2.11.1) - arel (~> 6.0) - activesupport (4.2.11.1) - i18n (~> 0.7) + activejob (5.2.1) + activesupport (= 5.2.1) + globalid (>= 0.3.6) + activemodel (5.2.1) + activesupport (= 5.2.1) + activerecord (5.2.1) + activemodel (= 5.2.1) + activesupport (= 5.2.1) + arel (>= 9.0) + activestorage (5.2.1) + actionpack (= 5.2.1) + activerecord (= 5.2.1) + marcel (~> 0.3.1) + activesupport (5.2.1) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) - arel (6.0.4) + arel (9.0.0) ast (2.4.0) backports (3.15.0) + bootsnap (1.4.5) + msgpack (~> 1.0) builder (3.2.3) byebug (11.0.1) - capistrano (2.15.9) - highline - net-scp (>= 1.0.0) - net-sftp (>= 2.0.0) - net-ssh (>= 2.0.14) - net-ssh-gateway (>= 1.1.0) capybara (3.29.0) addressable mini_mime (>= 0.1.3) @@ -61,9 +64,9 @@ GEM json childprocess (3.0.0) coderay (1.1.2) - coffee-rails (4.1.1) + coffee-rails (5.0.0) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.1.x) + railties (>= 5.2.0) coffee-script (2.4.1) coffee-script-source execjs @@ -102,6 +105,7 @@ GEM dotenv-rails (2.7.5) dotenv (= 2.7.5) railties (>= 3.2, < 6.1) + erubi (1.9.0) erubis (2.7.0) execjs (2.7.0) fabrication (2.21.0) @@ -148,13 +152,12 @@ GEM rainbow rubocop (>= 0.50.0) sysexits (~> 1.1) - highline (2.0.3) html2haml (2.2.0) erubis (~> 2.7.0) haml (>= 4.0, < 6) nokogiri (>= 1.6.0) ruby_parser (~> 3.5) - i18n (0.9.5) + i18n (1.7.0) concurrent-ruby (~> 1.0) jaro_winkler (1.5.4) jbuilder (2.9.1) @@ -178,25 +181,22 @@ GEM lumberjack (1.0.13) mail (2.7.1) mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) memoist (0.16.1) method_source (0.9.2) mime-types (3.3) mime-types-data (~> 3.2015) mime-types-data (3.2019.1009) + mimemagic (0.3.3) mini_mime (1.0.2) mini_portile2 (2.4.0) minitest (5.13.0) + msgpack (1.3.1) multi_json (1.14.1) multi_test (0.1.2) mysql2 (0.5.2) nenv (0.3.0) - net-scp (2.0.0) - net-ssh (>= 2.6.5, < 6.0.0) - net-sftp (2.1.2) - net-ssh (>= 2.6.5) - net-ssh (5.2.0) - net-ssh-gateway (2.0.0) - net-ssh (>= 4.0.0) nio4r (2.5.2) nokogiri (1.10.5) mini_portile2 (~> 2.4.0) @@ -213,37 +213,41 @@ GEM public_suffix (4.0.1) puma (4.3.0) nio4r (~> 2.0) - rack (1.6.11) - rack-test (0.6.3) - rack (>= 1.0) - rails (4.2.11.1) - actionmailer (= 4.2.11.1) - actionpack (= 4.2.11.1) - actionview (= 4.2.11.1) - activejob (= 4.2.11.1) - activemodel (= 4.2.11.1) - activerecord (= 4.2.11.1) - activesupport (= 4.2.11.1) - bundler (>= 1.3.0, < 2.0) - railties (= 4.2.11.1) - sprockets-rails - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.9) - activesupport (>= 4.2.0, < 5.0) - nokogiri (~> 1.6) - rails-deprecated_sanitizer (>= 1.0.1) + rack (2.0.7) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.1) + actioncable (= 5.2.1) + actionmailer (= 5.2.1) + actionpack (= 5.2.1) + actionview (= 5.2.1) + activejob (= 5.2.1) + activemodel (= 5.2.1) + activerecord (= 5.2.1) + activestorage (= 5.2.1) + activesupport (= 5.2.1) + bundler (>= 1.3.0) + railties (= 5.2.1) + sprockets-rails (>= 2.0.0) + rails-controller-testing (1.0.4) + actionpack (>= 5.0.1.x) + actionview (>= 5.0.1.x) + activesupport (>= 5.0.1.x) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) rails-observers (0.1.5) activemodel (>= 4.0) rails_emoji (1.7.1) rails (>= 3.1.0) - railties (4.2.11.1) - actionpack (= 4.2.11.1) - activesupport (= 4.2.11.1) + railties (5.2.1) + actionpack (= 5.2.1) + activesupport (= 5.2.1) + method_source rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) + thor (>= 0.19.0, < 2.0) rainbow (3.0.0) rake (13.0.1) rb-fsevent (0.10.3) @@ -308,8 +312,6 @@ GEM ruby-progressbar (1.10.1) ruby_parser (3.14.1) sexp_processor (~> 4.9) - rvm-capistrano (1.5.6) - capistrano (~> 2.15.4) sass (3.7.4) sass-listen (~> 4.0.0) sass-listen (4.0.0) @@ -361,6 +363,9 @@ GEM nokogiri (>= 1.2.0) rack (>= 1.0) rack-test (>= 0.5.3) + websocket-driver (0.7.1) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.4) xpath (3.2.0) nokogiri (~> 1.8) @@ -368,11 +373,11 @@ PLATFORMS ruby DEPENDENCIES + bootsnap byebug - capistrano (~> 2.0) capybara (>= 2.2.0) capybara-webkit (>= 1.0.0) - coffee-rails (~> 4.1.0) + coffee-rails connection_pool cucumber-rails database_cleaner (>= 1.2.0) @@ -397,7 +402,8 @@ DEPENDENCIES mysql2 pg (~> 0.21) puma - rails (~> 4.2.11) + rails (~> 5.2.1) + rails-controller-testing rails-observers rails_emoji rb-fsevent @@ -408,7 +414,6 @@ DEPENDENCIES rspec-collection_matchers rspec-rails (>= 2.13.1) rubocop - rvm-capistrano sass-rails (~> 5.0) settingslogic simplecov From f817215863468f79503b4490d051114f9de4868e Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Thu, 28 Nov 2019 17:25:39 +0900 Subject: [PATCH 03/21] Use prepend because alias_method_chain is obsolete --- lib/arel_node_match_postgres_ext.rb | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/arel_node_match_postgres_ext.rb b/lib/arel_node_match_postgres_ext.rb index 647dcfdd6..9ca10b7e8 100644 --- a/lib/arel_node_match_postgres_ext.rb +++ b/lib/arel_node_match_postgres_ext.rb @@ -4,15 +4,8 @@ module ArelExt module Visitors module PostgreSQL module InstanceMethods - def self.included(base) - base.class_eval do - alias_method_chain :visit_Arel_Nodes_Matches, :format_sql92 - alias_method_chain :visit_Arel_Nodes_DoesNotMatch, :format_sql92 - end - end - - def visit_Arel_Nodes_Matches_with_format_sql92 o, a - collector = visit_Arel_Nodes_Matches_without_format_sql92(o, a) + def visit_Arel_Nodes_Matches o, a + collector = super if o.escape collector << ' ESCAPE ' visit o.escape, collector @@ -21,8 +14,8 @@ def visit_Arel_Nodes_Matches_with_format_sql92 o, a end end - def visit_Arel_Nodes_DoesNotMatch_with_format_sql92 o, a - collector = visit_Arel_Nodes_DoesNotMatch_without_format_sql92(o, a) + def visit_Arel_Nodes_DoesNotMatch o, a + collector = super if o.escape collector << ' ESCAPE ' visit o.escape, collector @@ -36,5 +29,5 @@ def visit_Arel_Nodes_DoesNotMatch_with_format_sql92 o, a end ActiveSupport.on_load(:active_record) do - Arel::Visitors::PostgreSQL.send(:include, ArelExt::Visitors::PostgreSQL::InstanceMethods) + Arel::Visitors::PostgreSQL.prepend ArelExt::Visitors::PostgreSQL::InstanceMethods end From fa01fdf328af720e01d250a81bc7c49bd4350b55 Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Thu, 28 Nov 2019 17:27:29 +0900 Subject: [PATCH 04/21] Exec rails app:update --- bin/setup | 33 +++++++++------- bin/update | 31 +++++++++++++++ bin/yarn | 11 ++++++ config/application.rb | 3 -- config/boot.rb | 3 +- config/cable.yml | 10 +++++ config/environment.rb | 2 +- .../application_controller_renderer.rb | 8 ++++ .../initializers/content_security_policy.rb | 25 ++++++++++++ .../new_framework_defaults_5_2.rb | 38 +++++++++++++++++++ config/initializers/wrap_parameters.rb | 5 +-- config/puma.rb | 34 +++++++++++++++++ config/routes.rb | 2 +- config/storage.yml | 34 +++++++++++++++++ 14 files changed, 216 insertions(+), 23 deletions(-) create mode 100755 bin/update create mode 100755 bin/yarn create mode 100644 config/cable.yml create mode 100644 config/initializers/application_controller_renderer.rb create mode 100644 config/initializers/content_security_policy.rb create mode 100644 config/initializers/new_framework_defaults_5_2.rb create mode 100644 config/puma.rb create mode 100644 config/storage.yml diff --git a/bin/setup b/bin/setup index 0a3b26fea..94fd4d797 100755 --- a/bin/setup +++ b/bin/setup @@ -1,31 +1,36 @@ #!/usr/bin/env ruby -# frozen_string_literal: true - -require 'pathname' +require 'fileutils' +include FileUtils # path to your application root. -APP_ROOT = Pathname.new File.expand_path('..', __dir__) +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end -Dir.chdir APP_ROOT do +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') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') # 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 --git a/bin/update b/bin/update new file mode 100755 index 000000000..58bfaed51 --- /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..460dd565b --- /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 + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/config/application.rb b/config/application.rb index 02bb4148f..6b04e1c8d 100644 --- a/config/application.rb +++ b/config/application.rb @@ -61,8 +61,5 @@ class Application < Rails::Application g.test_framework :rspec, fixture: true g.fixture_replacement :fabrication end - - # Do not swallow errors in after_commit/after_rollback callbacks. - config.active_record.raise_in_transactional_callbacks = true end end diff --git a/config/boot.rb b/config/boot.rb index 6b750f00b..b9e460cef 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,4 @@ -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +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..8becce680 --- /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: sanataro_production diff --git a/config/environment.rb b/config/environment.rb index ee8d90dc6..426333bb4 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -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 --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/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/initializers/new_framework_defaults_5_2.rb b/config/initializers/new_framework_defaults_5_2.rb new file mode 100644 index 000000000..c383d072b --- /dev/null +++ b/config/initializers/new_framework_defaults_5_2.rb @@ -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/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 12a2508e2..bbfc3961b 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -1,4 +1,3 @@ -# frozen_string_literal: true # Be sure to restart your server when you modify this file. # This file contains settings for ActionController::ParamsWrapper which @@ -6,10 +5,10 @@ # 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] if respond_to?(:wrap_parameters) + 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 +# self.include_root_in_json = true # end 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/routes.rb b/config/routes.rb index 773937177..abfe191fd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,4 @@ -Sanataro::Application.routes.draw do +Rails.application.routes.draw do use_doorkeeper root to: "login#login" 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 ] From 38e8e4074d6625ac39f22d55f992d700c7d1e368 Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Thu, 28 Nov 2019 17:28:20 +0900 Subject: [PATCH 05/21] Throw abort for error on destroy --- app/models/account.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/account.rb b/app/models/account.rb index f4246e118..20cbea854 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -72,7 +72,8 @@ def error_if_items_exist items_table = Item.arel_table item = Item.where(items_table[:from_account_id].eq(id).or(items_table[:to_account_id].eq(id))).first errors[:base] << I18n.t('error.already_used_account') + "#{I18n.l(item.action_date)} #{item.name} #{number_to_currency(item.amount)}" if item - errors.empty? + + throw :abort unless errors.empty? end def clear_cache @@ -83,7 +84,8 @@ def error_if_credit_relations_exist cr_table = CreditRelation.arel_table credit_rel = CreditRelation.where(cr_table[:credit_account_id].eq(id).or(cr_table[:payment_account_id].eq(id))).first errors[:base] << I18n.t('error.already_has_relation_to_credit') if credit_rel - errors.empty? + + throw :abort unless errors.empty? end class << self From bc4dd5ac091be7dbca0887eda8ef17a8802a54c6 Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Thu, 28 Nov 2019 17:29:42 +0900 Subject: [PATCH 06/21] Fix delete_all changes of args --- app/models/autologin_key.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/autologin_key.rb b/app/models/autologin_key.rb index a052e4b01..07062bf09 100644 --- a/app/models/autologin_key.rb +++ b/app/models/autologin_key.rb @@ -20,7 +20,7 @@ def matched_key(user_id, plain_key) end def cleanup - AutologinKey.delete_all(['created_at < ?', Time.now - (30 * 24 * 3600)]) + AutologinKey.where('created_at < ?', Time.now - (30 * 24 * 3600)).delete_all end end From 5f801dc413ba4ea2c07e67a95558ae52e34b41ee Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Thu, 28 Nov 2019 17:30:16 +0900 Subject: [PATCH 07/21] Make use of prepend instead of alias_method_chain --- app/controllers/api.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/api.rb b/app/controllers/api.rb index e47fd0931..2e74c42e2 100644 --- a/app/controllers/api.rb +++ b/app/controllers/api.rb @@ -41,15 +41,14 @@ def authenticate_via_api module General def self.included(base) base.class_eval do - include Api::General::InstanceMethods - alias_method_chain :verified_request?, :condition + prepend Api::General::InstanceMethods end end module InstanceMethods # override the method which checks CSRF token. def verified_request_with_condition? - doorkeeper_token || request.authorization.present? || verified_request_without_condition? + doorkeeper_token || request.authorization.present? || super end end end From 7864f192d2363dc151eba607eee22ad4031213c0 Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Thu, 28 Nov 2019 19:14:40 +0900 Subject: [PATCH 08/21] Change be_success to be_successful in rspec --- .../admin/users_controller_spec.rb | 8 +- .../api/accounts_controller_spec.rb | 6 +- .../api/entries_controller_spec.rb | 44 +++--- .../balance_sheets_controller_spec.rb | 10 +- .../chart_data/assets_controller_spec.rb | 6 +- .../chart_data/budgets_controller_spec.rb | 6 +- .../yearly_assets_controller_spec.rb | 4 +- .../yearly_budgets_controller_spec.rb | 13 +- .../confirmation_requireds_controller_spec.rb | 10 +- spec/controllers/entries_controller_spec.rb | 130 +++++++++--------- .../entry_candidates_controller_spec.rb | 6 +- spec/controllers/login_controller_spec.rb | 12 +- .../profit_losses_controller_spec.rb | 6 +- .../settings/accounts_controller_spec.rb | 2 +- .../credit_relations_controller_spec.rb | 10 +- .../settings/users_controller_spec.rb | 4 +- .../tag_statuses_controller_spec.rb | 2 +- 17 files changed, 140 insertions(+), 139 deletions(-) diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index c1ed245c3..40d2a2d68 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -44,7 +44,7 @@ def mock_user get :index end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end end @@ -106,7 +106,7 @@ def mock_user end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index' } end end @@ -129,7 +129,7 @@ def mock_user end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index' } end end @@ -187,7 +187,7 @@ def mock_user end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index' } end end diff --git a/spec/controllers/api/accounts_controller_spec.rb b/spec/controllers/api/accounts_controller_spec.rb index 47edaeaaa..2f6c9c1c6 100644 --- a/spec/controllers/api/accounts_controller_spec.rb +++ b/spec/controllers/api/accounts_controller_spec.rb @@ -22,7 +22,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template :index } end end @@ -57,7 +57,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template :index } end end @@ -83,7 +83,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template :index } end end diff --git a/spec/controllers/api/entries_controller_spec.rb b/spec/controllers/api/entries_controller_spec.rb index 74e6dcbfa..87d719874 100644 --- a/spec/controllers/api/entries_controller_spec.rb +++ b/spec/controllers/api/entries_controller_spec.rb @@ -43,7 +43,7 @@ shared_examples_for 'Success in JSON' do describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index' } end end @@ -113,7 +113,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index' } end @@ -148,7 +148,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index' } end @@ -183,7 +183,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index' } end @@ -202,7 +202,7 @@ shared_examples_for 'filtered index in JSON' do describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index' } end @@ -271,7 +271,7 @@ shared_examples_for 'executed correctly in JSON' do describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index' } end end @@ -369,7 +369,7 @@ end describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'show' } end @@ -445,7 +445,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#content_type' do subject { super().content_type } @@ -511,7 +511,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#content_type' do subject { super().content_type } @@ -567,7 +567,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'amount of from_account' do @@ -609,7 +609,7 @@ describe 'response' do before { action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'specified item' do @@ -650,7 +650,7 @@ describe 'response' do before { action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#content_type' do subject { super().content_type } @@ -713,7 +713,7 @@ describe 'response' do before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#response_code' do subject { super().response_code } @@ -802,7 +802,7 @@ shared_examples_for 'created successfully by JSON' do describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#response_code' do subject { super().response_code } @@ -1074,7 +1074,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#content_type' do subject { super().content_type } @@ -1562,7 +1562,7 @@ describe 'response' do before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'updated item' do @@ -1665,7 +1665,7 @@ def item describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#response_code' do subject { super().response_code } @@ -1722,7 +1722,7 @@ def item describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#response_code' do subject { super().response_code } @@ -1787,7 +1787,7 @@ def item end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#response_code' do subject { super().response_code } @@ -1930,7 +1930,7 @@ def item describe 'response' do before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#response_code' do subject { super().response_code } @@ -2088,7 +2088,7 @@ def item @action.call end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#response_code' do subject { super().response_code } @@ -2197,7 +2197,7 @@ def item @action.call end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#response_code' do subject { super().response_code } diff --git a/spec/controllers/balance_sheets_controller_spec.rb b/spec/controllers/balance_sheets_controller_spec.rb index 81d40876c..8741ecb82 100644 --- a/spec/controllers/balance_sheets_controller_spec.rb +++ b/spec/controllers/balance_sheets_controller_spec.rb @@ -24,7 +24,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index' } end @@ -81,7 +81,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index' } end @@ -148,7 +148,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index' } end @@ -219,7 +219,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'show' } end @@ -268,7 +268,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'show' } end diff --git a/spec/controllers/chart_data/assets_controller_spec.rb b/spec/controllers/chart_data/assets_controller_spec.rb index c29a015fe..acdbe4ae5 100644 --- a/spec/controllers/chart_data/assets_controller_spec.rb +++ b/spec/controllers/chart_data/assets_controller_spec.rb @@ -57,7 +57,7 @@ get :show, id: '200301', format: :json end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#body' do subject { super().body } @@ -88,7 +88,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } specify do expect(ActiveSupport::JSON.decode(subject.body)).to eq([{ 'label' => 'その1', 'data' => 800 }, { 'label' => 'その3', 'data' => 900 }]) end @@ -101,7 +101,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } specify do expect(ActiveSupport::JSON.decode(subject.body)).to eq([{ 'label' => 'その4', 'data' => 200 }]) end diff --git a/spec/controllers/chart_data/budgets_controller_spec.rb b/spec/controllers/chart_data/budgets_controller_spec.rb index 30320a491..a9abf8cfb 100644 --- a/spec/controllers/chart_data/budgets_controller_spec.rb +++ b/spec/controllers/chart_data/budgets_controller_spec.rb @@ -57,7 +57,7 @@ get :show, id: '200301', format: :json end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#body' do subject { super().body } @@ -89,7 +89,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } specify do expect(ActiveSupport::JSON.decode(subject.body)).to eq([{ 'label' => 'その2', 'data' => 900 }, { 'label' => I18n.t('label.unknown_income'), 'data' => 800 }]) end @@ -105,7 +105,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } specify do expect(ActiveSupport::JSON.decode(subject.body)).to eq([{ 'label' => 'その4', 'data' => 200 }, { 'label' => I18n.t('label.unknown_expense'), 'data' => 500 }]) end diff --git a/spec/controllers/chart_data/yearly_assets_controller_spec.rb b/spec/controllers/chart_data/yearly_assets_controller_spec.rb index 4bac51382..bb1a1abf8 100644 --- a/spec/controllers/chart_data/yearly_assets_controller_spec.rb +++ b/spec/controllers/chart_data/yearly_assets_controller_spec.rb @@ -36,7 +36,7 @@ end describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'response.body' do @@ -80,7 +80,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'response.body' do diff --git a/spec/controllers/chart_data/yearly_budgets_controller_spec.rb b/spec/controllers/chart_data/yearly_budgets_controller_spec.rb index cb2c3bbc2..9ad3791ed 100644 --- a/spec/controllers/chart_data/yearly_budgets_controller_spec.rb +++ b/spec/controllers/chart_data/yearly_budgets_controller_spec.rb @@ -8,6 +8,7 @@ describe '#show' do context 'before login,' do before do +pp method(:get).source_location get :show, id: '200802', budget_type: 'expense', format: :json end @@ -45,7 +46,7 @@ end describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'response.body' do subject { response.body } @@ -92,7 +93,7 @@ end describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'response.body' do @@ -130,7 +131,7 @@ end describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'response.body' do subject { response.body } @@ -175,7 +176,7 @@ end describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'response.body' do subject { response.body } @@ -211,7 +212,7 @@ end describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'response' do subject { response.body } @@ -259,7 +260,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'response' do subject { response.body } diff --git a/spec/controllers/confirmation_requireds_controller_spec.rb b/spec/controllers/confirmation_requireds_controller_spec.rb index 04fdd8a09..e106e8132 100644 --- a/spec/controllers/confirmation_requireds_controller_spec.rb +++ b/spec/controllers/confirmation_requireds_controller_spec.rb @@ -31,7 +31,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'update' } end @@ -59,7 +59,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'update' } end @@ -92,7 +92,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'update' } end @@ -120,7 +120,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'update' } end end @@ -138,7 +138,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'update' } end end diff --git a/spec/controllers/entries_controller_spec.rb b/spec/controllers/entries_controller_spec.rb index d3108cecb..bd18603f5 100644 --- a/spec/controllers/entries_controller_spec.rb +++ b/spec/controllers/entries_controller_spec.rb @@ -34,7 +34,7 @@ shared_examples_for 'Success' do describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index' } end end @@ -112,7 +112,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index_with_tag_keyword' } end @@ -137,7 +137,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index_with_mark' } end @@ -162,7 +162,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index_with_tag_keyword' } end @@ -184,7 +184,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index_with_tag_keyword' } end @@ -206,7 +206,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index_with_tag_keyword' } end @@ -225,7 +225,7 @@ shared_examples_for 'filtered index' do describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe '@items' do @@ -295,7 +295,7 @@ shared_examples_for 'executed correctly' do describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index_for_remaining' } end end @@ -385,7 +385,7 @@ shared_examples_for "execute edit successfully of #{item_name}" do describe 'resposne' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'edit' } end @@ -440,7 +440,7 @@ end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'show' } end end @@ -465,7 +465,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'new' } end @@ -487,7 +487,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'new' } end @@ -506,7 +506,7 @@ shared_examples_for 'respond successfully' do describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'new' } end end @@ -582,7 +582,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'new_simple' } end @@ -669,7 +669,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#content_type' do subject { super().content_type } @@ -730,7 +730,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#content_type' do subject { super().content_type } @@ -786,7 +786,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'amount of from_account' do @@ -828,7 +828,7 @@ describe 'response' do before { action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'specified item' do @@ -869,7 +869,7 @@ describe 'response' do before { action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#content_type' do subject { super().content_type } @@ -928,7 +928,7 @@ describe 'response' do before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'specified item(adjustment2)' do @@ -969,7 +969,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#content_type' do subject { super().content_type } @@ -1064,7 +1064,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#content_type' do subject { super().content_type } @@ -1157,7 +1157,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_js_error id: 'warning', default_message: I18n.t('error.input_is_invalid') } end @@ -1175,7 +1175,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_js_error id: 'warning', default_message: I18n.t('error.input_is_invalid') } end @@ -1193,7 +1193,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_js_error id: 'warning', default_message: I18n.t('error.date_is_invalid') } end @@ -1206,7 +1206,7 @@ shared_examples_for 'created successfully' do describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end end @@ -1217,7 +1217,7 @@ end describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_js_error id: 'warning', default_message: I18n.t('error.amount_is_invalid') } end @@ -1476,7 +1476,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_js_error id: 'warning' } end @@ -1818,7 +1818,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#content_type' do subject { super().content_type } @@ -1911,7 +1911,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#content_type' do subject { super().content_type } @@ -2023,7 +2023,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#content_type' do subject { super().content_type } @@ -2135,7 +2135,7 @@ describe 'response' do before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#content_type' do subject { super().content_type } @@ -2299,7 +2299,7 @@ describe 'response' do before { action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'all adjustments count' do @@ -2345,7 +2345,7 @@ describe 'response' do before { action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'all adjustments count' do @@ -2396,7 +2396,7 @@ action.call end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'count of items' do @@ -2481,7 +2481,7 @@ def total_amount_to(the_date) action.call end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'count of items' do @@ -2570,7 +2570,7 @@ def total_amount_to(the_date) action.call end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'count of items' do @@ -2658,7 +2658,7 @@ def total_amount_to(the_date) action.call end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'count of items' do @@ -2755,7 +2755,7 @@ def total_amount_to(the_date) @action.call end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'item to update' do @@ -2787,7 +2787,7 @@ def total_amount_to(the_date) describe 'response' do before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'item to update' do @@ -2818,7 +2818,7 @@ def total_amount_to(the_date) describe 'response' do before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_js_error id: "item_warning_#{items(:adjustment2).id}" } end @@ -2859,7 +2859,7 @@ def total_amount_to(the_date) @action.call end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'updated item' do @@ -2940,7 +2940,7 @@ def total_amount_to(the_date) describe 'response' do before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'updated item' do @@ -2986,7 +2986,7 @@ def total_amount_to(the_date) describe 'response' do before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'updated item' do @@ -3032,7 +3032,7 @@ def total_amount_to(the_date) @action.call end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'updated item' do @@ -3093,7 +3093,7 @@ def item describe 'response' do before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'updated adjustment' do @@ -3179,7 +3179,7 @@ def item describe 'response' do before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'updated adjustment' do @@ -3258,7 +3258,7 @@ def item before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'updated item' do @@ -3325,7 +3325,7 @@ def item before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'updated item' do @@ -3398,7 +3398,7 @@ def item describe 'response' do before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'item to update' do @@ -3434,7 +3434,7 @@ def item describe 'response' do before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_js_error id: "item_warning_#{@old_item1.id}" } end @@ -3467,7 +3467,7 @@ def item describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'updated item' do @@ -3520,7 +3520,7 @@ def item describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'updated item' do @@ -3580,7 +3580,7 @@ def item @action.call end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'updated item' do @@ -3745,7 +3745,7 @@ def item describe 'response' do before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'updated item' do @@ -3843,7 +3843,7 @@ def item describe 'response' do before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#content_type' do subject { super().content_type } @@ -3918,7 +3918,7 @@ def item describe 'response' do before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#content_type' do subject { super().content_type } @@ -3994,7 +3994,7 @@ def item describe 'response' do before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#content_type' do subject { super().content_type } @@ -4070,7 +4070,7 @@ def item describe 'response' do before { @action.call } subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } describe '#content_type' do subject { super().content_type } @@ -4171,7 +4171,7 @@ def item @action.call end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'the number of items' do @@ -4247,7 +4247,7 @@ def item @action.call end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'the number of items' do @@ -4335,7 +4335,7 @@ def item @action.call end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'the number of items' do @@ -4409,7 +4409,7 @@ def item @action.call end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'the number of items' do @@ -4477,7 +4477,7 @@ def item @action.call end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'the number of items' do @@ -4548,7 +4548,7 @@ def item @action.call end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'the number of items' do diff --git a/spec/controllers/entry_candidates_controller_spec.rb b/spec/controllers/entry_candidates_controller_spec.rb index 10d29f097..8bc352ca5 100644 --- a/spec/controllers/entry_candidates_controller_spec.rb +++ b/spec/controllers/entry_candidates_controller_spec.rb @@ -13,7 +13,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it_should_behave_like 'Unauthenticated Access by xhr' end end @@ -30,7 +30,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.not_to render_template '_candidate' } end end @@ -41,7 +41,7 @@ end describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template '_candidate' } end end diff --git a/spec/controllers/login_controller_spec.rb b/spec/controllers/login_controller_spec.rb index 518bd03d2..356b6bdc5 100644 --- a/spec/controllers/login_controller_spec.rb +++ b/spec/controllers/login_controller_spec.rb @@ -8,7 +8,7 @@ describe '#login' do shared_examples_for 'render login' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'login' } end @@ -50,7 +50,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'login' } end end @@ -359,7 +359,7 @@ end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'create_user' } end @@ -372,7 +372,7 @@ describe 'response' do subject { response } it { is_expected.to render_template 'do_create_user' } - it { is_expected.to be_success } + it { is_expected.to be_successful } end describe 'created user' do @@ -427,7 +427,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'confirmation' } end end @@ -448,7 +448,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'confirmation_error' } end end diff --git a/spec/controllers/profit_losses_controller_spec.rb b/spec/controllers/profit_losses_controller_spec.rb index 664a52263..89b245ece 100644 --- a/spec/controllers/profit_losses_controller_spec.rb +++ b/spec/controllers/profit_losses_controller_spec.rb @@ -25,7 +25,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template('index') } end @@ -77,7 +77,7 @@ end describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template('index') } end @@ -203,7 +203,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'show' } end describe 'assigned variables' do diff --git a/spec/controllers/settings/accounts_controller_spec.rb b/spec/controllers/settings/accounts_controller_spec.rb index 52747dc59..7a96a2eb6 100644 --- a/spec/controllers/settings/accounts_controller_spec.rb +++ b/spec/controllers/settings/accounts_controller_spec.rb @@ -35,7 +35,7 @@ %i[banking expense income].each do |type| shared_examples_for "type = '#{type}'" do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template('index') } describe '@type' do diff --git a/spec/controllers/settings/credit_relations_controller_spec.rb b/spec/controllers/settings/credit_relations_controller_spec.rb index 74aab67f2..0713cdca7 100644 --- a/spec/controllers/settings/credit_relations_controller_spec.rb +++ b/spec/controllers/settings/credit_relations_controller_spec.rb @@ -35,7 +35,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'index' } end end @@ -79,7 +79,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'show' } end end @@ -153,7 +153,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'edit' } end @@ -197,7 +197,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'no_record' } end @@ -227,7 +227,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'destroy' } end diff --git a/spec/controllers/settings/users_controller_spec.rb b/spec/controllers/settings/users_controller_spec.rb index d24b8d4b6..b93bc63a7 100644 --- a/spec/controllers/settings/users_controller_spec.rb +++ b/spec/controllers/settings/users_controller_spec.rb @@ -27,7 +27,7 @@ end subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'show' } end end @@ -66,7 +66,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'update' } end diff --git a/spec/controllers/tag_statuses_controller_spec.rb b/spec/controllers/tag_statuses_controller_spec.rb index dfb714a81..3cbde5bfa 100644 --- a/spec/controllers/tag_statuses_controller_spec.rb +++ b/spec/controllers/tag_statuses_controller_spec.rb @@ -25,7 +25,7 @@ describe 'response' do subject { response } - it { is_expected.to be_success } + it { is_expected.to be_successful } it { is_expected.to render_template 'show' } end From b37fbf7eac7dbcbbc47a9f6f83dcc01de92e5902 Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Thu, 28 Nov 2019 19:15:36 +0900 Subject: [PATCH 09/21] Change the option of `render` from `text` to `plain` --- app/controllers/chart_data.rb | 2 +- app/controllers/chart_data/yearly_budgets_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/chart_data.rb b/app/controllers/chart_data.rb index d9f4f8fbf..c6380bda5 100644 --- a/app/controllers/chart_data.rb +++ b/app/controllers/chart_data.rb @@ -15,7 +15,7 @@ module InstanceMethods def redirect_if_invalid_year_month! unless CommonUtil.valid_combined_year_month?(params[:id]) - render status: :not_acceptable, text: 'Not Acceptable' + render status: :not_acceptable, plain: 'Not Acceptable' return end true diff --git a/app/controllers/chart_data/yearly_budgets_controller.rb b/app/controllers/chart_data/yearly_budgets_controller.rb index d6e6e63b3..d96c7b90b 100644 --- a/app/controllers/chart_data/yearly_budgets_controller.rb +++ b/app/controllers/chart_data/yearly_budgets_controller.rb @@ -22,7 +22,7 @@ def _redirect_if_invalid_budget_type! if %w(expense income total).include?(params[:budget_type]) true else - render status: :not_acceptable, text: 'Not Acceptable' + render status: :not_acceptable, plain: 'Not Acceptable' false end end From e5784fe2f9c89624aa9b3c4469e6899a66835ccd Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Thu, 28 Nov 2019 19:17:58 +0900 Subject: [PATCH 10/21] Define get/post methods for backward compatibility --- spec/spec_helper.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 374d31465..0a5a83d1d 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -99,6 +99,10 @@ def create_entry(*params) xhr :post, :create, *params @controller = orig_controller end + + def xhr(method, path, **options) + send(method, path, params: options, xhr: true) + end end RSpec::Matchers.define :redirect_by_js_to do |path| @@ -144,3 +148,21 @@ def create_entry(*params) 'error.js.haml matcher' end end + +# +# This module changes the behaviors of get/post action +# This changes are for backward compatibility +# +module HttpVerbs + %i(get post).each do |verb| + define_method verb do |*args, **options| + if options.present? && !options.key?(:params) + super *args, params: options + else + super *args, **options + end + end + end +end + +Rails::Controller::Testing::Integration.prepend HttpVerbs From 6b9cc6bc81ea15f0076fa699a49e0b60b8c48de9 Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Thu, 28 Nov 2019 19:20:23 +0900 Subject: [PATCH 11/21] Remove capistrano gem and its associates because of installation failure --- Gemfile | 3 --- 1 file changed, 3 deletions(-) diff --git a/Gemfile b/Gemfile index 598c3f27f..75a4c8149 100644 --- a/Gemfile +++ b/Gemfile @@ -57,9 +57,6 @@ group :production do gem 'redis-store', '>= 1.4.0' end -# gem 'capistrano', '~> 2.0' -# gem 'rvm-capistrano' - gem 'mysql2' # for AR-4.2 gem 'pg', '~> 0.21' From 5620ebcbb2453f0b95f317385e0ef6926a6e65cb Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Thu, 28 Nov 2019 19:36:17 +0900 Subject: [PATCH 12/21] Ignore ./bin directory by rubocop --- .rubocop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.rubocop.yml b/.rubocop.yml index aa196d42d..1e37c632d 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,6 +5,7 @@ AllCops: - features/**/* - db/migrate/**/* - lib/arel_node_match_postgres_ext.rb + - bin/**/* TargetRubyVersion: 2.3 Layout/MultilineOperationIndentation: From 85ae45188a193cf8745173f8f783e3d096528cc7 Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Thu, 28 Nov 2019 19:36:38 +0900 Subject: [PATCH 13/21] Remove debug print --- spec/controllers/chart_data/yearly_budgets_controller_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/controllers/chart_data/yearly_budgets_controller_spec.rb b/spec/controllers/chart_data/yearly_budgets_controller_spec.rb index 9ad3791ed..9296551ce 100644 --- a/spec/controllers/chart_data/yearly_budgets_controller_spec.rb +++ b/spec/controllers/chart_data/yearly_budgets_controller_spec.rb @@ -8,7 +8,6 @@ describe '#show' do context 'before login,' do before do -pp method(:get).source_location get :show, id: '200802', budget_type: 'expense', format: :json end From 2621d1054d6a24b19e7c5f3203f1ccdcf4d99cb7 Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Thu, 28 Nov 2019 19:37:03 +0900 Subject: [PATCH 14/21] Shut rubocop up --- Gemfile | 2 +- spec/spec_helper.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 75a4c8149..e19bf1ba7 100644 --- a/Gemfile +++ b/Gemfile @@ -64,7 +64,7 @@ gem 'pg', '~> 0.21' gem 'sqlite3', '~> 1.3.11' gem 'bootsnap', require: false -gem 'coffee-rails' #, '~> 4.1.0' +gem 'coffee-rails' gem 'haml', '>= 5.0.0' gem 'haml-rails' gem 'i18n' diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 0a5a83d1d..b5398f870 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -157,9 +157,9 @@ module HttpVerbs %i(get post).each do |verb| define_method verb do |*args, **options| if options.present? && !options.key?(:params) - super *args, params: options + super(*args, params: options) else - super *args, **options + super(*args, **options) end end end From a3f7757e68109f4c4bf796287249425244e4afc9 Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Fri, 29 Nov 2019 07:08:33 +0900 Subject: [PATCH 15/21] Update Gemfile for JRuby to support Rails5.2 --- gemfiles/Gemfile.jruby | 21 +++-- gemfiles/Gemfile.jruby.lock | 183 ++++++++++++++++++++---------------- 2 files changed, 117 insertions(+), 87 deletions(-) diff --git a/gemfiles/Gemfile.jruby b/gemfiles/Gemfile.jruby index eb97b7ebc..b46cfc104 100644 --- a/gemfiles/Gemfile.jruby +++ b/gemfiles/Gemfile.jruby @@ -1,6 +1,6 @@ source 'http://rubygems.org' -gem 'rails', '~> 4.2.11' +gem 'rails', '~> 5.2.1' group :development, :test do gem "minitest" @@ -26,20 +26,25 @@ platforms :jruby do # for rails4.0.0.base1 gem 'krypt-ossl' - gem "activerecord-jdbc-adapter", '>= 1.3.0.beta2' - gem "activerecord-jdbcmysql-adapter", '>= 1.3.0.beta2' - gem "activerecord-jdbcsqlite3-adapter", '>= 1.3.0.beta2' - gem "activerecord-jdbcpostgresql-adapter",'>= 1.3.0.beta2' - gem "activerecord-jdbcmssql-adapter", '>= 1.3.0.beta2' + gem "activerecord-jdbc-adapter", '>= 52.0' + gem "activerecord-jdbcmysql-adapter", '>= 52.0' + gem "activerecord-jdbcsqlite3-adapter", '>= 52.0' + gem "activerecord-jdbcpostgresql-adapter",'>= 52.0' + # mssql adapter for ActiveRecord(>=5.2) has not been released + # sqlserver-adapter is hoped to be released before the end of 2019 + # see https://github.com/jruby/activerecord-jdbc-adapter/issues/784#issuecomment-558202005 + # gem "activerecord-jdbcmssql-adapter", '>= 52.0' + # gem 'jdbc-jtds' gem 'jdbc-mysql' gem 'jdbc-postgres' gem 'jdbc-sqlite3' - gem 'jdbc-jtds' gem "therubyrhino" end +gem 'bootsnap', require: false +gem 'rails-controller-testing' gem 'sass-rails', '~> 5.0' -gem 'coffee-rails', '~> 4.1.0' +gem 'coffee-rails' gem 'uglifier' gem "i18n" diff --git a/gemfiles/Gemfile.jruby.lock b/gemfiles/Gemfile.jruby.lock index 6a1c05e72..9a818d551 100644 --- a/gemfiles/Gemfile.jruby.lock +++ b/gemfiles/Gemfile.jruby.lock @@ -1,62 +1,70 @@ GEM remote: http://rubygems.org/ specs: - actionmailer (4.2.11.1) - actionpack (= 4.2.11.1) - actionview (= 4.2.11.1) - activejob (= 4.2.11.1) + actioncable (5.2.4) + actionpack (= 5.2.4) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.4) + actionpack (= 5.2.4) + actionview (= 5.2.4) + activejob (= 5.2.4) mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.11.1) - actionview (= 4.2.11.1) - activesupport (= 4.2.11.1) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) + rails-dom-testing (~> 2.0) + actionpack (5.2.4) + actionview (= 5.2.4) + activesupport (= 5.2.4) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.11.1) - activesupport (= 4.2.11.1) + actionview (5.2.4) + activesupport (= 5.2.4) builder (~> 3.1) - erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (4.2.11.1) - activesupport (= 4.2.11.1) - globalid (>= 0.3.0) - activemodel (4.2.11.1) - activesupport (= 4.2.11.1) - builder (~> 3.1) - activerecord (4.2.11.1) - activemodel (= 4.2.11.1) - activesupport (= 4.2.11.1) - arel (~> 6.0) - activerecord-jdbc-adapter (1.3.25) - activerecord (>= 2.2, < 5.0) - activerecord-jdbcmssql-adapter (1.3.25) - activerecord-jdbc-adapter (~> 1.3.25) - jdbc-jtds (>= 1.2.7) - activerecord-jdbcmysql-adapter (1.3.25) - activerecord-jdbc-adapter (~> 1.3.25) - jdbc-mysql (>= 5.1.22) - activerecord-jdbcpostgresql-adapter (1.3.25) - activerecord-jdbc-adapter (~> 1.3.25) - jdbc-postgres (~> 9.1, <= 9.4.1206) - activerecord-jdbcsqlite3-adapter (1.3.25) - activerecord-jdbc-adapter (~> 1.3.25) - jdbc-sqlite3 (>= 3.7.2, < 3.9) - activesupport (4.2.11.1) - i18n (~> 0.7) + activejob (5.2.4) + activesupport (= 5.2.4) + globalid (>= 0.3.6) + activemodel (5.2.4) + activesupport (= 5.2.4) + activerecord (5.2.4) + activemodel (= 5.2.4) + activesupport (= 5.2.4) + arel (>= 9.0) + activerecord-jdbc-adapter (52.4-java) + activerecord (~> 5.2.0) + activerecord-jdbcmysql-adapter (52.4-java) + activerecord-jdbc-adapter (= 52.4) + jdbc-mysql (~> 5.1.36, < 9) + activerecord-jdbcpostgresql-adapter (52.4-java) + activerecord-jdbc-adapter (= 52.4) + jdbc-postgres (>= 9.4, < 43) + activerecord-jdbcsqlite3-adapter (52.4-java) + activerecord-jdbc-adapter (= 52.4) + jdbc-sqlite3 (~> 3.8, < 3.30) + activestorage (5.2.4) + actionpack (= 5.2.4) + activerecord (= 5.2.4) + marcel (~> 0.3.1) + activesupport (5.2.4) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) - arel (6.0.4) + arel (9.0.0) ast (2.4.0) + bootsnap (1.4.5) + msgpack (~> 1.0) + bootsnap (1.4.5-java) + msgpack (~> 1.0) builder (3.2.3) - coffee-rails (4.1.1) + coffee-rails (5.0.0) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.1.x) + railties (>= 5.2.0) coffee-script (2.4.1) coffee-script-source execjs @@ -71,6 +79,7 @@ GEM dotenv-rails (2.7.5) dotenv (= 2.7.5) railties (>= 3.2, < 6.1) + erubi (1.9.0) erubis (2.7.0) execjs (2.7.0) fabrication (2.21.0) @@ -97,13 +106,12 @@ GEM haml (>= 4.0, < 6) nokogiri (>= 1.6.0) ruby_parser (~> 3.5) - i18n (0.9.5) + i18n (1.7.0) concurrent-ruby (~> 1.0) jaro_winkler (1.5.4) jaro_winkler (1.5.4-java) jbuilder (2.9.1) activesupport (>= 4.2.0) - jdbc-jtds (1.3.1) jdbc-mysql (5.1.47) jdbc-postgres (9.4.1206) jdbc-sqlite3 (3.8.11.2) @@ -133,10 +141,18 @@ GEM nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) memoist (0.16.1) + method_source (0.9.2) + mimemagic (0.3.3) mini_mime (1.0.2) mini_portile2 (2.4.0) minitest (5.13.0) + msgpack (1.3.1) + msgpack (1.3.1-java) + nio4r (2.5.2) + nio4r (2.5.2-java) nokogiri (1.10.5) mini_portile2 (~> 2.4.0) nokogiri (1.10.5-java) @@ -144,37 +160,41 @@ GEM parser (2.6.5.0) ast (~> 2.4.0) public_suffix (4.0.1) - rack (1.6.11) - rack-test (0.6.3) - rack (>= 1.0) - rails (4.2.11.1) - actionmailer (= 4.2.11.1) - actionpack (= 4.2.11.1) - actionview (= 4.2.11.1) - activejob (= 4.2.11.1) - activemodel (= 4.2.11.1) - activerecord (= 4.2.11.1) - activesupport (= 4.2.11.1) - bundler (>= 1.3.0, < 2.0) - railties (= 4.2.11.1) - sprockets-rails - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.9) - activesupport (>= 4.2.0, < 5.0) - nokogiri (~> 1.6) - rails-deprecated_sanitizer (>= 1.0.1) + rack (2.0.7) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (5.2.4) + actioncable (= 5.2.4) + actionmailer (= 5.2.4) + actionpack (= 5.2.4) + actionview (= 5.2.4) + activejob (= 5.2.4) + activemodel (= 5.2.4) + activerecord (= 5.2.4) + activestorage (= 5.2.4) + activesupport (= 5.2.4) + bundler (>= 1.3.0) + railties (= 5.2.4) + sprockets-rails (>= 2.0.0) + rails-controller-testing (1.0.4) + actionpack (>= 5.0.1.x) + actionview (>= 5.0.1.x) + activesupport (>= 5.0.1.x) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) rails-observers (0.1.5) activemodel (>= 4.0) rails_emoji (1.7.1) rails (>= 3.1.0) - railties (4.2.11.1) - actionpack (= 4.2.11.1) - activesupport (= 4.2.11.1) + railties (5.2.4) + actionpack (= 5.2.4) + activesupport (= 5.2.4) + method_source rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) + thor (>= 0.19.0, < 2.0) rainbow (3.0.0) rake (13.0.1) rb-fsevent (0.10.3) @@ -264,18 +284,23 @@ GEM execjs (>= 0.3.0, < 3) underscore-rails (1.8.3) unicode-display_width (1.6.0) + websocket-driver (0.7.1) + websocket-extensions (>= 0.1.0) + websocket-driver (0.7.1-java) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.4) PLATFORMS java ruby DEPENDENCIES - activerecord-jdbc-adapter (>= 1.3.0.beta2) - activerecord-jdbcmssql-adapter (>= 1.3.0.beta2) - activerecord-jdbcmysql-adapter (>= 1.3.0.beta2) - activerecord-jdbcpostgresql-adapter (>= 1.3.0.beta2) - activerecord-jdbcsqlite3-adapter (>= 1.3.0.beta2) - coffee-rails (~> 4.1.0) + activerecord-jdbc-adapter (>= 52.0) + activerecord-jdbcmysql-adapter (>= 52.0) + activerecord-jdbcpostgresql-adapter (>= 52.0) + activerecord-jdbcsqlite3-adapter (>= 52.0) + bootsnap + coffee-rails doorkeeper (>= 0.7.1) dotenv-rails fabrication @@ -284,7 +309,6 @@ DEPENDENCIES haml_lint i18n jbuilder - jdbc-jtds jdbc-mysql jdbc-postgres jdbc-sqlite3 @@ -294,7 +318,8 @@ DEPENDENCIES launchy memoist minitest - rails (~> 4.2.11) + rails (~> 5.2.1) + rails-controller-testing rails-observers rails_emoji responders From 93f1a5a5f5e9d377cfddd33431b28bbbb67be430 Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Fri, 29 Nov 2019 07:45:23 +0900 Subject: [PATCH 16/21] Refactor --- spec/controllers/admin/users_controller_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index 40d2a2d68..e76387c98 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -13,7 +13,6 @@ def mock_user ENV['ADMIN_PASSWORD'] = nil end - let(:user_objects) { [mock_user, mock_user, mock_user] } context 'without authentication data in server,' do describe 'response' do before do @@ -159,6 +158,8 @@ def mock_user context 'when authentication pass,' do context 'when user/password is correct,' do + let(:user_objects) { [mock_user, mock_user, mock_user] } + before do expect(@controller).to receive(:authenticate).and_return(true) end From 550bc21150bdff335ddecb508d08edfd5b58fb32 Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Fri, 29 Nov 2019 07:51:26 +0900 Subject: [PATCH 17/21] Replace `render nothing: true` with `head` --- app/controllers/admin/users_controller.rb | 2 +- app/controllers/api/entries_controller.rb | 4 ++-- app/controllers/api/sessions_controller.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index 994c448fa..7ef44dc7f 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -12,7 +12,7 @@ def index def authenticate admin_user, admin_password = correct_credential if admin_user.nil? || admin_password.nil? - render nothing: true, status: :unauthorized + head :unauthorized return end diff --git a/app/controllers/api/entries_controller.rb b/app/controllers/api/entries_controller.rb index 04393666e..a13774eff 100644 --- a/app/controllers/api/entries_controller.rb +++ b/app/controllers/api/entries_controller.rb @@ -9,7 +9,7 @@ def index super render locals: { items: @items } rescue ArgumentError - render nothing: true, status: :not_acceptable + head :not_acceptable end def show @@ -51,7 +51,7 @@ def _json_action(&block) errors = [t('error.date_is_invalid')] render json: { errors: errors }.to_json, status: :not_acceptable rescue ActiveRecord::RecordNotFound - render nothing: true, status: :not_found + head :not_found rescue ActiveRecord::RecordInvalid => e errors = e.record.errors.full_messages render json: { errors: errors }.to_json, status: :not_acceptable diff --git a/app/controllers/api/sessions_controller.rb b/app/controllers/api/sessions_controller.rb index 649f5f664..ef2cd7375 100644 --- a/app/controllers/api/sessions_controller.rb +++ b/app/controllers/api/sessions_controller.rb @@ -34,6 +34,6 @@ def destroy private def render_when_not_login - render nothing: true, status: :unauthorized + head :unauthorized end end From 50afce711069c5fa2a5adf2de87085cd90ae96b6 Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Fri, 29 Nov 2019 07:54:02 +0900 Subject: [PATCH 18/21] Support put/patch/delete for spec helper wrapper --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b5398f870..bb67e255e 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -154,7 +154,7 @@ def xhr(method, path, **options) # This changes are for backward compatibility # module HttpVerbs - %i(get post).each do |verb| + %i(get post put patch delete).each do |verb| define_method verb do |*args, **options| if options.present? && !options.key?(:params) super(*args, params: options) From 94ab4ee45ad2cc17be2bc87143e9bff908da634f Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Sat, 30 Nov 2019 00:49:14 +0900 Subject: [PATCH 19/21] Exec bundle update rails --- Gemfile.lock | 72 ++++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index a23cbfa0f..3a892b4a0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,43 +1,43 @@ GEM remote: http://rubygems.org/ specs: - actioncable (5.2.1) - actionpack (= 5.2.1) + actioncable (5.2.4) + actionpack (= 5.2.4) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailer (5.2.1) - actionpack (= 5.2.1) - actionview (= 5.2.1) - activejob (= 5.2.1) + actionmailer (5.2.4) + actionpack (= 5.2.4) + actionview (= 5.2.4) + activejob (= 5.2.4) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (5.2.1) - actionview (= 5.2.1) - activesupport (= 5.2.1) + actionpack (5.2.4) + actionview (= 5.2.4) + activesupport (= 5.2.4) rack (~> 2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (5.2.1) - activesupport (= 5.2.1) + actionview (5.2.4) + activesupport (= 5.2.4) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (5.2.1) - activesupport (= 5.2.1) + activejob (5.2.4) + activesupport (= 5.2.4) globalid (>= 0.3.6) - activemodel (5.2.1) - activesupport (= 5.2.1) - activerecord (5.2.1) - activemodel (= 5.2.1) - activesupport (= 5.2.1) + activemodel (5.2.4) + activesupport (= 5.2.4) + activerecord (5.2.4) + activemodel (= 5.2.4) + activesupport (= 5.2.4) arel (>= 9.0) - activestorage (5.2.1) - actionpack (= 5.2.1) - activerecord (= 5.2.1) + activestorage (5.2.4) + actionpack (= 5.2.4) + activerecord (= 5.2.4) marcel (~> 0.3.1) - activesupport (5.2.1) + activesupport (5.2.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) @@ -216,18 +216,18 @@ GEM rack (2.0.7) rack-test (1.1.0) rack (>= 1.0, < 3) - rails (5.2.1) - actioncable (= 5.2.1) - actionmailer (= 5.2.1) - actionpack (= 5.2.1) - actionview (= 5.2.1) - activejob (= 5.2.1) - activemodel (= 5.2.1) - activerecord (= 5.2.1) - activestorage (= 5.2.1) - activesupport (= 5.2.1) + rails (5.2.4) + actioncable (= 5.2.4) + actionmailer (= 5.2.4) + actionpack (= 5.2.4) + actionview (= 5.2.4) + activejob (= 5.2.4) + activemodel (= 5.2.4) + activerecord (= 5.2.4) + activestorage (= 5.2.4) + activesupport (= 5.2.4) bundler (>= 1.3.0) - railties (= 5.2.1) + railties (= 5.2.4) sprockets-rails (>= 2.0.0) rails-controller-testing (1.0.4) actionpack (>= 5.0.1.x) @@ -242,9 +242,9 @@ GEM activemodel (>= 4.0) rails_emoji (1.7.1) rails (>= 3.1.0) - railties (5.2.1) - actionpack (= 5.2.1) - activesupport (= 5.2.1) + railties (5.2.4) + actionpack (= 5.2.4) + activesupport (= 5.2.4) method_source rake (>= 0.8.7) thor (>= 0.19.0, < 2.0) From 7f86ab6bf0047f23cec3e172c47ec63309593617 Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Sat, 30 Nov 2019 06:15:19 +0900 Subject: [PATCH 20/21] Replace `render text: xxxx` with `render plain: xxxx` --- app/controllers/api.rb | 2 +- app/controllers/entry_candidates_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/api.rb b/app/controllers/api.rb index 2e74c42e2..8327d323f 100644 --- a/app/controllers/api.rb +++ b/app/controllers/api.rb @@ -31,7 +31,7 @@ def authenticate_via_api @user = user true else - render text: 'You do not have the permission to access this resource.', status: :unauthorized + render plain: 'You do not have the permission to access this resource.', status: :unauthorized false end end diff --git a/app/controllers/entry_candidates_controller.rb b/app/controllers/entry_candidates_controller.rb index 429ff742e..b036912f9 100644 --- a/app/controllers/entry_candidates_controller.rb +++ b/app/controllers/entry_candidates_controller.rb @@ -7,7 +7,7 @@ def index partial_name = params[:item_name] if partial_name.blank? - render text: '' + render plain: '' return end From 7b0a6d8ac37c26caeb61796dab811083122d517b Mon Sep 17 00:00:00 2001 From: Kazuya NUMATA Date: Sat, 30 Nov 2019 07:01:33 +0900 Subject: [PATCH 21/21] Follow the change of the nil-valued key in params --- app/controllers/login_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/login_controller.rb b/app/controllers/login_controller.rb index 6a3bb500d..3bb0d0a6e 100644 --- a/app/controllers/login_controller.rb +++ b/app/controllers/login_controller.rb @@ -14,13 +14,13 @@ def login end def do_login - _do_login(params[:login], params[:password], params[:autologin], false, params[:only_add]) + _do_login(params[:login], params[:password], params[:autologin].presence, false, params[:only_add].presence) unless session[:user_id] render_js_error id: 'warning', default_message: t('error.user_or_password_is_invalid') return end - redirect_js_to params[:only_add] ? simple_input_url : current_entries_url + redirect_js_to params[:only_add].present? ? simple_input_url : current_entries_url end def do_logout