Skip to content

Commit

Permalink
Create sample orders through the state machine
Browse files Browse the repository at this point in the history
  • Loading branch information
jhawthorn committed May 26, 2015
1 parent 4486def commit 0edf7bf
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sample/db/samples/orders.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
Spree::Sample.load_sample("addresses")

payment_method = Spree::PaymentMethod::Check.first!

orders = []
orders << Spree::Order.create!(
:number => "R123456789",
Expand Down Expand Up @@ -29,11 +31,9 @@
:quantity => 1,
:price => 22.99)

orders.each(&:create_proposed_shipments)
orders.each(&:create_tax_charge!)

orders.each do |order|
order.state = "complete"
order.completed_at = Time.now - 1.day
order.save!
order.payments.create!(payment_method: payment_method)

order.next! while !order.can_complete?
order.complete!
end

0 comments on commit 0edf7bf

Please sign in to comment.