Sha256: dd84bfa803c9271aba299d05c7683a309c7cf0ece97bc33146936673d6ac1838

Contents?: true

Size: 701 Bytes

Versions: 3

Compression:

Stored size: 701 Bytes

Contents

module ShoppingCart
  FactoryGirl.define do
    factory :order, class: Order do
      user
      
      factory :order_in_progress do
        after :create do |order|
          product = create :product
          create :order_item,
                 productable_id: product.id,
                 productable_type: product.class,
                 quantity: 2,
                 order: order
        end

        factory :order_delivered do
          after :create do |order|
            order.update state: :delivered
          end
        end
      end

      factory :order_with_coupon do
        after :create do |order|
          order.coupon = create :coupon
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
shopping-cart-0.1.2 spec/factories/shopping_cart_orders.rb
shopping-cart-0.1.1 spec/factories/shopping_cart_orders.rb
shopping-cart-0.1.0 spec/factories/shopping_cart_orders.rb