diff --git a/.rubocop.yml b/.rubocop.yml index 7e692d4f3..1a742be2e 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,8 +4,8 @@ require: - rubocop-performance AllCops: - TargetRailsVersion: 6.0 - TargetRubyVersion: 3.0 + TargetRailsVersion: 7.0 + TargetRubyVersion: 3.2 Exclude: - 'bin/**/*' - 'db/schema.rb' diff --git a/Gemfile b/Gemfile index 1e3bb4c36..420a0721d 100644 --- a/Gemfile +++ b/Gemfile @@ -1,47 +1,47 @@ source 'https://rubygems.org' -gem 'bcrypt', '~> 3.1.0' -gem 'bootsnap', '~> 1.12.0' -gem 'browser', '~> 5.3.0' -gem 'devise', '~>4.8.0' -gem 'devise-i18n', '~>1.10.0' -gem 'factory_bot_rails', '~> 6.2.0' -gem 'faker', '~> 3.1.1' -gem 'font-awesome-rails', '~> 4.7.0.0' -gem 'http', '~> 5.0.0' -gem 'jbuilder', '~> 2.11.0' -gem 'jquery-rails', '~> 4.5.0' -gem 'kaminari', '~> 1.2.0' -gem 'mini_racer', '~> 0.6.0' -gem 'mollie-api-ruby', '~> 4.7.0' +gem 'bcrypt', '~> 3.1.20' +gem 'bootsnap', '~> 1.18.4' +gem 'browser', '~> 5.3.1' +gem 'devise', '~>4.9.4' +gem 'devise-i18n', '~>1.12.1' +gem 'factory_bot_rails', '~> 6.4.4' +gem 'faker', '~> 3.5.1' +gem 'font-awesome-rails', '~> 4.7.0.9' +gem 'http', '~> 5.2.0' +gem 'jbuilder', '~> 2.13.0' +gem 'jquery-rails', '~> 4.6.0' +gem 'kaminari', '~> 1.2.2' +gem 'mini_racer', '~> 0.16.0' +gem 'mollie-api-ruby', '~> 4.15.0' gem 'net-imap', require: false gem 'net-pop', require: false gem 'net-smtp', require: false -gem 'omniauth', '~> 2.0.0' -gem 'omniauth-oauth2', '~> 1.7.0' -gem 'omniauth-rails_csrf_protection', '~> 1.0' +gem 'omniauth', '~> 2.1.2' +gem 'omniauth-oauth2', '~> 1.8.0' +gem 'omniauth-rails_csrf_protection', '~> 1.0', '>= 1.0.2' gem 'paper_trail', '~> 16.0.0' gem 'paranoia', '~> 3.0.0' -gem 'pg', '~> 1.3.0' -gem 'puma', '~> 6.4.0' -gem 'pundit', '~> 2.2.0' -gem 'rack-attack', '~> 6.6.0' +gem 'pg', '~> 1.5.9' +gem 'puma', '~> 6.5.0' +gem 'pundit', '~> 2.4.0' +gem 'rack-attack', '~> 6.7.0' gem 'rails', '~> 7.0.4', '>= 7.0.4.3' -gem 'rails-i18n', '~> 7.0.0' -gem 'redis-rails', '~> 5.0.0' +gem 'rails-i18n', '~> 7.0.10' +gem 'redis-rails', '~> 5.0.2' gem 'rest-client', '~> 2.1.0' -gem 'sassc-rails', '~> 2.1.0' -gem 'sentry-rails', '~> 5.5' -gem 'sentry-ruby', '~> 5.5' -gem 'sentry-sidekiq', '~> 5.5' -gem 'sidekiq', '~> 7.1.0' -gem 'sidekiq-scheduler', '~> 5.0.2' -gem 'simple_form', '~> 5.1.0' +gem 'sassc-rails', '~> 2.1.2' +gem 'sentry-rails', '~> 5.22', '>= 5.22.1' +gem 'sentry-ruby', '~> 5.22', '>= 5.22.1' +gem 'sentry-sidekiq', '~> 5.22', '>= 5.22.1' +gem 'sidekiq', '~> 7.3.7' +gem 'sidekiq-scheduler', '~> 5.0.6' +gem 'simple_form', '~> 5.3.1' gem 'slack-notifier', '~> 2.4.0' -gem 'turbolinks', '~> 5.2.0' -gem 'uglifier', '~> 4.2.0' -gem 'validates_timeliness', '~> 7.0.0.beta2' -gem 'webpacker', '~> 5.4.0' +gem 'turbolinks', '~> 5.2.1' +gem 'uglifier', '~> 4.2.1' +gem 'validates_timeliness', '~> 7.1.0' +gem 'webpacker', '~> 5.4.4' gem 'wicked_pdf' gem 'wkhtmltopdf-binary' @@ -49,11 +49,11 @@ group :development, :test do gem 'awesome_print' gem 'better_errors' gem 'brakeman', require: false - gem 'bullet' + gem 'bullet', '~> 8.0' gem 'colorize' gem 'consistency_fail' - gem 'dotenv-rails', '~> 2.7.0' - gem 'guard-livereload', '~> 2.5.0' + gem 'dotenv-rails', '~> 2.8.1' + gem 'guard-livereload', '~> 2.5.2' gem 'guard-rspec', require: false gem 'pry-byebug' gem 'pry-rails' @@ -65,16 +65,16 @@ group :development do gem 'capistrano-sidekiq' gem 'foreman', require: false gem 'listen' - gem 'mina', '~> 1.2.0' + gem 'mina', '~> 1.2.5' gem 'spring', require: false gem 'spring-commands-rspec', require: false gem 'spring-watcher-listen', require: false - gem 'web-console', '~> 4.2.0' + gem 'web-console', '~> 4.2.1' end group :test do - gem 'rails-controller-testing', '~> 1.0.0' - gem 'rubocop', '~> 1.30.0', require: false + gem 'rails-controller-testing', '~> 1.0.5' + gem 'rubocop', '~> 1.50.2', require: false gem 'rubocop-performance' gem 'rubocop-rails' gem 'rubocop-rspec' diff --git a/Gemfile.lock b/Gemfile.lock index 906c9aa56..5a942f7d4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,67 +1,67 @@ GEM remote: https://rubygems.org/ specs: - actioncable (7.0.8.6) - actionpack (= 7.0.8.6) - activesupport (= 7.0.8.6) + actioncable (7.0.8.7) + actionpack (= 7.0.8.7) + activesupport (= 7.0.8.7) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.8.6) - actionpack (= 7.0.8.6) - activejob (= 7.0.8.6) - activerecord (= 7.0.8.6) - activestorage (= 7.0.8.6) - activesupport (= 7.0.8.6) + actionmailbox (7.0.8.7) + actionpack (= 7.0.8.7) + activejob (= 7.0.8.7) + activerecord (= 7.0.8.7) + activestorage (= 7.0.8.7) + activesupport (= 7.0.8.7) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.8.6) - actionpack (= 7.0.8.6) - actionview (= 7.0.8.6) - activejob (= 7.0.8.6) - activesupport (= 7.0.8.6) + actionmailer (7.0.8.7) + actionpack (= 7.0.8.7) + actionview (= 7.0.8.7) + activejob (= 7.0.8.7) + activesupport (= 7.0.8.7) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.8.6) - actionview (= 7.0.8.6) - activesupport (= 7.0.8.6) + actionpack (7.0.8.7) + actionview (= 7.0.8.7) + activesupport (= 7.0.8.7) rack (~> 2.0, >= 2.2.4) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.8.6) - actionpack (= 7.0.8.6) - activerecord (= 7.0.8.6) - activestorage (= 7.0.8.6) - activesupport (= 7.0.8.6) + actiontext (7.0.8.7) + actionpack (= 7.0.8.7) + activerecord (= 7.0.8.7) + activestorage (= 7.0.8.7) + activesupport (= 7.0.8.7) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.8.6) - activesupport (= 7.0.8.6) + actionview (7.0.8.7) + activesupport (= 7.0.8.7) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.8.6) - activesupport (= 7.0.8.6) + activejob (7.0.8.7) + activesupport (= 7.0.8.7) globalid (>= 0.3.6) - activemodel (7.0.8.6) - activesupport (= 7.0.8.6) - activerecord (7.0.8.6) - activemodel (= 7.0.8.6) - activesupport (= 7.0.8.6) - activestorage (7.0.8.6) - actionpack (= 7.0.8.6) - activejob (= 7.0.8.6) - activerecord (= 7.0.8.6) - activesupport (= 7.0.8.6) + activemodel (7.0.8.7) + activesupport (= 7.0.8.7) + activerecord (7.0.8.7) + activemodel (= 7.0.8.7) + activesupport (= 7.0.8.7) + activestorage (7.0.8.7) + actionpack (= 7.0.8.7) + activejob (= 7.0.8.7) + activerecord (= 7.0.8.7) + activesupport (= 7.0.8.7) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.8.6) + activesupport (7.0.8.7) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -72,18 +72,20 @@ GEM sshkit (>= 1.6.1, != 1.7.0) ast (2.4.2) awesome_print (1.9.2) - bcrypt (3.1.18) + base64 (0.2.0) + bcrypt (3.1.20) better_errors (2.9.1) coderay (>= 1.0.0) erubi (>= 1.0.0) rack (>= 0.9.0) + bigdecimal (3.1.9) bindex (0.8.1) - bootsnap (1.12.0) + bootsnap (1.18.4) msgpack (~> 1.2) brakeman (5.2.3) browser (5.3.1) - builder (3.2.4) - bullet (7.0.2) + builder (3.3.0) + bullet (8.0.0) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) byebug (11.1.3) @@ -104,37 +106,37 @@ GEM connection_pool (2.4.1) consistency_fail (0.3.7) crass (1.0.6) - devise (4.8.1) + date (3.4.1) + devise (4.9.4) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) - devise-i18n (1.10.2) - devise (>= 4.8.0) + devise-i18n (1.12.1) + devise (>= 4.9.0) diff-lcs (1.5.0) - digest (3.1.1) docile (1.4.0) domain_name (0.5.20190701) unf (>= 0.0.5, < 1.0.0) - dotenv (2.7.6) - dotenv-rails (2.7.6) - dotenv (= 2.7.6) + dotenv (2.8.1) + dotenv-rails (2.8.1) + dotenv (= 2.8.1) railties (>= 3.2) em-websocket (0.5.3) eventmachine (>= 0.12.9) http_parser.rb (~> 0) - erubi (1.12.0) + erubi (1.13.1) et-orbi (1.2.7) tzinfo eventmachine (1.2.7) execjs (2.8.1) - factory_bot (6.2.1) + factory_bot (6.5.0) activesupport (>= 5.0.0) - factory_bot_rails (6.2.0) - factory_bot (~> 6.2.0) + factory_bot_rails (6.4.4) + factory_bot (~> 6.5) railties (>= 5.0.0) - faker (3.1.1) + faker (3.5.1) i18n (>= 1.8.11, < 2) faraday (2.3.0) faraday-net_http (~> 2.0) @@ -144,15 +146,15 @@ GEM ffi-compiler (1.0.1) ffi (>= 1.0.0) rake - font-awesome-rails (4.7.0.8) - railties (>= 3.2, < 8.0) + font-awesome-rails (4.7.0.9) + railties (>= 3.2, < 9.0) foreman (0.87.2) formatador (1.1.0) fugit (1.8.1) et-orbi (~> 1, >= 1.2.7) raabro (~> 1.4) - globalid (1.1.0) - activesupport (>= 5.0) + globalid (1.2.1) + activesupport (>= 6.1) guard (2.18.0) formatador (>= 0.2.4) listen (>= 2.7, < 4.0) @@ -173,11 +175,12 @@ GEM guard-compat (~> 1.1) rspec (>= 2.99.0, < 4.0) hashie (5.0.0) - http (5.0.4) + http (5.2.0) addressable (~> 2.8) + base64 (~> 0.1) http-cookie (~> 1.0) http-form_data (~> 2.2) - llhttp-ffi (~> 0.4.0) + llhttp-ffi (~> 0.5.0) http-accept (1.7.0) http-cookie (1.0.5) domain_name (~> 0.5) @@ -185,13 +188,14 @@ GEM http_parser.rb (0.8.0) i18n (1.14.6) concurrent-ruby (~> 1.0) - jbuilder (2.11.5) + jbuilder (2.13.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) - jquery-rails (4.5.0) + jquery-rails (4.6.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) + json (2.9.1) jwt (2.4.1) kaminari (1.2.2) activesupport (>= 4.1.0) @@ -205,17 +209,18 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) - libv8-node (16.10.0.0) - libv8-node (16.10.0.0-x86_64-linux) + libv8-node (18.19.0.0) + libv8-node (18.19.0.0-x86_64-linux) listen (3.7.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - llhttp-ffi (0.4.0) + llhttp-ffi (0.5.0) ffi-compiler (~> 1.0) rake (~> 13.0) - loofah (2.20.0) + logger (1.6.4) + loofah (2.24.0) crass (~> 1.0.2) - nokogiri (>= 1.5.9) + nokogiri (>= 1.12.0) lumberjack (1.2.8) mail (2.8.1) mini_mime (>= 0.1.1) @@ -227,38 +232,38 @@ GEM mime-types (3.4.1) mime-types-data (~> 3.2015) mime-types-data (3.2022.0105) - mina (1.2.4) - open4 (~> 1.3.4) + mina (1.2.5) rake mini_mime (1.1.5) mini_portile2 (2.8.8) - mini_racer (0.6.2) - libv8-node (~> 16.10.0.0) - minitest (5.25.2) - mollie-api-ruby (4.7.1) + mini_racer (0.16.0) + libv8-node (~> 18.19.0.0) + minitest (5.25.4) + mollie-api-ruby (4.15.0) + bigdecimal (~> 3.1, >= 3.1.8) + ostruct (~> 0.6.0) msgpack (1.5.2) multi_json (1.15.0) multi_xml (0.6.0) nenv (0.3.0) - net-imap (0.2.4) - digest + net-imap (0.5.5) + date net-protocol - strscan net-pop (0.1.2) net-protocol - net-protocol (0.1.3) + net-protocol (0.2.2) timeout net-scp (3.0.0) net-ssh (>= 2.6.5, < 7.0.0) - net-smtp (0.3.4) + net-smtp (0.5.0) net-protocol net-ssh (6.1.0) netrc (0.11.0) nio4r (2.7.4) - nokogiri (1.14.5) - mini_portile2 (~> 2.8.0) + nokogiri (1.18.1) + mini_portile2 (~> 2.8.2) racc (~> 1.4) - nokogiri (1.14.5-x86_64-linux) + nokogiri (1.18.1-x86_64-linux-gnu) racc (~> 1.4) notiffany (0.1.3) nenv (~> 0.1) @@ -269,27 +274,28 @@ GEM multi_json (~> 1.3) multi_xml (~> 0.5) rack (>= 1.2, < 3) - omniauth (2.0.4) + omniauth (2.1.2) hashie (>= 3.4.6) - rack (>= 1.6.2, < 3) + rack (>= 2.2.3) rack-protection - omniauth-oauth2 (1.7.2) - oauth2 (~> 1.4) - omniauth (>= 1.9, < 3) - omniauth-rails_csrf_protection (1.0.1) + omniauth-oauth2 (1.8.0) + oauth2 (>= 1.4, < 3) + omniauth (~> 2.0) + omniauth-rails_csrf_protection (1.0.2) actionpack (>= 4.2) omniauth (~> 2.0) - open4 (1.3.4) orm_adapter (0.5.0) + ostruct (0.6.1) paper_trail (16.0.0) activerecord (>= 6.1) request_store (~> 1.4) - parallel (1.22.1) + parallel (1.26.3) paranoia (3.0.0) activerecord (>= 6, < 8.1) - parser (3.1.2.0) + parser (3.3.6.0) ast (~> 2.4.1) - pg (1.3.5) + racc + pg (1.5.9) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) @@ -299,56 +305,58 @@ GEM pry-rails (0.3.9) pry (>= 0.10.4) public_suffix (4.0.7) - puma (6.4.3) + puma (6.5.0) nio4r (~> 2.0) - pundit (2.2.0) + pundit (2.4.0) activesupport (>= 3.0.0) raabro (1.4.0) - racc (1.6.2) + racc (1.8.1) rack (2.2.10) - rack-attack (6.6.1) - rack (>= 1.0, < 3) + rack-attack (6.7.0) + rack (>= 1.0, < 4) rack-protection (3.0.2) rack rack-proxy (0.7.2) rack - rack-test (2.1.0) + rack-test (2.2.0) rack (>= 1.3) - rails (7.0.8.6) - actioncable (= 7.0.8.6) - actionmailbox (= 7.0.8.6) - actionmailer (= 7.0.8.6) - actionpack (= 7.0.8.6) - actiontext (= 7.0.8.6) - actionview (= 7.0.8.6) - activejob (= 7.0.8.6) - activemodel (= 7.0.8.6) - activerecord (= 7.0.8.6) - activestorage (= 7.0.8.6) - activesupport (= 7.0.8.6) + rails (7.0.8.7) + actioncable (= 7.0.8.7) + actionmailbox (= 7.0.8.7) + actionmailer (= 7.0.8.7) + actionpack (= 7.0.8.7) + actiontext (= 7.0.8.7) + actionview (= 7.0.8.7) + activejob (= 7.0.8.7) + activemodel (= 7.0.8.7) + activerecord (= 7.0.8.7) + activestorage (= 7.0.8.7) + activesupport (= 7.0.8.7) bundler (>= 1.15.0) - railties (= 7.0.8.6) + railties (= 7.0.8.7) 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) + rails-dom-testing (2.2.0) + activesupport (>= 5.0.0) + minitest nokogiri (>= 1.6) - rails-html-sanitizer (1.5.0) - loofah (~> 2.19, >= 2.19.1) - rails-i18n (7.0.3) + rails-html-sanitizer (1.6.2) + loofah (~> 2.21) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) + rails-i18n (7.0.10) i18n (>= 0.7, < 2) railties (>= 6.0.0, < 8) - railties (7.0.8.6) - actionpack (= 7.0.8.6) - activesupport (= 7.0.8.6) + railties (7.0.8.7) + actionpack (= 7.0.8.7) + activesupport (= 7.0.8.7) method_source rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.5) rainbow (3.1.1) - rake (13.0.6) + rake (13.2.1) rb-fsevent (0.11.1) rb-inotify (0.10.1) ffi (~> 1.0) @@ -372,7 +380,7 @@ GEM redis-store (>= 1.2, < 2) redis-store (1.9.1) redis (>= 4, < 5) - regexp_parser (2.5.0) + regexp_parser (2.10.0) request_store (1.7.0) rack (>= 1.4) responders (3.0.1) @@ -383,7 +391,7 @@ GEM http-cookie (>= 1.0.2, < 2.0) mime-types (>= 1.16, < 4.0) netrc (~> 0.8) - rexml (3.2.5) + rexml (3.4.0) rspec (3.12.0) rspec-core (~> 3.12.0) rspec-expectations (~> 3.12.0) @@ -405,17 +413,18 @@ GEM rspec-mocks (~> 3.12) rspec-support (~> 3.12) rspec-support (3.12.0) - rubocop (1.30.1) + rubocop (1.50.2) + json (~> 2.3) parallel (~> 1.10) - parser (>= 3.1.0.0) + parser (>= 3.2.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.18.0, < 2.0) + rubocop-ast (>= 1.28.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.18.0) - parser (>= 3.1.1.0) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.37.0) + parser (>= 3.3.1.0) rubocop-performance (1.14.2) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) @@ -425,7 +434,7 @@ GEM rubocop (>= 1.7.0, < 2.0) rubocop-rspec (2.11.1) rubocop (~> 1.19) - ruby-progressbar (1.11.0) + ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) rufus-scheduler (3.8.2) fugit (~> 1.1, >= 1.1.6) @@ -438,25 +447,26 @@ GEM sprockets-rails tilt semantic_range (3.0.0) - sentry-rails (5.5.0) + sentry-rails (5.22.1) railties (>= 5.0) - sentry-ruby (~> 5.5.0) - sentry-ruby (5.5.0) + sentry-ruby (~> 5.22.1) + sentry-ruby (5.22.1) + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) - sentry-sidekiq (5.5.0) - sentry-ruby (~> 5.5.0) + sentry-sidekiq (5.22.1) + sentry-ruby (~> 5.22.1) sidekiq (>= 3.0) shellany (0.0.1) - sidekiq (7.1.6) - concurrent-ruby (< 2) + sidekiq (7.3.7) connection_pool (>= 2.3.0) + logger rack (>= 2.2.4) - redis-client (>= 0.14.0) - sidekiq-scheduler (5.0.2) + redis-client (>= 0.22.2) + sidekiq-scheduler (5.0.6) rufus-scheduler (~> 3.2) sidekiq (>= 6, < 8) - tilt (>= 1.4.0) - simple_form (5.1.0) + tilt (>= 1.4.0, < 3) + simple_form (5.3.1) actionpack (>= 5.2) activemodel (>= 5.2) simplecov (0.21.2) @@ -483,47 +493,47 @@ GEM sshkit (1.21.2) net-scp (>= 1.1.2) net-ssh (>= 2.8.0) - strscan (3.0.9) terminal-notifier-guard (1.7.0) - thor (1.2.2) + thor (1.3.2) tilt (2.1.0) timecop (0.9.5) timeliness (0.4.5) - timeout (0.3.2) + timeout (0.4.3) turbolinks (5.2.1) turbolinks-source (~> 5.2) turbolinks-source (5.2.0) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - uglifier (4.2.0) + uglifier (4.2.1) execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext unf_ext (0.0.8.2) - unicode-display_width (2.1.0) + unicode-display_width (2.6.0) uniform_notifier (1.16.0) - validates_timeliness (7.0.0.beta2) + validates_timeliness (7.1.0) activemodel (>= 7.0.0, < 8) timeliness (>= 0.3.10, < 1) warden (1.2.9) rack (>= 2.0.9) - web-console (4.2.0) + web-console (4.2.1) actionview (>= 6.0.0) activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webpacker (5.4.3) + webpacker (5.4.4) activesupport (>= 5.2) rack-proxy (>= 0.6.1) railties (>= 5.2) semantic_range (>= 2.3.0) - websocket-driver (0.7.6) + websocket-driver (0.7.7) + base64 websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) wicked_pdf (2.6.3) activesupport wkhtmltopdf-binary (0.12.6.5) - zeitwerk (2.6.18) + zeitwerk (2.7.1) PLATFORMS ruby @@ -531,64 +541,64 @@ PLATFORMS DEPENDENCIES awesome_print - bcrypt (~> 3.1.0) + bcrypt (~> 3.1.20) better_errors - bootsnap (~> 1.12.0) + bootsnap (~> 1.18.4) brakeman - browser (~> 5.3.0) - bullet + browser (~> 5.3.1) + bullet (~> 8.0) capistrano-sidekiq colorize consistency_fail - devise (~> 4.8.0) - devise-i18n (~> 1.10.0) - dotenv-rails (~> 2.7.0) - factory_bot_rails (~> 6.2.0) - faker (~> 3.1.1) - font-awesome-rails (~> 4.7.0.0) + devise (~> 4.9.4) + devise-i18n (~> 1.12.1) + dotenv-rails (~> 2.8.1) + factory_bot_rails (~> 6.4.4) + faker (~> 3.5.1) + font-awesome-rails (~> 4.7.0.9) foreman - guard-livereload (~> 2.5.0) + guard-livereload (~> 2.5.2) guard-rspec - http (~> 5.0.0) - jbuilder (~> 2.11.0) - jquery-rails (~> 4.5.0) - kaminari (~> 1.2.0) + http (~> 5.2.0) + jbuilder (~> 2.13.0) + jquery-rails (~> 4.6.0) + kaminari (~> 1.2.2) listen - mina (~> 1.2.0) - mini_racer (~> 0.6.0) - mollie-api-ruby (~> 4.7.0) + mina (~> 1.2.5) + mini_racer (~> 0.16.0) + mollie-api-ruby (~> 4.15.0) net-imap net-pop net-smtp - omniauth (~> 2.0.0) - omniauth-oauth2 (~> 1.7.0) - omniauth-rails_csrf_protection (~> 1.0) + omniauth (~> 2.1.2) + omniauth-oauth2 (~> 1.8.0) + omniauth-rails_csrf_protection (~> 1.0, >= 1.0.2) paper_trail (~> 16.0.0) paranoia (~> 3.0.0) - pg (~> 1.3.0) + pg (~> 1.5.9) pry-byebug pry-rails - puma (~> 6.4.0) - pundit (~> 2.2.0) - rack-attack (~> 6.6.0) + puma (~> 6.5.0) + pundit (~> 2.4.0) + rack-attack (~> 6.7.0) rails (~> 7.0.4, >= 7.0.4.3) - rails-controller-testing (~> 1.0.0) - rails-i18n (~> 7.0.0) + rails-controller-testing (~> 1.0.5) + rails-i18n (~> 7.0.10) rb-readline - redis-rails (~> 5.0.0) + redis-rails (~> 5.0.2) rest-client (~> 2.1.0) rspec-rails - rubocop (~> 1.30.0) + rubocop (~> 1.50.2) rubocop-performance rubocop-rails rubocop-rspec - sassc-rails (~> 2.1.0) - sentry-rails (~> 5.5) - sentry-ruby (~> 5.5) - sentry-sidekiq (~> 5.5) - sidekiq (~> 7.1.0) - sidekiq-scheduler (~> 5.0.2) - simple_form (~> 5.1.0) + sassc-rails (~> 2.1.2) + sentry-rails (~> 5.22, >= 5.22.1) + sentry-ruby (~> 5.22, >= 5.22.1) + sentry-sidekiq (~> 5.22, >= 5.22.1) + sidekiq (~> 7.3.7) + sidekiq-scheduler (~> 5.0.6) + simple_form (~> 5.3.1) simplecov simplecov-lcov (~> 0.8.0) slack-notifier (~> 2.4.0) @@ -597,12 +607,12 @@ DEPENDENCIES spring-watcher-listen terminal-notifier-guard timecop - turbolinks (~> 5.2.0) + turbolinks (~> 5.2.1) tzinfo-data - uglifier (~> 4.2.0) - validates_timeliness (~> 7.0.0.beta2) - web-console (~> 4.2.0) - webpacker (~> 5.4.0) + uglifier (~> 4.2.1) + validates_timeliness (~> 7.1.0) + web-console (~> 4.2.1) + webpacker (~> 5.4.4) wicked_pdf wkhtmltopdf-binary diff --git a/LICENSE b/LICENSE index 26dcc45df..b6b965c3f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2019 C.S.V. Alpha +Copyright (c) 2025 C.S.V. Alpha Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index aef9c7370..3e7497e7c 100644 --- a/README.md +++ b/README.md @@ -93,3 +93,4 @@ When submitting a PR, it'll need to be approved, but once approved (and green) y - [@wilco375](https://github.com/wilco375) - [@guidojw](https://github.com/guidojw) - [@ellen-wittingen](https://github.com/Ellen-Wittingen) +- [@jorai](https://github.com/lodewiges) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 298cc4118..7577e83b0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,5 @@ class ApplicationController < ActionController::Base - include Pundit + include Pundit::Authorization before_action :set_sentry_context before_action :set_paper_trail_whodunnit diff --git a/app/controllers/invoices_controller.rb b/app/controllers/invoices_controller.rb index ea5c788c2..258a0e83f 100644 --- a/app/controllers/invoices_controller.rb +++ b/app/controllers/invoices_controller.rb @@ -52,7 +52,7 @@ def pay # rubocop:disable Metrics/AbcSize, Metrics/MethodLength if payment.valid? checkout_url = payment.mollie_payment.checkout_url - redirect_to URI.parse(checkout_url).to_s + redirect_to URI.parse(checkout_url).to_s, allow_other_host: true else flash[:error] = payment.errors redirect_to invoice_path params[:id] diff --git a/app/controllers/orders_controller.rb b/app/controllers/orders_controller.rb index 73496787d..ca5521a48 100644 --- a/app/controllers/orders_controller.rb +++ b/app/controllers/orders_controller.rb @@ -78,7 +78,7 @@ def allowed_filters end def send_insufficient_credit_mail?(user, old_credit) - return if user.nil? + return false if user.nil? user.provider == 'amber_oauth2' && user.credit.negative? && old_credit.positive? end diff --git a/app/controllers/payments_controller.rb b/app/controllers/payments_controller.rb index 4f6ed90e6..6364abaef 100644 --- a/app/controllers/payments_controller.rb +++ b/app/controllers/payments_controller.rb @@ -15,7 +15,7 @@ def create # rubocop:disable Metrics/AbcSize if payment.valid? checkout_url = payment.mollie_payment.checkout_url - redirect_to URI.parse(checkout_url).to_s + redirect_to URI.parse(checkout_url).to_s, allow_other_host: true else flash[:error] = payment.errors redirect_to add_payments_path diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ba7e6d785..dadde077c 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -120,7 +120,7 @@ def send_slack_users_refresh_notification return unless Rails.env.production? || Rails.env.staging? || Rails.env.luxproduction? # :nocov: - SlackMessageJob.perform_later("User ##{current_user.id} (#{current_user.name}) "\ + SlackMessageJob.perform_later("User ##{current_user.id} (#{current_user.name}) " \ "is importing users from Amber (#{Rails.application.config.x.amber_api_host})") # :nocov: end diff --git a/app/controllers/zatladder_controller.rb b/app/controllers/zatladder_controller.rb index 06d230f29..34093dd83 100644 --- a/app/controllers/zatladder_controller.rb +++ b/app/controllers/zatladder_controller.rb @@ -24,7 +24,7 @@ def current_year end def zatladder_spendings(from, to) - @users_spendings = User.in_amber.calculate_spendings(from: from, to: to) + @users_spendings = User.in_amber.calculate_spendings(from:, to:) zatladder = User.in_amber.select(:id, :name).map do |user| { id: user.id, diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 13c0d17c3..c7fb5eadc 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,10 +1,10 @@ module ApplicationHelper # TODO: Spec this method # :nocov: - def nav_link(name = nil, options = nil, html_options = nil, &block) + def nav_link(name = nil, options = nil, html_options = nil, &) options&.merge!(class: 'active') { |_, v1, v2| [v1, v2].join ' ' } if current_page?(name) - link_to(name, options, html_options, &block) + link_to(name, options, html_options, &) end def flash_class(level) diff --git a/app/jobs/activity_invoice_job.rb b/app/jobs/activity_invoice_job.rb index 1d4ccb27c..c1ef64d06 100644 --- a/app/jobs/activity_invoice_job.rb +++ b/app/jobs/activity_invoice_job.rb @@ -3,7 +3,7 @@ class ActivityInvoiceJob < ApplicationJob def perform(activity) activity.manually_added_users_with_orders.each do |user| - Invoice.create(activity: activity, user: user) + Invoice.create(activity:, user:) end end end diff --git a/app/jobs/credit_insufficient_notification_job.rb b/app/jobs/credit_insufficient_notification_job.rb index 74b26728b..fe99065b4 100644 --- a/app/jobs/credit_insufficient_notification_job.rb +++ b/app/jobs/credit_insufficient_notification_job.rb @@ -32,8 +32,8 @@ def send_notification_delivery_reports(success_count, unnotifyable_users) # rubo return unless Rails.env.production? || Rails.env.staging? || Rails.env.luxproduction? - SlackMessageJob.perform_later("Er is voor #{Rails.application.config.x.amber_api_host} een saldomail "\ - "verstuurd naar #{success_count} mensen, en #{unnotifyable_users.count} saldomail(s) kon(den) niet "\ + SlackMessageJob.perform_later("Er is voor #{Rails.application.config.x.amber_api_host} een saldomail " \ + "verstuurd naar #{success_count} mensen, en #{unnotifyable_users.count} saldomail(s) kon(den) niet " \ 'verzonden worden door het ontbreken van een e-mail adres.') HealthCheckJob.perform_later('credit_insufficient') diff --git a/app/mailers/user_credit_mailer.rb b/app/mailers/user_credit_mailer.rb index f4ea71fd0..32cc94898 100644 --- a/app/mailers/user_credit_mailer.rb +++ b/app/mailers/user_credit_mailer.rb @@ -15,7 +15,7 @@ def credit_delivery_report_mail(treasurer, success_count, unnotifyable_users) subject = "Er is #{@success_count.positive? ? 'een' : 'geen'} saldomail verstuurd" - mail to: treasurer.email, subject: subject + mail to: treasurer.email, subject: end def new_credit_mutation_mail(credit_mutation) diff --git a/app/models/activity.rb b/app/models/activity.rb index 12433222a..de04f2785 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -5,26 +5,26 @@ class Activity < ApplicationRecord has_many :credit_mutations, dependent: :destroy has_many :ordering_users, through: :orders, source: :user belongs_to :price_list - belongs_to :created_by, class_name: 'User', inverse_of: :activities + belongs_to :created_by, class_name: 'User' belongs_to :locked_by, class_name: 'User', optional: true validates :title, :start_time, :end_time, presence: true validates_datetime :end_time, after: :start_time validate :activity_not_locked - scope :upcoming, (lambda { + scope :upcoming, lambda { where('(start_time < ? and end_time > ?) or start_time > ?', Time.zone.now, Time.zone.now, Time.zone.now).order(:start_time, :end_time) - }) + } - scope :current, (lambda { + scope :current, lambda { where('(start_time < ? and end_time > ?)', Time.zone.now, Time.zone.now).order(:start_time, :end_time) - }) + } - scope :not_locked, (lambda { + scope :not_locked, lambda { where('end_time >= ? AND locked_by_id IS NULL', 2.months.ago) - }) + } delegate :products, to: :price_list @@ -64,7 +64,7 @@ def count_per_product(**args) @count_per_product = OrderRow.where(order: records).group(:product_id, :name).joins(:product) .pluck(:name, Arel.sql('SUM(product_count)'), Arel.sql('SUM(product_count * price_per_product)')) - @count_per_product.map { |name, amount, price| { name: name, amount: amount.to_i, price: price.to_f } } + @count_per_product.map { |name, amount, price| { name:, amount: amount.to_i, price: price.to_f } } end def revenue_by_category @@ -81,7 +81,7 @@ def revenue_per_product end def revenue_by_user(user) - user_orders = orders.where(user: user) + user_orders = orders.where(user:) OrderRow.where(order: user_orders).sum('product_count * price_per_product') end diff --git a/app/models/credit_mutation.rb b/app/models/credit_mutation.rb index 6a2f48bb2..e15fb9914 100644 --- a/app/models/credit_mutation.rb +++ b/app/models/credit_mutation.rb @@ -1,16 +1,16 @@ class CreditMutation < ApplicationRecord belongs_to :user belongs_to :activity, optional: true - belongs_to :created_by, class_name: 'User', inverse_of: :credit_mutations + belongs_to :created_by, class_name: 'User' validates :description, presence: true validates :amount, presence: true, numericality: { less_than_or_equal_to: 1000 } validate :activity_not_locked - scope :linked_to_activity, (lambda { + scope :linked_to_activity, lambda { where.not(activity: nil) - }) + } before_destroy -> { throw(:abort) } diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 43afe14b4..b1ed7e1a1 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -5,7 +5,7 @@ class Invoice < ApplicationRecord belongs_to :user belongs_to :activity - has_many :rows, class_name: 'InvoiceRow', inverse_of: :invoice, dependent: :destroy + has_many :rows, class_name: 'InvoiceRow', dependent: :destroy accepts_nested_attributes_for :rows validate :activity_is_locked diff --git a/app/models/order.rb b/app/models/order.rb index 9a4318f78..cd93f7fd0 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -1,7 +1,7 @@ class Order < ApplicationRecord belongs_to :activity belongs_to :user, optional: true - belongs_to :created_by, class_name: 'User', inverse_of: :orders + belongs_to :created_by, class_name: 'User' has_many :order_rows, dependent: :destroy accepts_nested_attributes_for :order_rows @@ -15,7 +15,7 @@ class Order < ApplicationRecord before_create :can_user_create_order? before_destroy -> { throw(:abort) } - scope :orders_for, (->(user) { where(user: user) }) + scope :orders_for, ->(user) { where(user:) } def can_user_create_order? throw(:abort) unless user.nil? || user.can_order(activity) @@ -30,7 +30,7 @@ def self.count_per_product(from_date, to_date) order_rows = OrderRow.where(order: records).group(:product_id, :name).joins(:product) .pluck(:name, Arel.sql('SUM(product_count)'), Arel.sql('SUM(product_count * price_per_product)')) - order_rows.map { |name, amount, price| { name: name, amount: amount.to_i, price: price.to_f } } + order_rows.map { |name, amount, price| { name:, amount: amount.to_i, price: price.to_f } } end def self.count_per_category(from_date, to_date) @@ -39,7 +39,7 @@ def self.count_per_category(from_date, to_date) order_rows = OrderRow.where(order: records).group(:category).joins(:product) .pluck(:category, Arel.sql('SUM(product_count)'), Arel.sql('SUM(product_count * price_per_product)')) - order_rows.map { |category, amount, price| { category: category, amount: amount.to_i, price: price.to_f } } + order_rows.map { |category, amount, price| { category:, amount: amount.to_i, price: price.to_f } } end private diff --git a/app/models/order_row.rb b/app/models/order_row.rb index aba802773..a330b0974 100644 --- a/app/models/order_row.rb +++ b/app/models/order_row.rb @@ -1,5 +1,5 @@ class OrderRow < ApplicationRecord - belongs_to :order, inverse_of: :order_rows + belongs_to :order belongs_to :product validates :product_count, presence: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } diff --git a/app/models/payment.rb b/app/models/payment.rb index 8a5982dec..50b7a3ab4 100644 --- a/app/models/payment.rb +++ b/app/models/payment.rb @@ -18,7 +18,7 @@ class << self validate :user_xor_invoice validate :user_amount - scope :not_completed, (-> { where.not(status: COMPLETE_STATUSES) }) + scope :not_completed, -> { where.not(status: COMPLETE_STATUSES) } after_save :process_complete_payment! @@ -32,7 +32,7 @@ def self.create_with_mollie(description, attributes = nil) mollie_payment = Mollie::Payment.create( amount: { value: format('%.2f', amount: attributes[:amount]), currency: 'EUR' }, - description: description, + description:, redirect_url: "http://#{Rails.application.config.x.sofia_host}/payments/#{obj.id}/callback" ) @@ -52,8 +52,8 @@ def process_complete_payment! end def process_user! - mutation = CreditMutation.create(user: user, - amount: amount, + mutation = CreditMutation.create(user:, + amount:, description: 'iDEAL inleg', created_by: user) UserCreditMailer.new_credit_mutation_mail(mutation).deliver_later @@ -61,7 +61,7 @@ def process_user! def process_invoice! CreditMutation.create(user: invoice.user, - amount: amount, + amount:, description: "Betaling factuur #{invoice.human_id}", created_by: invoice.user) invoice.update(status: 'paid') diff --git a/app/models/price_list.rb b/app/models/price_list.rb index dff0a3006..42e050344 100644 --- a/app/models/price_list.rb +++ b/app/models/price_list.rb @@ -5,7 +5,7 @@ class PriceList < ApplicationRecord validates :name, presence: true - scope :unarchived, (-> { where(archived_at: nil) }) + scope :unarchived, -> { where(archived_at: nil) } def product_price_for(product) @product_price ||= ProductPrice.includes(:product).where(price_list: self) diff --git a/app/models/role.rb b/app/models/role.rb index 55d9a47a2..db7220447 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -2,7 +2,7 @@ class Role < ApplicationRecord enum role_type: { treasurer: 0, main_bartender: 1, renting_manager: 2 } validates :role_type, :group_uid, presence: true - has_many :roles_users, class_name: 'RolesUsers', dependent: :destroy, inverse_of: :role + has_many :roles_users, class_name: 'RolesUsers', dependent: :destroy has_many :users, through: :roles_users def name diff --git a/app/models/user.rb b/app/models/user.rb index 086e3d444..7eece9722 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -5,18 +5,18 @@ class User < ApplicationRecord # rubocop:disable Metrics/ClassLength has_many :credit_mutations, dependent: :destroy has_many :activities, dependent: :destroy, foreign_key: 'created_by_id', inverse_of: :created_by - has_many :roles_users, class_name: 'RolesUsers', dependent: :destroy, inverse_of: :user + has_many :roles_users, class_name: 'RolesUsers', dependent: :destroy has_many :roles, through: :roles_users validates :name, presence: true validates :uid, uniqueness: true, allow_blank: true validate :no_deactivation_when_nonzero_credit - scope :in_amber, (-> { where(provider: 'amber_oauth2') }) - scope :manual, (-> { where(provider: nil) }) - scope :active, (-> { where(deactivated: false) }) - scope :inactive, (-> { where(deactivated: true) }) - scope :treasurer, (-> { joins(:roles).merge(Role.treasurer) }) + scope :in_amber, -> { where(provider: 'amber_oauth2') } + scope :manual, -> { where(provider: nil) } + scope :active, -> { where(deactivated: false) } + scope :inactive, -> { where(deactivated: true) } + scope :treasurer, -> { joins(:roles).merge(Role.treasurer) } attr_accessor :current_activity @@ -53,7 +53,7 @@ def can_order(activity = nil) if activity.nil? !insufficient_credit else - !insufficient_credit or activity.orders.select { |order| order.user_id == id }.any? + !insufficient_credit or activity.orders.any? { |order| order.user_id == id } end end @@ -71,7 +71,7 @@ def renting_manager? def update_role(groups) roles_to_have = Role.where(group_uid: groups) - roles_users_to_have = roles_to_have.map { |role| RolesUsers.find_or_create_by(role: role, user: self) } + roles_users_to_have = roles_to_have.map { |role| RolesUsers.find_or_create_by(role:, user: self) } roles_users_not_to_have = roles_users - roles_users_to_have roles_users_not_to_have.map(&:destroy) diff --git a/app/views/invoices/show.html.erb b/app/views/invoices/show.html.erb index e4f9d064a..bfcd4daa1 100644 --- a/app/views/invoices/show.html.erb +++ b/app/views/invoices/show.html.erb @@ -63,7 +63,7 @@ - <% if policy(Invoice).send_invoice? && !@invoice.paid? %> + <% unless @invoice.paid? %> <%= link_to pay_invoice_url @invoice.token do %> <% end %> diff --git a/config/application.rb b/config/application.rb index 1bfc53384..89fbae712 100644 --- a/config/application.rb +++ b/config/application.rb @@ -7,7 +7,7 @@ module Sofia class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 6.0 + config.load_defaults 7.0 config.time_zone = 'Europe/Amsterdam' @@ -28,9 +28,7 @@ class Application < Rails::Application config.x.amber_api_url = "#{Rails.env.development? ? 'http' : 'https'}://#{credentials.dig(Rails.env.to_sym, :amber_host)}" config.x.amber_client_id = credentials.dig(Rails.env.to_sym, :amber_client_id) || ENV.fetch('AMBER_CLIENT_ID', nil) - config.x.amber_client_secret = credentials.dig( - Rails.env.to_sym, :amber_client_secret - ) || ENV.fetch('AMBER_CLIENT_SECRET', nil) + config.x.amber_client_secret = credentials.dig(Rails.env.to_sym, :amber_client_secret) || ENV.fetch('AMBER_CLIENT_SECRET', nil) config.x.amber_host = credentials.dig(Rails.env.to_sym, :amber_host) config.x.sofia_host = credentials.dig(Rails.env.to_sym, :sofia_host) diff --git a/config/environments/production.rb b/config/environments/production.rb index ddbcd9648..6ade5d8ed 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -77,7 +77,7 @@ config.active_support.deprecation = :notify # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new + config.log_formatter = Logger::Formatter.new # Use a different logger for distributed setups. # require 'syslog/logger' diff --git a/config/routes.rb b/config/routes.rb index 94c0d9774..8838a243c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -57,7 +57,7 @@ require 'sidekiq/web' require 'sidekiq-scheduler/web' - authenticate :user, ->(u) { u.treasurer? } do + authenticate :user, lambda(&:treasurer?) do mount Sidekiq::Web => '/sidekiq' end diff --git a/config/webpacker.yml b/config/webpacker.yml index b11acd4b0..afb7be7b5 100644 --- a/config/webpacker.yml +++ b/config/webpacker.yml @@ -96,8 +96,6 @@ production: &production staging: <<: *production - public_root_path: public # https://github.com/rails/webpacker/issues/1912 luxproduction: <<: *production - public_root_path: public # https://github.com/rails/webpacker/issues/1912 diff --git a/db/seeds.rb b/db/seeds.rb index 3043c9a22..6bf58e4bd 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,4 +1,4 @@ -require_relative './seeds/products' +require_relative 'seeds/products' # rubocop:disable Rails/Output p 'Seeding products...' @@ -6,9 +6,8 @@ p 'Seeding price lists...' price_lists_names = %w[BSA Inkoopprijs Extern] -price_lists = [] -price_lists_names.each do |name| - price_lists << FactoryBot.create(:price_list, :with_all_products, name: name) +price_lists = price_lists_names.map do |name| + FactoryBot.create(:price_list, :with_all_products, name:) end p 'Seeding users...' @@ -27,14 +26,14 @@ p 'Seeding orders...' activities.each do |activity| 5.times do - FactoryBot.create(:order, :with_items, products: activity.products.sample(2), activity: activity, + FactoryBot.create(:order, :with_items, products: activity.products.sample(2), activity:, user: users.sample, created_by: users.sample) end end p 'Seeding credit mutations...' users.each do |user| - FactoryBot.create_list(:credit_mutation, 3, user: user, created_by: users.sample, + FactoryBot.create_list(:credit_mutation, 3, user:, created_by: users.sample, activity: (activities + [nil]).sample) end diff --git a/db/seeds/products.rb b/db/seeds/products.rb index 8d8862fe7..2c224beb2 100644 --- a/db/seeds/products.rb +++ b/db/seeds/products.rb @@ -1,6 +1,4 @@ def seed_products # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity - products = [] - # rubocop:disable Style/WordArray products_beer = ['Bier (glas)', 'Bier (pul)', 'Bier (pitcher)', '12+1'] products_low_alcohol_beer = ['Alcoholarm bier', 'Radler 0.0'] @@ -14,44 +12,44 @@ def seed_products # rubocop:disable Metrics/AbcSize, Metrics/MethodLength, Metri products_donation = ['Donatie'] # rubocop:enable Style/WordArray - products_beer.each do |name| - products << Product.create(name: name, category: :beer) + products = products_beer.map do |name| + Product.create(name:, category: :beer) end products_low_alcohol_beer.each do |name| - products << Product.create(name: name, category: :low_alcohol_beer) + products << Product.create(name:, category: :low_alcohol_beer) end products_craft_beer.each do |name| - products << Product.create(name: name, category: :craft_beer) + products << Product.create(name:, category: :craft_beer) end products_non_alcoholic.each do |name| - products << Product.create(name: name, category: :non_alcoholic) + products << Product.create(name:, category: :non_alcoholic) end products_distilled.each do |name| - products << Product.create(name: name, category: :distilled) + products << Product.create(name:, category: :distilled) end products_whiskey.each do |name| - products << Product.create(name: name, category: :whiskey) + products << Product.create(name:, category: :whiskey) end products_wine.each do |name| - products << Product.create(name: name, category: :wine) + products << Product.create(name:, category: :wine) end products_food.each do |name| - products << Product.create(name: name, category: :food) + products << Product.create(name:, category: :food) end products_tobacco.each do |name| - products << Product.create(name: name, category: :tobacco) + products << Product.create(name:, category: :tobacco) end products_donation.each do |name| - products << Product.create(name: name, category: :donation) + products << Product.create(name:, category: :donation) end products diff --git a/spec/controllers/activities_controller/destroy_spec.rb b/spec/controllers/activities_controller/destroy_spec.rb index 7333ef35c..a78e78f8d 100644 --- a/spec/controllers/activities_controller/destroy_spec.rb +++ b/spec/controllers/activities_controller/destroy_spec.rb @@ -32,7 +32,7 @@ end context 'when with non-empty activity' do - let(:additional_records) { create(:order, activity: activity) } + let(:additional_records) { create(:order, activity:) } it { expect(request.status).to eq 302 } it { expect(Activity.count).to eq 1 } @@ -48,7 +48,7 @@ end context 'when with non-empty activity' do - let(:additional_records) { create(:order, activity: activity) } + let(:additional_records) { create(:order, activity:) } it { expect(request.status).to eq 302 } it { expect(Activity.count).to eq 1 } @@ -64,7 +64,7 @@ end context 'when with non-empty activity' do - let(:additional_records) { create(:order, activity: activity) } + let(:additional_records) { create(:order, activity:) } it { expect(request.status).to eq 302 } it { expect(Activity.count).to eq 1 } diff --git a/spec/controllers/activities_controller/product_totals_spec.rb b/spec/controllers/activities_controller/product_totals_spec.rb index 1b5838c3a..8ef267516 100644 --- a/spec/controllers/activities_controller/product_totals_spec.rb +++ b/spec/controllers/activities_controller/product_totals_spec.rb @@ -4,15 +4,15 @@ describe 'GET product_totals' do let(:activity) { create(:activity) } let(:params) { { id: activity.id } } - let(:request) { get :product_totals, params: params } - let(:order) { create(:order, activity: activity) } - let(:unbound_order) { create(:order, activity: activity) } + let(:request) { get :product_totals, params: } + let(:order) { create(:order, activity:) } + let(:unbound_order) { create(:order, activity:) } let(:products) { activity.price_list.products.sample(2) } before do activity - create(:order_row, order: order, product_count: 2, product: products.first) - create(:order_row, order: order, product_count: 3, product: products.last) + create(:order_row, order:, product_count: 2, product: products.first) + create(:order_row, order:, product_count: 3, product: products.last) create(:order_row, order: unbound_order, product_count: 4, product: products.first) sign_in user @@ -35,7 +35,7 @@ end context 'when filtering for user' do - let(:order) { create(:order, activity: activity, user: user) } + let(:order) { create(:order, activity:, user:) } let(:params) { { id: activity.id, user: user.id } } it do @@ -45,7 +45,7 @@ end context 'when filtering for cash' do - let(:order) { create(:order, activity: activity, paid_with_cash: true) } + let(:order) { create(:order, activity:, paid_with_cash: true) } let(:params) { { id: activity.id, paid_with_cash: true } } it do @@ -55,7 +55,7 @@ end context 'when filtering for pin' do - let(:order) { create(:order, activity: activity, paid_with_pin: true) } + let(:order) { create(:order, activity:, paid_with_pin: true) } let(:params) { { id: activity.id, paid_with_pin: true } } it do @@ -75,7 +75,7 @@ end context 'when filtering for user' do - let(:order) { create(:order, activity: activity, user: user) } + let(:order) { create(:order, activity:, user:) } let(:params) { { id: activity.id, user: user.id } } it do @@ -85,7 +85,7 @@ end context 'when filtering for cash' do - let(:order) { create(:order, activity: activity, paid_with_cash: true) } + let(:order) { create(:order, activity:, paid_with_cash: true) } let(:params) { { id: activity.id, paid_with_cash: true } } it do @@ -95,7 +95,7 @@ end context 'when filtering for pin' do - let(:order) { create(:order, activity: activity, paid_with_pin: true) } + let(:order) { create(:order, activity:, paid_with_pin: true) } let(:params) { { id: activity.id, paid_with_pin: true } } it do @@ -115,7 +115,7 @@ end context 'when filtering for user' do - let(:order) { create(:order, activity: activity, user: user) } + let(:order) { create(:order, activity:, user:) } let(:params) { { id: activity.id, user: user.id } } it do @@ -125,7 +125,7 @@ end context 'when filtering for cash' do - let(:order) { create(:order, activity: activity, paid_with_cash: true) } + let(:order) { create(:order, activity:, paid_with_cash: true) } let(:params) { { id: activity.id, paid_with_cash: true } } it do @@ -135,7 +135,7 @@ end context 'when filtering for pin' do - let(:order) { create(:order, activity: activity, paid_with_pin: true) } + let(:order) { create(:order, activity:, paid_with_pin: true) } let(:params) { { id: activity.id, paid_with_pin: true } } it do diff --git a/spec/controllers/credit_mutations_controller/create_spec.rb b/spec/controllers/credit_mutations_controller/create_spec.rb index df987739f..8f9701f9b 100644 --- a/spec/controllers/credit_mutations_controller/create_spec.rb +++ b/spec/controllers/credit_mutations_controller/create_spec.rb @@ -4,10 +4,10 @@ describe 'POST create' do let(:user) { create(:user) } let(:credit_mutation) do - build(:credit_mutation, user: user) + build(:credit_mutation, user:) end let(:credit_mutation_with_activity) do - build(:credit_mutation, activity: create(:activity), user: user) + build(:credit_mutation, activity: create(:activity), user:) end let(:request1) do post :create, params: { credit_mutation: credit_mutation.attributes, format: :json } diff --git a/spec/controllers/invoices_controller/pay_spec.rb b/spec/controllers/invoices_controller/pay_spec.rb index d7c129311..9414ffe35 100644 --- a/spec/controllers/invoices_controller/pay_spec.rb +++ b/spec/controllers/invoices_controller/pay_spec.rb @@ -6,7 +6,7 @@ let(:id) { invoice.id } let(:http_request) do - get :pay, params: { id: id } + get :pay, params: { id: } end context 'when authorized' do diff --git a/spec/controllers/orders_controller/create_spec.rb b/spec/controllers/orders_controller/create_spec.rb index d863db985..3112bc571 100644 --- a/spec/controllers/orders_controller/create_spec.rb +++ b/spec/controllers/orders_controller/create_spec.rb @@ -5,7 +5,7 @@ let(:activity) { create(:activity) } let(:locked_activity) { create(:activity) } let(:order) do - build(:order, activity: activity, user: create(:user)) + build(:order, activity:, user: create(:user)) end let(:order_on_locked_activity) do build(:order, activity: locked_activity, user: create(:user)) diff --git a/spec/controllers/orders_controller/destroy_spec.rb b/spec/controllers/orders_controller/destroy_spec.rb index 6a5ef5beb..857bd33ca 100644 --- a/spec/controllers/orders_controller/destroy_spec.rb +++ b/spec/controllers/orders_controller/destroy_spec.rb @@ -5,7 +5,7 @@ let(:activity) { create(:activity) } let(:locked_activity) { create(:activity) } let(:order) do - create(:order, activity: activity, user: create(:user)) + create(:order, activity:, user: create(:user)) end let(:order_on_locked_activity) do create(:order, activity: locked_activity, user: create(:user)) @@ -19,7 +19,7 @@ end before do - create(:order_row, order: order, product_count: 2, product: activity.price_list.products.first) + create(:order_row, order:, product_count: 2, product: activity.price_list.products.first) create(:order_row, order: order_on_locked_activity, product_count: 2, product: locked_activity.price_list.products.first) locked_activity.update(locked_by: create(:user)) diff --git a/spec/controllers/orders_controller/update_spec.rb b/spec/controllers/orders_controller/update_spec.rb index 1da12b7ad..3a50671fe 100644 --- a/spec/controllers/orders_controller/update_spec.rb +++ b/spec/controllers/orders_controller/update_spec.rb @@ -5,7 +5,7 @@ let(:activity) { create(:activity) } let(:locked_activity) { create(:activity) } let(:order) do - create(:order, activity: activity, user: create(:user)) + create(:order, activity:, user: create(:user)) end let(:order_on_locked_activity) do create(:order, activity: locked_activity, user: create(:user)) @@ -21,7 +21,7 @@ end before do - create(:order_row, order: order, product_count: 2, product: activity.price_list.products.first) + create(:order_row, order:, product_count: 2, product: activity.price_list.products.first) create(:order_row, order: order_on_locked_activity, product_count: 2, product: locked_activity.price_list.products.first) locked_activity.update(locked_by: create(:user)) diff --git a/spec/controllers/payments_controller/callback_spec.rb b/spec/controllers/payments_controller/callback_spec.rb index 45405575d..b253055b5 100644 --- a/spec/controllers/payments_controller/callback_spec.rb +++ b/spec/controllers/payments_controller/callback_spec.rb @@ -9,7 +9,7 @@ end describe 'handles paid payment' do - let(:payment) { create(:payment, status: 'open', user: user, amount: '22.00') } + let(:payment) { create(:payment, status: 'open', user:, amount: '22.00') } let(:request) { get :callback, params: { id: payment.id } } let(:mollie) { instance_double(Mollie::Payment) } @@ -27,7 +27,7 @@ end describe 'handles open payment' do - let(:payment) { create(:payment, status: 'open', user: user, amount: '22.00') } + let(:payment) { create(:payment, status: 'open', user:, amount: '22.00') } let(:request) { get :callback, params: { id: payment.id } } let(:mollie) { instance_double(Mollie::Payment) } diff --git a/spec/factories/invoices.rb b/spec/factories/invoices.rb index 221d5d7fa..1e53a65d7 100644 --- a/spec/factories/invoices.rb +++ b/spec/factories/invoices.rb @@ -7,7 +7,7 @@ trait :with_rows do after(:create) do |invoice, _evaluator| - create :invoice_row, invoice: invoice + create :invoice_row, invoice: end end end diff --git a/spec/factories/order.rb b/spec/factories/order.rb index 12c4f2a17..c87c2ad7a 100644 --- a/spec/factories/order.rb +++ b/spec/factories/order.rb @@ -24,7 +24,7 @@ end after(:create) do |order, evaluator| - create :order_row, order: order, product: evaluator.products.sample, product_count: 1 + create :order_row, order:, product: evaluator.products.sample, product_count: 1 end end diff --git a/spec/factories/price_list.rb b/spec/factories/price_list.rb index 2044f8c6d..42ccb6687 100644 --- a/spec/factories/price_list.rb +++ b/spec/factories/price_list.rb @@ -23,14 +23,14 @@ after(:create) do |price_list, evaluator| if evaluator.with_all_products Product.all.each do |product| - create(:product_price, price_list: price_list, product: product) + create(:product_price, price_list:, product:) end elsif evaluator.with_specific_products evaluator.products.each do |product| - create(:product_price, price_list: price_list, product: product) + create(:product_price, price_list:, product:) end else - create_list(:product_price, 2, price_list: price_list) + create_list(:product_price, 2, price_list:) end end end diff --git a/spec/jobs/activity_invoice_job_spec.rb b/spec/jobs/activity_invoice_job_spec.rb index 133be2b5a..8c9e8a047 100644 --- a/spec/jobs/activity_invoice_job_spec.rb +++ b/spec/jobs/activity_invoice_job_spec.rb @@ -9,8 +9,8 @@ subject(:job) { perform_enqueued_jobs { described_class.perform_now(activity) } } before do - manual_users.each { |u| create(:order_with_items, user: u, activity: activity) } - external_users.each { |u| create(:order_with_items, user: u, activity: activity) } + manual_users.each { |u| create(:order_with_items, user: u, activity:) } + external_users.each { |u| create(:order_with_items, user: u, activity:) } activity.update(locked_by: create(:user)) job diff --git a/spec/jobs/new_credit_mutation_notification_job_spec.rb b/spec/jobs/new_credit_mutation_notification_job_spec.rb index fae445826..d59106b7e 100644 --- a/spec/jobs/new_credit_mutation_notification_job_spec.rb +++ b/spec/jobs/new_credit_mutation_notification_job_spec.rb @@ -4,7 +4,7 @@ describe '#perform' do let(:user) { create(:user, name: 'Buddy Normal', email: 'bahamas@example.com') } let(:emails) { ActionMailer::Base.deliveries } - let(:mutation) { create(:credit_mutation, user: user, amount: -2.30) } + let(:mutation) { create(:credit_mutation, user:, amount: -2.30) } subject(:job) { perform_enqueued_jobs { described_class.perform_now(mutation) } } diff --git a/spec/models/activity_spec.rb b/spec/models/activity_spec.rb index 82aa7fe8e..2acfdd159 100644 --- a/spec/models/activity_spec.rb +++ b/spec/models/activity_spec.rb @@ -92,7 +92,7 @@ describe '#lock_date' do let(:start_time) { (2.months + 3.days).ago } - subject(:activity) { build(:activity, start_time: start_time, end_time: start_time + 4.hours) } + subject(:activity) { build(:activity, start_time:, end_time: start_time + 4.hours) } it { expect(activity.lock_date).to eq activity.end_time + 2.months } it { expect(activity.locked?).to be true } @@ -115,7 +115,7 @@ let(:activity) { create(:activity) } before do - create(:order, activity: activity) + create(:order, activity:) end it { expect(activity.destroyable?).to be false } @@ -125,7 +125,7 @@ let(:activity) { create(:activity) } before do - create(:credit_mutation, activity: activity) + create(:credit_mutation, activity:) end it { expect(activity.destroyable?).to be false } @@ -189,8 +189,8 @@ context 'when with credit mutations' do before do - create(:credit_mutation, activity: activity, amount: 10) - create(:credit_mutation, activity: activity, amount: 50) + create(:credit_mutation, activity:, amount: 10) + create(:credit_mutation, activity:, amount: 50) end it { expect(activity.credit_mutations_total).to eq 60 } @@ -200,14 +200,14 @@ describe '#revenue_with(out)_cash' do let(:product) { activity.price_list.products.sample } let(:product_price) { activity.price_list.product_price_for(product).price } - let(:cash_order) { create(:order, :cash, activity: activity) } - let(:pin_order) { create(:order, :pin, activity: activity) } - let(:order) { create(:order, activity: activity) } + let(:cash_order) { create(:order, :cash, activity:) } + let(:pin_order) { create(:order, :pin, activity:) } + let(:order) { create(:order, activity:) } before do - create(:order_row, product: product, order: cash_order, product_count: 2) - create(:order_row, product: product, order: order, product_count: 3) - create(:order_row, product: product, order: pin_order, product_count: 4) + create(:order_row, product:, order: cash_order, product_count: 2) + create(:order_row, product:, order:, product_count: 3) + create(:order_row, product:, order: pin_order, product_count: 4) end it { expect(activity.revenue_with_cash).to eq product_price * 2 } @@ -219,15 +219,15 @@ describe '#cash_total' do let(:product) { activity.price_list.products.sample } let(:product_price) { activity.price_list.product_price_for(product).price } - let(:cash_order) { create(:order, :cash, activity: activity) } - let(:pin_order) { create(:order, :pin, activity: activity) } - let(:order) { create(:order, activity: activity) } + let(:cash_order) { create(:order, :cash, activity:) } + let(:pin_order) { create(:order, :pin, activity:) } + let(:order) { create(:order, activity:) } before do - create(:credit_mutation, activity: activity, amount: 50) - create(:order_row, product: product, order: cash_order, product_count: 2) - create(:order_row, product: product, order: order, product_count: 3) - create(:order_row, product: product, order: pin_order, product_count: 4) + create(:credit_mutation, activity:, amount: 50) + create(:order_row, product:, order: cash_order, product_count: 2) + create(:order_row, product:, order:, product_count: 3) + create(:order_row, product:, order: pin_order, product_count: 4) end it { expect(activity.cash_total).to eq (2 * product_price) + 50 } @@ -236,15 +236,15 @@ describe '#revenue_total' do let(:product) { activity.price_list.products.sample } let(:product_price) { activity.price_list.product_price_for(product).price } - let(:cash_order) { create(:order, :cash, activity: activity) } - let(:pin_order) { create(:order, :pin, activity: activity) } - let(:order) { create(:order, activity: activity) } + let(:cash_order) { create(:order, :cash, activity:) } + let(:pin_order) { create(:order, :pin, activity:) } + let(:order) { create(:order, activity:) } before do - create(:credit_mutation, activity: activity, amount: 50) - create(:order_row, product: product, order: cash_order, product_count: 2) - create(:order_row, product: product, order: order, product_count: 3) - create(:order_row, product: product, order: pin_order, product_count: 4) + create(:credit_mutation, activity:, amount: 50) + create(:order_row, product:, order: cash_order, product_count: 2) + create(:order_row, product:, order:, product_count: 3) + create(:order_row, product:, order: pin_order, product_count: 4) end it { expect(activity.revenue_total).to eq 9 * product_price } @@ -252,16 +252,16 @@ describe '#count_per_product' do let(:products) { activity.price_list.products.sample(2) } - let(:unbound_order) { create(:order, activity: activity) } + let(:unbound_order) { create(:order, activity:) } before do - create(:order_row, order: order, product_count: 2, product: products.first) - create(:order_row, order: order, product_count: 3, product: products.last) + create(:order_row, order:, product_count: 2, product: products.first) + create(:order_row, order:, product_count: 3, product: products.last) create(:order_row, order: unbound_order, product_count: 4, product: products.first) end context 'without arguments' do - let(:order) { create(:order, activity: activity) } + let(:order) { create(:order, activity:) } it { expect(activity.count_per_product.find { |item| item[:name] == products.first[:name] }[:amount]).to eq 6 } it { expect(activity.count_per_product.find { |item| item[:name] == products.last[:name] }[:amount]).to eq 3 } @@ -269,21 +269,21 @@ context 'when specific user' do let(:user) { create(:user) } - let(:order) { create(:order, activity: activity, user: user) } + let(:order) { create(:order, activity:, user:) } - it { expect(activity.count_per_product(user: user).find { |item| item[:name] == products.first[:name] }[:amount]).to eq 2 } - it { expect(activity.count_per_product(user: user).find { |item| item[:name] == products.last[:name] }[:amount]).to eq 3 } + it { expect(activity.count_per_product(user:).find { |item| item[:name] == products.first[:name] }[:amount]).to eq 2 } + it { expect(activity.count_per_product(user:).find { |item| item[:name] == products.last[:name] }[:amount]).to eq 3 } end context 'when paid with pin' do - let(:order) { create(:order, activity: activity, paid_with_pin: true) } + let(:order) { create(:order, activity:, paid_with_pin: true) } it { expect(activity.count_per_product(paid_with_pin: true).find { |item| item[:name] == products.first[:name] }[:amount]).to eq 2 } it { expect(activity.count_per_product(paid_with_pin: true).find { |item| item[:name] == products.last[:name] }[:amount]).to eq 3 } end context 'when paid with cash' do - let(:order) { create(:order, activity: activity, paid_with_cash: true) } + let(:order) { create(:order, activity:, paid_with_cash: true) } let(:count_per_product) { activity.count_per_product(paid_with_cash: true) } it { expect(count_per_product.find { |item| item[:name] == products.first[:name] }[:amount]).to eq 2 } @@ -294,14 +294,14 @@ describe '#revenue_by_category' do let(:product) { create(:product, category: :beer) } let(:other_product) { create(:product, category: :wine) } - let(:order) { create(:order, activity: activity) } + let(:order) { create(:order, activity:) } before do - create(:product_price, price_list: activity.price_list, product: product, price: 2) + create(:product_price, price_list: activity.price_list, product:, price: 2) create(:product_price, price_list: activity.price_list, product: other_product, price: 3) - create(:order_row, order: order, product: product, product_count: 1) - create(:order_row, order: order, product: other_product, product_count: 1) + create(:order_row, order:, product:, product_count: 1) + create(:order_row, order:, product: other_product, product_count: 1) end it { expect(activity.revenue_by_category['beer']).to eq 2 } @@ -310,14 +310,14 @@ describe '#revenue_per_product' do let(:product) { create(:product, category: :beer) } let(:other_product) { create(:product, category: :wine) } - let(:order) { create(:order, activity: activity) } + let(:order) { create(:order, activity:) } before do - create(:product_price, price_list: activity.price_list, product: product, price: 2) + create(:product_price, price_list: activity.price_list, product:, price: 2) create(:product_price, price_list: activity.price_list, product: other_product, price: 3) - create(:order_row, order: order, product: product, product_count: 1) - create(:order_row, order: order, product: other_product, product_count: 1) + create(:order_row, order:, product:, product_count: 1) + create(:order_row, order:, product: other_product, product_count: 1) end it { expect(activity.revenue_per_product[product]).to eq 2 } @@ -327,11 +327,11 @@ let(:user) { create(:user) } let(:price) { create(:product_price, price: 2) } let(:activity) { create(:activity, price_list: price.price_list) } - let(:order) { create(:order, activity: activity, user: user) } + let(:order) { create(:order, activity:, user:) } before do - create(:order_row, order: order, product: price.product, product_count: 10) - create(:order_row, order: order, product: price.product, product_count: 40) + create(:order_row, order:, product: price.product, product_count: 10) + create(:order_row, order:, product: price.product, product_count: 40) end it { expect(activity.revenue_by_user(user)).to eq 100 } @@ -341,7 +341,7 @@ let(:bartender) { create(:user) } before do - create(:order, created_by: bartender, activity: activity) + create(:order, created_by: bartender, activity:) end it { expect(activity.bartenders).to match_array [bartender] } @@ -358,13 +358,13 @@ subject(:activity) { create(:activity) } let(:manually_added_user) { create(:user) } - let(:manually_added_user_order) { create(:order, user: manually_added_user, activity: activity) } + let(:manually_added_user_order) { create(:order, user: manually_added_user, activity:) } # Make sure that a user only shows up once in the list, even if he/she has placed multiple orders - let(:second_manually_added_user_order) { create(:order, user: manually_added_user, activity: activity) } + let(:second_manually_added_user_order) { create(:order, user: manually_added_user, activity:) } let(:provider_added_user) { create(:user, provider: 'some_provider') } - let(:provider_added_user_order) { create(:order, user: provider_added_user, activity: activity) } + let(:provider_added_user_order) { create(:order, user: provider_added_user, activity:) } before do manually_added_user_order diff --git a/spec/models/credit_mutation_spec.rb b/spec/models/credit_mutation_spec.rb index 5885c2478..0a9bd4ba4 100644 --- a/spec/models/credit_mutation_spec.rb +++ b/spec/models/credit_mutation_spec.rb @@ -38,7 +38,7 @@ context 'when with a locked activity' do let(:activity) { build(:activity, :locked) } - let(:mutation) { build(:credit_mutation, activity: activity) } + let(:mutation) { build(:credit_mutation, activity:) } it { expect(mutation).not_to be_valid } end diff --git a/spec/models/invoice_spec.rb b/spec/models/invoice_spec.rb index 7f7f46f54..8369376c5 100644 --- a/spec/models/invoice_spec.rb +++ b/spec/models/invoice_spec.rb @@ -51,14 +51,14 @@ let(:activity) { create(:activity) } let(:user) { create(:user) } - subject(:invoice) { build(:invoice, activity: activity, user: user) } + subject(:invoice) { build(:invoice, activity:, user:) } before do - create_list(:order, 5, :with_items, user: user, activity: activity) + create_list(:order, 5, :with_items, user:, activity:) activity.update(locked_by: user) invoice.save invoice.reload - create(:invoice_row, invoice: invoice, amount: 5, price: 10) + create(:invoice_row, invoice:, amount: 5, price: 10) end it { expect(invoice.amount).to eq activity.revenue_by_user(user) + 50 } @@ -66,7 +66,7 @@ describe '#set_human_id' do let(:activity) { create(:activity, :manually_locked) } - let(:invoice) { build(:invoice, activity: activity) } + let(:invoice) { build(:invoice, activity:) } before do create_list(:invoice, 2) diff --git a/spec/models/order_row_spec.rb b/spec/models/order_row_spec.rb index 5feceb257..2cc4541aa 100644 --- a/spec/models/order_row_spec.rb +++ b/spec/models/order_row_spec.rb @@ -32,13 +32,13 @@ describe '#copy_product_price' do let(:product) { create(:product) } let(:price_list) { create(:price_list) } - let(:activity) { create(:activity, price_list: price_list) } - let(:order) { create(:order, activity: activity) } + let(:activity) { create(:activity, price_list:) } + let(:order) { create(:order, activity:) } let!(:product_price) do - create(:product_price, price_list: price_list, product: product, price: 2.00) + create(:product_price, price_list:, product:, price: 2.00) end - subject!(:order_row) { create(:order_row, order: order, product: product) } + subject!(:order_row) { create(:order_row, order:, product:) } context 'when with a product' do it { expect(order_row.price_per_product).to eq(2.00) } @@ -65,10 +65,10 @@ context 'when with an order' do let(:all_products) { create_list(:product, 5) } let(:price_list) { create(:price_list, :with_products, products: all_products) } - let(:activity) { create(:activity, price_list: price_list) } - let(:order) { create(:order, activity: activity) } + let(:activity) { create(:activity, price_list:) } + let(:order) { create(:order, activity:) } - subject(:order_row) { create(:order_row, order: order) } + subject(:order_row) { create(:order_row, order:) } before { create(:product) } diff --git a/spec/models/order_spec.rb b/spec/models/order_spec.rb index 3a913153b..10970f2e4 100644 --- a/spec/models/order_spec.rb +++ b/spec/models/order_spec.rb @@ -32,7 +32,7 @@ context 'when with locked activity' do let(:activity) { build_stubbed(:activity, :locked) } - let(:order) { build(:order, activity: activity) } + let(:order) { build(:order, activity:) } it { expect(order).not_to be_valid } end @@ -49,12 +49,12 @@ let(:product) { create(:product) } let(:price_list) { create(:price_list, :with_products, products: [product]) } - let(:activity) { create(:activity, price_list: price_list) } + let(:activity) { create(:activity, price_list:) } - subject(:order) { create(:order, activity: activity) } + subject(:order) { create(:order, activity:) } before do - create(:order_row, order: order, product: product, product_count: 2) + create(:order_row, order:, product:, product_count: 2) order.reload end @@ -66,15 +66,15 @@ let(:product_a) { create(:product, name: 'A') } let(:product_b) { create(:product, name: 'B') } let(:price_list) { create(:price_list, :with_products, products: [product_a, product_b]) } - let(:activity) { create(:activity, price_list: price_list) } - let(:order) { create(:order, activity: activity) } - let(:to_new_order) { create(:order, activity: activity, created_at: 11.days.from_now) } + let(:activity) { create(:activity, price_list:) } + let(:order) { create(:order, activity:) } + let(:to_new_order) { create(:order, activity:, created_at: 11.days.from_now) } subject(:count) { described_class.count_per_product(10.days.ago, 10.days.from_now) } before do - create_list(:order_row, 2, order: order, product: product_a, product_count: 2) - create_list(:order_row, 3, order: order, product: product_b, product_count: 3) + create_list(:order_row, 2, order:, product: product_a, product_count: 2) + create_list(:order_row, 3, order:, product: product_b, product_count: 3) create_list(:order_row, 3, order: to_new_order, product: product_b, product_count: 3) end @@ -86,15 +86,15 @@ let(:product_a) { create(:product, name: 'A', category: 'beer') } let(:product_b) { create(:product, name: 'B', category: 'wine') } let(:price_list) { create(:price_list, :with_products, products: [product_a, product_b]) } - let(:activity) { create(:activity, price_list: price_list) } - let(:order) { create(:order, activity: activity) } - let(:to_new_order) { create(:order, activity: activity, created_at: 11.days.from_now) } + let(:activity) { create(:activity, price_list:) } + let(:order) { create(:order, activity:) } + let(:to_new_order) { create(:order, activity:, created_at: 11.days.from_now) } subject(:count) { described_class.count_per_category(10.days.ago, 10.days.from_now) } before do - create_list(:order_row, 2, order: order, product: product_a, product_count: 2) - create_list(:order_row, 3, order: order, product: product_b, product_count: 3) + create_list(:order_row, 2, order:, product: product_a, product_count: 2) + create_list(:order_row, 3, order:, product: product_b, product_count: 3) create_list(:order_row, 3, order: to_new_order, product: product_b, product_count: 3) end @@ -106,17 +106,17 @@ let(:activity) { create(:activity) } context 'when no user' do - let(:order) { build(:order, paid_with_cash: true, activity: activity) } + let(:order) { build(:order, paid_with_cash: true, activity:) } it { expect(order.save).to be true } end context 'when non-amber user without credit' do let(:user) { create(:user) } - let(:order) { build(:order, user: user, activity: activity) } + let(:order) { build(:order, user:, activity:) } before do - create(:credit_mutation, user: user, amount: -1) + create(:credit_mutation, user:, amount: -1) end it { expect(order.save).to be true } @@ -124,7 +124,7 @@ context 'when amber user' do let(:user) { create(:user, provider: 'amber_oauth2') } - let(:order) { build(:order, user: user, activity: activity) } + let(:order) { build(:order, user:, activity:) } context 'with credit' do # Note that a credit of 0 counts as non-negative credit @@ -133,8 +133,8 @@ context 'without credit with activity order' do before do - create(:order, user: user, activity: activity) - create(:credit_mutation, user: user, amount: -1) + create(:order, user:, activity:) + create(:credit_mutation, user:, amount: -1) end it { expect(order.save).to be true } @@ -142,7 +142,7 @@ context 'without credit without activity order' do before do - create(:credit_mutation, user: user, amount: -1) + create(:credit_mutation, user:, amount: -1) end it { expect(order.save).to be false } diff --git a/spec/models/payment_spec.rb b/spec/models/payment_spec.rb index 3dd15d5ad..5da9268b8 100644 --- a/spec/models/payment_spec.rb +++ b/spec/models/payment_spec.rb @@ -48,7 +48,7 @@ describe '.not_completed' do context 'when with not_completed status' do %w[open pending].each do |status| - subject(:payment) { create(:payment, status: status) } + subject(:payment) { create(:payment, status:) } before { payment } @@ -58,7 +58,7 @@ context 'when with complete status' do %w[paid failed canceled expired].each do |status| - subject(:payment) { create(:payment, status: status) } + subject(:payment) { create(:payment, status:) } before { payment } @@ -71,7 +71,7 @@ let(:user) { create(:user) } context 'when updating user payment to paid' do - subject(:payment) { create(:payment, user: user, amount: 22.00, status: 'open') } + subject(:payment) { create(:payment, user:, amount: 22.00, status: 'open') } describe 'creates credit mutation' do before do @@ -89,9 +89,9 @@ context 'when updating invoice payment to paid' do let(:invoice_row) { create(:invoice_row, amount: 1, price: 22.00) } - let(:invoice) { create(:invoice, rows: [invoice_row], user: user) } + let(:invoice) { create(:invoice, rows: [invoice_row], user:) } - subject(:payment) { create(:payment, user: nil, invoice: invoice, amount: invoice.amount, status: 'open') } + subject(:payment) { create(:payment, user: nil, invoice:, amount: invoice.amount, status: 'open') } describe 'creates credit mutation' do before do @@ -109,7 +109,7 @@ end context 'when not updating payment to paid' do - subject(:payment) { create(:payment, user: user, amount: 22.00, status: 'open') } + subject(:payment) { create(:payment, user:, amount: 22.00, status: 'open') } it { expect { payment.update(status: 'open') }.not_to change(CreditMutation, :count) } it { expect { payment.update(status: 'pending') }.not_to change(CreditMutation, :count) } @@ -119,7 +119,7 @@ end context 'when updating already paid payment' do - subject(:payment) { create(:payment, user: user, amount: 22.00, status: 'paid') } + subject(:payment) { create(:payment, user:, amount: 22.00, status: 'paid') } before do payment.update(status: 'paid') diff --git a/spec/models/price_list_spec.rb b/spec/models/price_list_spec.rb index 4547d7015..a64b0a2b1 100644 --- a/spec/models/price_list_spec.rb +++ b/spec/models/price_list_spec.rb @@ -19,7 +19,7 @@ let(:product) { create(:product) } before do - create(:product_price, product: product, price_list: price_list, price: 8) + create(:product_price, product:, price_list:, price: 8) end it { expect(price_list.product_price_for(product).price).to eq 8 } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 98f7e89f0..647d334f8 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -16,7 +16,7 @@ subject(:user) { create(:user, deactivated: true) } before do - create(:order_with_items, user: user) + create(:order_with_items, user:) end it { expect(user).not_to be_valid } @@ -65,7 +65,7 @@ let(:treasurer_role) { create(:role, role_type: :treasurer) } - before { create(:roles_users, user: user, role: treasurer_role) } + before { create(:roles_users, user:, role: treasurer_role) } it { expect(described_class.treasurer).to include user } end @@ -94,11 +94,11 @@ describe '#credit' do subject(:user) { create(:user) } - let(:order) { create(:order, user: user) } + let(:order) { create(:order, user:) } let(:product_price) { create(:product_price, price_list: order.activity.price_list, price: 1.23) } before do - create(:order_row, order: order, product: product_price.product, product_count: 1) + create(:order_row, order:, product: product_price.product, product_count: 1) end it { expect(user.credit).to eq(-1.23) } @@ -111,7 +111,7 @@ let(:role) { create(:role) } before do - create(:roles_users, role: role, user: user) + create(:roles_users, role:, user:) end it { expect(user.roles).to match_array [role] } @@ -121,7 +121,7 @@ subject(:user) { create(:user) } let(:role) { create(:role) } - let(:roles_users) { create(:roles_users, role: role, user: user) } + let(:roles_users) { create(:roles_users, role:, user:) } before do roles_users @@ -189,7 +189,7 @@ let(:role) { create(:role, role_type: :treasurer) } before do - create(:roles_users, role: role, user: user) + create(:roles_users, role:, user:) end it { expect(user.treasurer?).to be true } @@ -209,7 +209,7 @@ let(:role) { create(:role, role_type: :main_bartender) } before do - create(:roles_users, role: role, user: user) + create(:roles_users, role:, user:) end it { expect(user.main_bartender?).to be true } @@ -264,9 +264,9 @@ let(:product_price) { build(:product_price, price: 2.00) } let(:price_list) { build(:price_list, product_price: [product_price]) } - let(:activity) { build(:activity, price_list: price_list) } + let(:activity) { build(:activity, price_list:) } - let(:default_order) { { products: [product_price.product], activity: activity, user: user } } + let(:default_order) { { products: [product_price.product], activity:, user: } } let(:order) do create(:order_with_items, default_order.merge(created_at: 4.weeks.ago)) @@ -277,7 +277,7 @@ end let(:third_order) do - create(:order_with_items, default_order.merge(user: user, created_at: Time.zone.now)) + create(:order_with_items, default_order.merge(user:, created_at: Time.zone.now)) end before do @@ -349,10 +349,10 @@ context 'when with data' do let(:product_price) { build(:product_price, price: 2.18) } let(:price_list) { build(:price_list, product_price: [product_price]) } - let(:activity) { build(:activity, price_list: price_list) } + let(:activity) { build(:activity, price_list:) } context 'without orders' do - let(:credit_mutation) { create(:credit_mutation, user: user, amount: 20) } + let(:credit_mutation) { create(:credit_mutation, user:, amount: 20) } before do credit_mutation @@ -363,7 +363,7 @@ context 'without credit_mutations' do let(:order) do - build(:order_with_items, products: [product_price.product], activity: activity, user: user) + build(:order_with_items, products: [product_price.product], activity:, user:) end before do @@ -375,9 +375,9 @@ context 'when with both' do let(:order) do - build(:order_with_items, products: [product_price.product], activity: activity, user: user) + build(:order_with_items, products: [product_price.product], activity:, user:) end - let(:credit_mutation) { create(:credit_mutation, user: user, amount: 20) } + let(:credit_mutation) { create(:credit_mutation, user:, amount: 20) } before do credit_mutation diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index f55e65a10..8866ea435 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -33,7 +33,7 @@ config.include Devise::Test::ControllerHelpers, type: :controller # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.fixture_path = Rails.root.join('spec', 'fixtures') # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false