solidus_backend 2.10.1 → 2.11.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_backend might be problematic. Click here for more details.

Files changed (233) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/backend.js +4 -1
  3. data/app/assets/javascripts/spree/backend/adjustments.js +1 -1
  4. data/app/assets/javascripts/spree/backend/admin.js +18 -29
  5. data/app/assets/javascripts/spree/backend/collections/states.js +1 -1
  6. data/app/assets/javascripts/spree/backend/components/selectable_table.js +5 -0
  7. data/app/assets/javascripts/spree/backend/components/selectable_table/return_items.js +5 -0
  8. data/app/assets/javascripts/spree/backend/components/selectable_table/summary.js +7 -0
  9. data/app/assets/javascripts/spree/backend/components/sortable_table.js +31 -25
  10. data/app/assets/javascripts/spree/backend/models/order.js +3 -3
  11. data/app/assets/javascripts/spree/backend/models/payment.js +1 -1
  12. data/app/assets/javascripts/spree/backend/models/shipment.js +1 -1
  13. data/app/assets/javascripts/spree/backend/models/stock_item.js +1 -1
  14. data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +2 -2
  15. data/app/assets/javascripts/spree/backend/option_value_picker.js +2 -2
  16. data/app/assets/javascripts/spree/backend/product_picker.js +2 -2
  17. data/app/assets/javascripts/spree/backend/routes.js +40 -21
  18. data/app/assets/javascripts/spree/backend/shipments.js +5 -5
  19. data/app/assets/javascripts/spree/backend/shipping_methods/stock_locations_picker.js +18 -0
  20. data/app/assets/javascripts/spree/backend/stock_management.js +4 -2
  21. data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +2 -2
  22. data/app/assets/javascripts/spree/backend/taxons.js +3 -3
  23. data/app/assets/javascripts/spree/backend/templates/index.js +2 -0
  24. data/app/assets/javascripts/spree/backend/templates/orders/customer_details/autocomplete.hbs +2 -2
  25. data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +5 -1
  26. data/app/assets/javascripts/spree/backend/templates/tables/return_item_sum_amount.hbs +7 -0
  27. data/app/assets/javascripts/spree/backend/templates/tables/selectable_label.hbs +6 -0
  28. data/app/assets/javascripts/spree/backend/user_picker.js +3 -4
  29. data/app/assets/javascripts/spree/backend/variant_autocomplete.js +2 -2
  30. data/app/assets/javascripts/spree/backend/views/cart/empty_cart_button.js +2 -2
  31. data/app/assets/javascripts/spree/backend/views/index.js +4 -0
  32. data/app/assets/javascripts/spree/backend/views/order/address.js +1 -1
  33. data/app/assets/javascripts/spree/backend/views/order/customer_select.js +2 -3
  34. data/app/assets/javascripts/spree/backend/views/order/details_adjustments.js +4 -1
  35. data/app/assets/javascripts/spree/backend/views/stock/edit_stock_item_row.js +4 -0
  36. data/app/assets/javascripts/spree/backend/views/tables/return_items.js +9 -0
  37. data/app/assets/javascripts/spree/backend/views/tables/selectable_table.js +70 -0
  38. data/app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js +32 -0
  39. data/app/assets/javascripts/spree/backend/views/tables/selectable_table/summary.js +45 -0
  40. data/app/assets/stylesheets/spree/backend/components/_navigation.scss +4 -5
  41. data/app/assets/stylesheets/spree/backend/sections/_orders.scss +5 -1
  42. data/app/assets/stylesheets/spree/backend/sections/_style_guide.scss +4 -0
  43. data/app/assets/stylesheets/spree/backend/shared/_forms.scss +1 -0
  44. data/app/controllers/spree/admin/base_controller.rb +6 -0
  45. data/app/controllers/spree/admin/cancellations_controller.rb +2 -0
  46. data/app/controllers/spree/admin/customer_returns_controller.rb +4 -4
  47. data/app/controllers/spree/admin/images_controller.rb +2 -1
  48. data/app/controllers/spree/admin/orders/customer_details_controller.rb +2 -0
  49. data/app/controllers/spree/admin/orders_controller.rb +7 -2
  50. data/app/controllers/spree/admin/payments_controller.rb +3 -1
  51. data/app/controllers/spree/admin/product_properties_controller.rb +1 -1
  52. data/app/controllers/spree/admin/products_controller.rb +18 -24
  53. data/app/controllers/spree/admin/promotion_codes_controller.rb +9 -4
  54. data/app/controllers/spree/admin/refunds_controller.rb +20 -0
  55. data/app/controllers/spree/admin/resource_controller.rb +27 -7
  56. data/app/controllers/spree/admin/return_authorizations_controller.rb +1 -1
  57. data/app/controllers/spree/admin/root_controller.rb +1 -1
  58. data/app/controllers/spree/admin/search_controller.rb +1 -2
  59. data/app/controllers/spree/admin/stock_items_controller.rb +6 -5
  60. data/app/controllers/spree/admin/stock_locations_controller.rb +4 -0
  61. data/app/controllers/spree/admin/stock_movements_controller.rb +7 -0
  62. data/app/controllers/spree/admin/taxons_controller.rb +12 -1
  63. data/app/controllers/spree/admin/users/api_key_controller.rb +29 -0
  64. data/app/controllers/spree/admin/users_controller.rb +37 -20
  65. data/app/controllers/spree/admin/variants_controller.rb +4 -2
  66. data/app/controllers/spree/admin/zones_controller.rb +1 -1
  67. data/app/helpers/spree/admin/base_helper.rb +4 -0
  68. data/app/helpers/spree/admin/customer_returns_helper.rb +1 -1
  69. data/app/helpers/spree/admin/navigation_helper.rb +1 -1
  70. data/app/helpers/spree/admin/orders_helper.rb +8 -4
  71. data/app/helpers/spree/admin/stock_movements_helper.rb +8 -4
  72. data/app/views/spree/admin/customer_returns/_return_item_selection.html.erb +2 -3
  73. data/app/views/spree/admin/images/index.html.erb +25 -21
  74. data/app/views/spree/admin/option_types/_option_value_fields.html.erb +8 -1
  75. data/app/views/spree/admin/option_types/edit.html.erb +3 -1
  76. data/app/views/spree/admin/orders/customer_details/_form.html.erb +13 -13
  77. data/app/views/spree/admin/orders/index.html.erb +23 -13
  78. data/app/views/spree/admin/payment_methods/_form.html.erb +7 -2
  79. data/app/views/spree/admin/payments/index.html.erb +3 -1
  80. data/app/views/spree/admin/prices/_master_variant_table.html.erb +3 -3
  81. data/app/views/spree/admin/prices/_table.html.erb +3 -3
  82. data/app/views/spree/admin/product_properties/_product_property_fields.html.erb +7 -2
  83. data/app/views/spree/admin/product_properties/index.html.erb +14 -2
  84. data/app/views/spree/admin/products/_form.html.erb +13 -2
  85. data/app/views/spree/admin/products/index.html.erb +1 -1
  86. data/app/views/spree/admin/promotion_codes/index.html.erb +1 -1
  87. data/app/views/spree/admin/promotions/_actions.html.erb +1 -1
  88. data/app/views/spree/admin/promotions/_activations_new.html.erb +1 -1
  89. data/app/views/spree/admin/promotions/_rules.html.erb +1 -1
  90. data/app/views/spree/admin/promotions/edit.html.erb +2 -2
  91. data/app/views/spree/admin/promotions/index.html.erb +12 -5
  92. data/app/views/spree/admin/return_authorizations/_form.html.erb +3 -10
  93. data/app/views/spree/admin/return_authorizations/index.html.erb +1 -1
  94. data/app/views/spree/admin/search/users.json.jbuilder +15 -1
  95. data/app/views/spree/admin/shared/_address.html.erb +6 -6
  96. data/app/views/spree/admin/shared/_address_form.html.erb +15 -8
  97. data/app/views/spree/admin/shared/_order_submenu.html.erb +4 -4
  98. data/app/views/spree/admin/shared/_payments_tabs.html.erb +1 -1
  99. data/app/views/spree/admin/shared/_settings_checkout_tabs.html.erb +5 -5
  100. data/app/views/spree/admin/shared/_settings_sub_menu.html.erb +6 -6
  101. data/app/views/spree/admin/shared/_shipping_tabs.html.erb +3 -3
  102. data/app/views/spree/admin/shared/_taxes_tabs.html.erb +2 -2
  103. data/app/views/spree/admin/shared/preference_fields/_encrypted_string.html.erb +12 -0
  104. data/app/views/spree/admin/shipping_methods/_form.html.erb +18 -0
  105. data/app/views/spree/admin/stock_items/_stock_management.html.erb +1 -1
  106. data/app/views/spree/admin/stock_locations/edit.html.erb +1 -1
  107. data/app/views/spree/admin/stock_locations/index.html.erb +3 -1
  108. data/app/views/spree/admin/stock_movements/index.html.erb +30 -1
  109. data/app/views/spree/admin/stores/_form.html.erb +6 -0
  110. data/app/views/spree/admin/style_guide/topics/tables/_building_tables.html.erb +27 -3
  111. data/app/views/spree/admin/tax_categories/_form.html.erb +1 -0
  112. data/app/views/spree/admin/users/_form.html.erb +2 -2
  113. data/app/views/spree/admin/users/_tabs.html.erb +1 -1
  114. data/app/views/spree/admin/users/edit.html.erb +4 -4
  115. data/app/views/spree/admin/users/items.html.erb +5 -3
  116. data/app/views/spree/admin/users/orders.html.erb +5 -3
  117. data/app/views/spree/admin/variants/_table_filter.html.erb +1 -1
  118. data/app/views/spree/admin/variants/index.html.erb +2 -2
  119. data/config/initializers/form_builder.rb +2 -2
  120. data/lib/spree/backend/engine.rb +0 -2
  121. data/lib/spree/backend_configuration.rb +14 -1
  122. data/solidus_backend.gemspec +4 -4
  123. metadata +24 -123
  124. data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +0 -35
  125. data/script/rails +0 -10
  126. data/spec/controllers/spree/admin/base_controller_spec.rb +0 -26
  127. data/spec/controllers/spree/admin/cancellations_controller_spec.rb +0 -83
  128. data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +0 -235
  129. data/spec/controllers/spree/admin/locale_controller_spec.rb +0 -45
  130. data/spec/controllers/spree/admin/missing_products_controller_spec.rb +0 -18
  131. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +0 -128
  132. data/spec/controllers/spree/admin/orders_controller_spec.rb +0 -408
  133. data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +0 -95
  134. data/spec/controllers/spree/admin/payments_controller_spec.rb +0 -194
  135. data/spec/controllers/spree/admin/prices_controller_spec.rb +0 -45
  136. data/spec/controllers/spree/admin/product_properties_controller_spec.rb +0 -71
  137. data/spec/controllers/spree/admin/products_controller_spec.rb +0 -270
  138. data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +0 -23
  139. data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +0 -32
  140. data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +0 -36
  141. data/spec/controllers/spree/admin/promotions_controller_spec.rb +0 -122
  142. data/spec/controllers/spree/admin/refunds_controller_spec.rb +0 -35
  143. data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +0 -137
  144. data/spec/controllers/spree/admin/resource_controller_spec.rb +0 -201
  145. data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +0 -291
  146. data/spec/controllers/spree/admin/return_items_controller_spec.rb +0 -29
  147. data/spec/controllers/spree/admin/root_controller_spec.rb +0 -43
  148. data/spec/controllers/spree/admin/search_controller_spec.rb +0 -106
  149. data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +0 -16
  150. data/spec/controllers/spree/admin/stock_items_controller_spec.rb +0 -52
  151. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +0 -44
  152. data/spec/controllers/spree/admin/store_credits_controller_spec.rb +0 -311
  153. data/spec/controllers/spree/admin/users_controller_spec.rb +0 -287
  154. data/spec/controllers/spree/admin/variants_controller_spec.rb +0 -71
  155. data/spec/features/admin/configuration/payment_methods_spec.rb +0 -176
  156. data/spec/features/admin/configuration/shipping_methods_spec.rb +0 -126
  157. data/spec/features/admin/configuration/stock_locations_spec.rb +0 -54
  158. data/spec/features/admin/configuration/store_spec.rb +0 -62
  159. data/spec/features/admin/configuration/tax_categories_spec.rb +0 -58
  160. data/spec/features/admin/configuration/tax_rates_spec.rb +0 -31
  161. data/spec/features/admin/configuration/taxonomies_spec.rb +0 -61
  162. data/spec/features/admin/configuration/zones_spec.rb +0 -41
  163. data/spec/features/admin/homepage_spec.rb +0 -86
  164. data/spec/features/admin/javascript_format_money_spec.rb +0 -22
  165. data/spec/features/admin/locale_spec.rb +0 -34
  166. data/spec/features/admin/orders/adjustments_promotions_spec.rb +0 -55
  167. data/spec/features/admin/orders/adjustments_spec.rb +0 -130
  168. data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +0 -45
  169. data/spec/features/admin/orders/cancelling_inventory_spec.rb +0 -50
  170. data/spec/features/admin/orders/customer_details_spec.rb +0 -203
  171. data/spec/features/admin/orders/customer_returns_spec.rb +0 -41
  172. data/spec/features/admin/orders/line_items_spec.rb +0 -52
  173. data/spec/features/admin/orders/listing_spec.rb +0 -186
  174. data/spec/features/admin/orders/log_entries_spec.rb +0 -56
  175. data/spec/features/admin/orders/new_order_spec.rb +0 -379
  176. data/spec/features/admin/orders/new_refund_spec.rb +0 -35
  177. data/spec/features/admin/orders/order_details_spec.rb +0 -591
  178. data/spec/features/admin/orders/payments_spec.rb +0 -330
  179. data/spec/features/admin/orders/return_authorizations_spec.rb +0 -56
  180. data/spec/features/admin/orders/return_payment_state_spec.rb +0 -65
  181. data/spec/features/admin/orders/risk_analysis_spec.rb +0 -49
  182. data/spec/features/admin/orders/shipments_spec.rb +0 -145
  183. data/spec/features/admin/payments/store_credits_spec.rb +0 -23
  184. data/spec/features/admin/products/edit/images_spec.rb +0 -76
  185. data/spec/features/admin/products/edit/products_spec.rb +0 -92
  186. data/spec/features/admin/products/edit/taxons_spec.rb +0 -57
  187. data/spec/features/admin/products/edit/variants_spec.rb +0 -63
  188. data/spec/features/admin/products/option_types_spec.rb +0 -116
  189. data/spec/features/admin/products/pricing_spec.rb +0 -127
  190. data/spec/features/admin/products/products_spec.rb +0 -348
  191. data/spec/features/admin/products/properties_spec.rb +0 -141
  192. data/spec/features/admin/products/stock_management_spec.rb +0 -101
  193. data/spec/features/admin/products/variant_spec.rb +0 -89
  194. data/spec/features/admin/promotion_adjustments_spec.rb +0 -286
  195. data/spec/features/admin/promotions/option_value_rule_spec.rb +0 -90
  196. data/spec/features/admin/promotions/product_rule_spec.rb +0 -35
  197. data/spec/features/admin/promotions/promotion_categories_spec.rb +0 -83
  198. data/spec/features/admin/promotions/promotion_code_batches_spec.rb +0 -37
  199. data/spec/features/admin/promotions/promotion_code_spec.rb +0 -31
  200. data/spec/features/admin/promotions/promotion_spec.rb +0 -52
  201. data/spec/features/admin/promotions/tiered_calculator_spec.rb +0 -76
  202. data/spec/features/admin/promotions/user_rule_spec.rb +0 -42
  203. data/spec/features/admin/reimbursements_spec.rb +0 -18
  204. data/spec/features/admin/store_credits_spec.rb +0 -132
  205. data/spec/features/admin/stores_spec.rb +0 -37
  206. data/spec/features/admin/style_guide_spec.rb +0 -14
  207. data/spec/features/admin/taxons_spec.rb +0 -90
  208. data/spec/features/admin/users_spec.rb +0 -412
  209. data/spec/fixtures/files/ror_ringer.jpeg +0 -0
  210. data/spec/helpers/admin/base_helper_spec.rb +0 -49
  211. data/spec/helpers/admin/navigation_helper_spec.rb +0 -139
  212. data/spec/helpers/admin/stock_movements_helper_spec.rb +0 -29
  213. data/spec/helpers/admin/store_credit_events_helper_spec.rb +0 -97
  214. data/spec/helpers/promotion_rules_helper_spec.rb +0 -14
  215. data/spec/javascripts/fixtures/_boot.html.erb +0 -8
  216. data/spec/javascripts/fixtures/number_with_currency/with_currency_select.html.erb +0 -3
  217. data/spec/javascripts/fixtures/number_with_currency/without_select.html.erb +0 -3
  218. data/spec/javascripts/format_money_spec.js +0 -48
  219. data/spec/javascripts/spec_helper.js +0 -13
  220. data/spec/javascripts/support/show_errors.js +0 -8
  221. data/spec/javascripts/support/with_translations.js +0 -11
  222. data/spec/javascripts/translation_spec.js +0 -58
  223. data/spec/javascripts/views/number_with_currency_spec.js +0 -72
  224. data/spec/lib/spree/backend_configuration/menu_item_spec.rb +0 -17
  225. data/spec/lib/spree/backend_configuration_spec.rb +0 -22
  226. data/spec/spec_helper.rb +0 -123
  227. data/spec/support/appear_before_matcher.rb +0 -10
  228. data/spec/support/feature/base_feature_helper.rb +0 -17
  229. data/spec/support/feature/order_feature_helper.rb +0 -27
  230. data/spec/teaspoon_env.rb +0 -51
  231. data/spec/test_views/spree/admin/widgets/edit.html.erb +0 -1
  232. data/spec/test_views/spree/admin/widgets/new.html.erb +0 -1
  233. data/spec/views/spree/admin/shared/navigation_footer_spec.rb +0 -67
