Created
June 24, 2013 07:03
-
-
Save gamov/5848212 to your computer and use it in GitHub Desktop.
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
test 'create a standard po with items' do | |
po_count = PurchaseOrder.count | |
visit new_purchase_order_path | |
page.select po.supplier.name, from: 'purchase_order_supplier_id' | |
page.select po.company_profile.name, from: 'purchase_order_company_profile_id' | |
page.select po.delivery_site.name, from: 'purchase_order_delivery_site_id' | |
page.click_button 'purchase_order_submit' | |
page.has_content? 'PurchaseOrder was successfully created.' | |
assert_equal po_count + 1, PurchaseOrder.count | |
#How can I get the newly created po.... | |
po = ? | |
#adding items | |
page.click_link 'Add items to this purchase order' | |
#select all | |
assert_equal 0, PurchasedItem.where(purchase_order_id: po.to_param).count | |
page.all("table#new_purchased_items input[type='checkbox']").each{|cb| page.check(cb[:id])} | |
page.click_button 'purchase_order_submit' | |
#errors | |
assert_equal 0, PurchasedItem.where(purchase_order_id: po.to_param).count | |
page.has_content? 'error' | |
page.all('table#new_purchased_items input[id$="unit_price"]').each{|ip| ip.set(3.5)} | |
page.all('table#new_purchased_items input[id$="quantity"]').each{|ip| ip.set(5)} | |
page.click_button 'purchase_order_submit' | |
assert_not_equal 0, PurchasedItem.where(purchase_order_id: po.to_param).count | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment