1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-06 05:55:21 +02:00

Test fixes

This commit is contained in:
Zach Gollwitzer 2025-07-08 13:03:40 -04:00
parent 018310d4d1
commit 2e09d1a8c0
10 changed files with 126 additions and 25 deletions

View file

@ -8,26 +8,26 @@ class Api::V1::TransactionsControllerTest < ActionDispatch::IntegrationTest
@family = @user.family
@account = @family.accounts.first
@transaction = @family.transactions.first
# Destroy existing active API keys to avoid validation errors
@user.api_keys.active.destroy_all
# Create fresh API keys instead of using fixtures to avoid parallel test conflicts
@api_key = ApiKey.create!(
user: @user,
name: "Test Read-Write Key",
scopes: ["read_write"],
scopes: [ "read_write" ],
display_key: "test_rw_#{SecureRandom.hex(8)}"
)
@read_only_api_key = ApiKey.create!(
user: @user,
name: "Test Read-Only Key",
scopes: ["read"],
name: "Test Read-Only Key",
scopes: [ "read" ],
display_key: "test_ro_#{SecureRandom.hex(8)}",
source: "mobile" # Use different source to allow multiple keys
)
# Clear any existing rate limit data
Redis.new.del("api_rate_limit:#{@api_key.id}")
Redis.new.del("api_rate_limit:#{@read_only_api_key.id}")

View file

@ -11,8 +11,8 @@ class CreditCardsControllerTest < ActionDispatch::IntegrationTest
test "creates with credit card details" do
assert_difference -> { Account.count } => 1,
-> { CreditCard.count } => 1,
-> { Valuation.count } => 2,
-> { Entry.count } => 2 do
-> { Valuation.count } => 1,
-> { Entry.count } => 1 do
post credit_cards_path, params: {
account: {
name: "New Credit Card",

View file

@ -11,8 +11,8 @@ class LoansControllerTest < ActionDispatch::IntegrationTest
test "creates with loan details" do
assert_difference -> { Account.count } => 1,
-> { Loan.count } => 1,
-> { Valuation.count } => 2,
-> { Entry.count } => 2 do
-> { Valuation.count } => 1,
-> { Entry.count } => 1 do
post loans_path, params: {
account: {
name: "New Loan",

View file

@ -23,7 +23,7 @@ class ValuationsControllerTest < ActionDispatch::IntegrationTest
end
created_entry = Entry.order(created_at: :desc).first
assert_equal "Manual account value update", created_entry.name
assert_equal "Manual value update", created_entry.name
assert_equal Date.current, created_entry.date
assert_equal account.balance + 100, created_entry.amount_money.to_f

View file

@ -11,8 +11,8 @@ class VehiclesControllerTest < ActionDispatch::IntegrationTest
test "creates with vehicle details" do
assert_difference -> { Account.count } => 1,
-> { Vehicle.count } => 1,
-> { Valuation.count } => 2,
-> { Entry.count } => 2 do
-> { Valuation.count } => 1,
-> { Entry.count } => 1 do
post vehicles_path, params: {
account: {
name: "Vehicle",