solidus_backend 2.7.4 → 2.9.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 (214) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +12 -8
  3. data/app/assets/images/favicon.ico +0 -0
  4. data/app/assets/javascripts/spree/backend.js +0 -2
  5. data/app/assets/javascripts/spree/backend/adjustments.js +1 -1
  6. data/app/assets/javascripts/spree/backend/components/sortable_table.js +1 -0
  7. data/app/assets/javascripts/spree/backend/components/tabs.js +1 -0
  8. data/app/assets/javascripts/spree/backend/components/tooltips.js +21 -17
  9. data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +1 -1
  10. data/app/assets/javascripts/spree/backend/product_picker.js +1 -1
  11. data/app/assets/javascripts/spree/backend/shipments.js +7 -1
  12. data/app/assets/javascripts/spree/backend/stock_management.js +18 -0
  13. data/app/assets/javascripts/spree/backend/store_credits.js +18 -2
  14. data/app/assets/javascripts/spree/backend/taxons.js +1 -1
  15. data/app/assets/javascripts/spree/backend/templates/orders/line_item.hbs +1 -1
  16. data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +24 -25
  17. data/app/assets/javascripts/spree/backend/user_picker.js +1 -1
  18. data/app/assets/javascripts/spree/backend/variant_autocomplete.js +1 -1
  19. data/app/assets/javascripts/spree/backend/views/order/customer_select.js +1 -1
  20. data/app/assets/javascripts/spree/backend/views/order/summary.js +2 -2
  21. data/app/assets/javascripts/spree/backend/views/stock/add_stock_item.js +15 -4
  22. data/app/assets/javascripts/spree/backend/views/stock/edit_stock_item_row.js +46 -10
  23. data/app/assets/stylesheets/spree/backend/_bootstrap_custom.scss +24 -16
  24. data/app/assets/stylesheets/spree/backend/components/_breadcrumb.scss +12 -0
  25. data/app/assets/stylesheets/spree/backend/components/_buttons.scss +18 -0
  26. data/app/assets/stylesheets/spree/backend/components/_image_placeholder.scss +2 -2
  27. data/app/assets/stylesheets/spree/backend/components/_list_group.scss +2 -2
  28. data/app/assets/stylesheets/spree/backend/components/_messages.scss +20 -12
  29. data/app/assets/stylesheets/spree/backend/components/_navigation.scss +45 -11
  30. data/app/assets/stylesheets/spree/backend/components/_progress.scss +3 -3
  31. data/app/assets/stylesheets/spree/backend/components/_sidebar.scss +1 -2
  32. data/app/assets/stylesheets/spree/backend/components/_tabs.scss +14 -13
  33. data/app/assets/stylesheets/spree/backend/globals/_deprecated_variables.scss +24 -0
  34. data/app/assets/stylesheets/spree/backend/globals/_deprecation.scss +10 -1
  35. data/app/assets/stylesheets/spree/backend/globals/_functions.scss +2 -0
  36. data/app/assets/stylesheets/spree/backend/globals/_variables.scss +88 -57
  37. data/app/assets/stylesheets/spree/backend/globals/_variables_override.scss +1 -0
  38. data/app/assets/stylesheets/spree/backend/globals/mixins/_caret.scss +1 -1
  39. data/app/assets/stylesheets/spree/backend/globals/mixins/_line_through.scss +1 -1
  40. data/app/assets/stylesheets/spree/backend/sections/_log_entries.scss +8 -2
  41. data/app/assets/stylesheets/spree/backend/sections/_orders.scss +25 -6
  42. data/app/assets/stylesheets/spree/backend/sections/_products.scss +3 -1
  43. data/app/assets/stylesheets/spree/backend/sections/_promotions.scss +5 -5
  44. data/app/assets/stylesheets/spree/backend/sections/_stock_management.scss +77 -2
  45. data/app/assets/stylesheets/spree/backend/sections/_style_guide.scss +4 -4
  46. data/app/assets/stylesheets/spree/backend/sections/_taxonomies.scss +1 -1
  47. data/app/assets/stylesheets/spree/backend/shared/_fonts.scss +15 -0
  48. data/app/assets/stylesheets/spree/backend/shared/_forms.scss +27 -7
  49. data/app/assets/stylesheets/spree/backend/shared/_header.scss +2 -2
  50. data/app/assets/stylesheets/spree/backend/shared/_icons.scss +5 -1
  51. data/app/assets/stylesheets/spree/backend/shared/_layout.scss +5 -4
  52. data/app/assets/stylesheets/spree/backend/shared/_tables.scss +11 -6
  53. data/app/assets/stylesheets/spree/backend/shared/_typography.scss +10 -6
  54. data/app/assets/stylesheets/spree/backend/spree_admin.scss +3 -1
  55. data/app/controllers/spree/admin/cancellations_controller.rb +2 -2
  56. data/app/controllers/spree/admin/customer_returns_controller.rb +8 -1
  57. data/app/controllers/spree/admin/locale_controller.rb +1 -1
  58. data/app/controllers/spree/admin/log_entries_controller.rb +3 -0
  59. data/app/controllers/spree/admin/orders/customer_details_controller.rb +8 -1
  60. data/app/controllers/spree/admin/orders_controller.rb +1 -12
  61. data/app/controllers/spree/admin/products_controller.rb +10 -6
  62. data/app/controllers/spree/admin/promotion_codes_controller.rb +19 -1
  63. data/app/controllers/spree/admin/promotions_controller.rb +1 -1
  64. data/app/controllers/spree/admin/reimbursements_controller.rb +7 -2
  65. data/app/controllers/spree/admin/resource_controller.rb +1 -0
  66. data/app/controllers/spree/admin/store_credit_reasons_controller.rb +8 -0
  67. data/app/controllers/spree/admin/store_credits_controller.rb +11 -11
  68. data/app/controllers/spree/admin/users_controller.rb +4 -2
  69. data/app/helpers/spree/admin/base_helper.rb +9 -3
  70. data/app/helpers/spree/admin/navigation_helper.rb +1 -1
  71. data/app/helpers/spree/admin/promotions_helper.rb +15 -0
  72. data/app/models/spree/backend_configuration.rb +38 -21
  73. data/app/views/spree/admin/cancellations/index.html.erb +3 -1
  74. data/app/views/spree/admin/images/_image_row.html.erb +1 -1
  75. data/app/views/spree/admin/images/edit.html.erb +3 -3
  76. data/app/views/spree/admin/images/index.html.erb +3 -3
  77. data/app/views/spree/admin/log_entries/index.html.erb +1 -19
  78. data/app/views/spree/admin/option_types/edit.html.erb +1 -1
  79. data/app/views/spree/admin/orders/_carton_manifest.html.erb +3 -1
  80. data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +1 -1
  81. data/app/views/spree/admin/orders/_shipment_manifest.html.erb +3 -1
  82. data/app/views/spree/admin/orders/confirm/_line_items.html.erb +3 -2
  83. data/app/views/spree/admin/orders/confirm/_shipment_manifest.html.erb +3 -1
  84. data/app/views/spree/admin/orders/index.html.erb +1 -1
  85. data/app/views/spree/admin/payments/_capture_events.html.erb +15 -18
  86. data/app/views/spree/admin/payments/_list.html.erb +1 -1
  87. data/app/views/spree/admin/payments/_log_entries.html.erb +29 -0
  88. data/app/views/spree/admin/payments/show.html.erb +13 -6
  89. data/app/views/spree/admin/payments/source_forms/{_storecredit.html.erb → _store_credit.html.erb} +0 -0
  90. data/app/views/spree/admin/payments/source_views/{_storecredit.html.erb → _store_credit.html.erb} +0 -0
  91. data/app/views/spree/admin/prices/_form.html.erb +1 -1
  92. data/app/views/spree/admin/product_properties/index.html.erb +1 -1
  93. data/app/views/spree/admin/products/_form.html.erb +23 -12
  94. data/app/views/spree/admin/products/edit.html.erb +5 -0
  95. data/app/views/spree/admin/products/index.html.erb +3 -1
  96. data/app/views/spree/admin/promotion_categories/index.html.erb +1 -1
  97. data/app/views/spree/admin/promotion_code_batches/index.html.erb +1 -1
  98. data/app/views/spree/admin/promotion_codes/index.html.erb +5 -1
  99. data/app/views/spree/admin/promotion_codes/new.html.erb +31 -0
  100. data/app/views/spree/admin/promotions/_actions.html.erb +1 -1
  101. data/app/views/spree/admin/promotions/_activations_edit.html.erb +1 -1
  102. data/app/views/spree/admin/promotions/_form.html.erb +6 -5
  103. data/app/views/spree/admin/promotions/_rules.html.erb +1 -1
  104. data/app/views/spree/admin/promotions/edit.html.erb +3 -1
  105. data/app/views/spree/admin/promotions/index.html.erb +4 -4
  106. data/app/views/spree/admin/refunds/new.html.erb +1 -1
  107. data/app/views/spree/admin/reimbursements/edit.html.erb +2 -2
  108. data/app/views/spree/admin/shared/_address_form.html.erb +10 -3
  109. data/app/views/spree/admin/shared/_edit_resource_links.html.erb +1 -1
  110. data/app/views/spree/admin/shared/_head.html.erb +1 -3
  111. data/app/views/spree/admin/shared/_image.html.erb +2 -2
  112. data/app/views/spree/admin/shared/_modal.html.erb +1 -1
  113. data/app/views/spree/admin/shared/_product_sub_menu.html.erb +1 -1
  114. data/app/views/spree/admin/shared/_settings_checkout_tabs.html.erb +4 -0
  115. data/app/views/spree/admin/shared/_settings_sub_menu.html.erb +3 -3
  116. data/app/views/spree/admin/shared/_tabs.html.erb +3 -2
  117. data/app/views/spree/admin/shared/_variant_search.html.erb +1 -1
  118. data/app/views/spree/admin/shipping_methods/_form.html.erb +10 -10
  119. data/app/views/spree/admin/stock_items/_stock_management.html.erb +56 -38
  120. data/app/views/spree/admin/stock_locations/_form.html.erb +133 -121
  121. data/app/views/spree/admin/stock_locations/edit.html.erb +4 -2
  122. data/app/views/spree/admin/store_credit_reasons/edit.html.erb +15 -0
  123. data/app/views/spree/admin/store_credit_reasons/index.html.erb +56 -0
  124. data/app/views/spree/admin/store_credit_reasons/new.html.erb +18 -0
  125. data/app/views/spree/admin/store_credit_reasons/shared/_form.html.erb +15 -0
  126. data/app/views/spree/admin/store_credits/_store_credit_reason_field.html.erb +7 -0
  127. data/app/views/spree/admin/store_credits/edit_amount.html.erb +1 -1
  128. data/app/views/spree/admin/store_credits/edit_validity.html.erb +2 -2
  129. data/app/views/spree/admin/store_credits/index.html.erb +1 -1
  130. data/app/views/spree/admin/store_credits/show.html.erb +3 -3
  131. data/app/views/spree/admin/stores/_form.html.erb +1 -0
  132. data/app/views/spree/admin/style_guide/topics/typography/_colors.html.erb +30 -20
  133. data/app/views/spree/admin/style_guide/topics/typography/_fonts.html.erb +1 -1
  134. data/app/views/spree/admin/taxonomies/edit.html.erb +1 -1
  135. data/app/views/spree/admin/taxons/_form.html.erb +1 -1
  136. data/app/views/spree/admin/taxons/edit.html.erb +2 -2
  137. data/app/views/spree/admin/users/edit.html.erb +2 -2
  138. data/app/views/spree/admin/users/index.html.erb +2 -2
  139. data/app/views/spree/admin/users/items.html.erb +3 -1
  140. data/app/views/spree/admin/users/orders.html.erb +1 -1
  141. data/app/views/spree/admin/variants/_form.html.erb +1 -1
  142. data/app/views/spree/admin/variants/index.html.erb +1 -1
  143. data/app/views/spree/admin/zones/_state_members.html.erb +1 -1
  144. data/config/routes.rb +2 -8
  145. data/lib/spree/backend.rb +1 -1
  146. data/solidus_backend.gemspec +3 -4
  147. data/spec/controllers/spree/admin/base_controller_spec.rb +1 -1
  148. data/spec/controllers/spree/admin/cancellations_controller_spec.rb +7 -3
  149. data/spec/controllers/spree/admin/locale_controller_spec.rb +45 -0
  150. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +50 -2
  151. data/spec/controllers/spree/admin/orders_controller_spec.rb +25 -13
  152. data/spec/controllers/spree/admin/payments_controller_spec.rb +1 -1
  153. data/spec/controllers/spree/admin/products_controller_spec.rb +72 -0
  154. data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +13 -1
  155. data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +11 -0
  156. data/spec/controllers/spree/admin/resource_controller_spec.rb +22 -0
  157. data/spec/controllers/spree/admin/stock_items_controller_spec.rb +1 -1
  158. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +1 -1
  159. data/spec/controllers/spree/admin/store_credits_controller_spec.rb +7 -7
  160. data/spec/features/admin/configuration/payment_methods_spec.rb +2 -2
  161. data/spec/features/admin/configuration/shipping_methods_spec.rb +2 -2
  162. data/spec/features/admin/homepage_spec.rb +1 -6
  163. data/spec/features/admin/locale_spec.rb +1 -2
  164. data/spec/features/admin/orders/adjustments_spec.rb +1 -1
  165. data/spec/features/admin/orders/customer_details_spec.rb +5 -7
  166. data/spec/features/admin/orders/customer_returns_spec.rb +28 -0
  167. data/spec/features/admin/orders/listing_spec.rb +2 -7
  168. data/spec/features/admin/orders/log_entries_spec.rb +2 -2
  169. data/spec/features/admin/orders/new_order_spec.rb +117 -0
  170. data/spec/features/admin/orders/new_refund_spec.rb +35 -0
  171. data/spec/features/admin/orders/order_details_spec.rb +10 -5
  172. data/spec/features/admin/orders/payments_spec.rb +82 -41
  173. data/spec/features/admin/orders/return_payment_state_spec.rb +3 -0
  174. data/spec/features/admin/orders/shipments_spec.rb +28 -0
  175. data/spec/features/admin/products/edit/products_spec.rb +25 -0
  176. data/spec/features/admin/products/edit/taxons_spec.rb +4 -0
  177. data/spec/features/admin/products/pricing_spec.rb +24 -6
  178. data/spec/features/admin/products/products_spec.rb +5 -5
  179. data/spec/features/admin/products/stock_management_spec.rb +27 -13
  180. data/spec/features/admin/products/variant_spec.rb +1 -1
  181. data/spec/features/admin/promotion_adjustments_spec.rb +12 -12
  182. data/spec/features/admin/promotions/option_value_rule_spec.rb +2 -2
  183. data/spec/features/admin/promotions/product_rule_spec.rb +1 -1
  184. data/spec/features/admin/promotions/promotion_spec.rb +52 -0
  185. data/spec/features/admin/promotions/tiered_calculator_spec.rb +1 -1
  186. data/spec/features/admin/promotions/user_rule_spec.rb +2 -2
  187. data/spec/features/admin/reimbursements_spec.rb +1 -1
  188. data/spec/features/admin/store_credits_spec.rb +51 -2
  189. data/spec/features/admin/taxons_spec.rb +35 -0
  190. data/spec/features/admin/users_spec.rb +44 -11
  191. data/spec/helpers/admin/navigation_helper_spec.rb +4 -2
  192. data/spec/helpers/admin/store_credit_events_helper_spec.rb +2 -2
  193. data/spec/javascripts/spec_helper.js +2 -0
  194. data/spec/models/spree/backend_configuration/menu_item_spec.rb +17 -0
  195. data/spec/models/spree/backend_configuration_spec.rb +22 -0
  196. data/spec/spec_helper.rb +2 -2
  197. data/spec/support/appear_before_matcher.rb +1 -1
  198. data/spec/support/feature/order_feature_helper.rb +1 -1
  199. data/spec/views/spree/admin/shared/navigation_footer_spec.rb +1 -1
  200. data/vendor/assets/fonts/inter/Inter-Regular.woff +0 -0
  201. data/vendor/assets/fonts/inter/Inter-Regular.woff2 +0 -0
  202. data/vendor/assets/fonts/inter/Inter-SemiBold.woff +0 -0
  203. data/vendor/assets/fonts/inter/Inter-SemiBold.woff2 +0 -0
  204. data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_en-US.js +10 -0
  205. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_pagination.scss +4 -0
  206. metadata +38 -36
  207. data/.eslintrc +0 -21
  208. data/app/controllers/spree/admin/reports_controller.rb +0 -82
  209. data/app/views/spree/admin/reports/index.html.erb +0 -19
  210. data/app/views/spree/admin/reports/sales_total.html.erb +0 -35
  211. data/app/views/spree/admin/shared/_report_order_criteria.html.erb +0 -19
  212. data/app/views/spree/admin/store_credits/_update_reason_field.html.erb +0 -7
  213. data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -133
  214. data/spec/features/admin/reports_spec.rb +0 -63
@@ -21,8 +21,8 @@ describe "Payment Methods", type: :feature do
21
21
  within("table#listing_payment_methods") do
22
22
  expect(all("th")[1].text).to eq("Name")
23
23
  expect(all("th")[2].text).to eq("Type")
24
- expect(all("th")[3].text).to eq("Available to users")
25
- expect(all("th")[4].text).to eq("Available to admin")
24
+ expect(all("th")[3].text).to eq("Available to Users")
25
+ expect(all("th")[4].text).to eq("Available to Admin")
26
26
  expect(all("th")[5].text).to eq("State")
27
27
  end
28
28
 
@@ -18,7 +18,7 @@ describe "Shipping Methods", type: :feature do
18
18
  within_row(1) do
19
19
  expect(column_text(1)).to eq(shipping_method.name)
20
20
  expect(column_text(2)).to eq(zone.name)
21
- expect(column_text(3)).to eq("Flat rate")
21
+ expect(column_text(3)).to eq("Flat Rate")
22
22
  expect(column_text(4)).to eq("Yes")
23
23
  end
24
24
  end
@@ -99,7 +99,7 @@ describe "Shipping Methods", type: :feature do
99
99
  click_icon :edit
100
100
  end
101
101
 
102
- select 'Flexible Rate per package item', from: 'Base Calculator'
102
+ select 'Flexible Rate per Package Item', from: 'Base Calculator'
103
103
 
