solidus_backend 2.2.2 → 2.3.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 (186) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/backend.js +1 -2
  3. data/app/assets/javascripts/spree/backend/address_states.js +1 -1
  4. data/app/assets/javascripts/spree/backend/adjustments.js.coffee +1 -1
  5. data/app/assets/javascripts/spree/backend/admin.js +37 -41
  6. data/app/assets/javascripts/spree/backend/components/editable_table.js.coffee +3 -0
  7. data/app/assets/javascripts/spree/backend/images/index.js.coffee +1 -1
  8. data/app/assets/javascripts/spree/backend/images/upload.js +13 -189
  9. data/app/assets/javascripts/spree/backend/models/image_upload.js +76 -0
  10. data/app/assets/javascripts/spree/backend/models/index.js +2 -0
  11. data/app/assets/javascripts/spree/backend/models/taxonomy.js +3 -0
  12. data/app/assets/javascripts/spree/backend/namespaces.js +3 -1
  13. data/app/assets/javascripts/spree/backend/payments/new.js +8 -36
  14. data/app/assets/javascripts/spree/backend/promotions.js.coffee +1 -1
  15. data/app/assets/javascripts/spree/backend/select_payments.js.coffee +0 -12
  16. data/app/assets/javascripts/spree/backend/shipments.js +1 -1
  17. data/app/assets/javascripts/spree/backend/spree-select2.js +1 -1
  18. data/app/assets/javascripts/spree/backend/taxonomy.js.coffee +101 -95
  19. data/app/assets/javascripts/spree/backend/templates/products/upload_progress.hbs +5 -3
  20. data/app/assets/javascripts/spree/backend/views/images/upload_progress.js +48 -0
  21. data/app/assets/javascripts/spree/backend/views/images/upload_zone.js +39 -0
  22. data/app/assets/javascripts/spree/backend/views/index.js +6 -0
  23. data/app/assets/javascripts/spree/backend/views/order/address.js +1 -5
  24. data/app/assets/javascripts/spree/backend/views/payment/edit_credit_card.js +23 -0
  25. data/app/assets/javascripts/spree/backend/views/payment/new.js +25 -0
  26. data/app/assets/javascripts/spree/backend/views/state_select.js +4 -4
  27. data/app/assets/javascripts/spree/backend/views/tables/editable_table.js.coffee +14 -0
  28. data/app/assets/javascripts/spree/backend/views/tables/editable_table_row.js.coffee +45 -0
  29. data/app/assets/stylesheets/spree/backend/components/_date-picker.scss +0 -1
  30. data/app/assets/stylesheets/spree/backend/components/_editable_table.scss +37 -0
  31. data/app/assets/stylesheets/spree/backend/plugins/_bootstrap_tooltip.scss +2 -2
  32. data/app/assets/stylesheets/spree/backend/sections/_products.scss +0 -8
  33. data/app/assets/stylesheets/spree/backend/sections/_style_guide.scss +15 -9
  34. data/app/assets/stylesheets/spree/backend/shared/_icons.scss +14 -14
  35. data/app/assets/stylesheets/spree/backend/shared/_tables.scss +1 -2
  36. data/app/assets/stylesheets/spree/backend/shared/_utilities.scss +13 -0
  37. data/app/assets/stylesheets/spree/backend/spree_admin.scss +1 -1
  38. data/app/controllers/spree/admin/cancellations_controller.rb +1 -1
  39. data/app/controllers/spree/admin/orders/customer_details_controller.rb +1 -1
  40. data/app/controllers/spree/admin/orders_controller.rb +3 -10
  41. data/app/controllers/spree/admin/payment_methods_controller.rb +19 -6
  42. data/app/controllers/spree/admin/payments_controller.rb +2 -2
  43. data/app/controllers/spree/admin/products_controller.rb +3 -9
  44. data/app/controllers/spree/admin/promotion_rules_controller.rb +5 -1
  45. data/app/controllers/spree/admin/promotions_controller.rb +1 -1
  46. data/app/controllers/spree/admin/properties_controller.rb +1 -1
  47. data/app/controllers/spree/admin/reports_controller.rb +24 -21
  48. data/app/controllers/spree/admin/resource_controller.rb +25 -14
  49. data/app/controllers/spree/admin/style_guide_controller.rb +4 -0
  50. data/app/controllers/spree/admin/users_controller.rb +1 -1
  51. data/app/controllers/spree/admin/variants_controller.rb +5 -0
  52. data/app/helpers/spree/admin/navigation_helper.rb +6 -2
  53. data/app/helpers/spree/promotion_rules_helper.rb +2 -2
  54. data/app/models/spree/backend_configuration.rb +1 -0
  55. data/app/views/spree/admin/adjustments/_form.html.erb +1 -1
  56. data/app/views/spree/admin/customer_returns/_return_item_selection.html.erb +2 -2
  57. data/app/views/spree/admin/customer_returns/new.html.erb +1 -1
  58. data/app/views/spree/admin/images/_form.html.erb +1 -1
  59. data/app/views/spree/admin/images/_image_row.html.erb +22 -4
  60. data/app/views/spree/admin/images/create.js.erb +8 -5
  61. data/app/views/spree/admin/images/index.html.erb +4 -8
  62. data/app/views/spree/admin/orders/_risk_analysis.html.erb +6 -7
  63. data/app/views/spree/admin/orders/_shipment.html.erb +1 -1
  64. data/app/views/spree/admin/orders/confirm/_customer_details.html.erb +1 -1
  65. data/app/views/spree/admin/orders/confirm/_payments.html.erb +1 -1
  66. data/app/views/spree/admin/orders/index.html.erb +3 -3
  67. data/app/views/spree/admin/payment_methods/_form.html.erb +5 -5
  68. data/app/views/spree/admin/payments/_form.html.erb +2 -2
  69. data/app/views/spree/admin/payments/_list.html.erb +1 -1
  70. data/app/views/spree/admin/payments/show.html.erb +1 -1
  71. data/app/views/spree/admin/payments/source_forms/_gateway.html.erb +2 -7
  72. data/app/views/spree/admin/prices/_form.html.erb +2 -2
  73. data/app/views/spree/admin/prices/edit.html.erb +2 -0
  74. data/app/views/spree/admin/prices/index.html.erb +5 -4
  75. data/app/views/spree/admin/prices/new.html.erb +4 -0
  76. data/app/views/spree/admin/product_properties/index.html.erb +1 -1
  77. data/app/views/spree/admin/products/_form.html.erb +4 -3
  78. data/app/views/spree/admin/products/index.html.erb +3 -3
  79. data/app/views/spree/admin/products/new.html.erb +2 -2
  80. data/app/views/spree/admin/products/new.js.erb +0 -3
  81. data/app/views/spree/admin/promotion_actions/create.js.erb +2 -6
  82. data/app/views/spree/admin/promotion_rules/create.js.erb +0 -8
  83. data/app/views/spree/admin/promotions/_actions.html.erb +2 -2
  84. data/app/views/spree/admin/promotions/_form.html.erb +1 -1
  85. data/app/views/spree/admin/promotions/_promotion_action.html.erb +3 -4
  86. data/app/views/spree/admin/promotions/_promotion_rule.html.erb +3 -3
  87. data/app/views/spree/admin/promotions/_rules.html.erb +1 -1
  88. data/app/views/spree/admin/promotions/actions/_create_item_adjustments.html.erb +6 -2
  89. data/app/views/spree/admin/promotions/actions/_promotion_calculators_with_custom_fields.html.erb +1 -1
  90. data/app/views/spree/admin/promotions/calculators/distributed_amount/_fields.html.erb +54 -0
  91. data/app/views/spree/admin/promotions/calculators/tiered_flat_rate/_fields.html.erb +33 -14
  92. data/app/views/spree/admin/promotions/calculators/tiered_percent/_fields.html.erb +33 -14
  93. data/app/views/spree/admin/promotions/index.html.erb +1 -1
  94. data/app/views/spree/admin/promotions/rules/_first_repeat_purchase_since.html.erb +1 -1
  95. data/app/views/spree/admin/promotions/rules/_item_total.html.erb +1 -1
  96. data/app/views/spree/admin/promotions/rules/_landing_page.html.erb +1 -1
  97. data/app/views/spree/admin/promotions/rules/_nth_order.html.erb +1 -1
  98. data/app/views/spree/admin/promotions/rules/_product.html.erb +1 -1
  99. data/app/views/spree/admin/promotions/rules/_taxon.html.erb +1 -1
  100. data/app/views/spree/admin/promotions/rules/_user_role.html.erb +2 -2
  101. data/app/views/spree/admin/refunds/edit.html.erb +1 -1
  102. data/app/views/spree/admin/refunds/new.html.erb +1 -1
  103. data/app/views/spree/admin/reimbursements/edit.html.erb +2 -2
  104. data/app/views/spree/admin/reports/sales_total.html.erb +1 -1
  105. data/app/views/spree/admin/return_authorizations/_form.html.erb +4 -4
  106. data/app/views/spree/admin/shared/_address_form.html.erb +2 -2
  107. data/app/views/spree/admin/shared/_calculator_fields.html.erb +1 -1
  108. data/app/views/spree/admin/shared/_product_tabs.html.erb +4 -4
  109. data/app/views/spree/admin/shared/_report_order_criteria.html.erb +1 -1
  110. data/app/views/spree/admin/shared/_variant_search.html.erb +1 -1
  111. data/app/views/spree/admin/shipping_methods/_form.html.erb +1 -1
  112. data/app/views/spree/admin/states/index.html.erb +1 -1
  113. data/app/views/spree/admin/stock_items/_stock_management.html.erb +1 -1
  114. data/app/views/spree/admin/stock_locations/_form.html.erb +1 -1
  115. data/app/views/spree/admin/stock_transfers/edit.html.erb +1 -1
  116. data/app/views/spree/admin/stock_transfers/index.html.erb +1 -1
  117. data/app/views/spree/admin/stock_transfers/new.html.erb +1 -1
  118. data/app/views/spree/admin/store_credits/_form.html.erb +1 -1
  119. data/app/views/spree/admin/store_credits/_update_reason_field.html.erb +1 -1
  120. data/app/views/spree/admin/stores/_form.html.erb +1 -1
  121. data/app/views/spree/admin/style_guide/topics/forms/_building_forms.html.erb +4 -8
  122. data/app/views/spree/admin/style_guide/topics/forms/_buttons.html.erb +6 -0
  123. data/app/views/spree/admin/style_guide/topics/forms/_helper_text.html.erb +13 -0
  124. data/app/views/spree/admin/style_guide/topics/forms/_inputs.html.erb +96 -0
  125. data/app/views/spree/admin/style_guide/topics/forms/_labels.html.erb +6 -0
  126. data/app/views/spree/admin/style_guide/topics/forms/_validation.html.erb +8 -1
  127. data/app/views/spree/admin/style_guide/topics/layout/_full_width_table_layout.html.erb +10 -0
  128. data/app/views/spree/admin/style_guide/topics/layout/_helpful_layout.html.erb +0 -0
  129. data/app/views/spree/admin/style_guide/topics/layout/_sidebar_layout.html.erb +4 -0
  130. data/app/views/spree/admin/style_guide/topics/messaging/_flashes.html.erb +10 -4
  131. data/app/views/spree/admin/style_guide/topics/messaging/_tooltips.html.erb +45 -0
  132. data/app/views/spree/admin/style_guide/topics/tables/_forms_in_tables.html.erb +4 -0
  133. data/app/views/spree/admin/style_guide/topics/typography/_lists.html.erb +1 -1
  134. data/app/views/spree/admin/tax_rates/_form.html.erb +17 -3
  135. data/app/views/spree/admin/tax_rates/index.html.erb +12 -3
  136. data/app/views/spree/admin/taxonomies/edit.erb +1 -8
  137. data/app/views/spree/admin/taxons/_form.html.erb +6 -4
  138. data/app/views/spree/admin/taxons/edit.html.erb +0 -15
  139. data/app/views/spree/admin/taxons/index.html.erb +1 -1
  140. data/app/views/spree/admin/variants/_form.html.erb +8 -9
  141. data/app/views/spree/admin/variants/new.js.erb +0 -1
  142. data/config/routes.rb +1 -1
  143. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +1 -1
  144. data/spec/controllers/spree/admin/orders_controller_spec.rb +16 -4
  145. data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +2 -2
  146. data/spec/controllers/spree/admin/payments_controller_spec.rb +1 -1
  147. data/spec/controllers/spree/admin/products_controller_spec.rb +33 -0
  148. data/spec/controllers/spree/admin/variants_controller_spec.rb +39 -13
  149. data/spec/features/admin/configuration/payment_methods_spec.rb +11 -11
  150. data/spec/features/admin/configuration/shipping_methods_spec.rb +1 -1
  151. data/spec/features/admin/configuration/states_spec.rb +4 -4
  152. data/spec/features/admin/configuration/store_spec.rb +3 -3
  153. data/spec/features/admin/configuration/tax_rates_spec.rb +1 -1
  154. data/spec/features/admin/orders/adjustments_spec.rb +1 -1
  155. data/spec/features/admin/orders/customer_details_spec.rb +10 -11
  156. data/spec/features/admin/orders/listing_spec.rb +1 -1
  157. data/spec/features/admin/orders/new_order_spec.rb +4 -11
  158. data/spec/features/admin/orders/order_details_spec.rb +20 -30
  159. data/spec/features/admin/orders/return_payment_state_spec.rb +60 -0
  160. data/spec/features/admin/orders/shipments_spec.rb +7 -0
  161. data/spec/features/admin/products/edit/images_spec.rb +48 -9
  162. data/spec/features/admin/products/edit/variants_spec.rb +1 -1
  163. data/spec/features/admin/products/option_types_spec.rb +2 -2
  164. data/spec/features/admin/products/products_spec.rb +49 -3
  165. data/spec/features/admin/products/stock_management_spec.rb +1 -3
  166. data/spec/features/admin/products/variant_spec.rb +20 -0
  167. data/spec/features/admin/promotion_adjustments_spec.rb +35 -34
  168. data/spec/features/admin/promotions/option_value_rule_spec.rb +2 -2
  169. data/spec/features/admin/promotions/product_rule_spec.rb +1 -1
  170. data/spec/features/admin/promotions/tiered_calculator_spec.rb +2 -2
  171. data/spec/features/admin/promotions/user_rule_spec.rb +2 -2
  172. data/spec/features/admin/stock_transfer_spec.rb +11 -8
  173. data/spec/helpers/admin/navigation_helper_spec.rb +23 -0
  174. metadata +26 -18
  175. data/app/assets/javascripts/spree/backend/images/new.js.coffee +0 -7
  176. data/app/assets/stylesheets/spree/backend/sections/_payments.scss +0 -14
  177. data/app/helpers/spree/admin/images_helper.rb +0 -17
  178. data/app/views/spree/admin/orders/_add_line_item.html.erb +0 -15
  179. data/app/views/spree/admin/prices/new.js.erb +0 -2
  180. data/app/views/spree/admin/products/_properties_form.erb +0 -10
  181. data/app/views/spree/admin/promotions/_tab.html.erb +0 -1
  182. data/app/views/spree/admin/shared/_report_criteria.html.erb +0 -17
  183. data/app/views/spree/admin/states/_new.html.erb +0 -7
  184. data/app/views/spree/admin/stock_locations/_transfer_stock_form.html.erb +0 -38
  185. data/app/views/spree/admin/stock_transfers/_stock_movements.html.erb +0 -27
  186. data/app/views/spree/admin/taxons/_taxon_table.html.erb +0 -23
