solidus_backend 2.10.0 → 2.11.1
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 +19 -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,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,201 +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
|
-
errors.add :base, "Terrible things might happen."
|
41
|
-
throw(:abort)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
before do
|
47
|
-
Spree::Core::Engine.routes.draw do
|
48
|
-
namespace :admin do
|
49
|
-
resources :widgets do
|
50
|
-
post :update_positions, on: :member
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe '#new' do
|
57
|
-
subject do
|
58
|
-
get :new
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'succeeds' do
|
62
|
-
subject
|
63
|
-
expect(response).to be_successful
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe '#edit' do
|
68
|
-
let(:widget) { Widget.create!(name: 'a widget') }
|
69
|
-
|
70
|
-
subject do
|
71
|
-
get :edit, params: { id: widget.to_param }
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'succeeds' do
|
75
|
-
subject
|
76
|
-
expect(response).to be_successful
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe '#create' do
|
81
|
-
let(:params) do
|
82
|
-
{ widget: { name: 'a widget' } }
|
83
|
-
end
|
84
|
-
|
85
|
-
subject { post :create, params: params }
|
86
|
-
|
87
|
-
it 'creates the resource' do
|
88
|
-
expect { subject }.to change { Widget.count }.by(1)
|
89
|
-
end
|
90
|
-
|
91
|
-
context 'failure' do
|
92
|
-
let(:params) do
|
93
|
-
{ widget: { name: '' } } # blank name generates an error
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'sets a flash error' do
|
97
|
-
subject
|
98
|
-
expect(flash[:error]).to eq assigns(:widget).errors.full_messages.join(', ')
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
context 'without any parameters' do
|
103
|
-
let(:params) { {} }
|
104
|
-
|
105
|
-
before do
|
106
|
-
allow_any_instance_of(Widget).to receive(:name).and_return('some name')
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'creates the resource' do
|
110
|
-
expect { subject }.to change { Widget.count }.by(1)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
describe '#update' do
|
116
|
-
let(:widget) { Widget.create!(name: 'a widget') }
|
117
|
-
|
118
|
-
let(:params) do
|
119
|
-
{
|
120
|
-
id: widget.to_param,
|
121
|
-
widget: { name: 'widget renamed' }
|
122
|
-
}
|
123
|
-
end
|
124
|
-
|
125
|
-
subject { put :update, params: params }
|
126
|
-
|
127
|
-
it 'updates the resource' do
|
128
|
-
expect { subject }.to change { widget.reload.name }.from('a widget').to('widget renamed')
|
129
|
-
end
|
130
|
-
|
131
|
-
context 'failure' do
|
132
|
-
let(:params) do
|
133
|
-
{
|
134
|
-
id: widget.to_param,
|
135
|
-
widget: { name: '' }, # a blank name will trigger a validation error
|
136
|
-
}
|
137
|
-
end
|
138
|
-
|
139
|
-
it 'sets a flash error' do
|
140
|
-
subject
|
141
|
-
expect(flash[:error]).to eq assigns(:widget).errors.full_messages.join(', ')
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
describe '#destroy' do
|
147
|
-
let!(:widget) { Widget.create!(name: 'a widget') }
|
148
|
-
let(:params) { { id: widget.id } }
|
149
|
-
|
150
|
-
subject {
|
151
|
-
delete :destroy, params: params
|
152
|
-
}
|
153
|
-
|
154
|
-
it 'destroys the resource' do
|
155
|
-
expect { subject }.to change { Widget.count }.from(1).to(0)
|
156
|
-
end
|
157
|
-
|
158
|
-
context 'failure' do
|
159
|
-
let(:widget) { Widget.create!(name: 'undestroyable') }
|
160
|
-
let(:params) { { id: widget.id } }
|
161
|
-
|
162
|
-
context 'js format' do
|
163
|
-
subject { delete :destroy, params: params, format: 'js' }
|
164
|
-
|
165
|
-
it 'responds with error message' do
|
166
|
-
subject
|
167
|
-
expect(response).to be_unprocessable
|
168
|
-
expect(response.body).to eq assigns(:widget).errors.full_messages.to_sentence
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
context 'html format' do
|
173
|
-
subject { delete :destroy, params: params }
|
174
|
-
|
175
|
-
it 'responds with error message' do
|
176
|
-
subject
|
177
|
-
expect(response).to be_redirect
|
178
|
-
expect(flash[:error]).to eq assigns(:widget).errors.full_messages.to_sentence
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
describe '#update_positions' do
|
185
|
-
let(:widget_1) { Widget.create!(name: 'widget 1', position: 1) }
|
186
|
-
let(:widget_2) { Widget.create!(name: 'widget 2', position: 2) }
|
187
|
-
|
188
|
-
subject do
|
189
|
-
post :update_positions, params: { id: widget_1.to_param,
|
190
|
-
positions: { widget_1.id => '2', widget_2.id => '1' }, format: 'js' }
|
191
|
-
end
|
192
|
-
|
193
|
-
it 'updates the position of widget 1' do
|
194
|
-
expect { subject }.to change { widget_1.reload.position }.from(1).to(2)
|
195
|
-
end
|
196
|
-
|
197
|
-
it 'updates the position of widget 2' do
|
198
|
-
expect { subject }.to change { widget_2.reload.position }.from(2).to(1)
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|