@@ -169,33 +169,6 @@ module Wombat
169
169
end
170
170
end
171
171
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
-
199
172
context "the stock location does not exist" do
200
173
before { StockLocation . where ( name : stock_location . name ) . destroy_all }
201
174
it_behaves_like "does not receive the return items" do
@@ -218,7 +191,7 @@ module Wombat
218
191
context "any of the items could possibly be returned" do
219
192
before do
220
193
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 ) ) ] ,
222
195
stock_location : stock_location
223
196
)
224
197
end
@@ -232,7 +205,7 @@ module Wombat
232
205
context "none of the items could possibly be returned since they all already have been" do
233
206
before do
234
207
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 ) } ,
236
209
stock_location : stock_location
237
210
)
238
211
end
@@ -281,14 +254,6 @@ module Wombat
281
254
expect ( customer_return . return_items ) . to eq [ return_item ]
282
255
end
283
256
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
-
292
257
it "prefers created return items that are for the rma requested" do
293
258
other_inventory_unit = order . inventory_units . detect { |i | i . variant == return_item . inventory_unit . variant }
294
259
other_return_item = other_inventory_unit . current_or_new_return_item . tap ( &:save )
0 commit comments