@@ -12,7 +12,7 @@ describe "Tax Rates", type: :feature do
12
12
 
13
13
  # Regression test for https://github.com/spree/spree/issues/535
14
14
  it "can see a tax rate in the list if the tax category has been deleted" do
15
- tax_rate.tax_category.update_column(:deleted_at, Time.current)
15
+ tax_rate.tax_categories.first.update_column(:deleted_at, Time.current)
16
16
  click_link "Tax Rates"
17
17
 
18
18
  expect(find("table tbody td:nth-child(3)")).to have_content('N/A')
@@ -5,7 +5,7 @@ describe "Adjustments", type: :feature do
5
5
 
6
6
  let!(:ship_address) { create(:address) }
7
7
  let!(:tax_zone) { create(:global_zone) } # will include the above address
8
- let!(:tax_rate) { create(:tax_rate, amount: 0.20, zone: tax_zone, tax_category: tax_category) }
8
+ let!(:tax_rate) { create(:tax_rate, amount: 0.20, zone: tax_zone, tax_categories: [tax_category]) }
9
9
 
10
10
  let!(:order) do
11
11
  create(
@@ -24,7 +24,6 @@ describe "Customer Details", type: :feature, js: true do
24
24
  visit spree.admin_path
25
25
  click_link "Orders"
26
26
  click_link "New Order"
27
- click_on 'Cart'
28
27
 
29
28
  add_line_item product.name, quantity: quantity
30
29
 
@@ -79,7 +78,7 @@ describe "Customer Details", type: :feature, js: true do
79
78
  click_link "Customer"
80
79
 
81
80
  within("#billing") do
82
- targetted_select2 "Brazil", from: "#s2id_order_bill_address_attributes_country_id"
81
+ select "Brazil", from: "Country"
83
82
  fill_in "order_bill_address_attributes_state_name", with: "Piaui"
84
83
  end
85
84
 
@@ -95,8 +94,8 @@ describe "Customer Details", type: :feature, js: true do
95
94
  order.save!
96
95
 
97
96
  click_link "Customer"
98
- within("#shipping") { fill_in_address "ship" }
99
- within("#billing") { fill_in_address "bill" }
97
+ within("#shipping") { fill_in_address }
98
+ within("#billing") { fill_in_address }
100
99
 
101
100
  click_button "Update"
102
101
  click_link "Customer"
@@ -136,6 +135,7 @@ describe "Customer Details", type: :feature, js: true do
136
135
  end
137
136
 
138
137
  it "sets default country when displaying form" do
138
+ click_link "Cart"
139
139
  click_link "Customer"
140
140
  expect(page).to have_field("order_bill_address_attributes_country_id", with: brazil.id, visible: false)
141
141
  end
@@ -158,18 +158,17 @@ describe "Customer Details", type: :feature, js: true do
158
158
  fill_in "order_ship_address_attributes_city", with: "Bethesda"
159
159
  fill_in "order_ship_address_attributes_zipcode", with: "20170"
160
160
 
161
- select_state('Alabama', 'ship')
161
+ within("#shipping") do
162
+ select 'Alabama', from: "State"
163
+ end
164
+
162
165
  fill_in "order_ship_address_attributes_phone", with: "123-456-7890"
163
166
  click_button "Update"
164
167
  end
165
168
  end
166
169
  end
167
170
 
168
- def select_state(state_name, kind = "bill")
169
- targetted_select2 state_name, from: "#s2id_order_#{kind}_address_attributes_state_id"
170
- end
171
-
172
- def fill_in_address(kind = "bill")
171
+ def fill_in_address
173
172
  fill_in "First Name", with: "John 99"
174
173
  fill_in "Last Name", with: "Doe"
175
174
  fill_in "Company", with: "Company"
@@ -177,7 +176,7 @@ describe "Customer Details", type: :feature, js: true do
177
176
  fill_in "Street Address (cont'd)", with: "#101"
178
177
  fill_in "City", with: "Bethesda"
179
178
  fill_in "Zip Code", with: "20170"
180
- select_state("Alabama", kind)
179
+ select 'Alabama', from: "State"
181
180
  fill_in "Phone", with: "123-456-7890"
182
181
  end
183
182
  end
@@ -73,7 +73,7 @@ describe "Orders Listing", type: :feature, js: true do
73
73
  main_store, other_store = stores
74
74
 
75
75
  click_on "Filter Results"
76
- select2 main_store.name, from: Spree.t(:store)
76
+ select main_store.name, from: Spree.t(:store)
77
77
  click_on "Filter Results"
78
78
 
79
79
  within_row(1) do
@@ -4,7 +4,7 @@ describe "New Order", type: :feature do
4
4
  include OrderFeatureHelper
5
5
 
6
6
  let!(:product) { create(:product_in_stock) }
7
- let!(:state) { create(:state) }
7
+ let!(:state) { create(:state, state_code: 'CA') }
8
8
  let!(:store) { create(:store) }
9
9
  let!(:user) { create(:user, ship_address: create(:address), bill_address: create(:address)) }
10
10
  let!(:payment_method) { create(:check_payment_method) }
@@ -25,7 +25,6 @@ describe "New Order", type: :feature do
25
25
  end
26
26
 
27
27
  it "completes new order succesfully without using the cart", js: true do
28
- click_on 'Cart'
29
28
  add_line_item product.name
30
29
 
31
30
  click_on "Customer"
@@ -60,7 +59,6 @@ describe "New Order", type: :feature do
60
59
  end
61
60
 
62
61
  it 'can create split payments', js: true do
63
- click_on 'Cart'
64
62
  add_line_item product.name
65
63
 
66
64
  click_on "Customer"
@@ -87,7 +85,6 @@ describe "New Order", type: :feature do
87
85
 
88
86
  context "adding new item to the order", js: true do
89
87
  it "inventory items show up just fine and are also registered as shipments" do
90
- click_on 'Cart'
91
88
  add_line_item product.name
92
89
 
93
90
  within(".line-items") do
@@ -119,7 +116,6 @@ describe "New Order", type: :feature do
119
116
  end
120
117
 
121
118
  it "can still see line items" do
122
- click_on 'Cart'
123
119
  add_line_item product.name
124
120
 
125
121
  within(".line-items") do
@@ -149,8 +145,7 @@ describe "New Order", type: :feature do
149
145
  fill_in_address
150
146
  click_on "Update"
151
147
 
152
- click_on "Shipments"
153
-
148
+ # Automatically redirected to Shipments page
154
149
  select2_search product.name, from: Spree.t(:name_or_sku)
155
150
 
156
151
  click_icon :plus
@@ -175,8 +170,6 @@ describe "New Order", type: :feature do
175
170
  end
176
171
 
177
172
  it "transitions to delivery not to complete" do
178
- click_on 'Cart'
179
-
180
173
  add_line_item product.name
181
174
 
182
175
  expect(page).to have_css('.line-item')
@@ -200,14 +193,14 @@ describe "New Order", type: :feature do
200
193
  end
201
194
  end
202
195
 
203
- def fill_in_address(kind = "bill")
196
+ def fill_in_address
204
197
  fill_in "First Name", with: "John 99"
205
198
  fill_in "Last Name", with: "Doe"
206
199
  fill_in "Street Address", with: "100 first lane"
207
200
  fill_in "Street Address (cont'd)", with: "#101"
208
201
  fill_in "City", with: "Bethesda"
209
202
  fill_in "Zip Code", with: "20170"
210
- targetted_select2_search state.name, from: "#s2id_order_#{kind}_address_attributes_state_id"
203
+ select state.name, from: "State"
211
204
  fill_in "Phone", with: "123-456-7890"
212
205
  end
213
206
  end
@@ -9,8 +9,6 @@ describe "Order Details", type: :feature, js: true do
9
9
  let!(:tote) { create(:product, name: "Tote", price: 15.00) }
10
10
  let(:order) { create(:order, state: 'complete', completed_at: "2011-02-01 12:36:15", number: "R100") }
11
11
  let(:state) { create(:state) }
12
- # let(:shipment) { create(:shipment, order: order, stock_location: stock_location) }
13
- let!(:shipping_method) { create(:shipping_method, name: "Default") }
14
12
 
15
13
  before do
16
14
  @shipment1 = order.shipments.create(stock_location_id: stock_location.id)
@@ -57,7 +55,7 @@ describe "Order Details", type: :feature, js: true do
57
55
  expect(page).to have_content("spree t-shirt")
58
56
 
59
57
  within_row(1) do
60
- accept_alert do
58
+ accept_confirm "Are you sure you want to delete this record?" do
61
59
  click_icon :trash
62
60
  end
63
61
  end
@@ -74,7 +72,7 @@ describe "Order Details", type: :feature, js: true do
74
72
 
75
73
  within_row(1) do
76
74
  # Click "cancel" on confirmation dialog
77
- dismiss_confirm do
75
+ dismiss_confirm "Are you sure you want to delete this record?" do
78
76
  click_icon :trash
79
77
  end
80
78
  end
@@ -101,11 +99,11 @@ describe "Order Details", type: :feature, js: true do
101
99
  within("table.index tr.show-method") do
102
100
  click_icon :edit
103
101
  end
104
- select2 "Default", from: "Shipping Method"
102
+ select "UPS Ground $100.00", from: "Shipping Method"
105
103
  click_icon :check
106
104
 
107
105
  expect(page).not_to have_css('#selected_shipping_rate_id')
108
- expect(page).to have_content("Default")
106
+ expect(page).to have_content("UPS Ground")
109
107
  end
110
108
 
111
109
  context "with a completed order" do
@@ -219,35 +217,24 @@ describe "Order Details", type: :feature, js: true do
219
217
  expect(order.shipments.first.stock_location.id).to eq(stock_location2.id)
220
218
  end
221
219
 
222
- it 'should not split anything if the input quantity is garbage' do
223
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
224
-
225
- within_row(1) { click_icon 'arrows-h' }
226
- complete_split_to(stock_location2, quantity: 'ff')
227
-
228
- accept_alert "undefined"
229
-
230
- expect(order.shipments.count).to eq(1)
231
- expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
232
- expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
233
- end
234
-
235
220
  it 'should not allow less than or equal to zero qty' do
236
221
  expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
237
222
 
238
223
  within_row(1) { click_icon 'arrows-h' }
239
- complete_split_to(stock_location2, quantity: 0)
240
224
 
241
- accept_alert "undefined"
225
+ accept_alert "Unable to complete split" do
226
+ complete_split_to(stock_location2, quantity: 0)
227
+ end
242
228
 
243
229
  expect(order.shipments.count).to eq(1)
244
230
  expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
245
231
  expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
246
232
 
247
233
  fill_in 'item_quantity', with: -1
248
- click_icon :ok
249
234
 
250
- accept_alert "undefined"
235
+ accept_alert "Unable to complete split" do
236
+ click_icon :ok
237
+ end
251
238
 
252
239
  expect(order.shipments.count).to eq(1)
253
240
  expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
@@ -278,7 +265,7 @@ describe "Order Details", type: :feature, js: true do
278
265
  within_row(1) { click_icon 'arrows-h' }
279
266
  complete_split_to(stock_location2, quantity: 2)
280
267
 
281
- accept_alert "undefined"
268
+ accept_alert "Unable to complete split"
282
269
 
283
270
  expect(order.shipments.count).to eq(1)
284
271
  expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
@@ -333,7 +320,9 @@ describe "Order Details", type: :feature, js: true do
333
320
  expect(page).to have_css('.stock-item', count: 2)
334
321
 
335
322
  within '[data-hook=admin_shipment_form]', text: @shipment2.number do
336
- click_icon :trash
323
+ accept_confirm "Are you sure you want to delete this record?" do
324
+ click_icon :trash
325
+ end
337
326
  end
338
327
 
339
328
  expect(page).to have_css('.stock-item', count: 1)
@@ -374,10 +363,11 @@ describe "Order Details", type: :feature, js: true do
374
363
 
375
364
  within(all('.stock-contents', count: 2).first) do
376
365
  within_row(1) { click_icon 'arrows-h' }
377
- complete_split_to(@shipment2, quantity: 200)
378
- end
379
366
 
380
- accept_alert "undefined"
367
+ accept_alert("Unable to complete split") do
368
+ complete_split_to(@shipment2, quantity: 200)
369
+ end
370
+ end
381
371
 
382
372
  expect(order.shipments.count).to eq(2)
383
373
  expect(order.shipments.first.inventory_units_for(product.master).count).to eq(1)
@@ -520,11 +510,11 @@ describe "Order Details", type: :feature, js: true do
520
510
  within("table.index tr.show-method") do
521
511
  click_icon :edit
522
512
  end
523
- select2 "Default", from: "Shipping Method"
513
+ select "UPS Ground $100.00", from: "Shipping Method"
524
514
  click_icon :check
525
515
 
526
516
  expect(page).not_to have_css('#selected_shipping_rate_id')
527
- expect(page).to have_content("Default")
517
+ expect(page).to have_content("UPS Ground")
528
518
  end
529
519
 
530
520
  it 'can ship' do
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Return payment state spec" do
4
+ stub_authorization!
5
+
6
+ before do
7
+ Spree::RefundReason.create!(name: Spree::RefundReason::RETURN_PROCESSING_REASON, mutable: false)
8
+ end
9
+
10
+ let!(:order) { create(:shipped_order) }
11
+
12
+ # Regression test for https://github.com/spree/spree/issues/6229
13
+ it "refunds and has outstanding_balance of zero", js: true do
14
+ expect(order).to have_attributes(
15
+ total: 110,
16
+ refund_total: 0,
17
+ payment_total: 110,
18
+ outstanding_balance: 0,
19
+ payment_state: 'paid'
20
+ )
21
+
22
+ # From an order with a shipped shipment
23
+ visit "/admin/orders/#{order.number}/edit"
24
+
25
+ # Create a Return Authorization (select the Original Reimbursement type)
26
+ click_on 'RMA'
27
+ click_on 'New RMA'
28
+
29
+ find('.add-item').click # check first (and only) item
30
+ select Spree::StockLocation.first.name, from: 'return_authorization[stock_location_id]', visible: false
31
+ click_on 'Create'
32
+
33
+ # Create a Customer Return (select the item from 'Items in Return Authorizations')
34
+ click_on 'Customer Returns'
35
+ click_on 'New Customer Return'
36
+
37
+ find('input.add-item').click # check first (and only) item
38
+ select 'Received', from: 'customer_return[return_items_attributes][0][reception_status_event]', visible: false
39
+ select Spree::StockLocation.first.name, from: 'customer_return[stock_location_id]', visible: false
40
+ click_on 'Create'
41
+
42
+ # Create reimbursement
43
+ click_on 'Create reimbursement'
44
+
45
+ # Reimburse.
46
+ click_on 'Reimburse'
47
+
48
+ expect(page).to have_css('tr.reimbursement-refund')
49
+
50
+ order.reload
51
+
52
+ expect(order).to have_attributes(
53
+ total: 110,
54
+ refund_total: 10,
55
+ payment_total: 100,
56
+ outstanding_balance: 0,
57
+ payment_state: 'paid'
58
+ )
59
+ end
60
+ end
@@ -73,11 +73,18 @@ describe "Shipments", type: :feature do
73
73
  expect(page).to have_css("#shipment_#{shipment1.id} tr.stock-item", count: 4)
74
74
  shipment2 = (order.reload.shipments.to_a - [shipment1]).first
75
75
  expect(page).to have_css("#shipment_#{shipment2.id} tr.stock-item", count: 1)
76
+ within "#shipment_#{shipment2.id}" do
77
+ expect(page).to have_content("UPS Ground")
78
+ end
76
79
 
77
80
  within_row(2) { click_icon 'arrows-h' }
78
81
  complete_split_to("LA(#{shipment2.number})")
79
82
  expect(page).to have_css("#shipment_#{shipment2.id} tr.stock-item", count: 2)
80
83
  expect(page).to have_css("#shipment_#{shipment1.id} tr.stock-item", count: 3)
84
+
85
+ within "#shipment_#{shipment2.id}" do
86
+ expect(page).to have_content("UPS Ground")
87
+ end
81
88
  end
82
89
 
83
90
  context "with a ready-to-ship order" do
@@ -30,22 +30,33 @@ describe "Product Images", type: :feature do
30
30
  click_button "Update"
31
31
  expect(page).to have_content("successfully created!")
32
32
 
33
+ # Icons are hidden, so hover to have them pop-up
34
+ find('tbody > tr').hover
33
35
  within_row(1) do
34
- click_icon(:edit)
36
+ within ".actions" do
37
+ click_icon :edit
38
+ end
35
39
  end
40
+
36
41
  fill_in "image_alt", with: "ruby on rails t-shirt"
37
42
  click_button "Update"
38
- expect(page).to have_content("successfully updated!")
39
- expect(page).to have_content("ruby on rails t-shirt")
40
43
 
44
+ expect(page).to have_content "successfully updated!"
45
+ expect(page).to have_field "image[alt]", with: "ruby on rails t-shirt"
46
+
47
+ find('tbody > tr').hover
41
48
  accept_alert do
42
49
  click_icon :trash
43
50
  end
44
- expect(page).not_to have_content("ruby on rails t-shirt")
51
+ expect(page).not_to have_field "image[alt]", with: "ruby on rails t-shirt"
45
52
  end
46
53
  end
47
54
 
48
55
  context 'Via the upload zone', js: true do
56
+ before do
57
+ create(:variant, product: product)
58
+ end
59
+
49
60
  it "uploads an image with ajax and appends it to the images table" do
50
61
  visit spree.admin_product_images_path(product)
51
62
  expect(page).to have_content("No images found")
@@ -58,22 +69,30 @@ describe "Product Images", type: :feature do
58
69
  expect(page).not_to have_content("No images found")
59
70
 
60
71
  within("table.index") do
61
- expect(page).to have_css("tbody tr", count: 1)
72
+ expect(page).to have_css "tbody tr", count: 1
62
73
 
63
74
  within("tbody") do
64
- expect(page).to have_xpath("//img[contains(@src,'ror_ringer')]")
75
+ expect(page).to have_xpath "//img[contains(@src,'ror_ringer')]"
76
+ expect(page).to have_content "All"
65
77
  end
78
+
79
+ # Change the image to the other variant
80
+ targetted_select2 "Size: S", from: "#s2id_image_viewable_id"
81
+ click_icon :check
82
+ expect(page).to have_content "Size: S"
66
83
  end
84
+
85
+ expect(Spree::Image.last.viewable).to eq(product.master)
67
86
  end
68
87
  end
69
88
 
70
- # Regression test for https://github.com/spree/spree/issues/2228
71
- it "should see variant images" do
89
+ it "should see variant images and allow for inline changing the image's variant", js: true do
72
90
  variant = create(:variant)
73
91
  variant.images.create!(attachment: File.open(file_path))
74
92
  visit spree.admin_product_images_path(variant.product)
75
93
 
76
94
  expect(page).not_to have_content("No Images Found.")
95
+
77
96
  within("table.index") do
78
97
  expect(page).to have_content(variant.options_text)
79
98
 
@@ -85,10 +104,30 @@ describe "Product Images", type: :feature do
85
104
  expect(page).to have_content("Variant")
86
105
  end
87
106
 
88
- # ensure variant header is displayed
89
107
  within("tbody") do
90
108
  expect(page).to have_content("Size: S")
91
109
  end
110
+
111
+ # Do an inline change of variant and alt
112
+ targetted_select2 "All", from: "#s2id_image_viewable_id"
113
+ fill_in 'image[alt]', with: 'ruby on rails t-shirt'
114
+ click_icon :check
115
+
116
+ expect(page).to have_content "All"
117
+ expect(page).to have_field "image[alt]", with: "ruby on rails t-shirt"
118
+
119
+ # test escape
120
+ find("#image_alt").click # to focus
121
+ fill_in 'image[alt]', with: 'red shirt'
122
+ find("#image_alt").send_keys(:escape)
123
+ expect(page).to have_field "image[alt]", with: "ruby on rails t-shirt"
124
+
125
+ # And then go back to Size S variant, but using Enter key
126
+ targetted_select2 "Size: S", from: "#s2id_image_viewable_id"
127
+ find("#s2id_image_viewable_id").send_keys(:return)
128
+
129
+ expect(page).to have_content "Size: S"
130
+ expect(page).to have_field "image[alt]", with: "ruby on rails t-shirt"
92
131
  end
93
132
  end
94
133