solidus_backend 2.10.2 → 2.11.0

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

Potentially problematic release.


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

Files changed (233) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/backend.js +4 -1
  3. data/app/assets/javascripts/spree/backend/adjustments.js +1 -1
  4. data/app/assets/javascripts/spree/backend/admin.js +18 -29
  5. data/app/assets/javascripts/spree/backend/collections/states.js +1 -1
  6. data/app/assets/javascripts/spree/backend/components/selectable_table.js +5 -0
  7. data/app/assets/javascripts/spree/backend/components/selectable_table/return_items.js +5 -0
  8. data/app/assets/javascripts/spree/backend/components/selectable_table/summary.js +7 -0
  9. data/app/assets/javascripts/spree/backend/components/sortable_table.js +31 -25
  10. data/app/assets/javascripts/spree/backend/models/order.js +3 -3
  11. data/app/assets/javascripts/spree/backend/models/payment.js +1 -1
  12. data/app/assets/javascripts/spree/backend/models/shipment.js +1 -1
  13. data/app/assets/javascripts/spree/backend/models/stock_item.js +1 -1
  14. data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +2 -2
  15. data/app/assets/javascripts/spree/backend/option_value_picker.js +2 -2
  16. data/app/assets/javascripts/spree/backend/product_picker.js +2 -2
  17. data/app/assets/javascripts/spree/backend/routes.js +40 -21
  18. data/app/assets/javascripts/spree/backend/shipments.js +5 -5
  19. data/app/assets/javascripts/spree/backend/shipping_methods/stock_locations_picker.js +18 -0
  20. data/app/assets/javascripts/spree/backend/stock_management.js +4 -2
  21. data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +2 -2
  22. data/app/assets/javascripts/spree/backend/taxons.js +3 -3
  23. data/app/assets/javascripts/spree/backend/templates/index.js +2 -0
  24. data/app/assets/javascripts/spree/backend/templates/orders/customer_details/autocomplete.hbs +2 -2
  25. data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +5 -1
  26. data/app/assets/javascripts/spree/backend/templates/tables/return_item_sum_amount.hbs +7 -0
  27. data/app/assets/javascripts/spree/backend/templates/tables/selectable_label.hbs +6 -0
  28. data/app/assets/javascripts/spree/backend/user_picker.js +3 -4
  29. data/app/assets/javascripts/spree/backend/variant_autocomplete.js +2 -2
  30. data/app/assets/javascripts/spree/backend/views/cart/empty_cart_button.js +2 -2
  31. data/app/assets/javascripts/spree/backend/views/index.js +4 -0
  32. data/app/assets/javascripts/spree/backend/views/order/address.js +1 -1
  33. data/app/assets/javascripts/spree/backend/views/order/customer_select.js +2 -3
  34. data/app/assets/javascripts/spree/backend/views/order/details_adjustments.js +4 -1
  35. data/app/assets/javascripts/spree/backend/views/stock/edit_stock_item_row.js +4 -0
  36. data/app/assets/javascripts/spree/backend/views/tables/return_items.js +9 -0
  37. data/app/assets/javascripts/spree/backend/views/tables/selectable_table.js +70 -0
  38. data/app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js +32 -0
  39. data/app/assets/javascripts/spree/backend/views/tables/selectable_table/summary.js +45 -0
  40. data/app/assets/stylesheets/spree/backend/components/_navigation.scss +4 -5
  41. data/app/assets/stylesheets/spree/backend/sections/_orders.scss +5 -1
  42. data/app/assets/stylesheets/spree/backend/sections/_style_guide.scss +4 -0
  43. data/app/assets/stylesheets/spree/backend/shared/_forms.scss +1 -0
  44. data/app/controllers/spree/admin/base_controller.rb +6 -0
  45. data/app/controllers/spree/admin/cancellations_controller.rb +2 -0
  46. data/app/controllers/spree/admin/customer_returns_controller.rb +4 -4
  47. data/app/controllers/spree/admin/images_controller.rb +2 -1
  48. data/app/controllers/spree/admin/orders/customer_details_controller.rb +2 -0
  49. data/app/controllers/spree/admin/orders_controller.rb +7 -2
  50. data/app/controllers/spree/admin/payments_controller.rb +3 -1
  51. data/app/controllers/spree/admin/product_properties_controller.rb +1 -1
  52. data/app/controllers/spree/admin/products_controller.rb +18 -24
  53. data/app/controllers/spree/admin/promotion_codes_controller.rb +9 -4
  54. data/app/controllers/spree/admin/refunds_controller.rb +19 -0
  55. data/app/controllers/spree/admin/resource_controller.rb +27 -7
  56. data/app/controllers/spree/admin/return_authorizations_controller.rb +1 -1
  57. data/app/controllers/spree/admin/root_controller.rb +1 -1
  58. data/app/controllers/spree/admin/search_controller.rb +1 -2
  59. data/app/controllers/spree/admin/stock_items_controller.rb +6 -5
  60. data/app/controllers/spree/admin/stock_locations_controller.rb +4 -0
  61. data/app/controllers/spree/admin/stock_movements_controller.rb +7 -0
  62. data/app/controllers/spree/admin/taxons_controller.rb +12 -1
  63. data/app/controllers/spree/admin/users/api_key_controller.rb +29 -0
  64. data/app/controllers/spree/admin/users_controller.rb +37 -20
  65. data/app/controllers/spree/admin/variants_controller.rb +4 -2
  66. data/app/controllers/spree/admin/zones_controller.rb +1 -1
  67. data/app/helpers/spree/admin/base_helper.rb +4 -0
  68. data/app/helpers/spree/admin/customer_returns_helper.rb +1 -1
  69. data/app/helpers/spree/admin/navigation_helper.rb +1 -1
  70. data/app/helpers/spree/admin/orders_helper.rb +8 -4
  71. data/app/helpers/spree/admin/stock_movements_helper.rb +8 -4
  72. data/app/views/spree/admin/customer_returns/_return_item_selection.html.erb +2 -3
  73. data/app/views/spree/admin/images/index.html.erb +25 -21
  74. data/app/views/spree/admin/option_types/_option_value_fields.html.erb +8 -1
  75. data/app/views/spree/admin/option_types/edit.html.erb +3 -1
  76. data/app/views/spree/admin/orders/customer_details/_form.html.erb +13 -13
  77. data/app/views/spree/admin/orders/index.html.erb +23 -13
  78. data/app/views/spree/admin/payment_methods/_form.html.erb +7 -2
  79. data/app/views/spree/admin/payments/index.html.erb +3 -1
  80. data/app/views/spree/admin/prices/_master_variant_table.html.erb +3 -3
  81. data/app/views/spree/admin/prices/_table.html.erb +3 -3
  82. data/app/views/spree/admin/product_properties/_product_property_fields.html.erb +7 -2
  83. data/app/views/spree/admin/product_properties/index.html.erb +14 -2
  84. data/app/views/spree/admin/products/_form.html.erb +13 -2
  85. data/app/views/spree/admin/products/index.html.erb +1 -1
  86. data/app/views/spree/admin/promotion_codes/index.html.erb +1 -1
  87. data/app/views/spree/admin/promotions/_actions.html.erb +1 -1
  88. data/app/views/spree/admin/promotions/_activations_new.html.erb +1 -1
  89. data/app/views/spree/admin/promotions/_rules.html.erb +1 -1
  90. data/app/views/spree/admin/promotions/edit.html.erb +2 -2
  91. data/app/views/spree/admin/promotions/index.html.erb +12 -5
  92. data/app/views/spree/admin/return_authorizations/_form.html.erb +3 -10
  93. data/app/views/spree/admin/return_authorizations/index.html.erb +1 -1
  94. data/app/views/spree/admin/search/users.json.jbuilder +15 -1
  95. data/app/views/spree/admin/shared/_address.html.erb +6 -6
  96. data/app/views/spree/admin/shared/_address_form.html.erb +15 -8
  97. data/app/views/spree/admin/shared/_order_submenu.html.erb +4 -4
  98. data/app/views/spree/admin/shared/_payments_tabs.html.erb +1 -1
  99. data/app/views/spree/admin/shared/_settings_checkout_tabs.html.erb +5 -5
  100. data/app/views/spree/admin/shared/_settings_sub_menu.html.erb +6 -6
  101. data/app/views/spree/admin/shared/_shipping_tabs.html.erb +3 -3
  102. data/app/views/spree/admin/shared/_taxes_tabs.html.erb +2 -2
  103. data/app/views/spree/admin/shared/preference_fields/_encrypted_string.html.erb +12 -0
  104. data/app/views/spree/admin/shipping_methods/_form.html.erb +18 -0
  105. data/app/views/spree/admin/stock_items/_stock_management.html.erb +1 -1
  106. data/app/views/spree/admin/stock_locations/edit.html.erb +1 -1
  107. data/app/views/spree/admin/stock_locations/index.html.erb +3 -1
  108. data/app/views/spree/admin/stock_movements/index.html.erb +30 -1
  109. data/app/views/spree/admin/stores/_form.html.erb +6 -0
  110. data/app/views/spree/admin/style_guide/topics/tables/_building_tables.html.erb +27 -3
  111. data/app/views/spree/admin/tax_categories/_form.html.erb +1 -0
  112. data/app/views/spree/admin/users/_form.html.erb +2 -2
  113. data/app/views/spree/admin/users/_tabs.html.erb +1 -1
  114. data/app/views/spree/admin/users/edit.html.erb +4 -4
  115. data/app/views/spree/admin/users/items.html.erb +5 -3
  116. data/app/views/spree/admin/users/orders.html.erb +5 -3
  117. data/app/views/spree/admin/variants/_table_filter.html.erb +1 -1
  118. data/app/views/spree/admin/variants/index.html.erb +2 -2
  119. data/config/initializers/form_builder.rb +2 -2
  120. data/lib/spree/backend/engine.rb +0 -2
  121. data/lib/spree/backend_configuration.rb +14 -1
  122. data/solidus_backend.gemspec +4 -4
  123. metadata +23 -122
  124. data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +0 -35
  125. data/script/rails +0 -10
  126. data/spec/controllers/spree/admin/base_controller_spec.rb +0 -26
  127. data/spec/controllers/spree/admin/cancellations_controller_spec.rb +0 -83
  128. data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +0 -235
  129. data/spec/controllers/spree/admin/locale_controller_spec.rb +0 -45
  130. data/spec/controllers/spree/admin/missing_products_controller_spec.rb +0 -18
  131. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +0 -128
  132. data/spec/controllers/spree/admin/orders_controller_spec.rb +0 -408
  133. data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +0 -95
  134. data/spec/controllers/spree/admin/payments_controller_spec.rb +0 -194
  135. data/spec/controllers/spree/admin/prices_controller_spec.rb +0 -45
  136. data/spec/controllers/spree/admin/product_properties_controller_spec.rb +0 -71
  137. data/spec/controllers/spree/admin/products_controller_spec.rb +0 -270
  138. data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +0 -23
  139. data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +0 -32
  140. data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +0 -36
  141. data/spec/controllers/spree/admin/promotions_controller_spec.rb +0 -122
  142. data/spec/controllers/spree/admin/refunds_controller_spec.rb +0 -35
  143. data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +0 -137
  144. data/spec/controllers/spree/admin/resource_controller_spec.rb +0 -201
  145. data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +0 -291
  146. data/spec/controllers/spree/admin/return_items_controller_spec.rb +0 -29
  147. data/spec/controllers/spree/admin/root_controller_spec.rb +0 -43
  148. data/spec/controllers/spree/admin/search_controller_spec.rb +0 -106
  149. data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +0 -16
  150. data/spec/controllers/spree/admin/stock_items_controller_spec.rb +0 -52
  151. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +0 -44
  152. data/spec/controllers/spree/admin/store_credits_controller_spec.rb +0 -311
  153. data/spec/controllers/spree/admin/users_controller_spec.rb +0 -287
  154. data/spec/controllers/spree/admin/variants_controller_spec.rb +0 -71
  155. data/spec/features/admin/configuration/payment_methods_spec.rb +0 -176
  156. data/spec/features/admin/configuration/shipping_methods_spec.rb +0 -126
  157. data/spec/features/admin/configuration/stock_locations_spec.rb +0 -54
  158. data/spec/features/admin/configuration/store_spec.rb +0 -62
  159. data/spec/features/admin/configuration/tax_categories_spec.rb +0 -58
  160. data/spec/features/admin/configuration/tax_rates_spec.rb +0 -31
  161. data/spec/features/admin/configuration/taxonomies_spec.rb +0 -61
  162. data/spec/features/admin/configuration/zones_spec.rb +0 -41
  163. data/spec/features/admin/homepage_spec.rb +0 -86
  164. data/spec/features/admin/javascript_format_money_spec.rb +0 -22
  165. data/spec/features/admin/locale_spec.rb +0 -34
  166. data/spec/features/admin/orders/adjustments_promotions_spec.rb +0 -55
  167. data/spec/features/admin/orders/adjustments_spec.rb +0 -130
  168. data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +0 -45
  169. data/spec/features/admin/orders/cancelling_inventory_spec.rb +0 -50
  170. data/spec/features/admin/orders/customer_details_spec.rb +0 -203
  171. data/spec/features/admin/orders/customer_returns_spec.rb +0 -41
  172. data/spec/features/admin/orders/line_items_spec.rb +0 -52
  173. data/spec/features/admin/orders/listing_spec.rb +0 -186
  174. data/spec/features/admin/orders/log_entries_spec.rb +0 -56
  175. data/spec/features/admin/orders/new_order_spec.rb +0 -379
  176. data/spec/features/admin/orders/new_refund_spec.rb +0 -35
  177. data/spec/features/admin/orders/order_details_spec.rb +0 -591
  178. data/spec/features/admin/orders/payments_spec.rb +0 -330
  179. data/spec/features/admin/orders/return_authorizations_spec.rb +0 -56
  180. data/spec/features/admin/orders/return_payment_state_spec.rb +0 -65
  181. data/spec/features/admin/orders/risk_analysis_spec.rb +0 -49
  182. data/spec/features/admin/orders/shipments_spec.rb +0 -145
  183. data/spec/features/admin/payments/store_credits_spec.rb +0 -23
  184. data/spec/features/admin/products/edit/images_spec.rb +0 -76
  185. data/spec/features/admin/products/edit/products_spec.rb +0 -92
  186. data/spec/features/admin/products/edit/taxons_spec.rb +0 -57
  187. data/spec/features/admin/products/edit/variants_spec.rb +0 -63
  188. data/spec/features/admin/products/option_types_spec.rb +0 -116
  189. data/spec/features/admin/products/pricing_spec.rb +0 -127
  190. data/spec/features/admin/products/products_spec.rb +0 -348
  191. data/spec/features/admin/products/properties_spec.rb +0 -141
  192. data/spec/features/admin/products/stock_management_spec.rb +0 -101
  193. data/spec/features/admin/products/variant_spec.rb +0 -89
  194. data/spec/features/admin/promotion_adjustments_spec.rb +0 -286
  195. data/spec/features/admin/promotions/option_value_rule_spec.rb +0 -90
  196. data/spec/features/admin/promotions/product_rule_spec.rb +0 -35
  197. data/spec/features/admin/promotions/promotion_categories_spec.rb +0 -83
  198. data/spec/features/admin/promotions/promotion_code_batches_spec.rb +0 -37
  199. data/spec/features/admin/promotions/promotion_code_spec.rb +0 -31
  200. data/spec/features/admin/promotions/promotion_spec.rb +0 -52
  201. data/spec/features/admin/promotions/tiered_calculator_spec.rb +0 -76
  202. data/spec/features/admin/promotions/user_rule_spec.rb +0 -42
  203. data/spec/features/admin/reimbursements_spec.rb +0 -18
  204. data/spec/features/admin/store_credits_spec.rb +0 -132
  205. data/spec/features/admin/stores_spec.rb +0 -37
  206. data/spec/features/admin/style_guide_spec.rb +0 -14
  207. data/spec/features/admin/taxons_spec.rb +0 -90
  208. data/spec/features/admin/users_spec.rb +0 -412
  209. data/spec/fixtures/files/ror_ringer.jpeg +0 -0
  210. data/spec/helpers/admin/base_helper_spec.rb +0 -49
  211. data/spec/helpers/admin/navigation_helper_spec.rb +0 -139
  212. data/spec/helpers/admin/stock_movements_helper_spec.rb +0 -29
  213. data/spec/helpers/admin/store_credit_events_helper_spec.rb +0 -97
  214. data/spec/helpers/promotion_rules_helper_spec.rb +0 -14
  215. data/spec/javascripts/fixtures/_boot.html.erb +0 -8
  216. data/spec/javascripts/fixtures/number_with_currency/with_currency_select.html.erb +0 -3
  217. data/spec/javascripts/fixtures/number_with_currency/without_select.html.erb +0 -3
  218. data/spec/javascripts/format_money_spec.js +0 -48
  219. data/spec/javascripts/spec_helper.js +0 -13
  220. data/spec/javascripts/support/show_errors.js +0 -8
  221. data/spec/javascripts/support/with_translations.js +0 -11
  222. data/spec/javascripts/translation_spec.js +0 -58
  223. data/spec/javascripts/views/number_with_currency_spec.js +0 -72
  224. data/spec/lib/spree/backend_configuration/menu_item_spec.rb +0 -17
  225. data/spec/lib/spree/backend_configuration_spec.rb +0 -22
  226. data/spec/spec_helper.rb +0 -123
  227. data/spec/support/appear_before_matcher.rb +0 -10
  228. data/spec/support/feature/base_feature_helper.rb +0 -17
  229. data/spec/support/feature/order_feature_helper.rb +0 -27
  230. data/spec/teaspoon_env.rb +0 -51
  231. data/spec/test_views/spree/admin/widgets/edit.html.erb +0 -1
  232. data/spec/test_views/spree/admin/widgets/new.html.erb +0 -1
  233. data/spec/views/spree/admin/shared/navigation_footer_spec.rb +0 -67
