-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
482 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
spec/bill/operations/mixins/receive_direct_invoice_payment_spec.cr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
require "../../../spec_helper" | ||
|
||
describe Bill::ReceiveDirectInvoicePayment do | ||
it "requires open invoice" do | ||
amount = 90 | ||
user = UserFactory.create | ||
|
||
invoice = CreateInvoice.create!( | ||
params( | ||
user_id: user.id, | ||
description: "New invoice", | ||
due_at: 3.days.from_now, | ||
status: :draft | ||
), | ||
line_items: [{ | ||
"description" => "Item 1", | ||
"quantity" => "1", | ||
"price" => "#{amount}" | ||
}] | ||
) | ||
|
||
CreateDirectReceipt.create(params( | ||
invoice_id: invoice.id, | ||
user_id: user.id, | ||
description: "New invoice", | ||
amount: amount, | ||
status: :open | ||
)) do |operation, receipt| | ||
receipt.should be_nil | ||
operation.invoice_id.should have_error("operation.error.invoice_not_open") | ||
end | ||
end | ||
|
||
it "ensures receipt amount equals invoice amount" do | ||
user = UserFactory.create | ||
|
||
invoice = CreateInvoice.create!( | ||
params( | ||
user_id: user.id, | ||
description: "New invoice", | ||
due_at: 3.days.from_now, | ||
status: :open | ||
), | ||
line_items: [{ | ||
"description" => "Item 1", | ||
"quantity" => "1", | ||
"price" => "90" | ||
}] | ||
) | ||
|
||
CreateDirectReceipt.create(params( | ||
invoice_id: invoice.id, | ||
user_id: user.id, | ||
description: "New invoice", | ||
amount: 100, | ||
status: :open | ||
)) do |operation, receipt| | ||
receipt.should be_nil | ||
|
||
operation.amount | ||
.should(have_error "operation.error.receipt_not_equal_invoice") | ||
end | ||
end | ||
end |
64 changes: 64 additions & 0 deletions
64
spec/bill/operations/mixins/receive_invoice_payment_spec.cr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
require "../../../spec_helper" | ||
|
||
describe Bill::ReceiveInvoicePayment do | ||
it "requires open invoice" do | ||
amount = 90 | ||
user = UserFactory.create | ||
|
||
invoice = CreateInvoice.create!( | ||
params( | ||
user_id: user.id, | ||
description: "New invoice", | ||
due_at: 3.days.from_now, | ||
status: :draft | ||
), | ||
line_items: [{ | ||
"description" => "Item 1", | ||
"quantity" => "1", | ||
"price" => "#{amount}" | ||
}] | ||
) | ||
|
||
CreateReceipt.create(params( | ||
invoice_id: invoice.id, | ||
user_id: user.id, | ||
description: "New invoice", | ||
amount: amount, | ||
status: :open | ||
)) do |operation, receipt| | ||
receipt.should be_nil | ||
operation.invoice_id.should have_error("operation.error.invoice_not_open") | ||
end | ||
end | ||
|
||
it "ensures receipt amount equals invoice amount" do | ||
user = UserFactory.create | ||
|
||
invoice = CreateInvoice.create!( | ||
params( | ||
user_id: user.id, | ||
description: "New invoice", | ||
due_at: 3.days.from_now, | ||
status: :open | ||
), | ||
line_items: [{ | ||
"description" => "Item 1", | ||
"quantity" => "1", | ||
"price" => "90" | ||
}] | ||
) | ||
|
||
CreateReceipt.create(params( | ||
invoice_id: invoice.id, | ||
user_id: user.id, | ||
description: "New invoice", | ||
amount: 100, | ||
status: :open | ||
)) do |operation, receipt| | ||
receipt.should be_nil | ||
|
||
operation.amount | ||
.should(have_error "operation.error.receipt_not_equal_invoice") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.