spree_backend 3.2.1 → 3.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/app/views/spree/admin/products/_form.html.erb +8 -8
  3. data/spree_backend.gemspec +2 -2
  4. metadata +9 -100
  5. data/spec/controllers/spree/admin/base_controller_spec.rb +0 -46
  6. data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +0 -185
  7. data/spec/controllers/spree/admin/general_settings_controller_spec.rb +0 -41
  8. data/spec/controllers/spree/admin/missing_products_controller_spec.rb +0 -18
  9. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +0 -197
  10. data/spec/controllers/spree/admin/orders_controller_spec.rb +0 -296
  11. data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +0 -64
  12. data/spec/controllers/spree/admin/payments_controller_spec.rb +0 -97
  13. data/spec/controllers/spree/admin/products_controller_spec.rb +0 -99
  14. data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +0 -21
  15. data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +0 -21
  16. data/spec/controllers/spree/admin/promotions_controller_spec.rb +0 -44
  17. data/spec/controllers/spree/admin/refunds_controller_spec.rb +0 -32
  18. data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +0 -74
  19. data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -42
  20. data/spec/controllers/spree/admin/resource_controller_spec.rb +0 -252
  21. data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +0 -225
  22. data/spec/controllers/spree/admin/return_index_controller_spec.rb +0 -37
  23. data/spec/controllers/spree/admin/return_items_controller_spec.rb +0 -27
  24. data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +0 -14
  25. data/spec/controllers/spree/admin/stock_items_controller_spec.rb +0 -19
  26. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +0 -41
  27. data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +0 -41
  28. data/spec/controllers/spree/admin/tax_categories_controller_spec.rb +0 -34
  29. data/spec/controllers/spree/admin/users_controller_spec.rb +0 -161
  30. data/spec/controllers/spree/admin/variants_controller_spec.rb +0 -32
  31. data/spec/features/admin/configuration/analytics_tracker_spec.rb +0 -47
  32. data/spec/features/admin/configuration/countries_spec.rb +0 -24
  33. data/spec/features/admin/configuration/general_settings_spec.rb +0 -44
  34. data/spec/features/admin/configuration/payment_methods_spec.rb +0 -63
  35. data/spec/features/admin/configuration/roles_spec.rb +0 -47
  36. data/spec/features/admin/configuration/shipping_methods_spec.rb +0 -62
  37. data/spec/features/admin/configuration/states_spec.rb +0 -68
  38. data/spec/features/admin/configuration/stock_locations_spec.rb +0 -48
  39. data/spec/features/admin/configuration/store_credit_categories_spec.rb +0 -50
  40. data/spec/features/admin/configuration/tax_categories_spec.rb +0 -56
  41. data/spec/features/admin/configuration/tax_rates_spec.rb +0 -18
  42. data/spec/features/admin/configuration/zones_spec.rb +0 -39
  43. data/spec/features/admin/homepage_spec.rb +0 -89
  44. data/spec/features/admin/locale_spec.rb +0 -31
  45. data/spec/features/admin/orders/adjustments_promotions_spec.rb +0 -53
  46. data/spec/features/admin/orders/adjustments_spec.rb +0 -130
  47. data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +0 -47
  48. data/spec/features/admin/orders/customer_details_spec.rb +0 -154
  49. data/spec/features/admin/orders/line_items_spec.rb +0 -51
  50. data/spec/features/admin/orders/listing_spec.rb +0 -224
  51. data/spec/features/admin/orders/log_entries_spec.rb +0 -55
  52. data/spec/features/admin/orders/new_order_spec.rb +0 -186
  53. data/spec/features/admin/orders/order_details_spec.rb +0 -662
  54. data/spec/features/admin/orders/payments_spec.rb +0 -231
  55. data/spec/features/admin/orders/risk_analysis_spec.rb +0 -48
  56. data/spec/features/admin/orders/shipments_spec.rb +0 -64
  57. data/spec/features/admin/orders/state_changes_spec.rb +0 -21
  58. data/spec/features/admin/products/edit/images_spec.rb +0 -86
  59. data/spec/features/admin/products/edit/products_spec.rb +0 -64
  60. data/spec/features/admin/products/edit/taxons_spec.rb +0 -41
  61. data/spec/features/admin/products/edit/variants_spec.rb +0 -56
  62. data/spec/features/admin/products/option_types_spec.rb +0 -114
  63. data/spec/features/admin/products/products_spec.rb +0 -445
  64. data/spec/features/admin/products/properties_spec.rb +0 -147
  65. data/spec/features/admin/products/prototypes_spec.rb +0 -112
  66. data/spec/features/admin/products/stock_management_spec.rb +0 -124
  67. data/spec/features/admin/products/taxonomies_spec.rb +0 -52
  68. data/spec/features/admin/products/variant_spec.rb +0 -50
  69. data/spec/features/admin/promotions/adjustments_spec.rb +0 -258
  70. data/spec/features/admin/promotions/option_value_rule_spec.rb +0 -70
  71. data/spec/features/admin/promotions/tiered_calculator_spec.rb +0 -70
  72. data/spec/features/admin/refund_reasons/refund_reasons_spec.rb +0 -57
  73. data/spec/features/admin/reimbursement_type/edit_reimbursement_type_spec.rb +0 -36
  74. data/spec/features/admin/reimbursement_type/new_reimbursement_type_spec.rb +0 -62
  75. data/spec/features/admin/reports_spec.rb +0 -61
  76. data/spec/features/admin/return_authorization_reasons/return_authorization_reasons_spec.rb +0 -63
  77. data/spec/features/admin/returns/customer_returns_spec.rb +0 -80
  78. data/spec/features/admin/returns/return_authorizations_spec.rb +0 -152
  79. data/spec/features/admin/stock_transfer_spec.rb +0 -75
  80. data/spec/features/admin/store_credits_spec.rb +0 -93
  81. data/spec/features/admin/taxons_spec.rb +0 -47
  82. data/spec/features/admin/users_spec.rb +0 -286
  83. data/spec/helpers/admin/base_helper_spec.rb +0 -30
  84. data/spec/helpers/admin/navigation_helper_spec.rb +0 -111
  85. data/spec/helpers/admin/promotion_rules_helper_spec.rb +0 -12
  86. data/spec/helpers/admin/stock_movements_helper_spec.rb +0 -30
  87. data/spec/models/spree/resource_spec.rb +0 -48
  88. data/spec/routing/admin_path_spec.rb +0 -22
  89. data/spec/spec_helper.rb +0 -144
  90. data/spec/support/appear_before_matcher.rb +0 -8
  91. data/spec/support/ror_ringer.jpeg +0 -0
  92. data/spec/test_views/spree/admin/submodule/posts/edit.html.erb +0 -1
  93. data/spec/test_views/spree/admin/submodule/posts/new.html.erb +0 -1
  94. data/spec/test_views/spree/admin/widgets/edit.html.erb +0 -1
  95. data/spec/test_views/spree/admin/widgets/new.html.erb +0 -1
