From 0ca7dfdf5d9e337869f464f244c1cc0445f819f5 Mon Sep 17 00:00:00 2001 From: Tony Yesudas Date: Sat, 14 Sep 2024 08:50:18 +0200 Subject: [PATCH 01/11] add error handling for vehicle and property account creation --- app/controllers/properties_controller.rb | 4 +++ app/controllers/vehicles_controller.rb | 4 +++ .../controllers/properties_controller_test.rb | 27 +++++++++++++++++++ test/controllers/vehicles_controller_test.rb | 21 +++++++++++++++ 4 files changed, 56 insertions(+) diff --git a/app/controllers/properties_controller.rb b/app/controllers/properties_controller.rb index b663b6ae..eaa7f494 100644 --- a/app/controllers/properties_controller.rb +++ b/app/controllers/properties_controller.rb @@ -11,12 +11,16 @@ class PropertiesController < ApplicationController account.sync_later redirect_to account, notice: t(".success") + rescue ActiveRecord::RecordInvalid => e + redirect_back_or_to accounts_path, alert: e.record.errors.full_messages.to_sentence end def update @account.update!(account_params) @account.sync_later redirect_to @account, notice: t(".success") + rescue ActiveRecord::RecordInvalid => e + redirect_back_or_to account_path(@account), alert: e.record.errors.full_messages.to_sentence end private diff --git a/app/controllers/vehicles_controller.rb b/app/controllers/vehicles_controller.rb index b2d81ed6..a9c01f5e 100644 --- a/app/controllers/vehicles_controller.rb +++ b/app/controllers/vehicles_controller.rb @@ -11,12 +11,16 @@ class VehiclesController < ApplicationController account.sync_later redirect_to account, notice: t(".success") + rescue ActiveRecord::RecordInvalid => e + redirect_back_or_to accounts_path, alert: e.record.errors.full_messages.to_sentence end def update @account.update!(account_params) @account.sync_later redirect_to @account, notice: t(".success") + rescue ActiveRecord::RecordInvalid => e + redirect_back_or_to account_path(@account), alert: e.record.errors.full_messages.to_sentence end private diff --git a/test/controllers/properties_controller_test.rb b/test/controllers/properties_controller_test.rb index c2debe3e..4e264485 100644 --- a/test/controllers/properties_controller_test.rb +++ b/test/controllers/properties_controller_test.rb @@ -46,6 +46,33 @@ class PropertiesControllerTest < ActionDispatch::IntegrationTest assert_enqueued_with(job: AccountSyncJob) end + test "handles erors when creating property" do + assert_no_difference [ "Account.count", "Property.count", "Account::Valuation.count", "Account::Entry.count" ] do + post properties_path, params: { + account: { + name: "Property", + currency: "USD", + accountable_type: "Property", + accountable_attributes: { + year_built: 2002, + area_value: 1000, + area_unit: "sqft", + address_attributes: { + line1: "123 Main St", + line2: "Apt 1", + locality: "Los Angeles", + region: "CA", + country: "US", + postal_code: "90001" + } + } + } + } + assert_redirected_to accounts_path + assert_equal "Balance can't be blank and Entries is invalid", flash[:alert] + end + end + test "updates property" do assert_no_difference [ "Account.count", "Property.count", "Account::Valuation.count", "Account::Entry.count" ] do patch property_path(@account), params: { diff --git a/test/controllers/vehicles_controller_test.rb b/test/controllers/vehicles_controller_test.rb index 2aecb42f..7cd19367 100644 --- a/test/controllers/vehicles_controller_test.rb +++ b/test/controllers/vehicles_controller_test.rb @@ -43,6 +43,27 @@ class VehiclesControllerTest < ActionDispatch::IntegrationTest assert_enqueued_with(job: AccountSyncJob) end + test "handles errors when creating vehicle" do + assert_no_difference [ "Account.count", "Vehicle.count", "Account::Valuation.count", "Account::Entry.count" ] do + post vehicles_path, params: { + account: { + name: "Vehicle", + currency: "USD", + accountable_type: "Vehicle", + accountable_attributes: { + make: "Toyota", + model: "Camry", + year: 2020, + mileage_value: 15000, + mileage_unit: "mi" + } + } + } + end + assert_redirected_to accounts_path + assert_equal "Balance can't be blank and Entries is invalid", flash[:alert] + end + test "updates vehicle" do assert_no_difference [ "Account.count", "Vehicle.count", "Account::Valuation.count", "Account::Entry.count" ] do patch vehicle_path(@account), params: { -- 2.53.0 From 9bb9a062ac72a5df783de7986e2acecf02b5ee7f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 09:43:59 -0400 Subject: [PATCH 02/11] Bump pagy from 9.0.8 to 9.0.9 (#1186) Bumps [pagy](https://github.com/ddnexus/pagy) from 9.0.8 to 9.0.9. - [Release notes](https://github.com/ddnexus/pagy/releases) - [Changelog](https://github.com/ddnexus/pagy/blob/master/CHANGELOG.md) - [Commits](https://github.com/ddnexus/pagy/compare/9.0.8...9.0.9) --- updated-dependencies: - dependency-name: pagy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 8adb4ffa..54b8811f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -265,7 +265,7 @@ GEM octokit (9.1.0) faraday (>= 1, < 3) sawyer (~> 0.9) - pagy (9.0.8) + pagy (9.0.9) parallel (1.25.1) parser (3.3.4.0) ast (~> 2.4.1) -- 2.53.0 From cc1954b33bd7ab823a7a7034bc617d5ccffc4943 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 09:44:12 -0400 Subject: [PATCH 03/11] Bump aws-sdk-s3 from 1.160.0 to 1.162.0 (#1184) Bumps [aws-sdk-s3](https://github.com/aws/aws-sdk-ruby) from 1.160.0 to 1.162.0. - [Release notes](https://github.com/aws/aws-sdk-ruby/releases) - [Changelog](https://github.com/aws/aws-sdk-ruby/blob/version-3/gems/aws-sdk-s3/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-ruby/commits) --- updated-dependencies: - dependency-name: aws-sdk-s3 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 54b8811f..80083d26 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -82,17 +82,17 @@ GEM public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) aws-eventstream (1.3.0) - aws-partitions (1.971.0) - aws-sdk-core (3.203.0) + aws-partitions (1.975.0) + aws-sdk-core (3.205.0) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.651.0) aws-sigv4 (~> 1.9) jmespath (~> 1, >= 1.6.1) - aws-sdk-kms (1.89.0) - aws-sdk-core (~> 3, >= 3.203.0) + aws-sdk-kms (1.91.0) + aws-sdk-core (~> 3, >= 3.205.0) aws-sigv4 (~> 1.5) - aws-sdk-s3 (1.160.0) - aws-sdk-core (~> 3, >= 3.203.0) + aws-sdk-s3 (1.162.0) + aws-sdk-core (~> 3, >= 3.205.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.5) aws-sigv4 (1.9.1) -- 2.53.0 From 5a5e27685a5090b8540b0464c695f5ed8e420e9f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 10:13:49 -0400 Subject: [PATCH 04/11] Bump turbo-rails from 2.0.6 to 2.0.7 (#1185) Bumps [turbo-rails](https://github.com/hotwired/turbo-rails) from 2.0.6 to 2.0.7. - [Release notes](https://github.com/hotwired/turbo-rails/releases) - [Commits](https://github.com/hotwired/turbo-rails/compare/v2.0.6...v2.0.7) --- updated-dependencies: - dependency-name: turbo-rails dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 80083d26..e48fbf38 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -184,7 +184,7 @@ GEM actioncable (>= 6.0.0) listen (>= 3.0.0) railties (>= 6.0.0) - i18n (1.14.5) + i18n (1.14.6) concurrent-ruby (~> 1.0) i18n-tasks (1.0.14) activesupport (>= 4.0.2) @@ -429,7 +429,7 @@ GEM unicode-display_width (>= 1.1.1, < 3) thor (1.3.2) timeout (0.4.1) - turbo-rails (2.0.6) + turbo-rails (2.0.7) actionpack (>= 6.0.0) activejob (>= 6.0.0) railties (>= 6.0.0) -- 2.53.0 From 818178157022b5ecd771f7f5a59c5aded324f9e6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 10:14:06 -0400 Subject: [PATCH 05/11] Bump tailwindcss-rails from 2.7.3 to 2.7.4 (#1182) Bumps [tailwindcss-rails](https://github.com/rails/tailwindcss-rails) from 2.7.3 to 2.7.4. - [Release notes](https://github.com/rails/tailwindcss-rails/releases) - [Changelog](https://github.com/rails/tailwindcss-rails/blob/main/CHANGELOG.md) - [Commits](https://github.com/rails/tailwindcss-rails/compare/v2.7.3...v2.7.4) --- updated-dependencies: - dependency-name: tailwindcss-rails dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index e48fbf38..9de8433c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -413,17 +413,17 @@ GEM railties (>= 6.0.0) stringio (3.1.1) strscan (3.1.0) - tailwindcss-rails (2.7.3) + tailwindcss-rails (2.7.4) railties (>= 7.0.0) - tailwindcss-rails (2.7.3-aarch64-linux) + tailwindcss-rails (2.7.4-aarch64-linux) railties (>= 7.0.0) - tailwindcss-rails (2.7.3-arm-linux) + tailwindcss-rails (2.7.4-arm-linux) railties (>= 7.0.0) - tailwindcss-rails (2.7.3-arm64-darwin) + tailwindcss-rails (2.7.4-arm64-darwin) railties (>= 7.0.0) - tailwindcss-rails (2.7.3-x86_64-darwin) + tailwindcss-rails (2.7.4-x86_64-darwin) railties (>= 7.0.0) - tailwindcss-rails (2.7.3-x86_64-linux) + tailwindcss-rails (2.7.4-x86_64-linux) railties (>= 7.0.0) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) -- 2.53.0 From b7e3c61d094de4a5c8f4a4906ab68ca81db6a04c Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 10:23:54 -0400 Subject: [PATCH 06/11] Bump good_job from 4.2.1 to 4.3.0 (#1183) Bumps [good_job](https://github.com/bensheldon/good_job) from 4.2.1 to 4.3.0. - [Release notes](https://github.com/bensheldon/good_job/releases) - [Changelog](https://github.com/bensheldon/good_job/blob/main/CHANGELOG.md) - [Commits](https://github.com/bensheldon/good_job/compare/v4.2.1...v4.3.0) --- updated-dependencies: - dependency-name: good_job dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 9de8433c..62f69852 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -171,7 +171,7 @@ GEM raabro (~> 1.4) globalid (1.2.1) activesupport (>= 6.1) - good_job (4.2.1) + good_job (4.3.0) activejob (>= 6.1.0) activerecord (>= 6.1.0) concurrent-ruby (>= 1.3.1) -- 2.53.0 From fc0bc1ac961c6d878ffa3fb87c6cb80425dc90f3 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 10:24:05 -0400 Subject: [PATCH 07/11] Bump ruby-lsp-rails from 0.3.13 to 0.3.14 (#1181) Bumps [ruby-lsp-rails](https://github.com/Shopify/ruby-lsp-rails) from 0.3.13 to 0.3.14. - [Release notes](https://github.com/Shopify/ruby-lsp-rails/releases) - [Commits](https://github.com/Shopify/ruby-lsp-rails/compare/v0.3.13...v0.3.14) --- updated-dependencies: - dependency-name: ruby-lsp-rails dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 62f69852..28054543 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -271,7 +271,7 @@ GEM ast (~> 2.4.1) racc pg (1.5.8) - prism (0.30.0) + prism (1.0.0) propshaft (0.9.1) actionpack (>= 7.0.0) activesupport (>= 7.0.0) @@ -332,7 +332,7 @@ GEM rb-fsevent (0.11.2) rb-inotify (0.11.1) ffi (~> 1.0) - rbs (3.5.2) + rbs (3.5.3) logger rdoc (6.7.0) psych (>= 4.0.0) @@ -371,12 +371,12 @@ GEM rubocop-minitest rubocop-performance rubocop-rails - ruby-lsp (0.17.13) + ruby-lsp (0.17.17) language_server-protocol (~> 3.17.0) - prism (>= 0.29.0, < 0.31) + prism (~> 1.0) rbs (>= 3, < 4) sorbet-runtime (>= 0.5.10782) - ruby-lsp-rails (0.3.13) + ruby-lsp-rails (0.3.14) ruby-lsp (>= 0.17.12, < 0.18.0) ruby-progressbar (1.13.0) ruby-vips (2.2.2) @@ -407,7 +407,7 @@ GEM simplecov-html (0.12.3) simplecov_json_formatter (0.1.4) smart_properties (1.17.0) - sorbet-runtime (0.5.11528) + sorbet-runtime (0.5.11558) stackprof (0.2.26) stimulus-rails (1.3.4) railties (>= 6.0.0) -- 2.53.0 From b8b8e61ff837291ebc5989b7410a8cc85274ac9f Mon Sep 17 00:00:00 2001 From: Tony Yesudas Date: Mon, 16 Sep 2024 16:57:55 +0200 Subject: [PATCH 08/11] Add required true for money_field --- app/helpers/forms_helper.rb | 3 ++- app/views/shared/_money_field.html.erb | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/helpers/forms_helper.rb b/app/helpers/forms_helper.rb index 19f75b29..c5d3d5d5 100644 --- a/app/helpers/forms_helper.rb +++ b/app/helpers/forms_helper.rb @@ -34,7 +34,8 @@ module FormsHelper default_currency: options[:default_currency] || "USD", disable_currency: options[:disable_currency] || false, hide_currency: options[:hide_currency] || false, - label: options[:label] || "Amount" + label: options[:label] || "Amount", + required: options[:required] || false } end diff --git a/app/views/shared/_money_field.html.erb b/app/views/shared/_money_field.html.erb index 14fe7e7b..ae863ff0 100644 --- a/app/views/shared/_money_field.html.erb +++ b/app/views/shared/_money_field.html.erb @@ -1,4 +1,4 @@ -<%# locals: (form:, money_method:, default_currency:, disable_currency: false, hide_currency: false, label: nil) %> +<%# locals: (form:, money_method:, default_currency:, disable_currency: false, hide_currency: false, label: nil, required: false) %> <% fallback_label = t(".money-label") %> <% currency = form.object ? (form.object.send(money_method)&.currency || Money::Currency.new(default_currency)) : Money::Currency.new(default_currency) %> @@ -9,7 +9,7 @@
<%= currency.symbol %> - <%= money_field form, money_method, { inline: true, "data-money-field-target" => "amount", default_currency: currency } %> + <%= money_field form, money_method, { inline: true, "data-money-field-target" => "amount", default_currency: currency, required: required } %>
<% unless hide_currency %>
-- 2.53.0 From fd4011126422023228a9295b2d9b30bb1b9402cb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Sep 2024 11:17:16 -0400 Subject: [PATCH 09/11] Bump propshaft from 0.9.1 to 1.0.0 (#1187) Bumps [propshaft](https://github.com/rails/propshaft) from 0.9.1 to 1.0.0. - [Release notes](https://github.com/rails/propshaft/releases) - [Commits](https://github.com/rails/propshaft/compare/v0.9.1...v1.0.0) --- updated-dependencies: - dependency-name: propshaft dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 28054543..f4ecd715 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -272,7 +272,7 @@ GEM racc pg (1.5.8) prism (1.0.0) - propshaft (0.9.1) + propshaft (1.0.0) actionpack (>= 7.0.0) activesupport (>= 7.0.0) rack -- 2.53.0 From aa6d755402f530fb3497cf2d2a998e9b618a2bc6 Mon Sep 17 00:00:00 2001 From: Zach Gollwitzer Date: Mon, 16 Sep 2024 19:18:07 -0400 Subject: [PATCH 10/11] Fix styles on import modal (#1188) * Fix styles on import modal * Remove stale translations --- app/views/imports/_type_selector.html.erb | 83 ++++++++--------------- config/locales/views/imports/en.yml | 6 +- 2 files changed, 31 insertions(+), 58 deletions(-) diff --git a/app/views/imports/_type_selector.html.erb b/app/views/imports/_type_selector.html.erb index 9f68c343..eac0476e 100644 --- a/app/views/imports/_type_selector.html.erb +++ b/app/views/imports/_type_selector.html.erb @@ -29,62 +29,37 @@
- + + <% end %> +
  • + <%= link_to new_import_path, class: "flex items-center gap-3 p-4 group cursor-pointer", data: { turbo: false } do %> +
    + <%= lucide_icon("file-spreadsheet", class: "w-5 h-5 text-indigo-500") %> +
    + + <%= t(".import_from_csv") %> + + <%= lucide_icon("chevron-right", class: "w-5 h-5 text-gray-500 ml-auto") %> <% end %> -
  • - <%= link_to new_import_path, class: "flex items-center gap-3 p-4 group cursor-pointer", data: { turbo: false } do %> -
    - <%= lucide_icon("file-spreadsheet", class: "w-5 h-5 text-indigo-500") %> -
    - - <%= t(".import_from_csv") %> - - <%= lucide_icon("chevron-right", class: "w-5 h-5 text-gray-500 ml-auto") %> - <% end %> -
    -
    -
    -
  • -
  • -
    - <%= image_tag("mint-logo.jpeg", alt: "Mint logo", class: "w-8 h-8 rounded-md") %> - - <%= t(".import_from_mint") %> - - <%= t(".soon") %> - <%= lucide_icon("chevron-right", class: "w-5 h-5 text-gray-300 ml-auto") %> -
    +
    +
    +
    +
  • +
  • +
    + <%= image_tag("mint-logo.jpeg", alt: "Mint logo", class: "w-8 h-8 rounded-md") %> + + <%= t(".import_from_mint") %> + + <%= t(".soon") %> + <%= lucide_icon("chevron-right", class: "w-5 h-5 text-gray-300 ml-auto") %> +
    -
    -
    -
    -
  • -
  • -
    - <%= image_tag("empower-logo.jpeg", alt: "Mint logo", class: "w-8 h-8 border border-alpha-black-100 rounded-md") %> - - <%= t(".import_from_empower") %> - - <%= t(".soon") %> - <%= lucide_icon("chevron-right", class: "w-5 h-5 text-gray-300 ml-auto") %> -
    - -
    -
    -
    -
  • -
  • -
    - <%= image_tag("apple-logo.png", alt: "Mint logo", class: "w-8 h-8 rounded-md") %> - - <%= t(".import_from_apple") %> - - <%= t(".soon") %> - <%= lucide_icon("chevron-right", class: "w-5 h-5 text-gray-300 ml-auto") %> -
    -
  • - +
    +
    +
    + +
    -
    diff --git a/config/locales/views/imports/en.yml b/config/locales/views/imports/en.yml index 37b11f4f..c459e2f5 100644 --- a/config/locales/views/imports/en.yml +++ b/config/locales/views/imports/en.yml @@ -95,11 +95,9 @@ en: import_published: Import has started in the background invalid_data: Your import is invalid type_selector: - description: You can manually import transactions from CSVs or from other financial - apps like Mint, Empower (formerly Personal Capital) or Apple Card. - import_from_apple: Import from Apple Card + description: You can manually import transactions from CSVs or other financial + apps like Mint. import_from_csv: New import from CSV - import_from_empower: Import from Empower import_from_mint: Import from Mint import_transactions: Import transactions resume_latest_import: Resume latest import -- 2.53.0 From 7a69dd8da198c2f2547218cfa3325a9839486fb7 Mon Sep 17 00:00:00 2001 From: Tony Yesudas Date: Tue, 17 Sep 2024 14:05:30 +0200 Subject: [PATCH 11/11] Remove rescue in controllers --- app/controllers/accounts_controller.rb | 2 -- app/controllers/properties_controller.rb | 4 --- app/controllers/vehicles_controller.rb | 4 --- app/views/accounts/_form.html.erb | 2 +- .../controllers/properties_controller_test.rb | 27 ------------------- test/controllers/vehicles_controller_test.rb | 21 --------------- 6 files changed, 1 insertion(+), 59 deletions(-) diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb index db54d17c..11b55ac6 100644 --- a/app/controllers/accounts_controller.rb +++ b/app/controllers/accounts_controller.rb @@ -58,8 +58,6 @@ class AccountsController < ApplicationController start_balance: account_params[:start_balance] @account.sync_later redirect_back_or_to account_path(@account), notice: t(".success") - rescue ActiveRecord::RecordInvalid => e - redirect_back_or_to accounts_path, alert: e.record.errors.full_messages.to_sentence end def destroy diff --git a/app/controllers/properties_controller.rb b/app/controllers/properties_controller.rb index eaa7f494..b663b6ae 100644 --- a/app/controllers/properties_controller.rb +++ b/app/controllers/properties_controller.rb @@ -11,16 +11,12 @@ class PropertiesController < ApplicationController account.sync_later redirect_to account, notice: t(".success") - rescue ActiveRecord::RecordInvalid => e - redirect_back_or_to accounts_path, alert: e.record.errors.full_messages.to_sentence end def update @account.update!(account_params) @account.sync_later redirect_to @account, notice: t(".success") - rescue ActiveRecord::RecordInvalid => e - redirect_back_or_to account_path(@account), alert: e.record.errors.full_messages.to_sentence end private diff --git a/app/controllers/vehicles_controller.rb b/app/controllers/vehicles_controller.rb index a9c01f5e..b2d81ed6 100644 --- a/app/controllers/vehicles_controller.rb +++ b/app/controllers/vehicles_controller.rb @@ -11,16 +11,12 @@ class VehiclesController < ApplicationController account.sync_later redirect_to account, notice: t(".success") - rescue ActiveRecord::RecordInvalid => e - redirect_back_or_to accounts_path, alert: e.record.errors.full_messages.to_sentence end def update @account.update!(account_params) @account.sync_later redirect_to @account, notice: t(".success") - rescue ActiveRecord::RecordInvalid => e - redirect_back_or_to account_path(@account), alert: e.record.errors.full_messages.to_sentence end private diff --git a/app/views/accounts/_form.html.erb b/app/views/accounts/_form.html.erb index 86ee96bd..ad537264 100644 --- a/app/views/accounts/_form.html.erb +++ b/app/views/accounts/_form.html.erb @@ -5,7 +5,7 @@ <%= f.hidden_field :accountable_type %> <%= f.text_field :name, placeholder: t(".name_placeholder"), required: "required", label: t(".name_label"), autofocus: true %> <%= f.collection_select :institution_id, Current.family.institutions.alphabetically, :id, :name, { include_blank: t(".ungrouped"), label: t(".institution") } %> - <%= money_with_currency_field f, :balance_money, label: t(".balance"), required: "required", default_currency: Current.family.currency %> + <%= money_with_currency_field f, :balance_money, label: t(".balance"), required: true, default_currency: Current.family.currency %> <% if account.new_record? %>
    diff --git a/test/controllers/properties_controller_test.rb b/test/controllers/properties_controller_test.rb index 4e264485..c2debe3e 100644 --- a/test/controllers/properties_controller_test.rb +++ b/test/controllers/properties_controller_test.rb @@ -46,33 +46,6 @@ class PropertiesControllerTest < ActionDispatch::IntegrationTest assert_enqueued_with(job: AccountSyncJob) end - test "handles erors when creating property" do - assert_no_difference [ "Account.count", "Property.count", "Account::Valuation.count", "Account::Entry.count" ] do - post properties_path, params: { - account: { - name: "Property", - currency: "USD", - accountable_type: "Property", - accountable_attributes: { - year_built: 2002, - area_value: 1000, - area_unit: "sqft", - address_attributes: { - line1: "123 Main St", - line2: "Apt 1", - locality: "Los Angeles", - region: "CA", - country: "US", - postal_code: "90001" - } - } - } - } - assert_redirected_to accounts_path - assert_equal "Balance can't be blank and Entries is invalid", flash[:alert] - end - end - test "updates property" do assert_no_difference [ "Account.count", "Property.count", "Account::Valuation.count", "Account::Entry.count" ] do patch property_path(@account), params: { diff --git a/test/controllers/vehicles_controller_test.rb b/test/controllers/vehicles_controller_test.rb index 7cd19367..2aecb42f 100644 --- a/test/controllers/vehicles_controller_test.rb +++ b/test/controllers/vehicles_controller_test.rb @@ -43,27 +43,6 @@ class VehiclesControllerTest < ActionDispatch::IntegrationTest assert_enqueued_with(job: AccountSyncJob) end - test "handles errors when creating vehicle" do - assert_no_difference [ "Account.count", "Vehicle.count", "Account::Valuation.count", "Account::Entry.count" ] do - post vehicles_path, params: { - account: { - name: "Vehicle", - currency: "USD", - accountable_type: "Vehicle", - accountable_attributes: { - make: "Toyota", - model: "Camry", - year: 2020, - mileage_value: 15000, - mileage_unit: "mi" - } - } - } - end - assert_redirected_to accounts_path - assert_equal "Balance can't be blank and Entries is invalid", flash[:alert] - end - test "updates vehicle" do assert_no_difference [ "Account.count", "Vehicle.count", "Account::Valuation.count", "Account::Entry.count" ] do patch vehicle_path(@account), params: { -- 2.53.0