@@ -1,95 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- module Spree
6
- class GatewayWithPassword < PaymentMethod
7
- preference :password, :string, default: "password"
8
- end
9
-
10
- describe Admin::PaymentMethodsController, type: :controller do
11
- stub_authorization!
12
-
13
- let(:payment_method) { GatewayWithPassword.create!(name: "Bogus", preferred_password: "haxme") }
14
-
15
- context "GatewayWithPassword" do
16
- before do
17
- allow(Rails.application.config.spree).to receive(:payment_methods).and_return([GatewayWithPassword])
18
- end
19
-
20
- # regression test for https://github.com/spree/spree/issues/2094
21
- it "does not clear password on update" do
22
- expect(payment_method.preferred_password).to eq("haxme")
23
- put :update, params: { id: payment_method.id, payment_method: { type: payment_method.class.to_s, preferred_password: "" } }
24
- expect(response).to redirect_to(spree.edit_admin_payment_method_path(payment_method))
25
-
26
- payment_method.reload
27
- expect(payment_method.preferred_password).to eq("haxme")
28
- end
29
- end
30
-
31
- context "tries to save invalid payment" do
32
- it "doesn't break, responds nicely" do
33
- post :create, params: { payment_method: { name: "", type: "Spree::PaymentMethod::BogusCreditCard" } }
34
- end
35
- end
36
-
37
- it "can create a payment method of a valid type" do
38
- expect {
39
- post :create, params: { payment_method: { name: "Test Method", type: "Spree::PaymentMethod::BogusCreditCard" } }
40
- }.to change(Spree::PaymentMethod, :count).by(1)
41
-
42
- expect(response).to be_redirect
43
- expect(response).to redirect_to spree.edit_admin_payment_method_path(assigns(:payment_method))
44
- end
45
-
46
- it "can not create a payment method of an invalid type" do
47
- expect {
48
- post :create, params: { payment_method: { name: "Invalid Payment Method", type: "Spree::InvalidType" } }
49
- }.to change(Spree::PaymentMethod, :count).by(0)
50
-
51
- expect(response).to be_redirect
52
- expect(response).to redirect_to spree.new_admin_payment_method_path
53
- end
54
-
55
- describe "#index" do
56
- subject { get :index }
57
-
58
- let!(:first_method) { GatewayWithPassword.create! name: "First", preferred_password: "1235" }
59
- let!(:second_method) { GatewayWithPassword.create! name: "Second", preferred_password: "1235" }
60
-
61
- before do
62
- second_method.move_to_top
63
- end
64
-
65
- it { is_expected.to be_successful }
66
- it { is_expected.to render_template "index" }
67
-
68
- it "respects the order of payment methods by position" do
69
- subject
70
- expect(assigns(:payment_methods).to_a).to eql([second_method, first_method])
71
- end
72
- end
73
-
74
- describe "#update" do
75
- # Regression test for https://github.com/solidusio/solidus/issues/2789
76
- let(:params) do
77
- {
78
- id: payment_method.id,
79
- payment_method: {
80
- name: 'Check',
81
- type: 'Spree::PaymentMethod::Check'
82
- }
83
- }
84
- end
85
-
86
- it 'updates the resource' do
87
- put :update, params: params
88
-
89
- expect(response).to redirect_to(spree.edit_admin_payment_method_path(payment_method))
90
- response_payment_method = Spree::PaymentMethod.find(payment_method.id)
91
- expect(response_payment_method.name).to eql('Check')
92
- end
93
- end
94
- end
95
- end
@@ -1,194 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- module Spree
6
- module Admin
7
- describe PaymentsController, type: :controller do
8
- before do
9
- allow(controller).to receive_messages try_spree_current_user: user
10
- end
11
-
12
- let(:user) { create(:admin_user) }
13
- let(:order) { create(:order) }
14
-
15
- describe '#create' do
16
- context "with a valid credit card" do
17
- let(:order) { create(:order_with_line_items, state: "payment") }
18
- let(:payment_method) { create(:credit_card_payment_method, available_to_admin: true, available_to_users: false) }
19
- let(:attributes) do
20
- {
21
- order_id: order.number,
22
- card: "new",
23
- payment: {
24
- amount: order.total,
25
- payment_method_id: payment_method.id.to_s,
26
- source_attributes: {
27
- name: "Test User",
28
- number: "4111 1111 1111 1111",
29
- expiry: "09 / #{Time.current.year + 1}",
30
- verification_value: "123"
31
- }
32
- }
33
- }
34
- end
35
-
36
- before do
37
- post :create, params: attributes
38
- end
39
-
40
- it "should process payment correctly" do
41
- expect(order.payments.count).to eq(1)
42
- expect(order.payments.last.state).to eq 'checkout'
43
- expect(response).to redirect_to(spree.admin_order_payments_path(order))
44
- expect(order.reload.state).to eq('confirm')
45
- end
46
-
47
- context 'with credit card address fields' do
48
- let(:address) { build(:address) }
49
-
50
- let(:attributes) do
51
- attrs = super()
52
- attrs[:payment][:source_attributes][:address_attributes] = address_attributes
53
- attrs
54
- end
55
-
56
- let(:address_attributes) do
57
- {
58
- 'firstname' => address.firstname,
59
- 'address1' => address.address1,
60
- 'city' => address.city,
61
- 'country_id' => address.country_id,
62
- 'state_id' => address.state_id,
63
- 'zipcode' => address.zipcode,
64
- 'phone' => address.phone
65
- }
66
- end
67
-
68
- it 'associates the address' do
69
- expect(order.payments.count).to eq(1)
70
- credit_card = order.payments.last.source
71
- expect(credit_card.address.attributes).to include(address_attributes)
72
- end
73
- end
74
- end
75
- end
76
-
77
- describe '#new' do
78
- # Regression test for https://github.com/spree/spree/issues/3233
79
- context "with a backend payment method" do
80
- context "and the payment method is active" do
81
- before do
82
- @payment_method = create(:check_payment_method, available_to_admin: true)
83
- end
84
-
85
- it "loads the payment method" do
86
- get :new, params: { order_id: order.number }
87
- expect(response.status).to eq(200)
88
- expect(assigns[:payment_methods]).to include(@payment_method)
89
- end
90
- end
91
-
92
- context "and the payment method is inactive" do
93
- before do
94
- @payment_method = create(:check_payment_method, available_to_admin: true, active: false)
95
- end
96
-
97
- it "does not load the payment method" do
98
- get :new, params: { order_id: order.number }
99
- expect(response.status).to eq(200)
100
- expect(assigns[:payment_methods]).to be_empty
101
- end
102
- end
103
- end
104
- end
105
-
106
- describe '#index' do
107
- context "order has billing address" do
108
- before do
109
- order.bill_address = create(:address)
110
- order.save!
111
- end
112
-
113
- context "order does not have payments" do
114
- it "redirect to new payments page" do
115
- get :index, params: { amount: 100, order_id: order.number }
116
- expect(response).to redirect_to(spree.new_admin_order_payment_path(order))
117
- end
118
- end
119
-
120
- context "order has payments" do
121
- before do
122
- order.payments << create(:payment, amount: order.total, order: order, state: 'completed')
123
- end
124
-
125
- it "shows the payments page" do
126
- get :index, params: { amount: 100, order_id: order.number }
127
- expect(response.code).to eq "200"
128
- end
129
- end
130
- end
131
-
132
- context "order does not have a billing address" do
133
- before do
134
- order.bill_address = nil
135
- order.save
136
- end
137
-
138
- it "should redirect to the customer details page" do
139
- get :index, params: { amount: 100, order_id: order.number }
140
- expect(response).to redirect_to(spree.edit_admin_order_customer_path(order))
141
- end
142
- end
143
- end
144
-
145
- describe '#fire' do
146
- describe 'authorization' do
147
- let(:payment) { create(:payment, state: 'checkout') }
148
- let(:order) { payment.order }
149
-
150
- context 'the user is authorized' do
151
- class CaptureAllowedAbility
152
- include CanCan::Ability
153
-
154
- def initialize(_user)
155
- can :capture, Spree::Payment
156
- end
157
- end
158
-
159
- before do
160
- Spree::Ability.register_ability(CaptureAllowedAbility)
161
- end
162
-
163
- it 'allows the action' do
164
- expect {
165
- post(:fire, params: { id: payment.to_param, e: 'capture', order_id: order.to_param })
166
- }.to change { payment.reload.state }.from('checkout').to('completed')
167
- end
168
-
169
- context 'the user is not authorized' do
170
- class CaptureNotAllowedAbility
171
- include CanCan::Ability
172
-
173
- def initialize(_user)
174
- cannot :capture, Spree::Payment
175
- end
176
- end
177
-
178
- before do
179
- Spree::Ability.register_ability(CaptureNotAllowedAbility)
180
- end
181
-
182
- it 'does not allow the action' do
183
- expect {
184
- post(:fire, params: { id: payment.to_param, e: 'capture', order_id: order.to_param })
185
- }.to_not change { payment.reload.state }
186
- expect(flash[:error]).to eq('Authorization Failure')
187
- end
188
- end
189
- end
190
- end
191
- end
192
- end
193
- end
194
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Spree::Admin::PricesController do
6
- stub_authorization!
7
-
8
- let!(:product) { create(:product) }
9
-
10
- describe '#index' do
11
- context "when only given a product" do
12
- let(:product) { create(:product) }
13
-
14
- subject { get :index, params: { product_id: product.slug } }
15
-
16
- it { is_expected.to be_successful }
17
-
18
- it 'assigns usable instance variables' do
19
- subject
20
- expect(assigns(:search)).to be_a(Ransack::Search)
21
- expect(assigns(:variant_prices)).to eq(product.prices.for_variant)
22
- expect(assigns(:master_prices)).to eq(product.prices.for_master)
23
- expect(assigns(:product)).to eq(product)
24
- end
25
- end
26
-
27
- context "when given a product and a variant" do
28
- let(:variant) { create(:variant) }
29
- let(:product) { variant.product }
30
-
31
- subject { get :index, params: { product_id: product.slug, variant_id: variant.id } }
32
-
33
- it { is_expected.to be_successful }
34
-
35
- it 'assigns usable instance variables' do
36
- subject
37
- expect(assigns(:search)).to be_a(Ransack::Search)
38
- expect(assigns(:variant_prices)).to eq(product.prices.for_variant)
39
- expect(assigns(:master_prices)).to eq(product.prices.for_master)
40
- expect(assigns(:variant_prices)).to include(variant.default_price)
41
- expect(assigns(:product)).to eq(product)
42
- end
43
- end
44
- end
45
- end
@@ -1,71 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- module Spree
6
- module Admin
7
- describe ProductPropertiesController, type: :controller do
8
- stub_authorization!
9
-
10
- describe "#index" do
11
- subject { get :index, params: parameters }
12
-
13
- context "no option values are provided" do
14
- let(:product) { create(:product) }
15
- let(:parameters) do
16
- { product_id: product.to_param }
17
- end
18
-
19
- before { subject }
20
-
21
- it "instantiates a new variant property rule" do
22
- expect(assigns(:variant_property_rule)).to_not be_persisted
23
- end
24
-
25
- it "instantiates a new variant property rule value" do
26
- expect(assigns(:variant_property_rule).values.size).to eq 1
27
- expect(assigns(:variant_property_rule).values.first).to_not be_persisted
28
- end
29
- end
30
-
31
- context "option values are provided" do
32
- let(:size) { create(:option_type, name: 'size') }
33
- let(:product) { create(:product, option_types: [size]) }
34
- let(:size_small) { create(:option_value, name: 'small', option_type: size) }
35
- let(:size_large) { create(:option_value, name: 'large', option_type: size) }
36
- let!(:first_rule) { create(:variant_property_rule, product: product, option_value: size_small) }
37
-
38
- context "no rules match the option values" do
39
- let(:parameters) do
40
- {
41
- product_id: product.to_param,
42
- ovi: [size_large.id]
43
- }
44
- end
45
-
46
- before { subject }
47
-
48
- it "instantiates a new variant property rule" do
49
- expect(assigns(:variant_property_rule)).to_not be_persisted
50
- end
51
- end
52
-
53
- context "a rule matches the option values" do
54
- let(:parameters) do
55
- {
56
- product_id: product.to_param,
57
- ovi: [size_small.id]
58
- }
59
- end
60
-
61
- before { subject }
62
-
63
- it "assigns the property rule to the only property rule that matches the option values" do
64
- expect(assigns(:variant_property_rule)).to eq first_rule
65
- end
66
- end
67
- end
68
- end
69
- end
70
- end
71
- end
@@ -1,270 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe Spree::Admin::ProductsController, type: :controller do
6
- stub_authorization!
7
-
8
- context "#index" do
9
- let(:ability_user) { stub_model(Spree::LegacyUser, has_spree_role?: true) }
10
-
11
- # Regression test for https://github.com/spree/spree/issues/1259
12
- it "can find a product by SKU" do
13
- product = create(:product, sku: "ABC123")
14
- get :index, params: { q: { sku_start: "ABC123" } }
15
- expect(assigns[:collection]).not_to be_empty
16
- expect(assigns[:collection]).to include(product)
17
- end
18
-
19
- # Regression test for https://github.com/spree/spree/issues/1903
20
- context 'when soft deleted products exist' do
21
- let!(:soft_deleted_product) { create(:product, sku: "ABC123") }
22
- before { soft_deleted_product.discard }
23
-
24
- context 'when params[:q][:with_deleted] is not set' do
25
- let(:params) { { q: {} } }
26
-
27
- it 'filters out soft-deleted products by default' do
28
- get :index, params: params
29
- expect(assigns[:collection]).to_not include(soft_deleted_product)
30
- end
31
- end
32
-
33
- context 'when params[:q][:with_deleted] is set to "true"' do
34
- let(:params) { { q: { with_deleted: 'true' } } }
35
-
36
- it 'includes soft-deleted products' do
37
- get :index, params: params
38
- expect(assigns[:collection]).to include(soft_deleted_product)
39
- end
40
- end
41
- end
42
- end
43
-
44
- # regression test for https://github.com/spree/spree/issues/1370
45
- context "adding properties to a product" do
46
- let!(:product) { create(:product) }
47
- specify do
48
- put :update, params: { id: product.to_param, product: { product_properties_attributes: { "1" => { property_name: "Foo", value: "bar" } } } }
49
- expect(flash[:success]).to eq("Product #{product.name.inspect} has been successfully updated!")
50
- end
51
- end
52
-
53
- # regression test for https://github.com/solidusio/solidus/issues/2791
54
- context "creating a product" do
55
- before(:all) do
56
- create(:shipping_category)
57
- end
58
-
59
- it "creates a product" do
60
- post :create, params: {
61
- product: {
62
- name: "Product #1 - 9632",
63
- description: "As seen on TV!",
64
- price: 19.99,
65
- shipping_category_id: Spree::ShippingCategory.first.id,
66
- }
67
- }
68
- expect(flash[:success]).to eq("Product \"Product #1 - 9632\" has been successfully created!")
69
- end
70
-
71
- context "when there is a taxon" do
72
- let(:first_taxon) { create(:taxon) }
73
-
74
- it "creates a product with a taxon" do
75
- post :create, params: {
76
- product: {
77
- name: "Product #1 - 9632",
78
- description: "As seen on TV!",
79
- price: 19.99,
80
- shipping_category_id: Spree::ShippingCategory.first.id,
81
- taxon_ids: first_taxon.id.to_s
82
- }
83
- }
84
- expect(flash[:success]).to eq("Product \"Product #1 - 9632\" has been successfully created!")
85
- end
86
-
87
- context "when their are multiple taxons" do
88
- let(:second_taxon) { create(:taxon) }
89
-
90
- it "creates a product with multiple taxons" do
91
- post :create, params: {
92
- product: {
93
- name: "Product #1 - 9632",
94
- description: "As seen on TV!",
95
- price: 19.99,
96
- shipping_category_id: Spree::ShippingCategory.first.id,
97
- taxon_ids: "#{first_taxon.id}, #{second_taxon.id}"
98
- }
99
- }
100
- expect(flash[:success]).to eq("Product \"Product #1 - 9632\" has been successfully created!")
101
- end
102
- end
103
- end
104
- end
105
-
106
- context "adding taxons to a product" do
107
- let(:product) { create(:product) }
108
- let(:first_taxon) { create(:taxon) }
109
-
110
- it "adds a single taxon to a product" do
111
- put :update, params: { id: product.to_param, product: { taxon_ids: first_taxon.id.to_s } }
112
- expect(flash[:success]).to eq("Product #{product.name.inspect} has been successfully updated!")
113
- end
114
-
115
- context "when there are mulitple taxons" do
116
- let(:second_taxon) { create(:taxon) }
117
-
118
- it "adds multiple taxons to a product" do
119
- put :update, params: { id: product.to_param, product: { taxon_ids: "#{first_taxon.id}, #{second_taxon.id}" } }
120
- expect(flash[:success]).to eq("Product #{product.name.inspect} has been successfully updated!")
121
- end
122
- end
123
- end
124
-
125
- describe "creating variant property rules" do
126
- let(:first_property) { create(:property) }
127
- let(:second_property) { create(:property) }
128
- let(:option_value) { create(:option_value) }
129
- let!(:product) { create(:product, option_types: [option_value.option_type]) }
130
- let(:payload) do
131
- {
132
- id: product.to_param,
133
- product: {
134
- id: product.id,
135
- variant_property_rules_attributes: {
136
- "0" => {
137
- option_value_ids: option_value.id,
138
- values_attributes: {
139
- "0" => {
140
- property_name: first_property.name,
141
- value: "First"
142
- },
143
- "1" => {
144
- property_name: second_property.name,
145
- value: "Second"
146
- }
147
- }
148
- }
149
- }
150
- }
151
- }
152
- end
153
-
154
- subject { put :update, params: payload }
155
-
156
- it "creates a variant property rule" do
157
- expect { subject }.to change { product.variant_property_rules.count }.by(1)
158
- end
159
-
160
- it "creates a variant property rule condition" do
161
- expect { subject }.to change { product.variant_property_rule_conditions.count }.by(1)
162
- end
163
-
164
- it "creates a variant property rule value for the 'First' value" do
165
- subject
166
- expect(product.variant_property_rule_values.find_by(value: 'First')).to_not be_nil
167
- end
168
-
169
- it "creates a variant property rule value for the 'Second' value" do
170
- subject
171
- expect(product.variant_property_rule_values.find_by(value: 'Second')).to_not be_nil
172
- end
173
-
174
- it "redirects to the product properties page" do
175
- subject
176
- expect(response).to redirect_to(spree.admin_product_product_properties_path(product, ovi: [option_value.id]))
177
- end
178
- end
179
-
180
- describe "updating variant property rules" do
181
- let(:first_property) { create(:property) }
182
- let(:second_property) { create(:property) }
183
- let(:option_value) { create(:option_value) }
184
- let(:original_option_value) { create(:option_value) }
185
- let!(:product) { create(:product, option_types: [option_value.option_type]) }
186
- let!(:rule) do
187
- create(:variant_property_rule, product: product, option_value: original_option_value)
188
- end
189
- let(:payload) do
190
- {
191
- id: product.to_param,
192
- product: {
193
- id: product.id,
194
- variant_property_rules_attributes: {
195
- "0" => {
196
- id: rule.id,
197
- option_value_ids: option_value.id,
198
- values_attributes: {
199
- "0" => {
200
- property_name: first_property.name,
201
- value: "First Edit"
202
- },
203
- "1" => {
204
- property_name: second_property.name,
205
- value: "Second Edit"
206
- }
207
- }
208
- }
209
- }
210
- }
211
- }
212
- end
213
-
214
- subject { put :update, params: payload }
215
-
216
- it "does not create any new rules" do
217
- expect { subject }.to_not change { Spree::VariantPropertyRule.count }
218
- end
219
-
220
- it "replaces the rule's condition" do
221
- expect { subject }.to change { rule.reload.option_value_ids }.from([original_option_value.id]).to([option_value.id])
222
- end
223
-
224
- it "adds two values to the rule" do
225
- expect { subject }.to change { rule.values.count }.by(2)
226
- end
227
-
228
- it "creates the 'First Edit' value" do
229
- subject
230
- expect(rule.values.find_by(value: 'First Edit')).to_not be_nil
231
- end
232
-
233
- it "creates the 'Second Edit' value" do
234
- subject
235
- expect(rule.values.find_by(value: 'Second Edit')).to_not be_nil
236
- end
237
-
238
- it "redirects to the product properties page" do
239
- subject
240
- expect(response).to redirect_to(spree.admin_product_product_properties_path(product, ovi: [option_value.id]))
241
- end
242
- end
243
-
244
- context "cloning a product" do
245
- let!(:product) { create(:product) }
246
-
247
- it "duplicates the product" do
248
- expect do
249
- post :clone, params: { id: product.id }
250
- end.to change { Spree::Product.count }.by(1)
251
- end
252
- end
253
-
254
- # regression test for https://github.com/spree/spree/issues/801
255
- context "destroying a product" do
256
- let(:product) do
257
- product = create(:product)
258
- create(:variant, product: product)
259
- product
260
- end
261
-
262
- it "deletes all the variants (including master) for the product" do
263
- delete :destroy, params: { id: product }
264
- expect(product.reload.deleted_at).not_to be_nil
265
- product.variants_including_master.each do |variant|
266
- expect(variant.reload.deleted_at).not_to be_nil
267
- end
268
- end
269
- end
270
- end