@@ -1,591 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe "Order Details", type: :feature, js: true do
6
- include OrderFeatureHelper
7
-
8
- let!(:stock_location) { create(:stock_location_with_items) }
9
- let!(:product) { create(:product, name: 'spree t-shirt', price: 20.00) }
10
- let(:order) { create(:order, state: 'complete', completed_at: "2011-02-01 12:36:15", number: "R100") }
11
- let(:state) { create(:state) }
12
- let(:line_item) { order.line_items.first }
13
-
14
- let!(:shipment1) do
15
- order.shipments.create(stock_location_id: stock_location.id)
16
- end
17
-
18
- before do
19
- order.contents.add(product.master, 2)
20
- # order.contents.add causes things (like line items & shipments) to get
21
- # cached, and these are going to change during this spec so we go ahead and
22
- # reload now
23
- order.reload
24
- end
25
-
26
- context 'as Admin' do
27
- stub_authorization!
28
-
29
- context "cart edit page" do
30
- let(:track_inventory) { true }
31
- let(:backorderable) { true }
32
- let(:count_on_hand) { 100 }
33
-
34
- before do
35
- product.master.update_columns(track_inventory: track_inventory)
36
- product.master.stock_items.update_all(count_on_hand: count_on_hand, backorderable: backorderable)
37
-
38
- visit spree.cart_admin_order_path(order)
39
- end
40
-
41
- it "should allow me to edit order details" do
42
- expect(page).to have_content("spree t-shirt")
43
- expect(page).to have_content("$40.00")
44
-
45
- within('tr', text: line_item.sku) do
46
- click_icon :edit
47
- fill_in "quantity", with: "1"
48
- end
49
- click_icon :ok
50
-
51
- within("#order_total") do
52
- expect(page).to have_content("$20.00")
53
- end
54
- end
55
-
56
- it "can add an item" do
57
- add_line_item "spree t-shirt", quantity: 2
58
-
59
- within("#order_total") do
60
- expect(page).to have_content("$80.00")
61
- end
62
- end
63
-
64
- it "can remove an item from a shipment" do
65
- expect(page).to have_content("spree t-shirt")
66
-
67
- within('tr', text: line_item.sku) do
68
- accept_confirm "Are you sure you want to delete this record?" do
69
- click_icon :trash
70
- end
71
- end
72
-
73
- expect(page).not_to have_content("spree t-shirt")
74
-
75
- # Should have a new item row
76
- expect(page).to have_field('quantity')
77
- end
78
-
79
- it "can remove all items with empty cart" do
80
- expect(page).to have_content("spree t-shirt")
81
-
82
- accept_confirm "Are you sure you want to delete this record?" do
83
- click_on 'Empty Cart'
84
- end
85
-
86
- expect(page).not_to have_content("spree t-shirt")
87
-
88
- # Should have a new item row
89
- expect(page).to have_field('quantity')
90
- end
91
-
92
- # Regression test for https://github.com/spree/spree/issues/3862
93
- it "can cancel removing an item from a shipment" do
94
- expect(page).to have_content("spree t-shirt")
95
-
96
- within('tr', text: line_item.sku) do
97
- # Click "cancel" on confirmation dialog
98
- dismiss_confirm "Are you sure you want to delete this record?" do
99
- click_icon :trash
100
- end
101
- end
102
-
103
- expect(page).to have_content("spree t-shirt")
104
- end
105
-
106
- it "can add tracking information" do
107
- visit spree.edit_admin_order_path(order)
108
-
109
- within("tr", text: "Tracking Number") do
110
- click_icon :edit
111
- fill_in "tracking", with: "FOOBAR"
112
- click_icon :check
113
-
114
- expect(page).not_to have_css("input")
115
- expect(page).to have_content("Tracking Number FOOBAR")
116
- end
117
- end
118
-
119
- context "with a completed order" do
120
- let!(:order) { create(:completed_order_with_totals) }
121
- let(:shipment1) { order.shipments[0] }
122
-
123
- it "can change the shipping method" do
124
- visit spree.edit_admin_order_path(order)
125
-
126
- within("tr", text: "Shipping Method") do
127
- click_icon :edit
128
- select "UPS Ground $100.00"
129
- click_icon :check
130
- end
131
-
132
- expect(page).not_to have_css('#selected_shipping_rate_id')
133
- expect(page).to have_content("UPS Ground")
134
- end
135
-
136
- it "can use admin-only shipping methods" do
137
- create(:shipping_method, name: "Admin Free Shipping", cost: 0, available_to_users: false)
138
-
139
- visit spree.edit_admin_order_path(order)
140
-
141
- within("tr", text: "Shipping Method") do
142
- click_icon :edit
143
- select "Admin Free Shipping $0.00"
144
- click_icon :check
145
- end
146
-
147
- expect(page).not_to have_css('#selected_shipping_rate_id')
148
- expect(page).to have_no_content("UPS Ground")
149
- expect(page).to have_content("Admin Free Shipping")
150
- end
151
-
152
- it "will show the variant sku" do
153
- visit spree.edit_admin_order_path(order)
154
- sku = order.line_items.first.variant.sku
155
- expect(page).to have_content("SKU: #{sku}")
156
- end
157
- end
158
-
159
- context "with special_instructions present" do
160
- let(:order) { create(:order, state: 'complete', completed_at: "2011-02-01 12:36:15", number: "R100", special_instructions: "Very special instructions here") }
161
- it "will show the special_instructions" do
162
- visit spree.edit_admin_order_path(order)
163
- expect(page).to have_content("Very special instructions here")
164
- end
165
- end
166
-
167
- context "variant doesn't track inventory" do
168
- let(:track_inventory) { false }
169
- let(:backorderable) { false }
170
- let(:count_on_hand) { 0 }
171
-
172
- it "adds variant to order just fine" do
173
- add_line_item "spree t-shirt"
174
-
175
- within(".line-items") do
176
- expect(page).to have_content("spree t-shirt")
177
- end
178
- end
179
- end
180
-
181
- context "variant out of stock and not backorderable" do
182
- let(:backorderable) { false }
183
- let(:count_on_hand) { 0 }
184
-
185
- it "doesn't display the out of stock variant in the search results" do
186
- click_on 'Add Item'
187
- select2_search_without_selection product.name, from: ".select-variant"
188
-
189
- expect(page).to have_selector('.select2-no-results')
190
- within(".select2-no-results") do
191
- expect(page).to have_content("No matches found")
192
- end
193
- end
194
- end
195
- end
196
-
197
- context 'Shipment edit page' do
198
- let!(:stock_location2) { create(:stock_location_with_items, name: 'Clarksville') }
199
-
200
- before do
201
- product.master.stock_items.first.update_column(:backorderable, true)
202
- product.master.stock_items.first.update_column(:count_on_hand, 100)
203
- product.master.stock_items.last.update_column(:count_on_hand, 100)
204
- end
205
-
206
- context 'splitting to location' do
207
- it 'should warn you if you have not selected a location or shipment' do
208
- visit spree.edit_admin_order_path(order)
209
-
210
- within('tr', text: line_item.sku) { click_icon 'arrows-h' }
211
- accept_alert 'Please select the split destination.' do
212
- click_icon :ok
213
- end
214
- end
215
-
216
- context 'there is enough stock at the other location' do
217
- it 'should allow me to make a split' do
218
- expect(order.shipments.count).to eq(1)
219
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
220
-
221
- visit spree.edit_admin_order_path(order)
222
-
223
- within('tr', text: line_item.sku) { click_icon 'arrows-h' }
224
- complete_split_to(stock_location2)
225
-
226
- expect(page).to have_css('.shipment', count: 2)
227
-
228
- expect(order.shipments.count).to eq(2)
229
- expect(order.shipments.last.backordered?).to eq(false)
230
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(1)
231
- expect(order.shipments.last.inventory_units_for(product.master).count).to eq(1)
232
- end
233
-
234
- it 'should allow me to make a transfer via splitting off all stock' do
235
- visit spree.edit_admin_order_path(order)
236
-
237
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
238
-
239
- within('tr', text: line_item.sku) { click_icon 'arrows-h' }
240
- complete_split_to(stock_location2, quantity: 2)
241
-
242
- expect(page).to have_content("Pending package from 'Clarksville'")
243
-
244
- expect(order.shipments.count).to eq(1)
245
- expect(order.shipments.last.backordered?).to eq(false)
246
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
247
- expect(order.shipments.first.stock_location.id).to eq(stock_location2.id)
248
- end
249
-
250
- it 'should not allow me to split more than I had in the original shipment' do
251
- visit spree.edit_admin_order_path(order)
252
-
253
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
254
-
255
- within('tr', text: line_item.sku) { click_icon 'arrows-h' }
256
- complete_split_to(stock_location2, quantity: 5)
257
-
258
- expect(page).to have_content("Pending package from 'Clarksville'")
259
-
260
- expect(order.shipments.count).to eq(1)
261
- expect(order.shipments.last.backordered?).to eq(false)
262
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
263
- expect(order.shipments.first.stock_location.id).to eq(stock_location2.id)
264
- end
265
-
266
- it 'should not allow less than or equal to zero qty' do
267
- visit spree.edit_admin_order_path(order)
268
-
269
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
270
-
271
- within('tr', text: line_item.sku) { click_icon 'arrows-h' }
272
-
273
- accept_alert "Quantity must be greater than 0" do
274
- complete_split_to(stock_location2, quantity: 0)
275
- end
276
-
277
- expect(order.shipments.count).to eq(1)
278
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
279
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
280
-
281
- fill_in 'item_quantity', with: -1
282
-
283
- accept_alert "Quantity must be greater than 0" do
284
- click_icon :ok
285
- end
286
-
287
- expect(order.shipments.count).to eq(1)
288
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
289
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
290
- end
291
-
292
- context 'A shipment has shipped' do
293
- it 'should not show or let me back to the cart page, nor show the shipment edit buttons' do
294
- order = create(:shipped_order, state: 'payment', stock_location: stock_location)
295
-
296
- visit spree.cart_admin_order_path(order)
297
-
298
- expect(page.current_path).to eq(spree.edit_admin_order_path(order))
299
- expect(page).not_to have_text 'Cart'
300
- expect(page).not_to have_selector('.fa-arrows-h')
301
- expect(page).not_to have_selector('.fa-trash')
302
- end
303
- end
304
- end
305
-
306
- context 'there is not enough stock at the other location' do
307
- context 'and it cannot backorder' do
308
- it 'should not allow me to split stock' do
309
- product.master.stock_items.last.update_column(:backorderable, false)
310
- product.master.stock_items.last.update_column(:count_on_hand, 0)
311
-
312
- visit spree.edit_admin_order_path(order)
313
-
314
- within('tr', text: line_item.sku) { click_icon 'arrows-h' }
315
- accept_alert "Desired shipment not enough stock in desired stock location" do
316
- complete_split_to(stock_location2, quantity: 2)
317
- end
318
-
319
- expect(order.shipments.count).to eq(1)
320
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
321
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
322
- end
323
- end
324
-
325
- context 'but it can backorder' do
326
- it 'should allow me to split and backorder the stock' do
327
- product.master.stock_items.last.update_column(:count_on_hand, 0)
328
- product.master.stock_items.last.update_column(:backorderable, true)
329
-
330
- visit spree.edit_admin_order_path(order)
331
-
332
- within('tr', text: line_item.sku) { click_icon 'arrows-h' }
333
- complete_split_to(stock_location2, quantity: 2)
334
-
335
- expect(page).to have_content("Pending package from 'Clarksville'")
336
-
337
- expect(order.shipments.count).to eq(1)
338
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
339
- expect(order.shipments.first.stock_location.id).to eq(stock_location2.id)
340
- end
341
- end
342
- end
343
-
344
- context 'multiple items in cart' do
345
- it 'should have no problem splitting if multiple items are in the from shipment' do
346
- order.contents.add(create(:variant), 2)
347
- order.reload
348
-
349
- visit spree.edit_admin_order_path(order)
350
-
351
- expect(order.shipments.count).to eq(1)
352
- expect(order.shipments.first.manifest.count).to eq(2)
353
-
354
- within('tr', text: line_item.sku) { click_icon 'arrows-h' }
355
- complete_split_to(stock_location2)
356
-
357
- expect(page).to have_css('.shipment', count: 2)
358
-
359
- expect(order.shipments.count).to eq(2)
360
- expect(order.shipments.last.backordered?).to eq(false)
361
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(1)
362
- expect(order.shipments.last.inventory_units_for(product.master).count).to eq(1)
363
- end
364
- end
365
- end
366
-
367
- context 'removing an item' do
368
- let!(:shipment2) { order.shipments.create(stock_location_id: stock_location2.id) }
369
-
370
- it "removes only the one item" do
371
- order.line_items[0].inventory_units[0].update!(shipment: shipment2)
372
- visit spree.edit_admin_order_path(order)
373
-
374
- expect(page).to have_css('.stock-item', count: 2)
375
-
376
- within '[data-hook=admin_shipment_form]', text: shipment2.number do
377
- accept_confirm "Are you sure you want to delete this record?" do
378
- click_icon :trash
379
- end
380
- end
381
-
382
- expect(page).to have_css('.stock-item', count: 1)
383
- end
384
- end
385
-
386
- context 'splitting to shipment' do
387
- let!(:shipment2) { order.shipments.create(stock_location_id: stock_location2.id) }
388
-
389
- it 'should delete the old shipment if enough are split off' do
390
- expect(order.shipments.count).to eq(2)
391
-
392
- visit spree.edit_admin_order_path(order)
393
-
394
- within('tr', text: line_item.sku) { click_icon 'arrows-h' }
395
- complete_split_to(shipment2, quantity: 2)
396
-
397
- expect(page).not_to have_content(/Move .* to/)
398
-
399
- expect(page).to have_css("#shipment_#{shipment2.id}", count: 1)
400
-
401
- expect(order.shipments.count).to eq(1)
402
- expect(order.shipments.last.inventory_units_for(product.master).count).to eq(2)
403
- end
404
-
405
- context 'receiving shipment can not backorder' do
406
- before { product.master.stock_items.last.update_column(:backorderable, false) }
407
-
408
- it 'should not allow a split if the receiving shipment qty plus the incoming is greater than the count_on_hand' do
409
- expect(order.shipments.count).to eq(2)
410
-
411
- visit spree.edit_admin_order_path(order)
412
- expect(page).to have_css('.item-name', text: product.name, count: 1)
413
-
414
- within('tr', text: line_item.sku) { click_icon 'arrows-h' }
415
- complete_split_to(shipment2, quantity: 1)
416
-
417
- expect(page).to have_css('.item-name', text: product.name, count: 2)
418
-
419
- within(all('.stock-contents', count: 2).first) do
420
- within('tr', text: line_item.sku) { click_icon 'arrows-h' }
421
-
422
- accept_alert("Desired shipment not enough stock in desired stock location") do
423
- complete_split_to(shipment2, quantity: 200)
424
- end
425
- end
426
-
427
- expect(order.shipments.count).to eq(2)
428
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(1)
429
- expect(order.shipments.last.inventory_units_for(product.master).count).to eq(1)
430
- end
431
-
432
- it 'should not allow a shipment to split stock to itself' do
433
- visit spree.edit_admin_order_path(order)
434
- within('tr', text: line_item.sku) { click_icon 'arrows-h' }
435
- click_on 'Choose Location'
436
- within '.select2-results' do
437
- expect(page).to have_content(shipment2.number)
438
- expect(page).not_to have_content(shipment1.number)
439
- end
440
- end
441
-
442
- it 'should split fine if more than one line_item is in the receiving shipment' do
443
- variant2 = create(:variant)
444
- order.contents.add(variant2, 2, shipment: shipment2)
445
- order.reload
446
-
447
- visit spree.edit_admin_order_path(order)
448
-
449
- within('tr', text: line_item.sku) { click_icon 'arrows-h' }
450
- complete_split_to(shipment2, quantity: 1)
451
-
452
- expect(page).not_to have_content(/Move .* to/)
453
- expect(page).to have_css('.shipment', count: 2)
454
-
455
- expect(order.shipments.count).to eq(2)
456
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq 1
457
- expect(order.shipments.last.inventory_units_for(product.master).count).to eq 1
458
- expect(order.shipments.first.inventory_units_for(variant2).count).to eq 0
459
- expect(order.shipments.last.inventory_units_for(variant2).count).to eq 2
460
- end
461
- end
462
-
463
- context 'receiving shipment can backorder' do
464
- it 'should add more to the backorder' do
465
- shipment1.inventory_units.update_all(state: :on_hand)
466
- product.master.stock_items.last.update_column(:backorderable, true)
467
- product.master.stock_items.last.update_column(:count_on_hand, 0)
468
- expect(shipment2.reload).not_to be_backordered
469
-
470
- visit spree.edit_admin_order_path(order)
471
-
472
- within('tr', text: line_item.sku) { click_icon 'arrows-h' }
473
- complete_split_to(shipment2, quantity: 1)
474
-
475
- expect(page).to have_content("1 x Backordered")
476
-
477
- within('.stock-contents', text: "1 x On hand") do
478
- within('tr', text: line_item.sku) { click_icon 'arrows-h' }
479
- complete_split_to(shipment2, quantity: 1)
480
- end
481
-
482
- # Empty shipment should be removed
483
- expect(page).to have_css('.stock-contents', count: 1)
484
- expect(page).to have_content("2 x Backordered")
485
- end
486
- end
487
- end
488
-
489
- describe 'line item sort order' do
490
- let(:product2) { create(:product) }
491
- let(:product3) { create(:product) }
492
-
493
- before do
494
- # grab this one first and then create others that should end up before
495
- # and after
496
- @middle_line_item = order.line_items[0]
497
-
498
- @first_line_item = order.contents.add(product2.master)
499
- @first_line_item.update_columns(created_at: 1.day.ago)
500
- @last_line_item = order.contents.add(product3.master)
501
- @last_line_item.update_columns(created_at: 1.day.from_now)
502
- end
503
-
504
- it 'orders the items in a shipment by created_at' do
505
- visit spree.edit_admin_order_path(order)
506
-
507
- stock_items = page.all(:css, '.stock-item', count: 3)
508
-
509
- expect(stock_items[0]).to have_text(@first_line_item.variant.sku)
510
- expect(stock_items[1]).to have_text(@middle_line_item.variant.sku)
511
- expect(stock_items[2]).to have_text(@last_line_item.variant.sku)
512
- end
513
- end
514
- end
515
- end
516
-
517
- context 'with only read permissions' do
518
- before do
519
- allow_any_instance_of(Spree::Admin::BaseController).to receive(:try_spree_current_user).and_return(nil)
520
- end
521
-
522
- custom_authorization! do |_user|
523
- can [:admin, :index, :read, :edit], Spree::Order
524
- end
525
- it "should not display forbidden links" do
526
- visit spree.edit_admin_order_path(order)
527
-
528
- expect(page).not_to have_button('cancel')
529
- expect(page).not_to have_button('Resend')
530
-
531
- # Order Tabs
532
- expect(page).not_to have_link('Adjustments')
533
- expect(page).not_to have_link('Payments')
534
- expect(page).not_to have_link('Return Authorizations')
535
-
536
- # Order item actions
537
- expect(page).not_to have_css('.delete-item')
538
- expect(page).not_to have_css('.split-item')
539
- expect(page).not_to have_css('.edit-tracking')
540
- end
541
- end
542
-
543
- context 'as Fakedispatch' do
544
- custom_authorization! do |_user|
545
- # allow dispatch to :admin, :index, and :edit on Spree::Order
546
- can [:admin, :edit, :index, :read], Spree::Order
547
- # allow dispatch to :index, :show, :create and :update shipments on the admin
548
- can [:admin, :manage, :read, :ship], Spree::Shipment
549
- end
550
-
551
- before do
552
- allow(Spree.user_class).to receive(:find_by).
553
- with(hash_including(:spree_api_key)).
554
- and_return(Spree.user_class.new)
555
- end
556
-
557
- it 'should not display order tabs or edit buttons without ability' do
558
- visit spree.edit_admin_order_path(order)
559
-
560
- # Order Tabs
561
- expect(page).not_to have_link('Adjustments')
562
- expect(page).not_to have_link('Payments')
563
- expect(page).not_to have_link('Return Authorizations')
564
- end
565
-
566
- it "can change the shipping method" do
567
- order = create(:completed_order_with_totals)
568
- visit spree.edit_admin_order_path(order)
569
- within("tr", text: "Shipping Method") do
570
- click_icon :edit
571
- end
572
- select "UPS Ground $100.00"
573
- click_icon :check
574
-
575
- expect(page).not_to have_css('#selected_shipping_rate_id')
576
- expect(page).to have_content("UPS Ground")
577
- end
578
-
579
- it 'can ship' do
580
- order = create(:order_ready_to_ship)
581
- order.refresh_shipment_rates
582
- visit spree.edit_admin_order_path(order)
583
-
584
- find(".ship-shipment-button").click
585
-
586
- within '.carton-state' do
587
- expect(page).to have_content('Shipped')
588
- end
589
- end
590
- end
591
- end