Sha256: a9089bac93decbfc92c1a6afa375c25aa2b9676957f00e8bd2d051341c092323

Contents?: true

Size: 1.27 KB

Versions: 4

Compression:

Stored size: 1.27 KB

Contents

Comable::Sample.import('products')
Comable::Sample.import('variants')
Comable::Sample.import('addresses')

bill_address = Comable::Address.first
ship_address = Comable::Address.last
suede_dress = Comable::Product.where(name: Comable::Sample.t(:suede_dress)).first!
girly_coat = Comable::Product.where(name: Comable::Sample.t(:girly_coat)).first!

orders_attributes = [
  {
    email: 'comable@example.com',
    bill_address: bill_address,
    ship_address: ship_address,
    shipment_fee: 300,
    payment_fee: 200,
    total_price: 500 + suede_dress.price,
    order_items_attributes: [
      {
        variant: suede_dress.variants.first,
        quantity: 1
      }
    ]
  },
  {
    email: 'comable@example.com',
    bill_address: bill_address,
    ship_address: ship_address,
    shipment_fee: 300,
    payment_fee: 200,
    total_price: 500 + (suede_dress.price * 2) + (girly_coat.price * 3),
    order_items_attributes: [
      {
        variant: suede_dress.variants.first,
        quantity: 2
      },
      {
        variant: girly_coat.variants.first,
        quantity: 3
      }
    ]
  }
]

orders_attributes.each do |attributes|
  order = Comable::Order.create!(attributes)
  order.send(:generate_code)
  order.state = 'completed'
  order.completed_at = Time.now
  order.save!
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
comable-sample-0.7.1 db/samples/orders.rb
comable-sample-0.7.0 db/samples/orders.rb
comable-sample-0.7.0.beta2 db/samples/orders.rb
comable-sample-0.7.0.beta1 db/samples/orders.rb