solidus_backend 2.10.1 → 2.11.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_backend might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree/backend.js +4 -1
- data/app/assets/javascripts/spree/backend/adjustments.js +1 -1
- data/app/assets/javascripts/spree/backend/admin.js +18 -29
- data/app/assets/javascripts/spree/backend/collections/states.js +1 -1
- data/app/assets/javascripts/spree/backend/components/selectable_table.js +5 -0
- data/app/assets/javascripts/spree/backend/components/selectable_table/return_items.js +5 -0
- data/app/assets/javascripts/spree/backend/components/selectable_table/summary.js +7 -0
- data/app/assets/javascripts/spree/backend/components/sortable_table.js +31 -25
- data/app/assets/javascripts/spree/backend/models/order.js +3 -3
- data/app/assets/javascripts/spree/backend/models/payment.js +1 -1
- data/app/assets/javascripts/spree/backend/models/shipment.js +1 -1
- data/app/assets/javascripts/spree/backend/models/stock_item.js +1 -1
- data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +2 -2
- data/app/assets/javascripts/spree/backend/option_value_picker.js +2 -2
- data/app/assets/javascripts/spree/backend/product_picker.js +2 -2
- data/app/assets/javascripts/spree/backend/routes.js +40 -21
- data/app/assets/javascripts/spree/backend/shipments.js +5 -5
- data/app/assets/javascripts/spree/backend/shipping_methods/stock_locations_picker.js +18 -0
- data/app/assets/javascripts/spree/backend/stock_management.js +4 -2
- data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +2 -2
- data/app/assets/javascripts/spree/backend/taxons.js +3 -3
- data/app/assets/javascripts/spree/backend/templates/index.js +2 -0
- data/app/assets/javascripts/spree/backend/templates/orders/customer_details/autocomplete.hbs +2 -2
- data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +5 -1
- data/app/assets/javascripts/spree/backend/templates/tables/return_item_sum_amount.hbs +7 -0
- data/app/assets/javascripts/spree/backend/templates/tables/selectable_label.hbs +6 -0
- data/app/assets/javascripts/spree/backend/user_picker.js +3 -4
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js +2 -2
- data/app/assets/javascripts/spree/backend/views/cart/empty_cart_button.js +2 -2
- data/app/assets/javascripts/spree/backend/views/index.js +4 -0
- data/app/assets/javascripts/spree/backend/views/order/address.js +1 -1
- data/app/assets/javascripts/spree/backend/views/order/customer_select.js +2 -3
- data/app/assets/javascripts/spree/backend/views/order/details_adjustments.js +4 -1
- data/app/assets/javascripts/spree/backend/views/stock/edit_stock_item_row.js +4 -0
- data/app/assets/javascripts/spree/backend/views/tables/return_items.js +9 -0
- data/app/assets/javascripts/spree/backend/views/tables/selectable_table.js +70 -0
- data/app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js +32 -0
- data/app/assets/javascripts/spree/backend/views/tables/selectable_table/summary.js +45 -0
- data/app/assets/stylesheets/spree/backend/components/_navigation.scss +4 -5
- data/app/assets/stylesheets/spree/backend/sections/_orders.scss +5 -1
- data/app/assets/stylesheets/spree/backend/sections/_style_guide.scss +4 -0
- data/app/assets/stylesheets/spree/backend/shared/_forms.scss +1 -0
- data/app/controllers/spree/admin/base_controller.rb +6 -0
- data/app/controllers/spree/admin/cancellations_controller.rb +2 -0
- data/app/controllers/spree/admin/customer_returns_controller.rb +4 -4
- data/app/controllers/spree/admin/images_controller.rb +2 -1
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +2 -0
- data/app/controllers/spree/admin/orders_controller.rb +7 -2
- data/app/controllers/spree/admin/payments_controller.rb +3 -1
- data/app/controllers/spree/admin/product_properties_controller.rb +1 -1
- data/app/controllers/spree/admin/products_controller.rb +18 -24
- data/app/controllers/spree/admin/promotion_codes_controller.rb +9 -4
- data/app/controllers/spree/admin/refunds_controller.rb +20 -0
- data/app/controllers/spree/admin/resource_controller.rb +27 -7
- data/app/controllers/spree/admin/return_authorizations_controller.rb +1 -1
- data/app/controllers/spree/admin/root_controller.rb +1 -1
- data/app/controllers/spree/admin/search_controller.rb +1 -2
- data/app/controllers/spree/admin/stock_items_controller.rb +6 -5
- data/app/controllers/spree/admin/stock_locations_controller.rb +4 -0
- data/app/controllers/spree/admin/stock_movements_controller.rb +7 -0
- data/app/controllers/spree/admin/taxons_controller.rb +12 -1
- data/app/controllers/spree/admin/users/api_key_controller.rb +29 -0
- data/app/controllers/spree/admin/users_controller.rb +37 -20
- data/app/controllers/spree/admin/variants_controller.rb +4 -2
- data/app/controllers/spree/admin/zones_controller.rb +1 -1
- data/app/helpers/spree/admin/base_helper.rb +4 -0
- data/app/helpers/spree/admin/customer_returns_helper.rb +1 -1
- data/app/helpers/spree/admin/navigation_helper.rb +1 -1
- data/app/helpers/spree/admin/orders_helper.rb +8 -4
- data/app/helpers/spree/admin/stock_movements_helper.rb +8 -4
- data/app/views/spree/admin/customer_returns/_return_item_selection.html.erb +2 -3
- data/app/views/spree/admin/images/index.html.erb +25 -21
- data/app/views/spree/admin/option_types/_option_value_fields.html.erb +8 -1
- data/app/views/spree/admin/option_types/edit.html.erb +3 -1
- data/app/views/spree/admin/orders/customer_details/_form.html.erb +13 -13
- data/app/views/spree/admin/orders/index.html.erb +23 -13
- data/app/views/spree/admin/payment_methods/_form.html.erb +7 -2
- data/app/views/spree/admin/payments/index.html.erb +3 -1
- data/app/views/spree/admin/prices/_master_variant_table.html.erb +3 -3
- data/app/views/spree/admin/prices/_table.html.erb +3 -3
- data/app/views/spree/admin/product_properties/_product_property_fields.html.erb +7 -2
- data/app/views/spree/admin/product_properties/index.html.erb +14 -2
- data/app/views/spree/admin/products/_form.html.erb +13 -2
- data/app/views/spree/admin/products/index.html.erb +1 -1
- data/app/views/spree/admin/promotion_codes/index.html.erb +1 -1
- data/app/views/spree/admin/promotions/_actions.html.erb +1 -1
- data/app/views/spree/admin/promotions/_activations_new.html.erb +1 -1
- data/app/views/spree/admin/promotions/_rules.html.erb +1 -1
- data/app/views/spree/admin/promotions/edit.html.erb +2 -2
- data/app/views/spree/admin/promotions/index.html.erb +12 -5
- data/app/views/spree/admin/return_authorizations/_form.html.erb +3 -10
- data/app/views/spree/admin/return_authorizations/index.html.erb +1 -1
- data/app/views/spree/admin/search/users.json.jbuilder +15 -1
- data/app/views/spree/admin/shared/_address.html.erb +6 -6
- data/app/views/spree/admin/shared/_address_form.html.erb +15 -8
- data/app/views/spree/admin/shared/_order_submenu.html.erb +4 -4
- data/app/views/spree/admin/shared/_payments_tabs.html.erb +1 -1
- data/app/views/spree/admin/shared/_settings_checkout_tabs.html.erb +5 -5
- data/app/views/spree/admin/shared/_settings_sub_menu.html.erb +6 -6
- data/app/views/spree/admin/shared/_shipping_tabs.html.erb +3 -3
- data/app/views/spree/admin/shared/_taxes_tabs.html.erb +2 -2
- data/app/views/spree/admin/shared/preference_fields/_encrypted_string.html.erb +12 -0
- data/app/views/spree/admin/shipping_methods/_form.html.erb +18 -0
- data/app/views/spree/admin/stock_items/_stock_management.html.erb +1 -1
- data/app/views/spree/admin/stock_locations/edit.html.erb +1 -1
- data/app/views/spree/admin/stock_locations/index.html.erb +3 -1
- data/app/views/spree/admin/stock_movements/index.html.erb +30 -1
- data/app/views/spree/admin/stores/_form.html.erb +6 -0
- data/app/views/spree/admin/style_guide/topics/tables/_building_tables.html.erb +27 -3
- data/app/views/spree/admin/tax_categories/_form.html.erb +1 -0
- data/app/views/spree/admin/users/_form.html.erb +2 -2
- data/app/views/spree/admin/users/_tabs.html.erb +1 -1
- data/app/views/spree/admin/users/edit.html.erb +4 -4
- data/app/views/spree/admin/users/items.html.erb +5 -3
- data/app/views/spree/admin/users/orders.html.erb +5 -3
- data/app/views/spree/admin/variants/_table_filter.html.erb +1 -1
- data/app/views/spree/admin/variants/index.html.erb +2 -2
- data/config/initializers/form_builder.rb +2 -2
- data/lib/spree/backend/engine.rb +0 -2
- data/lib/spree/backend_configuration.rb +14 -1
- data/solidus_backend.gemspec +4 -4
- metadata +24 -123
- data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +0 -35
- data/script/rails +0 -10
- data/spec/controllers/spree/admin/base_controller_spec.rb +0 -26
- data/spec/controllers/spree/admin/cancellations_controller_spec.rb +0 -83
- data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +0 -235
- data/spec/controllers/spree/admin/locale_controller_spec.rb +0 -45
- data/spec/controllers/spree/admin/missing_products_controller_spec.rb +0 -18
- data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +0 -128
- data/spec/controllers/spree/admin/orders_controller_spec.rb +0 -408
- data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +0 -95
- data/spec/controllers/spree/admin/payments_controller_spec.rb +0 -194
- data/spec/controllers/spree/admin/prices_controller_spec.rb +0 -45
- data/spec/controllers/spree/admin/product_properties_controller_spec.rb +0 -71
- data/spec/controllers/spree/admin/products_controller_spec.rb +0 -270
- data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +0 -23
- data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +0 -32
- data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +0 -36
- data/spec/controllers/spree/admin/promotions_controller_spec.rb +0 -122
- data/spec/controllers/spree/admin/refunds_controller_spec.rb +0 -35
- data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +0 -137
- data/spec/controllers/spree/admin/resource_controller_spec.rb +0 -201
- data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +0 -291
- data/spec/controllers/spree/admin/return_items_controller_spec.rb +0 -29
- data/spec/controllers/spree/admin/root_controller_spec.rb +0 -43
- data/spec/controllers/spree/admin/search_controller_spec.rb +0 -106
- data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +0 -16
- data/spec/controllers/spree/admin/stock_items_controller_spec.rb +0 -52
- data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +0 -44
- data/spec/controllers/spree/admin/store_credits_controller_spec.rb +0 -311
- data/spec/controllers/spree/admin/users_controller_spec.rb +0 -287
- data/spec/controllers/spree/admin/variants_controller_spec.rb +0 -71
- data/spec/features/admin/configuration/payment_methods_spec.rb +0 -176
- data/spec/features/admin/configuration/shipping_methods_spec.rb +0 -126
- data/spec/features/admin/configuration/stock_locations_spec.rb +0 -54
- data/spec/features/admin/configuration/store_spec.rb +0 -62
- data/spec/features/admin/configuration/tax_categories_spec.rb +0 -58
- data/spec/features/admin/configuration/tax_rates_spec.rb +0 -31
- data/spec/features/admin/configuration/taxonomies_spec.rb +0 -61
- data/spec/features/admin/configuration/zones_spec.rb +0 -41
- data/spec/features/admin/homepage_spec.rb +0 -86
- data/spec/features/admin/javascript_format_money_spec.rb +0 -22
- data/spec/features/admin/locale_spec.rb +0 -34
- data/spec/features/admin/orders/adjustments_promotions_spec.rb +0 -55
- data/spec/features/admin/orders/adjustments_spec.rb +0 -130
- data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +0 -45
- data/spec/features/admin/orders/cancelling_inventory_spec.rb +0 -50
- data/spec/features/admin/orders/customer_details_spec.rb +0 -203
- data/spec/features/admin/orders/customer_returns_spec.rb +0 -41
- data/spec/features/admin/orders/line_items_spec.rb +0 -52
- data/spec/features/admin/orders/listing_spec.rb +0 -186
- data/spec/features/admin/orders/log_entries_spec.rb +0 -56
- data/spec/features/admin/orders/new_order_spec.rb +0 -379
- data/spec/features/admin/orders/new_refund_spec.rb +0 -35
- data/spec/features/admin/orders/order_details_spec.rb +0 -591
- data/spec/features/admin/orders/payments_spec.rb +0 -330
- data/spec/features/admin/orders/return_authorizations_spec.rb +0 -56
- data/spec/features/admin/orders/return_payment_state_spec.rb +0 -65
- data/spec/features/admin/orders/risk_analysis_spec.rb +0 -49
- data/spec/features/admin/orders/shipments_spec.rb +0 -145
- data/spec/features/admin/payments/store_credits_spec.rb +0 -23
- data/spec/features/admin/products/edit/images_spec.rb +0 -76
- data/spec/features/admin/products/edit/products_spec.rb +0 -92
- data/spec/features/admin/products/edit/taxons_spec.rb +0 -57
- data/spec/features/admin/products/edit/variants_spec.rb +0 -63
- data/spec/features/admin/products/option_types_spec.rb +0 -116
- data/spec/features/admin/products/pricing_spec.rb +0 -127
- data/spec/features/admin/products/products_spec.rb +0 -348
- data/spec/features/admin/products/properties_spec.rb +0 -141
- data/spec/features/admin/products/stock_management_spec.rb +0 -101
- data/spec/features/admin/products/variant_spec.rb +0 -89
- data/spec/features/admin/promotion_adjustments_spec.rb +0 -286
- data/spec/features/admin/promotions/option_value_rule_spec.rb +0 -90
- data/spec/features/admin/promotions/product_rule_spec.rb +0 -35
- data/spec/features/admin/promotions/promotion_categories_spec.rb +0 -83
- data/spec/features/admin/promotions/promotion_code_batches_spec.rb +0 -37
- data/spec/features/admin/promotions/promotion_code_spec.rb +0 -31
- data/spec/features/admin/promotions/promotion_spec.rb +0 -52
- data/spec/features/admin/promotions/tiered_calculator_spec.rb +0 -76
- data/spec/features/admin/promotions/user_rule_spec.rb +0 -42
- data/spec/features/admin/reimbursements_spec.rb +0 -18
- data/spec/features/admin/store_credits_spec.rb +0 -132
- data/spec/features/admin/stores_spec.rb +0 -37
- data/spec/features/admin/style_guide_spec.rb +0 -14
- data/spec/features/admin/taxons_spec.rb +0 -90
- data/spec/features/admin/users_spec.rb +0 -412
- data/spec/fixtures/files/ror_ringer.jpeg +0 -0
- data/spec/helpers/admin/base_helper_spec.rb +0 -49
- data/spec/helpers/admin/navigation_helper_spec.rb +0 -139
- data/spec/helpers/admin/stock_movements_helper_spec.rb +0 -29
- data/spec/helpers/admin/store_credit_events_helper_spec.rb +0 -97
- data/spec/helpers/promotion_rules_helper_spec.rb +0 -14
- data/spec/javascripts/fixtures/_boot.html.erb +0 -8
- data/spec/javascripts/fixtures/number_with_currency/with_currency_select.html.erb +0 -3
- data/spec/javascripts/fixtures/number_with_currency/without_select.html.erb +0 -3
- data/spec/javascripts/format_money_spec.js +0 -48
- data/spec/javascripts/spec_helper.js +0 -13
- data/spec/javascripts/support/show_errors.js +0 -8
- data/spec/javascripts/support/with_translations.js +0 -11
- data/spec/javascripts/translation_spec.js +0 -58
- data/spec/javascripts/views/number_with_currency_spec.js +0 -72
- data/spec/lib/spree/backend_configuration/menu_item_spec.rb +0 -17
- data/spec/lib/spree/backend_configuration_spec.rb +0 -22
- data/spec/spec_helper.rb +0 -123
- data/spec/support/appear_before_matcher.rb +0 -10
- data/spec/support/feature/base_feature_helper.rb +0 -17
- data/spec/support/feature/order_feature_helper.rb +0 -27
- data/spec/teaspoon_env.rb +0 -51
- data/spec/test_views/spree/admin/widgets/edit.html.erb +0 -1
- data/spec/test_views/spree/admin/widgets/new.html.erb +0 -1
- 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
|