Skip to content

Commit

Permalink
Make transaction explicitly a deposit
Browse files Browse the repository at this point in the history
- Fix spec to be more explicit
  • Loading branch information
jonny5 committed Jun 1, 2024
1 parent f9bdd0c commit cb649ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 5 additions & 1 deletion app/controllers/admin/students_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ def update
def create_portfolio_transaction!
return unless fund_amount.present?

PortfolioTransaction.create!(portfolio: requested_resource.portfolio, amount: fund_amount) if fund_amount
PortfolioTransaction.create!(
portfolio: requested_resource.portfolio,
amount: fund_amount,
transaction_type: 'deposit'
)
end

def fund_amount
Expand Down
5 changes: 1 addition & 4 deletions test/controllers/admin/students_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Admin::StudentsControllerTest < ActionDispatch::IntegrationTest

transaction = PortfolioTransaction.last

assert_equal 'deposit', transaction.transaction_type
assert_equal 10.50, transaction.amount
assert_equal @student.reload.portfolio.portfolio_transactions.last, transaction

Expand All @@ -43,9 +44,5 @@ class Admin::StudentsControllerTest < ActionDispatch::IntegrationTest
assert_difference('PortfolioTransaction.count', 0) do
patch admin_student_url(@student), params: { student: { add_fund_amount: '' } }
end

transaction = PortfolioTransaction.last

assert_equal nil, transaction.amount
end
end

0 comments on commit cb649ea

Please sign in to comment.