Advertisement
Guest User

Untitled

a guest
May 27th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. #test
  2. def test_create_purchase_order
  3. # Login as a clerk
  4.  
  5. user = users(:clerk_1)
  6. get_via_redirect '/login'
  7. assert_redirected_to '/login/login'
  8. post_via_redirect '/login/login', :user => {:login => user.email, :password => 'secretive' }
  9. assert_redirected_to '/'
  10.  
  11.  
  12. # Check the units can be changed
  13. assert user.company.units == 'kg'
  14. post_via_redirect '/data_entry/update_units', {:units => 'tonne'}
  15. assert_redirected_to :action => :index
  16. user.company.reload
  17. assert user.company.units == 'tonne'
  18.  
  19. # You need to scan the response here to find the relevant periods!!!
  20.  
  21. period = periods(:period_one)
  22. category = categories(:one)
  23. fishery_profile = fishery_profiles(:fishery_profile_30)
  24. po = purchase_orders(:one)
  25. supplier = user.company
  26. puts "narayan"
  27. puts period.inspect
  28. puts supplier.inspect
  29. 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"
  30.  
  31.  
  32. assert_select_rjs :replace_html,'data_entry'
  33. assert_equal "Purchase order for period #{period.name} created successfully.", flash.now[:message]
  34.  
  35.  
  36. end
  37.  
  38. period.yaml
  39. period_one:
  40. id: 1
  41. name: 2010-Apr
  42. start_date: 2010-04-01
  43. end_date: 2010-04-30
  44. type: BusinessMonth
  45. created_at: 2010-04-16 11:46:01.666327
  46. updated_at: 2010-04-16 11:46:01.666327
  47.  
  48. period_two:
  49. id: 2
  50. name: 2010-Mar
  51. start_date: 2010-03-01
  52. end_date: 2010-03-31
  53. type: BusinessMonth
  54. created_at: 2010-04-16 11:46:01.679228
  55. updated_at: 2010-04-16 11:46:01.679228
  56.  
  57. period_purchase.yml
  58. po_one:
  59. id: 1
  60. title: Demo Retailer purchases from Acme for period 2010-Apr
  61. period_id: 1
  62. supplier_id: 2
  63. created_at: 2010-04-16 11:59:09.768127
  64. updated_at: 2010-04-16 11:59:09.768127
  65.  
  66. po_two:
  67. id: 2
  68. title: Demo Retailer purchases from Acme for period 2010-May
  69. period_id: 2
  70. supplier_id: 2
  71. created_at: 2010-05-10 15:08:56.72103
  72. updated_at: 2010-05-10 15:08:56.72103
  73.  
  74. purchaseorder.yml
  75. one:
  76. id: 1
  77. periodic_purchase_id: 1
  78. category_id: 1
  79. volume: 30
  80. profile_id: 3
  81. transaction_date:
  82. created_at: 2010-04-20 10:44:31.956792
  83. updated_at: 2010-04-20 10:44:31.956792
  84.  
  85. two:
  86. id: 2
  87. periodic_purchase_id: 1
  88. category_id: 1
  89. volume: 20
  90. profile_id: 4
  91. transaction_date:
  92. created_at: 2010-04-20 10:44:32.020315
  93. updated_at: 2010-04-20 10:48:35.43639
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement