solidus_backend 2.7.4 → 2.9.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_backend might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +12 -8
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/javascripts/spree/backend.js +0 -2
- data/app/assets/javascripts/spree/backend/adjustments.js +1 -1
- data/app/assets/javascripts/spree/backend/components/sortable_table.js +1 -0
- data/app/assets/javascripts/spree/backend/components/tabs.js +1 -0
- data/app/assets/javascripts/spree/backend/components/tooltips.js +21 -17
- data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +1 -1
- data/app/assets/javascripts/spree/backend/product_picker.js +1 -1
- data/app/assets/javascripts/spree/backend/shipments.js +7 -1
- data/app/assets/javascripts/spree/backend/stock_management.js +18 -0
- data/app/assets/javascripts/spree/backend/store_credits.js +18 -2
- data/app/assets/javascripts/spree/backend/taxons.js +1 -1
- data/app/assets/javascripts/spree/backend/templates/orders/line_item.hbs +1 -1
- data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +24 -25
- data/app/assets/javascripts/spree/backend/user_picker.js +1 -1
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js +1 -1
- data/app/assets/javascripts/spree/backend/views/order/customer_select.js +1 -1
- data/app/assets/javascripts/spree/backend/views/order/summary.js +2 -2
- data/app/assets/javascripts/spree/backend/views/stock/add_stock_item.js +15 -4
- data/app/assets/javascripts/spree/backend/views/stock/edit_stock_item_row.js +46 -10
- data/app/assets/stylesheets/spree/backend/_bootstrap_custom.scss +24 -16
- data/app/assets/stylesheets/spree/backend/components/_breadcrumb.scss +12 -0
- data/app/assets/stylesheets/spree/backend/components/_buttons.scss +18 -0
- data/app/assets/stylesheets/spree/backend/components/_image_placeholder.scss +2 -2
- data/app/assets/stylesheets/spree/backend/components/_list_group.scss +2 -2
- data/app/assets/stylesheets/spree/backend/components/_messages.scss +20 -12
- data/app/assets/stylesheets/spree/backend/components/_navigation.scss +45 -11
- data/app/assets/stylesheets/spree/backend/components/_progress.scss +3 -3
- data/app/assets/stylesheets/spree/backend/components/_sidebar.scss +1 -2
- data/app/assets/stylesheets/spree/backend/components/_tabs.scss +14 -13
- data/app/assets/stylesheets/spree/backend/globals/_deprecated_variables.scss +24 -0
- data/app/assets/stylesheets/spree/backend/globals/_deprecation.scss +10 -1
- data/app/assets/stylesheets/spree/backend/globals/_functions.scss +2 -0
- data/app/assets/stylesheets/spree/backend/globals/_variables.scss +88 -57
- data/app/assets/stylesheets/spree/backend/globals/_variables_override.scss +1 -0
- data/app/assets/stylesheets/spree/backend/globals/mixins/_caret.scss +1 -1
- data/app/assets/stylesheets/spree/backend/globals/mixins/_line_through.scss +1 -1
- data/app/assets/stylesheets/spree/backend/sections/_log_entries.scss +8 -2
- data/app/assets/stylesheets/spree/backend/sections/_orders.scss +25 -6
- data/app/assets/stylesheets/spree/backend/sections/_products.scss +3 -1
- data/app/assets/stylesheets/spree/backend/sections/_promotions.scss +5 -5
- data/app/assets/stylesheets/spree/backend/sections/_stock_management.scss +77 -2
- data/app/assets/stylesheets/spree/backend/sections/_style_guide.scss +4 -4
- data/app/assets/stylesheets/spree/backend/sections/_taxonomies.scss +1 -1
- data/app/assets/stylesheets/spree/backend/shared/_fonts.scss +15 -0
- data/app/assets/stylesheets/spree/backend/shared/_forms.scss +27 -7
- data/app/assets/stylesheets/spree/backend/shared/_header.scss +2 -2
- data/app/assets/stylesheets/spree/backend/shared/_icons.scss +5 -1
- data/app/assets/stylesheets/spree/backend/shared/_layout.scss +5 -4
- data/app/assets/stylesheets/spree/backend/shared/_tables.scss +11 -6
- data/app/assets/stylesheets/spree/backend/shared/_typography.scss +10 -6
- data/app/assets/stylesheets/spree/backend/spree_admin.scss +3 -1
- data/app/controllers/spree/admin/cancellations_controller.rb +2 -2
- data/app/controllers/spree/admin/customer_returns_controller.rb +8 -1
- data/app/controllers/spree/admin/locale_controller.rb +1 -1
- data/app/controllers/spree/admin/log_entries_controller.rb +3 -0
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +8 -1
- data/app/controllers/spree/admin/orders_controller.rb +1 -12
- data/app/controllers/spree/admin/products_controller.rb +10 -6
- data/app/controllers/spree/admin/promotion_codes_controller.rb +19 -1
- data/app/controllers/spree/admin/promotions_controller.rb +1 -1
- data/app/controllers/spree/admin/reimbursements_controller.rb +7 -2
- data/app/controllers/spree/admin/resource_controller.rb +1 -0
- data/app/controllers/spree/admin/store_credit_reasons_controller.rb +8 -0
- data/app/controllers/spree/admin/store_credits_controller.rb +11 -11
- data/app/controllers/spree/admin/users_controller.rb +4 -2
- data/app/helpers/spree/admin/base_helper.rb +9 -3
- data/app/helpers/spree/admin/navigation_helper.rb +1 -1
- data/app/helpers/spree/admin/promotions_helper.rb +15 -0
- data/app/models/spree/backend_configuration.rb +38 -21
- data/app/views/spree/admin/cancellations/index.html.erb +3 -1
- data/app/views/spree/admin/images/_image_row.html.erb +1 -1
- data/app/views/spree/admin/images/edit.html.erb +3 -3
- data/app/views/spree/admin/images/index.html.erb +3 -3
- data/app/views/spree/admin/log_entries/index.html.erb +1 -19
- data/app/views/spree/admin/option_types/edit.html.erb +1 -1
- data/app/views/spree/admin/orders/_carton_manifest.html.erb +3 -1
- data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +1 -1
- data/app/views/spree/admin/orders/_shipment_manifest.html.erb +3 -1
- data/app/views/spree/admin/orders/confirm/_line_items.html.erb +3 -2
- data/app/views/spree/admin/orders/confirm/_shipment_manifest.html.erb +3 -1
- data/app/views/spree/admin/orders/index.html.erb +1 -1
- data/app/views/spree/admin/payments/_capture_events.html.erb +15 -18
- data/app/views/spree/admin/payments/_list.html.erb +1 -1
- data/app/views/spree/admin/payments/_log_entries.html.erb +29 -0
- data/app/views/spree/admin/payments/show.html.erb +13 -6
- data/app/views/spree/admin/payments/source_forms/{_storecredit.html.erb → _store_credit.html.erb} +0 -0
- data/app/views/spree/admin/payments/source_views/{_storecredit.html.erb → _store_credit.html.erb} +0 -0
- data/app/views/spree/admin/prices/_form.html.erb +1 -1
- data/app/views/spree/admin/product_properties/index.html.erb +1 -1
- data/app/views/spree/admin/products/_form.html.erb +23 -12
- data/app/views/spree/admin/products/edit.html.erb +5 -0
- data/app/views/spree/admin/products/index.html.erb +3 -1
- data/app/views/spree/admin/promotion_categories/index.html.erb +1 -1
- data/app/views/spree/admin/promotion_code_batches/index.html.erb +1 -1
- data/app/views/spree/admin/promotion_codes/index.html.erb +5 -1
- data/app/views/spree/admin/promotion_codes/new.html.erb +31 -0
- data/app/views/spree/admin/promotions/_actions.html.erb +1 -1
- data/app/views/spree/admin/promotions/_activations_edit.html.erb +1 -1
- data/app/views/spree/admin/promotions/_form.html.erb +6 -5
- data/app/views/spree/admin/promotions/_rules.html.erb +1 -1
- data/app/views/spree/admin/promotions/edit.html.erb +3 -1
- data/app/views/spree/admin/promotions/index.html.erb +4 -4
- data/app/views/spree/admin/refunds/new.html.erb +1 -1
- data/app/views/spree/admin/reimbursements/edit.html.erb +2 -2
- data/app/views/spree/admin/shared/_address_form.html.erb +10 -3
- data/app/views/spree/admin/shared/_edit_resource_links.html.erb +1 -1
- data/app/views/spree/admin/shared/_head.html.erb +1 -3
- data/app/views/spree/admin/shared/_image.html.erb +2 -2
- data/app/views/spree/admin/shared/_modal.html.erb +1 -1
- data/app/views/spree/admin/shared/_product_sub_menu.html.erb +1 -1
- data/app/views/spree/admin/shared/_settings_checkout_tabs.html.erb +4 -0
- data/app/views/spree/admin/shared/_settings_sub_menu.html.erb +3 -3
- data/app/views/spree/admin/shared/_tabs.html.erb +3 -2
- data/app/views/spree/admin/shared/_variant_search.html.erb +1 -1
- data/app/views/spree/admin/shipping_methods/_form.html.erb +10 -10
- data/app/views/spree/admin/stock_items/_stock_management.html.erb +56 -38
- data/app/views/spree/admin/stock_locations/_form.html.erb +133 -121
- data/app/views/spree/admin/stock_locations/edit.html.erb +4 -2
- data/app/views/spree/admin/store_credit_reasons/edit.html.erb +15 -0
- data/app/views/spree/admin/store_credit_reasons/index.html.erb +56 -0
- data/app/views/spree/admin/store_credit_reasons/new.html.erb +18 -0
- data/app/views/spree/admin/store_credit_reasons/shared/_form.html.erb +15 -0
- data/app/views/spree/admin/store_credits/_store_credit_reason_field.html.erb +7 -0
- data/app/views/spree/admin/store_credits/edit_amount.html.erb +1 -1
- data/app/views/spree/admin/store_credits/edit_validity.html.erb +2 -2
- data/app/views/spree/admin/store_credits/index.html.erb +1 -1
- data/app/views/spree/admin/store_credits/show.html.erb +3 -3
- data/app/views/spree/admin/stores/_form.html.erb +1 -0
- data/app/views/spree/admin/style_guide/topics/typography/_colors.html.erb +30 -20
- data/app/views/spree/admin/style_guide/topics/typography/_fonts.html.erb +1 -1
- data/app/views/spree/admin/taxonomies/edit.html.erb +1 -1
- data/app/views/spree/admin/taxons/_form.html.erb +1 -1
- data/app/views/spree/admin/taxons/edit.html.erb +2 -2
- data/app/views/spree/admin/users/edit.html.erb +2 -2
- data/app/views/spree/admin/users/index.html.erb +2 -2
- data/app/views/spree/admin/users/items.html.erb +3 -1
- data/app/views/spree/admin/users/orders.html.erb +1 -1
- data/app/views/spree/admin/variants/_form.html.erb +1 -1
- data/app/views/spree/admin/variants/index.html.erb +1 -1
- data/app/views/spree/admin/zones/_state_members.html.erb +1 -1
- data/config/routes.rb +2 -8
- data/lib/spree/backend.rb +1 -1
- data/solidus_backend.gemspec +3 -4
- data/spec/controllers/spree/admin/base_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/cancellations_controller_spec.rb +7 -3
- data/spec/controllers/spree/admin/locale_controller_spec.rb +45 -0
- data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +50 -2
- data/spec/controllers/spree/admin/orders_controller_spec.rb +25 -13
- data/spec/controllers/spree/admin/payments_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/products_controller_spec.rb +72 -0
- data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +13 -1
- data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +11 -0
- data/spec/controllers/spree/admin/resource_controller_spec.rb +22 -0
- data/spec/controllers/spree/admin/stock_items_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/store_credits_controller_spec.rb +7 -7
- data/spec/features/admin/configuration/payment_methods_spec.rb +2 -2
- data/spec/features/admin/configuration/shipping_methods_spec.rb +2 -2
- data/spec/features/admin/homepage_spec.rb +1 -6
- data/spec/features/admin/locale_spec.rb +1 -2
- data/spec/features/admin/orders/adjustments_spec.rb +1 -1
- data/spec/features/admin/orders/customer_details_spec.rb +5 -7
- data/spec/features/admin/orders/customer_returns_spec.rb +28 -0
- data/spec/features/admin/orders/listing_spec.rb +2 -7
- data/spec/features/admin/orders/log_entries_spec.rb +2 -2
- data/spec/features/admin/orders/new_order_spec.rb +117 -0
- data/spec/features/admin/orders/new_refund_spec.rb +35 -0
- data/spec/features/admin/orders/order_details_spec.rb +10 -5
- data/spec/features/admin/orders/payments_spec.rb +82 -41
- data/spec/features/admin/orders/return_payment_state_spec.rb +3 -0
- data/spec/features/admin/orders/shipments_spec.rb +28 -0
- data/spec/features/admin/products/edit/products_spec.rb +25 -0
- data/spec/features/admin/products/edit/taxons_spec.rb +4 -0
- data/spec/features/admin/products/pricing_spec.rb +24 -6
- data/spec/features/admin/products/products_spec.rb +5 -5
- data/spec/features/admin/products/stock_management_spec.rb +27 -13
- data/spec/features/admin/products/variant_spec.rb +1 -1
- data/spec/features/admin/promotion_adjustments_spec.rb +12 -12
- data/spec/features/admin/promotions/option_value_rule_spec.rb +2 -2
- data/spec/features/admin/promotions/product_rule_spec.rb +1 -1
- data/spec/features/admin/promotions/promotion_spec.rb +52 -0
- data/spec/features/admin/promotions/tiered_calculator_spec.rb +1 -1
- data/spec/features/admin/promotions/user_rule_spec.rb +2 -2
- data/spec/features/admin/reimbursements_spec.rb +1 -1
- data/spec/features/admin/store_credits_spec.rb +51 -2
- data/spec/features/admin/taxons_spec.rb +35 -0
- data/spec/features/admin/users_spec.rb +44 -11
- data/spec/helpers/admin/navigation_helper_spec.rb +4 -2
- data/spec/helpers/admin/store_credit_events_helper_spec.rb +2 -2
- data/spec/javascripts/spec_helper.js +2 -0
- data/spec/models/spree/backend_configuration/menu_item_spec.rb +17 -0
- data/spec/models/spree/backend_configuration_spec.rb +22 -0
- data/spec/spec_helper.rb +2 -2
- data/spec/support/appear_before_matcher.rb +1 -1
- data/spec/support/feature/order_feature_helper.rb +1 -1
- data/spec/views/spree/admin/shared/navigation_footer_spec.rb +1 -1
- data/vendor/assets/fonts/inter/Inter-Regular.woff +0 -0
- data/vendor/assets/fonts/inter/Inter-Regular.woff2 +0 -0
- data/vendor/assets/fonts/inter/Inter-SemiBold.woff +0 -0
- data/vendor/assets/fonts/inter/Inter-SemiBold.woff2 +0 -0
- data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_en-US.js +10 -0
- data/vendor/assets/stylesheets/solidus_admin/bootstrap/_pagination.scss +4 -0
- metadata +38 -36
- data/.eslintrc +0 -21
- data/app/controllers/spree/admin/reports_controller.rb +0 -82
- data/app/views/spree/admin/reports/index.html.erb +0 -19
- data/app/views/spree/admin/reports/sales_total.html.erb +0 -35
- data/app/views/spree/admin/shared/_report_order_criteria.html.erb +0 -19
- data/app/views/spree/admin/store_credits/_update_reason_field.html.erb +0 -7
- data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -133
- data/spec/features/admin/reports_spec.rb +0 -63
data/solidus_backend.gemspec
CHANGED
@@ -26,12 +26,11 @@ Gem::Specification.new do |s|
|
|
26
26
|
|
27
27
|
s.add_dependency 'coffee-rails'
|
28
28
|
s.add_dependency 'font-awesome-rails', '~> 4.0'
|
29
|
-
s.add_dependency 'jbuilder', '~> 2.
|
29
|
+
s.add_dependency 'jbuilder', '~> 2.8'
|
30
30
|
s.add_dependency 'jquery-rails'
|
31
31
|
s.add_dependency 'kaminari', '~> 1.1'
|
32
|
-
s.add_dependency '
|
33
|
-
s.add_dependency 'sass', '>= 3.5.2'
|
32
|
+
s.add_dependency 'sassc-rails'
|
34
33
|
|
35
|
-
s.add_dependency 'autoprefixer-rails'
|
34
|
+
s.add_dependency 'autoprefixer-rails'
|
36
35
|
s.add_dependency 'handlebars_assets', '~> 0.23'
|
37
36
|
end
|
@@ -15,7 +15,7 @@ describe Spree::Admin::BaseController, type: :controller do
|
|
15
15
|
|
16
16
|
context "unauthorized request" do
|
17
17
|
before do
|
18
|
-
allow_any_instance_of(Spree::Admin::BaseController).to receive(:
|
18
|
+
allow_any_instance_of(Spree::Admin::BaseController).to receive(:try_spree_current_user).and_return(nil)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "redirects to unauthorized" do
|
@@ -22,7 +22,7 @@ describe Spree::Admin::CancellationsController do
|
|
22
22
|
describe "#cancel" do
|
23
23
|
subject { post :short_ship, params: { order_id: order.number, inventory_unit_ids: inventory_units.map(&:id) } }
|
24
24
|
|
25
|
-
let(:order) { create(:
|
25
|
+
let(:order) { create(:order_with_line_items, line_items_attributes: [{ quantity: 4 }]) }
|
26
26
|
let(:referer) { "order_admin_page" }
|
27
27
|
|
28
28
|
context "no inventory unit ids are provided" do
|
@@ -67,12 +67,16 @@ describe Spree::Admin::CancellationsController do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
it "creates a unit cancel" do
|
70
|
-
expect { subject }.to change { Spree::UnitCancel.count }.by(
|
70
|
+
expect { subject }.to change { Spree::UnitCancel.count }.by(4)
|
71
71
|
end
|
72
72
|
|
73
73
|
it "cancels the inventory" do
|
74
74
|
subject
|
75
|
-
expect(order.inventory_units.map(&:state).uniq).to match_array(['canceled'])
|
75
|
+
expect(order.reload.inventory_units.map(&:state).uniq).to match_array(['canceled'])
|
76
|
+
end
|
77
|
+
|
78
|
+
it "adjusts the order" do
|
79
|
+
expect { subject }.to change { order.reload.total }.by(-40.0)
|
76
80
|
end
|
77
81
|
end
|
78
82
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.describe Spree::Admin::LocaleController, type: :controller do
|
6
|
+
stub_authorization!
|
7
|
+
|
8
|
+
before { I18n.backend.store_translations(:fr, {}) }
|
9
|
+
|
10
|
+
after do
|
11
|
+
I18n.locale = :en
|
12
|
+
I18n.reload!
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'switch_to_locale specified' do
|
16
|
+
let(:json_response) { JSON.parse(response.body, symbolize_names: true) }
|
17
|
+
|
18
|
+
before do
|
19
|
+
get :set, params: { switch_to_locale: switch_to_locale, format: :json }
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'available locale' do
|
23
|
+
let(:switch_to_locale) { 'fr' }
|
24
|
+
|
25
|
+
it 'sets locale and returns the location for the redirect' do
|
26
|
+
expect(I18n.locale).to eq :fr
|
27
|
+
expect(session[:admin_locale]).to eq(switch_to_locale)
|
28
|
+
expect(json_response).
|
29
|
+
to eq({ locale: switch_to_locale,
|
30
|
+
location: spree.admin_url(host: 'test.host') })
|
31
|
+
expect(response).to have_http_status(:ok)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'unavailable locale' do
|
36
|
+
let(:switch_to_locale) { 'klingon' }
|
37
|
+
|
38
|
+
it 'does not change locale and returns 404' do
|
39
|
+
expect(I18n.locale).to eq :en
|
40
|
+
expect(json_response).to eq({ locale: 'en', })
|
41
|
+
expect(response).to have_http_status(:not_found)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -7,11 +7,59 @@ describe Spree::Admin::Orders::CustomerDetailsController, type: :controller do
|
|
7
7
|
context "with authorization" do
|
8
8
|
stub_authorization!
|
9
9
|
|
10
|
-
|
10
|
+
context '#edit' do
|
11
|
+
context 'when order has no shipping nor billing address' do
|
12
|
+
let(:order) { create(:order, number: "R123456789", ship_address: nil, bill_address: nil) }
|
11
13
|
|
12
|
-
|
14
|
+
context "with a checkout_zone set as the country of Canada" do
|
15
|
+
let!(:united_states) { create(:country, iso: 'US', states_required: true) }
|
16
|
+
let!(:canada) { create(:country, iso: 'CA', states_required: true) }
|
17
|
+
let!(:checkout_zone) { create(:zone, name: "Checkout Zone", countries: [canada]) }
|
18
|
+
|
19
|
+
before do
|
20
|
+
stub_spree_preferences(checkout_zone: checkout_zone.name)
|
21
|
+
end
|
22
|
+
|
23
|
+
context "and default_country_iso of the Canada" do
|
24
|
+
before do
|
25
|
+
stub_spree_preferences(default_country_iso: Spree::Country.find_by!(iso: "CA").iso)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'defaults the shipping address country to Canada' do
|
29
|
+
get :edit, params: { order_id: order.number }
|
30
|
+
expect(assigns(:order).shipping_address.country_id).to eq canada.id
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'defaults the billing address country to Canada' do
|
34
|
+
get :edit, params: { order_id: order.number }
|
35
|
+
expect(assigns(:order).billing_address.country_id).to eq canada.id
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "and default_country_iso of the United States" do
|
40
|
+
before do
|
41
|
+
stub_spree_preferences(default_country_iso: Spree::Country.find_by!(iso: "US").iso)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'defaults the shipping address country to nil' do
|
45
|
+
get :edit, params: { order_id: order.number }
|
46
|
+
expect(assigns(:order).shipping_address.country_id).to be_nil
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'defaults the billing address country to nil' do
|
50
|
+
get :edit, params: { order_id: order.number }
|
51
|
+
expect(assigns(:order).billing_address.country_id).to be_nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
13
57
|
|
14
58
|
context "#update" do
|
59
|
+
let(:order) { create(:order, number: "R123456789") }
|
60
|
+
|
61
|
+
before { allow(Spree::Order).to receive_message_chain(:includes, :find_by!) { order } }
|
62
|
+
|
15
63
|
it "updates + progresses the order" do
|
16
64
|
expect(order).to receive(:update_attributes) { true }
|
17
65
|
expect(order).to receive(:next) { false }
|
@@ -69,7 +69,7 @@ describe Spree::Admin::OrdersController, type: :controller do
|
|
69
69
|
it "can page through the orders" do
|
70
70
|
get :index, params: { page: 2, per_page: 10 }
|
71
71
|
expect(assigns[:orders].offset_value).to eq(10)
|
72
|
-
expect(assigns[:orders].
|
72
|
+
expect(assigns[:orders].limit_value).to eq(10)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -77,7 +77,7 @@ describe Spree::Admin::OrdersController, type: :controller do
|
|
77
77
|
context "#new" do
|
78
78
|
let(:user) { create(:user) }
|
79
79
|
before do
|
80
|
-
allow(controller).to receive_messages
|
80
|
+
allow(controller).to receive_messages try_spree_current_user: user
|
81
81
|
end
|
82
82
|
|
83
83
|
it "imports a new order and sets the current user as a creator" do
|
@@ -140,7 +140,7 @@ describe Spree::Admin::OrdersController, type: :controller do
|
|
140
140
|
end
|
141
141
|
|
142
142
|
context 'when order_bill_address_used is true' do
|
143
|
-
before {
|
143
|
+
before { stub_spree_preferences(order_bill_address_used: true) }
|
144
144
|
|
145
145
|
it "should redirect to the customer details page" do
|
146
146
|
get :edit, params: { id: order.number }
|
@@ -149,7 +149,7 @@ describe Spree::Admin::OrdersController, type: :controller do
|
|
149
149
|
end
|
150
150
|
|
151
151
|
context 'when order_bill_address_used is false' do
|
152
|
-
before {
|
152
|
+
before { stub_spree_preferences(order_bill_address_used: false) }
|
153
153
|
|
154
154
|
it "should redirect to the customer details page" do
|
155
155
|
get :edit, params: { id: order.number }
|
@@ -288,18 +288,30 @@ describe Spree::Admin::OrdersController, type: :controller do
|
|
288
288
|
let(:user) { create(:user) }
|
289
289
|
|
290
290
|
before do
|
291
|
-
allow(controller).to receive_messages
|
291
|
+
allow(controller).to receive_messages try_spree_current_user: user
|
292
292
|
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
293
293
|
|
294
|
-
|
295
|
-
expect(Spree::Order.count).to eq
|
294
|
+
create_list(:completed_order_with_totals, 2)
|
295
|
+
expect(Spree::Order.count).to eq 2
|
296
296
|
end
|
297
297
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
298
|
+
context 'by line_items_variant_id_in' do
|
299
|
+
it "does not display duplicated results" do
|
300
|
+
get :index, params: { q: {
|
301
|
+
line_items_variant_id_in: Spree::Order.first.variants.map(&:id)
|
302
|
+
} }
|
303
|
+
expect(assigns[:orders].size).to eq 1
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
context 'by email' do
|
308
|
+
it "does not display duplicated results" do
|
309
|
+
get :index, params: { q: {
|
310
|
+
email_start: Spree::Order.first.email
|
311
|
+
} }
|
312
|
+
expect(assigns[:orders].size).to eq 1
|
313
|
+
expect(assigns[:orders][0].email).to eq(Spree::Order.first.email)
|
314
|
+
end
|
303
315
|
end
|
304
316
|
end
|
305
317
|
|
@@ -349,7 +361,7 @@ describe Spree::Admin::OrdersController, type: :controller do
|
|
349
361
|
let!(:order) { create(:completed_order_with_totals, number: 'R987654321') }
|
350
362
|
|
351
363
|
before do
|
352
|
-
allow(controller).to receive_messages
|
364
|
+
allow(controller).to receive_messages try_spree_current_user: user
|
353
365
|
end
|
354
366
|
|
355
367
|
it 'should grant access to users with an admin role' do
|
@@ -6,7 +6,7 @@ module Spree
|
|
6
6
|
module Admin
|
7
7
|
describe PaymentsController, type: :controller do
|
8
8
|
before do
|
9
|
-
allow(controller).to receive_messages
|
9
|
+
allow(controller).to receive_messages try_spree_current_user: user
|
10
10
|
end
|
11
11
|
|
12
12
|
let(:user) { create(:admin_user) }
|
@@ -50,6 +50,78 @@ describe Spree::Admin::ProductsController, type: :controller do
|
|
50
50
|
end
|
51
51
|
end
|
52
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
|
+
|
53
125
|
describe "creating variant property rules" do
|
54
126
|
let(:first_property) { create(:property) }
|
55
127
|
let(:second_property) { create(:property) }
|
@@ -11,10 +11,22 @@ describe Spree::Admin::PromotionCodesController do
|
|
11
11
|
let!(:code2) { create(:promotion_code, promotion: promotion) }
|
12
12
|
let!(:code3) { create(:promotion_code, promotion: promotion) }
|
13
13
|
|
14
|
-
it "can create a
|
14
|
+
it "can create a CSV file with all promotion codes" do
|
15
15
|
get :index, params: { promotion_id: promotion.id, format: 'csv' }
|
16
16
|
expect(response).to be_successful
|
17
17
|
parsed = CSV.parse(response.body, headers: true)
|
18
18
|
expect(parsed.entries.map(&:to_h)).to eq([{ "Code" => code1.value }, { "Code" => code2.value }, { "Code" => code3.value }])
|
19
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
|
20
32
|
end
|
@@ -9,6 +9,13 @@ describe Spree::Admin::ReimbursementsController, type: :controller do
|
|
9
9
|
Spree::RefundReason.find_or_create_by!(name: Spree::RefundReason::RETURN_PROCESSING_REASON, mutable: false)
|
10
10
|
end
|
11
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
|
+
|
12
19
|
describe '#edit' do
|
13
20
|
let(:reimbursement) { create(:reimbursement) }
|
14
21
|
let(:order) { reimbursement.order }
|
@@ -42,6 +49,10 @@ describe Spree::Admin::ReimbursementsController, type: :controller do
|
|
42
49
|
expect(assigns(:reimbursement).return_items.to_a).to eq customer_return.return_items.to_a
|
43
50
|
end
|
44
51
|
|
52
|
+
it 'order is recalculated' do
|
53
|
+
expect { subject }.to change { order.reload.payment_state }.from('paid').to('credit_owed')
|
54
|
+
end
|
55
|
+
|
45
56
|
it 'redirects to the edit page' do
|
46
57
|
subject
|
47
58
|
expect(response).to redirect_to(spree.edit_admin_order_reimbursement_path(order, assigns(:reimbursement)))
|
@@ -32,6 +32,13 @@ describe Spree::Admin::WidgetsController, type: :controller do
|
|
32
32
|
model do
|
33
33
|
acts_as_list
|
34
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
|
35
42
|
end
|
36
43
|
end
|
37
44
|
|
@@ -146,6 +153,21 @@ describe Spree::Admin::WidgetsController, type: :controller do
|
|
146
153
|
it 'destroys the resource' do
|
147
154
|
expect { subject }.to change { Widget.count }.from(1).to(0)
|
148
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
|
149
171
|
end
|
150
172
|
|
151
173
|
describe '#update_positions' do
|
@@ -13,7 +13,7 @@ module Spree
|
|
13
13
|
let(:stock_item) { variant.stock_items.first }
|
14
14
|
let!(:user) { create :user }
|
15
15
|
|
16
|
-
before { expect(controller).to receive(:
|
16
|
+
before { expect(controller).to receive(:try_spree_current_user).and_return(user) }
|
17
17
|
before { request.env["HTTP_REFERER"] = "product_admin_page" }
|
18
18
|
|
19
19
|
subject do
|
@@ -3,8 +3,8 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
shared_examples "update reason loader" do
|
6
|
-
it "sets the
|
7
|
-
expect(assigns(:
|
6
|
+
it "sets the store_credit_reasons variable to a list of categories sorted by category name " do
|
7
|
+
expect(assigns(:store_credit_reasons)).to eq [store_credit_reason]
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
@@ -16,11 +16,11 @@ describe Spree::Admin::StoreCreditsController do
|
|
16
16
|
|
17
17
|
let!(:b_credit_category) { create(:store_credit_category, name: "B category") }
|
18
18
|
let!(:a_credit_category) { create(:store_credit_category, name: "A category") }
|
19
|
-
let!(:
|
19
|
+
let!(:store_credit_reason) { create(:store_credit_reason) }
|
20
20
|
|
21
21
|
describe "#show" do
|
22
22
|
let!(:store_credit) { create(:store_credit, user: user, category: a_credit_category) }
|
23
|
-
let!(:event)
|
23
|
+
let!(:event) { create(:store_credit_auth_event, store_credit: store_credit, created_at: 5.days.ago) }
|
24
24
|
|
25
25
|
before { get :show, params: { user_id: user.id, id: store_credit.id } }
|
26
26
|
|
@@ -173,12 +173,12 @@ describe Spree::Admin::StoreCreditsController do
|
|
173
173
|
describe "#update_amount" do
|
174
174
|
let(:original_amount) { 100.0 }
|
175
175
|
let!(:store_credit) { create(:store_credit, user: user, amount: original_amount) }
|
176
|
-
let!(:
|
176
|
+
let!(:store_credit_reason) { create(:store_credit_reason) }
|
177
177
|
let(:parameters) do
|
178
178
|
{
|
179
179
|
user_id: user.id,
|
180
180
|
id: store_credit.id,
|
181
|
-
|
181
|
+
store_credit_reason_id: store_credit_reason.id,
|
182
182
|
store_credit: {
|
183
183
|
amount: updated_amount
|
184
184
|
}
|
@@ -271,7 +271,7 @@ describe Spree::Admin::StoreCreditsController do
|
|
271
271
|
{
|
272
272
|
user_id: user.id,
|
273
273
|
id: store_credit.id,
|
274
|
-
|
274
|
+
store_credit_reason_id: store_credit_reason.id
|
275
275
|
}
|
276
276
|
end
|
277
277
|
|