Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #test
- def test_create_purchase_order
- # Login as a clerk
- user = users(:clerk_1)
- get_via_redirect '/login'
- assert_redirected_to '/login/login'
- post_via_redirect '/login/login', :user => {:login => user.email, :password => 'secretive' }
- assert_redirected_to '/'
- # Check the units can be changed
- assert user.company.units == 'kg'
- post_via_redirect '/data_entry/update_units', {:units => 'tonne'}
- assert_redirected_to :action => :index
- user.company.reload
- assert user.company.units == 'tonne'
- # You need to scan the response here to find the relevant periods!!!
- period = periods(:period_one)
- category = categories(:one)
- fishery_profile = fishery_profiles(:fishery_profile_30)
- po = purchase_orders(:one)
- supplier = user.company
- puts "narayan"
- puts period.inspect
- puts supplier.inspect
- xml_http_request :put, "/data_entry/create_purchase_order",:periodic_purchase_id => po.id, :category_id => category.name, :volume => 20,:fishery_profile_id => fishery_profile.name,:period_id => period.name,@supplier=> supplier,:po_action =>"create",:overwrite_duplicate =>"false"
- assert_select_rjs :replace_html,'data_entry'
- assert_equal "Purchase order for period #{period.name} created successfully.", flash.now[:message]
- end
- period.yaml
- period_one:
- id: 1
- name: 2010-Apr
- start_date: 2010-04-01
- end_date: 2010-04-30
- type: BusinessMonth
- created_at: 2010-04-16 11:46:01.666327
- updated_at: 2010-04-16 11:46:01.666327
- period_two:
- id: 2
- name: 2010-Mar
- start_date: 2010-03-01
- end_date: 2010-03-31
- type: BusinessMonth
- created_at: 2010-04-16 11:46:01.679228
- updated_at: 2010-04-16 11:46:01.679228
- period_purchase.yml
- po_one:
- id: 1
- title: Demo Retailer purchases from Acme for period 2010-Apr
- period_id: 1
- supplier_id: 2
- created_at: 2010-04-16 11:59:09.768127
- updated_at: 2010-04-16 11:59:09.768127
- po_two:
- id: 2
- title: Demo Retailer purchases from Acme for period 2010-May
- period_id: 2
- supplier_id: 2
- created_at: 2010-05-10 15:08:56.72103
- updated_at: 2010-05-10 15:08:56.72103
- purchaseorder.yml
- one:
- id: 1
- periodic_purchase_id: 1
- category_id: 1
- volume: 30
- profile_id: 3
- transaction_date:
- created_at: 2010-04-20 10:44:31.956792
- updated_at: 2010-04-20 10:44:31.956792
- two:
- id: 2
- periodic_purchase_id: 1
- category_id: 1
- volume: 20
- profile_id: 4
- transaction_date:
- created_at: 2010-04-20 10:44:32.020315
- updated_at: 2010-04-20 10:48:35.43639
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement