The personal finance app for everyone
Change default valuation currency to that of the related account, not family (#728)
Jakub Kottnauer1108e4559679
diff --git a/app/controllers/valuations_controller.rb b/app/controllers/valuations_controller.rbindex c77d7067..1c2979ea 100644--- a/app/controllers/valuations_controller.rb+++ b/app/controllers/valuations_controller.rb@@ -4,7 +4,7 @@ class ValuationsController < ApplicationController@account = Current.family.accounts.find(params[:account_id])# TODO: placeholder logic until we have a better abstraction for trends- @valuation = @account.valuations.new(valuation_params.merge(currency: Current.family.currency))+ @valuation = @account.valuations.new(valuation_params.merge(currency: @account.currency))if @valuation.save@valuation.account.sync_later(@valuation.date)diff --git a/test/controllers/valuations_controller_test.rb b/test/controllers/valuations_controller_test.rbindex 43fc7b6b..bd7e476e 100644--- a/test/controllers/valuations_controller_test.rb+++ b/test/controllers/valuations_controller_test.rb@@ -20,6 +20,12 @@ class ValuationsControllerTest < ActionDispatch::IntegrationTestassert_redirected_to account_path(@valuation.account)end+ test "should create valuation with account's currency" do+ foreign_account = accounts(:eur_checking)+ post account_valuations_url(foreign_account), params: { valuation: { value: 1, date: Date.current, type: "Appraisal" } }+ assert_equal foreign_account.currency, Valuation.order(created_at: :desc).first.currency+ end+test "create should sync account with correct start date" dodate = Date.current - 1.day