From 2076ab3572effa60278b9e318ee1320376dda95e Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Mon, 6 Mar 2023 23:02:19 -0500 Subject: [PATCH 01/11] Slam Ruby 3.2 --- .ruby-version | 2 +- Gemfile | 2 +- Gemfile.lock | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.ruby-version b/.ruby-version index ef538c2..944880f 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.1.2 +3.2.0 diff --git a/Gemfile b/Gemfile index f225c12..446e25c 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } -ruby "3.1.2" +ruby "3.2.0" # Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" gem "rails", "~> 7.0.4" diff --git a/Gemfile.lock b/Gemfile.lock index 3119f0e..9d2a086 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -110,6 +110,7 @@ GEM matrix (0.4.2) method_source (1.0.0) mini_mime (1.1.2) + mini_portile2 (2.8.1) minitest (5.16.3) msgpack (1.6.0) net-imap (0.3.1) @@ -121,7 +122,8 @@ GEM net-smtp (0.3.3) net-protocol nio4r (2.5.8) - nokogiri (1.13.9-x86_64-linux) + nokogiri (1.13.9) + mini_portile2 (~> 2.8.0) racc (~> 1.4) public_suffix (5.0.0) puma (5.6.5) @@ -174,7 +176,8 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - sqlite3 (1.5.4-x86_64-linux) + sqlite3 (1.5.4) + mini_portile2 (~> 2.8.0) stimulus-rails (1.1.1) railties (>= 6.0.0) tailwindcss-rails (2.0.21-x86_64-linux) @@ -226,7 +229,7 @@ DEPENDENCIES webdrivers RUBY VERSION - ruby 3.1.2p20 + ruby 3.2.0p0 BUNDLED WITH 2.3.26 -- 2.45.2 From e0a49ba5b78ea106842f27d27589946336b70965 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Mon, 6 Mar 2023 23:03:49 -0500 Subject: [PATCH 02/11] Bump puma --- Gemfile | 43 +------------------------------------------ Gemfile.lock | 5 ++--- 2 files changed, 3 insertions(+), 45 deletions(-) diff --git a/Gemfile b/Gemfile index 446e25c..a1055d5 100644 --- a/Gemfile +++ b/Gemfile @@ -3,69 +3,28 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby "3.2.0" -# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" gem "rails", "~> 7.0.4" - -# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails] gem "sprockets-rails" - -# Use sqlite3 as the database for Active Record gem "sqlite3", "~> 1.4" - -# Use the Puma web server [https://github.com/puma/puma] -gem "puma", "~> 5.0" - -# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] +gem "puma" gem "importmap-rails" - -# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] gem "turbo-rails" - -# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] gem "stimulus-rails" - -# Build JSON APIs with ease [https://github.com/rails/jbuilder] gem "jbuilder" -# Use Redis adapter to run Action Cable in production -# gem "redis", "~> 4.0" - -# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis] -# gem "kredis" - -# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] -# gem "bcrypt", "~> 3.1.7" - -# Windows does not include zoneinfo files, so bundle the tzinfo-data gem -gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ] - -# Reduces boot times through caching; required in config/boot.rb gem "bootsnap", require: false -# Use Sass to process CSS -# gem "sassc-rails" - -# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] # gem "image_processing", "~> 1.2" group :development, :test do - # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem gem "debug", platforms: %i[ mri mingw x64_mingw ] end group :development do - # Use console on exceptions pages [https://github.com/rails/web-console] gem "web-console" - - # Add speed badges [https://github.com/MiniProfiler/rack-mini-profiler] - # gem "rack-mini-profiler" - - # Speed up commands on slow machines / big apps [https://github.com/rails/spring] - # gem "spring" end group :test do - # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] gem "capybara" gem "selenium-webdriver" gem "webdrivers" diff --git a/Gemfile.lock b/Gemfile.lock index 9d2a086..cdb5478 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -126,7 +126,7 @@ GEM mini_portile2 (~> 2.8.0) racc (~> 1.4) public_suffix (5.0.0) - puma (5.6.5) + puma (6.1.1) nio4r (~> 2.0) racc (1.6.0) rack (2.2.4) @@ -216,7 +216,7 @@ DEPENDENCIES debug importmap-rails jbuilder - puma (~> 5.0) + puma rails (~> 7.0.4) selenium-webdriver sprockets-rails @@ -224,7 +224,6 @@ DEPENDENCIES stimulus-rails tailwindcss-rails (~> 2.0) turbo-rails - tzinfo-data web-console webdrivers -- 2.45.2 From ecb3a2659633b69f0f5a782881acda4d14e5827a Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Mon, 6 Mar 2023 23:05:06 -0500 Subject: [PATCH 03/11] Bump sqlite3 --- Gemfile | 2 +- Gemfile.lock | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Gemfile b/Gemfile index a1055d5..08459be 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,7 @@ ruby "3.2.0" gem "rails", "~> 7.0.4" gem "sprockets-rails" -gem "sqlite3", "~> 1.4" +gem "sqlite3" gem "puma" gem "importmap-rails" gem "turbo-rails" diff --git a/Gemfile.lock b/Gemfile.lock index cdb5478..e741d5e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -176,8 +176,7 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - sqlite3 (1.5.4) - mini_portile2 (~> 2.8.0) + sqlite3 (1.6.1-x86_64-linux) stimulus-rails (1.1.1) railties (>= 6.0.0) tailwindcss-rails (2.0.21-x86_64-linux) @@ -220,7 +219,7 @@ DEPENDENCIES rails (~> 7.0.4) selenium-webdriver sprockets-rails - sqlite3 (~> 1.4) + sqlite3 stimulus-rails tailwindcss-rails (~> 2.0) turbo-rails -- 2.45.2 From bb13e4579378b7127b58f7c9a64afee54c23d105 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Mon, 6 Mar 2023 23:05:36 -0500 Subject: [PATCH 04/11] Bump Rails --- Gemfile | 2 +- Gemfile.lock | 133 ++++++++++++++++++++++++++------------------------- 2 files changed, 69 insertions(+), 66 deletions(-) diff --git a/Gemfile b/Gemfile index 08459be..792f5cb 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby "3.2.0" -gem "rails", "~> 7.0.4" +gem "rails", "7.0.4.2" gem "sprockets-rails" gem "sqlite3" gem "puma" diff --git a/Gemfile.lock b/Gemfile.lock index e741d5e..c0a9e2c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,67 +1,67 @@ GEM remote: https://rubygems.org/ specs: - actioncable (7.0.4) - actionpack (= 7.0.4) - activesupport (= 7.0.4) + actioncable (7.0.4.2) + actionpack (= 7.0.4.2) + activesupport (= 7.0.4.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (7.0.4) - actionpack (= 7.0.4) - activejob (= 7.0.4) - activerecord (= 7.0.4) - activestorage (= 7.0.4) - activesupport (= 7.0.4) + actionmailbox (7.0.4.2) + actionpack (= 7.0.4.2) + activejob (= 7.0.4.2) + activerecord (= 7.0.4.2) + activestorage (= 7.0.4.2) + activesupport (= 7.0.4.2) mail (>= 2.7.1) net-imap net-pop net-smtp - actionmailer (7.0.4) - actionpack (= 7.0.4) - actionview (= 7.0.4) - activejob (= 7.0.4) - activesupport (= 7.0.4) + actionmailer (7.0.4.2) + actionpack (= 7.0.4.2) + actionview (= 7.0.4.2) + activejob (= 7.0.4.2) + activesupport (= 7.0.4.2) mail (~> 2.5, >= 2.5.4) net-imap net-pop net-smtp rails-dom-testing (~> 2.0) - actionpack (7.0.4) - actionview (= 7.0.4) - activesupport (= 7.0.4) + actionpack (7.0.4.2) + actionview (= 7.0.4.2) + activesupport (= 7.0.4.2) rack (~> 2.0, >= 2.2.0) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (7.0.4) - actionpack (= 7.0.4) - activerecord (= 7.0.4) - activestorage (= 7.0.4) - activesupport (= 7.0.4) + actiontext (7.0.4.2) + actionpack (= 7.0.4.2) + activerecord (= 7.0.4.2) + activestorage (= 7.0.4.2) + activesupport (= 7.0.4.2) globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (7.0.4) - activesupport (= 7.0.4) + actionview (7.0.4.2) + activesupport (= 7.0.4.2) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (7.0.4) - activesupport (= 7.0.4) + activejob (7.0.4.2) + activesupport (= 7.0.4.2) globalid (>= 0.3.6) - activemodel (7.0.4) - activesupport (= 7.0.4) - activerecord (7.0.4) - activemodel (= 7.0.4) - activesupport (= 7.0.4) - activestorage (7.0.4) - actionpack (= 7.0.4) - activejob (= 7.0.4) - activerecord (= 7.0.4) - activesupport (= 7.0.4) + activemodel (7.0.4.2) + activesupport (= 7.0.4.2) + activerecord (7.0.4.2) + activemodel (= 7.0.4.2) + activesupport (= 7.0.4.2) + activestorage (7.0.4.2) + actionpack (= 7.0.4.2) + activejob (= 7.0.4.2) + activerecord (= 7.0.4.2) + activesupport (= 7.0.4.2) marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (7.0.4) + activesupport (7.0.4.2) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -84,6 +84,7 @@ GEM childprocess (4.1.0) concurrent-ruby (1.1.10) crass (1.0.6) + date (3.3.3) debug (1.6.3) irb (>= 1.3.6) reline (>= 0.3.1) @@ -101,29 +102,31 @@ GEM jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) - loofah (2.19.0) + loofah (2.19.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.7.1) + mail (2.8.1) mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) mini_mime (1.1.2) - mini_portile2 (2.8.1) minitest (5.16.3) msgpack (1.6.0) - net-imap (0.3.1) + net-imap (0.3.4) + date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.1.3) + net-protocol (0.2.1) timeout net-smtp (0.3.3) net-protocol nio4r (2.5.8) - nokogiri (1.13.9) - mini_portile2 (~> 2.8.0) + nokogiri (1.14.2-x86_64-linux) racc (~> 1.4) public_suffix (5.0.0) puma (6.1.1) @@ -132,28 +135,28 @@ GEM rack (2.2.4) rack-test (2.0.2) rack (>= 1.3) - rails (7.0.4) - actioncable (= 7.0.4) - actionmailbox (= 7.0.4) - actionmailer (= 7.0.4) - actionpack (= 7.0.4) - actiontext (= 7.0.4) - actionview (= 7.0.4) - activejob (= 7.0.4) - activemodel (= 7.0.4) - activerecord (= 7.0.4) - activestorage (= 7.0.4) - activesupport (= 7.0.4) + rails (7.0.4.2) + actioncable (= 7.0.4.2) + actionmailbox (= 7.0.4.2) + actionmailer (= 7.0.4.2) + actionpack (= 7.0.4.2) + actiontext (= 7.0.4.2) + actionview (= 7.0.4.2) + activejob (= 7.0.4.2) + activemodel (= 7.0.4.2) + activerecord (= 7.0.4.2) + activestorage (= 7.0.4.2) + activesupport (= 7.0.4.2) bundler (>= 1.15.0) - railties (= 7.0.4) + railties (= 7.0.4.2) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.4.3) - loofah (~> 2.3) - railties (7.0.4) - actionpack (= 7.0.4) - activesupport (= 7.0.4) + rails-html-sanitizer (1.5.0) + loofah (~> 2.19, >= 2.19.1) + railties (7.0.4.2) + actionpack (= 7.0.4.2) + activesupport (= 7.0.4.2) method_source rake (>= 12.2) thor (~> 1.0) @@ -182,8 +185,8 @@ GEM tailwindcss-rails (2.0.21-x86_64-linux) railties (>= 6.0.0) thor (1.2.1) - timeout (0.3.0) - turbo-rails (1.3.2) + timeout (0.3.2) + turbo-rails (1.4.0) actionpack (>= 6.0.0) activejob (>= 6.0.0) railties (>= 6.0.0) @@ -216,7 +219,7 @@ DEPENDENCIES importmap-rails jbuilder puma - rails (~> 7.0.4) + rails (= 7.0.4.2) selenium-webdriver sprockets-rails sqlite3 -- 2.45.2 From fe99fbc9deecdfc447a2cf57db59b9eb8400a652 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Tue, 7 Mar 2023 22:08:02 -0500 Subject: [PATCH 05/11] Make the test suite pass --- app/models/member.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/models/member.rb b/app/models/member.rb index c8aad4b..6231711 100644 --- a/app/models/member.rb +++ b/app/models/member.rb @@ -1,5 +1,5 @@ class Member < ApplicationRecord - has_many :incomes + has_many :incomes, dependent: :destroy def income incomes.sum(&:amount) @@ -15,6 +15,8 @@ class Member < ApplicationRecord def burden_percent ((Income.total - others_included_income) / Income.total).round(2) + rescue + 0 end def burden_amount(total_amount: Expense.monthly_total) -- 2.45.2 From 91e2a5f4ffce664c6254630e4b3ee3b702e3cc05 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Tue, 7 Mar 2023 22:09:33 -0500 Subject: [PATCH 06/11] Add standardrb --- Gemfile | 3 +- Gemfile.lock | 29 +++++++++++++++++++ .../credit_card_bills_controller.rb | 19 ++++++------ app/controllers/expenses_controller.rb | 19 ++++++------ app/controllers/incomes_controller.rb | 19 ++++++------ app/controllers/members_controller.rb | 19 ++++++------ app/models/expense.rb | 2 +- config/environments/production.rb | 8 ++--- config/environments/test.rb | 2 +- config/puma.rb | 4 +-- .../credit_card_bills_controller_test.rb | 4 +-- test/controllers/expenses_controller_test.rb | 4 +-- test/controllers/incomes_controller_test.rb | 4 +-- test/controllers/members_controller_test.rb | 4 +-- 14 files changed, 87 insertions(+), 53 deletions(-) diff --git a/Gemfile b/Gemfile index 792f5cb..f9b353a 100644 --- a/Gemfile +++ b/Gemfile @@ -17,10 +17,11 @@ gem "bootsnap", require: false # gem "image_processing", "~> 1.2" group :development, :test do - gem "debug", platforms: %i[ mri mingw x64_mingw ] + gem "debug", platforms: %i[mri mingw x64_mingw] end group :development do + gem "standard" gem "web-console" end diff --git a/Gemfile.lock b/Gemfile.lock index c0a9e2c..f52c78a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -68,6 +68,7 @@ GEM tzinfo (~> 2.0) addressable (2.8.1) public_suffix (>= 2.0.2, < 6.0) + ast (2.4.2) bindex (0.8.1) bootsnap (1.14.0) msgpack (~> 1.2) @@ -102,6 +103,8 @@ GEM jbuilder (2.11.5) actionview (>= 5.0.0) activesupport (>= 5.0.0) + json (2.6.3) + language_server-protocol (3.17.0.3) loofah (2.19.1) crass (~> 1.0.2) nokogiri (>= 1.5.9) @@ -128,6 +131,9 @@ GEM nio4r (2.5.8) nokogiri (1.14.2-x86_64-linux) racc (~> 1.4) + parallel (1.22.1) + parser (3.2.1.1) + ast (~> 2.4.1) public_suffix (5.0.0) puma (6.1.1) nio4r (~> 2.0) @@ -161,11 +167,28 @@ GEM rake (>= 12.2) thor (~> 1.0) zeitwerk (~> 2.5) + rainbow (3.1.1) rake (13.0.6) regexp_parser (2.6.1) reline (0.3.1) io-console (~> 0.5) rexml (3.2.5) + rubocop (1.44.1) + json (~> 2.3) + parallel (~> 1.10) + 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.24.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.27.0) + parser (>= 3.2.1.0) + rubocop-performance (1.15.2) + rubocop (>= 1.7.0, < 2.0) + rubocop-ast (>= 0.4.0) + ruby-progressbar (1.13.0) rubyzip (2.3.2) selenium-webdriver (4.6.1) childprocess (>= 0.5, < 5.0) @@ -180,6 +203,10 @@ GEM activesupport (>= 5.2) sprockets (>= 3.0.0) sqlite3 (1.6.1-x86_64-linux) + standard (1.24.3) + language_server-protocol (~> 3.17.0.2) + rubocop (= 1.44.1) + rubocop-performance (= 1.15.2) stimulus-rails (1.1.1) railties (>= 6.0.0) tailwindcss-rails (2.0.21-x86_64-linux) @@ -192,6 +219,7 @@ GEM railties (>= 6.0.0) tzinfo (2.0.5) concurrent-ruby (~> 1.0) + unicode-display_width (2.4.2) web-console (4.2.0) actionview (>= 6.0.0) activemodel (>= 6.0.0) @@ -223,6 +251,7 @@ DEPENDENCIES selenium-webdriver sprockets-rails sqlite3 + standard stimulus-rails tailwindcss-rails (~> 2.0) turbo-rails diff --git a/app/controllers/credit_card_bills_controller.rb b/app/controllers/credit_card_bills_controller.rb index 8c41a88..d1f027a 100644 --- a/app/controllers/credit_card_bills_controller.rb +++ b/app/controllers/credit_card_bills_controller.rb @@ -1,5 +1,5 @@ class CreditCardBillsController < ApplicationController - before_action :set_credit_card_bill, only: %i[ show edit update destroy ] + before_action :set_credit_card_bill, only: %i[show edit update destroy] # GET /credit_card_bills or /credit_card_bills.json def index @@ -58,13 +58,14 @@ class CreditCardBillsController < ApplicationController end private - # Use callbacks to share common setup or constraints between actions. - def set_credit_card_bill - @credit_card_bill = CreditCardBill.find(params[:id]) - end - # Only allow a list of trusted parameters through. - def credit_card_bill_params - params.require(:credit_card_bill).permit(:description, :amount) - end + # Use callbacks to share common setup or constraints between actions. + def set_credit_card_bill + @credit_card_bill = CreditCardBill.find(params[:id]) + end + + # Only allow a list of trusted parameters through. + def credit_card_bill_params + params.require(:credit_card_bill).permit(:description, :amount) + end end diff --git a/app/controllers/expenses_controller.rb b/app/controllers/expenses_controller.rb index 34fb814..e5aa320 100644 --- a/app/controllers/expenses_controller.rb +++ b/app/controllers/expenses_controller.rb @@ -1,5 +1,5 @@ class ExpensesController < ApplicationController - before_action :set_expense, only: %i[ show edit update destroy ] + before_action :set_expense, only: %i[show edit update destroy] # GET /expenses or /expenses.json def index @@ -58,13 +58,14 @@ class ExpensesController < ApplicationController end private - # Use callbacks to share common setup or constraints between actions. - def set_expense - @expense = Expense.find(params[:id]) - end - # Only allow a list of trusted parameters through. - def expense_params - params.require(:expense).permit(:description, :payment, :period, :credit_card, :estimated) - end + # Use callbacks to share common setup or constraints between actions. + def set_expense + @expense = Expense.find(params[:id]) + end + + # Only allow a list of trusted parameters through. + def expense_params + params.require(:expense).permit(:description, :payment, :period, :credit_card, :estimated) + end end diff --git a/app/controllers/incomes_controller.rb b/app/controllers/incomes_controller.rb index 2623267..c7cee9e 100644 --- a/app/controllers/incomes_controller.rb +++ b/app/controllers/incomes_controller.rb @@ -1,5 +1,5 @@ class IncomesController < ApplicationController - before_action :set_income, only: %i[ show edit update destroy ] + before_action :set_income, only: %i[show edit update destroy] # GET /incomes or /incomes.json def index @@ -58,13 +58,14 @@ class IncomesController < ApplicationController end private - # Use callbacks to share common setup or constraints between actions. - def set_income - @income = Income.find(params[:id]) - end - # Only allow a list of trusted parameters through. - def income_params - params.require(:income).permit(:description, :included, :amount, :member_id) - end + # Use callbacks to share common setup or constraints between actions. + def set_income + @income = Income.find(params[:id]) + end + + # Only allow a list of trusted parameters through. + def income_params + params.require(:income).permit(:description, :included, :amount, :member_id) + end end diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index 6052ca8..647cec5 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -1,5 +1,5 @@ class MembersController < ApplicationController - before_action :set_member, only: %i[ show edit update destroy ] + before_action :set_member, only: %i[show edit update destroy] # GET /members or /members.json def index @@ -58,13 +58,14 @@ class MembersController < ApplicationController end private - # Use callbacks to share common setup or constraints between actions. - def set_member - @member = Member.find(params[:id]) - end - # Only allow a list of trusted parameters through. - def member_params - params.require(:member).permit(:name, :pays) - end + # Use callbacks to share common setup or constraints between actions. + def set_member + @member = Member.find(params[:id]) + end + + # Only allow a list of trusted parameters through. + def member_params + params.require(:member).permit(:name, :pays) + end end diff --git a/app/models/expense.rb b/app/models/expense.rb index 3e38e34..9f7c413 100644 --- a/app/models/expense.rb +++ b/app/models/expense.rb @@ -3,7 +3,7 @@ class Expense < ApplicationRecord monthly: 12, annually: 1, weekly: 52, - quarterly: 4, + quarterly: 4 }.freeze enum :period, PERIOD_OCCURENCES.keys diff --git a/config/environments/production.rb b/config/environments/production.rb index 3196e5f..b75b764 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -13,7 +13,7 @@ Rails.application.configure do config.eager_load = true # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false + config.consider_all_requests_local = false config.action_controller.perform_caching = true # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] @@ -53,7 +53,7 @@ Rails.application.configure do config.log_level = :info # Prepend all log lines with the following tags. - config.log_tags = [ :request_id ] + config.log_tags = [:request_id] # Use a different cache store in production. # config.cache_store = :mem_cache_store @@ -83,9 +83,9 @@ Rails.application.configure do # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name") if ENV["RAILS_LOG_TO_STDOUT"].present? - logger = ActiveSupport::Logger.new(STDOUT) + logger = ActiveSupport::Logger.new($stdout) logger.formatter = config.log_formatter - config.logger = ActiveSupport::TaggedLogging.new(logger) + config.logger = ActiveSupport::TaggedLogging.new(logger) end # Do not dump schema after migrations. diff --git a/config/environments/test.rb b/config/environments/test.rb index 6ea4d1e..9de8427 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -23,7 +23,7 @@ Rails.application.configure do } # Show full error reports and disable caching. - config.consider_all_requests_local = true + config.consider_all_requests_local = true config.action_controller.perform_caching = false config.cache_store = :null_store diff --git a/config/puma.rb b/config/puma.rb index daaf036..ce4878f 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -4,7 +4,7 @@ # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum; this matches the default thread size of Active Record. # -max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5) min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } threads min_threads_count, max_threads_count @@ -15,7 +15,7 @@ worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" # Specifies the `port` that Puma will listen on to receive requests; default is 3000. # -port ENV.fetch("PORT") { 3000 } +port ENV.fetch("PORT", 3000) # Specifies the `environment` that Puma will run in. # diff --git a/test/controllers/credit_card_bills_controller_test.rb b/test/controllers/credit_card_bills_controller_test.rb index 85a7106..6f4a29c 100644 --- a/test/controllers/credit_card_bills_controller_test.rb +++ b/test/controllers/credit_card_bills_controller_test.rb @@ -17,7 +17,7 @@ class CreditCardBillsControllerTest < ActionDispatch::IntegrationTest test "should create credit_card_bill" do assert_difference("CreditCardBill.count") do - post credit_card_bills_url, params: { credit_card_bill: { amount: @credit_card_bill.amount, description: @credit_card_bill.description } } + post credit_card_bills_url, params: {credit_card_bill: {amount: @credit_card_bill.amount, description: @credit_card_bill.description}} end assert_redirected_to credit_card_bill_url(CreditCardBill.last) @@ -34,7 +34,7 @@ class CreditCardBillsControllerTest < ActionDispatch::IntegrationTest end test "should update credit_card_bill" do - patch credit_card_bill_url(@credit_card_bill), params: { credit_card_bill: { amount: @credit_card_bill.amount, description: @credit_card_bill.description } } + patch credit_card_bill_url(@credit_card_bill), params: {credit_card_bill: {amount: @credit_card_bill.amount, description: @credit_card_bill.description}} assert_redirected_to credit_card_bill_url(@credit_card_bill) end diff --git a/test/controllers/expenses_controller_test.rb b/test/controllers/expenses_controller_test.rb index 49c2498..4f218a6 100644 --- a/test/controllers/expenses_controller_test.rb +++ b/test/controllers/expenses_controller_test.rb @@ -17,7 +17,7 @@ class ExpensesControllerTest < ActionDispatch::IntegrationTest test "should create expense" do assert_difference("Expense.count") do - post expenses_url, params: { expense: { credit_card: @expense.credit_card, description: @expense.description, estimated: @expense.estimated, payment: @expense.payment, period: @expense.period } } + post expenses_url, params: {expense: {credit_card: @expense.credit_card, description: @expense.description, estimated: @expense.estimated, payment: @expense.payment, period: @expense.period}} end assert_redirected_to expense_url(Expense.last) @@ -34,7 +34,7 @@ class ExpensesControllerTest < ActionDispatch::IntegrationTest end test "should update expense" do - patch expense_url(@expense), params: { expense: { credit_card: @expense.credit_card, description: @expense.description, estimated: @expense.estimated, payment: @expense.payment, period: @expense.period } } + patch expense_url(@expense), params: {expense: {credit_card: @expense.credit_card, description: @expense.description, estimated: @expense.estimated, payment: @expense.payment, period: @expense.period}} assert_redirected_to expense_url(@expense) end diff --git a/test/controllers/incomes_controller_test.rb b/test/controllers/incomes_controller_test.rb index cb07fbd..361a2f4 100644 --- a/test/controllers/incomes_controller_test.rb +++ b/test/controllers/incomes_controller_test.rb @@ -17,7 +17,7 @@ class IncomesControllerTest < ActionDispatch::IntegrationTest test "should create income" do assert_difference("Income.count") do - post incomes_url, params: { income: { amount: @income.amount, description: @income.description, included: @income.included, member_id: @income.member_id } } + post incomes_url, params: {income: {amount: @income.amount, description: @income.description, included: @income.included, member_id: @income.member_id}} end assert_redirected_to income_url(Income.last) @@ -34,7 +34,7 @@ class IncomesControllerTest < ActionDispatch::IntegrationTest end test "should update income" do - patch income_url(@income), params: { income: { amount: @income.amount, description: @income.description, included: @income.included, member_id: @income.member_id } } + patch income_url(@income), params: {income: {amount: @income.amount, description: @income.description, included: @income.included, member_id: @income.member_id}} assert_redirected_to income_url(@income) end diff --git a/test/controllers/members_controller_test.rb b/test/controllers/members_controller_test.rb index ac2b771..c04df44 100644 --- a/test/controllers/members_controller_test.rb +++ b/test/controllers/members_controller_test.rb @@ -17,7 +17,7 @@ class MembersControllerTest < ActionDispatch::IntegrationTest test "should create member" do assert_difference("Member.count") do - post members_url, params: { member: { name: @member.name, pays: @member.pays } } + post members_url, params: {member: {name: @member.name, pays: @member.pays}} end assert_redirected_to member_url(Member.last) @@ -34,7 +34,7 @@ class MembersControllerTest < ActionDispatch::IntegrationTest end test "should update member" do - patch member_url(@member), params: { member: { name: @member.name, pays: @member.pays } } + patch member_url(@member), params: {member: {name: @member.name, pays: @member.pays}} assert_redirected_to member_url(@member) end -- 2.45.2 From 8da07b47b52be91765cb768835e4f1e6a3c0bad0 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Tue, 7 Mar 2023 22:20:44 -0500 Subject: [PATCH 07/11] First pass at a drone file --- .drone.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..fdea2db --- /dev/null +++ b/.drone.yml @@ -0,0 +1,40 @@ +name: default +kind: pipeline + +steps: +- name: install + image: ruby:3.2.0 + volumes: + - name: bundle + path: /usr/local/bundle + commands: + - bin/bundle install --jobs=3 --retry=3 + +- name: test + image: ruby:3.2.0 + volumes: + - name: bundle + path: /usr/local/bundle + commands: + - bin/rails test + +- name: autoload + image: ruby:3.2.0 + volumes: + - name: bundle + path: /usr/local/bundle + commands: + - bin/rails zeitwerk:check + +- name: lint + image: ruby:3.2.0 + volumes: + - name: bundle + path: /usr/local/bundle + commands: + - bin/bundle exec standardrb + + +volumes: +- name: bundle + temp: {} -- 2.45.2 From d23ff42ef3e9f9b194af1e69d6a360aa734c2a24 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Tue, 7 Mar 2023 22:30:25 -0500 Subject: [PATCH 08/11] Update bundler --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index f52c78a..1f5bece 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -262,4 +262,4 @@ RUBY VERSION ruby 3.2.0p0 BUNDLED WITH - 2.3.26 + 2.4.7 -- 2.45.2 From ce6d1339b1fcc16051a54b31e3a1db3e22359b88 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Tue, 7 Mar 2023 22:30:58 -0500 Subject: [PATCH 09/11] Reorder step run --- .drone.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.drone.yml b/.drone.yml index fdea2db..9de4461 100644 --- a/.drone.yml +++ b/.drone.yml @@ -10,14 +10,6 @@ steps: commands: - bin/bundle install --jobs=3 --retry=3 -- name: test - image: ruby:3.2.0 - volumes: - - name: bundle - path: /usr/local/bundle - commands: - - bin/rails test - - name: autoload image: ruby:3.2.0 volumes: @@ -34,6 +26,13 @@ steps: commands: - bin/bundle exec standardrb +- name: test + image: ruby:3.2.0 + volumes: + - name: bundle + path: /usr/local/bundle + commands: + - bin/rails test volumes: - name: bundle -- 2.45.2 From 0581459a2cae6f0fc17276474ae07b68652267da Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Tue, 7 Mar 2023 22:39:32 -0500 Subject: [PATCH 10/11] Parallelize --- .drone.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.drone.yml b/.drone.yml index 9de4461..ea7ce32 100644 --- a/.drone.yml +++ b/.drone.yml @@ -17,6 +17,8 @@ steps: path: /usr/local/bundle commands: - bin/rails zeitwerk:check + depends_on: + - install - name: lint image: ruby:3.2.0 @@ -25,6 +27,8 @@ steps: path: /usr/local/bundle commands: - bin/bundle exec standardrb + depends_on: + - install - name: test image: ruby:3.2.0 @@ -33,6 +37,8 @@ steps: path: /usr/local/bundle commands: - bin/rails test + depends_on: + - install volumes: - name: bundle -- 2.45.2 From d3d8c5ea3dbf7515e3a3be7e2fb29ca8d02022dd Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Wed, 8 Mar 2023 19:17:51 -0500 Subject: [PATCH 11/11] Try to precompile assets --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index ea7ce32..e214580 100644 --- a/.drone.yml +++ b/.drone.yml @@ -36,6 +36,7 @@ steps: - name: bundle path: /usr/local/bundle commands: + - bin/rails assets:precompile - bin/rails test depends_on: - install -- 2.45.2