From 27be159c1d1fa83d075d8c3d4303c09369ba0f07 Mon Sep 17 00:00:00 2001 From: Marc Anguera Insa Date: Wed, 25 Sep 2019 22:43:20 +0200 Subject: [PATCH 01/22] Rails 6, first commit! the app boots fine and seems to work fine as well --- Gemfile | 41 +- Gemfile.lock | 394 ++++++++++-------- app/assets/javascripts/active_admin.js | 1 + app/assets/javascripts/active_admin.js.coffee | 1 - app/assets/javascripts/application.js | 22 + app/assets/javascripts/application.js.coffee | 19 - app/assets/javascripts/libs.js | 2 +- app/assets/javascripts/tags.js | 47 +++ app/assets/javascripts/tags.js.coffee | 34 -- app/controllers/application_controller.rb | 8 +- app/controllers/device_tokens_controller.rb | 2 +- app/controllers/members_controller.rb | 2 +- app/controllers/organizations_controller.rb | 2 +- app/controllers/reports_controller.rb | 2 +- app/controllers/statistics_controller.rb | 2 +- app/controllers/terms_controller.rb | 4 +- app/controllers/users_controller.rb | 4 +- app/views/layouts/report.html.erb | 4 +- bin/rails | 2 +- bin/setup | 32 +- config/application.rb | 12 +- config/boot.rb | 2 +- config/environment.rb | 2 +- config/environments/development.rb | 51 ++- config/environments/production.rb | 94 +++-- config/environments/test.rb | 34 +- config/initializers/assets.rb | 7 +- config/initializers/cookies_serializer.rb | 4 +- .../initializers/filter_parameter_logging.rb | 2 +- config/initializers/wrap_parameters.rb | 8 +- spec/spec_helper.rb | 17 - 31 files changed, 457 insertions(+), 401 deletions(-) create mode 100644 app/assets/javascripts/active_admin.js delete mode 100644 app/assets/javascripts/active_admin.js.coffee create mode 100644 app/assets/javascripts/application.js delete mode 100644 app/assets/javascripts/application.js.coffee create mode 100644 app/assets/javascripts/tags.js delete mode 100644 app/assets/javascripts/tags.js.coffee diff --git a/Gemfile b/Gemfile index f8b962925..d211df379 100644 --- a/Gemfile +++ b/Gemfile @@ -2,27 +2,27 @@ source 'https://rubygems.org' ruby File.read('.ruby-version').strip -gem 'rails', '~> 4.2' -gem 'rails-i18n' -gem "rdiscount" -gem 'activeadmin', '~> 1.2.1' -gem 'has_scope' +gem 'rails', '~> 6.0.0' +gem 'rails-i18n', '~> 6.0.0' +gem 'rdiscount', '~> 2.2.0.1' +gem 'activeadmin', '~> 2.3.1' +gem 'has_scope', '~> 0.7.2' gem 'pundit', '~> 2.0.0' -gem 'pg', '0.21.0' -gem 'hstore_translate' +gem 'pg', '1.1.4' +gem 'json_translate', '~> 4.0.0' gem 'dalli' -gem 'devise', '~> 4.5.0' +gem 'devise', '~> 4.7.1' gem "http_accept_language", '~> 2.1.1' -gem 'unicorn' +gem 'unicorn', '~> 5.5.1' gem 'kaminari', '~> 1.1.1' -gem "simple_form", ">= 3.0.0" -gem 'rollbar', '2.8.3' +gem 'simple_form', '~> 4.1.0' +gem 'rollbar', '~> 2.22.1' gem 'whenever', require: false gem 'prawn', '~> 2.2.0' gem 'prawn-table', '~> 0.2.2' gem 'elasticsearch-model' gem 'elasticsearch-rails' -gem 'skylight' +gem 'skylight', '~> 4.1.2' gem 'sidekiq', '5.1.3' gem 'sidekiq-cron', '0.6.3' # TODO: remove this once the following issue has been addressed @@ -30,18 +30,16 @@ gem 'sidekiq-cron', '0.6.3' gem 'rufus-scheduler', '~> 3.4.2' # Assets -gem 'jquery-rails', '>= 4.2.0' +gem 'jquery-rails', '~> 4.3.5' gem 'bootstrap-sass' -gem 'sass-rails', '~> 5.0.7' -gem 'coffee-rails' +gem 'sassc-rails', '~> 2.1.2' gem 'uglifier', '2.7.2' gem 'select2-rails' group :development do - gem "binding_of_caller", '~> 0.8.0' - gem "better_errors", '~> 2.4.0' + gem 'listen' gem 'rubocop', '~> 0.52.1', require: false - gem 'web-console', '2.1.3' + gem 'web-console', '4.0.1' gem 'capistrano', '~> 3.1' gem 'capistrano-rails', '~> 1.1' gem 'capistrano-rbenv', '~> 2.1' @@ -52,13 +50,14 @@ group :development do end group :development, :test do - gem "byebug" + gem 'byebug', '~> 11.0' end group :test do - gem "rspec-rails", '~> 3.8.2' + gem 'rspec-rails', '~> 4.0.0.beta2' + gem 'rails-controller-testing' gem "database_cleaner", '1.6.2' - gem 'shoulda-matchers', '~> 3.1.2' + gem 'shoulda-matchers', '~> 4.1.2' gem 'fabrication' gem 'faker', '~> 1.9' gem 'capybara', '~> 3.15' diff --git a/Gemfile.lock b/Gemfile.lock index ef6705fb3..3e4552265 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,76 +1,94 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (4.2.11.1) - actionpack (= 4.2.11.1) - actionview (= 4.2.11.1) - activejob (= 4.2.11.1) + actioncable (6.0.0) + actionpack (= 6.0.0) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (6.0.0) + actionpack (= 6.0.0) + activejob (= 6.0.0) + activerecord (= 6.0.0) + activestorage (= 6.0.0) + activesupport (= 6.0.0) + mail (>= 2.7.1) + actionmailer (6.0.0) + actionpack (= 6.0.0) + actionview (= 6.0.0) + activejob (= 6.0.0) 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-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.11.1) - activesupport (= 4.2.11.1) + rails-dom-testing (~> 2.0) + actionpack (6.0.0) + actionview (= 6.0.0) + activesupport (= 6.0.0) + rack (~> 2.0) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.0.0) + actionpack (= 6.0.0) + activerecord (= 6.0.0) + activestorage (= 6.0.0) + activesupport (= 6.0.0) + nokogiri (>= 1.8.5) + actionview (6.0.0) + activesupport (= 6.0.0) builder (~> 3.1) - erubis (~> 2.7.0) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.3) - activeadmin (1.2.1) - arbre (>= 1.1.1) - coffee-rails + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activeadmin (2.3.1) + arbre (~> 1.2, >= 1.2.1) formtastic (~> 3.1) - formtastic_i18n + formtastic_i18n (~> 0.4) inherited_resources (~> 1.7) - jquery-rails (>= 4.2.0) - kaminari (>= 0.15, < 2.0) - railties (>= 4.2, < 5.2) - ransack (~> 1.3) - sass (~> 3.1) - sprockets (< 4.1) - 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) + jquery-rails (~> 4.2) + kaminari (~> 1.0, >= 1.0.1) + railties (>= 5.0, < 6.1) + ransack (~> 2.1, >= 2.1.1) + sassc-rails (~> 2.1) + sprockets (>= 3.0, < 4.1) + sprockets-es6 (~> 0.9, >= 0.9.2) + activejob (6.0.0) + activesupport (= 6.0.0) + globalid (>= 0.3.6) + activemodel (6.0.0) + activesupport (= 6.0.0) + activerecord (6.0.0) + activemodel (= 6.0.0) + activesupport (= 6.0.0) + activestorage (6.0.0) + actionpack (= 6.0.0) + activejob (= 6.0.0) + activerecord (= 6.0.0) + marcel (~> 0.3.1) + activesupport (6.0.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) + zeitwerk (~> 2.1, >= 2.1.8) addressable (2.5.1) public_suffix (~> 2.0, >= 2.0.2) airbrussh (0.8.0) sshkit (>= 1.6.1, != 1.7.0) - arbre (1.1.1) + arbre (1.2.1) activesupport (>= 3.0.0) - arel (6.0.4) ast (2.4.0) autoprefixer-rails (6.3.1) execjs json - bcrypt (3.1.12) - better_errors (2.4.0) - coderay (>= 1.0.0) - erubi (>= 1.0.0) - rack (>= 0.9.0) - binding_of_caller (0.8.0) - debug_inspector (>= 0.0.1) + babel-source (5.8.35) + babel-transpiler (0.7.0) + babel-source (>= 4.0, < 6) + execjs (~> 2.0) + bcrypt (3.1.13) + bindex (0.8.1) bootstrap-sass (3.3.6) autoprefixer-rails (>= 5.2.1) sass (>= 3.3.4) builder (3.2.3) - byebug (4.0.5) - columnize (= 0.9.0) + byebug (11.0.1) capistrano (3.4.0) i18n rake (>= 10.0.0) @@ -95,25 +113,15 @@ GEM childprocess (1.0.1) rake (< 13.0) chronic (0.10.2) - coderay (1.1.2) - coffee-rails (4.1.0) - coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.0) - coffee-script (2.3.0) - coffee-script-source - execjs - coffee-script-source (1.8.0) - columnize (0.9.0) concurrent-ruby (1.1.5) connection_pool (2.2.1) crass (1.0.4) dalli (2.7.2) database_cleaner (1.6.2) - debug_inspector (0.0.3) - devise (4.5.0) + devise (4.7.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) - railties (>= 4.1.0, < 6.0) + railties (>= 4.1.0) responders warden (~> 1.2.3) diff-lcs (1.3) @@ -137,8 +145,7 @@ GEM elasticsearch-transport (1.0.7) faraday multi_json - erubi (1.7.1) - erubis (2.7.0) + erubi (1.9.0) et-orbi (1.1.2) tzinfo execjs (2.6.0) @@ -147,33 +154,34 @@ GEM i18n (>= 0.7) faraday (0.9.1) multipart-post (>= 1.2, < 3) + ffi (1.11.1) formtastic (3.1.5) actionpack (>= 3.2.13) formtastic_i18n (0.6.0) gli (2.16.0) globalid (0.4.2) activesupport (>= 4.2.0) - has_scope (0.6.0) - actionpack (>= 3.2, < 5) - activesupport (>= 3.2, < 5) + has_scope (0.7.2) + actionpack (>= 4.1) + activesupport (>= 4.1) hashie (3.4.1) - hstore_translate (1.0.0) - activerecord (>= 3.1.0) http-cookie (1.0.3) domain_name (~> 0.5) http_accept_language (2.1.1) i18n (0.9.5) concurrent-ruby (~> 1.0) - inherited_resources (1.8.0) - actionpack (>= 4.2, <= 5.2) + inherited_resources (1.11.0) + actionpack (>= 5.0, < 6.1) has_scope (~> 0.6) - railties (>= 4.2, <= 5.2) - responders - jquery-rails (4.3.1) + railties (>= 5.0, < 6.1) + responders (>= 2, < 4) + jquery-rails (4.3.5) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) json (2.1.0) + json_translate (4.0.0) + activerecord (>= 4.2.0) kaminari (1.1.1) activesupport (>= 4.1.0) kaminari-actionview (= 1.1.1) @@ -186,11 +194,15 @@ GEM activerecord kaminari-core (= 1.1.1) kaminari-core (1.1.1) - kgio (2.10.0) + kgio (2.11.2) launchy (2.4.3) addressable (~> 2.3) letter_opener (1.4.1) launchy (~> 2.2) + listen (3.1.5) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + ruby_dep (~> 1.2) localeapp (2.1.1) gli i18n (~> 0.4) @@ -201,28 +213,33 @@ GEM nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (0.9.2) mime-types (3.1) mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) - mini_mime (1.0.1) + mimemagic (0.3.3) + mini_mime (1.0.2) mini_portile2 (2.4.0) - minitest (5.11.3) + minitest (5.12.0) multi_json (1.11.2) multipart-post (2.0.0) net-scp (1.2.1) net-ssh (>= 2.6.5) net-ssh (2.9.2) netrc (0.11.0) - nokogiri (1.10.3) + nio4r (2.5.2) + nokogiri (1.10.4) mini_portile2 (~> 2.4.0) orm_adapter (0.5.0) parallel (1.12.1) parser (2.5.0.0) ast (~> 2.4.0) pdf-core (0.7.0) - pg (0.21.0) - polyamorous (1.3.3) - activerecord (>= 3.0) + pg (1.1.4) + polyamorous (2.3.0) + activerecord (>= 5.0) powerpack (0.1.1) prawn (2.2.2) pdf-core (~> 0.7.0) @@ -232,76 +249,84 @@ GEM public_suffix (2.0.5) pundit (2.0.0) activesupport (>= 3.0.0) - rack (1.6.11) + rack (2.0.7) rack-protection (2.0.1) rack - 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) - rails-html-sanitizer (1.0.4) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (6.0.0) + actioncable (= 6.0.0) + actionmailbox (= 6.0.0) + actionmailer (= 6.0.0) + actionpack (= 6.0.0) + actiontext (= 6.0.0) + actionview (= 6.0.0) + activejob (= 6.0.0) + activemodel (= 6.0.0) + activerecord (= 6.0.0) + activestorage (= 6.0.0) + activesupport (= 6.0.0) + bundler (>= 1.3.0) + railties (= 6.0.0) + 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.2.0) loofah (~> 2.2, >= 2.2.2) - rails-i18n (4.0.3) - i18n (~> 0.6) - railties (~> 4.0) - railties (4.2.11.1) - actionpack (= 4.2.11.1) - activesupport (= 4.2.11.1) + rails-i18n (6.0.0) + i18n (>= 0.7, < 2) + railties (>= 6.0.0, < 7) + railties (6.0.0) + actionpack (= 6.0.0) + activesupport (= 6.0.0) + method_source rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) + thor (>= 0.20.3, < 2.0) rainbow (3.0.0) - raindrops (0.16.0) - rake (12.3.2) - ransack (1.8.6) - actionpack (>= 3.0) - activerecord (>= 3.0) - activesupport (>= 3.0) + raindrops (0.19.0) + rake (12.3.3) + ransack (2.3.0) + actionpack (>= 5.0) + activerecord (>= 5.0) + activesupport (>= 5.0) i18n - polyamorous (~> 1.3.2) - rdiscount (2.1.7.1) + polyamorous (= 2.3.0) + rb-fsevent (0.10.3) + rb-inotify (0.10.0) + ffi (~> 1.0) + rdiscount (2.2.0.1) redis (4.0.1) regexp_parser (1.6.0) - responders (2.4.0) - actionpack (>= 4.2.0, < 5.3) - railties (>= 4.2.0, < 5.3) + responders (3.0.0) + actionpack (>= 5.0) + railties (>= 5.0) rest-client (2.0.1) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rollbar (2.8.3) - multi_json - rspec-core (3.8.0) + rollbar (2.22.1) + rspec-core (3.8.2) rspec-support (~> 3.8.0) - rspec-expectations (3.8.2) + rspec-expectations (3.8.4) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.8.0) - rspec-mocks (3.8.0) + rspec-mocks (3.8.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.8.0) - rspec-rails (3.8.2) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.8.0) - rspec-expectations (~> 3.8.0) - rspec-mocks (~> 3.8.0) - rspec-support (~> 3.8.0) - rspec-support (3.8.0) + rspec-rails (4.0.0.beta2) + actionpack (>= 4.2) + activesupport (>= 4.2) + railties (>= 4.2) + rspec-core (~> 3.8) + rspec-expectations (~> 3.8) + rspec-mocks (~> 3.8) + rspec-support (~> 3.8) + rspec-support (3.8.2) rubocop (0.52.1) parallel (~> 1.10) parser (>= 2.4.0.2, < 3.0) @@ -310,23 +335,26 @@ GEM ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) ruby-progressbar (1.9.0) + ruby_dep (1.5.0) rubyzip (1.2.3) rufus-scheduler (3.4.2) et-orbi (~> 1.0) sass (3.4.21) - 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) + sassc (2.2.1) + ffi (~> 1.9) + sassc-rails (2.1.2) + railties (>= 4.0.0) + sassc (>= 2.0) + sprockets (> 3.0) + sprockets-rails + tilt select2-rails (4.0.1) thor (~> 0.14) selenium-webdriver (3.142.3) childprocess (>= 0.5, < 2.0) rubyzip (~> 1.2, >= 1.2.2) - shoulda-matchers (3.1.2) - activesupport (>= 4.0.0) + shoulda-matchers (4.1.2) + activesupport (>= 4.2.0) sidekiq (5.1.3) concurrent-ruby (~> 1.0) connection_pool (~> 2.2, >= 2.2.0) @@ -335,21 +363,25 @@ GEM sidekiq-cron (0.6.3) rufus-scheduler (>= 3.3.0) sidekiq (>= 4.2.1) - simple_form (3.1.0) - actionpack (~> 4.0) - activemodel (~> 4.0) + simple_form (4.1.0) + actionpack (>= 5.0) + activemodel (>= 5.0) simplecov (0.17.0) docile (~> 1.1) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) - skylight (2.0.1) - skylight-core (= 2.0.1) - skylight-core (2.0.1) + skylight (4.1.2) + skylight-core (= 4.1.2) + skylight-core (4.1.2) activesupport (>= 4.2.0) sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) + sprockets-es6 (0.9.2) + babel-source (>= 5.8.11) + babel-transpiler + sprockets (>= 3.0.0) sprockets-rails (3.2.1) actionpack (>= 4.0) activesupport (>= 4.0) @@ -359,7 +391,7 @@ GEM net-ssh (>= 2.8.0) thor (0.20.3) thread_safe (0.3.6) - tilt (2.0.8) + tilt (2.0.10) ttfunk (1.5.1) tzinfo (1.2.5) thread_safe (~> 0.1) @@ -370,79 +402,81 @@ GEM unf_ext unf_ext (0.0.7.2) unicode-display_width (1.3.0) - unicorn (5.0.1) + unicorn (5.5.1) kgio (~> 2.6) - rack raindrops (~> 0.7) - warden (1.2.7) - rack (>= 1.0) - web-console (2.1.3) - activemodel (>= 4.0) - binding_of_caller (>= 0.7.2) - railties (>= 4.0) - sprockets-rails (>= 2.0, < 4.0) + warden (1.2.8) + rack (>= 2.0.6) + web-console (4.0.1) + actionview (>= 6.0.0) + activemodel (>= 6.0.0) + bindex (>= 0.4.0) + railties (>= 6.0.0) webdrivers (4.1.2) nokogiri (~> 1.6) rubyzip (~> 1.0) selenium-webdriver (>= 3.0, < 4.0) + websocket-driver (0.7.1) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.4) whenever (0.9.4) chronic (>= 0.6.3) xpath (3.2.0) nokogiri (~> 1.8) + zeitwerk (2.1.10) PLATFORMS ruby DEPENDENCIES - activeadmin (~> 1.2.1) + activeadmin (~> 2.3.1) airbrussh - better_errors (~> 2.4.0) - binding_of_caller (~> 0.8.0) bootstrap-sass - byebug + byebug (~> 11.0) capistrano (~> 3.1) capistrano-rails (~> 1.1) capistrano-rbenv (~> 2.1) capybara (~> 3.15) - coffee-rails dalli database_cleaner (= 1.6.2) - devise (~> 4.5.0) + devise (~> 4.7.1) dotenv-rails (~> 2.7.1) elasticsearch-model elasticsearch-rails fabrication faker (~> 1.9) - has_scope - hstore_translate + has_scope (~> 0.7.2) http_accept_language (~> 2.1.1) - jquery-rails (>= 4.2.0) + jquery-rails (~> 4.3.5) + json_translate (~> 4.0.0) kaminari (~> 1.1.1) letter_opener (= 1.4.1) + listen localeapp (= 2.1.1) - pg (= 0.21.0) + pg (= 1.1.4) prawn (~> 2.2.0) prawn-table (~> 0.2.2) pundit (~> 2.0.0) - rails (~> 4.2) - rails-i18n - rdiscount - rollbar (= 2.8.3) - rspec-rails (~> 3.8.2) + rails (~> 6.0.0) + rails-controller-testing + rails-i18n (~> 6.0.0) + rdiscount (~> 2.2.0.1) + rollbar (~> 2.22.1) + rspec-rails (~> 4.0.0.beta2) rubocop (~> 0.52.1) rufus-scheduler (~> 3.4.2) - sass-rails (~> 5.0.7) + sassc-rails (~> 2.1.2) select2-rails selenium-webdriver (~> 3.142) - shoulda-matchers (~> 3.1.2) + shoulda-matchers (~> 4.1.2) sidekiq (= 5.1.3) sidekiq-cron (= 0.6.3) - simple_form (>= 3.0.0) + simple_form (~> 4.1.0) simplecov (~> 0.17) - skylight + skylight (~> 4.1.2) uglifier (= 2.7.2) - unicorn - web-console (= 2.1.3) + unicorn (~> 5.5.1) + web-console (= 4.0.1) webdrivers (~> 4.1.2) whenever diff --git a/app/assets/javascripts/active_admin.js b/app/assets/javascripts/active_admin.js new file mode 100644 index 000000000..d2b66c59f --- /dev/null +++ b/app/assets/javascripts/active_admin.js @@ -0,0 +1 @@ +//= require active_admin/base diff --git a/app/assets/javascripts/active_admin.js.coffee b/app/assets/javascripts/active_admin.js.coffee deleted file mode 100644 index 3752dcef6..000000000 --- a/app/assets/javascripts/active_admin.js.coffee +++ /dev/null @@ -1 +0,0 @@ -#= require active_admin/base diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js new file mode 100644 index 000000000..eb821271f --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,22 @@ +//= require give_time +//= require tags +//= require mobile_app_libs +//= require multi_select2 + +$(document).on('click', 'a[data-popup]', function(event) { + window.open($(this).attr('href'), 'popup', 'width=600,height=600'); + return event.preventDefault(); +}); + +$(document).on('click', 'span.show-password', function(event) { + if ($(this).hasClass('checked')) { + $(this).removeClass('checked'); + $(this).prev('input').attr('type', 'password'); + $(this).find('.material-icons').html("visibility"); + } else { + $(this).addClass('checked'); + $(this).prev('input').attr('type', 'text'); + $(this).find('.material-icons').html("visibility_off"); + } + return event.preventDefault(); +}); diff --git a/app/assets/javascripts/application.js.coffee b/app/assets/javascripts/application.js.coffee deleted file mode 100644 index 42b73e2d0..000000000 --- a/app/assets/javascripts/application.js.coffee +++ /dev/null @@ -1,19 +0,0 @@ -#= require give_time -#= require tags -#= require mobile_app_libs -#= require multi_select2 - -$(document).on 'click', 'a[data-popup]', (event) -> - window.open($(this).attr('href'), 'popup', 'width=600,height=600') - event.preventDefault() - -$(document).on 'click', 'span.show-password', (event) -> - if $(this).hasClass('checked') - $(this).removeClass('checked'); - $(this).prev('input').attr('type', 'password'); - $(this).find('.material-icons').html("visibility") - else - $(this).addClass('checked'); - $(this).prev('input').attr('type', 'text'); - $(this).find('.material-icons').html("visibility_off") - event.preventDefault() diff --git a/app/assets/javascripts/libs.js b/app/assets/javascripts/libs.js index bc8647cb7..1c941bd13 100644 --- a/app/assets/javascripts/libs.js +++ b/app/assets/javascripts/libs.js @@ -1,4 +1,4 @@ -//= require jquery +//= require jquery2 //= require jquery_ujs //= require jquery.validate //= require bootstrap diff --git a/app/assets/javascripts/tags.js b/app/assets/javascripts/tags.js new file mode 100644 index 000000000..879311553 --- /dev/null +++ b/app/assets/javascripts/tags.js @@ -0,0 +1,47 @@ +$(function() { + $(".switch_offer-js").on("click", () => $.ajax('/tags/offers', { + type: 'GET', + dataType: 'html', + error(jqXHR, textStatus, errorThrown) { + return $('.alpha_tag_list').html(`AJAX Error: ${textStatus}`); + }, + success(data, textStatus, jqXHR) { + return $('.alpha_tag_list').html(`${data}`); + } + } + )); + + $(".switch_inquiry-js").on("click", () => $.ajax('/tags/inquiries', { + type: 'GET', + dataType: 'html', + error(jqXHR, textStatus, errorThrown) { + return $('.alpha_tag_list').html(`AJAX Error: ${textStatus}`); + }, + success(data, textStatus, jqXHR) { + return $('.alpha_tag_list').html(`${data}`); + } + } + )); + + $('#tags-js').select2({ + tags: true, + tokenSeparators: [','], + dataType: 'json', + delay: 250, + ajax: { + url: '/tags.json', + data(params) { + return { term: params.term }; + }, + processResults(data, params) { + // parse the data into the format expected by Select2 + return { + results: $.map(data, item => ({ + id: item, + text: item + })) + }; + } + } + }); +}); diff --git a/app/assets/javascripts/tags.js.coffee b/app/assets/javascripts/tags.js.coffee deleted file mode 100644 index 6e4bd7c73..000000000 --- a/app/assets/javascripts/tags.js.coffee +++ /dev/null @@ -1,34 +0,0 @@ -$ -> - $(".switch_offer-js").on "click", -> - $.ajax '/tags/offers', - type: 'GET' - dataType: 'html' - error: (jqXHR, textStatus, errorThrown) -> - $('.alpha_tag_list').html "AJAX Error: #{textStatus}" - success: (data, textStatus, jqXHR) -> - $('.alpha_tag_list').html "#{data}" - - $(".switch_inquiry-js").on "click", -> - $.ajax '/tags/inquiries', - type: 'GET' - dataType: 'html' - error: (jqXHR, textStatus, errorThrown) -> - $('.alpha_tag_list').html "AJAX Error: #{textStatus}" - success: (data, textStatus, jqXHR) -> - $('.alpha_tag_list').html "#{data}" - - $('#tags-js').select2 - tags: true - tokenSeparators: [','] - dataType: 'json' - delay: 250 - ajax: - url: '/tags.json' - data: (params) -> - term: params.term - processResults: (data, params) -> - # parse the data into the format expected by Select2 - results: $.map(data, (item) -> - id: item - text: item - ) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a86f2f506..90e55a96c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,10 +6,10 @@ class ApplicationController < ActionController::Base MissingTOSAcceptance = Class.new(Exception) OutadedTOSAcceptance = Class.new(Exception) - append_before_filter :check_for_terms_acceptance!, unless: :devise_controller? - before_filter :configure_permitted_parameters, if: :devise_controller? - before_filter :set_locale - before_filter :set_current_organization + append_before_action :check_for_terms_acceptance!, unless: :devise_controller? + before_action :configure_permitted_parameters, if: :devise_controller? + before_action :set_locale + before_action :set_current_organization rescue_from MissingTOSAcceptance, OutadedTOSAcceptance do redirect_to terms_path diff --git a/app/controllers/device_tokens_controller.rb b/app/controllers/device_tokens_controller.rb index 681105c30..2b8bde098 100644 --- a/app/controllers/device_tokens_controller.rb +++ b/app/controllers/device_tokens_controller.rb @@ -1,5 +1,5 @@ class DeviceTokensController < ApplicationController - before_filter :authenticate_user! + before_action :authenticate_user! def create @device_token = DeviceToken.new device_token_params.merge! user_id: current_user.id diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 5545f4186..7719fa88f 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -1,5 +1,5 @@ class MembersController < ApplicationController - before_filter :authenticate_user! + before_action :authenticate_user! def destroy find_member diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index a49ee91c4..cd104aec6 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -1,5 +1,5 @@ class OrganizationsController < ApplicationController - before_filter :load_resource, only: [:show, :edit, :update, :set_current] + before_action :load_resource, only: [:show, :edit, :update, :set_current] def new @organization = Organization.new diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index ab47ce4aa..d73f96bfd 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -1,5 +1,5 @@ class ReportsController < ApplicationController - before_filter :authenticate_user! + before_action :authenticate_user! layout "report" diff --git a/app/controllers/statistics_controller.rb b/app/controllers/statistics_controller.rb index 458af84b9..efd9a4215 100644 --- a/app/controllers/statistics_controller.rb +++ b/app/controllers/statistics_controller.rb @@ -9,7 +9,7 @@ class StatisticsController < ApplicationController 65..100 => "65+", } - before_filter :authenticate_user! + before_action :authenticate_user! def statistics_global_activity @members = current_organization.members diff --git a/app/controllers/terms_controller.rb b/app/controllers/terms_controller.rb index 5affdff16..ecf1ce81e 100644 --- a/app/controllers/terms_controller.rb +++ b/app/controllers/terms_controller.rb @@ -1,6 +1,6 @@ class TermsController < ApplicationController - before_filter :authenticate_user! - skip_before_filter :check_for_terms_acceptance! + before_action :authenticate_user! + skip_before_action :check_for_terms_acceptance! def show @document = Document.terms_and_conditions diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 398a80292..d95c34a87 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,5 +1,5 @@ class UsersController < ApplicationController - before_filter :authenticate_user! + before_action :authenticate_user! def index search_and_load_members current_organization.members.active, { s: 'user_last_sign_in_at DESC' } @@ -58,7 +58,7 @@ def update private def search_and_load_members(members_scope, default_search_params) - @search = members_scope.ransack(default_search_params.merge(params.fetch(:q, {}))) + @search = members_scope.ransack(default_search_params.merge(params.to_unsafe_h.fetch(:q, {}))) result = @search.result orders = result.orders.map { |order| order.direction == :asc ? "#{order.to_sql} NULLS FIRST" : "#{order.to_sql} NULLS LAST" } diff --git a/app/views/layouts/report.html.erb b/app/views/layouts/report.html.erb index 1f0bd80ae..c8f97aadf 100644 --- a/app/views/layouts/report.html.erb +++ b/app/views/layouts/report.html.erb @@ -15,8 +15,8 @@
<%= t 'reports.download' %> - <%= link_to 'CSV', url_for(params.merge(format: :csv)) %> - <%= link_to 'PDF', url_for(params.merge(format: :pdf)) %> + <%= link_to 'CSV', url_for(params.to_unsafe_h.merge(format: :csv)) %> + <%= link_to 'PDF', url_for(params.to_unsafe_h.merge(format: :pdf)) %>
<%= yield %>
diff --git a/bin/rails b/bin/rails index 5191e6927..073966023 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path('../../config/application', __FILE__) +APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/setup b/bin/setup index acdb2c138..0e39e8cb1 100755 --- a/bin/setup +++ b/bin/setup @@ -1,29 +1,33 @@ #!/usr/bin/env ruby -require 'pathname' +require '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 - # This script is a starting point to setup your application. - # Add necessary setup steps to this file: +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +FileUtils.chdir APP_ROOT do + # This script is a way to setup or update your development environment automatically. + # This script is idempotent, so that you can run it at anytime and get an expectable outcome. + # 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') # 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') + # FileUtils.cp 'config/database.yml.sample', 'config/database.yml' # end puts "\n== Preparing database ==" - system "bin/rake db:setup" + system! 'bin/rails db:prepare' 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/config/application.rb b/config/application.rb index 4bba4fc1b..59ce50146 100644 --- a/config/application.rb +++ b/config/application.rb @@ -8,13 +8,8 @@ module Timeoverflow 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. - - # 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 = 'Central Time (US & Canada)' + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 5.0 # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] @@ -23,9 +18,6 @@ class Application < Rails::Application config.i18n.available_locales = [:es, :ca, :eu, :gl, :en, :'pt-BR'] config.i18n.fallbacks = true - # Do not swallow errors in after_commit/after_rollback callbacks. - config.active_record.raise_in_transactional_callbacks = true - # This tells Rails to serve error pages from the app itself, rather than using static error pages in public/ config.exceptions_app = self.routes diff --git a/config/boot.rb b/config/boot.rb index 6b750f00b..30f5120df 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,3 @@ -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. 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/environments/development.rb b/config/environments/development.rb index ef2d42c86..66df51f6f 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -9,15 +9,32 @@ # 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.action_controller.enable_fragment_cache_logging = 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 = true - config.action_mailer.default_url_options = { - host: (ENV["MAIL_LINK_HOST"] || "localhost:3000") - } + 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 @@ -25,25 +42,21 @@ # 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 - - # Suppresses logger output for asset requests + # Suppress logger output for asset requests. config.assets.quiet = 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 - - # Raises error for missing translations + # Raises error for missing translations. # config.action_view.raise_on_missing_translations = true - config.action_mailer.delivery_method = :letter_opener + # 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 63287d136..b7f268269 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -14,72 +14,57 @@ 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 = true + config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? - # Compress JavaScripts and CSS. - config.assets.js_compressor = :uglifier + # Compress CSS using a preprocessor. # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. - config.assets.compile = true # false + 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 + # config.force_ssl = true # Use the lowest log level to ensure availability of diagnostic information # when problems arise. config.log_level = :debug # Prepend all log lines with the following tags. - # config.log_tags = [ :subdomain, :uuid ] - - # Use a different logger for distributed setups. - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + config.log_tags = [ :request_id ] # Use a different cache store in production. # config.cache_store = :mem_cache_store - config.cache_store = :dalli_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 = "timeoverflow_production" + + 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. - config.action_mailer.raise_delivery_errors = true - - config.action_mailer.delivery_method = :smtp - config.action_mailer.default_url_options = { - host: ENV["MAIL_LINK_HOST"], - protocol: (ENV["MAIL_LINK_PROTO"] || "https") - } - - smtp_env = Hash[ENV.map do |k,v| - if /^SMTP_(.*)$/ === k - [$1.downcase.to_sym, YAML.load(v)] - end - end.compact] - - if smtp_env.present? - config.action_mailer.smtp_settings = smtp_env - end + # config.action_mailer.raise_delivery_errors = false # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). @@ -91,6 +76,37 @@ # 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 + + # Inserts middleware to perform automatic connection switching. + # The `database_selector` hash is used to pass options to the DatabaseSelector + # middleware. The `delay` is used to determine how long to wait after a write + # to send a subsequent read to the primary. + # + # The `database_resolver` class is used by the middleware to determine which + # database is appropriate to use based on the time delay. + # + # The `database_resolver_context` class is used by the middleware to set + # timestamps for the last write to the primary. The resolver uses the context + # class timestamps to determine how long to wait before reading from the + # replica. + # + # By default Rails will store a last write timestamp in the session. The + # DatabaseSelector middleware is designed as such you can define your own + # strategy for connection switching and pass that into the middleware through + # these configuration options. + # config.active_record.database_selector = { delay: 2.seconds } + # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver + # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session end diff --git a/config/environments/test.rb b/config/environments/test.rb index 5dfdff1c1..470dee4be 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,10 +1,11 @@ +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. - # The test environment is used exclusively to run your application's - # test suite. You never need to work with it otherwise. Remember that - # your test database is "scratch space" for the test suite and is wiped - # and recreated between test runs. Don't rely on the data there! config.cache_classes = true # Do not eager load code on boot. This avoids loading your whole application @@ -12,13 +13,16 @@ # 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 config.action_controller.perform_caching = false + config.cache_store = :null_store # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false @@ -26,25 +30,19 @@ # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false - config.action_mailer.default_url_options = { host: "localhost:3000" } + # 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 - # Raises error for missing translations + # Raises error for missing translations. # config.action_view.raise_on_missing_translations = true - - # Avoid seeing all that stuff in tests - config.log_level = :warn - - # ActiveJob configuration - config.active_job.queue_adapter = :test end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 109e3bc42..878a7285c 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -3,11 +3,10 @@ # 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 # Precompile additional assets. -# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. Rails.application.config.assets.precompile += %w( libs.css libs.js ) - -Rails.application.config.assets.initialize_on_precompile = false diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb index ac5f8b663..f51a497e1 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. -Rails.application.config.action_dispatch.cookies_serializer = :marshal +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :hybrid diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb index 24dc90d49..4a994e1e7 100644 --- a/config/initializers/filter_parameter_logging.rb +++ b/config/initializers/filter_parameter_logging.rb @@ -1,4 +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, :assertion] +Rails.application.config.filter_parameters += [:password] diff --git a/config/initializers/wrap_parameters.rb b/config/initializers/wrap_parameters.rb index 007c0deff..bbfc3961b 100644 --- a/config/initializers/wrap_parameters.rb +++ b/config/initializers/wrap_parameters.rb @@ -5,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 = false -end +# ActiveSupport.on_load(:active_record) do +# self.include_root_in_json = true +# end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index daa6c289b..44cd48558 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -157,20 +157,3 @@ def set_browser_locale(locale) with.library :rails end end - -# Rails 4.2 call `initialize` inside `recycle!`. However Ruby 2.6 doesn't allow calling `initialize` twice. -# More info: https://github.com/rails/rails/issues/34790 -if Rails.version < "5" - module ActionController - class TestResponse < ActionDispatch::TestResponse - def recycle! - # hack to avoid MonitorMixin double-initialize error - @mon_mutex_owner_object_id = nil - @mon_mutex = nil - initialize - end - end - end -else - puts "⚠ Monkeypatch for ActionController::TestResponse no longer needed! Remove me please!" -end From c0071212b2c486bdb507ee267d3d644e23f7b71e Mon Sep 17 00:00:00 2001 From: Marc Anguera Insa Date: Thu, 26 Sep 2019 02:16:05 +0200 Subject: [PATCH 02/22] more gem updates; minor js refactor; first pass over tests and first fixes :) --- .gitignore | 3 +- .rubocop.yml | 21 ++-- Gemfile | 19 ++-- Gemfile.lock | 69 ++++++------ app/assets/javascripts/application.js | 4 +- app/assets/javascripts/tags.js | 43 ++++---- app/controllers/application_controller.rb | 2 +- app/controllers/device_tokens_controller.rb | 4 +- app/controllers/members_controller.rb | 7 +- app/controllers/transfers_controller.rb | 5 +- app/controllers/users_controller.rb | 4 +- app/models/account.rb | 4 +- app/models/application_record.rb | 3 + app/models/category.rb | 2 +- app/models/concerns/taggable.rb | 1 - app/models/device_token.rb | 3 +- app/models/document.rb | 4 +- app/models/event.rb | 8 +- app/models/member.rb | 2 +- app/models/movement.rb | 2 +- app/models/organization.rb | 2 +- app/models/post.rb | 6 +- app/models/push_notification.rb | 3 +- app/models/transfer.rb | 4 +- app/models/user.rb | 2 +- app/services/report/csv.rb | 2 +- app/services/report/pdf.rb | 2 +- config/application.rb | 2 +- config/environments/development.rb | 7 +- config/environments/production.rb | 26 ++++- config/environments/staging.rb | 100 +----------------- config/environments/test.rb | 5 +- db/schema.rb | 2 +- db/seeds.rb | 21 +--- lib/assets/.gitkeep | 0 lib/assets/.keep | 0 lib/tasks/.gitkeep | 0 spec/admin/organizations_controller_spec.rb | 2 +- .../application_controller_spec.rb | 2 +- .../device_tokens_controller_spec.rb | 2 +- spec/controllers/inquiries_controller_spec.rb | 40 +++---- .../multi_transfers_controller_spec.rb | 40 +++---- spec/controllers/offers_controller_spec.rb | 46 ++++---- .../organizations_controller_spec.rb | 10 +- spec/controllers/pages_controller_spec.rb | 4 +- spec/controllers/reports_controller_spec.rb | 2 +- spec/controllers/sessions_controller_spec.rb | 8 +- spec/controllers/tags_controller_spec.rb | 2 +- spec/controllers/transfers_controller_spec.rb | 40 +++---- spec/controllers/users_controller_spec.rb | 61 +++++------ spec/spec_helper.rb | 21 ---- 51 files changed, 278 insertions(+), 396 deletions(-) create mode 100644 app/models/application_record.rb delete mode 100644 lib/assets/.gitkeep delete mode 100644 lib/assets/.keep delete mode 100644 lib/tasks/.gitkeep diff --git a/.gitignore b/.gitignore index 70a3775c7..779901f98 100644 --- a/.gitignore +++ b/.gitignore @@ -33,11 +33,10 @@ rerun.txt pickle-email-*.html timeoverflow_development timeoverflow_test - +.byebug_history .env .DS_Store .idea/ -sgemset # Ignore .vagrant folder with images .vagrant diff --git a/.rubocop.yml b/.rubocop.yml index 62dfcb6ab..4035b36b5 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,5 @@ +require: rubocop-rails + AllCops: Exclude: - db/schema.rb @@ -5,8 +7,8 @@ AllCops: Naming/AccessorMethodName: Enabled: false -Rails/ActionFilter: - Enabled: false +Rails/HttpPositionalArguments: + Enabled: true Style/Alias: Enabled: false @@ -57,9 +59,6 @@ Style/CommentAnnotation: Metrics/CyclomaticComplexity: Enabled: false -Rails/Delegate: - Enabled: false - Style/Documentation: Enabled: false @@ -84,7 +83,7 @@ Style/EvenOdd: Naming/FileName: Enabled: false -Style/FlipFlop: +Lint/FlipFlop: Enabled: false Style/FormatString: @@ -187,16 +186,16 @@ Style/StringLiterals: Style/VariableInterpolation: Enabled: false -Style/TrailingCommaInLiteral: +Style/TrailingCommaInArrayLiteral: Enabled: false -Style/TrailingCommaInArguments: +Style/TrailingCommaInHashLiteral: Enabled: false -Style/TrivialAccessors: +Style/TrailingCommaInArguments: Enabled: false -Style/VariableInterpolation: +Style/TrivialAccessors: Enabled: false Style/WhenThen: @@ -214,7 +213,7 @@ Lint/AmbiguousRegexpLiteral: Lint/AssignmentInCondition: Enabled: false -Lint/ConditionPosition: +Layout/ConditionPosition: Enabled: false Lint/DeprecatedClassMethods: diff --git a/Gemfile b/Gemfile index d211df379..17fc3795a 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,7 @@ gem 'rdiscount', '~> 2.2.0.1' gem 'activeadmin', '~> 2.3.1' gem 'has_scope', '~> 0.7.2' gem 'pundit', '~> 2.0.0' -gem 'pg', '1.1.4' +gem 'pg', '~> 1.1.4' gem 'json_translate', '~> 4.0.0' gem 'dalli' gem 'devise', '~> 4.7.1' @@ -23,7 +23,7 @@ gem 'prawn-table', '~> 0.2.2' gem 'elasticsearch-model' gem 'elasticsearch-rails' gem 'skylight', '~> 4.1.2' -gem 'sidekiq', '5.1.3' +gem 'sidekiq', '~> 6.0.0' gem 'sidekiq-cron', '0.6.3' # TODO: remove this once the following issue has been addressed # https://github.com/ondrejbartas/sidekiq-cron/issues/199 @@ -33,19 +33,20 @@ gem 'rufus-scheduler', '~> 3.4.2' gem 'jquery-rails', '~> 4.3.5' gem 'bootstrap-sass' gem 'sassc-rails', '~> 2.1.2' -gem 'uglifier', '2.7.2' +gem 'uglifier', '~> 4.1.20' gem 'select2-rails' group :development do - gem 'listen' - gem 'rubocop', '~> 0.52.1', require: false - gem 'web-console', '4.0.1' + gem 'listen', '~> 3.1.5' + gem 'rubocop', '~> 0.74.0', require: false + gem 'rubocop-rails', require: false + gem 'web-console', '~> 4.0.1' gem 'capistrano', '~> 3.1' gem 'capistrano-rails', '~> 1.1' gem 'capistrano-rbenv', '~> 2.1' gem 'airbrussh', require: false gem 'localeapp', '2.1.1', require: false - gem 'letter_opener', '1.4.1' + gem 'letter_opener', '~> 1.7.0' gem 'dotenv-rails', '~> 2.7.1' end @@ -56,11 +57,11 @@ end group :test do gem 'rspec-rails', '~> 4.0.0.beta2' gem 'rails-controller-testing' - gem "database_cleaner", '1.6.2' + gem 'database_cleaner', '~> 1.7.0' gem 'shoulda-matchers', '~> 4.1.2' gem 'fabrication' gem 'faker', '~> 1.9' - gem 'capybara', '~> 3.15' + gem 'capybara', '~> 3.29' gem 'selenium-webdriver', '~> 3.142' gem 'webdrivers', '~> 4.1.2' gem 'simplecov', '~> 0.17', require: false diff --git a/Gemfile.lock b/Gemfile.lock index 3e4552265..06ac7676c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -102,22 +102,22 @@ GEM capistrano-rbenv (2.1.3) capistrano (~> 3.1) sshkit (~> 1.3) - capybara (3.15.1) + capybara (3.29.0) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) rack (>= 1.6.0) rack-test (>= 0.6.3) - regexp_parser (~> 1.2) + regexp_parser (~> 1.5) xpath (~> 3.2) childprocess (1.0.1) rake (< 13.0) chronic (0.10.2) concurrent-ruby (1.1.5) - connection_pool (2.2.1) + connection_pool (2.2.2) crass (1.0.4) dalli (2.7.2) - database_cleaner (1.6.2) + database_cleaner (1.7.0) devise (4.7.1) bcrypt (~> 3.0) orm_adapter (~> 0.1) @@ -175,6 +175,7 @@ GEM has_scope (~> 0.6) railties (>= 5.0, < 6.1) responders (>= 2, < 4) + jaro_winkler (1.5.3) jquery-rails (4.3.5) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -197,7 +198,7 @@ GEM kgio (2.11.2) launchy (2.4.3) addressable (~> 2.3) - letter_opener (1.4.1) + letter_opener (1.7.0) launchy (~> 2.2) listen (3.1.5) rb-fsevent (~> 0.9, >= 0.9.4) @@ -233,14 +234,13 @@ GEM nokogiri (1.10.4) mini_portile2 (~> 2.4.0) orm_adapter (0.5.0) - parallel (1.12.1) - parser (2.5.0.0) + parallel (1.17.0) + parser (2.6.4.1) ast (~> 2.4.0) pdf-core (0.7.0) pg (1.1.4) polyamorous (2.3.0) activerecord (>= 5.0) - powerpack (0.1.1) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) @@ -250,7 +250,7 @@ GEM pundit (2.0.0) activesupport (>= 3.0.0) rack (2.0.7) - rack-protection (2.0.1) + rack-protection (2.0.7) rack rack-test (1.1.0) rack (>= 1.0, < 3) @@ -300,7 +300,7 @@ GEM rb-inotify (0.10.0) ffi (~> 1.0) rdiscount (2.2.0.1) - redis (4.0.1) + redis (4.1.3) regexp_parser (1.6.0) responders (3.0.0) actionpack (>= 5.0) @@ -327,14 +327,17 @@ GEM rspec-mocks (~> 3.8) rspec-support (~> 3.8) rspec-support (3.8.2) - rubocop (0.52.1) + rubocop (0.74.0) + jaro_winkler (~> 1.5.1) parallel (~> 1.10) - parser (>= 2.4.0.2, < 3.0) - powerpack (~> 0.1) + parser (>= 2.6) rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) - unicode-display_width (~> 1.0, >= 1.0.1) - ruby-progressbar (1.9.0) + unicode-display_width (>= 1.4.0, < 1.7) + rubocop-rails (2.3.2) + rack (>= 1.1) + rubocop (>= 0.72.0) + ruby-progressbar (1.10.1) ruby_dep (1.5.0) rubyzip (1.2.3) rufus-scheduler (3.4.2) @@ -355,11 +358,11 @@ GEM rubyzip (~> 1.2, >= 1.2.2) shoulda-matchers (4.1.2) activesupport (>= 4.2.0) - sidekiq (5.1.3) - concurrent-ruby (~> 1.0) - connection_pool (~> 2.2, >= 2.2.0) - rack-protection (>= 1.5.0) - redis (>= 3.3.5, < 5) + sidekiq (6.0.0) + connection_pool (>= 2.2.2) + rack (>= 2.0.0) + rack-protection (>= 2.0.0) + redis (>= 4.1.0) sidekiq-cron (0.6.3) rufus-scheduler (>= 3.3.0) sidekiq (>= 4.2.1) @@ -395,13 +398,12 @@ GEM ttfunk (1.5.1) tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (2.7.2) - execjs (>= 0.3.0) - json (>= 1.8.0) + uglifier (4.1.20) + execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext unf_ext (0.0.7.2) - unicode-display_width (1.3.0) + unicode-display_width (1.6.0) unicorn (5.5.1) kgio (~> 2.6) raindrops (~> 0.7) @@ -436,9 +438,9 @@ DEPENDENCIES capistrano (~> 3.1) capistrano-rails (~> 1.1) capistrano-rbenv (~> 2.1) - capybara (~> 3.15) + capybara (~> 3.29) dalli - database_cleaner (= 1.6.2) + database_cleaner (~> 1.7.0) devise (~> 4.7.1) dotenv-rails (~> 2.7.1) elasticsearch-model @@ -450,10 +452,10 @@ DEPENDENCIES jquery-rails (~> 4.3.5) json_translate (~> 4.0.0) kaminari (~> 1.1.1) - letter_opener (= 1.4.1) - listen + letter_opener (~> 1.7.0) + listen (~> 3.1.5) localeapp (= 2.1.1) - pg (= 1.1.4) + pg (~> 1.1.4) prawn (~> 2.2.0) prawn-table (~> 0.2.2) pundit (~> 2.0.0) @@ -463,20 +465,21 @@ DEPENDENCIES rdiscount (~> 2.2.0.1) rollbar (~> 2.22.1) rspec-rails (~> 4.0.0.beta2) - rubocop (~> 0.52.1) + rubocop (~> 0.74.0) + rubocop-rails rufus-scheduler (~> 3.4.2) sassc-rails (~> 2.1.2) select2-rails selenium-webdriver (~> 3.142) shoulda-matchers (~> 4.1.2) - sidekiq (= 5.1.3) + sidekiq (~> 6.0.0) sidekiq-cron (= 0.6.3) simple_form (~> 4.1.0) simplecov (~> 0.17) skylight (~> 4.1.2) - uglifier (= 2.7.2) + uglifier (~> 4.1.20) unicorn (~> 5.5.1) - web-console (= 4.0.1) + web-console (~> 4.0.1) webdrivers (~> 4.1.2) whenever diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index eb821271f..5cf3ef03a 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -4,11 +4,12 @@ //= require multi_select2 $(document).on('click', 'a[data-popup]', function(event) { + event.preventDefault(); window.open($(this).attr('href'), 'popup', 'width=600,height=600'); - return event.preventDefault(); }); $(document).on('click', 'span.show-password', function(event) { + event.preventDefault(); if ($(this).hasClass('checked')) { $(this).removeClass('checked'); $(this).prev('input').attr('type', 'password'); @@ -18,5 +19,4 @@ $(document).on('click', 'span.show-password', function(event) { $(this).prev('input').attr('type', 'text'); $(this).find('.material-icons').html("visibility_off"); } - return event.preventDefault(); }); diff --git a/app/assets/javascripts/tags.js b/app/assets/javascripts/tags.js index 879311553..3fc98952f 100644 --- a/app/assets/javascripts/tags.js +++ b/app/assets/javascripts/tags.js @@ -1,27 +1,24 @@ $(function() { - $(".switch_offer-js").on("click", () => $.ajax('/tags/offers', { - type: 'GET', - dataType: 'html', - error(jqXHR, textStatus, errorThrown) { - return $('.alpha_tag_list').html(`AJAX Error: ${textStatus}`); - }, - success(data, textStatus, jqXHR) { - return $('.alpha_tag_list').html(`${data}`); - } - } - )); + $(".switch_offer-js").on("click", function() { + loadTags('/tags/offers'); + }); - $(".switch_inquiry-js").on("click", () => $.ajax('/tags/inquiries', { - type: 'GET', - dataType: 'html', - error(jqXHR, textStatus, errorThrown) { - return $('.alpha_tag_list').html(`AJAX Error: ${textStatus}`); - }, - success(data, textStatus, jqXHR) { - return $('.alpha_tag_list').html(`${data}`); - } + $(".switch_inquiry-js").on("click", function() { + loadTags('/tags/inquiries'); + }); + + function loadTags(url){ + $.get({ + url: url, + dataType: 'html', + error: function(jqXHR, textStatus, errorThrown) { + $('.alpha_tag_list').html('AJAX Error: ' + textStatus); + }, + success: function(data, textStatus, jqXHR) { + $('.alpha_tag_list').html(data); + } + }); } - )); $('#tags-js').select2({ tags: true, @@ -30,10 +27,10 @@ $(function() { delay: 250, ajax: { url: '/tags.json', - data(params) { + data: function(params) { return { term: params.term }; }, - processResults(data, params) { + processResults: function(data, params) { // parse the data into the format expected by Select2 return { results: $.map(data, item => ({ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 90e55a96c..615602cad 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -21,7 +21,7 @@ class ApplicationController < ActionController::Base helper_method :current_organization, :admin?, :superadmin? def switch_lang - redirect_to :back + redirect_back(fallback_location: root_path) end private diff --git a/app/controllers/device_tokens_controller.rb b/app/controllers/device_tokens_controller.rb index 2b8bde098..105b76d60 100644 --- a/app/controllers/device_tokens_controller.rb +++ b/app/controllers/device_tokens_controller.rb @@ -5,9 +5,9 @@ def create @device_token = DeviceToken.new device_token_params.merge! user_id: current_user.id if @device_token.save - render nothing: true, status: :created + head :created else - render nothing: true, status: :unprocessable_entity + head :unprocessable_entity end end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 7719fa88f..6b01870ff 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -5,15 +5,17 @@ def destroy find_member toggle_active_posts @member.destroy + redirect_to manage_users_path end def toggle_manager find_member @member.toggle(:manager).save! + respond_to do |format| format.json { head :ok } - format.html { redirect_to :back } + format.html { redirect_to manage_users_path } end end @@ -25,9 +27,10 @@ def toggle_active else @member.remove_all_posts_from_index end + respond_to do |format| format.json { head :ok } - format.html { redirect_to :back } + format.html { redirect_to manage_users_path } end end diff --git a/app/controllers/transfers_controller.rb b/app/controllers/transfers_controller.rb index 7ef94931a..e65506566 100644 --- a/app/controllers/transfers_controller.rb +++ b/app/controllers/transfers_controller.rb @@ -14,7 +14,7 @@ def create if persister.save redirect_to redirect_target else - redirect_to :back, alert: transfer.errors.full_messages.to_sentence + redirect_back fallback_location: redirect_target, alert: transfer.errors.full_messages.to_sentence end end @@ -40,9 +40,10 @@ def new def delete_reason @transfer = Transfer.find(params[:id]) @transfer.update_columns(reason: nil) + respond_to do |format| format.json { head :ok } - format.html { redirect_to :back } + format.html { redirect_back(fallback_location: request.referer) } end end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d95c34a87..5b18594d3 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -61,8 +61,8 @@ def search_and_load_members(members_scope, default_search_params) @search = members_scope.ransack(default_search_params.merge(params.to_unsafe_h.fetch(:q, {}))) result = @search.result - orders = result.orders.map { |order| order.direction == :asc ? "#{order.to_sql} NULLS FIRST" : "#{order.to_sql} NULLS LAST" } - result = result.except(:order).order(orders.join(", ")) if orders.count > 0 + # orders = result.orders.map { |order| order.direction == :asc ? "#{order.to_sql} NULLS FIRST" : "#{order.to_sql} NULLS LAST" } + # result = result.except(:order).order(orders.join(", ")) if orders.count > 0 @members = result.eager_load(:account, :user).page(params[:page]).per(20) diff --git a/app/models/account.rb b/app/models/account.rb index 973010148..b85cc3a6a 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -6,7 +6,7 @@ # The Account may also be flagged, if needed, when the balance overflows # some set limits # -class Account < ActiveRecord::Base +class Account < ApplicationRecord belongs_to :accountable, polymorphic: true belongs_to :organization, inverse_of: :all_accounts has_many :movements @@ -18,7 +18,7 @@ class Account < ActiveRecord::Base def update_balance new_balance = movements.sum(:amount) self.balance = new_balance - self.flagged = !within_allowed_limits? if balance_changed? + self.flagged = !within_allowed_limits? if saved_change_to_balance? save end diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 000000000..10a4cba84 --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/app/models/category.rb b/app/models/category.rb index af083e149..16b4e6063 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -1,4 +1,4 @@ -class Category < ActiveRecord::Base +class Category < ApplicationRecord has_many :posts translates :name diff --git a/app/models/concerns/taggable.rb b/app/models/concerns/taggable.rb index 31f81e709..0a499bbf1 100644 --- a/app/models/concerns/taggable.rb +++ b/app/models/concerns/taggable.rb @@ -17,7 +17,6 @@ def tag_list=(tag_list) self.tags = tag_list.reject(&:empty?) end - # class methods (stupid comment to make rubocop happy) module ClassMethods def all_tags pluck(:tags).flatten.compact.reject(&:empty?) diff --git a/app/models/device_token.rb b/app/models/device_token.rb index ce15196d3..e6539c2eb 100644 --- a/app/models/device_token.rb +++ b/app/models/device_token.rb @@ -1,7 +1,6 @@ -class DeviceToken < ActiveRecord::Base +class DeviceToken < ApplicationRecord belongs_to :user - validates :user_id, presence: true validates :token, presence: true validates :token, uniqueness: { scope: :user_id } end diff --git a/app/models/document.rb b/app/models/document.rb index 494bfba82..6cbb0a814 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -1,5 +1,5 @@ -class Document < ActiveRecord::Base - belongs_to :documentable, polymorphic: true +class Document < ApplicationRecord + belongs_to :documentable, polymorphic: true, optional: true def self.terms_and_conditions where(label: "t&c", documentable_id: nil).first diff --git a/app/models/event.rb b/app/models/event.rb index df6275dd7..fa05bfd21 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -1,9 +1,9 @@ -class Event < ActiveRecord::Base +class Event < ApplicationRecord enum action: { created: 0, updated: 1 } - belongs_to :post - belongs_to :member - belongs_to :transfer + belongs_to :post, optional: true + belongs_to :member, optional: true + belongs_to :transfer, optional: true has_many :push_notifications, dependent: :destroy validates :action, presence: true diff --git a/app/models/member.rb b/app/models/member.rb index 6e5381860..e0fe3a1be 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -1,4 +1,4 @@ -class Member < ActiveRecord::Base +class Member < ApplicationRecord # Cast the member_uid integer to a string to allow pg ILIKE search (from Ransack *_contains) ransacker :member_uid_search do Arel.sql("member_uid::text") diff --git a/app/models/movement.rb b/app/models/movement.rb index 3408de8cc..5e2ee10c2 100644 --- a/app/models/movement.rb +++ b/app/models/movement.rb @@ -3,7 +3,7 @@ # These records should not be created nor modified by themselves. # They are created during the creation of the corresponding Transfer record. # -class Movement < ActiveRecord::Base +class Movement < ApplicationRecord attr_readonly :account_id, :transfer_id, :amount belongs_to :account diff --git a/app/models/organization.rb b/app/models/organization.rb index ad93d45ad..3e8d3a530 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -1,4 +1,4 @@ -class Organization < ActiveRecord::Base +class Organization < ApplicationRecord has_many :members, dependent: :destroy has_many :users, -> { order "members.created_at DESC" }, through: :members has_many :all_accounts, class_name: "Account", inverse_of: :organization, dependent: :destroy diff --git a/app/models/post.rb b/app/models/post.rb index 485f0f319..535030ee8 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -1,6 +1,6 @@ require 'elasticsearch/model' -class Post < ActiveRecord::Base +class Post < ApplicationRecord include Taggable # Elasticsearch::Model doesn't work well with STI, so @@ -40,7 +40,7 @@ def self.inherited(child) belongs_to :category belongs_to :user - belongs_to :organization + belongs_to :organization, optional: true has_many :transfers has_many :movements, through: :transfers has_many :events, dependent: :destroy @@ -68,8 +68,6 @@ def self.inherited(child) where(created_at: (1.week.ago.beginning_of_day...DateTime.now.end_of_day)) } - validates :user, presence: true - validates :category, presence: true validates :title, presence: true def index_document diff --git a/app/models/push_notification.rb b/app/models/push_notification.rb index a55f02411..8344537b8 100644 --- a/app/models/push_notification.rb +++ b/app/models/push_notification.rb @@ -1,8 +1,7 @@ -class PushNotification < ActiveRecord::Base +class PushNotification < ApplicationRecord belongs_to :event, foreign_key: 'event_id' belongs_to :device_token, foreign_key: 'device_token_id' - validates :event, :device_token, presence: true validates :title, :body, presence: true, allow_blank: false delegate :token, to: :device_token diff --git a/app/models/transfer.rb b/app/models/transfer.rb index 050b24bfc..9efeec490 100644 --- a/app/models/transfer.rb +++ b/app/models/transfer.rb @@ -10,10 +10,10 @@ # Along with the transfer, two movements are created, one in each related # account, so the total sum of the system is zero # -class Transfer < ActiveRecord::Base +class Transfer < ApplicationRecord attr_accessor :source, :destination, :amount, :hours, :minutes - belongs_to :post + belongs_to :post, optional: true has_many :movements, dependent: :destroy has_many :events, dependent: :destroy diff --git a/app/models/user.rb b/app/models/user.rb index fca0fdff6..67fa3de9c 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,4 +1,4 @@ -class User < ActiveRecord::Base +class User < ApplicationRecord include LazyRecoverable devise *[ diff --git a/app/services/report/csv.rb b/app/services/report/csv.rb index c6483c63d..ac4b54a0e 100644 --- a/app/services/report/csv.rb +++ b/app/services/report/csv.rb @@ -2,7 +2,7 @@ module Report module CSV - MIME_TYPE = Mime::CSV + MIME_TYPE = Mime[:pdf] def self.run(headers, rows) ::CSV.generate do |csv| diff --git a/app/services/report/pdf.rb b/app/services/report/pdf.rb index 4e148b548..f36a235ab 100644 --- a/app/services/report/pdf.rb +++ b/app/services/report/pdf.rb @@ -1,6 +1,6 @@ module Report module PDF - MIME_TYPE = Mime::PDF + MIME_TYPE = Mime[:pdf] def self.run(headers, rows) pdf = Prawn::Document.new(options) diff --git a/config/application.rb b/config/application.rb index 59ce50146..f5f0a3b55 100644 --- a/config/application.rb +++ b/config/application.rb @@ -9,7 +9,7 @@ module Timeoverflow class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 5.0 + config.load_defaults 6.0 # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] diff --git a/config/environments/development.rb b/config/environments/development.rb index 66df51f6f..748f5db8d 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -29,13 +29,18 @@ end # Store uploaded files on the local file system (see config/storage.yml for options). - config.active_storage.service = :local + # 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 + config.action_mailer.delivery_method = :letter_opener + config.action_mailer.default_url_options = { + host: (ENV["MAIL_LINK_HOST"] || "localhost:3000") + } + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log diff --git a/config/environments/production.rb b/config/environments/production.rb index b7f268269..6c75e2c7d 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -20,13 +20,13 @@ # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. - config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? + config.public_file_server.enabled = true # Compress CSS using a preprocessor. # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. - config.assets.compile = false + config.assets.compile = true # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = 'http://assets.example.com' @@ -36,7 +36,7 @@ # 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 + # config.active_storage.service = :local # Mount Action Cable outside main process or domain. # config.action_cable.mount_path = nil @@ -44,7 +44,7 @@ # 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 + config.force_ssl = true # Use the lowest log level to ensure availability of diagnostic information # when problems arise. @@ -54,7 +54,7 @@ config.log_tags = [ :request_id ] # Use a different cache store in production. - # config.cache_store = :mem_cache_store + config.cache_store = :dalli_store # Use a real queuing backend for Active Job (and separate queues per environment). # config.active_job.queue_adapter = :resque @@ -66,6 +66,22 @@ # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false + config.action_mailer.delivery_method = :smtp + config.action_mailer.default_url_options = { + host: ENV["MAIL_LINK_HOST"], + protocol: (ENV["MAIL_LINK_PROTO"] || "https") + } + + smtp_env = Hash[ENV.map do |k,v| + if /^SMTP_(.*)$/ === k + [$1.downcase.to_sym, YAML.load(v)] + end + end.compact] + + if smtp_env.present? + config.action_mailer.smtp_settings = smtp_env + end + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true diff --git a/config/environments/staging.rb b/config/environments/staging.rb index 1ba241c29..cb080f68a 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -1,98 +1,2 @@ -Rails.application.configure do - # Settings specified here will take precedence over those in config/application.rb. - - # Code is not reloaded between requests. - config.cache_classes = true - - # Eager load code on boot. This eager loads most of Rails and - # your application in memory, allowing both threaded web servers - # and those relying on copy on write to perform better. - # Rake tasks automatically ignore this option for performance. - config.eager_load = true - - # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false - config.action_controller.perform_caching = true - - # Enable Rack::Cache to put a simple HTTP cache in front of your application - # Add `rack-cache` to your Gemfile before enabling this. - # For large-scale production use, consider using a caching reverse proxy like - # NGINX, varnish or squid. - # config.action_dispatch.rack_cache = true - - # Disable serving static files from the `/public` folder by default since - # Apache or NGINX already handles this. - config.serve_static_files = true - - # Compress JavaScripts and CSS. - config.assets.js_compressor = :uglifier - # config.assets.css_compressor = :sass - - # Do not fallback to assets pipeline if a precompiled asset is missed. - config.assets.compile = true # 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 - - # 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 - - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - config.force_ssl = true - - # Use the lowest log level to ensure availability of diagnostic information - # when problems arise. - config.log_level = :debug - - # Prepend all log lines with the following tags. - # config.log_tags = [ :subdomain, :uuid ] - - # Use a different logger for distributed setups. - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) - - # Use a different cache store in production. - # config.cache_store = :mem_cache_store - config.cache_store = :dalli_store - - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = 'http://assets.example.com' - - # 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. - config.action_mailer.raise_delivery_errors = true - - config.action_mailer.delivery_method = :smtp - config.action_mailer.default_url_options = { - host: ENV["MAIL_LINK_HOST"], - protocol: (ENV["MAIL_LINK_PROTO"] || "https") - } - - # Retrieve SMTP configuration from environment variables - # starting with `SMTP_` - smtp_env = Hash[ENV.map do |k,v| - if /^SMTP_(.*)$/ === k - [$1.downcase.to_sym, YAML.load(v)] - end - end.compact] - - if smtp_env.present? - config.action_mailer.smtp_settings = smtp_env - end - - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation cannot be found). - config.i18n.fallbacks = true - - # Send deprecation notices to registered listeners. - config.active_support.deprecation = :notify - - # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new - - # Do not dump schema after migrations. - config.active_record.dump_schema_after_migration = false -end +# Use same settings we use for production +require_relative "production" diff --git a/config/environments/test.rb b/config/environments/test.rb index 470dee4be..e531ea5da 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -31,7 +31,7 @@ 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.active_storage.service = :test config.action_mailer.perform_caching = false @@ -45,4 +45,7 @@ # Raises error for missing translations. # config.action_view.raise_on_missing_translations = true + + # ActiveJob configuration + config.active_job.queue_adapter = :test end diff --git a/db/schema.rb b/db/schema.rb index bfcd9e381..a114760b4 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -51,7 +51,7 @@ create_table "categories", force: :cascade do |t| t.datetime "created_at" t.datetime "updated_at" - t.hstore "name_translations" + t.jsonb "name_translations" end create_table "device_tokens", force: :cascade do |t| diff --git a/db/seeds.rb b/db/seeds.rb index 65dd95171..818dbdfff 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,20 +1,5 @@ -# encoding: utf-8 - -# This file should contain all the record creation needed to seed the database -# with its default values. -# The data can then be loaded with the rake db:seed (or created alongside the -# db with db:setup). -# -# Examples: -# -# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) -# Mayor.create(name: 'Emanuel', city: cities.first) - -Organization.find_or_create_by(name: "Banco de Tiempo Local") do |org| -end - -Organization.find_or_create_by(name: "El otro Banco de Tiempo :)") do |org| -end +Organization.find_or_create_by(name: "Banco de Tiempo Local") +Organization.find_or_create_by(name: "El otro Banco de Tiempo :)") User.find_or_create_by(email: "admin@timeoverflow.org") do |user| user.terms_accepted_at = DateTime.now.utc @@ -214,7 +199,7 @@ Note that --- not considering the asterisk --- the actual text content starts at 4-columns in. - http://www.google.com + http://www.google.com EOF post.category_id = 5 post.user_id = 1 diff --git a/lib/assets/.gitkeep b/lib/assets/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/assets/.keep b/lib/assets/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/tasks/.gitkeep b/lib/tasks/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/spec/admin/organizations_controller_spec.rb b/spec/admin/organizations_controller_spec.rb index c30dad8a5..2cd3b2bf8 100644 --- a/spec/admin/organizations_controller_spec.rb +++ b/spec/admin/organizations_controller_spec.rb @@ -15,7 +15,7 @@ session[:current_organization_id] = organization.id expect { - delete :destroy, id: organization.id + delete :destroy, params: { id: organization.id } }.to change { controller.current_user }.to(nil) .and change { session[:current_organization_id] }.to(nil) end diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 58f34db3a..377b3103b 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -16,7 +16,7 @@ new_locale = (I18n.available_locales - [original_locale]).sample expect do - get :switch_lang, locale: new_locale + get :switch_lang, params: { locale: new_locale } end.to change(I18n, :locale).from(original_locale).to(new_locale) expect(response).to redirect_to(root_path) diff --git a/spec/controllers/device_tokens_controller_spec.rb b/spec/controllers/device_tokens_controller_spec.rb index 5f2afde64..19a42cf78 100644 --- a/spec/controllers/device_tokens_controller_spec.rb +++ b/spec/controllers/device_tokens_controller_spec.rb @@ -18,7 +18,7 @@ login(member.user) expect do - post :create, token: 'xxx' + post :create, params: { token: 'xxx' } end.to change(DeviceToken, :count).by(1) end end diff --git a/spec/controllers/inquiries_controller_spec.rb b/spec/controllers/inquiries_controller_spec.rb index 694be650f..1fc226b21 100644 --- a/spec/controllers/inquiries_controller_spec.rb +++ b/spec/controllers/inquiries_controller_spec.rb @@ -31,7 +31,7 @@ it "assigns the requested inquiry to @inquiry" do login(another_member.user) - get "show", id: inquiry.id + get "show", params: { id: inquiry.id } expect(assigns(:inquiry)).to eq(inquiry) end end @@ -45,9 +45,9 @@ login(another_member.user) expect do - post "create", inquiry: { user: another_member.user, + post "create", params: { inquiry: { user: another_member.user, category_id: test_category.id, - title: "New title" } + title: "New title" }} end.to change(Inquiry, :count).by(1) end end @@ -60,20 +60,21 @@ it "located the requested @inquiry" do login(member.user) - put "update", id: inquiry.id, inquiry: Fabricate.to_params(:inquiry) + put "update", params: { id: inquiry.id, inquiry: Fabricate.to_params(:inquiry) } expect(assigns(:inquiry)).to eq(inquiry) end it "changes @inquiry's attributes" do login(member.user) - put "update", - id: inquiry.id, - inquiry: Fabricate.to_params(:inquiry, - user: member, - title: "New title", - description: "New description", - tag_list: ["foo"]) + put "update", params: { + id: inquiry.id, + inquiry: Fabricate.to_params(:inquiry, + user: member, + title: "New title", + description: "New description", + tag_list: ["foo"]) + } inquiry.reload expect(inquiry.title).to eq("New title") @@ -88,12 +89,13 @@ it "does not change @inquiry's attributes" do login(member.user) - put :update, - id: inquiry.id, - inquiry: Fabricate.to_params(:inquiry, - user: nil, - title: "New title", - description: "New description") + put :update, params: { + id: inquiry.id, + inquiry: Fabricate.to_params(:inquiry, + user: nil, + title: "New title", + description: "New description") + } expect(inquiry.title).not_to eq("New title") expect(inquiry.description).not_to eq("New description") @@ -106,7 +108,7 @@ it "toggle active field" do login(member.user) - delete :destroy, id: inquiry.id + delete :destroy, params: { id: inquiry.id } inquiry.reload expect(inquiry.active).to be false @@ -115,7 +117,7 @@ it "redirects to inquiries#index" do login(member.user) - delete :destroy, id: inquiry.id + delete :destroy, params: { id: inquiry.id } expect(response).to redirect_to inquiries_url end end diff --git a/spec/controllers/multi_transfers_controller_spec.rb b/spec/controllers/multi_transfers_controller_spec.rb index bab67003e..e92ab6093 100644 --- a/spec/controllers/multi_transfers_controller_spec.rb +++ b/spec/controllers/multi_transfers_controller_spec.rb @@ -22,31 +22,31 @@ expect do login(admin.user) - get :step, step: 1 + get :step, params: { step: 1 } params = {} - post :step, params.merge!( + post :step, params: params.merge!( step: 2, type_of_transfer: :one_to_many ) - post :step, params.merge!( + post :step, params: params.merge!( step: 3, from: [member.account].map(&:id) ) - post :step, params.merge!( + post :step, params: params.merge!( step: 4, to: [another_member.account, yet_another_member.account].map(&:id) ) - post :step, params.merge!( + post :step, params: params.merge!( step: 5, transfer: {amount: 3600, reason: 'because of reasons'} ) - post :create, params + post :create, params: params end.to change { Transfer.count }.by(2) end @@ -54,31 +54,31 @@ expect do login(admin.user) - get :step, step: 1 + get :step, params: { step: 1 } params = {} - post :step, params.merge!( + post :step, params: params.merge!( step: 2, type_of_transfer: :many_to_one ) - post :step, params.merge!( + post :step, params: params.merge!( step: 3, to: [another_member.account, yet_another_member.account].map(&:id) ) - post :step, params.merge!( + post :step, params: params.merge!( step: 4, from: [member.account].map(&:id) ) - post :step, params.merge!( + post :step, params: params.merge!( step: 5, transfer: {amount: 3600, reason: 'because of reasons'} ) - post :create, params + post :create, params: params end.to change { Transfer.count }.by(2) end @@ -87,31 +87,31 @@ expect do login(admin.user) - get :step, step: 1 + get :step, params: { step: 1 } params = {} - post :step, params.merge!( + post :step, params: params.merge!( step: 2, type_of_transfer: :many_to_one ) - post :step, params.merge!( + post :step, params: params.merge!( step: 3, to: [member.account].map(&:id) ) - post :step, params.merge!( + post :step, params: params.merge!( step: 4, from: [another_member.account].map(&:id) ) - post :step, params.merge!( + post :step, params: params.merge!( step: 5, transfer: {amount: 3600, reason: 'because of reasons'} ) - post :create, params + post :create, params: params end.to change { Transfer.count }.by(1) end end @@ -120,7 +120,7 @@ it 'cannot access step route' do login(member.user) - get :step, step: 1 + get :step, params: { step: 1 } expect(response).not_to have_http_status(:success) end @@ -128,7 +128,7 @@ it 'cannot access create route' do login(member.user) - post :create, {} + post :create response.should redirect_to('/') end diff --git a/spec/controllers/offers_controller_spec.rb b/spec/controllers/offers_controller_spec.rb index 4f1db8ecf..fcdd8b57f 100644 --- a/spec/controllers/offers_controller_spec.rb +++ b/spec/controllers/offers_controller_spec.rb @@ -48,7 +48,7 @@ it "populates an array of offers" do login(another_member.user) - get "index", q: offer.title.split(/\s/).first + get "index", params: { q: offer.title.split(/\s/).first } # @offers is a wrapper from Elasticsearch. It's iterator-equivalent to # the underlying query from the database. @@ -71,7 +71,7 @@ end it 'renders the 404 page' do - get :show, id: offer.id + get :show, params: { id: offer.id } expect(response.status).to eq(404) end end @@ -84,29 +84,29 @@ end it 'renders the 404 page' do - get :show, id: offer.id + get :show, params: { id: offer.id } expect(response.status).to eq(404) end end context 'and the user that created the offer is active' do it 'renders a successful response' do - get :show, id: offer.id + get :show, params: { id: offer.id } expect(response.status).to eq(200) end it 'assigns the requested offer to @offer' do - get :show, id: offer.id + get :show, params: { id: offer.id } expect(assigns(:offer)).to eq(offer) end it 'assigns the account destination of the transfer' do - get :show, id: offer.id + get :show, params: { id: offer.id } expect(assigns(:destination_account)).to eq(member.account) end it 'displays the offer\'s user details' do - get :show, id: offer.id + get :show, params: { id: offer.id } expect(response.body).to include(offer.user.email) end end @@ -123,12 +123,12 @@ end it 'displays the offer\'s user details' do - get :show, id: offer.id + get :show, params: { id: offer.id } expect(response.body).to include(offer.user.email) end it 'sets the offer\'s organization as user\'s current organization' do - get :show, id: offer.id + get :show, params: { id: offer.id } expect(session[:current_organization_id]).to eq(offer.organization_id) expect(assigns(:current_organization)).to eq(offer.organization) end @@ -142,19 +142,19 @@ before { login(another_user) } it 'doesn\'t display the offer\'s user details' do - get :show, id: offer.id + get :show, params: { id: offer.id } expect(response.body).to_not include(offer.user.email) end end context 'when the user is not logged in' do it 'assigns the requested offer to @offer' do - get :show, id: offer.id + get :show, params: { id: offer.id } expect(assigns(:offer)).to eq(offer) end it 'doesn\'t display the offer\'s user details' do - get :show, id: offer.id + get :show, params: { id: offer.id } expect(response.body).to_not include(offer.user.email) end end @@ -167,9 +167,9 @@ login(another_member.user) expect do - post "create", offer: { user: another_member.user, + post "create", params: { offer: { user: another_member.user, category_id: test_category, - title: "New title" } + title: "New title" } } end.to change(Offer, :count).by(1) end end @@ -182,20 +182,18 @@ it "located the requested @offer" do login(member.user) - put "update", id: offer.id, offer: Fabricate.to_params(:offer) + put "update", params: { id: offer.id, offer: Fabricate.to_params(:offer) } expect(assigns(:offer)).to eq(offer) end it "changes @offer's attributes" do login(member.user) - put "update", - id: offer.id, - offer: Fabricate.to_params(:offer, + put "update", params: { id: offer.id, offer: Fabricate.to_params(:offer, user: member, title: "New title", description: "New description", - tag_list: ["foo"]) + tag_list: ["foo"]) } offer.reload expect(offer.title).to eq("New title") @@ -210,12 +208,10 @@ it "does not change @offer's attributes" do login(member.user) - put :update, - id: offer.id, - offer: Fabricate.to_params(:offer, + put :update, params: { id: offer.id, offer: Fabricate.to_params(:offer, user: nil, title: "New title", - description: "New description") + description: "New description") } expect(offer.title).not_to eq("New title") expect(offer.description).not_to eq("New description") @@ -228,7 +224,7 @@ it "toggle active field" do login(member.user) - delete :destroy, id: offer.id + delete :destroy, params: { id: offer.id } offer.reload expect(offer.active).to be false @@ -237,7 +233,7 @@ it "redirects to offers#index" do login(member.user) - delete :destroy, id: offer.id + delete :destroy, params: { id: offer.id } expect(response).to redirect_to offers_url end end diff --git a/spec/controllers/organizations_controller_spec.rb b/spec/controllers/organizations_controller_spec.rb index 8bf15c25b..eb6f3027a 100644 --- a/spec/controllers/organizations_controller_spec.rb +++ b/spec/controllers/organizations_controller_spec.rb @@ -7,7 +7,7 @@ describe 'GET #show' do it 'displays the organization page' do - get 'show', id: organization.id + get 'show', params: { id: organization.id } expect(assigns(:organization)).to eq(organization) expect(response.status).to eq(200) @@ -28,7 +28,7 @@ login(member.user) expect { - post :create, organization: { name: 'New cool organization' } + post :create, params: { organization: { name: 'New cool organization' } } }.not_to change { Organization.count } end end @@ -40,7 +40,7 @@ it 'allows to update organization' do login(member.user) - post :update, id: organization.id, organization: { name: 'New org name' } + post :update, params: { id: organization.id, organization: { name: 'New org name' } } organization.reload expect(organization.name).to eq('New org name') @@ -49,7 +49,7 @@ context 'without a logged user' do it 'does not allow to update organization' do - post :update, id: organization.id, organization: { name: 'New org name' } + post :update, params: { id: organization.id, organization: { name: 'New org name' } } expect(response).to redirect_to(root_path) expect(flash[:error]).to eq('You are not authorized to perform this action.') @@ -61,7 +61,7 @@ before { login(user) } it 'stores the given organization as current organization in session' do - post 'set_current', id: organization.id + post 'set_current', params: { id: organization.id } expect(session[:current_organization_id]).to eq(organization.id) end diff --git a/spec/controllers/pages_controller_spec.rb b/spec/controllers/pages_controller_spec.rb index dfbc512b8..3e8e484bf 100644 --- a/spec/controllers/pages_controller_spec.rb +++ b/spec/controllers/pages_controller_spec.rb @@ -3,13 +3,13 @@ RSpec.describe PagesController do describe '#show' do it 'renders the page successfully' do - get :show, page: :about + get :show, params: { page: :about } expect(response).to render_template(:about) end it 'returns a 404 if the page does not exist' do - get :show, page: :foo + get :show, params: { page: :foo } expect(response.status).to eq(404) end diff --git a/spec/controllers/reports_controller_spec.rb b/spec/controllers/reports_controller_spec.rb index ec0636bbc..b3079b877 100644 --- a/spec/controllers/reports_controller_spec.rb +++ b/spec/controllers/reports_controller_spec.rb @@ -30,7 +30,7 @@ it 'do NOT show the inactive members' do login(member1.user) - get 'post_list', type: 'offer' + get 'post_list', params: { type: 'offer' } posts = assigns(:posts)[0][1] expect(posts.size).to eq(active_organization_offers.size) expect(posts.map(&:id)).to match_array(active_organization_offers.map(&:id)) diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index d81029b6d..dcbd34376 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -11,10 +11,10 @@ end it 'does not show a notice flash message' do - post :create, user: { + post :create, params: { user: { email: user.email, password: user.password - } + } } expect(flash[:notice]).to be_nil end end @@ -22,10 +22,10 @@ describe '#destroy' do before do request.env["devise.mapping"] = Devise.mappings[:user] - post :create, user: { + post :create, params: { user: { email: user.email, password: user.password - } + } } end it 'does not show a notice flash message' do diff --git a/spec/controllers/tags_controller_spec.rb b/spec/controllers/tags_controller_spec.rb index a2192222a..e3ecc3ffe 100644 --- a/spec/controllers/tags_controller_spec.rb +++ b/spec/controllers/tags_controller_spec.rb @@ -26,7 +26,7 @@ end it "with search term, returns filtered tags" do - get 'index', term: "foo" + get 'index', params: { term: "foo" } expect(assigns(:all_tags)).to eq(["foo"]) end end diff --git a/spec/controllers/transfers_controller_spec.rb b/spec/controllers/transfers_controller_spec.rb index 96b4bd05f..ea69f46f3 100644 --- a/spec/controllers/transfers_controller_spec.rb +++ b/spec/controllers/transfers_controller_spec.rb @@ -27,18 +27,18 @@ end it 'finds the accountable' do - get :new, params + get :new, params: params expect(response.body) .to include("#{member_giver.display_name_with_uid}") end it 'finds the destination account' do - get :new, params + get :new, params: params expect(response.body).to include("") end it 'builds a transfer with the id of the destination' do - get :new, params + get :new, params: params expect(response.body) .to include("") end @@ -47,19 +47,19 @@ let(:offer) { Fabricate(:offer, organization: user.organizations.first) } it 'finds the transfer offer' do - get :new, params.merge(offer: offer.id) + get :new, params: params.merge(offer: offer.id) expect(response.body).to include("

#{offer}

") end it 'builds a transfer with the offer as post' do - get :new, params.merge(offer: offer.id) + get :new, params: params.merge(offer: offer.id) expect(response.body).to include("") end end context 'when the offer is not specified' do it 'does not find any offer' do - get :new, params + get :new, params: params expect(response.body).to include('