solidus_backend 1.0.7 → 1.1.0.beta1

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 (201) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/backend.js +3 -0
  3. data/app/assets/javascripts/spree/backend/admin.js.erb +17 -24
  4. data/app/assets/javascripts/spree/backend/checkouts/edit.js +3 -5
  5. data/app/assets/javascripts/spree/backend/flash.coffee +17 -0
  6. data/app/assets/javascripts/spree/backend/handlebars_extensions.coffee +9 -0
  7. data/app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb +6 -6
  8. data/app/assets/javascripts/spree/backend/option_value_picker.js +43 -0
  9. data/app/assets/javascripts/spree/backend/product_picker.js +10 -8
  10. data/app/assets/javascripts/spree/backend/promotions.js.coffee +101 -0
  11. data/app/assets/javascripts/spree/backend/routes.js +2 -1
  12. data/app/assets/javascripts/spree/backend/shipments.js.erb +1 -1
  13. data/app/assets/javascripts/spree/backend/stock_management/index_add_forms.coffee +1 -1
  14. data/app/assets/javascripts/spree/backend/stock_movement.js.coffee +2 -2
  15. data/app/assets/javascripts/spree/backend/stock_transfers/variant_form.coffee +1 -1
  16. data/app/assets/javascripts/spree/backend/taxon_autocomplete.js.erb +6 -6
  17. data/app/assets/javascripts/spree/backend/taxons.js.coffee +6 -7
  18. data/app/assets/javascripts/spree/backend/templates/orders/customer_details/autocomplete.hbs +17 -0
  19. data/app/assets/javascripts/spree/backend/templates/products/sortable.hbs +5 -0
  20. data/app/assets/javascripts/spree/backend/templates/promotions/calculators/fields/tiered_flat_rate.hbs +17 -0
  21. data/app/assets/javascripts/spree/backend/templates/promotions/calculators/fields/tiered_percent.hbs +17 -0
  22. data/app/assets/javascripts/spree/backend/templates/promotions/rules/option_values.hbs +10 -0
  23. data/app/assets/javascripts/spree/backend/templates/promotions/rules/option_values_select.hbs +1 -0
  24. data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +19 -0
  25. data/app/assets/javascripts/spree/backend/templates/stock_transfers/transfer_item.hbs.erb +52 -0
  26. data/app/assets/javascripts/spree/backend/templates/variants/autocomplete.hbs.erb +23 -0
  27. data/app/assets/javascripts/spree/backend/templates/variants/autocomplete_stock.hbs +51 -0
  28. data/app/assets/javascripts/spree/backend/templates/variants/line_items_autocomplete_stock.hbs +67 -0
  29. data/app/assets/javascripts/spree/backend/templates/variants/split.hbs +27 -0
  30. data/app/assets/javascripts/spree/backend/user_picker.js +8 -8
  31. data/app/assets/javascripts/spree/backend/variant_autocomplete.js.coffee.erb +6 -8
  32. data/app/assets/stylesheets/spree/backend/components/_messages.scss +6 -3
  33. data/app/assets/stylesheets/spree/backend/sections/_promotions.scss +16 -0
  34. data/app/controllers/spree/admin/base_controller.rb +1 -1
  35. data/app/controllers/spree/admin/option_types_controller.rb +1 -3
  36. data/app/controllers/spree/admin/orders/customer_details_controller.rb +1 -1
  37. data/app/controllers/spree/admin/orders_controller.rb +6 -11
  38. data/app/controllers/spree/admin/product_properties_controller.rb +9 -0
  39. data/app/controllers/spree/admin/products_controller.rb +20 -5
  40. data/app/controllers/spree/admin/promotions_controller.rb +2 -1
  41. data/app/controllers/spree/admin/reimbursements_controller.rb +20 -0
  42. data/app/controllers/spree/admin/resource_controller.rb +1 -1
  43. data/app/controllers/spree/admin/return_authorizations_controller.rb +5 -0
  44. data/app/controllers/spree/admin/root_controller.rb +1 -1
  45. data/app/controllers/spree/admin/search_controller.rb +2 -4
  46. data/app/controllers/spree/admin/states_controller.rb +1 -1
  47. data/app/controllers/spree/admin/stock_items_controller.rb +1 -1
  48. data/app/controllers/spree/admin/stock_transfers_controller.rb +3 -14
  49. data/app/controllers/spree/admin/users_controller.rb +2 -3
  50. data/app/controllers/spree/admin/variant_property_rule_values_controller.rb +7 -0
  51. data/app/controllers/spree/admin/variants_controller.rb +1 -1
  52. data/app/controllers/spree/admin/zones_controller.rb +1 -1
  53. data/app/helpers/spree/admin/adjustments_helper.rb +4 -9
  54. data/app/helpers/spree/admin/base_helper.rb +7 -6
  55. data/app/helpers/spree/admin/navigation_helper.rb +8 -2
  56. data/app/helpers/spree/admin/orders_helper.rb +1 -1
  57. data/app/helpers/spree/admin/products_helper.rb +2 -4
  58. data/app/helpers/spree/admin/stock_movements_helper.rb +3 -3
  59. data/app/views/spree/admin/adjustments/_adjustment.html.erb +1 -1
  60. data/app/views/spree/admin/orders/_add_line_item.html.erb +0 -5
  61. data/app/views/spree/admin/orders/_add_product.html.erb +0 -3
  62. data/app/views/spree/admin/orders/_carton.html.erb +0 -1
  63. data/app/views/spree/admin/orders/_shipment.html.erb +0 -1
  64. data/app/views/spree/admin/orders/confirm/_shipment.html.erb +0 -1
  65. data/app/views/spree/admin/orders/customer_details/_form.html.erb +1 -1
  66. data/app/views/spree/admin/orders/customer_details/edit.html.erb +0 -1
  67. data/app/views/spree/admin/orders/index.html.erb +1 -2
  68. data/app/views/spree/admin/payment_methods/_form.html.erb +0 -4
  69. data/app/views/spree/admin/payment_methods/index.html.erb +0 -2
  70. data/app/views/spree/admin/payments/source_views/_gateway.html.erb +3 -0
  71. data/app/views/spree/admin/product_properties/index.html.erb +52 -2
  72. data/app/views/spree/admin/promotions/_actions.html.erb +14 -10
  73. data/app/views/spree/admin/promotions/_promotion_action.html.erb +5 -3
  74. data/app/views/spree/admin/promotions/_promotion_rule.html.erb +5 -3
  75. data/app/views/spree/admin/promotions/_rules.html.erb +18 -14
  76. data/app/views/spree/admin/promotions/calculators/tiered_flat_rate/_fields.html.erb +5 -28
  77. data/app/views/spree/admin/promotions/calculators/tiered_percent/_fields.html.erb +5 -27
  78. data/app/views/spree/admin/promotions/edit.html.erb +6 -4
  79. data/app/views/spree/admin/promotions/index.html.erb +1 -1
  80. data/app/views/spree/admin/promotions/rules/_option_value.html.erb +13 -0
  81. data/app/views/spree/admin/refund_reasons/index.html.erb +2 -2
  82. data/app/views/spree/admin/reimbursements/edit.html.erb +1 -1
  83. data/app/views/spree/admin/return_authorizations/_form.html.erb +2 -2
  84. data/app/views/spree/admin/search/users.rabl +1 -1
  85. data/app/views/spree/admin/shared/_order_summary.html.erb +6 -0
  86. data/app/views/spree/admin/shared/_tabs.html.erb +2 -2
  87. data/app/views/spree/admin/shared/_translations.html.erb +16 -46
  88. data/app/views/spree/admin/shared/named_types/_index.html.erb +2 -2
  89. data/app/views/spree/admin/stock_items/_stock_management.html.erb +0 -2
  90. data/app/views/spree/admin/stock_movements/_form.html.erb +0 -2
  91. data/app/views/spree/admin/stock_transfers/edit.html.erb +0 -3
  92. data/app/views/spree/admin/stock_transfers/receive.html.erb +0 -2
  93. data/app/views/spree/admin/stock_transfers/show.html.erb +1 -1
  94. data/app/views/spree/admin/taxons/index.html.erb +0 -1
  95. data/app/views/spree/admin/users/_addresses_form.html.erb +4 -4
  96. data/app/views/spree/layouts/admin.html.erb +11 -9
  97. data/config/routes.rb +5 -0
  98. data/lib/spree/backend.rb +1 -2
  99. metadata +41 -139
  100. data/CHANGELOG.md +0 -1
  101. data/Gemfile +0 -6
  102. data/Rakefile +0 -15
  103. data/app/assets/javascripts/spree/backend/handlebar_extensions.js +0 -9
  104. data/app/assets/javascripts/spree/backend/promotions.js +0 -73
  105. data/app/assets/javascripts/spree/backend/stock_transfer.js.coffee +0 -196
  106. data/app/views/spree/admin/products/_autocomplete.js.erb +0 -14
  107. data/app/views/spree/admin/products/_sortable.html +0 -7
  108. data/app/views/spree/admin/stock_items/_stock_location_stock_item_template.html.erb +0 -21
  109. data/app/views/spree/admin/stock_transfers/_transfer_item_template.html.erb +0 -54
  110. data/app/views/spree/admin/variants/_autocomplete.js.erb +0 -25
  111. data/app/views/spree/admin/variants/_autocomplete_line_items_stock.js.erb +0 -69
  112. data/app/views/spree/admin/variants/_autocomplete_stock.js.erb +0 -53
  113. data/app/views/spree/admin/variants/_split.js.erb +0 -29
  114. data/script/rails +0 -9
  115. data/solidus_backend.gemspec +0 -30
  116. data/spec/controllers/spree/admin/base_controller_spec.rb +0 -24
  117. data/spec/controllers/spree/admin/cancellations_controller_spec.rb +0 -77
  118. data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +0 -234
  119. data/spec/controllers/spree/admin/general_settings_controller_spec.rb +0 -41
  120. data/spec/controllers/spree/admin/missing_products_controller_spec.rb +0 -18
  121. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +0 -80
  122. data/spec/controllers/spree/admin/orders_controller_spec.rb +0 -472
  123. data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +0 -49
  124. data/spec/controllers/spree/admin/payments_controller_spec.rb +0 -175
  125. data/spec/controllers/spree/admin/products_controller_spec.rb +0 -45
  126. data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +0 -21
  127. data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +0 -18
  128. data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +0 -21
  129. data/spec/controllers/spree/admin/promotions_controller_spec.rb +0 -122
  130. data/spec/controllers/spree/admin/refunds_controller_spec.rb +0 -32
  131. data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +0 -75
  132. data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -134
  133. data/spec/controllers/spree/admin/resource_controller_spec.rb +0 -166
  134. data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +0 -226
  135. data/spec/controllers/spree/admin/return_items_controller_spec.rb +0 -27
  136. data/spec/controllers/spree/admin/root_controller_spec.rb +0 -41
  137. data/spec/controllers/spree/admin/search_controller_spec.rb +0 -104
  138. data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +0 -14
  139. data/spec/controllers/spree/admin/stock_items_controller_spec.rb +0 -50
  140. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +0 -41
  141. data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +0 -331
  142. data/spec/controllers/spree/admin/store_credits_controller_spec.rb +0 -309
  143. data/spec/controllers/spree/admin/users_controller_spec.rb +0 -236
  144. data/spec/controllers/spree/admin/variants_controller_spec.rb +0 -32
  145. data/spec/features/admin/configuration/analytics_tracker_spec.rb +0 -54
  146. data/spec/features/admin/configuration/countries_spec.rb +0 -22
  147. data/spec/features/admin/configuration/general_settings_spec.rb +0 -45
  148. data/spec/features/admin/configuration/payment_methods_spec.rb +0 -125
  149. data/spec/features/admin/configuration/shipping_methods_spec.rb +0 -64
  150. data/spec/features/admin/configuration/states_spec.rb +0 -64
  151. data/spec/features/admin/configuration/stock_locations_spec.rb +0 -50
  152. data/spec/features/admin/configuration/tax_categories_spec.rb +0 -56
  153. data/spec/features/admin/configuration/tax_rates_spec.rb +0 -30
  154. data/spec/features/admin/configuration/taxonomies_spec.rb +0 -52
  155. data/spec/features/admin/configuration/zones_spec.rb +0 -39
  156. data/spec/features/admin/homepage_spec.rb +0 -78
  157. data/spec/features/admin/locale_spec.rb +0 -30
  158. data/spec/features/admin/orders/adjustments_promotions_spec.rb +0 -53
  159. data/spec/features/admin/orders/adjustments_spec.rb +0 -126
  160. data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +0 -48
  161. data/spec/features/admin/orders/cancelling_inventory_spec.rb +0 -48
  162. data/spec/features/admin/orders/customer_details_spec.rb +0 -163
  163. data/spec/features/admin/orders/line_items_spec.rb +0 -50
  164. data/spec/features/admin/orders/listing_spec.rb +0 -130
  165. data/spec/features/admin/orders/log_entries_spec.rb +0 -55
  166. data/spec/features/admin/orders/new_order_spec.rb +0 -197
  167. data/spec/features/admin/orders/order_details_spec.rb +0 -533
  168. data/spec/features/admin/orders/payments_spec.rb +0 -228
  169. data/spec/features/admin/orders/risk_analysis_spec.rb +0 -47
  170. data/spec/features/admin/orders/shipments_spec.rb +0 -65
  171. data/spec/features/admin/payments/store_credits_spec.rb +0 -21
  172. data/spec/features/admin/products/edit/images_spec.rb +0 -87
  173. data/spec/features/admin/products/edit/products_spec.rb +0 -66
  174. data/spec/features/admin/products/edit/taxons_spec.rb +0 -56
  175. data/spec/features/admin/products/edit/variants_spec.rb +0 -61
  176. data/spec/features/admin/products/option_types_spec.rb +0 -114
  177. data/spec/features/admin/products/products_spec.rb +0 -392
  178. data/spec/features/admin/products/properties_spec.rb +0 -139
  179. data/spec/features/admin/products/prototypes_spec.rb +0 -110
  180. data/spec/features/admin/products/stock_management_spec.rb +0 -82
  181. data/spec/features/admin/products/variant_spec.rb +0 -51
  182. data/spec/features/admin/promotion_adjustments_spec.rb +0 -220
  183. data/spec/features/admin/promotions/tiered_calculator_spec.rb +0 -69
  184. data/spec/features/admin/promotions/user_rule_spec.rb +0 -25
  185. data/spec/features/admin/reports_spec.rb +0 -61
  186. data/spec/features/admin/stock_transfer_spec.rb +0 -86
  187. data/spec/features/admin/store_credits_spec.rb +0 -82
  188. data/spec/features/admin/taxons_spec.rb +0 -31
  189. data/spec/features/admin/users_spec.rb +0 -270
  190. data/spec/helpers/admin/base_helper_spec.rb +0 -24
  191. data/spec/helpers/admin/navigation_helper_spec.rb +0 -73
  192. data/spec/helpers/admin/reimbursements_helper_spec.rb +0 -34
  193. data/spec/helpers/admin/stock_movements_helper_spec.rb +0 -29
  194. data/spec/helpers/admin/store_credit_events_helper_spec.rb +0 -95
  195. data/spec/helpers/promotion_rules_helper_spec.rb +0 -12
  196. data/spec/spec_helper.rb +0 -108
  197. data/spec/support/appear_before_matcher.rb +0 -8
  198. data/spec/support/ror_ringer.jpeg +0 -0
  199. data/spec/test_views/spree/admin/widgets/edit.html.erb +0 -1
  200. data/spec/test_views/spree/admin/widgets/new.html.erb +0 -1
  201. data/vendor/assets/javascripts/handlebars.js +0 -2746