104
104
  fill_in 'First Item', with: 10
105
105
  fill_in 'Additional Item', with: 20
@@ -23,10 +23,6 @@ describe "Homepage", type: :feature do
23
23
  expect(page).to have_link("Products", href: "/admin/products", count: 2)
24
24
  end
25
25
 
26
- it "should have a link to reports" do
27
- expect(page).to have_link("Reports", href: "/admin/reports")
28
- end
29
-
30
26
  it "should have a link to configuration" do
31
27
  expect(page).to have_link("Settings", href: "/admin/stores")
32
28
  end
@@ -71,7 +67,7 @@ describe "Homepage", type: :feature do
71
67
 
72
68
  context 'as fakedispatch user' do
73
69
  before do
74
- allow_any_instance_of(Spree::Admin::BaseController).to receive(:spree_current_user).and_return(nil)
70
+ allow_any_instance_of(Spree::Admin::BaseController).to receive(:try_spree_current_user).and_return(nil)
75
71
  end
76
72
 
77
73
  custom_authorization! do |_user|
@@ -84,7 +80,6 @@ describe "Homepage", type: :feature do
84
80
  expect(page).to have_link('Orders')
85
81
  expect(page).not_to have_link('Products')
86
82
  expect(page).not_to have_link('Promotions')
87
- expect(page).not_to have_link('Reports')
88
83
  expect(page).not_to have_link('Settings')
