-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added tests for InvoiceItem, Invoices, Timeslips, Tasks
- Loading branch information
1 parent
33689f5
commit f53d1d0
Showing
18 changed files
with
1,125 additions
and
142 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
require 'test_helper' | ||
|
||
class InvoiceItemTest < Test::Unit::TestCase | ||
|
||
fake_it_all | ||
|
||
context "InvoiceItem class" do | ||
should "has correct collection path" do | ||
assert_equal '/invoices/1000/invoice_items.xml', InvoiceItem.collection_path(:invoice_id => 1000) | ||
end | ||
should "has correct element path" do | ||
assert_equal '/invoices/1000/invoice_items/first.xml', InvoiceItem.element_path(:first, :invoice_id => 1000) | ||
assert_equal '/invoices/1000/invoice_items/1.xml', InvoiceItem.element_path(1, :invoice_id => 1000) | ||
end | ||
end | ||
|
||
context "Invoice Items" do | ||
setup do | ||
@invoice_items = InvoiceItem.find :all, :params => {:invoice_id => 73867} | ||
end | ||
should "return an array" do | ||
assert @invoice_items.is_a? Array | ||
end | ||
should "return Invoices" do | ||
assert_equal 3, @invoice_items.size | ||
assert @invoice_items.first.is_a? InvoiceItem | ||
end | ||
end | ||
|
||
context "Invoice Item" do | ||
setup do | ||
@invoice_item = InvoiceItem.find 169399, :params => {:invoice_id => 73867} | ||
end | ||
should "return a Invoice Item" do | ||
assert @invoice_item.is_a? InvoiceItem | ||
end | ||
should "update and save" do | ||
@invoice_item.description = 'Create wireframe templates' | ||
assert @invoice_item.save | ||
end | ||
should "be destroyed" do | ||
assert @invoice_item.destroy | ||
end | ||
end | ||
|
||
#TODO - Add test for invalid resource | ||
# Need support from fakeweb in order to achieve this | ||
|
||
context "New Invoice Item" do | ||
setup do | ||
params = { | ||
:item_type => 'Hours', | ||
:description => 'Create wireframe templates', | ||
:quantity => '12', | ||
:price => '50', | ||
:sales_tax_rate => '15', | ||
:invoice_id => '73867' | ||
} | ||
@invoice_item = InvoiceItem.new params | ||
end | ||
should "validate and save" do | ||
assert @invoice_item.save_with_validation | ||
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
Oops, something went wrong.