Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zachgoll committed Dec 19, 2024
1 parent f07ccea commit 8dc706d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 28 deletions.
1 change: 1 addition & 0 deletions app/models/account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def update_balance!(balance)
else
entries.create! \
date: Date.current,
name: "Balance update",
amount: balance,
currency: currency,
entryable: Account::Valuation.new
Expand Down
1 change: 1 addition & 0 deletions app/views/account/valuations/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<% end %>

<div class="space-y-3">
<%= form.hidden_field :name, value: "Balance update" %>
<%= form.date_field :date, label: true, required: true, value: Date.current, min: Account::Entry.min_supported_date, max: Date.current %>
<%= form.money_field :amount, label: t(".amount"), required: true %>
</div>
Expand Down
48 changes: 24 additions & 24 deletions config/brakeman.ignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,29 @@
],
"note": ""
},
{
"warning_type": "Mass Assignment",
"warning_code": 105,
"fingerprint": "5bfdb129316655dc4e02f3a599156660414a6562212a5f61057d376f6888f078",
"check_name": "PermitAttributes",
"message": "Potentially dangerous key allowed for mass assignment",
"file": "app/controllers/concerns/entryable_resource.rb",
"line": 122,
"link": "https://brakemanscanner.org/docs/warning_types/mass_assignment/",
"code": "params.require(:account_entry).permit(:account_id, :name, :enriched_name, :date, :amount, :currency, :excluded, :notes, :nature, :entryable_attributes => self.class.permitted_entryable_attributes)",
"render_path": null,
"location": {
"type": "method",
"class": "EntryableResource",
"method": "entry_params"
},
"user_input": ":account_id",
"confidence": "High",
"cwe_id": [
915
],
"note": ""
},
{
"warning_type": "Mass Assignment",
"warning_code": 105,
Expand Down Expand Up @@ -80,29 +103,6 @@
],
"note": ""
},
{
"warning_type": "Mass Assignment",
"warning_code": 105,
"fingerprint": "f158202dcc66f2273ddea5e5296bad7146a50ca6667f49c77372b5b234542334",
"check_name": "PermitAttributes",
"message": "Potentially dangerous key allowed for mass assignment",
"file": "app/controllers/concerns/entryable_resource.rb",
"line": 122,
"link": "https://brakemanscanner.org/docs/warning_types/mass_assignment/",
"code": "params.require(:account_entry).permit(:account_id, :name, :date, :amount, :currency, :excluded, :notes, :nature, :entryable_attributes => self.class.permitted_entryable_attributes)",
"render_path": null,
"location": {
"type": "method",
"class": "EntryableResource",
"method": "entry_params"
},
"user_input": ":account_id",
"confidence": "High",
"cwe_id": [
915
],
"note": ""
},
{
"warning_type": "Dynamic Render Path",
"warning_code": 15,
Expand Down Expand Up @@ -138,6 +138,6 @@
"note": ""
}
],
"updated": "2024-11-27 15:33:53 -0500",
"updated": "2024-12-18 17:46:13 -0500",
"brakeman_version": "6.2.2"
}
2 changes: 1 addition & 1 deletion test/interfaces/accountable_resource_interface_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ module AccountableResourceInterfaceTest
end

test "updates account balance by editing existing valuation for today" do
@account.entries.create! date: Date.current, amount: 6000, currency: "USD", entryable: Account::Valuation.new
@account.entries.create! date: Date.current, amount: 6000, currency: "USD", name: "Balance update", entryable: Account::Valuation.new

assert_no_difference [ "Account::Entry.count", "Account::Valuation.count" ] do
patch account_url(@account), params: {
Expand Down
6 changes: 3 additions & 3 deletions test/system/trades_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class TradesTest < ApplicationSystemTestCase
end

test "can create buy transaction" do
shares_qty = 25.0
shares_qty = 25

open_new_trade_modal

Expand All @@ -38,7 +38,7 @@ class TradesTest < ApplicationSystemTestCase
visit_account_trades

within_trades do
assert_text "Buy 10.0 shares of AAPL"
assert_text "Purchase 10 shares of AAPL"
assert_text "Buy #{shares_qty} shares of AAPL"
end
end
Expand All @@ -60,7 +60,7 @@ class TradesTest < ApplicationSystemTestCase
visit_account_trades

within_trades do
assert_text "Sell #{aapl.qty} shares of AAPL"
assert_text "Sell #{aapl.qty.round} shares of AAPL"
end
end

Expand Down

0 comments on commit 8dc706d

Please sign in to comment.