89
84
  end
90
85
  end
@@ -19,12 +19,11 @@ describe "setting locale", type: :feature do
19
19
  },
20
20
  listing_orders: "Ordres"
21
21
  })
22
- Spree::Backend::Config[:locale] = "fr"
22
+ stub_spree_preferences(Spree::Backend::Config, locale: "fr")
23
23
  end
24
24
 
25
25
  after do
26
26
  I18n.locale = I18n.default_locale
27
- Spree::Backend::Config[:locale] = "en"
28
27
  ActionView::Base.raise_on_missing_translations = true
29
28
  end
30
29
 
@@ -124,7 +124,7 @@ describe "Adjustments", type: :feature do
124
124
  end
125
125
  end
126
126
 
127
- expect(page).to have_content(/Total: ?\$170\.00/)
127
+ expect(page).to have_content('Total: $170.00', normalize_ws: true)
128
128
  end
129
129
  end
130
130
  end
@@ -70,10 +70,10 @@ describe "Customer Details", type: :feature, js: true do
70
70
 
71
71
  context "editing an order" do
72
72
  before do
73
- configure_spree_preferences do |config|
74
- config.default_country_iso = country.iso
75
- config.company = true
76
- end
73
+ stub_spree_preferences(
74
+ default_country_iso: country.iso,
75
+ company: true
76
+ )
77
77
 
