diff --git a/.gitignore b/.gitignore index 00ec87fc7..f175a47d5 100644 --- a/.gitignore +++ b/.gitignore @@ -15,38 +15,27 @@ /log/*.log /tmp +# Ignore .vagrant folder with images +.vagrant +.metadata + +# CTAGS generated files +.tags +tags + +# Misc *.rbc *.sassc +**.orig .sass-cache capybara-*.html -.rspec -/.bundle /vendor/bundle -/log/* -/tmp/* -/db/*.sqlite3 -/public/system/* /coverage/ /spec/tmp/* -**.orig -rerun.txt -pickle-email-*.html timeoverflow_development timeoverflow_test - +.byebug_history .env .DS_Store .idea/ -sgemset - -# Ignore .vagrant folder with images -.vagrant -.metadata - -# CTAGS generated files -.tags -tags - .localeapp - -.byebug_history diff --git a/.rspec b/.rspec new file mode 100644 index 000000000..c99d2e739 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--require spec_helper diff --git a/.rubocop.yml b/.rubocop.yml index d36a46731..b05f0c547 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,3 +1,5 @@ +require: rubocop-rails + AllCops: Exclude: - db/schema.rb @@ -5,6 +7,9 @@ AllCops: Naming/AccessorMethodName: Enabled: false +Rails/HttpPositionalArguments: + Enabled: true + Style/Alias: Enabled: false diff --git a/.travis.yml b/.travis.yml index 3a6dec338..d1259e700 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,10 +11,9 @@ env: global: - DATABASE_URL=postgres://postgres@localhost/timeoverflow_test - CC_TEST_REPORTER_ID=025bc15a0fa9afa52d86ee24fea845cf1d363f48a466bcf2cef8ab80c29acb28 -before_install: - - gem install bundler:1.17.3 before_script: - - bundle exec rake db:setup + - psql -c 'create database timeoverflow_test;' -U postgres + - psql -U postgres -q -d timeoverflow_test -f db/structure.sql - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter - chmod +x ./cc-test-reporter - ./cc-test-reporter before-build diff --git a/Gemfile b/Gemfile index 364d371f5..9b35c35a8 100644 --- a/Gemfile +++ b/Gemfile @@ -2,61 +2,61 @@ 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 'pundit', '~> 2.0.0' -gem 'pg', '0.21.0' -gem 'hstore_translate' +gem 'rails', '~> 6.0.2' +gem 'rails-i18n', '~> 6.0.0' +gem 'rdiscount', '~> 2.2.0.1' +gem 'activeadmin', '~> 2.9.0' +gem 'has_scope', '~> 0.7.2' +gem 'pundit', '~> 2.1.0' +gem 'pg', '~> 1.2.1' +gem 'json_translate', '~> 4.0.0' gem 'devise', '~> 4.7.1' gem "http_accept_language", '~> 2.1.1' -gem 'unicorn' -gem 'kaminari', '~> 1.1.1' -gem "simple_form", ">= 3.0.0" -gem 'rollbar', '2.8.3' -gem 'pg_search', '2.1.4' +gem 'unicorn', '~> 5.5.1' +gem 'kaminari', '~> 1.2.1' +gem 'simple_form', '~> 5.0.2' +gem 'rollbar', '~> 2.22.1' gem 'prawn', '~> 2.2.0' gem 'prawn-table', '~> 0.2.2' -gem 'skylight' -gem 'sidekiq', '5.1.3' +gem 'pg_search', '~> 2.3.5' +gem 'skylight', '~> 4.1.2' +gem 'sidekiq', '~> 6.0.0' gem 'sidekiq-cron', '~> 1.1.0' # Assets -gem 'jquery-rails', '>= 4.2.0' -gem 'bootstrap-sass' -gem 'sass-rails', '~> 5.0.7' -gem 'coffee-rails' -gem 'uglifier', '2.7.2' -gem 'select2-rails' +gem 'jquery-rails', '~> 4.3.5' +gem 'bootstrap-sass', '~> 3.4' +gem 'sassc-rails', '~> 2.1.2' +gem 'uglifier', '~> 4.2.0' +gem 'select2-rails', '~> 4.0.13' group :development do - gem "binding_of_caller", '~> 0.8.0' - gem "better_errors", '~> 2.4.0' - gem 'rubocop', '~> 0.80.0', require: false - gem 'web-console', '2.1.3' + gem 'listen', '~> 3.2.0' + gem 'rubocop', '~> 1.6', require: false + gem 'rubocop-rails', '~> 2.9', 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 group :development, :test do - gem "byebug", '~> 11.0' + gem 'byebug', '~> 11.0' end group :test do - gem "rspec-rails", '~> 3.9' - gem "database_cleaner", '1.6.2' - gem 'shoulda-matchers', '~> 3.1.2' + gem 'rspec-rails', '~> 4.0.0' + gem 'rails-controller-testing' + gem 'database_cleaner', '~> 1.8.5' + gem 'shoulda-matchers', '~> 4.4.0' gem 'fabrication', '~> 2.20' gem 'faker', '~> 1.9' - gem 'capybara', '~> 3.15' + gem 'capybara', '~> 3.29' gem 'selenium-webdriver', '~> 3.142' - gem 'webdrivers', '~> 4.2.0' + gem 'webdrivers', '~> 4.4.0' gem 'simplecov', '~> 0.17', require: false end diff --git a/Gemfile.lock b/Gemfile.lock index d39bf051f..13ea54e60 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,88 +1,101 @@ 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.3.4) + actionpack (= 6.0.3.4) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (6.0.3.4) + actionpack (= 6.0.3.4) + activejob (= 6.0.3.4) + activerecord (= 6.0.3.4) + activestorage (= 6.0.3.4) + activesupport (= 6.0.3.4) + mail (>= 2.7.1) + actionmailer (6.0.3.4) + actionpack (= 6.0.3.4) + actionview (= 6.0.3.4) + activejob (= 6.0.3.4) mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.11.1) - actionview (= 4.2.11.1) - activesupport (= 4.2.11.1) - rack (~> 1.6) - rack-test (~> 0.6.2) - rails-dom-testing (~> 1.0, >= 1.0.5) - rails-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.3.4) + actionview (= 6.0.3.4) + activesupport (= 6.0.3.4) + rack (~> 2.0, >= 2.0.8) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.0.3.4) + actionpack (= 6.0.3.4) + activerecord (= 6.0.3.4) + activestorage (= 6.0.3.4) + activesupport (= 6.0.3.4) + nokogiri (>= 1.8.5) + actionview (6.0.3.4) + activesupport (= 6.0.3.4) 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 - formtastic (~> 3.1) - formtastic_i18n + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activeadmin (2.9.0) + arbre (~> 1.2, >= 1.2.1) + formtastic (>= 3.1, < 5.0) + 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.2.1) + railties (>= 5.2, < 6.2) + ransack (~> 2.1, >= 2.1.1) + activejob (6.0.3.4) + activesupport (= 6.0.3.4) + globalid (>= 0.3.6) + activemodel (6.0.3.4) + activesupport (= 6.0.3.4) + activerecord (6.0.3.4) + activemodel (= 6.0.3.4) + activesupport (= 6.0.3.4) + activestorage (6.0.3.4) + actionpack (= 6.0.3.4) + activejob (= 6.0.3.4) + activerecord (= 6.0.3.4) + marcel (~> 0.3.1) + activesupport (6.0.3.4) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 0.7, < 2) minitest (~> 5.1) - thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) + zeitwerk (~> 2.2, >= 2.2.2) addressable (2.7.0) public_suffix (>= 2.0.2, < 5.0) - airbrussh (0.8.0) + airbrussh (1.4.0) sshkit (>= 1.6.1, != 1.7.0) - arbre (1.1.1) - activesupport (>= 3.0.0) - arel (6.0.4) - ast (2.4.0) - autoprefixer-rails (9.7.4) + arbre (1.4.0) + activesupport (>= 3.0.0, < 6.2) + ruby2_keywords (>= 0.0.2, < 1.0) + ast (2.4.1) + autoprefixer-rails (10.1.0.0) execjs - bcrypt (3.1.13) - 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) + bcrypt (3.1.16) + bindex (0.8.1) bootstrap-sass (3.4.1) autoprefixer-rails (>= 5.2.1) sassc (>= 2.0.0) builder (3.2.4) - byebug (11.0.0) - capistrano (3.4.1) + byebug (11.1.3) + capistrano (3.14.1) + airbrussh (>= 1.0.0) i18n rake (>= 10.0.0) - sshkit (~> 1.3) - capistrano-bundler (1.1.4) + sshkit (>= 1.9.0) + capistrano-bundler (2.0.1) capistrano (~> 3.1) - sshkit (~> 1.2) - capistrano-rails (1.1.5) + capistrano-rails (1.6.1) capistrano (~> 3.1) - capistrano-bundler (~> 1.1) - capistrano-rbenv (2.1.3) + capistrano-bundler (>= 1.1, < 3) + capistrano-rbenv (2.2.0) capistrano (~> 3.1) sshkit (~> 1.3) - capybara (3.31.0) + capybara (3.34.0) addressable mini_mime (>= 0.1.3) nokogiri (~> 1.8) @@ -91,348 +104,357 @@ GEM regexp_parser (~> 1.5) xpath (~> 3.2) childprocess (3.0.0) - 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) - concurrent-ruby (1.1.6) - connection_pool (2.2.1) + concurrent-ruby (1.1.7) + connection_pool (2.2.3) crass (1.0.6) - database_cleaner (1.6.2) - debug_inspector (0.0.3) - devise (4.7.1) + database_cleaner (1.8.5) + devise (4.7.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) - diff-lcs (1.3) + diff-lcs (1.4.4) docile (1.3.2) - domain_name (0.5.20170223) + domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) - dotenv (2.7.1) - dotenv-rails (2.7.1) - dotenv (= 2.7.1) - railties (>= 3.2, < 6.1) - erubi (1.9.0) - erubis (2.7.0) - et-orbi (1.1.7) + dotenv (2.7.6) + dotenv-rails (2.7.6) + dotenv (= 2.7.6) + railties (>= 3.2) + erubi (1.10.0) + et-orbi (1.2.4) tzinfo execjs (2.7.0) - fabrication (2.20.1) + fabrication (2.21.1) faker (1.9.6) i18n (>= 0.7) - ffi (1.12.2) + ffi (1.13.1) formtastic (3.1.5) actionpack (>= 3.2.13) formtastic_i18n (0.6.0) - fugit (1.1.8) - et-orbi (~> 1.1, >= 1.1.7) - raabro (~> 1.1) - gli (2.16.0) + fugit (1.4.1) + et-orbi (~> 1.1, >= 1.1.8) + raabro (~> 1.4) + gli (2.19.2) globalid (0.4.2) activesupport (>= 4.2.0) - has_scope (0.6.0) - actionpack (>= 3.2, < 5) - activesupport (>= 3.2, < 5) - hstore_translate (1.0.0) - activerecord (>= 3.1.0) + has_scope (0.7.2) + actionpack (>= 4.1) + activesupport (>= 4.1) + http-accept (1.7.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.12.0) + actionpack (>= 5.2, < 6.2) has_scope (~> 0.6) - railties (>= 4.2, <= 5.2) - responders - jaro_winkler (1.5.4) - jquery-rails (4.3.1) + railties (>= 5.2, < 6.2) + responders (>= 2, < 4) + jquery-rails (4.3.5) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - json (2.3.0) - kaminari (1.1.1) + json (2.4.0) + json_translate (4.0.0) + activerecord (>= 4.2.0) + kaminari (1.2.1) activesupport (>= 4.1.0) - kaminari-actionview (= 1.1.1) - kaminari-activerecord (= 1.1.1) - kaminari-core (= 1.1.1) - kaminari-actionview (1.1.1) + kaminari-actionview (= 1.2.1) + kaminari-activerecord (= 1.2.1) + kaminari-core (= 1.2.1) + kaminari-actionview (1.2.1) actionview - kaminari-core (= 1.1.1) - kaminari-activerecord (1.1.1) + kaminari-core (= 1.2.1) + kaminari-activerecord (1.2.1) activerecord - kaminari-core (= 1.1.1) - kaminari-core (1.1.1) - kgio (2.10.0) - launchy (2.4.3) - addressable (~> 2.3) - letter_opener (1.4.1) + kaminari-core (= 1.2.1) + kaminari-core (1.2.1) + kgio (2.11.3) + launchy (2.5.0) + addressable (~> 2.7) + letter_opener (1.7.0) launchy (~> 2.2) + listen (3.2.1) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) localeapp (2.1.1) gli i18n (~> 0.4) json rest-client - loofah (2.4.0) + loofah (2.8.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) - mime-types (3.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mime-types (3.3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2016.0521) + mime-types-data (3.2020.1104) + mimemagic (0.3.5) mini_mime (1.0.2) - mini_portile2 (2.4.0) - minitest (5.14.0) - multi_json (1.11.2) - net-scp (2.0.0) - net-ssh (>= 2.6.5, < 6.0.0) - net-ssh (5.2.0) + mini_portile2 (2.5.0) + minitest (5.14.2) + net-scp (3.0.0) + net-ssh (>= 2.6.5, < 7.0.0) + net-ssh (6.1.0) netrc (0.11.0) - nokogiri (1.10.8) - mini_portile2 (~> 2.4.0) + nio4r (2.5.4) + nokogiri (1.11.0) + mini_portile2 (~> 2.5.0) + racc (~> 1.4) orm_adapter (0.5.0) - parallel (1.19.1) - parser (2.7.0.2) - ast (~> 2.4.0) + parallel (1.20.1) + parser (2.7.2.0) + ast (~> 2.4.1) pdf-core (0.7.0) - pg (0.21.0) - pg_search (2.1.4) - activerecord (>= 4.2) - activesupport (>= 4.2) + pg (1.2.3) + pg_search (2.3.5) + activerecord (>= 5.2) + activesupport (>= 5.2) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) prawn-table (0.2.2) prawn (>= 1.3.0, < 3.0.0) - public_suffix (4.0.3) - pundit (2.0.0) + public_suffix (4.0.6) + pundit (2.1.0) activesupport (>= 3.0.0) - raabro (1.1.6) - rack (1.6.13) - rack-protection (2.0.1) + raabro (1.4.0) + racc (1.5.2) + rack (2.2.3) + rack-protection (2.1.0) 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) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (6.0.3.4) + actioncable (= 6.0.3.4) + actionmailbox (= 6.0.3.4) + actionmailer (= 6.0.3.4) + actionpack (= 6.0.3.4) + actiontext (= 6.0.3.4) + actionview (= 6.0.3.4) + activejob (= 6.0.3.4) + activemodel (= 6.0.3.4) + activerecord (= 6.0.3.4) + activestorage (= 6.0.3.4) + activesupport (= 6.0.3.4) + bundler (>= 1.3.0) + railties (= 6.0.3.4) + sprockets-rails (>= 2.0.0) + rails-controller-testing (1.0.5) + actionpack (>= 5.0.1.rc1) + actionview (>= 5.0.1.rc1) + activesupport (>= 5.0.1.rc1) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) rails-html-sanitizer (1.3.0) loofah (~> 2.3) - 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.3.4) + actionpack (= 6.0.3.4) + activesupport (= 6.0.3.4) + 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) + raindrops (0.19.1) rake (13.0.1) - ransack (1.8.10) - actionpack (>= 3.0, < 5.2) - activerecord (>= 3.0, < 5.2) - activesupport (>= 3.0, < 5.2) + ransack (2.4.0) + activerecord (>= 5.2.4) + activesupport (>= 5.2.4) i18n - rb-fsevent (0.10.3) + rb-fsevent (0.10.4) rb-inotify (0.10.1) ffi (~> 1.0) - rdiscount (2.1.7.1) - redis (4.0.1) - regexp_parser (1.6.0) - responders (2.4.1) - actionpack (>= 4.2.0, < 6.0) - railties (>= 4.2.0, < 6.0) - rest-client (2.0.1) + rdiscount (2.2.0.2) + redis (4.2.5) + regexp_parser (1.8.2) + responders (3.0.1) + actionpack (>= 5.0) + railties (>= 5.0) + rest-client (2.1.0) + http-accept (>= 1.7.0, < 2.0) http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) rexml (3.2.4) - rollbar (2.8.3) - multi_json - rspec-core (3.9.1) - rspec-support (~> 3.9.1) - rspec-expectations (3.9.1) + rollbar (2.22.1) + rspec-core (3.10.0) + rspec-support (~> 3.10.0) + rspec-expectations (3.10.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-mocks (3.9.1) + rspec-support (~> 3.10.0) + rspec-mocks (3.10.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-rails (3.9.1) - actionpack (>= 3.0) - activesupport (>= 3.0) - railties (>= 3.0) - rspec-core (~> 3.9.0) - rspec-expectations (~> 3.9.0) - rspec-mocks (~> 3.9.0) - rspec-support (~> 3.9.0) - rspec-support (3.9.2) - rubocop (0.80.0) - jaro_winkler (~> 1.5.1) + rspec-support (~> 3.10.0) + rspec-rails (4.0.1) + actionpack (>= 4.2) + activesupport (>= 4.2) + railties (>= 4.2) + rspec-core (~> 3.9) + rspec-expectations (~> 3.9) + rspec-mocks (~> 3.9) + rspec-support (~> 3.9) + rspec-support (3.10.0) + rubocop (1.6.1) parallel (~> 1.10) - parser (>= 2.7.0.1) + parser (>= 2.7.1.5) rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) rexml + rubocop-ast (>= 1.2.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 1.7) + unicode-display_width (>= 1.4.0, < 2.0) + rubocop-ast (1.3.0) + parser (>= 2.7.1.5) + rubocop-rails (2.9.0) + activesupport (>= 4.2.0) + rack (>= 1.1) + rubocop (>= 0.90.0, < 2.0) ruby-progressbar (1.10.1) - rubyzip (2.2.0) - sass (3.7.4) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (5.0.7) - railties (>= 4.0.0, < 6) - sass (~> 3.1) - sprockets (>= 2.8, < 4.0) - sprockets-rails (>= 2.0, < 4.0) - tilt (>= 1.1, < 3) - sassc (2.2.1) + ruby2_keywords (0.0.2) + rubyzip (2.3.0) + sassc (2.4.0) ffi (~> 1.9) - select2-rails (4.0.1) - thor (~> 0.14) + sassc-rails (2.1.2) + railties (>= 4.0.0) + sassc (>= 2.0) + sprockets (> 3.0) + sprockets-rails + tilt + select2-rails (4.0.13) selenium-webdriver (3.142.7) childprocess (>= 0.5, < 4.0) rubyzip (>= 1.2.2) - shoulda-matchers (3.1.3) - activesupport (>= 4.0.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) + shoulda-matchers (4.4.1) + activesupport (>= 4.2.0) + sidekiq (6.0.7) + connection_pool (>= 2.2.2) + rack (~> 2.0) + rack-protection (>= 2.0.0) + redis (>= 4.1.0) sidekiq-cron (1.1.0) fugit (~> 1.1) sidekiq (>= 4.2.1) - simple_form (3.1.0) - actionpack (~> 4.0) - activemodel (~> 4.0) - simplecov (0.17.0) + simple_form (5.0.3) + actionpack (>= 5.0) + activemodel (>= 5.0) + simplecov (0.20.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) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.2) + skylight (4.1.2) + skylight-core (= 4.1.2) + skylight-core (4.1.2) activesupport (>= 4.2.0) - sprockets (3.7.2) + sprockets (4.0.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.1) + sprockets-rails (3.2.2) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sshkit (1.20.0) + sshkit (1.21.1) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) - thor (0.20.3) + thor (1.0.1) thread_safe (0.3.6) - tilt (2.0.8) - ttfunk (1.5.1) - tzinfo (1.2.6) + tilt (2.0.10) + ttfunk (1.6.2.1) + tzinfo (1.2.8) thread_safe (~> 0.1) - uglifier (2.7.2) - execjs (>= 0.3.0) - json (>= 1.8.0) + uglifier (4.2.0) + execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext - unf_ext (0.0.7.2) - unicode-display_width (1.6.1) - unicorn (5.0.1) + unf_ext (0.0.7.7) + unicode-display_width (1.7.0) + unicorn (5.5.5) 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) - webdrivers (4.2.0) + warden (1.2.9) + rack (>= 2.0.9) + web-console (4.0.4) + actionview (>= 6.0.0) + activemodel (>= 6.0.0) + bindex (>= 0.4.0) + railties (>= 6.0.0) + webdrivers (4.4.1) nokogiri (~> 1.6) rubyzip (>= 1.3.0) selenium-webdriver (>= 3.0, < 4.0) + websocket-driver (0.7.3) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) + zeitwerk (2.4.2) PLATFORMS ruby DEPENDENCIES - activeadmin (~> 1.2.1) + activeadmin (~> 2.9.0) airbrussh - better_errors (~> 2.4.0) - binding_of_caller (~> 0.8.0) - bootstrap-sass + bootstrap-sass (~> 3.4) byebug (~> 11.0) capistrano (~> 3.1) capistrano-rails (~> 1.1) capistrano-rbenv (~> 2.1) - capybara (~> 3.15) - coffee-rails - database_cleaner (= 1.6.2) + capybara (~> 3.29) + database_cleaner (~> 1.8.5) devise (~> 4.7.1) dotenv-rails (~> 2.7.1) fabrication (~> 2.20) faker (~> 1.9) - has_scope - hstore_translate + has_scope (~> 0.7.2) http_accept_language (~> 2.1.1) - jquery-rails (>= 4.2.0) - kaminari (~> 1.1.1) - letter_opener (= 1.4.1) + jquery-rails (~> 4.3.5) + json_translate (~> 4.0.0) + kaminari (~> 1.2.1) + letter_opener (~> 1.7.0) + listen (~> 3.2.0) localeapp (= 2.1.1) - pg (= 0.21.0) - pg_search (= 2.1.4) + pg (~> 1.2.1) + pg_search (~> 2.3.5) 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.9) - rubocop (~> 0.80.0) - sass-rails (~> 5.0.7) - select2-rails + pundit (~> 2.1.0) + rails (~> 6.0.2) + rails-controller-testing + rails-i18n (~> 6.0.0) + rdiscount (~> 2.2.0.1) + rollbar (~> 2.22.1) + rspec-rails (~> 4.0.0) + rubocop (~> 1.6) + rubocop-rails (~> 2.9) + sassc-rails (~> 2.1.2) + select2-rails (~> 4.0.13) selenium-webdriver (~> 3.142) - shoulda-matchers (~> 3.1.2) - sidekiq (= 5.1.3) + shoulda-matchers (~> 4.4.0) + sidekiq (~> 6.0.0) sidekiq-cron (~> 1.1.0) - simple_form (>= 3.0.0) + simple_form (~> 5.0.2) simplecov (~> 0.17) - skylight - uglifier (= 2.7.2) - unicorn - web-console (= 2.1.3) - webdrivers (~> 4.2.0) + skylight (~> 4.1.2) + uglifier (~> 4.2.0) + unicorn (~> 5.5.1) + web-console (~> 4.0.1) + webdrivers (~> 4.4.0) RUBY VERSION ruby 2.6.3p62 BUNDLED WITH - 1.17.3 + 2.1.4 diff --git a/app/admin/user.rb b/app/admin/user.rb index 203743025..728c90e03 100644 --- a/app/admin/user.rb +++ b/app/admin/user.rb @@ -1,5 +1,3 @@ -# coding: utf-8 - ActiveAdmin.register User do action_item :upload_csv, only: :index do link_to I18n.t("active_admin.users.upload_from_csv"), action: "upload_csv" diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 000000000..7d52bcf35 --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../stylesheets .css +//= link_directory ../javascripts .js 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..e276396e6 --- /dev/null +++ b/app/assets/javascripts/application.js @@ -0,0 +1,25 @@ +//= require_tree ./application + +$(document).on('click', 'a[data-popup]', function(event) { + event.preventDefault(); + + window.open($(this).attr('href'), 'popup', 'width=600,height=600'); +}); + +$(document).on('click', 'span.show-password', function(event) { + event.preventDefault(); + + var inputType = 'text'; + var icon = 'visibility_off'; + + if ($(this).hasClass('checked')) { + $(this).removeClass('checked'); + inputType = 'password'; + icon = 'visibility'; + } else { + $(this).addClass('checked'); + } + + $(this).prev('input').attr('type', inputType); + $(this).find('.material-icons').html(icon); +}); 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/give_time.js b/app/assets/javascripts/application/give_time.js similarity index 100% rename from app/assets/javascripts/give_time.js rename to app/assets/javascripts/application/give_time.js diff --git a/app/assets/javascripts/mobile_app_libs.js b/app/assets/javascripts/application/mobile_app_libs.js similarity index 100% rename from app/assets/javascripts/mobile_app_libs.js rename to app/assets/javascripts/application/mobile_app_libs.js diff --git a/app/assets/javascripts/multi_select2.js b/app/assets/javascripts/application/multi_select2.js similarity index 100% rename from app/assets/javascripts/multi_select2.js rename to app/assets/javascripts/application/multi_select2.js diff --git a/app/assets/javascripts/application/tags.js b/app/assets/javascripts/application/tags.js new file mode 100644 index 000000000..3fc98952f --- /dev/null +++ b/app/assets/javascripts/application/tags.js @@ -0,0 +1,44 @@ +$(function() { + $(".switch_offer-js").on("click", function() { + loadTags('/tags/offers'); + }); + + $(".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, + tokenSeparators: [','], + dataType: 'json', + delay: 250, + ajax: { + url: '/tags.json', + data: function(params) { + return { term: params.term }; + }, + processResults: function(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/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.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/assets/stylesheets/active_admin.css.scss b/app/assets/stylesheets/active_admin.scss similarity index 100% rename from app/assets/stylesheets/active_admin.css.scss rename to app/assets/stylesheets/active_admin.scss diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.scss similarity index 98% rename from app/assets/stylesheets/application.css.scss rename to app/assets/stylesheets/application.scss index 30da15afe..c8bd7ba29 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.scss @@ -1,9 +1,13 @@ -@import "variables"; +/* +*= require select2 +*/ + +@import "application/variables"; @import "bootstrap-sprockets"; -@import "bootstrap-custom"; -@import "to-categories-dropdown"; -@import "to-member-card"; -@import "footer"; +@import "application/bootstrap-custom"; +@import "application/to-categories-dropdown"; +@import "application/to-member-card"; +@import "application/footer"; html { font-size: 62.5%; diff --git a/app/assets/stylesheets/_bootstrap-custom.scss b/app/assets/stylesheets/application/bootstrap-custom.scss similarity index 100% rename from app/assets/stylesheets/_bootstrap-custom.scss rename to app/assets/stylesheets/application/bootstrap-custom.scss diff --git a/app/assets/stylesheets/_bootstrap-overrides.scss b/app/assets/stylesheets/application/bootstrap-overrides.scss similarity index 100% rename from app/assets/stylesheets/_bootstrap-overrides.scss rename to app/assets/stylesheets/application/bootstrap-overrides.scss diff --git a/app/assets/stylesheets/_footer.scss b/app/assets/stylesheets/application/footer.scss similarity index 100% rename from app/assets/stylesheets/_footer.scss rename to app/assets/stylesheets/application/footer.scss diff --git a/app/assets/stylesheets/_to-categories-dropdown.scss b/app/assets/stylesheets/application/to-categories-dropdown.scss similarity index 100% rename from app/assets/stylesheets/_to-categories-dropdown.scss rename to app/assets/stylesheets/application/to-categories-dropdown.scss diff --git a/app/assets/stylesheets/_to-member-card.scss b/app/assets/stylesheets/application/to-member-card.scss similarity index 100% rename from app/assets/stylesheets/_to-member-card.scss rename to app/assets/stylesheets/application/to-member-card.scss diff --git a/app/assets/stylesheets/_variables.scss b/app/assets/stylesheets/application/variables.scss similarity index 100% rename from app/assets/stylesheets/_variables.scss rename to app/assets/stylesheets/application/variables.scss diff --git a/app/assets/stylesheets/libs.scss b/app/assets/stylesheets/libs.scss deleted file mode 100644 index 46c001a3f..000000000 --- a/app/assets/stylesheets/libs.scss +++ /dev/null @@ -1,3 +0,0 @@ -/* -*= require select2 -*/ diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a86f2f506..615602cad 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 @@ -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 681105c30..105b76d60 100644 --- a/app/controllers/device_tokens_controller.rb +++ b/app/controllers/device_tokens_controller.rb @@ -1,13 +1,13 @@ 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 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 d8dff153d..c29e3e668 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -1,28 +1,31 @@ class MembersController < ApplicationController - before_filter :authenticate_user! + before_action :authenticate_user! 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 def toggle_active find_member @member.toggle(:active).save! + 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/multi_transfers_controller.rb b/app/controllers/multi_transfers_controller.rb index 55544145c..91f45a0b9 100644 --- a/app/controllers/multi_transfers_controller.rb +++ b/app/controllers/multi_transfers_controller.rb @@ -23,7 +23,7 @@ def create operation = Operations::Transfers.create( from: params[:from], to: params[:to], - transfer_params: params[:transfer].to_hash + transfer_params: params[:transfer].to_unsafe_h ) operation.perform end 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/posts_controller.rb b/app/controllers/posts_controller.rb index 55fe2d32e..e72630be4 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -92,7 +92,7 @@ def set_user_id(p) if current_user.manages?(current_organization) p.reverse_merge! user_id: current_user.id else - p.update user_id: current_user.id + p.merge! user_id: current_user.id end end diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index ab47ce4aa..ec87224e5 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" @@ -11,11 +11,11 @@ def user_list respond_to do |format| format.html format.csv do - report = Report::CSV::Member.new(current_organization, @members) + report = Report::Csv::Member.new(current_organization, @members) send_data report.run, filename: report.name, type: report.mime_type end format.pdf do - report = Report::PDF::Member.new(current_organization, @members) + report = Report::Pdf::Member.new(current_organization, @members) send_data report.run, filename: report.name, type: report.mime_type end end @@ -35,11 +35,11 @@ def post_list respond_to do |format| format.html format.csv do - report = Report::CSV::Post.new(current_organization, @posts, @post_type) + report = Report::Csv::Post.new(current_organization, @posts, @post_type) send_data report.run, filename: report.name, type: report.mime_type end format.pdf do - report = Report::PDF::Post.new(current_organization, @posts, @post_type) + report = Report::Pdf::Post.new(current_organization, @posts, @post_type) send_data report.run, filename: report.name, type: report.mime_type end end diff --git a/app/controllers/statistics_controller.rb b/app/controllers/statistics_controller.rb index 458af84b9..ded39a636 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 @@ -103,7 +103,7 @@ def statistics_all_transfers @transfers = current_organization.all_transfers. includes(movements: {account: :accountable}). order("transfers.created_at DESC"). - uniq. + distinct. page(params[:page]). per(20) end 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/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 398a80292..acbea1bf0 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,10 +58,10 @@ 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" } + orders = result.order_values.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..b066ba845 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -6,9 +6,9 @@ # The Account may also be flagged, if needed, when the balance overflows # some set limits # -class Account < ActiveRecord::Base - belongs_to :accountable, polymorphic: true - belongs_to :organization, inverse_of: :all_accounts +class Account < ApplicationRecord + belongs_to :accountable, polymorphic: true, optional: true + belongs_to :organization, inverse_of: :all_accounts, optional: true has_many :movements before_create :add_organization 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 47739daa0..ddafdc5f7 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..9c974a558 100644 --- a/app/models/movement.rb +++ b/app/models/movement.rb @@ -3,11 +3,11 @@ # 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 - belongs_to :transfer + belongs_to :account, optional: true + belongs_to :transfer, optional: true has_one :other_side, (->(self_) { where ["NOT movements.id = #{self_.id}"] }), through: :transfer, 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 54711fef9..199755bf3 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -1,6 +1,6 @@ -class Post < ActiveRecord::Base +class Post < ApplicationRecord include Taggable - include PgSearch + include PgSearch::Model pg_search_scope :search_by_query, against: [:title, :description, :tags], @@ -16,7 +16,7 @@ class Post < ActiveRecord::Base 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 @@ -44,8 +44,6 @@ class Post < ActiveRecord::Base 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 as_indexed_json(*) 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 11e194e7d..fae6223c2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -1,4 +1,4 @@ -class User < ActiveRecord::Base +class User < ApplicationRecord devise *[ :database_authenticatable, :recoverable, diff --git a/app/services/report/csv.rb b/app/services/report/csv.rb index c6483c63d..768d87b59 100644 --- a/app/services/report/csv.rb +++ b/app/services/report/csv.rb @@ -1,8 +1,8 @@ require "csv" module Report - module CSV - MIME_TYPE = Mime::CSV + module Csv + MIME_TYPE = Mime[:csv] def self.run(headers, rows) ::CSV.generate do |csv| diff --git a/app/services/report/csv/member.rb b/app/services/report/csv/member.rb index 5f6ea7f32..d0a0d3a6c 100644 --- a/app/services/report/csv/member.rb +++ b/app/services/report/csv/member.rb @@ -1,5 +1,5 @@ module Report - module CSV + module Csv class Member def initialize(org, collection) @collection = collection @@ -11,11 +11,11 @@ def name end def mime_type - Report::CSV::MIME_TYPE + Report::Csv::MIME_TYPE end def run - Report::CSV.run(@decorator.headers, @decorator.rows) + Report::Csv.run(@decorator.headers, @decorator.rows) end end end diff --git a/app/services/report/csv/post.rb b/app/services/report/csv/post.rb index ca2b9a567..35ff79659 100644 --- a/app/services/report/csv/post.rb +++ b/app/services/report/csv/post.rb @@ -1,5 +1,5 @@ module Report - module CSV + module Csv class Post def initialize(org, collection, type) @collection = collection @@ -12,11 +12,11 @@ def name end def mime_type - Report::CSV::MIME_TYPE + Report::Csv::MIME_TYPE end def run - Report::CSV.run(@decorator.headers, @decorator.rows) + Report::Csv.run(@decorator.headers, @decorator.rows) end end end diff --git a/app/services/report/pdf.rb b/app/services/report/pdf.rb index 4e148b548..d4335d8a6 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 + module Pdf + MIME_TYPE = Mime[:pdf] def self.run(headers, rows) pdf = Prawn::Document.new(options) diff --git a/app/services/report/pdf/member.rb b/app/services/report/pdf/member.rb index b6c425d8a..be3f858e0 100644 --- a/app/services/report/pdf/member.rb +++ b/app/services/report/pdf/member.rb @@ -1,5 +1,5 @@ module Report - module PDF + module Pdf class Member def initialize(org, collection) @collection = collection @@ -11,11 +11,11 @@ def name end def mime_type - Report::PDF::MIME_TYPE + Report::Pdf::MIME_TYPE end def run - Report::PDF.run(@decorator.headers, @decorator.rows) + Report::Pdf.run(@decorator.headers, @decorator.rows) end end end diff --git a/app/services/report/pdf/post.rb b/app/services/report/pdf/post.rb index 2b40d9f18..c04211d27 100644 --- a/app/services/report/pdf/post.rb +++ b/app/services/report/pdf/post.rb @@ -1,5 +1,5 @@ module Report - module PDF + module Pdf class Post def initialize(org, collection, type) @collection = collection @@ -12,11 +12,11 @@ def name end def mime_type - Report::PDF::MIME_TYPE + Report::Pdf::MIME_TYPE end def run - Report::PDF.run(@decorator.headers, @decorator.rows) + Report::Pdf.run(@decorator.headers, @decorator.rows) end end end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 08ae6962d..dfbac3987 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -7,7 +7,6 @@ <%= page_title %> <%= csrf_meta_tags %> - <%= stylesheet_link_tag 'libs', media: 'all' %> <%= stylesheet_link_tag 'application', media: 'all' %> <%= stylesheet_link_tag 'https://fonts.googleapis.com/css?family=Work+Sans:400,500,600,700' %> <%= stylesheet_link_tag 'https://fonts.googleapis.com/icon?family=Material+Icons' %> diff --git a/app/views/layouts/report.html.erb b/app/views/layouts/report.html.erb index 1f0bd80ae..e5bee0ae3 100644 --- a/app/views/layouts/report.html.erb +++ b/app/views/layouts/report.html.erb @@ -7,7 +7,6 @@ <%= t('.report_title') %> - <%= stylesheet_link_tag 'libs', media: 'all' %> <%= stylesheet_link_tag 'application', media: 'all' %> @@ -15,8 +14,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..f1b194644 100755 --- a/bin/setup +++ b/bin/setup @@ -1,29 +1,28 @@ #!/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 - puts "== Installing dependencies ==" - system "gem install bundler --conservative" - system "bundle check || bundle install" +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 "\n== Copying sample files ==" - # unless File.exist?("config/database.yml") - # system "cp config/database.yml.sample config/database.yml" - # end + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') 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/bin/unicorn b/bin/unicorn deleted file mode 100755 index aa2ce9b6d..000000000 --- a/bin/unicorn +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'unicorn' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require "pathname" -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require "rubygems" -require "bundler/setup" - -load Gem.bin_path("unicorn", "unicorn") diff --git a/bin/unicorn_rails b/bin/unicorn_rails deleted file mode 100755 index 140d56f3c..000000000 --- a/bin/unicorn_rails +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env ruby -# -# This file was generated by Bundler. -# -# The application 'unicorn_rails' is installed as part of a gem, and -# this file is here to facilitate running it. -# - -require "pathname" -ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", - Pathname.new(__FILE__).realpath) - -require "rubygems" -require "bundler/setup" - -load Gem.bin_path("unicorn", "unicorn_rails") diff --git a/config/application.rb b/config/application.rb index 4edfc6c1d..916e96b79 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 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] @@ -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 @@ -39,5 +31,9 @@ class Application < Rails::Application # Use db/structure.sql with SQL as schema format # This is needed to store in the schema SQL statements not covered by the ORM config.active_record.schema_format = :sql + + # Guard against DNS rebinding attacks by permitting hosts + config.hosts << /timeoverflow\.(local|org)/ + config.hosts << "staging.timeoverflow.org" end end 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/deploy.rb b/config/deploy.rb index ba4e81a33..d8c3cb40f 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,5 +1,5 @@ # config valid only for current version of Capistrano -lock '3.4.1' +lock '3.14.1' set :application, 'timeoverflow' set :repo_url, 'git@github.com:coopdevs/timeoverflow.git' 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..1d80b1c7b 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -9,12 +9,34 @@ # 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.perform_caching = false + + config.action_mailer.delivery_method = :letter_opener config.action_mailer.default_url_options = { host: (ENV["MAIL_LINK_HOST"] || "localhost:3000") } @@ -25,25 +47,25 @@ # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load - # Debug mode disables concatenation and preprocessing of assets. - # This option may cause significant delays in view rendering with a large - # number of complex assets. - config.assets.debug = true + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = 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 - config.assets.quiet = 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 - # Adds additional error checking when serving assets at runtime. - # Checks for improperly declared sprockets dependencies. - # Raises helpful error messages. - config.assets.raise_runtime_errors = true + # Suppress logger output for asset requests. + config.assets.quiet = true - # Raises error for missing translations + # 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 a08c2828b..f9b93e8fa 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -14,33 +14,40 @@ 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 = true - # Compress JavaScripts and CSS. - config.assets.js_compressor = :uglifier - # config.assets.css_compressor = :sass + # Compress CSS & JS using preprocessors. + config.assets.js_compressor = Uglifier.new(harmony: true) + 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 = 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 - # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.action_controller.asset_host = 'http://assets.example.com' # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX + # Store uploaded files on the local file system (see config/storage.yml for options). + # config.active_storage.service = :local + + # Mount Action Cable outside main process or domain. + # config.action_cable.mount_path = nil + # config.action_cable.url = 'wss://example.com/cable' + # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. config.force_ssl = true @@ -49,20 +56,20 @@ config.log_level = :debug # Prepend all log lines with the following tags. - # config.log_tags = [ :subdomain, :uuid ] - - # Use a different logger for distributed setups. - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) + config.log_tags = [ :request_id ] # Use a different cache store in production. # config.cache_store = :mem_cache_store - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = 'http://assets.example.com' + # Use a real queuing backend for Active Job (and separate queues per environment). + # config.active_job.queue_adapter = :resque + # config.active_job.queue_name_prefix = "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.raise_delivery_errors = false config.action_mailer.delivery_method = :smtp config.action_mailer.default_url_options = { @@ -90,6 +97,16 @@ # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new + # Use a different logger for distributed setups. + # require 'syslog/logger' + # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') + + if ENV["RAILS_LOG_TO_STDOUT"].present? + logger = ActiveSupport::Logger.new(STDOUT) + logger.formatter = config.log_formatter + config.logger = ActiveSupport::TaggedLogging.new(logger) + end + # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false end diff --git a/config/environments/staging.rb b/config/environments/staging.rb index 1020fbbbf..cb080f68a 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -1,97 +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 - - # 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 5dfdff1c1..515e0aecc 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,26 @@ # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false + # Store uploaded files on the local file system in a temporary directory. + # config.active_storage.service = :test + config.action_mailer.default_url_options = { host: "localhost:3000" } + 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 + + # Allow local ip for Acceptance tests + config.hosts << "127.0.0.1" end diff --git a/config/initializers/active_admin.rb b/config/initializers/active_admin.rb index 5763b151f..83b8198f6 100644 --- a/config/initializers/active_admin.rb +++ b/config/initializers/active_admin.rb @@ -1,9 +1,4 @@ -# encoding: utf-8 - -# coding: utf-8 - ActiveAdmin.setup do |config| - # == Site Title # # Set the title that is displayed on the main layout @@ -144,8 +139,8 @@ # Active Admin resources and pages from here. # # config.before_filter :do_something_awesome - - + + # == Setting a Favicon # # config.favicon = '/assets/favicon.ico' @@ -248,6 +243,4 @@ # You can enable or disable them for all resources here. # # config.filters = true - - end diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 109e3bc42..ee1f11b3a 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -3,11 +3,5 @@ # 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. -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/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/db/structure.sql b/db/structure.sql index 5a2b8d516..fcb2d6336 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -12,7 +12,6 @@ SET standard_conforming_strings = on; SELECT pg_catalog.set_config('search_path', '', false); SET check_function_bodies = false; SET client_min_messages = warning; -SET row_security = off; -- -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: - 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/lib/tasks/deploy.rake b/lib/tasks/deploy.rake deleted file mode 100644 index 72aa0bfea..000000000 --- a/lib/tasks/deploy.rake +++ /dev/null @@ -1,27 +0,0 @@ -require 'net/http' -require 'rubygems' -require 'json' - -namespace :rollbar do - - desc 'Send the deployment notification to Rollbar.' - task :deploy do - uri = URI.parse 'https://api.rollbar.com/api/1/deploy/' - params = { - :local_username => ENV['DEPLOY_AUTHOR'], - :access_token => Rails.application.secrets.rollbar_access_token, - :environment => ENV['RAILS_ENV'], - :revision => ENV['DEPLOYED_REVISION'] } - - puts "Building Rollbar POST to #{uri} with #{params.inspect}" - - request = Net::HTTP::Post.new(uri.request_uri) - request.body = JSON.dump(params) - - Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http| - http.request(request) - end - - puts 'Rollbar notification complete.' - end -end diff --git a/spec/admin/organizations_controller_spec.rb b/spec/admin/organizations_controller_spec.rb index c30dad8a5..cf0f77f2e 100644 --- a/spec/admin/organizations_controller_spec.rb +++ b/spec/admin/organizations_controller_spec.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - RSpec.describe Admin::OrganizationsController, type: :controller do let(:organization) { Fabricate(:organization) } let(:member) { Fabricate(:member, organization: organization) } @@ -15,9 +13,9 @@ 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 end -end \ No newline at end of file +end diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index 58f34db3a..ade414f43 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - RSpec.describe ApplicationController do describe '#switch_lang' do let(:original_locale) { I18n.locale } @@ -16,7 +14,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..f97c6d62a 100644 --- a/spec/controllers/device_tokens_controller_spec.rb +++ b/spec/controllers/device_tokens_controller_spec.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - RSpec.describe DeviceTokensController do let (:organization) { Fabricate(:organization) } let (:member) { Fabricate(:member, organization: organization) } @@ -18,7 +16,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 f7bc2141e..0a78b1982 100644 --- a/spec/controllers/inquiries_controller_spec.rb +++ b/spec/controllers/inquiries_controller_spec.rb @@ -1,11 +1,9 @@ -require "spec_helper" - RSpec.describe InquiriesController do - let(:test_organization) { Fabricate(:organization) } - let(:member) { Fabricate(:member, organization: test_organization) } - let(:another_member) { Fabricate(:member, organization: test_organization) } - let(:test_category) { Fabricate(:category) } - let!(:inquiry) do + let (:test_organization) { Fabricate(:organization) } + let (:member) { Fabricate(:member, organization: test_organization) } + let (:another_member) { Fabricate(:member, organization: test_organization) } + let (:test_category) { Fabricate(:category) } + let! (:inquiry) do Fabricate(:inquiry, user: member.user, organization: test_organization, @@ -29,7 +27,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 @@ -41,10 +39,11 @@ context "with a logged user" do it "creates a new inquiry" do 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 @@ -54,21 +53,24 @@ describe "PUT #update" do context "with valid params" do context "with a logged user" do - before { login(member.user) } - it "located the requested @inquiry" do - put "update", id: inquiry.id, inquiry: Fabricate.to_params(:inquiry) + login(member.user) + + put "update", params: { id: inquiry.id, inquiry: Fabricate.to_params(:inquiry) } expect(assigns(:inquiry)).to eq(inquiry) end it "changes @inquiry's attributes" do - put "update", - id: inquiry.id, - inquiry: Fabricate.to_params(:inquiry, - user: member, - title: "New title", - description: "New description", - tag_list: ["foo"]) + login(member.user) + + 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") @@ -83,12 +85,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") @@ -98,17 +101,19 @@ end describe "DELETE destroy" do - before { login(member.user) } - it "toggle active field" do - delete :destroy, id: inquiry.id + login(member.user) + + delete :destroy, params: { id: inquiry.id } inquiry.reload expect(inquiry.active).to be false end it "redirects to inquiries#index" do - delete :destroy, id: inquiry.id + login(member.user) + + 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 1caa040c7..85378d33e 100644 --- a/spec/controllers/multi_transfers_controller_spec.rb +++ b/spec/controllers/multi_transfers_controller_spec.rb @@ -1,5 +1,3 @@ -require "spec_helper" - RSpec.describe MultiTransfersController, type: :controller do let(:organization) { Fabricate(:organization) } let(:admin) { Fabricate(:member, organization: organization, manager: true) } @@ -18,31 +16,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 @@ -50,31 +48,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 @@ -83,31 +81,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 @@ -116,7 +114,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 @@ -124,7 +122,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 d72c27610..e9b0184c3 100644 --- a/spec/controllers/offers_controller_spec.rb +++ b/spec/controllers/offers_controller_spec.rb @@ -1,5 +1,3 @@ -require "spec_helper" - RSpec.describe OffersController, type: :controller do let(:organization) { Fabricate(:organization) } let(:member) { Fabricate(:member, organization: organization) } @@ -78,13 +76,13 @@ end it "populates an array of offers" do - get :index, q: 'compañeros' + get :index, params: { q: 'compañeros' } expect(assigns(:offers)).to eq([offer]) end it "allows to search by partial word" do - get :index, q: 'compañ' + get :index, params: { q: 'compañ' } expect(assigns(:offers)).to eq([offer]) end @@ -132,7 +130,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 @@ -145,24 +143,24 @@ 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 end @@ -179,7 +177,7 @@ 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 @@ -195,10 +193,10 @@ 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 - + end end @@ -209,9 +207,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 @@ -224,20 +222,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") @@ -252,12 +248,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") @@ -270,7 +264,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 @@ -279,7 +273,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 fc4144bf6..1adb6f57b 100644 --- a/spec/controllers/organizations_controller_spec.rb +++ b/spec/controllers/organizations_controller_spec.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - RSpec.describe OrganizationsController do let!(:organization) { Fabricate(:organization) } let(:member) { Fabricate(:member, organization: organization) } @@ -14,8 +12,8 @@ end describe 'GET #show' do - it 'displays the organization page' do - get 'show', id: organization.id + it 'displays the organization page' do + get 'show', params: { id: organization.id } expect(assigns(:organization)).to eq(organization) expect(response.status).to eq(200) @@ -27,7 +25,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 @@ -39,7 +37,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') @@ -48,7 +46,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.') @@ -60,7 +58,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..eba90f4ed 100644 --- a/spec/controllers/pages_controller_spec.rb +++ b/spec/controllers/pages_controller_spec.rb @@ -1,15 +1,13 @@ -require 'spec_helper' - 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..078c0ef12 100644 --- a/spec/controllers/reports_controller_spec.rb +++ b/spec/controllers/reports_controller_spec.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - RSpec.describe ReportsController do let (:test_organization) { Fabricate(:organization) } let (:member1) { Fabricate(:member, organization: test_organization) } @@ -30,7 +28,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..57254daf2 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - RSpec.describe SessionsController do let(:user) do Fabricate(:user, password: 'papapa22', password_confirmation: 'papapa22') @@ -11,10 +9,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 +20,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/statistics_controller_spec.rb b/spec/controllers/statistics_controller_spec.rb new file mode 100644 index 000000000..ac97a5cce --- /dev/null +++ b/spec/controllers/statistics_controller_spec.rb @@ -0,0 +1,17 @@ +RSpec.describe StatisticsController do + let(:organization) { Fabricate(:organization) } + let(:member) { Fabricate(:member, organization: organization) } + + before(:each) { login(member.user) } + + describe '#statistics_all_transfers' do + it 'populates all transfers from current organization' do + transfer = Fabricate(:transfer, source: organization.account, destination: member.account) + transfer2 = Fabricate(:transfer) + + get :statistics_all_transfers + + expect(assigns(:transfers)).to eq([transfer]) + end + end +end diff --git a/spec/controllers/tags_controller_spec.rb b/spec/controllers/tags_controller_spec.rb index a2192222a..18463048e 100644 --- a/spec/controllers/tags_controller_spec.rb +++ b/spec/controllers/tags_controller_spec.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - RSpec.describe TagsController do let (:tags) { %w(foo bar baz) } let (:organization) { Fabricate(:organization) } @@ -16,8 +14,8 @@ it "returns http success" do get 'index' - expect(response).to be_success - expect(response.content_type).to eq("application/json") + expect(response).to have_http_status(:ok) + expect(response.content_type).to match("application/json") end it "with no search term, returns all tags" do @@ -26,7 +24,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 453b861c9..ca81e45f4 100644 --- a/spec/controllers/transfers_controller_spec.rb +++ b/spec/controllers/transfers_controller_spec.rb @@ -1,5 +1,3 @@ -require 'spec_helper' - RSpec.describe TransfersController do let (:test_organization) { Fabricate(:organization) } let (:member_admin) { Fabricate(:member, organization: test_organization, manager: true) } @@ -23,39 +21,39 @@ 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 - expect(response.body).to include("") + 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("") + .to include("") end context 'when the offer is specified' do 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) - expect(response.body).to include("") + 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('