|
|
|
@ -7,9 +7,9 @@ defmodule Explorer.Workers.RefreshBalanceTest do |
|
|
|
|
alias Explorer.Debit |
|
|
|
|
alias Explorer.Workers.RefreshBalance |
|
|
|
|
|
|
|
|
|
describe "perform/1" do |
|
|
|
|
describe "perform/0" do |
|
|
|
|
test "refreshes credit balances" do |
|
|
|
|
with_mock Exq, [enqueue: fn (_, _, _, _) -> Credit.refresh() end] do |
|
|
|
|
with_mock Exq, [enqueue: fn (_, _, _, [type]) -> RefreshBalance.perform(type) end] do |
|
|
|
|
address = insert(:address) |
|
|
|
|
transaction = insert(:transaction, value: 20) |
|
|
|
|
insert(:to_address, address: address, transaction: transaction) |
|
|
|
@ -19,7 +19,7 @@ defmodule Explorer.Workers.RefreshBalanceTest do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
test "refreshes debit balances" do |
|
|
|
|
with_mock Exq, [enqueue: fn (_, _, _, _) -> Debit.refresh() end] do |
|
|
|
|
with_mock Exq, [enqueue: fn (_, _, _, [type]) -> RefreshBalance.perform(type) end] do |
|
|
|
|
address = insert(:address) |
|
|
|
|
transaction = insert(:transaction, value: 20) |
|
|
|
|
insert(:from_address, address: address, transaction: transaction) |
|
|
|
@ -28,4 +28,22 @@ defmodule Explorer.Workers.RefreshBalanceTest do |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe "perform/1" do |
|
|
|
|
test "refreshes credit balances" do |
|
|
|
|
address = insert(:address) |
|
|
|
|
transaction = insert(:transaction, value: 20) |
|
|
|
|
insert(:to_address, address: address, transaction: transaction) |
|
|
|
|
RefreshBalance.perform("credit") |
|
|
|
|
assert Repo.one(Credit).value == Decimal.new(20) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
test "refreshes debit balances" do |
|
|
|
|
address = insert(:address) |
|
|
|
|
transaction = insert(:transaction, value: 20) |
|
|
|
|
insert(:from_address, address: address, transaction: transaction) |
|
|
|
|
RefreshBalance.perform("debit") |
|
|
|
|
assert Repo.one(Debit).value == Decimal.new(20) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|