78
78
  visit spree.admin_path
79
79
  click_link "Orders"
@@ -153,9 +153,7 @@ describe "Customer Details", type: :feature, js: true do
153
153
 
154
154
  before do
155
155
  order.bill_address.country.destroy
156
- configure_spree_preferences do |config|
157
- config.default_country_iso = brazil.iso
158
- end
156
+ stub_spree_preferences(default_country_iso: brazil.iso)
159
157
  end
160
158
 
161
159
  it "sets default country when displaying form" do
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'Customer returns', type: :feature do
6
+ stub_authorization!
7
+
8
+ context 'when the order has more than one line item' do
9
+ let(:order) { create :shipped_order, line_items_count: 2 }
10
+
11
+ context 'when creating a return with state "Received"' do
12
+ it 'marks the order as returned', :js do
13
+ visit spree.new_admin_order_customer_return_path(order)
14
+
15
+ find('#select-all').click
16
+ page.execute_script "$('select.add-item').val('receive')"
17
+ select 'NY Warehouse', from: 'Stock Location'
18
+ click_button 'Create'
19
+
20
+ expect(page).to have_content 'Customer Return has been successfully created'
21
+
22
+ within 'dd.order-state' do
23
+ expect(page).to have_content 'Returned'
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -47,7 +47,7 @@ describe "Orders Listing", type: :feature, js: true do
47
47
  within_row(1) { expect(page).to have_content("R100") }
48
48
  within_row(2) { expect(page).to have_content("R200") }
49
49
 
50
- click_link "Completed At", exact: false
50
+ click_link "Completed at", exact: false
51
51
 
52
52
  # Completed at desc
53
53
  within_row(1) { expect(page).to have_content("R200") }
@@ -114,12 +114,7 @@ describe "Orders Listing", type: :feature, js: true do
114
114
 
115
115
  context "when pagination is really short" do
116
116
  before do
117
- @old_per_page = Spree::Config[:orders_per_page]
118
- Spree::Config[:orders_per_page] = 1
119
- end
120
-
121
- after do
122
- Spree::Config[:orders_per_page] = @old_per_page
117
+ stub_spree_preferences(orders_per_page: 1)
123
118
  end
124
119
 
125
120
  # Regression test for https://github.com/spree/spree/issues/4004
@@ -23,7 +23,7 @@ describe "Log entries", type: :feature do
23
23
  it "shows a successful attempt" do
24
24
  visit spree.admin_order_payments_path(payment.order)
25
25
  click_on payment.number
26
- click_link "Logs"
26
+
27
27
  within("#listing_log_entries") do
28
28
  expect(page).to have_content("Transaction successful")
29
29
  end
@@ -47,7 +47,7 @@ describe "Log entries", type: :feature do
47
47
  it "shows a failed attempt" do
48
48
  visit spree.admin_order_payments_path(payment.order)
49
49
  click_on payment.number
50
- click_link "Logs"
50
+
51
51
  within("#listing_log_entries") do
52
52
  expect(page).to have_content("Transaction failed")
53
53
  end
@@ -201,6 +201,123 @@ describe "New Order", type: :feature do
201
201
  end
202
202
  end
203
203
 