@@ -1,662 +0,0 @@
1
- # coding: utf-8
2
- require 'spec_helper'
3
-
4
- describe "Order Details", type: :feature, js: true do
5
- let!(:stock_location) { create(:stock_location_with_items) }
6
- let!(:product) { create(:product, name: 'spree t-shirt', price: 20.00) }
7
- let(:order) { create(:order, state: 'complete', completed_at: "2011-02-01 12:36:15", number: "R100") }
8
- let(:state) { create(:state) }
9
- let!(:shipping_method) { create(:shipping_method, name: "Default") }
10
-
11
- before do
12
- order.shipments.create!(stock_location_id: stock_location.id)
13
- order.contents.add(product.master, 2)
14
- end
15
-
16
- context 'as Admin' do
17
- stub_authorization!
18
-
19
- context "cart edit page" do
20
- before do
21
- product.master.stock_items.first.update_column(:count_on_hand, 100)
22
- visit spree.cart_admin_order_path(order)
23
- end
24
-
25
- it "should allow me to edit order details" do
26
- expect(page).to have_content("spree t-shirt")
27
- expect(page).to have_content("$40.00")
28
-
29
- within_row(1) do
30
- click_icon :edit
31
- fill_in "quantity", with: "1"
32
- end
33
- click_icon :save
34
-
35
- within("#order_total") do
36
- expect(page).to have_content("$20.00")
37
- end
38
- end
39
-
40
- it "can add an item to a shipment" do
41
- select2_search "spree t-shirt", from: Spree.t(:name_or_sku)
42
- within("table.stock-levels") do
43
- fill_in "variant_quantity", with: 2
44
- click_icon :add
45
- end
46
-
47
- within("#order_total") do
48
- expect(page).to have_content("$80.00")
49
- end
50
- end
51
-
52
- it "can remove an item from a shipment" do
53
- expect(page).to have_content("spree t-shirt")
54
-
55
- within_row(1) do
56
- accept_alert do
57
- click_icon :delete
58
- end
59
- end
60
-
61
- # Click "ok" on confirmation dialog
62
- expect(page).not_to have_content("spree t-shirt")
63
- end
64
-
65
- # Regression test for #3862
66
- it "can cancel removing an item from a shipment" do
67
- expect(page).to have_content("spree t-shirt")
68
-
69
- within_row(1) do
70
- # Click "cancel" on confirmation dialog
71
- dismiss_alert do
72
- click_icon :delete
73
- end
74
- end
75
-
76
- expect(page).to have_content("spree t-shirt")
77
- end
78
-
79
- it "can add tracking information" do
80
- visit spree.edit_admin_order_path(order)
81
-
82
- within(".show-tracking") do
83
- click_icon :edit
84
- end
85
- fill_in "tracking", with: "FOOBAR"
86
- click_icon :save
87
-
88
- expect(page).not_to have_css("input[name=tracking]")
89
- expect(page).to have_content("Tracking: FOOBAR")
90
- end
91
-
92
- it "can change the shipping method" do
93
- order = create(:completed_order_with_totals)
94
- visit spree.edit_admin_order_path(order)
95
- within("table.table tr.show-method") do
96
- click_icon :edit
97
- end
98
- select2 "Default", from: "Shipping Method"
99
- click_icon :save
100
-
101
- expect(page).not_to have_css('#selected_shipping_rate_id')
102
- expect(page).to have_content("Default")
103
- end
104
-
105
- it "can assign a back-end only shipping method" do
106
- create(:shipping_method, name: "Backdoor", display_on: "back_end")
107
- order = create(
108
- :completed_order_with_totals,
109
- shipping_method_filter: Spree::ShippingMethod::DISPLAY_ON_FRONT_AND_BACK_END
110
- )
111
- visit spree.edit_admin_order_path(order)
112
- within("table tr.show-method") do
113
- click_icon :edit
114
- end
115
- select2 "Backdoor", from: "Shipping Method"
116
- click_icon :save
117
-
118
- expect(page).not_to have_css('#selected_shipping_rate_id')
119
- expect(page).to have_content("Backdoor")
120
- end
121
-
122
- it "will show the variant sku", js: false do
123
- order = create(:completed_order_with_totals)
124
- visit spree.edit_admin_order_path(order)
125
- sku = order.line_items.first.variant.sku
126
- expect(page).to have_content("SKU: #{sku}")
127
- end
128
-
129
- context "with special_instructions present" do
130
- before(:each) do
131
- order.update_column(:special_instructions, "Very special instructions here")
132
- end
133
-
134
- it "will show the special_instructions", js: false do
135
- visit spree.edit_admin_order_path(order)
136
- expect(page).to have_content("Very special instructions here")
137
- end
138
- end
139
-
140
- context 'when not tracking inventory' do
141
- let(:tote) { create(:product, name: "Tote", price: 15.00) }
142
-
143
- context "variant doesn't track inventory" do
144
- before do
145
- tote.master.update_column :track_inventory, false
146
- # make sure there's no stock level for any item
147
- tote.master.stock_items.update_all count_on_hand: 0, backorderable: false
148
- end
149
-
150
- it "adds variant to order just fine" do
151
- select2_search tote.name, from: Spree.t(:name_or_sku)
152
- within("table.stock-levels") do
153
- fill_in "variant_quantity", with: 1
154
- click_icon :add
155
- end
156
-
157
- wait_for_ajax
158
-
159
- within(".line-items") do
160
- expect(page).to have_content(tote.name)
161
- end
162
- end
163
- end
164
-
165
- context "site doesn't track inventory" do
166
- before do
167
- Spree::Config[:track_inventory_levels] = false
168
- tote.master.update_column(:track_inventory, true)
169
- # make sure there's no stock level for any item
170
- tote.master.stock_items.update_all count_on_hand: 0, backorderable: true
171
- end
172
-
173
- it "adds variant to order just fine" do
174
- select2_search tote.name, from: Spree.t(:name_or_sku)
175
- within("table.stock-levels") do
176
- fill_in "variant_quantity", with: 1
177
- click_icon :add
178
- end
179
-
180
- wait_for_ajax
181
-
182
- within(".line-items") do
183
- expect(page).to have_content(tote.name)
184
- end
185
- end
186
-
187
- after { Spree::Config[:track_inventory_levels] = true }
188
- end
189
- end
190
-
191
- context "variant out of stock and not backorderable" do
192
- before do
193
- product.master.stock_items.first.update_column(:backorderable, false)
194
- product.master.stock_items.first.update_column(:count_on_hand, 0)
195
- end
196
-
197
- it "displays out of stock instead of add button" do
198
- select2_search product.name, from: Spree.t(:name_or_sku)
199
-
200
- within("table.stock-levels") do
201
- expect(page).to have_content(Spree.t(:out_of_stock))
202
- end
203
- end
204
- end
205
- end
206
-
207
- context 'Shipment edit page' do
208
- let!(:stock_location2) { create(:stock_location_with_items, name: 'Clarksville') }
209
-
210
- before do
211
- product.master.stock_items.first.update_column(:backorderable, true)
212
- product.master.stock_items.first.update_column(:count_on_hand, 100)
213
- product.master.stock_items.last.update_column(:count_on_hand, 100)
214
- end
215
-
216
- context 'splitting to location' do
217
- before { visit spree.edit_admin_order_path(order) }
218
- # can not properly implement until poltergeist supports checking alert text
219
- # see https://github.com/teampoltergeist/poltergeist/pull/516
220
- it 'should warn you if you have not selected a location or shipment'
221
-
222
- context 'there is enough stock at the other location' do
223
- it 'should allow me to make a split' do
224
- expect(order.shipments.count).to eq(1)
225
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
226
-
227
- within_row(1) { click_icon 'split' }
228
- targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
229
- click_icon :save
230
-
231
- wait_for_ajax
232
- order.reload
233
-
234
- expect(order.shipments.count).to eq(2)
235
- expect(order.shipments.last.backordered?).to eq(false)
236
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(1)
237
- expect(order.shipments.last.inventory_units_for(product.master).count).to eq(1)
238
- end
239
-
240
- it 'should allow me to make a transfer via splitting off all stock' do
241
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
242
-
243
- within_row(1) { click_icon 'split' }
244
- targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
245
- fill_in 'item_quantity', with: 2
246
- click_icon :save
247
-
248
- wait_for_ajax
249
- order.reload
250
-
251
- expect(order.shipments.count).to eq(1)
252
- expect(order.shipments.last.backordered?).to eq(false)
253
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
254
- expect(order.shipments.first.stock_location.id).to eq(stock_location2.id)
255
- end
256
-
257
- it 'should allow me to split more than I have if available there' do
258
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
259
-
260
- within_row(1) { click_icon 'split' }
261
- targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
262
- fill_in 'item_quantity', with: 5
263
- click_icon :save
264
-
265
- wait_for_ajax
266
- order.reload
267
-
268
- expect(order.shipments.count).to eq(1)
269
- expect(order.shipments.last.backordered?).to eq(false)
270
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(5)
271
- expect(order.shipments.first.stock_location.id).to eq(stock_location2.id)
272
- end
273
-
274
- it 'should not split anything if the input quantity is garbage' do
275
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
276
-
277
- within_row(1) { click_icon 'split' }
278
- targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
279
- fill_in 'item_quantity', with: 'ff'
280
- click_icon :save
281
-
282
- wait_for_ajax
283
-
284
- expect(order.shipments.count).to eq(1)
285
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
286
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
287
- end
288
-
289
- it 'should not allow less than or equal to zero qty' do
290
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
291
-
292
- within_row(1) { click_icon 'split' }
293
- targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
294
- fill_in 'item_quantity', with: 0
295
- click_icon :save
296
-
297
- wait_for_ajax
298
-
299
- expect(order.shipments.count).to eq(1)
300
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
301
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
302
-
303
-
304
- fill_in 'item_quantity', with: -1
305
- click_icon :save
306
-
307
- wait_for_ajax
308
-
309
- expect(order.shipments.count).to eq(1)
310
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
311
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
312
- end
313
-
314
- context 'A shipment has shipped' do
315
-
316
- it 'should not show or let me back to the cart page, nor show the shipment edit buttons', js: false do
317
- order = create(:order, state: 'payment')
318
- order.shipments.create!(stock_location_id: stock_location.id, state: 'shipped')
319
-
320
- visit spree.cart_admin_order_path(order)
321
-
322
- expect(page.current_path).to eq(spree.edit_admin_order_path(order))
323
- expect(page).not_to have_text 'Cart'
324
- expect(page).not_to have_selector('.fa-split')
325
- expect(page).not_to have_selector('.fa-trash')
326
- end
327
-
328
- end
329
- end
330
-
331
- context 'there is not enough stock at the other location' do
332
- context 'and it cannot backorder' do
333
- it 'should not allow me to split stock' do
334
- product.master.stock_items.last.update_column(:backorderable, false)
335
- product.master.stock_items.last.update_column(:count_on_hand, 0)
336
-
337
- within_row(1) { click_icon 'split' }
338
- targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
339
- fill_in 'item_quantity', with: 2
340
- click_icon :save
341
-
342
- wait_for_ajax
343
-
344
- expect(order.shipments.count).to eq(1)
345
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
346
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
347
- end
348
-
349
- end
350
-
351
- context 'but it can backorder' do
352
- it 'should allow me to split and backorder the stock' do
353
- product.master.stock_items.last.update_column(:count_on_hand, 0)
354
- product.master.stock_items.last.update_column(:backorderable, true)
355
-
356
- within_row(1) { click_icon 'split' }
357
- targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
358
- fill_in 'item_quantity', with: 2
359
- click_icon :save
360
-
361
- wait_for_ajax
362
- order.reload
363
-
364
- expect(order.shipments.count).to eq(1)
365
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
366
- expect(order.shipments.first.stock_location.id).to eq(stock_location2.id)
367
- end
368
- end
369
- end
370
-
371
- context 'multiple items in cart' do
372
- it 'should have no problem splitting if multiple items are in the from shipment' do
373
- order.contents.add(create(:variant), 2)
374
- expect(order.shipments.count).to eq(1)
375
- expect(order.shipments.first.manifest.count).to eq(2)
376
-
377
- within_row(1) { click_icon 'split' }
378
- targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
379
- click_icon :save
380
-
381
- wait_for_ajax
382
- order.reload
383
-
384
- expect(order.shipments.count).to eq(2)
385
- expect(order.shipments.last.backordered?).to eq(false)
386
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(1)
387
- expect(order.shipments.last.inventory_units_for(product.master).count).to eq(1)
388
- end
389
- end
390
-
391
- context 'when not tracking inventory' do
392
- let(:tote) { create(:product, name: "Tote", price: 15.00) }
393
-
394
- context "variant doesn't track inventory" do
395
- before do
396
- tote.master.update_column :track_inventory, false
397
- # make sure there's no stock level for any item
398
- tote.master.stock_items.update_all count_on_hand: 0, backorderable: false
399
- end
400
-
401
- it "adds variant to order just fine" do
402
- select2_search tote.name, from: Spree.t(:name_or_sku)
403
- within("table.stock-levels") do
404
- fill_in "stock_item_quantity", with: 1
405
- click_icon :add
406
- end
407
-
408
- wait_for_ajax
409
-
410
- within("[data-hook=admin_order_form_fields]") do
411
- expect(page).to have_content(tote.name)
412
- end
413
- end
414
- end
415
-
416
- context "site doesn't track inventory" do
417
- before do
418
- Spree::Config[:track_inventory_levels] = false
419
- tote.master.update_column(:track_inventory, true)
420
- # make sure there's no stock level for any item
421
- tote.master.stock_items.update_all count_on_hand: 0, backorderable: true
422
- end
423
-
424
- it "adds variant to order just fine" do
425
- select2_search tote.name, from: Spree.t(:name_or_sku)
426
- within("table.stock-levels") do
427
- fill_in "stock_item_quantity", with: 1
428
- click_icon :add
429
- end
430
-
431
- wait_for_ajax
432
-
433
- within("[data-hook=admin_order_form_fields]") do
434
- expect(page).to have_content(tote.name)
435
- end
436
- end
437
-
438
- after { Spree::Config[:track_inventory_levels] = true }
439
- end
440
- end
441
-
442
- context "variant out of stock and not backorderable" do
443
- before do
444
- product.master.stock_items.first.update_column(:backorderable, false)
445
- product.master.stock_items.first.update_column(:count_on_hand, 0)
446
- end
447
-
448
- it "displays out of stock instead of add button" do
449
- select2_search product.name, from: Spree.t(:name_or_sku)
450
-
451
- within("table.stock-levels") do
452
- expect(page).to have_content(Spree.t(:out_of_stock))
453
- end
454
- end
455
- end
456
- end
457
-
458
- context 'splitting to shipment' do
459
- before do
460
- @shipment2 = order.shipments.create(stock_location_id: stock_location2.id)
461
- visit spree.edit_admin_order_path(order)
462
- end
463
-
464
- it 'should delete the old shipment if enough are split off' do
465
- expect(order.shipments.count).to eq(2)
466
-
467
- within_row(1) { click_icon 'split' }
468
- targetted_select2 @shipment2.number, from: '#s2id_item_stock_location'
469
- fill_in 'item_quantity', with: 2
470
- click_icon :save
471
-
472
- wait_for_ajax
473
- order.reload
474
-
475
- expect(order.shipments.count).to eq(1)
476
- expect(order.shipments.last.inventory_units_for(product.master).count).to eq(2)
477
- end
478
-
479
- context 'receiving shipment can not backorder' do
480
- before { product.master.stock_items.last.update_column(:backorderable, false) }
481
-
482
- it 'should not allow a split if the receiving shipment qty plus the incoming is greater than the count_on_hand' do
483
- expect(order.shipments.count).to eq(2)
484
-
485
- within_row(1) { click_icon 'split' }
486
- targetted_select2 @shipment2.number, from: '#s2id_item_stock_location'
487
- fill_in 'item_quantity', with: 1
488
- click_icon :save
489
-
490
- wait_for_ajax
491
-
492
- within_row(1) { click_icon 'split' }
493
- targetted_select2 @shipment2.number, from: '#s2id_item_stock_location'
494
- fill_in 'item_quantity', with: 200
495
- click_icon :save
496
-
497
- wait_for_ajax
498
-
499
- expect(order.shipments.count).to eq(2)
500
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(1)
501
- expect(order.shipments.last.inventory_units_for(product.master).count).to eq(1)
502
- end
503
-
504
- it 'should not allow a shipment to split stock to itself' do
505
- within_row(1) { click_icon 'split' }
506
- targetted_select2 order.shipments.first.number, from: '#s2id_item_stock_location'
507
- fill_in 'item_quantity', with: 1
508
- click_icon :save
509
-
510
- wait_for_ajax
511
-
512
- expect(order.shipments.count).to eq(2)
513
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
514
- end
515
-
516
- it 'should split fine if more than one line_item is in the receiving shipment' do
517
- variant2 = create(:variant)
518
- order.contents.add(variant2, 2, shipment: @shipment2)
519
-
520
- within_row(1) { click_icon 'split' }
521
- targetted_select2 @shipment2.number, from: '#s2id_item_stock_location'
522
- fill_in 'item_quantity', with: 1
523
- click_icon :save
524
-
525
- wait_for_ajax
526
-
527
- expect(order.shipments.count).to eq(2)
528
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq 1
529
- expect(order.shipments.last.inventory_units_for(product.master).count).to eq 1
530
- expect(order.shipments.first.inventory_units_for(variant2).count).to eq 0
531
- expect(order.shipments.last.inventory_units_for(variant2).count).to eq 2
532
- end
533
- end
534
-
535
- context 'receiving shipment can backorder' do
536
- it 'should add more to the backorder' do
537
- product.master.stock_items.last.update_column(:backorderable, true)
538
- product.master.stock_items.last.update_column(:count_on_hand, 0)
539
- expect(@shipment2.reload.backordered?).to eq(false)
540
-
541
-
542
- within_row(1) { click_icon 'split' }
543
- targetted_select2 @shipment2.number, from: '#s2id_item_stock_location'
544
- fill_in 'item_quantity', with: 1
545
- click_icon :save
546
-
547
- wait_for_ajax
548
-
549
- expect(@shipment2.reload.backordered?).to eq(true)
550
-
551
- within_row(1) { click_icon 'split' }
552
- targetted_select2 @shipment2.number, from: '#s2id_item_stock_location'
553
- fill_in 'item_quantity', with: 1
554
- click_icon :save
555
-
556
- wait_for_ajax
557
-
558
- expect(order.shipments.count).to eq(1)
559
- expect(order.shipments.last.inventory_units_for(product.master).count).to eq(2)
560
- expect(@shipment2.reload.backordered?).to eq(true)
561
- end
562
- end
563
- end
564
- end
565
- end
566
-
567
- context 'with only read permissions' do
568
- before do
569
- allow_any_instance_of(Spree::Admin::BaseController).to receive(:spree_current_user).and_return(nil)
570
- end
571
-
572
- custom_authorization! do |user|
573
- can [:admin, :index, :read, :edit], Spree::Order
574
- end
575
-
576
- it "should not display forbidden links" do
577
- visit spree.edit_admin_order_path(order)
578
-
579
- expect(page).not_to have_button('cancel')
580
- expect(page).not_to have_button('Resend')
581
-
582
- # Order Tabs
583
- expect(page).not_to have_link('Details')
584
- expect(page).not_to have_link('Customer')
585
- expect(page).not_to have_link('Adjustments')
586
- expect(page).not_to have_link('Payments')
587
- expect(page).not_to have_link('Returns')
588
-
589
- # Order item actions
590
- expect(page).not_to have_css('.delete-item')
591
- expect(page).not_to have_css('.split-item')
592
- expect(page).not_to have_css('.edit-item')
593
- expect(page).not_to have_css('.edit-tracking')
594
-
595
- expect(page).not_to have_css('#add-line-item')
596
- end
597
- end
598
-
599
- context 'as Fakedispatch' do
600
- custom_authorization! do |user|
601
- # allow dispatch to :admin, :index, and :edit on Spree::Order
602
- can [:admin, :edit, :index, :read], Spree::Order
603
- # allow dispatch to :index, :show, :create and :update shipments on the admin
604
- can [:admin, :manage, :read, :ship], Spree::Shipment
605
- end
606
-
607
- before do
608
- allow(Spree.user_class).to receive(:find_by).
609
- with(hash_including(:spree_api_key)).
610
- and_return(Spree.user_class.new)
611
- end
612
-
613
- it 'should not display order tabs or edit buttons without ability', js: false do
614
- visit spree.edit_admin_order_path(order)
615
-
616
- # Order Form
617
- expect(page).not_to have_css('.edit-item')
618
- # Order Tabs
619
- expect(page).not_to have_link('Details')
620
- expect(page).not_to have_link('Customer')
621
- expect(page).not_to have_link('Adjustments')
622
- expect(page).not_to have_link('Payments')
623
- expect(page).not_to have_link('Returns')
624
- end
625
-
626
- it "can add tracking information" do
627
- visit spree.edit_admin_order_path(order)
628
- within("table.table tr:nth-child(5)") do
629
- click_icon :edit
630
- end
631
- fill_in "tracking", with: "FOOBAR"
632
- click_icon :save
633
-
634
- expect(page).not_to have_css("input[name=tracking]")
635
- expect(page).to have_content("Tracking: FOOBAR")
636
- end
637
-
638
- it "can change the shipping method" do
639
- order = create(:completed_order_with_totals)
640
- visit spree.edit_admin_order_path(order)
641
- within("table.table tr.show-method") do
642
- click_icon :edit
643
- end
644
- select2 "Default", from: "Shipping Method"
645
- click_icon :save
646
-
647
- expect(page).not_to have_css('#selected_shipping_rate_id')
648
- expect(page).to have_content("Default")
649
- end
650
-
651
- it 'can ship' do
652
- order = create(:order_ready_to_ship)
653
- order.refresh_shipment_rates
654
- visit spree.edit_admin_order_path(order)
655
- click_on 'Ship'
656
- wait_for_ajax
657
- within '.shipment-state' do
658
- expect(page).to have_content('shipped')
659
- end
660
- end
661
- end
662
- end