@@ -1,197 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "New Order", :type => :feature do
4
- let!(:product) { create(:product_in_stock) }
5
- let!(:state) { create(:state) }
6
- let!(:store) { create(:store) }
7
- let!(:user) { create(:user, ship_address: create(:address), bill_address: create(:address)) }
8
- let!(:payment_method) { create(:check_payment_method) }
9
- let!(:shipping_method) { create(:shipping_method, cost: 0.0) }
10
-
11
- stub_authorization!
12
-
13
- before do
14
- visit spree.admin_path
15
- click_on "Orders"
16
- click_on "New Order"
17
- end
18
-
19
- it "does check if you have a billing address before letting you add shipments" do
20
- click_on "Shipments"
21
- expect(page).to have_content 'Please fill in customer info'
22
- expect(current_path).to eql(spree.edit_admin_order_customer_path(Spree::Order.last))
23
- end
24
-
25
- it "completes new order succesfully without using the cart", js: true do
26
- click_on 'Cart'
27
- select2_search product.name, from: Spree.t(:name_or_sku)
28
-
29
- fill_in_quantity("table.stock-levels", "quantity_0", 2)
30
-
31
- click_icon :plus
32
- click_on "Customer Details"
33
-
34
- within "#select-customer" do
35
- targetted_select2_search user.email, from: "#s2id_customer_search"
36
- end
37
-
38
- check "order_use_billing"
39
- fill_in_address
40
- click_on "Update"
41
-
42
- click_on "Payments"
43
- click_on "Update"
44
-
45
- expect(current_path).to eql(spree.admin_order_payments_path(Spree::Order.last))
46
-
47
- click_on "Confirm"
48
- click_on "Complete"
49
-
50
- expect(current_path).to eql(spree.edit_admin_order_path(Spree::Order.last))
51
-
52
- click_on "Payments"
53
- click_icon "capture"
54
-
55
- click_on "Shipments"
56
- click_on "ship"
57
-
58
- within '.carton-state' do
59
- expect(page).to have_content('SHIPPED')
60
- end
61
- end
62
-
63
- context "adding new item to the order", js: true do
64
- it "inventory items show up just fine and are also registered as shipments" do
65
- click_on 'Cart'
66
- select2_search product.name, from: Spree.t(:name_or_sku)
67
-
68
- fill_in_quantity('table.stock-levels', 'quantity_0', 2)
69
-
70
- click_icon :plus
71
-
72
- within(".line-items") do
73
- expect(page).to have_content(product.name)
74
- end
75
-
76
- click_on "Customer Details"
77
-
78
- within "#select-customer" do
79
- targetted_select2_search user.email, from: "#s2id_customer_search"
80
- end
81
-
82
- check "order_use_billing"
83
- fill_in_address
84
- click_on "Update"
85
-
86
- click_on "Shipments"
87
-
88
- within(".stock-contents") do
89
- expect(page).to have_content(product.name)
90
- end
91
- end
92
- end
93
-
94
- # Regression test for #3958
95
- context "without a delivery step", js: true do
96
- before do
97
- allow(Spree::Order).to receive_messages checkout_step_names: [:address, :payment, :confirm, :complete]
98
- end
99
-
100
- it "can still see line items" do
101
- click_on 'Cart'
102
- select2_search product.name, from: Spree.t(:name_or_sku)
103
-
104
- fill_in_quantity('table.stock-levels', 'quantity_0', 1)
105
-
106
- click_icon :plus
107
-
108
- within(".line-items") do
109
- within(".line-item-name") do
110
- expect(page).to have_content(product.name)
111
- end
112
- within(".line-item-qty-show") do
113
- expect(page).to have_content("1")
114
- end
115
- within(".line-item-price") do
116
- expect(page).to have_content(product.price)
117
- end
118
- end
119
- end
120
- end
121
-
122
- # Regression test for #3336
123
- context "start by customer address" do
124
- it "completes order fine", js: true do
125
- click_on "Customer Details"
126
-
127
- within "#select-customer" do
128
- targetted_select2_search user.email, from: "#s2id_customer_search"
129
- end
130
-
131
- check "order_use_billing"
132
- fill_in_address
133
- click_on "Update"
134
-
135
- click_on "Shipments"
136
-
137
- select2_search product.name, from: Spree.t(:name_or_sku)
138
-
139
- click_icon :plus
140
-
141
- expect(page).to have_css('.stock-item')
142
-
143
- click_on "Payments"
144
- click_on "Continue"
145
-
146
- within(".additional-info .state") do
147
- expect(page).to have_content("CONFIRM")
148
- end
149
- end
150
- end
151
-
152
- # Regression test for #5327
153
- context "customer with default credit card", js: true do
154
- before do
155
- create(:credit_card, default: true, user: user)
156
- end
157
- it "transitions to delivery not to complete" do
158
- click_on 'Cart'
159
- select2_search product.name, from: Spree.t(:name_or_sku)
160
- within("table.stock-levels") do
161
- find('.variant_quantity').set(1)
162
- end
163
-
164
- click_icon :plus
165
-
166
- expect(page).to have_css('.line-item')
167
-
168
- click_link "Customer Details"
169
- targetted_select2 user.email, from: "#s2id_customer_search"
170
- click_button "Update"
171
- expect(Spree::Order.last.state).to eq 'delivery'
172
- end
173
- end
174
-
175
- context "customer with attempted XSS", js: true do
176
- let(:xss_string) { %(<script>throw("XSS")</script>) }
177
- before do
178
- user.update!(email: xss_string)
179
- end
180
- it "displays the user's email escaped without executing" do
181
- click_on "Customer Details"
182
- targetted_select2_search user.email, from: "#s2id_customer_search"
183
- expect(page).to have_field("Email", with: xss_string)
184
- end
185
- end
186
-
187
- def fill_in_address(kind = "bill")
188
- fill_in "First Name", with: "John 99"
189
- fill_in "Last Name", with: "Doe"
190
- fill_in "Street Address", with: "100 first lane"
191
- fill_in "Street Address (cont'd)", with: "#101"
192
- fill_in "City", with: "Bethesda"
193
- fill_in "Zip", with: "20170"
194
- targetted_select2_search state.name, from: "#s2id_order_#{kind}_address_attributes_state_id"
195
- fill_in "Phone", with: "123-456-7890"
196
- end
197
- end
@@ -1,533 +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!(:tote) { create(:product, :name => "Tote", :price => 15.00) }
8
- let(:order) { create(:order, :state => 'complete', :completed_at => "2011-02-01 12:36:15", :number => "R100") }
9
- let(:state) { create(:state) }
10
- #let(:shipment) { create(:shipment, :order => order, :stock_location => stock_location) }
11
- let!(:shipping_method) { create(:shipping_method, :name => "Default") }
12
-
13
- before do
14
- order.shipments.create(stock_location_id: stock_location.id)
15
- order.contents.add(product.master, 2)
16
- end
17
-
18
- context 'as Admin' do
19
- stub_authorization!
20
-
21
-
22
- context "cart edit page" do
23
- before do
24
- product.master.stock_items.first.update_column(:count_on_hand, 100)
25
- visit spree.cart_admin_order_path(order)
26
- end
27
-
28
-
29
- it "should allow me to edit order details" do
30
- expect(page).to have_content("spree t-shirt")
31
- expect(page).to have_content("$40.00")
32
-
33
- within_row(1) do
34
- click_icon :edit
35
- fill_in "quantity", :with => "1"
36
- end
37
- click_icon :ok
38
-
39
- within("#order_total") do
40
- expect(page).to have_content("$20.00")
41
- end
42
- end
43
-
44
- it "can add an item to a shipment" do
45
- select2_search "spree t-shirt", :from => Spree.t(:name_or_sku)
46
- within("table.stock-levels") do
47
- fill_in "quantity_0", :with => 2
48
- end
49
-
50
- click_icon :plus
51
-
52
- within("#order_total") do
53
- expect(page).to have_content("$80.00")
54
- end
55
- end
56
-
57
- it "can remove an item from a shipment" do
58
- expect(page).to have_content("spree t-shirt")
59
-
60
- within_row(1) do
61
- accept_alert do
62
- click_icon :trash
63
- end
64
- end
65
-
66
- expect(page).to have_content("YOUR ORDER IS EMPTY") # wait for page refresh
67
- expect(page).not_to have_content("spree t-shirt")
68
- end
69
-
70
- # Regression test for #3862
71
- it "can cancel removing an item from a shipment" do
72
- expect(page).to have_content("spree t-shirt")
73
-
74
- within_row(1) do
75
- # Click "cancel" on confirmation dialog
76
- dismiss_alert do
77
- click_icon :trash
78
- end
79
- end
80
-
81
- expect(page).to have_content("spree t-shirt")
82
- end
83
-
84
- it "can add tracking information" do
85
- visit spree.edit_admin_order_path(order)
86
-
87
- within(".show-tracking") do
88
- click_icon :edit
89
- end
90
- fill_in "tracking", :with => "FOOBAR"
91
- click_icon :check
92
-
93
- expect(page).not_to have_css("input[name=tracking]")
94
- expect(page).to have_content("Tracking: FOOBAR")
95
- end
96
-
97
- it "can change the shipping method" do
98
- order = create(:completed_order_with_totals)
99
- visit spree.edit_admin_order_path(order)
100
- within("table.index tr.show-method") do
101
- click_icon :edit
102
- end
103
- select2 "Default", :from => "Shipping Method"
104
- click_icon :check
105
-
106
- expect(page).not_to have_css('#selected_shipping_rate_id')
107
- expect(page).to have_content("Default")
108
- end
109
-
110
- it "will show the variant sku" do
111
- order = create(:completed_order_with_totals)
112
- visit spree.edit_admin_order_path(order)
113
- sku = order.line_items.first.variant.sku
114
- expect(page).to have_content("SKU: #{sku}")
115
- end
116
-
117
- context "with special_instructions present" do
118
- let(:order) { create(:order, :state => 'complete', :completed_at => "2011-02-01 12:36:15", :number => "R100", :special_instructions => "Very special instructions here") }
119
- it "will show the special_instructions" do
120
- visit spree.edit_admin_order_path(order)
121
- expect(page).to have_content("Very special instructions here")
122
- end
123
- end
124
-
125
- context "variant doesn't track inventory" do
126
- before do
127
- tote.master.update_column :track_inventory, false
128
- # make sure there's no stock level for any item
129
- tote.master.stock_items.update_all count_on_hand: 0, backorderable: false
130
- end
131
-
132
- it "adds variant to order just fine" do
133
- select2_search tote.name, :from => Spree.t(:name_or_sku)
134
- within("table.stock-levels") do
135
- fill_in "variant_quantity", :with => 1
136
- end
137
-
138
- click_icon :plus
139
-
140
- within(".line-items") do
141
- expect(page).to have_content(tote.name)
142
- end
143
- end
144
- end
145
-
146
- context "variant out of stock and not backorderable" do
147
- before do
148
- product.master.stock_items.first.update_column(:backorderable, false)
149
- product.master.stock_items.first.update_column(:count_on_hand, 0)
150
- end
151
-
152
- it "doesn't display the out of stock variant in the search results" do
153
- select2_search_without_selection product.name, from: ".variant_autocomplete"
154
-
155
- expect(page).to have_selector('.select2-no-results')
156
- within(".select2-no-results") do
157
- expect(page).to have_content("NO MATCHES FOUND")
158
- end
159
- end
160
- end
161
- end
162
-
163
-
164
- context 'Shipment edit page' do
165
- let!(:stock_location2) { create(:stock_location_with_items, name: 'Clarksville') }
166
-
167
- before do
168
- product.master.stock_items.first.update_column(:backorderable, true)
169
- product.master.stock_items.first.update_column(:count_on_hand, 100)
170
- product.master.stock_items.last.update_column(:count_on_hand, 100)
171
- end
172
-
173
- context 'splitting to location' do
174
- before { visit spree.edit_admin_order_path(order) }
175
- # can not properly implement until poltergeist supports checking alert text
176
- # see https://github.com/teampoltergeist/poltergeist/pull/516
177
- it 'should warn you if you have not selected a location or shipment'
178
-
179
- context 'there is enough stock at the other location' do
180
- it 'should allow me to make a split' do
181
- expect(order.shipments.count).to eq(1)
182
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
183
-
184
- within_row(1) { click_icon 'arrows-h' }
185
- targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
186
- click_icon :ok
187
-
188
- expect(page).to have_css('.shipment', count: 2)
189
-
190
- expect(order.shipments.count).to eq(2)
191
- expect(order.shipments.last.backordered?).to eq(false)
192
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(1)
193
- expect(order.shipments.last.inventory_units_for(product.master).count).to eq(1)
194
- end
195
-
196
- it 'should allow me to make a transfer via splitting off all stock' do
197
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
198
-
199
- within_row(1) { click_icon 'arrows-h' }
200
- targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
201
- fill_in 'item_quantity', with: 2
202
- click_icon :ok
203
-
204
- expect(page).to have_content("PENDING PACKAGE FROM 'CLARKSVILLE'")
205
-
206
- expect(order.shipments.count).to eq(1)
207
- expect(order.shipments.last.backordered?).to eq(false)
208
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
209
- expect(order.shipments.first.stock_location.id).to eq(stock_location2.id)
210
- end
211
-
212
- it 'should allow me to split more than I have if available there' do
213
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
214
-
215
- within_row(1) { click_icon 'arrows-h' }
216
- targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
217
- fill_in 'item_quantity', with: 5
218
- click_icon :ok
219
-
220
- expect(page).to have_content("PENDING PACKAGE FROM 'CLARKSVILLE'")
221
-
222
- expect(order.shipments.count).to eq(1)
223
- expect(order.shipments.last.backordered?).to eq(false)
224
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(5)
225
- expect(order.shipments.first.stock_location.id).to eq(stock_location2.id)
226
- end
227
-
228
- it 'should not split anything if the input quantity is garbage' do
229
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
230
-
231
- within_row(1) { click_icon 'arrows-h' }
232
- targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
233
- fill_in 'item_quantity', with: 'ff'
234
- click_icon :ok
235
-
236
- wait_for_ajax
237
-
238
- expect(order.shipments.count).to eq(1)
239
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
240
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
241
- end
242
-
243
- it 'should not allow less than or equal to zero qty' do
244
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
245
-
246
- within_row(1) { click_icon 'arrows-h' }
247
- targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
248
- fill_in 'item_quantity', with: 0
249
- click_icon :ok
250
-
251
- wait_for_ajax
252
-
253
- expect(order.shipments.count).to eq(1)
254
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
255
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
256
-
257
-
258
- fill_in 'item_quantity', with: -1
259
- click_icon :ok
260
-
261
- wait_for_ajax
262
-
263
- expect(order.shipments.count).to eq(1)
264
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
265
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
266
- end
267
-
268
- context 'A shipment has shipped' do
269
-
270
- it 'should not show or let me back to the cart page, nor show the shipment edit buttons' do
271
- order = create(:order, :state => 'payment', :number => "R100")
272
- order.shipments.create!(stock_location_id: stock_location.id, state: 'shipped')
273
-
274
- visit spree.cart_admin_order_path(order)
275
-
276
- expect(page.current_path).to eq(spree.edit_admin_order_path(order))
277
- expect(page).not_to have_text 'Cart'
278
- expect(page).not_to have_selector('.fa-arrows-h')
279
- expect(page).not_to have_selector('.fa-trash')
280
- end
281
-
282
- end
283
- end
284
-
285
- context 'there is not enough stock at the other location' do
286
- context 'and it cannot backorder' do
287
- it 'should not allow me to split stock' do
288
- product.master.stock_items.last.update_column(:backorderable, false)
289
- product.master.stock_items.last.update_column(:count_on_hand, 0)
290
-
291
- within_row(1) { click_icon 'arrows-h' }
292
- targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
293
- fill_in 'item_quantity', with: 2
294
- click_icon :ok
295
-
296
- wait_for_ajax
297
-
298
- expect(order.shipments.count).to eq(1)
299
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
300
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
301
- end
302
-
303
- end
304
-
305
- context 'but it can backorder' do
306
- it 'should allow me to split and backorder the stock' do
307
- product.master.stock_items.last.update_column(:count_on_hand, 0)
308
- product.master.stock_items.last.update_column(:backorderable, true)
309
-
310
- within_row(1) { click_icon 'arrows-h' }
311
- targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
312
- fill_in 'item_quantity', with: 2
313
- click_icon :ok
314
-
315
- expect(page).to have_content("PENDING PACKAGE FROM 'CLARKSVILLE'")
316
-
317
- expect(order.shipments.count).to eq(1)
318
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
319
- expect(order.shipments.first.stock_location.id).to eq(stock_location2.id)
320
- end
321
- end
322
- end
323
-
324
- context 'multiple items in cart' do
325
- it 'should have no problem splitting if multiple items are in the from shipment' do
326
- order.contents.add(create(:variant), 2)
327
- expect(order.shipments.count).to eq(1)
328
- expect(order.shipments.first.manifest.count).to eq(2)
329
-
330
- within_row(1) { click_icon 'arrows-h' }
331
- targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
332
- click_icon :ok
333
-
334
- expect(page).to have_css('.shipment', count: 2)
335
-
336
- expect(order.shipments.count).to eq(2)
337
- expect(order.shipments.last.backordered?).to eq(false)
338
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(1)
339
- expect(order.shipments.last.inventory_units_for(product.master).count).to eq(1)
340
- end
341
- end
342
- end
343
-
344
-
345
- context 'splitting to shipment' do
346
- before do
347
- @shipment2 = order.shipments.create(stock_location_id: stock_location2.id)
348
- visit spree.edit_admin_order_path(order)
349
- end
350
-
351
- it 'should delete the old shipment if enough are split off' do
352
- expect(order.shipments.count).to eq(2)
353
-
354
- within_row(1) { click_icon 'arrows-h' }
355
- targetted_select2 @shipment2.number, from: '#s2id_item_stock_location'
356
- fill_in 'item_quantity', with: 2
357
- click_icon :ok
358
-
359
- wait_for_ajax
360
-
361
- expect(order.shipments.count).to eq(1)
362
- expect(order.shipments.last.inventory_units_for(product.master).count).to eq(2)
363
- end
364
-
365
- context 'receiving shipment can not backorder' do
366
- before { product.master.stock_items.last.update_column(:backorderable, false) }
367
-
368
- it 'should not allow a split if the receiving shipment qty plus the incoming is greater than the count_on_hand' do
369
- expect(order.shipments.count).to eq(2)
370
-
371
- within_row(1) { click_icon 'arrows-h' }
372
- targetted_select2 @shipment2.number, from: '#s2id_item_stock_location'
373
- fill_in 'item_quantity', with: 1
374
- click_icon :ok
375
-
376
- wait_for_ajax
377
-
378
- within_row(1) { click_icon 'arrows-h' }
379
- targetted_select2 @shipment2.number, from: '#s2id_item_stock_location'
380
- fill_in 'item_quantity', with: 200
381
- click_icon :ok
382
-
383
- wait_for_ajax
384
-
385
- expect(order.shipments.count).to eq(2)
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
-
390
- it 'should not allow a shipment to split stock to itself' do
391
- within_row(1) { click_icon 'arrows-h' }
392
- targetted_select2 order.shipments.first.number, from: '#s2id_item_stock_location'
393
- fill_in 'item_quantity', with: 1
394
- click_icon :ok
395
-
396
- wait_for_ajax
397
-
398
- expect(order.shipments.count).to eq(2)
399
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
400
- end
401
-
402
- it 'should split fine if more than one line_item is in the receiving shipment' do
403
- variant2 = create(:variant)
404
- order.contents.add(variant2, 2, shipment: @shipment2)
405
-
406
- within_row(1) { click_icon 'arrows-h' }
407
- targetted_select2 @shipment2.number, from: '#s2id_item_stock_location'
408
- fill_in 'item_quantity', with: 1
409
- click_icon :ok
410
-
411
- wait_for_ajax
412
-
413
- expect(order.shipments.count).to eq(2)
414
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq 1
415
- expect(order.shipments.last.inventory_units_for(product.master).count).to eq 1
416
- expect(order.shipments.first.inventory_units_for(variant2).count).to eq 0
417
- expect(order.shipments.last.inventory_units_for(variant2).count).to eq 2
418
- end
419
- end
420
-
421
- context 'receiving shipment can backorder' do
422
- it 'should add more to the backorder' do
423
- product.master.stock_items.last.update_column(:backorderable, true)
424
- product.master.stock_items.last.update_column(:count_on_hand, 0)
425
- expect(@shipment2.reload.backordered?).to eq(false)
426
-
427
-
428
- within_row(1) { click_icon 'arrows-h' }
429
- targetted_select2 @shipment2.number, from: '#s2id_item_stock_location'
430
- fill_in 'item_quantity', with: 1
431
- click_icon :ok
432
-
433
- wait_for_ajax
434
-
435
- expect(@shipment2.reload.backordered?).to eq(true)
436
-
437
- within_row(1) { click_icon 'arrows-h' }
438
- targetted_select2 @shipment2.number, from: '#s2id_item_stock_location'
439
- fill_in 'item_quantity', with: 1
440
- click_icon :ok
441
-
442
- wait_for_ajax
443
-
444
- expect(order.shipments.count).to eq(1)
445
- expect(order.shipments.last.inventory_units_for(product.master).count).to eq(2)
446
- expect(@shipment2.reload.backordered?).to eq(true)
447
- end
448
- end
449
- end
450
- end
451
- end
452
-
453
- context 'with only read permissions' do
454
- before do
455
- allow_any_instance_of(Spree::Admin::BaseController).to receive(:spree_current_user).and_return(nil)
456
- end
457
-
458
- custom_authorization! do |user|
459
- can [:admin, :index, :read, :edit], Spree::Order
460
- end
461
- it "should not display forbidden links" do
462
- visit spree.edit_admin_order_path(order)
463
-
464
- expect(page).not_to have_button('cancel')
465
- expect(page).not_to have_button('Resend')
466
-
467
- # Order Tabs
468
- expect(page).not_to have_link('Adjustments')
469
- expect(page).not_to have_link('Payments')
470
- expect(page).not_to have_link('Return Authorizations')
471
-
472
- # Order item actions
473
- expect(page).not_to have_css('.delete-item')
474
- expect(page).not_to have_css('.split-item')
475
- expect(page).not_to have_css('.edit-item')
476
- expect(page).not_to have_css('.edit-tracking')
477
-
478
- expect(page).not_to have_css('#add-line-item')
479
- end
480
- end
481
-
482
- context 'as Fakedispatch' do
483
- custom_authorization! do |user|
484
- # allow dispatch to :admin, :index, and :edit on Spree::Order
485
- can [:admin, :edit, :index, :read], Spree::Order
486
- # allow dispatch to :index, :show, :create and :update shipments on the admin
487
- can [:admin, :manage, :read, :ship], Spree::Shipment
488
- end
489
-
490
- before do
491
- allow(Spree.user_class).to receive(:find_by).
492
- with(hash_including(:spree_api_key)).
493
- and_return(Spree.user_class.new)
494
- end
495
-
496
- it 'should not display order tabs or edit buttons without ability' do
497
- visit spree.edit_admin_order_path(order)
498
-
499
- # Order Form
500
- expect(page).not_to have_css('.edit-item')
501
- # Order Tabs
502
- expect(page).not_to have_link('Adjustments')
503
- expect(page).not_to have_link('Payments')
504
- expect(page).not_to have_link('Return Authorizations')
505
- end
506
-
507
- it "can change the shipping method" do
508
- order = create(:completed_order_with_totals)
509
- visit spree.edit_admin_order_path(order)
510
- within("table.index tr.show-method") do
511
- click_icon :edit
512
- end
513
- select2 "Default", :from => "Shipping Method"
514
- click_icon :check
515
-
516
- expect(page).not_to have_css('#selected_shipping_rate_id')
517
- expect(page).to have_content("Default")
518
- end
519
-
520
- it 'can ship' do
521
- order = create(:order_ready_to_ship)
522
- order.refresh_shipment_rates
523
- visit spree.edit_admin_order_path(order)
524
-
525
- find(".ship-shipment-button").click
526
- wait_for_ajax
527
-
528
- within '.carton-state' do
529
- expect(page).to have_content('SHIPPED')
530
- end
531
- end
532
- end
533
- end