204
+ context 'with a checkout_zone set as the country of Canada' do
205
+ let!(:canada) { create(:country, iso: 'CA', states_required: true) }
206
+ let!(:canada_state) { create(:state, country: canada) }
207
+ let!(:checkout_zone) { create(:zone, name: 'Checkout Zone', countries: [canada]) }
208
+
209
+ before do
210
+ Spree::Country.update_all(states_required: true)
211
+ stub_spree_preferences(checkout_zone: checkout_zone.name)
212
+ end
213
+
214
+ context 'and default_country_iso of the United States' do
215
+ before do
216
+ stub_spree_preferences(default_country_iso: Spree::Country.find_by!(iso: 'US').iso)
217
+ end
218
+
219
+ it 'the shipping address country select includes only options for Canada' do
220
+ visit spree.new_admin_order_path
221
+ click_link 'Customer'
222
+ within '#shipping' do
223
+ expect(page).to have_select(
224
+ 'Country',
225
+ options: ['Canada']
226
+ )
227
+ end
228
+ end
229
+
230
+ it 'does not show any shipping address state' do
231
+ visit spree.new_admin_order_path
232
+ click_link 'Customer'
233
+ within '#shipping' do
234
+ expect(page).to have_select(
235
+ 'State',
236
+ disabled: true,
237
+ visible: false,
238
+ options: ['']
239
+ )
240
+ end
241
+ end
242
+
243
+ it 'the billing address country select includes only options for Canada' do
244
+ visit spree.new_admin_order_path
245
+ click_link 'Customer'
246
+ within '#billing' do
247
+ expect(page).to have_select(
248
+ 'Country',
249
+ options: ['Canada']
250
+ )
251
+ end
252
+ end
253
+
254
+ it 'does not show any billing address state' do
255
+ visit spree.new_admin_order_path
256
+ click_link 'Customer'
257
+ within '#billing' do
258
+ expect(page).to have_select(
259
+ 'State',
260
+ disabled: true,
261
+ visible: false,
262
+ options: ['']
263
+ )
264
+ end
265
+ end
266
+ end
267
+
268
+ context 'and default_country_iso of Canada' do
269
+ before do
270
+ stub_spree_preferences(default_country_iso: Spree::Country.find_by!(iso: 'CA').iso)
271
+ end
272
+
273
+ it 'defaults the shipping address country to Canada' do
274
+ visit spree.new_admin_order_path
275
+ click_link 'Customer'
276
+ within '#shipping' do
277
+ expect(page).to have_select(
278
+ 'Country',
279
+ selected: 'Canada',
280
+ options: ['Canada']
281
+ )
282
+ end
283
+ end
284
+
285
+ it 'shows relevant shipping address states' do
286
+ visit spree.new_admin_order_path
287
+ click_link 'Customer'
288
+ within '#shipping' do
289
+ expect(page).to have_select(
290
+ 'State',
291
+ options: [''] + canada.states.map(&:name)
292
+ )
293
+ end
294
+ end
295
+
296
+ it 'defaults the billing address country to Canada' do
297
+ visit spree.new_admin_order_path
298
+ click_link 'Customer'
299
+ within '#billing' do
300
+ expect(page).to have_select(
301
+ 'Country',
302
+ selected: 'Canada',
303
+ options: ['Canada']
304
+ )
305
+ end
306
+ end
307
+
308
+ it 'shows relevant billing address states' do
309
+ visit spree.new_admin_order_path
310
+ click_link 'Customer'
311
+ within '#billing' do
312
+ expect(page).to have_select(
313
+ 'State',
314
+ options: [''] + canada.states.map(&:name)
315
+ )
316
+ end
317
+ end
318
+ end
319
+ end
320
+
204
321
  def fill_in_address
205
322
  fill_in "First Name", with: "John 99"
206
323
  fill_in "Last Name", with: "Doe"
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe 'New Refund creation', :js do
6
+ stub_authorization!
7
+
8
+ let(:order) { create :order_ready_to_ship }
9
+ let(:payment) { order.payments.first }
10
+ let(:amount) { '10.99' }
11
+ let!(:reason) { create :refund_reason }
12
+
13
+ it 'creates a new refund' do
14
+ visit spree.new_admin_order_payment_refund_path(order, payment)
15
+ expect(page).not_to have_selector 'td', text: amount
16
+ within '.new_refund' do
17
+ fill_in 'refund_amount', with: amount
18
+ select reason.name, from: 'Reason'
19
+ click_button 'Refund'
20
+ end
21
+ expect(page).to have_content 'Refund has been successfully created!'
22
+ expect(page).to have_selector 'td', text: amount
23
+ end
24
+
25
+ it 'disables the button at submit' do
26
+ visit spree.new_admin_order_payment_refund_path(order, payment)
27
+ page.execute_script "$('form').submit(function(e) { e.preventDefault()})"
28
+ within '.new_refund' do
29
+ fill_in 'refund_amount', with: amount
30
+ select reason.name, from: 'Reason'
31
+ click_button 'Refund'
32
+ expect(find('input[type="submit"]')).to be_disabled
33
+ end
34
+ end
35
+ end
@@ -191,9 +191,14 @@ describe "Order Details", type: :feature, js: true do
191
191
  end
192
192
 
193
193
  context 'splitting to location' do
194
- # can not properly implement until poltergeist supports checking alert text
195
- # see https://github.com/teampoltergeist/poltergeist/pull/516
196
- it 'should warn you if you have not selected a location or shipment'
194
+ it 'should warn you if you have not selected a location or shipment' do
195
+ visit spree.edit_admin_order_path(order)
196
+
197
+ within('tr', text: line_item.sku) { click_icon 'arrows-h' }
198
+ accept_alert 'Please select the split destination.' do
199
+ click_icon :ok
200
+ end
201
+ end
197
202
 
198
203
  context 'there is enough stock at the other location' do
199
204
  it 'should allow me to make a split' do
@@ -415,7 +420,7 @@ describe "Order Details", type: :feature, js: true do
415
420
  it 'should not allow a shipment to split stock to itself' do
416
421
  visit spree.edit_admin_order_path(order)
417
422
  within('tr', text: line_item.sku) { click_icon 'arrows-h' }
418
- click_on 'Choose location'
423
+ click_on 'Choose Location'
419
424
  within '.select2-results' do
420
425
  expect(page).to have_content(shipment2.number)
421
426
  expect(page).not_to have_content(shipment1.number)
