Skip to content

Commit

Permalink
Improve order specs' performance
Browse files Browse the repository at this point in the history
  • Loading branch information
arku committed Oct 1, 2020
1 parent 350a3c0 commit 4858f5f
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions spec/models/spree/order_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
end

it "does nothing when the line item is not found" do
p = create(:simple_product)
p = build_stubbed(:simple_product)
subject.set_variant_attributes(p.master, { 'max_quantity' => '3' }.with_indifferent_access)
end
end
Expand Down Expand Up @@ -823,10 +823,14 @@ def advance_to_delivery_state(order)
end

describe '#restart_checkout!' do
let(:order) { build(:order, line_items: [build(:line_item)]) }

context 'when the order is complete' do
before { order.completed_at = Time.zone.now }
let(:order) do
build_stubbed(
:order,
completed_at: Time.zone.now,
line_items: [build_stubbed(:line_item)]
)
end

it 'raises' do
expect { order.restart_checkout! }
Expand All @@ -835,7 +839,13 @@ def advance_to_delivery_state(order)
end

context 'when the is not complete' do
before { order.completed_at = nil }
let(:order) do
build(
:order,
completed_at: nil,
line_items: [build(:line_item)]
)
end

it 'transitions to :cart state' do
order.restart_checkout!
Expand Down

0 comments on commit 4858f5f

Please sign in to comment.