Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow OrderWalkThrough to take a user #4292

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions core/lib/spree/testing_support/order_walkthrough.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
module Spree
module TestingSupport
class OrderWalkthrough
def self.up_to(state)
new.up_to(state)
def self.up_to(state, user: nil)
new.up_to(state, user: user)
end

def up_to(state)
def up_to(state, user: nil)
# Need to create a valid zone too...
@zone = ::FactoryBot.create(:zone)
@country = ::FactoryBot.create(:country)
Expand All @@ -23,6 +23,7 @@ def up_to(state)
end

order = Spree::Order.create!(
user: user,
email: "solidus@example.com",
store: Spree::Store.first || ::FactoryBot.create(:store)
)
Expand Down Expand Up @@ -61,7 +62,7 @@ def delivery(order)
end

def payment(order)
credit_card = ::FactoryBot.create(:credit_card)
credit_card = ::FactoryBot.create(:credit_card, user: order.user)
order.payments.create!(payment_method: credit_card.payment_method, amount: order.total, source: credit_card)
# TODO: maybe look at some way of making this payment_state change automatic
order.payment_state = 'paid'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
context "when the product from the order is not backorderable but has enough stock quantity" do
let(:user) { create(:user) }

let(:order) { Spree::TestingSupport::OrderWalkthrough.up_to(:payment) }
let(:order) { Spree::TestingSupport::OrderWalkthrough.up_to(:payment, user: user) }
let(:order_product) { order.products.first }
let(:order_stock_item) { order_product.stock_items.first }

Expand Down