diff --git a/spec/factories/requests.rb b/spec/factories/requests.rb index ec61b97c09..fce9e17189 100644 --- a/spec/factories/requests.rb +++ b/spec/factories/requests.rb @@ -31,17 +31,19 @@ def random_request_items # For compatibility we can take in a list of request_items and turn it into a # list of item_requests - after(:build) do |request| - if request.item_requests.empty? - request.request_items.each do |request_item| - item = Item.find(request_item['item_id']) - request.item_requests << Partners::ItemRequest.new( - item_id: item.id, - quantity: request_item['quantity'], - name: item.name, - partner_key: item.partner_key, - request_unit: request_item["request_unit"] - ) + trait :with_item_requests do + after(:build) do |request| + if request.item_requests.empty? + request.request_items.each do |request_item| + item = Item.find(request_item['item_id']) + request.item_requests << Partners::ItemRequest.new( + item_id: item.id, + quantity: request_item['quantity'], + name: item.name, + partner_key: item.partner_key, + request_unit: request_item["request_unit"] + ) + end end end end diff --git a/spec/requests/partners/requests_spec.rb b/spec/requests/partners/requests_spec.rb index 696d53055f..aa98e0f867 100644 --- a/spec/requests/partners/requests_spec.rb +++ b/spec/requests/partners/requests_spec.rb @@ -99,6 +99,7 @@ create(:item_unit, item: item3, name: "flat") request = create( :request, + :with_item_requests, partner_id: partner.id, partner_user_id: partner_user.id, request_items: [