From 049b7bc3e48fc63d88a1b00bb30afc80a43170a5 Mon Sep 17 00:00:00 2001 From: Robbe Van Herck Date: Wed, 20 Jun 2018 18:02:33 +0200 Subject: [PATCH] Updated to Rails 5.2.0 --- .ruby-version | 2 +- Gemfile | 11 +- Gemfile.lock | 458 +++++++++--------- app/controllers/callbacks_controller.rb | 4 +- app/controllers/notifications_controller.rb | 2 +- app/controllers/requests_controller.rb | 2 +- app/controllers/transactions_controller.rb | 2 +- app/controllers/users_controller.rb | 2 +- app/views/pages/sign_in_page.html.haml | 2 +- bin/bundle | 2 +- bin/rails | 6 +- bin/rake | 4 - bin/setup | 33 +- bin/spring | 2 +- bin/update | 31 ++ bin/yarn | 11 + config/application.rb | 15 +- config/boot.rb | 3 +- config/cable.yml | 10 + config/environment.rb | 2 +- config/environments/development.rb | 43 +- config/environments/production.rb | 48 +- config/environments/test.rb | 16 +- .../application_controller_renderer.rb | 8 + config/initializers/assets.rb | 9 +- .../initializers/content_security_policy.rb | 25 + config/initializers/cookies_serializer.rb | 2 + config/initializers/devise.rb | 3 +- config/initializers/errbit.rb | 7 +- .../new_framework_defaults_5_2.rb | 35 ++ config/spring.rb | 6 + config/storage.yml | 34 ++ .../20150908091028_devise_create_users.rb | 2 +- .../20150908091546_create_transactions.rb | 2 +- db/migrate/20150908092731_create_clients.rb | 2 +- ...095049_add_id_at_client_to_transactions.rb | 2 +- db/migrate/20170109123717_create_requests.rb | 2 +- .../20170109150245_create_notifications.rb | 2 +- .../20170123151219_rolify_create_roles.rb | 2 +- db/schema.rb | 113 +++-- 40 files changed, 593 insertions(+), 374 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/spring.rb create mode 100644 config/storage.yml diff --git a/.ruby-version b/.ruby-version index 2bf1c1c..437459c 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.3.1 +2.5.0 diff --git a/Gemfile b/Gemfile index d31482b..9248a80 100644 --- a/Gemfile +++ b/Gemfile @@ -2,7 +2,7 @@ source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '4.2.4' +gem 'rails', '5.2.0' # Use sqlite3 as the database for Active Record gem 'sqlite3' # Use SCSS for stylesheets @@ -10,19 +10,19 @@ gem 'sass-rails', '~> 5.0' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .coffee assets and views -gem 'coffee-rails', '~> 4.1.0' +gem 'coffee-rails' # See https://github.com/rails/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby # Authentication gem 'devise' -gem 'omniauth-oauth2' +gem 'omniauth-oauth2', '~> 1.3.1' # Authorisation gem 'cancancan' # Haml for templating! -gem "haml-rails", "~> 0.9" +gem "haml-rails" # Friendly ids! gem 'friendly_id', '~> 5.1.0' @@ -63,11 +63,12 @@ group :development, :test do gem 'rspec-rails' gem 'factory_girl_rails' gem 'faker' + gem 'listen' end group :development do # Access an IRB console on exception pages or by using <%= console %> in views - gem 'web-console', '~> 2.0' + gem 'web-console' gem 'annotate' diff --git a/Gemfile.lock b/Gemfile.lock index 2f608c8..297dd50 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,301 +1,322 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.4) - actionpack (= 4.2.4) - actionview (= 4.2.4) - activejob (= 4.2.4) + actioncable (5.2.0) + actionpack (= 5.2.0) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailer (5.2.0) + actionpack (= 5.2.0) + actionview (= 5.2.0) + activejob (= 5.2.0) mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.4) - actionview (= 4.2.4) - activesupport (= 4.2.4) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) + rails-dom-testing (~> 2.0) + actionpack (5.2.0) + actionview (= 5.2.0) + activesupport (= 5.2.0) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.4) - activesupport (= 4.2.4) + actionview (5.2.0) + activesupport (= 5.2.0) builder (~> 3.1) - erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (4.2.4) - activesupport (= 4.2.4) - globalid (>= 0.3.0) - activemodel (4.2.4) - activesupport (= 4.2.4) - builder (~> 3.1) - activerecord (4.2.4) - activemodel (= 4.2.4) - activesupport (= 4.2.4) - arel (~> 6.0) - activesupport (4.2.4) - i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (5.2.0) + activesupport (= 5.2.0) + globalid (>= 0.3.6) + activemodel (5.2.0) + activesupport (= 5.2.0) + activerecord (5.2.0) + activemodel (= 5.2.0) + activesupport (= 5.2.0) + arel (>= 9.0) + activestorage (5.2.0) + actionpack (= 5.2.0) + activerecord (= 5.2.0) + marcel (~> 0.3.1) + activesupport (5.2.0) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) - airbrake (4.3.1) - builder - multi_json - annotate (2.6.10) - activerecord (>= 3.2, <= 4.3) - rake (~> 10.4) - arel (6.0.3) - autoprefixer-rails (6.0.2) + airbrake (7.3.3) + airbrake-ruby (~> 2.10) + airbrake-ruby (2.10.0) + airbrussh (1.3.0) + sshkit (>= 1.6.1, != 1.7.0) + annotate (2.7.4) + activerecord (>= 3.2, < 6.0) + rake (>= 10.4, < 13.0) + arel (9.0.0) + autoprefixer-rails (8.6.2) execjs - json babel-source (5.8.35) babel-transpiler (0.7.0) babel-source (>= 4.0, < 6) execjs (~> 2.0) - bcrypt (3.1.10) - binding_of_caller (0.7.2) - debug_inspector (>= 0.0.1) - bootstrap-sass (3.3.5.1) - autoprefixer-rails (>= 5.0.0.1) - sass (>= 3.3.0) - builder (3.2.2) - byebug (6.0.2) - cancancan (1.12.0) - capistrano (3.4.0) + bcrypt (3.1.12) + bindex (0.5.0) + bootstrap-sass (3.3.7) + autoprefixer-rails (>= 5.2.1) + sass (>= 3.3.4) + builder (3.2.3) + byebug (10.0.2) + cancancan (2.2.0) + capistrano (3.11.0) + airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) - sshkit (~> 1.3) - capistrano-bundler (1.1.4) + sshkit (>= 1.9.0) + capistrano-bundler (1.3.0) capistrano (~> 3.1) sshkit (~> 1.2) - capistrano-passenger (0.1.1) + capistrano-passenger (0.2.0) capistrano (~> 3.0) - capistrano-rails (1.1.3) + capistrano-rails (1.4.0) capistrano (~> 3.1) capistrano-bundler (~> 1.1) - capistrano-rbenv (2.0.3) + capistrano-rbenv (2.1.3) capistrano (~> 3.1) sshkit (~> 1.3) - chartkick (1.3.2) - coffee-rails (4.1.0) + chartkick (2.3.4) + coffee-rails (4.2.2) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.0) + railties (>= 4.0.0) coffee-script (2.4.1) coffee-script-source execjs - coffee-script-source (1.9.1.1) - colorize (0.7.7) - connection_pool (2.2.1) - coveralls (0.8.2) - json (~> 1.8) - rest-client (>= 1.6.8, < 2) - simplecov (~> 0.10.0) + coffee-script-source (1.12.2) + concurrent-ruby (1.0.5) + connection_pool (2.2.2) + coveralls (0.8.21) + json (>= 1.8, < 3) + simplecov (~> 0.14.1) term-ansicolor (~> 1.3) - thor (~> 0.19.1) - debug_inspector (0.0.2) - devise (3.5.2) + thor (~> 0.19.4) + tins (~> 1.6) + crass (1.0.4) + devise (4.4.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 3.2.6, < 5) + railties (>= 4.1.0, < 6.0) responders - thread_safe (~> 0.1) warden (~> 1.2.3) - diff-lcs (1.2.5) + diff-lcs (1.3) docile (1.1.5) - domain_name (0.5.24) - unf (>= 0.0.5, < 1.0.0) + erubi (1.7.1) erubis (2.7.0) - execjs (2.6.0) - factory_girl (4.5.0) + execjs (2.7.0) + factory_girl (4.9.0) activesupport (>= 3.0.0) - factory_girl_rails (4.5.0) - factory_girl (~> 4.5.0) + factory_girl_rails (4.9.0) + factory_girl (~> 4.9.0) railties (>= 3.0.0) - faker (1.5.0) - i18n (~> 0.5) - faraday (0.9.1) + faker (1.8.7) + i18n (>= 0.7) + faraday (0.12.2) multipart-post (>= 1.2, < 3) + ffi (1.9.25) friendly_id (5.1.0) activerecord (>= 4.0.0) - globalid (0.3.6) - activesupport (>= 4.1.0) - haml (4.0.7) + globalid (0.4.1) + activesupport (>= 4.2.0) + haml (5.0.4) + temple (>= 0.8.0) tilt - haml-rails (0.9.0) + haml-rails (1.0.0) actionpack (>= 4.0.1) activesupport (>= 4.0.1) - haml (>= 4.0.6, < 5.0) + haml (>= 4.0.6, < 6.0) html2haml (>= 1.0.1) railties (>= 4.0.1) - hashie (3.4.2) + hashie (3.5.7) high_voltage (2.4.0) - html2haml (2.0.0) + html2haml (2.2.0) erubis (~> 2.7.0) - haml (~> 4.0.0) - nokogiri (~> 1.6.0) + haml (>= 4.0, < 6) + nokogiri (>= 1.6.0) ruby_parser (~> 3.5) - http-cookie (1.0.2) - domain_name (~> 0.5) - i18n (0.7.0) - jbuilder (2.3.1) - activesupport (>= 3.0.0, < 5) - multi_json (~> 1.2) - jquery-datatables-rails (3.3.0) + i18n (1.0.1) + concurrent-ruby (~> 1.0) + jbuilder (2.7.0) + activesupport (>= 4.2.0) + multi_json (>= 1.2) + jquery-datatables-rails (3.4.0) actionpack (>= 3.1) jquery-rails railties (>= 3.1) sass-rails - jquery-rails (4.0.5) - rails-dom-testing (~> 1.0) + jquery-rails (4.3.3) + rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (1.8.3) - jwt (1.5.1) - loofah (2.0.3) + json (1.8.6) + jwt (1.5.6) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) + loofah (2.2.2) + crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.6.3) - mime-types (>= 1.16, < 3) - mime-types (2.6.1) - mini_portile (0.6.2) - minitest (5.8.0) - multi_json (1.11.2) - multi_xml (0.5.5) + mail (2.7.0) + mini_mime (>= 0.1.1) + marcel (0.3.2) + mimemagic (~> 0.3.2) + method_source (0.9.0) + mimemagic (0.3.2) + mini_mime (1.0.0) + mini_portile2 (2.3.0) + minitest (5.11.3) + multi_json (1.13.1) + multi_xml (0.6.0) multipart-post (2.0.0) - mysql2 (0.3.20) + mysql2 (0.3.21) net-scp (1.2.1) net-ssh (>= 2.6.5) - net-ssh (2.9.2) - netrc (0.10.3) - nokogiri (1.6.6.2) - mini_portile (~> 0.6.0) - oauth2 (1.0.0) - faraday (>= 0.8, < 0.10) + net-ssh (5.0.1) + nio4r (2.3.1) + nokogiri (1.8.2) + mini_portile2 (~> 2.3.0) + oauth2 (1.4.0) + faraday (>= 0.8, < 0.13) jwt (~> 1.0) multi_json (~> 1.3) multi_xml (~> 0.5) - rack (~> 1.2) - omniauth (1.2.2) - hashie (>= 1.2, < 4) - rack (~> 1.0) + rack (>= 1.2, < 3) + omniauth (1.8.1) + hashie (>= 3.4.6, < 3.6.0) + rack (>= 1.6.2, < 3) omniauth-oauth2 (1.3.1) oauth2 (~> 1.0) omniauth (~> 1.2) orm_adapter (0.5.0) - purecss-rails (0.6.0) - railties (>= 3.2.6, < 5) - rack (1.6.4) - rack-test (0.6.3) - rack (>= 1.0) - rails (4.2.4) - actionmailer (= 4.2.4) - actionpack (= 4.2.4) - actionview (= 4.2.4) - activejob (= 4.2.4) - activemodel (= 4.2.4) - activerecord (= 4.2.4) - activesupport (= 4.2.4) - bundler (>= 1.3.0, < 2.0) - railties (= 4.2.4) - sprockets-rails - rails-deprecated_sanitizer (1.0.3) - activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.7) - activesupport (>= 4.2.0.beta, < 5.0) - nokogiri (~> 1.6.0) - rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.2) - loofah (~> 2.0) - railties (4.2.4) - actionpack (= 4.2.4) - activesupport (= 4.2.4) + purecss-rails (0.6.1) + railties (>= 3.2.6, < 6) + rack (2.0.5) + rack-test (1.0.0) + rack (>= 1.0, < 3) + rails (5.2.0) + actioncable (= 5.2.0) + actionmailer (= 5.2.0) + actionpack (= 5.2.0) + actionview (= 5.2.0) + activejob (= 5.2.0) + activemodel (= 5.2.0) + activerecord (= 5.2.0) + activestorage (= 5.2.0) + activesupport (= 5.2.0) + bundler (>= 1.3.0) + railties (= 5.2.0) + sprockets-rails (>= 2.0.0) + 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) + railties (5.2.0) + actionpack (= 5.2.0) + activesupport (= 5.2.0) + method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.4.2) - rdoc (4.2.0) - react-rails (1.10.0) + rake (12.3.1) + rb-fsevent (0.10.3) + rb-inotify (0.9.10) + ffi (>= 0.5.0, < 2) + rdoc (4.3.0) + react-rails (2.4.4) babel-transpiler (>= 0.7.0) - coffee-script-source (~> 1.8) connection_pool execjs railties (>= 3.2) tilt - responders (2.1.0) - railties (>= 4.2.0, < 5) - rest-client (1.8.0) - http-cookie (>= 1.0.2, < 2.0) - mime-types (>= 1.16, < 3.0) - netrc (~> 0.7) - rolify (5.1.0) - rspec-core (3.3.2) - rspec-support (~> 3.3.0) - rspec-expectations (3.3.1) + responders (2.4.0) + actionpack (>= 4.2.0, < 5.3) + railties (>= 4.2.0, < 5.3) + rolify (5.2.0) + rspec-core (3.7.1) + rspec-support (~> 3.7.0) + rspec-expectations (3.7.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.3.0) - rspec-mocks (3.3.2) + rspec-support (~> 3.7.0) + rspec-mocks (3.7.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.3.0) - rspec-rails (3.3.3) - actionpack (>= 3.0, < 4.3) - activesupport (>= 3.0, < 4.3) - railties (>= 3.0, < 4.3) - rspec-core (~> 3.3.0) - rspec-expectations (~> 3.3.0) - rspec-mocks (~> 3.3.0) - rspec-support (~> 3.3.0) - rspec-support (3.3.0) - ruby_parser (3.7.1) - sexp_processor (~> 4.1) - sass (3.4.18) - sass-rails (5.0.4) - railties (>= 4.0.0, < 5.0) + rspec-support (~> 3.7.0) + rspec-rails (3.7.2) + actionpack (>= 3.0) + activesupport (>= 3.0) + railties (>= 3.0) + rspec-core (~> 3.7.0) + rspec-expectations (~> 3.7.0) + rspec-mocks (~> 3.7.0) + rspec-support (~> 3.7.0) + rspec-support (3.7.1) + ruby_dep (1.5.0) + ruby_parser (3.11.0) + sexp_processor (~> 4.9) + sass (3.5.6) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sass-rails (5.0.7) + railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) - sdoc (0.4.1) + sdoc (0.4.2) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) - select2-rails (4.0.1) + select2-rails (4.0.3) thor (~> 0.14) - sexp_processor (4.6.0) - simplecov (0.10.0) + sexp_processor (4.11.0) + simplecov (0.14.1) docile (~> 1.1.0) - json (~> 1.8) + json (>= 1.8, < 3) simplecov-html (~> 0.10.0) - simplecov-html (0.10.0) - spring (1.3.6) - sprockets (3.3.4) - rack (~> 1.0) - sprockets-rails (2.3.3) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (>= 2.8, < 4.0) - sqlite3 (1.3.10) - sshkit (1.7.1) - colorize (>= 0.7.0) + simplecov-html (0.10.2) + spring (2.0.2) + activesupport (>= 4.2) + sprockets (3.7.1) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.1) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + sqlite3 (1.3.13) + sshkit (1.16.1) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) - term-ansicolor (1.3.2) + temple (0.8.0) + term-ansicolor (1.6.0) tins (~> 1.0) - thor (0.19.1) - thread_safe (0.3.5) - tilt (2.0.1) - tins (1.6.0) - turbolinks (2.5.3) - coffee-rails - tzinfo (1.2.2) + thor (0.19.4) + thread_safe (0.3.6) + tilt (2.0.8) + tins (1.16.3) + turbolinks (5.1.1) + turbolinks-source (~> 5.1) + turbolinks-source (5.1.0) + tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (2.7.2) - execjs (>= 0.3.0) - json (>= 1.8.0) - unf (0.1.4) - unf_ext - unf_ext (0.0.7.1) - warden (1.2.3) + uglifier (4.1.11) + execjs (>= 0.3.0, < 3) + warden (1.2.7) rack (>= 1.0) - web-console (2.2.1) - activemodel (>= 4.0) - binding_of_caller (>= 0.7.2) - railties (>= 4.0) - sprockets-rails (>= 2.0, < 4.0) + web-console (3.6.2) + actionview (>= 5.0) + activemodel (>= 5.0) + bindex (>= 0.4.0) + railties (>= 5.0) + websocket-driver (0.7.0) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.3) PLATFORMS ruby @@ -311,21 +332,22 @@ DEPENDENCIES capistrano-rails (~> 1.1) capistrano-rbenv chartkick - coffee-rails (~> 4.1.0) + coffee-rails coveralls devise factory_girl_rails faker friendly_id (~> 5.1.0) - haml-rails (~> 0.9) + haml-rails high_voltage (~> 2.4.0) jbuilder (~> 2.0) jquery-datatables-rails jquery-rails + listen mysql2 (~> 0.3.0) - omniauth-oauth2 + omniauth-oauth2 (~> 1.3.1) purecss-rails - rails (= 4.2.4) + rails (= 5.2.0) react-rails rolify rspec-rails @@ -336,7 +358,7 @@ DEPENDENCIES sqlite3 turbolinks uglifier (>= 1.3.0) - web-console (~> 2.0) + web-console BUNDLED WITH - 1.13.7 + 1.16.2 diff --git a/app/controllers/callbacks_controller.rb b/app/controllers/callbacks_controller.rb index dcd8663..050fbe1 100644 --- a/app/controllers/callbacks_controller.rb +++ b/app/controllers/callbacks_controller.rb @@ -1,10 +1,10 @@ class CallbacksController < Devise::OmniauthCallbacksController def zeuswpi @user = User.from_omniauth(request.env["omniauth.auth"]) - sign_in_and_redirect @user + sign_in_and_redirect @user, event: :authentication end def after_omniauth_failure_path_for(scope) root_path end -end +end \ No newline at end of file diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 8978823..ce7bed8 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -1,5 +1,5 @@ class NotificationsController < ApplicationController - load_and_authorize_resource :user, only: :index + load_and_authorize_resource :user, only: :index, find_by: :name before_action :load_notification, only: :read authorize_resource :notification, only: :read diff --git a/app/controllers/requests_controller.rb b/app/controllers/requests_controller.rb index f2c5ac5..e0c3b54 100644 --- a/app/controllers/requests_controller.rb +++ b/app/controllers/requests_controller.rb @@ -1,5 +1,5 @@ class RequestsController < ApplicationController - load_and_authorize_resource :user, only: :index + load_and_authorize_resource :user, only: :index, find_by: :name before_action :load_request, only: [:confirm, :decline] authorize_resource :request, only: [:confirm, :decline] diff --git a/app/controllers/transactions_controller.rb b/app/controllers/transactions_controller.rb index 4227c7e..234e25a 100644 --- a/app/controllers/transactions_controller.rb +++ b/app/controllers/transactions_controller.rb @@ -1,5 +1,5 @@ class TransactionsController < ApplicationController - skip_before_filter :verify_authenticity_token, only: :create + skip_before_action :verify_authenticity_token, only: :create before_action :authenticate_user!, except: :create before_action :authenticate_user_or_client!, only: :create diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ef6b866..2d771b4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,5 @@ class UsersController < ApplicationController - skip_before_filter :verify_authenticity_token, only: :create + skip_before_action :verify_authenticity_token, only: :create, find_by: :name before_action :authenticate_user!, except: :show before_action :authenticate_user_or_client!, only: :show diff --git a/app/views/pages/sign_in_page.html.haml b/app/views/pages/sign_in_page.html.haml index 2795a68..d749f99 100644 --- a/app/views/pages/sign_in_page.html.haml +++ b/app/views/pages/sign_in_page.html.haml @@ -4,7 +4,7 @@ .pure-u-1.pure-u-md-1-2 %h2 Authentication %p Log een keer in en betaal uw schulden! - %p= link_to "Log in met Zeus WPI", user_omniauth_authorize_path(:zeuswpi), class: "pure-button pure-button-primary login-button" + %p= link_to "Log in met Zeus WPI", user_zeuswpi_omniauth_authorize_path, class: "pure-button pure-button-primary login-button" .pure-u-1.pure-u-md-1-2 %h2 Pie of Shame = pie_chart @statistics.shamehash diff --git a/bin/bundle b/bin/bundle index 66e9889..f19acf5 100755 --- a/bin/bundle +++ b/bin/bundle @@ -1,3 +1,3 @@ #!/usr/bin/env ruby -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) load Gem.bin_path('bundler', 'bundle') diff --git a/bin/rails b/bin/rails index 4d608ed..0739660 100755 --- a/bin/rails +++ b/bin/rails @@ -1,8 +1,4 @@ #!/usr/bin/env ruby -begin - load File.expand_path("../spring", __FILE__) -rescue LoadError -end -APP_PATH = File.expand_path('../../config/application', __FILE__) +APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/rake b/bin/rake index 8017a02..1724048 100755 --- a/bin/rake +++ b/bin/rake @@ -1,8 +1,4 @@ #!/usr/bin/env ruby -begin - load File.expand_path("../spring", __FILE__) -rescue LoadError -end require_relative '../config/boot' require 'rake' Rake.application.run diff --git a/bin/setup b/bin/setup index acdb2c1..94fd4d7 100755 --- a/bin/setup +++ b/bin/setup @@ -1,29 +1,36 @@ #!/usr/bin/env ruby -require 'pathname' +require 'fileutils' +include FileUtils # path to your application root. -APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) +APP_ROOT = File.expand_path('..', __dir__) -Dir.chdir APP_ROOT do +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do # This script is a starting point to setup your application. - # Add necessary setup steps to this file: + # Add necessary setup steps to this file. - puts "== Installing dependencies ==" - system "gem install bundler --conservative" - system "bundle check || bundle install" + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') # puts "\n== Copying sample files ==" - # unless File.exist?("config/database.yml") - # 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/spring b/bin/spring index 7b45d37..7b6cef6 100755 --- a/bin/spring +++ b/bin/spring @@ -8,7 +8,7 @@ unless defined?(Spring) require "bundler" if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m) - Gem.paths = { "GEM_PATH" => [Bundler.bundle_path.to_s, *Gem.path].uniq } + Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq.join(File::PATH_SEPARATOR) } gem "spring", match[1] require "spring/binstub" end diff --git a/bin/update b/bin/update new file mode 100755 index 0000000..58bfaed --- /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 0000000..460dd56 --- /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 a9eff52..2bd6ca1 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,4 +1,4 @@ -require File.expand_path('../boot', __FILE__) +require_relative 'boot' require 'rails/all' @@ -8,10 +8,14 @@ Bundler.require(*Rails.groups) module Tab class Application < Rails::Application - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. + # Initialize configuration defaults for originally generated Rails version. + # config.load_defaults 5.0 + # Settings in config/environments/* take precedence over those specified here. + # Application configuration can go into files in config/initializers + # -- all .rb files in that directory are automatically loaded after loading + # the framework and any gems in your application. + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. config.time_zone = 'Brussels' @@ -20,9 +24,6 @@ module Tab # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de - # Do not swallow errors in after_commit/after_rollback callbacks. - config.active_record.raise_in_transactional_callbacks = true - # Which is the lowest balance you should be ashamed of. config.shameful_balance = 0 # In eurocents! config.maximum_amount = 3000 diff --git a/config/boot.rb b/config/boot.rb index 6b750f0..4423c97 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 0000000..c04d41e --- /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: tab_production diff --git a/config/environment.rb b/config/environment.rb index ee8d90d..426333b 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/environments/development.rb b/config/environments/development.rb index 180f8f7..1311e3e 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -9,36 +9,53 @@ Rails.application.configure do # Do not eager load code on boot. config.eager_load = false - # Show full error reports and disable caching. - config.consider_all_requests_local = true - config.action_controller.perform_caching = false + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp', 'caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false + config.action_mailer.perform_caching = false + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. - config.assets.digest = true - - # Adds additional error checking when serving assets at runtime. - # Checks for improperly declared sprockets dependencies. - # Raises helpful error messages. - config.assets.raise_runtime_errors = true + # Suppress logger output for asset requests. + config.assets.quiet = true # Raises error for missing translations # config.action_view.raise_on_missing_translations = true - # Required for Devise - config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + config.file_watcher = ActiveSupport::EventedFileUpdateChecker end diff --git a/config/environments/production.rb b/config/environments/production.rb index 585d591..80a1f6b 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -14,15 +14,13 @@ Rails.application.configure do config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Enable Rack::Cache to put a simple HTTP cache in front of your application - # Add `rack-cache` to your Gemfile before enabling this. - # For large-scale production use, consider using a caching reverse proxy like - # NGINX, varnish or squid. - # config.action_dispatch.rack_cache = true + # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] + # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # config.require_master_key = true # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier @@ -31,16 +29,23 @@ Rails.application.configure do # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false - # Asset digests allow you to set far-future HTTP expiration dates on all assets, - # yet still be able to expire them through the digest params. - config.assets.digest = true - # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' + # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local + + # Mount Action Cable outside main process or domain + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true @@ -49,16 +54,16 @@ Rails.application.configure do config.log_level = :debug # Prepend all log lines with the following tags. - # config.log_tags = [ :subdomain, :uuid ] - - # Use a different logger for distributed setups. - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + config.log_tags = [ :request_id ] # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = 'http://assets.example.com' + # Use a real queuing backend for Active Job (and separate queues per environment) + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "tab_#{Rails.env}" + + config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. @@ -74,7 +79,16 @@ Rails.application.configure do # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false - config.relative_url_root = "/tab" end diff --git a/config/environments/test.rb b/config/environments/test.rb index 1c19f08..0a38fd3 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -12,9 +12,11 @@ Rails.application.configure do # preloads Rails for running tests, you may have to set it to true. config.eager_load = false - # Configure static file server for tests with Cache-Control for performance. - config.serve_static_files = true - config.static_cache_control = 'public, max-age=3600' + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } # Show full error reports and disable caching. config.consider_all_requests_local = true @@ -26,14 +28,16 @@ Rails.application.configure do # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false + # Store uploaded files on the local file system in a temporary directory + config.active_storage.service = :test + + config.action_mailer.perform_caching = false + # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test - # Randomize the order test cases are executed. - config.active_support.test_order = :random - # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb new file mode 100644 index 0000000..89d2efa --- /dev/null +++ b/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 01ef3e6..4b828e8 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -3,9 +3,12 @@ # 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 +# Add additional assets to the asset load path. # Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') # 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 ) +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb new file mode 100644 index 0000000..d3bcaa5 --- /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/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index 7f70458..5a6a32d 100644 --- a/config/initializers/cookies_serializer.rb +++ b/config/initializers/cookies_serializer.rb @@ -1,3 +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 = :json diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 15aa283..c408253 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -235,7 +235,8 @@ Devise.setup do |config| # ==> OmniAuth # Add a new OmniAuth provider. Check the wiki for more information on setting # up on your models and hooks. - config.omniauth :zeuswpi, Rails.application.secrets.omniauth_client_id, Rails.application.secrets.omniauth_client_secret + config.omniauth :zeuswpi, Rails.application.secrets.omniauth_client_id, Rails.application.secrets.omniauth_client_secret, token_params: { parse: :json } + # ==> Warden configuration # If you want to use other strategies, that are not supported by Devise, or diff --git a/config/initializers/errbit.rb b/config/initializers/errbit.rb index 6d4b92a..c5cefb5 100644 --- a/config/initializers/errbit.rb +++ b/config/initializers/errbit.rb @@ -1,6 +1,5 @@ Airbrake.configure do |config| - config.api_key = '066f6146dde14038b5ab69a2f680cd4a' - config.host = 'errbit.awesomepeople.tv' - config.port = 80 - config.secure = config.port == 443 + config.project_key = '066f6146dde14038b5ab69a2f680cd4a' + config.project_id = '066f6146dde14038b5ab69a2f680cd4a' + config.host = 'http://errbit.awesomepeople.tv:80' end diff --git a/config/initializers/new_framework_defaults_5_2.rb b/config/initializers/new_framework_defaults_5_2.rb new file mode 100644 index 0000000..421e5a2 --- /dev/null +++ b/config/initializers/new_framework_defaults_5_2.rb @@ -0,0 +1,35 @@ +# 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 diff --git a/config/spring.rb b/config/spring.rb new file mode 100644 index 0000000..9fa7863 --- /dev/null +++ b/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/config/storage.yml b/config/storage.yml new file mode 100644 index 0000000..d32f76e --- /dev/null +++ b/config/storage.yml @@ -0,0 +1,34 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/db/migrate/20150908091028_devise_create_users.rb b/db/migrate/20150908091028_devise_create_users.rb index 2d83040..c8865e7 100644 --- a/db/migrate/20150908091028_devise_create_users.rb +++ b/db/migrate/20150908091028_devise_create_users.rb @@ -1,4 +1,4 @@ -class DeviseCreateUsers < ActiveRecord::Migration +class DeviseCreateUsers < ActiveRecord::Migration[5.0] def change create_table(:users) do |t| t.string :name, index: true, unique: true diff --git a/db/migrate/20150908091546_create_transactions.rb b/db/migrate/20150908091546_create_transactions.rb index d1e83c4..8134823 100644 --- a/db/migrate/20150908091546_create_transactions.rb +++ b/db/migrate/20150908091546_create_transactions.rb @@ -1,4 +1,4 @@ -class CreateTransactions < ActiveRecord::Migration +class CreateTransactions < ActiveRecord::Migration[5.0] def change create_table :transactions do |t| t.references :debtor, index: true, null: false diff --git a/db/migrate/20150908092731_create_clients.rb b/db/migrate/20150908092731_create_clients.rb index 8e1edff..24d9ee5 100644 --- a/db/migrate/20150908092731_create_clients.rb +++ b/db/migrate/20150908092731_create_clients.rb @@ -1,4 +1,4 @@ -class CreateClients < ActiveRecord::Migration +class CreateClients < ActiveRecord::Migration[5.0] def change create_table :clients do |t| t.string :name, null: false, index: true, unique: true diff --git a/db/migrate/20150914095049_add_id_at_client_to_transactions.rb b/db/migrate/20150914095049_add_id_at_client_to_transactions.rb index a2ceea8..6b0d5f3 100644 --- a/db/migrate/20150914095049_add_id_at_client_to_transactions.rb +++ b/db/migrate/20150914095049_add_id_at_client_to_transactions.rb @@ -1,4 +1,4 @@ -class AddIdAtClientToTransactions < ActiveRecord::Migration +class AddIdAtClientToTransactions < ActiveRecord::Migration[5.0] def change add_column :transactions, :id_at_client, :int add_index :transactions, [:issuer_id, :id_at_client] diff --git a/db/migrate/20170109123717_create_requests.rb b/db/migrate/20170109123717_create_requests.rb index aff94ea..6654acd 100644 --- a/db/migrate/20170109123717_create_requests.rb +++ b/db/migrate/20170109123717_create_requests.rb @@ -1,4 +1,4 @@ -class CreateRequests < ActiveRecord::Migration +class CreateRequests < ActiveRecord::Migration[5.0] def change unless table_exists? :requests create_table :requests do |t| diff --git a/db/migrate/20170109150245_create_notifications.rb b/db/migrate/20170109150245_create_notifications.rb index b8b3717..c36610b 100644 --- a/db/migrate/20170109150245_create_notifications.rb +++ b/db/migrate/20170109150245_create_notifications.rb @@ -1,4 +1,4 @@ -class CreateNotifications < ActiveRecord::Migration +class CreateNotifications < ActiveRecord::Migration[5.0] def change create_table :notifications do |t| t.references :user, index: true, null: false diff --git a/db/migrate/20170123151219_rolify_create_roles.rb b/db/migrate/20170123151219_rolify_create_roles.rb index 8437240..528ac6e 100644 --- a/db/migrate/20170123151219_rolify_create_roles.rb +++ b/db/migrate/20170123151219_rolify_create_roles.rb @@ -1,4 +1,4 @@ -class RolifyCreateRoles < ActiveRecord::Migration +class RolifyCreateRoles < ActiveRecord::Migration[5.0] def change create_table(:roles) do |t| t.string :name diff --git a/db/schema.rb b/db/schema.rb index 1ba8749..0afdaf2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,4 +1,3 @@ -# encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. @@ -11,88 +10,84 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170123151219) do +ActiveRecord::Schema.define(version: 2017_01_23_151219) do create_table "clients", force: :cascade do |t| - t.string "name", null: false - t.string "key", null: false + t.string "name", null: false + t.string "key", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.index ["key"], name: "index_clients_on_key" + t.index ["name"], name: "index_clients_on_name" end - add_index "clients", ["key"], name: "index_clients_on_key" - add_index "clients", ["name"], name: "index_clients_on_name" - create_table "clients_roles", id: false, force: :cascade do |t| t.integer "client_id" t.integer "role_id" + t.index ["client_id", "role_id"], name: "index_clients_roles_on_client_id_and_role_id" + t.index ["client_id"], name: "index_clients_roles_on_client_id" + t.index ["role_id"], name: "index_clients_roles_on_role_id" end - add_index "clients_roles", ["client_id", "role_id"], name: "index_clients_roles_on_client_id_and_role_id" - create_table "notifications", force: :cascade do |t| - t.integer "user_id", null: false - t.string "message" - t.boolean "read", default: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.integer "user_id", null: false + t.string "message" + t.boolean "read", default: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["user_id"], name: "index_notifications_on_user_id" end - add_index "notifications", ["user_id"], name: "index_notifications_on_user_id" - create_table "requests", force: :cascade do |t| - t.integer "debtor_id", null: false - t.integer "creditor_id", null: false - t.integer "issuer_id", null: false - t.string "issuer_type", null: false - t.integer "amount", default: 0, null: false - t.string "message" - t.integer "status", default: 0 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.integer "debtor_id", null: false + t.integer "creditor_id", null: false + t.string "issuer_type", null: false + t.integer "issuer_id", null: false + t.integer "amount", default: 0, null: false + t.string "message" + t.integer "status", default: 0 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["creditor_id"], name: "index_requests_on_creditor_id" + t.index ["debtor_id"], name: "index_requests_on_debtor_id" + t.index ["issuer_type", "issuer_id"], name: "index_requests_on_issuer_type_and_issuer_id" end - add_index "requests", ["creditor_id"], name: "index_requests_on_creditor_id" - add_index "requests", ["debtor_id"], name: "index_requests_on_debtor_id" - add_index "requests", ["issuer_type", "issuer_id"], name: "index_requests_on_issuer_type_and_issuer_id" - create_table "roles", force: :cascade do |t| - t.string "name" - t.integer "resource_id" - t.string "resource_type" - t.datetime "created_at" - t.datetime "updated_at" + t.string "name" + t.string "resource_type" + t.integer "resource_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id" + t.index ["name"], name: "index_roles_on_name" + t.index ["resource_type", "resource_id"], name: "index_roles_on_resource_type_and_resource_id" end - add_index "roles", ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id" - add_index "roles", ["name"], name: "index_roles_on_name" - create_table "transactions", force: :cascade do |t| - t.integer "debtor_id", null: false - t.integer "creditor_id", null: false - t.integer "issuer_id", null: false - t.string "issuer_type", null: false - t.integer "amount", default: 0, null: false - t.string "message" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.integer "id_at_client" + t.integer "debtor_id", null: false + t.integer "creditor_id", null: false + t.string "issuer_type", null: false + t.integer "issuer_id", null: false + t.integer "amount", default: 0, null: false + t.string "message" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.integer "id_at_client" + t.index ["creditor_id"], name: "index_transactions_on_creditor_id" + t.index ["debtor_id"], name: "index_transactions_on_debtor_id" + t.index ["issuer_id", "id_at_client"], name: "index_transactions_on_issuer_id_and_id_at_client" + t.index ["issuer_type", "issuer_id"], name: "index_transactions_on_issuer_type_and_issuer_id" end - add_index "transactions", ["creditor_id"], name: "index_transactions_on_creditor_id" - add_index "transactions", ["debtor_id"], name: "index_transactions_on_debtor_id" - add_index "transactions", ["issuer_id", "id_at_client"], name: "index_transactions_on_issuer_id_and_id_at_client" - add_index "transactions", ["issuer_type", "issuer_id"], name: "index_transactions_on_issuer_type_and_issuer_id" - create_table "users", force: :cascade do |t| - t.string "name" - t.integer "balance", default: 0, null: false - t.boolean "penning", default: false, null: false - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.string "name" + t.integer "balance", default: 0, null: false + t.boolean "penning", default: false, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["balance"], name: "index_users_on_balance" + t.index ["name"], name: "index_users_on_name" end - add_index "users", ["balance"], name: "index_users_on_balance" - add_index "users", ["name"], name: "index_users_on_name" - end