File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ defmodule Algora.PaymentsTest do
18
18
{ :ok , user: user , account: account }
19
19
end
20
20
21
- test "executes transfer when there are pending credits " , % { user: user , account: account } do
21
+ test "executes transfer when user has positive balance " , % { user: user , account: account } do
22
22
insert ( :transaction ,
23
23
user: user ,
24
24
type: :credit ,
@@ -61,9 +61,20 @@ defmodule Algora.PaymentsTest do
61
61
assert Money . equal? ( transfer_tx . total_fee , Money . new ( 0 , :USD ) )
62
62
end
63
63
64
- test "does nothing when user has no pending credits" , % { user: user } do
64
+ test "does nothing when user has positive unconfirmed balance" , % { user: user } do
65
+ insert ( :transaction ,
66
+ user: user ,
67
+ type: :credit ,
68
+ status: :processing ,
69
+ net_amount: Money . new ( 1 , :USD )
70
+ )
71
+
65
72
assert { :ok , nil } = Payments . execute_pending_transfers ( user . id )
73
+ assert Transaction |> where ( [ t ] , t . type == :transfer ) |> Repo . aggregate ( :count ) == 0
74
+ end
66
75
76
+ test "does nothing when user has zero balance" , % { user: user } do
77
+ assert { :ok , nil } = Payments . execute_pending_transfers ( user . id )
67
78
assert Repo . aggregate ( Transaction , :count ) == 0
68
79
end
69
80
You can’t perform that action at this time.
0 commit comments