spec/support/helper_methods.rb
#
# Simulates placing an order for an item and having it marked complete
# [_ordered_by_]
#   The user who is ordering the item
# [_facility_]
#   The facility with which the order is placed
# [_account_]
#   The account under which the order is placed
# [_reviewed_]
#   true if the completed order should also be marked as reviewed, false by default
Simulates placing an order for an item and having it marked complete
[_ordered_by_]
The user who is ordering the item
[_facility_]
The facility with which the order is placed
[_account_]
The account under which the order is placed
[_reviewed_]
true if the completed order should also be marked as reviewed, false by default
Simulates placing an order for an item and having it marked complete [ _ordered_by_ ] The user who is ordering the item [ _facility_ ] The facility with which the order is placed [ _account_ ] The account under which the order is placed [ _reviewed_ ] true if the completed order should also be marked as reviewed false by default
def place_and_complete_item_order(ordered_by, facility, account = nil, reviewed = false)
  @facility_account = FactoryBot.create(:facility_account, facility: facility)
  @item = facility.items.create(FactoryBot.attributes_for(:item, facility_account_id: @facility_account.id))
  place_product_order(ordered_by, facility, @item, account)
  @order.state = "validated"
  @order.purchase!
  @order_detail.change_status!(OrderStatus.complete)
  od_attrs = {
    actual_cost: 20,
    actual_subsidy: 10,
    price_policy_id: @item_pp.id,
  }
  od_attrs[:reviewed_at] = Time.zone.now - 1.day if reviewed
  @order_detail.update(od_attrs)
  @order_detail
end
def place_and_complete_item_order ( ordered_by , facility , account = nil , reviewed = false ) @facility_account = FactoryBot . create ( :facility_account , facility : facility ) @item = facility . items . create ( FactoryBot . attributes_for ( :item , facility_account_id : @facility_account . id ) ) place_product_order ( ordered_by , facility , @item , account ) @order . state = "validated" @order . purchase! @order_detail . change_status! ( OrderStatus . complete ) od_attrs = { actual_cost : 20 , actual_subsidy : 10 , price_policy_id : @item_pp . id , } od_attrs [ :reviewed_at ] = Time . zone . now - 1 . day if reviewed @order_detail . update ( od_attrs ) @order_detail end
Simulates placing an order for an item and having it marked complete
[_ordered_by_]
The user who is ordering the item
[_facility_]
The facility with which the order is placed
[_account_]
The account under which the order is placed
[_reviewed_]
true if the completed order should also be marked as reviewed, false by default
Simulates placing an order for an item and having it marked complete [ _ordered_by_ ] The user who is ordering the item [ _facility_ ] The facility with which the order is placed [ _account_ ] The account under which the order is placed [ _reviewed_ ] true if the completed order should also be marked as reviewed false by default
# act like the parent order is valid # purchase it
ordered_by
<not_specific>
facility
<not_specific>
account
<not_specific>
reviewed
<not_specific>