14873: Rails 5 upgrade. Some tests still failing. (WIP)
authorLucas Di Pentima <ldipentima@veritasgenetics.com>
Fri, 22 Mar 2019 12:42:44 +0000 (09:42 -0300)
committerLucas Di Pentima <ldipentima@veritasgenetics.com>
Fri, 22 Mar 2019 12:42:44 +0000 (09:42 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>

23 files changed:
services/api/Gemfile
services/api/Gemfile.lock
services/api/Rakefile
services/api/app/models/arvados_model.rb
services/api/bin/bundle [new file with mode: 0755]
services/api/bin/rails [new file with mode: 0755]
services/api/bin/rake [new file with mode: 0755]
services/api/bin/setup [new file with mode: 0755]
services/api/bin/update [new file with mode: 0755]
services/api/config/application.default.yml
services/api/config/boot.rb
services/api/config/cable.yml [new file with mode: 0644]
services/api/config/environment.rb
services/api/config/initializers/application_controller_renderer.rb [new file with mode: 0644]
services/api/config/initializers/assets.rb [new file with mode: 0644]
services/api/config/initializers/cookies_serializer.rb [new file with mode: 0644]
services/api/config/initializers/filter_parameter_logging.rb [new file with mode: 0644]
services/api/config/initializers/new_framework_defaults.rb [new file with mode: 0644]
services/api/config/initializers/session_store.rb
services/api/config/puma.rb [new file with mode: 0644]
services/api/config/secrets.yml [new file with mode: 0644]
services/api/config/spring.rb [new file with mode: 0644]
services/api/lib/has_uuid.rb

index c91495d8f5b9c4a8bd5b00ebbb8553e4cd01be60..62beda057a42717ee2b567aaa4bf3e3030ae26ac 100644 (file)
@@ -4,7 +4,7 @@
 
 source 'https://rubygems.org'
 
-gem 'rails', '~> 4.2'
+gem 'rails', '~> 5.0.0'
 gem 'responders', '~> 2.0'
 
 group :test, :development do
@@ -31,9 +31,6 @@ gem 'pg', '~> 0.18'
 gem 'multi_json'
 gem 'oj'
 
-# for building assets
-gem 'sass-rails',   '~> 4.0'
-gem 'coffee-rails', '~> 4.0'
 gem 'therubyracer'
 gem 'uglifier', '~> 2.0'
 
@@ -45,14 +42,15 @@ gem 'acts_as_api'
 
 gem 'passenger'
 
+# Locking to 5.10.3 to workaround issue in 5.11.1 (https://github.com/seattlerb/minitest/issues/730)
+gem 'minitest', '5.10.3'
+
 # Restricted because omniauth >= 1.5.0 requires Ruby >= 2.1.9:
 gem 'omniauth', '~> 1.4.0'
 gem 'omniauth-oauth2', '~> 1.1'
 
 gem 'andand'
 
-gem 'test_after_commit', :group => :test
-
 gem 'trollop'
 gem 'faye-websocket'
 
@@ -68,6 +66,9 @@ gem 'logstash-event'
 
 gem 'rails-observers'
 
+gem 'rails-perftest'
+gem 'rails-controller-testing'
+
 # Install any plugin gems
 Dir.glob(File.join(File.dirname(__FILE__), 'lib', '**', "Gemfile")) do |f|
     eval(IO.read(f), binding)
index ad76a2ffb1b869ead7451ed95e13062f38f5b114..e9a41861b797e9fa1e85f1826114a555f3e1b8d3 100644 (file)
@@ -8,39 +8,42 @@ GIT
 GEM
   remote: https://rubygems.org/
   specs:
-    actionmailer (4.2.11)
-      actionpack (= 4.2.11)
-      actionview (= 4.2.11)
-      activejob (= 4.2.11)
+    actioncable (5.0.7.2)
+      actionpack (= 5.0.7.2)
+      nio4r (>= 1.2, < 3.0)
+      websocket-driver (~> 0.6.1)
+    actionmailer (5.0.7.2)
+      actionpack (= 5.0.7.2)
+      actionview (= 5.0.7.2)
+      activejob (= 5.0.7.2)
       mail (~> 2.5, >= 2.5.4)
-      rails-dom-testing (~> 1.0, >= 1.0.5)
-    actionpack (4.2.11)
-      actionview (= 4.2.11)
-      activesupport (= 4.2.11)
-      rack (~> 1.6)
-      rack-test (~> 0.6.2)
-      rails-dom-testing (~> 1.0, >= 1.0.5)
+      rails-dom-testing (~> 2.0)
+    actionpack (5.0.7.2)
+      actionview (= 5.0.7.2)
+      activesupport (= 5.0.7.2)
+      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)
-      activesupport (= 4.2.11)
+    actionview (5.0.7.2)
+      activesupport (= 5.0.7.2)
       builder (~> 3.1)
       erubis (~> 2.7.0)
-      rails-dom-testing (~> 1.0, >= 1.0.5)
+      rails-dom-testing (~> 2.0)
       rails-html-sanitizer (~> 1.0, >= 1.0.3)
-    activejob (4.2.11)
-      activesupport (= 4.2.11)
-      globalid (>= 0.3.0)
-    activemodel (4.2.11)
-      activesupport (= 4.2.11)
-      builder (~> 3.1)
-    activerecord (4.2.11)
-      activemodel (= 4.2.11)
-      activesupport (= 4.2.11)
-      arel (~> 6.0)
-    activesupport (4.2.11)
-      i18n (~> 0.7)
+    activejob (5.0.7.2)
+      activesupport (= 5.0.7.2)
+      globalid (>= 0.3.6)
+    activemodel (5.0.7.2)
+      activesupport (= 5.0.7.2)
+    activerecord (5.0.7.2)
+      activemodel (= 5.0.7.2)
+      activesupport (= 5.0.7.2)
+      arel (~> 7.0)
+    activesupport (5.0.7.2)
+      concurrent-ruby (~> 1.0, >= 1.0.2)
+      i18n (>= 0.7, < 2)
       minitest (~> 5.1)
-      thread_safe (~> 0.3, >= 0.3.4)
       tzinfo (~> 1.1)
     acts_as_api (1.0.1)
       activemodel (>= 3.0.0)
@@ -49,23 +52,34 @@ GEM
     addressable (2.6.0)
       public_suffix (>= 2.0.2, < 4.0)
     andand (1.3.3)
-    arel (6.0.4)
-    arvados (1.3.1.20190301212059)
+    arel (7.1.4)
+    arvados (1.3.1.20190320201707)
       activesupport (>= 3)
       andand (~> 1.3, >= 1.3.3)
-      cure-google-api-client (>= 0.7, < 0.8.9)
+      arvados-google-api-client (>= 0.7, < 0.8.9)
       i18n (~> 0)
       json (>= 1.7.7, < 3)
       jwt (>= 0.1.5, < 2)
-    arvados-cli (1.3.1.20190211211047)
-      activesupport (>= 3.2.13, < 5)
+    arvados-cli (1.3.1.20190320201707)
+      activesupport (>= 3.2.13, < 5.1)
       andand (~> 1.3, >= 1.3.3)
       arvados (~> 1.3.0, >= 1.3.0)
+      arvados-google-api-client (~> 0.6, >= 0.6.3, < 0.8.9)
       curb (~> 0.8)
-      cure-google-api-client (~> 0.6, >= 0.6.3, < 0.8.9)
       json (>= 1.7.7, < 3)
       oj (~> 3.0)
       optimist (~> 3.0)
+    arvados-google-api-client (0.8.7.2)
+      activesupport (>= 3.2, < 5.1)
+      addressable (~> 2.3)
+      autoparse (~> 0.3)
+      extlib (~> 0.9)
+      faraday (~> 0.9)
+      googleauth (~> 0.3)
+      launchy (~> 2.4)
+      multi_json (~> 1.10)
+      retriable (~> 1.4)
+      signet (~> 0.6)
     autoparse (0.3.3)
       addressable (>= 2.3.1)
       extlib (>= 0.9.15)
@@ -77,43 +91,25 @@ GEM
       net-sftp (>= 2.0.0)
       net-ssh (>= 2.0.14)
       net-ssh-gateway (>= 1.1.0)
-    coffee-rails (4.2.2)
-      coffee-script (>= 2.2.0)
-      railties (>= 4.0.0)
-    coffee-script (2.4.1)
-      coffee-script-source
-      execjs
-    coffee-script-source (1.12.2)
-    concurrent-ruby (1.1.4)
+    concurrent-ruby (1.1.5)
     crass (1.0.4)
-    curb (0.9.8)
-    cure-google-api-client (0.8.7.1)
-      activesupport (>= 3.2, < 5.0)
-      addressable (~> 2.3)
-      autoparse (~> 0.3)
-      extlib (~> 0.9)
-      faraday (~> 0.9)
-      googleauth (~> 0.3)
-      launchy (~> 2.4)
-      multi_json (~> 1.10)
-      retriable (~> 1.4)
-      signet (~> 0.6)
+    curb (0.9.9)
     database_cleaner (1.7.0)
     erubis (2.7.0)
-    eventmachine (1.2.6)
+    eventmachine (1.2.7)
     execjs (2.7.0)
     extlib (0.9.16)
-    factory_bot (4.11.1)
-      activesupport (>= 3.0.0)
-    factory_bot_rails (4.11.1)
-      factory_bot (~> 4.11.1)
-      railties (>= 3.0.0)
-    faraday (0.12.2)
+    factory_bot (5.0.2)
+      activesupport (>= 4.2.0)
+    factory_bot_rails (5.0.1)
+      factory_bot (~> 5.0.0)
+      railties (>= 4.2.0)
+    faraday (0.15.4)
       multipart-post (>= 1.2, < 3)
     faye-websocket (0.10.7)
       eventmachine (>= 0.12.0)
       websocket-driver (>= 0.5.1)
-    globalid (0.4.1)
+    globalid (0.4.2)
       activesupport (>= 4.2.0)
     googleauth (0.8.0)
       faraday (~> 0.12)
@@ -122,9 +118,8 @@ GEM
       multi_json (~> 1.11)
       os (>= 0.9, < 2.0)
       signet (~> 0.7)
-    hashie (3.5.7)
-    highline (1.7.10)
-    hike (1.2.3)
+    hashie (3.6.0)
+    highline (2.0.1)
     httpclient (2.8.3)
     i18n (0.9.5)
       concurrent-ruby (~> 1.0)
@@ -150,30 +145,32 @@ GEM
       mini_mime (>= 0.1.1)
     memoist (0.16.0)
     metaclass (0.0.4)
+    method_source (0.9.2)
     mini_mime (1.0.1)
     mini_portile2 (2.4.0)
-    minitest (5.11.3)
-    mocha (1.5.0)
+    minitest (5.10.3)
+    mocha (1.8.0)
       metaclass (~> 0.0.1)
     multi_json (1.13.1)
     multi_xml (0.6.0)
     multipart-post (2.0.0)
-    net-scp (1.2.1)
-      net-ssh (>= 2.6.5)
+    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 (4.2.0)
+    net-ssh (5.2.0)
     net-ssh-gateway (2.0.0)
       net-ssh (>= 4.0.0)
-    nokogiri (1.9.1)
+    nio4r (2.3.1)
+    nokogiri (1.10.1)
       mini_portile2 (~> 2.4.0)
-    oauth2 (1.4.0)
-      faraday (>= 0.8, < 0.13)
-      jwt (~> 1.0)
+    oauth2 (1.4.1)
+      faraday (>= 0.8, < 0.16.0)
+      jwt (>= 1.0, < 3.0)
       multi_json (~> 1.3)
       multi_xml (~> 0.5)
       rack (>= 1.2, < 3)
-    oj (3.7.9)
+    oj (3.7.11)
     omniauth (1.4.3)
       hashie (>= 1.2, < 4)
       rack (>= 1.6.2, < 3)
@@ -182,59 +179,57 @@ GEM
       omniauth (~> 1.2)
     optimist (3.0.0)
     os (1.0.0)
-    passenger (5.3.0)
+    passenger (6.0.2)
       rack
       rake (>= 0.8.1)
     pg (0.21.0)
-    power_assert (1.1.1)
+    power_assert (1.1.3)
     public_suffix (3.0.3)
-    rack (1.6.11)
+    rack (2.0.6)
     rack-test (0.6.3)
       rack (>= 1.0)
-    rails (4.2.11)
-      actionmailer (= 4.2.11)
-      actionpack (= 4.2.11)
-      actionview (= 4.2.11)
-      activejob (= 4.2.11)
-      activemodel (= 4.2.11)
-      activerecord (= 4.2.11)
-      activesupport (= 4.2.11)
-      bundler (>= 1.3.0, < 2.0)
-      railties (= 4.2.11)
-      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)
+    rails (5.0.7.2)
+      actioncable (= 5.0.7.2)
+      actionmailer (= 5.0.7.2)
+      actionpack (= 5.0.7.2)
+      actionview (= 5.0.7.2)
+      activejob (= 5.0.7.2)
+      activemodel (= 5.0.7.2)
+      activerecord (= 5.0.7.2)
+      activesupport (= 5.0.7.2)
+      bundler (>= 1.3.0)
+      railties (= 5.0.7.2)
+      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.0.4)
       loofah (~> 2.2, >= 2.2.2)
     rails-observers (0.1.5)
       activemodel (>= 4.0)
-    railties (4.2.11)
-      actionpack (= 4.2.11)
-      activesupport (= 4.2.11)
+    rails-perftest (0.0.7)
+    railties (5.0.7.2)
+      actionpack (= 5.0.7.2)
+      activesupport (= 5.0.7.2)
+      method_source
       rake (>= 0.8.7)
       thor (>= 0.18.1, < 2.0)
     rake (12.3.2)
     ref (2.0.0)
     request_store (1.4.1)
       rack (>= 1.4)
-    responders (2.4.0)
-      actionpack (>= 4.2.0, < 5.3)
-      railties (>= 4.2.0, < 5.3)
+    responders (2.4.1)
+      actionpack (>= 4.2.0, < 6.0)
+      railties (>= 4.2.0, < 6.0)
     retriable (1.4.1)
     ruby-prof (0.17.0)
     rvm-capistrano (1.5.6)
       capistrano (~> 2.15.4)
-    safe_yaml (1.0.4)
-    sass (3.2.19)
-    sass-rails (4.0.5)
-      railties (>= 4.0.0, < 5.0)
-      sass (~> 3.2.2)
-      sprockets (~> 2.8, < 3.0)
-      sprockets-rails (~> 2.0)
+    safe_yaml (1.0.5)
     signet (0.11.0)
       addressable (~> 2.3)
       faraday (~> 0.9)
@@ -246,33 +241,28 @@ GEM
     simplecov-html (0.7.1)
     simplecov-rcov (0.2.3)
       simplecov (>= 0.4.1)
-    sprockets (2.12.5)
-      hike (~> 1.2)
-      multi_json (~> 1.0)
-      rack (~> 1.0)
-      tilt (~> 1.1, != 1.3.0)
-    sprockets-rails (2.3.3)
-      actionpack (>= 3.0)
-      activesupport (>= 3.0)
-      sprockets (>= 2.8, < 4.0)
-    sshkey (1.9.0)
-    test-unit (3.2.7)
+    sprockets (3.7.2)
+      concurrent-ruby (~> 1.0)
+      rack (> 1, < 3)
+    sprockets-rails (3.2.1)
+      actionpack (>= 4.0)
+      activesupport (>= 4.0)
+      sprockets (>= 3.0.0)
+    sshkey (2.0.0)
+    test-unit (3.3.0)
       power_assert
-    test_after_commit (1.1.0)
-      activerecord (>= 3.2)
     therubyracer (0.12.3)
       libv8 (~> 3.16.14.15)
       ref
     thor (0.20.3)
     thread_safe (0.3.6)
-    tilt (1.4.1)
     trollop (2.9.9)
     tzinfo (1.2.5)
       thread_safe (~> 0.1)
     uglifier (2.7.2)
       execjs (>= 0.3.0)
       json (>= 1.8.0)
-    websocket-driver (0.7.0)
+    websocket-driver (0.6.5)
       websocket-extensions (>= 0.1.0)
     websocket-extensions (0.1.3)
 
@@ -284,7 +274,6 @@ DEPENDENCIES
   andand
   arvados (>= 1.3.1.20190301212059)
   arvados-cli
-  coffee-rails (~> 4.0)
   database_cleaner
   factory_bot_rails
   faye-websocket
@@ -292,6 +281,7 @@ DEPENDENCIES
   jquery-rails
   lograge
   logstash-event
+  minitest (= 5.10.3)
   mocha
   multi_json
   oj
@@ -299,22 +289,22 @@ DEPENDENCIES
   omniauth-oauth2 (~> 1.1)
   passenger
   pg (~> 0.18)
-  rails (~> 4.2)
+  rails (~> 5.0.0)
+  rails-controller-testing
   rails-observers
+  rails-perftest
   responders (~> 2.0)
   ruby-prof
   rvm-capistrano
   safe_yaml
-  sass-rails (~> 4.0)
   simplecov (~> 0.7.1)
   simplecov-rcov
   sshkey
   test-unit (~> 3.0)
-  test_after_commit
   themes_for_rails!
   therubyracer
   trollop
   uglifier (~> 2.0)
 
 BUNDLED WITH
-   1.17.2
+   1.17.3
index 3de2d273bf98f3246cc8745e8f46d9e57ab74723..70ceb653e6f72afc79de5be38c5005486c1d2324 100644 (file)
@@ -7,6 +7,7 @@
 # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
 
 require File.expand_path('../config/application', __FILE__)
+require 'rake/testtask'
 
 Server::Application.load_tasks
 
index 3d6e15025cb1ba031f63e9e6081cae2fee922164..2fe4cec4c7ccc02891b9d01ade9227072954a04a 100644 (file)
@@ -119,7 +119,7 @@ class ArvadosModel < ActiveRecord::Base
   end
 
   def initialize raw_params={}, *args
-    super(self.class.permit_attribute_params(raw_params), *args)
+    super(self.class.permit_attribute_params(raw_params.to_hash), *args)
   end
 
   # Reload "old attributes" for logging, too.
diff --git a/services/api/bin/bundle b/services/api/bin/bundle
new file mode 100755 (executable)
index 0000000..66e9889
--- /dev/null
@@ -0,0 +1,3 @@
+#!/usr/bin/env ruby
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+load Gem.bin_path('bundler', 'bundle')
diff --git a/services/api/bin/rails b/services/api/bin/rails
new file mode 100755 (executable)
index 0000000..0739660
--- /dev/null
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+APP_PATH = File.expand_path('../config/application', __dir__)
+require_relative '../config/boot'
+require 'rails/commands'
diff --git a/services/api/bin/rake b/services/api/bin/rake
new file mode 100755 (executable)
index 0000000..1724048
--- /dev/null
@@ -0,0 +1,4 @@
+#!/usr/bin/env ruby
+require_relative '../config/boot'
+require 'rake'
+Rake.application.run
diff --git a/services/api/bin/setup b/services/api/bin/setup
new file mode 100755 (executable)
index 0000000..e620b4d
--- /dev/null
@@ -0,0 +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__)
+
+def system!(*args)
+  system(*args) || abort("\n== Command #{args} failed ==")
+end
+
+chdir APP_ROOT do
+  # This script is a starting point to setup your application.
+  # Add necessary setup steps to this file.
+
+  puts '== Installing dependencies =='
+  system! 'gem install bundler --conservative'
+  system('bundle check') || system!('bundle install')
+
+  # puts "\n== Copying sample files =="
+  # unless File.exist?('config/database.yml')
+  #   cp 'config/database.yml.sample', 'config/database.yml'
+  # end
+
+  puts "\n== Preparing database =="
+  system! 'bin/rails db:setup'
+
+  puts "\n== Removing old logs and tempfiles =="
+  system! 'bin/rails log:clear tmp:clear'
+
+  puts "\n== Restarting application server =="
+  system! 'bin/rails restart'
+end
diff --git a/services/api/bin/update b/services/api/bin/update
new file mode 100755 (executable)
index 0000000..a8e4462
--- /dev/null
@@ -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
index 8f0dbf4e496b15e73d37083c5d2ac84dd1e8f61d..b9e4638f2235f748c834631cc9e4c86d625ae7b3 100644 (file)
@@ -559,8 +559,10 @@ production:
 test:
   force_ssl: false
   cache_classes: true
-  serve_static_files: true
-  static_cache_control: public, max-age=3600
+  public_file_server:
+    enabled: true
+    headers:
+      'Cache-Control': public, max-age=3600
   whiny_nils: true
   consider_all_requests_local: true
   action_controller.perform_caching: false
index c70ab9591fe76ec2a8b19a4d32096e95d473d722..717101c2b2b6ccbacb9e01c587195b38e1bd8bb4 100644 (file)
@@ -2,9 +2,7 @@
 #
 # SPDX-License-Identifier: AGPL-3.0
 
-require 'rubygems'
-
 # 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'
diff --git a/services/api/config/cable.yml b/services/api/config/cable.yml
new file mode 100644 (file)
index 0000000..0bbde6f
--- /dev/null
@@ -0,0 +1,9 @@
+development:
+  adapter: async
+
+test:
+  adapter: async
+
+production:
+  adapter: redis
+  url: redis://localhost:6379/1
index e24eee035cd2c8f0d01c5b708c43f9d870a1fc71..b82ba27f9ae1bd390bdb71c0fd4f79c9c1fb4b70 100644 (file)
@@ -3,8 +3,8 @@
 # SPDX-License-Identifier: AGPL-3.0
 
 # Load the rails application
-require File.expand_path('../application', __FILE__)
+require_relative 'application'
 require 'josh_id'
 
 # Initialize the rails application
-Server::Application.initialize!
+Rails.application.initialize!
diff --git a/services/api/config/initializers/application_controller_renderer.rb b/services/api/config/initializers/application_controller_renderer.rb
new file mode 100644 (file)
index 0000000..89d2efa
--- /dev/null
@@ -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/services/api/config/initializers/assets.rb b/services/api/config/initializers/assets.rb
new file mode 100644 (file)
index 0000000..01ef3e6
--- /dev/null
@@ -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 --git a/services/api/config/initializers/cookies_serializer.rb b/services/api/config/initializers/cookies_serializer.rb
new file mode 100644 (file)
index 0000000..1389e86
--- /dev/null
@@ -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 --git a/services/api/config/initializers/filter_parameter_logging.rb b/services/api/config/initializers/filter_parameter_logging.rb
new file mode 100644 (file)
index 0000000..4a994e1
--- /dev/null
@@ -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 --git a/services/api/config/initializers/new_framework_defaults.rb b/services/api/config/initializers/new_framework_defaults.rb
new file mode 100644 (file)
index 0000000..cbf423a
--- /dev/null
@@ -0,0 +1,25 @@
+# Be sure to restart your server when you modify this file.
+#
+# This file contains migration options to ease your Rails 5.0 upgrade.
+#
+# Once upgraded flip defaults one by one to migrate to the new default.
+#
+# Read the Guide for Upgrading Ruby on Rails for more info on each option.
+
+Rails.application.config.action_controller.raise_on_unfiltered_parameters = true
+
+# Enable per-form CSRF tokens. Previous versions had false.
+Rails.application.config.action_controller.per_form_csrf_tokens = false
+
+# Enable origin-checking CSRF mitigation. Previous versions had false.
+Rails.application.config.action_controller.forgery_protection_origin_check = false
+
+# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
+# Previous versions had false.
+ActiveSupport.to_time_preserves_timezone = false
+
+# Require `belongs_to` associations by default. Previous versions had false.
+Rails.application.config.active_record.belongs_to_required_by_default = false
+
+# Do not halt callback chains when a callback returns false. Previous versions had true.
+ActiveSupport.halt_callback_chains_on_return_false = true
index 5e9290c88e30a3d253b48ecff6d5093d4fa812fb..7ed424e6441a19992a31576d8d3b8844c25e307c 100644 (file)
@@ -4,7 +4,7 @@
 
 # Be sure to restart your server when you modify this file.
 
-Server::Application.config.session_store :cookie_store, :key => '_server_session'
+Rails.application.config.session_store :cookie_store, key: '_server_session'
 
 # Use the database for sessions instead of the cookie-based default,
 # which shouldn't be used to store highly confidential information
diff --git a/services/api/config/puma.rb b/services/api/config/puma.rb
new file mode 100644 (file)
index 0000000..c7f311f
--- /dev/null
@@ -0,0 +1,47 @@
+# 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 }.to_i
+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. If you use this option
+# you need to make sure to reconnect any threads in the `on_worker_boot`
+# block.
+#
+# preload_app!
+
+# The code in the `on_worker_boot` will be called if you are using
+# clustered mode by specifying a number of `workers`. After each worker
+# process is booted this block will be run, if you are using `preload_app!`
+# option you will want to use this block to reconnect to any threads
+# or connections that may have been created at application boot, Ruby
+# cannot share connections between processes.
+#
+# on_worker_boot do
+#   ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
+# end
+
+# Allow puma to be restarted by `rails restart` command.
+plugin :tmp_restart
diff --git a/services/api/config/secrets.yml b/services/api/config/secrets.yml
new file mode 100644 (file)
index 0000000..4ebe02a
--- /dev/null
@@ -0,0 +1,22 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key is used for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+# You can use `rails secret` to generate a secure secret key.
+
+# Make sure the secrets in this file are kept private
+# if you're sharing your code publicly.
+
+development:
+  secret_key_base: ef8dfe92893202f906d198094f428aaefa75749338e306ed2874938598cad7153ef0dd3cb8036c618cc7c27bb0c6c559728e8cc224da7cdfa2ad1d02874643b0
+
+test:
+  secret_key_base: 0b5454fe8163063950a7124348e2bc780fabbb022fa15f8a074c2fbcfce8eca480ed46b549b87738904f2bae6617ad949c3c3579e272d486c25aaa0ead563355
+
+# Do not keep production secrets in the repository,
+# instead read values from the environment.
+production:
+  secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
diff --git a/services/api/config/spring.rb b/services/api/config/spring.rb
new file mode 100644 (file)
index 0000000..c9119b4
--- /dev/null
@@ -0,0 +1,6 @@
+%w(
+  .ruby-version
+  .rbenv-vars
+  tmp/restart.txt
+  tmp/caching-dev.txt
+).each { |path| Spring.watch(path) }
index dc8bdcb6c5ab126cbc9e2a758173c37c8faae7d9..60db53d5e687440f4297b0ea29fc5893e52cf68c 100644 (file)
@@ -79,8 +79,8 @@ module HasUuid
 
   def destroy_permission_links
     if uuid
-      Link.destroy_all(['link_class=? and (head_uuid=? or tail_uuid=?)',
-                        'permission', uuid, uuid])
+      Link.where(['link_class=? and (head_uuid=? or tail_uuid=?)',
+                  'permission', uuid, uuid]).destroy_all
     end
   end
 end