spec/features/products_spec.rb
# NOTE: This is ugly and massive and I know it. I'm down to change it.
This is ugly and massive and I know it. I'm down to change it.
This is ugly and massive and I know it . I ' m down to change it .
def product_payload(type = "base")
      payload = {
        sku: FFaker::Product.model,
        externalId: FFaker::Product.model,
        description: FFaker::Product.product,
        classification: "baseProduct",
        category: "OTHER",
        batteryConfiguration: "NOBATTERY",
        values: {
          costValue: 1,
          retailValue: 4
        },
        dimensions: {
          length: 1,
          width: 1,
          height: 1,
          weight: 1
        },
        flags: {
          isPackagedReadyToShip: 1,
          isFragile: 0,
          isDangerous: 0,
          isPerishable: 0,
          isLiquid: 0,
          isMedia: 0,
          isAdult: 0,
          hasInnerPack: 0,
          hasMasterCase: 0,
          hasPallet: 0
        }
      }
      product_contents = [
        {
          externalId: "TEST-PRODUCT",
          quantity: 1
        },
        {
          externalId: "TEST-PRODUCT2",
          quantity: 1
        }
      ]
      case type
      when "insert"
        payload.deeper_merge!(
          classification: "marketingInsert",
          dimensions: {
            height: 0.1,
            weight: 0.1
          },
          masterCase: {
            individualItemsPerCase: 1,
            sku: FFaker::Product.model,
            description: FFaker::Product.product,
            dimensions: {
              length: 1,
              width: 1,
              height: 1,
              weight: 1
            }
          },
          inclusionRules: {
            insertWhenWorthCurrency: "USD"
          }
        )
      when "kit"
        payload.deeper_merge!(
          classification: "kit",
          kitContent: product_contents
        )
      when "virtual_kit"
        payload.deeper_merge!(
          classification: "virtualKit",
          virtualKitContent: product_contents
        )
      end
      payload
    end
def product_payload ( type = "base" ) payload = { sku : FFaker :: Product . model , externalId : FFaker :: Product . model , description : FFaker :: Product . product , classification : "baseProduct" , category : "OTHER" , batteryConfiguration : "NOBATTERY" , values : { costValue : 1 , retailValue : 4 } , dimensions : { length : 1 , width : 1 , height : 1 , weight : 1 } , flags : { isPackagedReadyToShip : 1 , isFragile : 0 , isDangerous : 0 , isPerishable : 0 , isLiquid : 0 , isMedia : 0 , isAdult : 0 , hasInnerPack : 0 , hasMasterCase : 0 , hasPallet : 0 } } product_contents = [ { externalId : "TEST-PRODUCT" , quantity : 1 } , { externalId : "TEST-PRODUCT2" , quantity : 1 } ] case type when "insert" payload . deeper_merge! ( classification : "marketingInsert" , dimensions : { height : 0.1 , weight : 0.1 } , masterCase : { individualItemsPerCase : 1 , sku : FFaker :: Product . model , description : FFaker :: Product . product , dimensions : { length : 1 , width : 1 , height : 1 , weight : 1 } } , inclusionRules : { insertWhenWorthCurrency : "USD" } ) when "kit" payload . deeper_merge! ( classification : "kit" , kitContent : product_contents ) when "virtual_kit" payload . deeper_merge! ( classification : "virtualKit" , virtualKitContent : product_contents ) end payload end
NOTE: This is ugly and massive and I know it.
NOTE : This is ugly and massive and I know it .
type