solidus_backend 2.9.6 → 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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree/backend.js +5 -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/admin_nav.js +24 -0
- 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/components/tabs.js +1 -1
- data/app/assets/javascripts/spree/backend/models/order.js +11 -2
- 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/orders/cart.js +6 -0
- 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 -67
- 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 -1
- 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 +29 -0
- data/app/assets/javascripts/spree/backend/views/cart/line_item_table.js +5 -0
- data/app/assets/javascripts/spree/backend/views/index.js +5 -0
- data/app/assets/javascripts/spree/backend/views/order/address.js +8 -6
- 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/_bootstrap_custom.scss +2 -0
- data/app/assets/stylesheets/spree/backend/components/_breadcrumb.scss +3 -3
- data/app/assets/stylesheets/spree/backend/components/_messages.scss +4 -0
- data/app/assets/stylesheets/spree/backend/components/_navigation.scss +181 -49
- data/app/assets/stylesheets/spree/backend/globals/{_mixins.css → _mixins.scss} +0 -0
- data/app/assets/stylesheets/spree/backend/globals/_variables.scss +2 -0
- 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/assets/stylesheets/spree/backend/shared/_header.scss +5 -1
- data/app/assets/stylesheets/spree/backend/shared/_layout.scss +0 -9
- data/app/controllers/spree/admin/adjustments_controller.rb +1 -1
- data/app/controllers/spree/admin/base_controller.rb +7 -1
- 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 +9 -4
- data/app/controllers/spree/admin/payment_methods_controller.rb +4 -4
- data/app/controllers/spree/admin/payments_controller.rb +5 -3
- data/app/controllers/spree/admin/product_properties_controller.rb +2 -2
- data/app/controllers/spree/admin/products_controller.rb +19 -25
- data/app/controllers/spree/admin/promotion_codes_controller.rb +9 -4
- data/app/controllers/spree/admin/refunds_controller.rb +19 -0
- data/app/controllers/spree/admin/resource_controller.rb +39 -10
- 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/style_guide_controller.rb +1 -1
- data/app/controllers/spree/admin/taxons/attachment_controller.rb +20 -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 +43 -22
- 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 +4 -3
- data/app/helpers/spree/admin/orders_helper.rb +8 -4
- data/app/helpers/spree/admin/stock_movements_helper.rb +8 -4
- data/app/helpers/spree/promotion_rules_helper.rb +1 -1
- data/app/views/spree/admin/customer_returns/_return_item_selection.html.erb +2 -3
- data/app/views/spree/admin/customer_returns/new.html.erb +1 -1
- 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 +4 -2
- data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +1 -0
- data/app/views/spree/admin/orders/customer_details/_form.html.erb +13 -13
- data/app/views/spree/admin/orders/edit.html.erb +3 -4
- 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/payment_methods/new.html.erb +1 -1
- data/app/views/spree/admin/payments/index.html.erb +3 -1
- data/app/views/spree/admin/prices/_master_variant_table.html.erb +41 -41
- 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_code_batches/new.html.erb +1 -1
- data/app/views/spree/admin/promotion_codes/index.html.erb +1 -1
- data/app/views/spree/admin/promotion_codes/new.html.erb +1 -1
- data/app/views/spree/admin/promotions/_actions.html.erb +2 -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 +13 -6
- 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/return_authorizations/new.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/_calculator_fields.html.erb +5 -0
- data/app/views/spree/admin/shared/_navigation.html.erb +3 -0
- data/app/views/spree/admin/shared/_new_resource_links.html.erb +1 -1
- data/app/views/spree/admin/shared/_order_submenu.html.erb +6 -6
- 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 +7 -7
- 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 +19 -1
- 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 +4 -2
- data/app/views/spree/admin/stock_movements/index.html.erb +30 -1
- data/app/views/spree/admin/store_credit_reasons/index.html.erb +1 -1
- data/app/views/spree/admin/store_credits/index.html.erb +1 -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/tax_rates/_form.html.erb +1 -1
- data/app/views/spree/admin/taxonomies/new.html.erb +1 -1
- data/app/views/spree/admin/taxons/_form.html.erb +1 -5
- data/app/views/spree/admin/taxons/attachment_forms/_paperclip.html.erb +16 -0
- data/app/views/spree/admin/users/_form.html.erb +14 -12
- data/app/views/spree/admin/users/_tabs.html.erb +1 -1
- data/app/views/spree/admin/users/edit.html.erb +5 -6
- 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/app/views/spree/layouts/admin.html.erb +1 -2
- data/config/initializers/form_builder.rb +2 -2
- data/config/routes.rb +4 -6
- data/lib/spree/backend.rb +1 -0
- data/lib/spree/backend/config.rb +9 -0
- data/lib/spree/backend/engine.rb +5 -5
- data/{app/models → lib}/spree/backend_configuration.rb +19 -3
- data/solidus_backend.gemspec +5 -4
- data/vendor/assets/stylesheets/solidus_admin/bootstrap/_variables.scss +1 -1
- metadata +44 -124
- data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +0 -35
- data/app/assets/javascripts/spree/backend/templates/variants/autocomplete_stock.hbs +0 -56
- data/app/views/spree/admin/orders/_add_product.html.erb +0 -12
- 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 -190
- 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 -264
- data/spec/controllers/spree/admin/variants_controller_spec.rb +0 -71
- data/spec/features/admin/configuration/payment_methods_spec.rb +0 -167
- data/spec/features/admin/configuration/shipping_methods_spec.rb +0 -114
- 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 -54
- 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 -204
- data/spec/features/admin/orders/customer_returns_spec.rb +0 -28
- 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 -331
- data/spec/features/admin/orders/new_refund_spec.rb +0 -35
- data/spec/features/admin/orders/order_details_spec.rb +0 -581
- data/spec/features/admin/orders/payments_spec.rb +0 -330
- data/spec/features/admin/orders/return_authorizations_spec.rb +0 -27
- 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 -51
- 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 -336
- 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 -277
- 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_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 -78
- data/spec/features/admin/users_spec.rb +0 -402
- 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/models/spree/backend_configuration/menu_item_spec.rb +0 -17
- data/spec/models/spree/backend_configuration_spec.rb +0 -22
- data/spec/spec_helper.rb +0 -122
- data/spec/support/appear_before_matcher.rb +0 -10
- data/spec/support/feature/base_feature_helper.rb +0 -12
- data/spec/support/feature/order_feature_helper.rb +0 -27
- data/spec/support/ror_ringer.jpeg +0 -0
- 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,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Spree::Admin::PromotionActionsController, type: :controller do
|
6
|
-
stub_authorization!
|
7
|
-
|
8
|
-
let!(:promotion) { create(:promotion) }
|
9
|
-
|
10
|
-
it "can create a promotion action of a valid type" do
|
11
|
-
post :create, params: { promotion_id: promotion.id, action_type: "Spree::Promotion::Actions::CreateAdjustment" }
|
12
|
-
expect(response).to be_redirect
|
13
|
-
expect(response).to redirect_to spree.edit_admin_promotion_path(promotion)
|
14
|
-
expect(promotion.actions.count).to eq(1)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "can not create a promotion action of an invalid type" do
|
18
|
-
post :create, params: { promotion_id: promotion.id, action_type: "Spree::InvalidType" }
|
19
|
-
expect(response).to be_redirect
|
20
|
-
expect(response).to redirect_to spree.edit_admin_promotion_path(promotion)
|
21
|
-
expect(promotion.rules.count).to eq(0)
|
22
|
-
end
|
23
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Spree::Admin::PromotionCodesController do
|
6
|
-
stub_authorization!
|
7
|
-
render_views
|
8
|
-
|
9
|
-
let!(:promotion) { create(:promotion) }
|
10
|
-
let!(:code1) { create(:promotion_code, promotion: promotion) }
|
11
|
-
let!(:code2) { create(:promotion_code, promotion: promotion) }
|
12
|
-
let!(:code3) { create(:promotion_code, promotion: promotion) }
|
13
|
-
|
14
|
-
it "can create a CSV file with all promotion codes" do
|
15
|
-
get :index, params: { promotion_id: promotion.id, format: 'csv' }
|
16
|
-
expect(response).to be_successful
|
17
|
-
parsed = CSV.parse(response.body, headers: true)
|
18
|
-
expect(parsed.entries.map(&:to_h)).to eq([{ "Code" => code1.value }, { "Code" => code2.value }, { "Code" => code3.value }])
|
19
|
-
end
|
20
|
-
|
21
|
-
it "can create a new code" do
|
22
|
-
post :create, params: { promotion_id: promotion.id, promotion_code: { value: "new_code" } }
|
23
|
-
expect(response).to redirect_to(spree.admin_promotion_promotion_codes_path(promotion))
|
24
|
-
expect(Spree::PromotionCode.where(promotion: promotion).count).to eql(4)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "cannot create an existing code" do
|
28
|
-
post :create, params: { promotion_id: promotion.id, promotion_code: { value: code1.value } }
|
29
|
-
expect(flash[:error]).not_to be_nil
|
30
|
-
expect(Spree::PromotionCode.where(promotion: promotion).count).to eql(3)
|
31
|
-
end
|
32
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Spree::Admin::PromotionRulesController, type: :controller do
|
6
|
-
let!(:promotion) { create(:promotion) }
|
7
|
-
|
8
|
-
context "when the user is authorized" do
|
9
|
-
stub_authorization! do |_u|
|
10
|
-
Spree::PermissionSets::PromotionManagement.new(self).activate!
|
11
|
-
end
|
12
|
-
|
13
|
-
it "can create a promotion rule of a valid type" do
|
14
|
-
post :create, params: { promotion_id: promotion.id, promotion_rule: { type: "Spree::Promotion::Rules::Product" } }
|
15
|
-
expect(response).to be_redirect
|
16
|
-
expect(response).to redirect_to spree.edit_admin_promotion_path(promotion)
|
17
|
-
expect(promotion.rules.count).to eq(1)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "can not create a promotion rule of an invalid type" do
|
21
|
-
post :create, params: { promotion_id: promotion.id, promotion_rule: { type: "Spree::InvalidType" } }
|
22
|
-
expect(response).to be_redirect
|
23
|
-
expect(response).to redirect_to spree.edit_admin_promotion_path(promotion)
|
24
|
-
expect(promotion.rules.count).to eq(0)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
context "when the user is not authorized" do
|
29
|
-
it "sets an error message and redirects the user" do
|
30
|
-
post :create, params: { promotion_id: promotion.id, promotion_rule: { type: "Spree::Promotion::Rules::Product" } }
|
31
|
-
|
32
|
-
expect(flash[:error]).to eq("Authorization Failure")
|
33
|
-
expect(response).to redirect_to('/unauthorized')
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,122 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Spree::Admin::PromotionsController, type: :controller do
|
6
|
-
stub_authorization!
|
7
|
-
|
8
|
-
let!(:promotion1) { create(:promotion, name: "name1", code: "code1", path: "path1") }
|
9
|
-
let!(:promotion2) { create(:promotion, name: "name2", code: "code2", path: "path2") }
|
10
|
-
let!(:category) { create :promotion_category }
|
11
|
-
|
12
|
-
describe "#show" do
|
13
|
-
it "redirects to edit" do
|
14
|
-
expect(get(:show, params: { id: promotion1.id }))
|
15
|
-
.to redirect_to(action: :edit, id: promotion1.id )
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
describe "#index" do
|
20
|
-
it "succeeds" do
|
21
|
-
get :index
|
22
|
-
expect(assigns[:promotions]).to match_array [promotion2, promotion1]
|
23
|
-
end
|
24
|
-
|
25
|
-
it "assigns promotion categories" do
|
26
|
-
get :index
|
27
|
-
expect(assigns[:promotion_categories]).to match_array [category]
|
28
|
-
end
|
29
|
-
|
30
|
-
context "search" do
|
31
|
-
it "pages results" do
|
32
|
-
get :index, params: { per_page: '1' }
|
33
|
-
expect(assigns[:promotions]).to eq [promotion2]
|
34
|
-
end
|
35
|
-
|
36
|
-
it "filters by name" do
|
37
|
-
get :index, params: { q: { name_cont: promotion1.name } }
|
38
|
-
expect(assigns[:promotions]).to eq [promotion1]
|
39
|
-
end
|
40
|
-
|
41
|
-
it "filters by code" do
|
42
|
-
get :index, params: { q: { codes_value_cont: promotion1.codes.first.value } }
|
43
|
-
expect(assigns[:promotions]).to eq [promotion1]
|
44
|
-
end
|
45
|
-
|
46
|
-
it "filters by path" do
|
47
|
-
get :index, params: { q: { path_cont: promotion1.path } }
|
48
|
-
expect(assigns[:promotions]).to eq [promotion1]
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "#create" do
|
54
|
-
subject { post :create, params: params }
|
55
|
-
let(:params) { { promotion: { name: 'some promo' } } }
|
56
|
-
|
57
|
-
context "it succeeds" do
|
58
|
-
context "with no single code param" do
|
59
|
-
it "creates a promotion" do
|
60
|
-
expect { subject }.to change { Spree::Promotion.count }.by(1)
|
61
|
-
end
|
62
|
-
|
63
|
-
it "sets the flash message" do
|
64
|
-
subject
|
65
|
-
expect(flash[:success]).to eq "Promotion has been successfully created!"
|
66
|
-
end
|
67
|
-
|
68
|
-
it "redirects to promotion edit" do
|
69
|
-
subject
|
70
|
-
expect(response).to redirect_to "http://test.host/admin/promotions/#{assigns(:promotion).id}/edit"
|
71
|
-
end
|
72
|
-
|
73
|
-
it "doesn't create any promotion codes" do
|
74
|
-
expect { subject }.to_not change { Spree::PromotionCode.count }
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
context "with a single code" do
|
79
|
-
let(:params) { { promotion: { name: 'some promo' }, single_code: "promo" } }
|
80
|
-
|
81
|
-
it "creates a promotion" do
|
82
|
-
expect { subject }.to change { Spree::Promotion.count }.by(1)
|
83
|
-
end
|
84
|
-
|
85
|
-
it "sets the flash message" do
|
86
|
-
subject
|
87
|
-
expect(flash[:success]).to eq "Promotion has been successfully created!"
|
88
|
-
end
|
89
|
-
|
90
|
-
it "redirects to promotion edit" do
|
91
|
-
subject
|
92
|
-
expect(response).to redirect_to "http://test.host/admin/promotions/#{assigns(:promotion).id}/edit"
|
93
|
-
end
|
94
|
-
|
95
|
-
it "creates a promotion code" do
|
96
|
-
expect { subject }.to change { Spree::PromotionCode.count }.by(1)
|
97
|
-
expect(Spree::PromotionCode.last.value).to eq("promo")
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
context "it fails" do
|
103
|
-
let(:params) { {} }
|
104
|
-
|
105
|
-
it "does not create a promotion" do
|
106
|
-
expect {
|
107
|
-
subject
|
108
|
-
}.not_to change { Spree::Promotion.count }
|
109
|
-
end
|
110
|
-
|
111
|
-
it "sets the flash error" do
|
112
|
-
subject
|
113
|
-
expect(flash[:error]).to eq "Name can't be blank"
|
114
|
-
end
|
115
|
-
|
116
|
-
it "renders new" do
|
117
|
-
subject
|
118
|
-
expect(response).to render_template :new
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Spree::Admin::RefundsController do
|
6
|
-
stub_authorization!
|
7
|
-
|
8
|
-
describe "POST create" do
|
9
|
-
context "a Spree::Core::GatewayError is raised" do
|
10
|
-
let(:payment) { create(:payment) }
|
11
|
-
|
12
|
-
subject do
|
13
|
-
post :create,
|
14
|
-
params: {
|
15
|
-
refund: { amount: "50.0", refund_reason_id: "1" },
|
16
|
-
order_id: payment.order_id,
|
17
|
-
payment_id: payment.id
|
18
|
-
}
|
19
|
-
end
|
20
|
-
|
21
|
-
before(:each) do
|
22
|
-
def controller.create
|
23
|
-
raise Spree::Core::GatewayError.new('An error has occurred')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
it "sets an error message with the correct text" do
|
28
|
-
subject
|
29
|
-
expect(flash[:error]).to eq 'An error has occurred'
|
30
|
-
end
|
31
|
-
|
32
|
-
it { is_expected.to render_template(:new) }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,137 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Spree::Admin::ReimbursementsController, type: :controller do
|
6
|
-
stub_authorization!
|
7
|
-
|
8
|
-
let!(:default_refund_reason) do
|
9
|
-
Spree::RefundReason.find_or_create_by!(name: Spree::RefundReason::RETURN_PROCESSING_REASON, mutable: false)
|
10
|
-
end
|
11
|
-
|
12
|
-
let(:user) { stub_model(Spree::LegacyUser, has_spree_role?: true, id: 1) }
|
13
|
-
|
14
|
-
before do
|
15
|
-
allow_any_instance_of(described_class).to receive(:try_spree_current_user).
|
16
|
-
and_return(user)
|
17
|
-
end
|
18
|
-
|
19
|
-
describe '#edit' do
|
20
|
-
let(:reimbursement) { create(:reimbursement) }
|
21
|
-
let(:order) { reimbursement.order }
|
22
|
-
let!(:active_stock_location) { create(:stock_location, active: true) }
|
23
|
-
let!(:inactive_stock_location) { create(:stock_location, active: false) }
|
24
|
-
|
25
|
-
subject do
|
26
|
-
get :edit, params: { order_id: order.to_param, id: reimbursement.to_param }
|
27
|
-
end
|
28
|
-
|
29
|
-
it "loads all the active stock locations" do
|
30
|
-
subject
|
31
|
-
expect(assigns(:stock_locations)).to include(active_stock_location)
|
32
|
-
expect(assigns(:stock_locations)).not_to include(inactive_stock_location)
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '#create' do
|
37
|
-
let(:customer_return) { create(:customer_return, line_items_count: 1) }
|
38
|
-
let(:order) { customer_return.order }
|
39
|
-
let(:return_item) { customer_return.return_items.first }
|
40
|
-
let(:payment) { order.payments.first }
|
41
|
-
before { return_item.receive! }
|
42
|
-
|
43
|
-
subject do
|
44
|
-
post :create, params: { order_id: order.to_param, build_from_customer_return_id: customer_return.id }
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'creates the reimbursement' do
|
48
|
-
expect { subject }.to change { order.reimbursements.count }.by(1)
|
49
|
-
expect(assigns(:reimbursement).return_items.to_a).to eq customer_return.return_items.to_a
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'order is recalculated' do
|
53
|
-
expect { subject }.to change { order.reload.payment_state }.from('paid').to('credit_owed')
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'redirects to the edit page' do
|
57
|
-
subject
|
58
|
-
expect(response).to redirect_to(spree.edit_admin_order_reimbursement_path(order, assigns(:reimbursement)))
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'when create fails' do
|
62
|
-
before do
|
63
|
-
allow_any_instance_of(Spree::Reimbursement).to receive(:valid?) do |reimbursement, *_args|
|
64
|
-
reimbursement.errors.add(:base, 'something bad happened')
|
65
|
-
false
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context 'when a referer header is present' do
|
70
|
-
let(:referer) { spree.edit_admin_order_customer_return_path(order, customer_return) }
|
71
|
-
|
72
|
-
it 'redirects to the referer' do
|
73
|
-
request.env["HTTP_REFERER"] = referer
|
74
|
-
expect {
|
75
|
-
post :create, params: { order_id: order.to_param }
|
76
|
-
}.to_not change { Spree::Reimbursement.count }
|
77
|
-
expect(response).to redirect_to(referer)
|
78
|
-
expect(flash[:error]).to eq("something bad happened")
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
context 'when a referer header is not present' do
|
83
|
-
it 'redirects to the admin root' do
|
84
|
-
expect {
|
85
|
-
post :create, params: { order_id: order.to_param }
|
86
|
-
}.to_not change { Spree::Reimbursement.count }
|
87
|
-
expect(response).to redirect_to(spree.admin_path)
|
88
|
-
expect(flash[:error]).to eq("something bad happened")
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe "#perform" do
|
95
|
-
let(:reimbursement) { create(:reimbursement) }
|
96
|
-
let(:customer_return) { reimbursement.customer_return }
|
97
|
-
let(:order) { reimbursement.order }
|
98
|
-
let(:return_items) { reimbursement.return_items }
|
99
|
-
let(:payment) { order.payments.first }
|
100
|
-
|
101
|
-
subject do
|
102
|
-
post :perform, params: { order_id: order.to_param, id: reimbursement.to_param }
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'redirects to customer return page' do
|
106
|
-
subject
|
107
|
-
expect(response).to redirect_to spree.admin_order_reimbursement_path(order, reimbursement)
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'performs the reimbursement' do
|
111
|
-
expect {
|
112
|
-
subject
|
113
|
-
}.to change { payment.refunds.count }.by(1)
|
114
|
-
expect(payment.refunds.last.amount).to be > 0
|
115
|
-
expect(payment.refunds.last.amount).to eq return_items.to_a.sum(&:total)
|
116
|
-
end
|
117
|
-
|
118
|
-
context "a Spree::Core::GatewayError is raised" do
|
119
|
-
before(:each) do
|
120
|
-
def controller.perform
|
121
|
-
raise Spree::Core::GatewayError.new('An error has occurred')
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
it "sets an error message with the correct text" do
|
126
|
-
subject
|
127
|
-
expect(flash[:error]).to eq 'An error has occurred'
|
128
|
-
end
|
129
|
-
|
130
|
-
it 'redirects to the edit page' do
|
131
|
-
subject
|
132
|
-
redirect_path = spree.edit_admin_order_reimbursement_path(order, assigns(:reimbursement))
|
133
|
-
expect(response).to redirect_to(redirect_path)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
@@ -1,190 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
module Spree
|
6
|
-
module Admin
|
7
|
-
class WidgetsController < Spree::Admin::ResourceController
|
8
|
-
prepend_view_path('spec/test_views')
|
9
|
-
|
10
|
-
def model_class
|
11
|
-
Widget
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
describe Spree::Admin::WidgetsController, type: :controller do
|
18
|
-
stub_authorization!
|
19
|
-
|
20
|
-
after(:all) do
|
21
|
-
# Spree::Core::Engine.routes.reload_routes!
|
22
|
-
Rails.application.reload_routes!
|
23
|
-
end
|
24
|
-
|
25
|
-
with_model 'Widget', scope: :all do
|
26
|
-
table do |t|
|
27
|
-
t.string :name
|
28
|
-
t.integer :position
|
29
|
-
t.timestamps null: false
|
30
|
-
end
|
31
|
-
|
32
|
-
model do
|
33
|
-
acts_as_list
|
34
|
-
validates :name, presence: true
|
35
|
-
before_destroy :check_destroy_constraints
|
36
|
-
|
37
|
-
def check_destroy_constraints
|
38
|
-
return unless name == 'undestroyable'
|
39
|
-
errors.add :base, "You can't destroy undestroyable things!"
|
40
|
-
throw(:abort)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
before do
|
46
|
-
Spree::Core::Engine.routes.draw do
|
47
|
-
namespace :admin do
|
48
|
-
resources :widgets do
|
49
|
-
post :update_positions, on: :member
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe '#new' do
|
56
|
-
subject do
|
57
|
-
get :new
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'succeeds' do
|
61
|
-
subject
|
62
|
-
expect(response).to be_successful
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe '#edit' do
|
67
|
-
let(:widget) { Widget.create!(name: 'a widget') }
|
68
|
-
|
69
|
-
subject do
|
70
|
-
get :edit, params: { id: widget.to_param }
|
71
|
-
end
|
72
|
-
|
73
|
-
it 'succeeds' do
|
74
|
-
subject
|
75
|
-
expect(response).to be_successful
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe '#create' do
|
80
|
-
let(:params) do
|
81
|
-
{ widget: { name: 'a widget' } }
|
82
|
-
end
|
83
|
-
|
84
|
-
subject { post :create, params: params }
|
85
|
-
|
86
|
-
it 'creates the resource' do
|
87
|
-
expect { subject }.to change { Widget.count }.by(1)
|
88
|
-
end
|
89
|
-
|
90
|
-
context 'failure' do
|
91
|
-
let(:params) do
|
92
|
-
{ widget: { name: '' } } # blank name generates an error
|
93
|
-
end
|
94
|
-
|
95
|
-
it 'sets a flash error' do
|
96
|
-
subject
|
97
|
-
expect(flash[:error]).to eq assigns(:widget).errors.full_messages.join(', ')
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
context 'without any parameters' do
|
102
|
-
let(:params) { {} }
|
103
|
-
|
104
|
-
before do
|
105
|
-
allow_any_instance_of(Widget).to receive(:name).and_return('some name')
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'creates the resource' do
|
109
|
-
expect { subject }.to change { Widget.count }.by(1)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe '#update' do
|
115
|
-
let(:widget) { Widget.create!(name: 'a widget') }
|
116
|
-
|
117
|
-
let(:params) do
|
118
|
-
{
|
119
|
-
id: widget.to_param,
|
120
|
-
widget: { name: 'widget renamed' }
|
121
|
-
}
|
122
|
-
end
|
123
|
-
|
124
|
-
subject { put :update, params: params }
|
125
|
-
|
126
|
-
it 'updates the resource' do
|
127
|
-
expect { subject }.to change { widget.reload.name }.from('a widget').to('widget renamed')
|
128
|
-
end
|
129
|
-
|
130
|
-
context 'failure' do
|
131
|
-
let(:params) do
|
132
|
-
{
|
133
|
-
id: widget.to_param,
|
134
|
-
widget: { name: '' }, # a blank name will trigger a validation error
|
135
|
-
}
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'sets a flash error' do
|
139
|
-
subject
|
140
|
-
expect(flash[:error]).to eq assigns(:widget).errors.full_messages.join(', ')
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
describe '#destroy' do
|
146
|
-
let!(:widget) { Widget.create!(name: 'a widget') }
|
147
|
-
let(:params) { { id: widget.id } }
|
148
|
-
|
149
|
-
subject {
|
150
|
-
delete :destroy, params: params
|
151
|
-
}
|
152
|
-
|
153
|
-
it 'destroys the resource' do
|
154
|
-
expect { subject }.to change { Widget.count }.from(1).to(0)
|
155
|
-
end
|
156
|
-
|
157
|
-
context 'failure' do
|
158
|
-
let(:widget) { Widget.create!(name: 'undestroyable') }
|
159
|
-
let(:params) { { id: widget.id } }
|
160
|
-
|
161
|
-
context 'js format' do
|
162
|
-
subject { delete :destroy, params: params, format: 'js' }
|
163
|
-
|
164
|
-
it 'responds with error message' do
|
165
|
-
subject
|
166
|
-
expect(response).to be_unprocessable
|
167
|
-
expect(response.body).to eq assigns(:widget).errors.full_messages.join(', ')
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
describe '#update_positions' do
|
174
|
-
let(:widget_1) { Widget.create!(name: 'widget 1', position: 1) }
|
175
|
-
let(:widget_2) { Widget.create!(name: 'widget 2', position: 2) }
|
176
|
-
|
177
|
-
subject do
|
178
|
-
post :update_positions, params: { id: widget_1.to_param,
|
179
|
-
positions: { widget_1.id => '2', widget_2.id => '1' }, format: 'js' }
|
180
|
-
end
|
181
|
-
|
182
|
-
it 'updates the position of widget 1' do
|
183
|
-
expect { subject }.to change { widget_1.reload.position }.from(1).to(2)
|
184
|
-
end
|
185
|
-
|
186
|
-
it 'updates the position of widget 2' do
|
187
|
-
expect { subject }.to change { widget_2.reload.position }.from(2).to(1)
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|