@@ -499,7 +504,7 @@ describe "Order Details", type: :feature, js: true do
499
504
 
500
505
  context 'with only read permissions' do
501
506
  before do
502
- allow_any_instance_of(Spree::Admin::BaseController).to receive(:spree_current_user).and_return(nil)
507
+ allow_any_instance_of(Spree::Admin::BaseController).to receive(:try_spree_current_user).and_return(nil)
503
508
  end
504
509
 
505
510
  custom_authorization! do |_user|
@@ -5,31 +5,33 @@ require 'spec_helper'
5
5
  describe 'Payments', type: :feature do
6
6
  stub_authorization!
7
7
 
8
- context "with a pre-existing payment" do
9
- let!(:payment) do
10
- create(:payment,
11
- order: order,
12
- amount: order.outstanding_balance,
8
+ let(:state) { 'checkout' }
9
+
10
+ def create_payment(opts = {})
11
+ create(
12
+ :payment,
13
+ {
14
+ order: order,
15
+ amount: order.outstanding_balance,
13
16
  payment_method: create(:credit_card_payment_method),
14
- state: state)
15
- end
17
+ state: state
18
+ }.merge(opts)
19
+ )
20
+ end
21
+
22
+ context "with a pre-existing payment" do
23
+ let!(:payment) { create_payment }
16
24
 
17
25
  let(:order) { create(:completed_order_with_totals, number: 'R100', line_items_price: 50) }
18
- let(:state) { 'checkout' }
19
26
 
20
27
  before do
21
28
  visit "/admin/orders/#{order.number}/payments"
22
29
  end
23
30
 
24
31
  # Regression tests for https://github.com/spree/spree/issues/1453
25
- context 'with a check payment' do
32
+ context 'with a check payment', js: true do
26
33
  let(:order) { create(:completed_order_with_totals, number: 'R100') }
27
- let!(:payment) do
28
- create(:payment,
29
- order: order,
30
- amount: order.outstanding_balance,
31
- payment_method: create(:check_payment_method, available_to_admin: true)) # Check
32
- end
34
+ let!(:payment) { create_payment(payment_method: create(:check_payment_method, available_to_admin: true)) }
33
35
 
34
36
  it 'capturing a check payment from a new order' do
35
37
  click_icon(:capture)
@@ -49,11 +51,9 @@ describe 'Payments', type: :feature do
49
51
 
50
52
  visit spree.admin_order_payment_path(order, payment)
51
53
  expect(page).to have_content 'Capture Events'
52
- # within '#capture_events' do
53
- within_row(1) do
54
+ within '#capture_events' do
54
55
  expect(page).to have_content(capture_amount / 100)
55
56
  end
56
- # end
57
57
  end
58
58
 
59
59
  it 'displays the address for a credit card when present' do
@@ -62,6 +62,57 @@ describe 'Payments', type: :feature do
62
62
  expect(page).to have_content 'my cc address'
63
63
  end
64
64
 
65
+ context 'when there are multiple pending payments', :js do
66
+ context 'while marking all payments as void' do
67
+ let(:card_payment_method) { create(:credit_card_payment_method) }
68
+
69
+ let!(:payment) do
70
+ create_payment(
71
+ payment_method: card_payment_method,
72
+ state: :pending
73
+ )
74
+ end
75
+
76
+ let!(:second_payment) do
77
+ create_payment(
78
+ payment_method: card_payment_method,
79
+ state: :pending
80
+ )
81
+ end
82
+
83
+ it 'updates the order payment state correctly at each iteration' do
84
+ visit current_path
85
+ expect(page).to have_css('#payment_status', text: 'Balance due')
86
+
87
+ within '#payments' do
88
+ expect(page).to have_selector('.pill-pending', count: 2)
89
+ within "#payment_#{payment.id}" do
90
+ find('.fa-void').click
91
+ end
92
+ end
93
+
94
+ expect(page).to have_css('#payment_status', text: 'Balance due')
95
+
96
+ within '#payments' do
97
+ expect(page).to have_selector('.pill-pending', count: 1)
98
+ within "#payment_#{payment.id}" do
99
+ expect(page).to have_selector('.pill-void', count: 1)
100
+ end
101
+ end
102
+
103
+ within "#payment_#{second_payment.id}" do
104
+ find('.fa-void').click
105
+ end
106
+
107
+ within '#payments' do
108
+ expect(page).not_to have_selector('.pill-pending')
109
+ expect(page).to have_selector('.pill-void', count: 2)
110
+ end
111
+ expect(page).to have_css('#payment_status', text: 'Failed')
112
+ end
113
+ end
114
+ end
115
+
65
116
  it 'lists, updates and creates payments for an order', js: true do
66
117
  within_row(1) do
67
118
  expect(column_text(3)).to eq('Credit Card')
@@ -70,7 +121,7 @@ describe 'Payments', type: :feature do
70
121
  end
71
122
 
72
123
  click_icon :void
73
- expect(page).to have_css('#payment_status', text: 'Balance due')
124
+ expect(page).to have_css('#payment_status', text: 'Failed')
74
125
  expect(page).to have_content('Payment Updated')
75
126
 
76
127
  within_row(1) do
@@ -105,7 +156,7 @@ describe 'Payments', type: :feature do
105
156
  within_row(1) do
