Skip to content
This repository was archived by the owner on Feb 23, 2020. It is now read-only.

Commit 865c1e9

Browse files
Jeff DutilJeff Dutil
authored andcommitted
Fix specs from validation change in spree.
1 parent 0250451 commit 865c1e9

File tree

1 file changed

+2
-37
lines changed

1 file changed

+2
-37
lines changed

spec/lib/spree/wombat/handler/add_customer_return_handler_spec.rb

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -169,33 +169,6 @@ module Wombat
169169
end
170170
end
171171

172-
context "there are return items that are not preauthorized" do
173-
it_behaves_like "receives the return items"
174-
it_behaves_like "does not attempt to refund the customer"
175-
end
176-
177-
context "there are return items that are preauthorized by another rma" do
178-
let(:other_rma) do
179-
create(:return_authorization, order: order, return_items: order.inventory_units.map(&:current_or_new_return_item))
180-
end
181-
182-
it_behaves_like "receives the return items"
183-
it_behaves_like "does not attempt to refund the customer"
184-
end
185-
186-
context "the rma does not exist" do
187-
before { rma.destroy! }
188-
it_behaves_like "receives the return items"
189-
it_behaves_like "does not attempt to refund the customer"
190-
end
191-
192-
context "the order does not exist" do
193-
before { order.destroy! }
194-
it_behaves_like "does not receive the return items" do
195-
let(:error_message) { "Customer return could not be fully processed, errors:" }
196-
end
197-
end
198-
199172
context "the stock location does not exist" do
200173
before { StockLocation.where(name: stock_location.name).destroy_all }
201174
it_behaves_like "does not receive the return items" do
@@ -218,7 +191,7 @@ module Wombat
218191
context "any of the items could possibly be returned" do
219192
before do
220193
Spree::CustomerReturn.create!(
221-
return_items: [order.inventory_units.last.return_items.build],
194+
return_items: [order.inventory_units.last.return_items.create(return_authorization: create(:return_authorization, order: order, stock_location: stock_location))],
222195
stock_location: stock_location
223196
)
224197
end
@@ -232,7 +205,7 @@ module Wombat
232205
context "none of the items could possibly be returned since they all already have been" do
233206
before do
234207
Spree::CustomerReturn.create!(
235-
return_items: order.inventory_units.map { |iu| iu.return_items.build },
208+
return_items: order.inventory_units.map { |iu| iu.return_items.create return_authorization: create(:return_authorization, order: order, stock_location: stock_location) },
236209
stock_location: stock_location
237210
)
238211
end
@@ -281,14 +254,6 @@ module Wombat
281254
expect(customer_return.return_items).to eq [return_item]
282255
end
283256

284-
it "does not use return items that have already been received" do
285-
return_item.receive!
286-
expect { subject }.to change { Spree::ReturnItem.count }
287-
customer_return = Spree::CustomerReturn.last
288-
expect(customer_return.return_items.length).to eq 1
289-
expect(customer_return.return_items).not_to eq [return_item]
290-
end
291-
292257
it "prefers created return items that are for the rma requested" do
293258
other_inventory_unit = order.inventory_units.detect { |i| i.variant == return_item.inventory_unit.variant }
294259
other_return_item = other_inventory_unit.current_or_new_return_item.tap(&:save)

0 commit comments

Comments
 (0)