106
157
  click_icon(:edit)
107
158
  fill_in('amount', with: '$1')
108
- click_icon(:save)
159
+ click_icon(:ok)
109
160
  expect(page).to have_selector('td.amount span', text: '$1.00')
110
161
  expect(payment.reload.amount).to eq(1.00)
111
162
  end
@@ -114,12 +165,7 @@ describe 'Payments', type: :feature do
114
165
  it 'allows the amount change to be cancelled by clicking on the cancel button' do
115
166
  within_row(1) do
116
167
  click_icon(:edit)
117
-
118
- # Can't use fill_in here, as under poltergeist that will unfocus (and
119
- # thus submit) the field under poltergeist
120
- find('td.amount input').click
121
- page.execute_script("$('td.amount input').val('$1')")
122
-
168
+ fill_in 'amount', with: '$1'
123
169
  click_icon(:cancel)
124
170
  expect(page).to have_selector('td.amount span', text: '$150.00')
125
171
  expect(payment.reload.amount).to eq(150.00)
@@ -130,7 +176,7 @@ describe 'Payments', type: :feature do
130
176
  within_row(1) do
131
177
  click_icon(:edit)
132
178
  fill_in('amount', with: 'invalid')
133
- click_icon(:save)
179
+ click_icon(:ok)
134
180
  end
135
181
  expect(page).to have_selector('.flash.error', text: 'Invalid resource. Please fix errors and try again.')
136
182
  expect(payment.reload.amount).to eq(150.00)
@@ -159,9 +205,9 @@ describe 'Payments', type: :feature do
159
205
  end
160
206
 
161
207
  it "is able to create a new credit card payment with valid information", js: true do
162
- fill_in "Card Number", with: "4111 1111 1111 1111"
208
+ fill_in_with_force "Card Number", with: "4111 1111 1111 1111"
163
209
  fill_in "Name", with: "Test User"
164
- fill_in "Expiration", with: "09 / #{Time.current.year + 1}"
210
+ fill_in_with_force "Expiration", with: "09 / #{Time.current.year + 1}"
165
211
  fill_in "Card Code", with: "007"
166
212
  # Regression test for https://github.com/spree/spree/issues/4277
167
213
  expect(page).to have_css('.ccType[value="visa"]', visible: false)
@@ -182,7 +228,7 @@ describe 'Payments', type: :feature do
182
228
 
183
229
  context "user existing card" do
184
230
  let!(:cc) do
185
- create(:credit_card, payment_method: payment_method, gateway_customer_profile_id: "BGS-RFRE")
231
+ create(:credit_card, payment_method: payment_method, gateway_customer_profile_id: "BGS-RFRE", user: order.user)
186
232
  end
187
233
 
188
234
  before do
@@ -205,7 +251,7 @@ describe 'Payments', type: :feature do
205
251
  visit spree.admin_order_payments_path(order.reload)
206
252
  end
207
253
 
208
- it "can successfully be created and captured" do
254
+ it "can successfully be created and captured", js: true do
209
255
  click_on 'Update'
210
256
  expect(page).to have_content("Payment has been successfully created!")
211
257
  click_icon(:capture)
@@ -216,12 +262,7 @@ describe 'Payments', type: :feature do
216
262
  context 'with a soft-deleted payment method' do
217
263
  let(:order) { create(:completed_order_with_totals, line_items_count: 1) }
218
264
  let!(:payment_method) { create(:check_payment_method) }
219
- let!(:payment) do
220
- create(:payment,
221
- order: order,
222
- amount: order.outstanding_balance,
223
- payment_method: payment_method)
224
- end
265
+ let!(:payment) { create_payment(payment_method: payment_method) }
225
266
 
226
267
  before do
227
268
  payment_method.discard
@@ -249,9 +290,9 @@ describe 'Payments', type: :feature do
249
290
 
250
291
  it "is able to create a new payment", js: true do
251
292
  choose payment_method.name
252
- fill_in "Card Number", with: "4111 1111 1111 1111"
293
+ fill_in_with_force "Card Number", with: "4111 1111 1111 1111"
253
294
  fill_in "Name", with: "Test User"
254
- fill_in "Expiration", with: "09 / #{Time.current.year + 1}"
295
+ fill_in_with_force "Expiration", with: "09 / #{Time.current.year + 1}"
255
296
  fill_in "Card Code", with: "007"
256
297
  click_button "Continue"
257
298
  expect(page).to have_content("Payment has been successfully created!")
@@ -278,9 +319,9 @@ describe 'Payments', type: :feature do
278
319
 
279
320
  it "displays an error" do
280
321
  choose payment_method.name
281
- fill_in "Card Number", with: "4111 1111 1111 1111"
322
+ fill_in_with_force "Card Number", with: "4111 1111 1111 1111"
282
323
  fill_in "Name", with: "Test User"
283
- fill_in "Expiration", with: "09 / #{Time.current.year + 1}"
324
+ fill_in_with_force "Expiration", with: "09 / #{Time.current.year + 1}"
284
325
  fill_in "Card Code", with: "007"
285
326
  click_button "Continue"
286
327
  expect(page).to have_content I18n.t('spree.insufficient_stock_for_order')