solidus_backend 1.3.2 → 1.4.0.beta1
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 +38 -0
- data/app/assets/javascripts/spree/backend/components/tooltips.js +2 -0
- data/app/assets/javascripts/spree/backend/product_picker.js +2 -2
- data/app/assets/javascripts/spree/backend/routes.js +0 -1
- data/app/assets/javascripts/spree/backend/shipments.js +147 -118
- data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +16 -14
- data/app/assets/javascripts/spree/backend/templates/orders/customer_details/autocomplete.hbs +1 -1
- data/app/assets/javascripts/spree/backend/templates/variants/autocomplete.hbs.erb +1 -1
- data/app/assets/javascripts/spree/backend/templates/variants/line_items_autocomplete_stock.hbs +1 -1
- data/app/assets/javascripts/spree/backend/templates/variants/split.hbs +25 -27
- data/app/assets/javascripts/spree/backend/user_picker.js +14 -8
- data/app/assets/stylesheets/spree/backend/_bootstrap_custom.scss +3 -3
- data/app/assets/stylesheets/spree/backend/components/_breadcrumb.scss +4 -0
- data/app/assets/stylesheets/spree/backend/components/_date-picker.scss +0 -1
- data/app/assets/stylesheets/spree/backend/components/_hint.scss +3 -0
- data/app/assets/stylesheets/spree/backend/components/_navigation.scss +0 -1
- data/app/assets/stylesheets/spree/backend/components/_progress.scss +5 -2
- data/app/assets/stylesheets/spree/backend/components/_sidebar.scss +14 -5
- data/app/assets/stylesheets/spree/backend/components/_states.scss +1 -2
- data/app/assets/stylesheets/spree/backend/globals/_mixins.css +2 -0
- data/app/assets/stylesheets/spree/backend/globals/mixins/_line_through.scss +22 -0
- data/app/assets/stylesheets/spree/backend/plugins/_select2.scss +12 -3
- data/app/assets/stylesheets/spree/backend/sections/_products.scss +25 -7
- data/app/assets/stylesheets/spree/backend/sections/_promotions.scss +0 -1
- data/app/assets/stylesheets/spree/backend/sections/_transfer_items.scss +0 -1
- data/app/assets/stylesheets/spree/backend/shared/_forms.scss +4 -6
- data/app/assets/stylesheets/spree/backend/shared/_header.scss +5 -2
- data/app/assets/stylesheets/spree/backend/shared/_layout.scss +36 -3
- data/app/assets/stylesheets/spree/backend/shared/_tables.scss +1 -3
- data/app/assets/stylesheets/spree/backend/shared/_typography.scss +0 -2
- data/app/assets/stylesheets/spree/backend/spree_admin.scss +3 -1
- data/app/controllers/spree/admin/cancellations_controller.rb +1 -1
- data/app/controllers/spree/admin/general_settings_controller.rb +0 -6
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +7 -0
- data/app/controllers/spree/admin/orders_controller.rb +1 -1
- data/app/controllers/spree/admin/payment_methods_controller.rb +8 -3
- data/app/controllers/spree/admin/payments_controller.rb +12 -5
- data/app/controllers/spree/admin/products_controller.rb +1 -1
- data/app/controllers/spree/admin/refunds_controller.rb +1 -1
- data/app/controllers/spree/admin/reimbursements_controller.rb +1 -1
- data/app/controllers/spree/admin/root_controller.rb +1 -1
- data/app/controllers/spree/admin/stock_items_controller.rb +0 -8
- data/app/controllers/spree/admin/stock_transfers_controller.rb +6 -6
- data/app/controllers/spree/admin/users_controller.rb +7 -3
- data/app/helpers/spree/admin/base_helper.rb +11 -0
- data/app/helpers/spree/admin/navigation_helper.rb +46 -3
- data/app/helpers/spree/admin/orders_helper.rb +0 -1
- data/app/helpers/spree/admin/stock_locations_helper.rb +1 -5
- data/app/models/spree/backend_configuration.rb +100 -0
- data/app/views/spree/admin/adjustment_reasons/edit.html.erb +4 -7
- data/app/views/spree/admin/adjustment_reasons/index.html.erb +4 -4
- data/app/views/spree/admin/adjustment_reasons/new.html.erb +4 -4
- data/app/views/spree/admin/adjustments/edit.html.erb +4 -6
- data/app/views/spree/admin/adjustments/index.html.erb +3 -6
- data/app/views/spree/admin/adjustments/new.html.erb +5 -6
- data/app/views/spree/admin/cancellations/index.html.erb +4 -3
- data/app/views/spree/admin/countries/edit.html.erb +4 -6
- data/app/views/spree/admin/countries/index.html.erb +4 -4
- data/app/views/spree/admin/countries/new.html.erb +4 -4
- data/app/views/spree/admin/customer_returns/_return_item_decision.html.erb +1 -1
- data/app/views/spree/admin/customer_returns/edit.html.erb +4 -6
- data/app/views/spree/admin/customer_returns/index.html.erb +2 -5
- data/app/views/spree/admin/customer_returns/new.html.erb +5 -6
- data/app/views/spree/admin/general_settings/edit.html.erb +4 -28
- data/app/views/spree/admin/images/edit.html.erb +6 -2
- data/app/views/spree/admin/images/index.html.erb +3 -0
- data/app/views/spree/admin/images/new.html.erb +3 -3
- data/app/views/spree/admin/log_entries/index.html.erb +4 -8
- data/app/views/spree/admin/option_types/edit.html.erb +7 -9
- data/app/views/spree/admin/option_types/index.html.erb +4 -4
- data/app/views/spree/admin/orders/_shipment.html.erb +4 -1
- data/app/views/spree/admin/orders/_shipment_manifest.html.erb +4 -1
- data/app/views/spree/admin/orders/cart.html.erb +4 -8
- data/app/views/spree/admin/orders/confirm.html.erb +3 -4
- data/app/views/spree/admin/orders/confirm/_payments.html.erb +1 -1
- data/app/views/spree/admin/orders/confirm_advance.html.erb +3 -4
- data/app/views/spree/admin/orders/customer_details/_form.html.erb +1 -1
- data/app/views/spree/admin/orders/customer_details/edit.html.erb +2 -4
- data/app/views/spree/admin/orders/customer_details/show.html.erb +3 -5
- data/app/views/spree/admin/orders/edit.html.erb +1 -8
- data/app/views/spree/admin/orders/index.html.erb +11 -5
- data/app/views/spree/admin/payment_methods/edit.html.erb +5 -7
- data/app/views/spree/admin/payment_methods/index.html.erb +6 -5
- data/app/views/spree/admin/payment_methods/new.html.erb +6 -7
- data/app/views/spree/admin/payments/_capture_events.html.erb +1 -1
- data/app/views/spree/admin/payments/credit.html.erb +3 -3
- data/app/views/spree/admin/payments/index.html.erb +4 -7
- data/app/views/spree/admin/payments/new.html.erb +4 -5
- data/app/views/spree/admin/payments/show.html.erb +4 -7
- data/app/views/spree/admin/prices/_form.html.erb +1 -0
- data/app/views/spree/admin/prices/index.html.erb +2 -2
- data/app/views/spree/admin/product_properties/index.html.erb +3 -1
- data/app/views/spree/admin/products/_form.html.erb +11 -18
- data/app/views/spree/admin/products/_properties_form.erb +1 -1
- data/app/views/spree/admin/products/edit.html.erb +3 -2
- data/app/views/spree/admin/products/index.html.erb +19 -28
- data/app/views/spree/admin/products/new.html.erb +4 -2
- data/app/views/spree/admin/promotion_categories/edit.html.erb +4 -3
- data/app/views/spree/admin/promotion_categories/index.html.erb +4 -4
- data/app/views/spree/admin/promotion_categories/new.html.erb +4 -3
- data/app/views/spree/admin/promotion_rules/create.js.erb +1 -1
- data/app/views/spree/admin/promotions/_actions.html.erb +3 -3
- data/app/views/spree/admin/promotions/_rules.html.erb +2 -2
- data/app/views/spree/admin/promotions/calculators/tiered_flat_rate/_fields.html.erb +1 -1
- data/app/views/spree/admin/promotions/calculators/tiered_percent/_fields.html.erb +1 -1
- data/app/views/spree/admin/promotions/edit.html.erb +4 -5
- data/app/views/spree/admin/promotions/index.html.erb +3 -5
- data/app/views/spree/admin/promotions/new.html.erb +3 -3
- data/app/views/spree/admin/promotions/rules/_option_value.html.erb +2 -2
- data/app/views/spree/admin/properties/edit.html.erb +3 -6
- data/app/views/spree/admin/properties/index.html.erb +5 -5
- data/app/views/spree/admin/prototypes/_form.html.erb +3 -3
- data/app/views/spree/admin/prototypes/_prototypes.html.erb +1 -1
- data/app/views/spree/admin/prototypes/edit.html.erb +3 -6
- data/app/views/spree/admin/prototypes/index.html.erb +4 -4
- data/app/views/spree/admin/prototypes/show.html.erb +2 -2
- data/app/views/spree/admin/refund_reasons/edit.html.erb +4 -4
- data/app/views/spree/admin/refund_reasons/index.html.erb +5 -4
- data/app/views/spree/admin/refund_reasons/new.html.erb +5 -4
- data/app/views/spree/admin/refunds/edit.html.erb +5 -6
- data/app/views/spree/admin/refunds/new.html.erb +6 -6
- data/app/views/spree/admin/reimbursement_types/index.html.erb +4 -3
- data/app/views/spree/admin/reimbursements/edit.html.erb +5 -6
- data/app/views/spree/admin/reimbursements/index.html.erb +2 -4
- data/app/views/spree/admin/reimbursements/show.html.erb +3 -4
- data/app/views/spree/admin/reports/index.html.erb +2 -3
- data/app/views/spree/admin/reports/sales_total.html.erb +2 -4
- data/app/views/spree/admin/return_authorizations/edit.html.erb +15 -16
- data/app/views/spree/admin/return_authorizations/index.html.erb +3 -5
- data/app/views/spree/admin/return_authorizations/new.html.erb +5 -6
- data/app/views/spree/admin/return_reasons/edit.html.erb +3 -2
- data/app/views/spree/admin/return_reasons/index.html.erb +3 -1
- data/app/views/spree/admin/return_reasons/new.html.erb +4 -2
- data/app/views/spree/admin/shared/_areas_tabs.html.erb +3 -3
- data/app/views/spree/admin/shared/_configuration_menu.html.erb +2 -2
- data/app/views/spree/admin/shared/_edit_resource_links.html.erb +2 -2
- data/app/views/spree/admin/shared/_head.html.erb +1 -8
- data/app/views/spree/admin/shared/_header.html.erb +8 -12
- data/app/views/spree/admin/shared/_new_resource_links.html.erb +2 -2
- data/app/views/spree/admin/shared/_no_objects_found.html.erb +1 -1
- data/app/views/spree/admin/shared/_order_submenu.html.erb +10 -10
- data/app/views/spree/admin/shared/_order_summary.html.erb +1 -1
- data/app/views/spree/admin/shared/_order_tabs.html.erb +3 -3
- data/app/views/spree/admin/shared/_payments_tabs.html.erb +1 -1
- data/app/views/spree/admin/shared/_product_sub_menu.html.erb +2 -2
- data/app/views/spree/admin/shared/_product_tabs.html.erb +8 -9
- data/app/views/spree/admin/shared/_report_criteria.html.erb +2 -2
- data/app/views/spree/admin/shared/_report_order_criteria.html.erb +2 -2
- data/app/views/spree/admin/shared/_settings_checkout_tabs.html.erb +4 -4
- data/app/views/spree/admin/shared/_settings_sub_menu.html.erb +5 -5
- data/app/views/spree/admin/shared/_shipping_tabs.html.erb +4 -3
- data/app/views/spree/admin/shared/_sidebar.html.erb +1 -1
- data/app/views/spree/admin/shared/_tabs.html.erb +12 -37
- data/app/views/spree/admin/shared/_taxes_tabs.html.erb +2 -2
- data/app/views/spree/admin/shared/_variant_search.html.erb +1 -1
- data/app/views/spree/admin/shared/named_types/_edit.html.erb +5 -5
- data/app/views/spree/admin/shared/named_types/_index.html.erb +5 -4
- data/app/views/spree/admin/shared/named_types/_new.html.erb +5 -4
- data/app/views/spree/admin/shipping_categories/edit.html.erb +5 -6
- data/app/views/spree/admin/shipping_categories/index.html.erb +5 -4
- data/app/views/spree/admin/shipping_categories/new.html.erb +5 -6
- data/app/views/spree/admin/shipping_methods/_form.html.erb +2 -2
- data/app/views/spree/admin/shipping_methods/edit.html.erb +5 -6
- data/app/views/spree/admin/shipping_methods/index.html.erb +5 -5
- data/app/views/spree/admin/shipping_methods/new.html.erb +5 -6
- data/app/views/spree/admin/states/edit.html.erb +5 -6
- data/app/views/spree/admin/states/index.html.erb +5 -4
- data/app/views/spree/admin/states/new.html.erb +5 -3
- data/app/views/spree/admin/stock_items/index.html.erb +4 -7
- data/app/views/spree/admin/stock_locations/_transfer_stock_form.html.erb +2 -2
- data/app/views/spree/admin/stock_locations/edit.html.erb +5 -5
- data/app/views/spree/admin/stock_locations/index.html.erb +16 -9
- data/app/views/spree/admin/stock_locations/new.html.erb +5 -4
- data/app/views/spree/admin/stock_movements/index.html.erb +3 -4
- data/app/views/spree/admin/stock_movements/new.html.erb +2 -3
- data/app/views/spree/admin/stock_transfers/_location.html.erb +7 -0
- data/app/views/spree/admin/stock_transfers/_transfer_item_table.html.erb +1 -1
- data/app/views/spree/admin/stock_transfers/edit.html.erb +5 -6
- data/app/views/spree/admin/stock_transfers/index.html.erb +5 -5
- data/app/views/spree/admin/stock_transfers/new.html.erb +6 -8
- data/app/views/spree/admin/stock_transfers/receive.html.erb +4 -12
- data/app/views/spree/admin/stock_transfers/show.html.erb +6 -12
- data/app/views/spree/admin/stock_transfers/tracking_info.html.erb +5 -13
- data/app/views/spree/admin/store_credits/edit_amount.html.erb +6 -4
- data/app/views/spree/admin/store_credits/edit_validity.html.erb +8 -6
- data/app/views/spree/admin/store_credits/index.html.erb +5 -5
- data/app/views/spree/admin/store_credits/new.html.erb +5 -4
- data/app/views/spree/admin/store_credits/show.html.erb +5 -4
- data/app/views/spree/admin/style_guide/topics/typography/_icons.html.erb +2 -2
- data/app/views/spree/admin/tax_categories/edit.html.erb +5 -4
- data/app/views/spree/admin/tax_categories/index.html.erb +5 -4
- data/app/views/spree/admin/tax_categories/new.html.erb +5 -4
- data/app/views/spree/admin/tax_rates/edit.html.erb +5 -6
- data/app/views/spree/admin/tax_rates/index.html.erb +5 -4
- data/app/views/spree/admin/tax_rates/new.html.erb +5 -6
- data/app/views/spree/admin/taxonomies/edit.erb +7 -9
- data/app/views/spree/admin/taxonomies/index.html.erb +4 -4
- data/app/views/spree/admin/taxonomies/new.html.erb +5 -7
- data/app/views/spree/admin/taxons/edit.html.erb +5 -6
- data/app/views/spree/admin/taxons/index.html.erb +2 -3
- data/app/views/spree/admin/trackers/edit.html.erb +5 -6
- data/app/views/spree/admin/trackers/index.html.erb +4 -4
- data/app/views/spree/admin/trackers/new.html.erb +4 -6
- data/app/views/spree/admin/users/_form.html.erb +2 -2
- data/app/views/spree/admin/users/_tabs.html.erb +5 -5
- data/app/views/spree/admin/users/_user_page_actions.html.erb +1 -4
- data/app/views/spree/admin/users/addresses.html.erb +5 -4
- data/app/views/spree/admin/users/edit.html.erb +6 -6
- data/app/views/spree/admin/users/index.html.erb +4 -5
- data/app/views/spree/admin/users/items.html.erb +4 -3
- data/app/views/spree/admin/users/new.html.erb +2 -9
- data/app/views/spree/admin/users/orders.html.erb +4 -3
- data/app/views/spree/admin/variants/_form.html.erb +1 -0
- data/app/views/spree/admin/variants/edit.html.erb +4 -3
- data/app/views/spree/admin/variants/index.html.erb +10 -8
- data/app/views/spree/admin/variants/new.html.erb +5 -0
- data/app/views/spree/admin/zones/_country_members.html.erb +2 -2
- data/app/views/spree/admin/zones/_state_members.html.erb +2 -2
- data/app/views/spree/admin/zones/edit.html.erb +5 -6
- data/app/views/spree/admin/zones/index.html.erb +5 -4
- data/app/views/spree/admin/zones/new.html.erb +6 -7
- data/app/views/spree/layouts/admin.html.erb +28 -15
- data/config/initializers/form_builder.rb +6 -0
- data/config/routes.rb +2 -6
- data/spec/controllers/spree/admin/cancellations_controller_spec.rb +3 -3
- data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +4 -4
- data/spec/controllers/spree/admin/missing_products_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +5 -5
- data/spec/controllers/spree/admin/orders_controller_spec.rb +28 -28
- data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +5 -5
- data/spec/controllers/spree/admin/payments_controller_spec.rb +7 -7
- data/spec/controllers/spree/admin/prices_controller_spec.rb +2 -2
- data/spec/controllers/spree/admin/product_properties_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/products_controller_spec.rb +6 -6
- data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +2 -2
- data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +2 -2
- data/spec/controllers/spree/admin/promotions_controller_spec.rb +7 -7
- data/spec/controllers/spree/admin/refunds_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +5 -5
- data/spec/controllers/spree/admin/reports_controller_spec.rb +2 -2
- data/spec/controllers/spree/admin/resource_controller_spec.rb +6 -6
- data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +11 -11
- data/spec/controllers/spree/admin/return_items_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/search_controller_spec.rb +2 -2
- data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/stock_items_controller_spec.rb +3 -3
- data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +3 -3
- data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +10 -10
- data/spec/controllers/spree/admin/store_credits_controller_spec.rb +10 -10
- data/spec/controllers/spree/admin/users_controller_spec.rb +139 -141
- data/spec/controllers/spree/admin/variants_controller_spec.rb +2 -2
- data/spec/features/admin/configuration/general_settings_spec.rb +7 -16
- data/spec/features/admin/configuration/payment_methods_spec.rb +7 -7
- data/spec/features/admin/configuration/stock_locations_spec.rb +1 -1
- data/spec/features/admin/configuration/tax_categories_spec.rb +1 -1
- data/spec/features/admin/configuration/zones_spec.rb +1 -1
- data/spec/features/admin/homepage_spec.rb +2 -2
- data/spec/features/admin/orders/adjustments_spec.rb +1 -1
- data/spec/features/admin/orders/cancelling_inventory_spec.rb +8 -8
- data/spec/features/admin/orders/customer_details_spec.rb +20 -5
- data/spec/features/admin/orders/listing_spec.rb +97 -70
- data/spec/features/admin/orders/new_order_spec.rb +35 -6
- data/spec/features/admin/orders/order_details_spec.rb +37 -58
- data/spec/features/admin/orders/payments_spec.rb +57 -4
- data/spec/features/admin/orders/return_authorizations_spec.rb +25 -0
- data/spec/features/admin/orders/shipments_spec.rb +5 -5
- data/spec/features/admin/products/edit/products_spec.rb +1 -1
- data/spec/features/admin/products/edit/taxons_spec.rb +5 -5
- data/spec/features/admin/products/edit/variants_spec.rb +1 -1
- data/spec/features/admin/products/option_types_spec.rb +2 -2
- data/spec/features/admin/products/products_spec.rb +6 -6
- data/spec/features/admin/products/properties_spec.rb +6 -6
- data/spec/features/admin/products/prototypes_spec.rb +1 -1
- data/spec/features/admin/products/stock_management_spec.rb +5 -5
- data/spec/features/admin/promotion_adjustments_spec.rb +8 -8
- data/spec/features/admin/promotions/option_value_rule_spec.rb +4 -4
- data/spec/features/admin/promotions/product_rule_spec.rb +33 -0
- data/spec/features/admin/promotions/tiered_calculator_spec.rb +2 -2
- data/spec/features/admin/promotions/user_rule_spec.rb +15 -0
- data/spec/features/admin/reports_spec.rb +1 -1
- data/spec/features/admin/users_spec.rb +27 -2
- data/spec/helpers/admin/base_helper_spec.rb +30 -0
- data/spec/helpers/admin/navigation_helper_spec.rb +40 -2
- data/spec/spec_helper.rb +10 -8
- data/spec/support/feature/order_feature_helper.rb +17 -0
- metadata +18 -11
- data/app/assets/javascripts/spree/backend/general_settings.js.coffee +0 -13
- data/spec/controllers/spree/admin/general_settings_controller_spec.rb +0 -41
@@ -3,255 +3,253 @@ require 'spree/testing_support/bar_ability'
|
|
3
3
|
|
4
4
|
describe Spree::Admin::UsersController, type: :controller do
|
5
5
|
let(:user) { create(:user) }
|
6
|
-
let(:mock_user) { mock_model Spree.user_class }
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
let(:state) { create(:state, state_code: 'NY') }
|
8
|
+
let(:valid_address_attributes) do
|
9
|
+
{
|
10
|
+
firstname: 'Foo',
|
11
|
+
lastname: 'Bar',
|
12
|
+
city: "New York",
|
13
|
+
country_id: state.country.id,
|
14
|
+
state_id: state.id,
|
15
|
+
phone: '555-555-5555',
|
16
|
+
address1: '123 Fake St.',
|
17
|
+
zipcode: '10001',
|
18
|
+
}
|
11
19
|
end
|
12
20
|
|
13
21
|
context "#show" do
|
14
|
-
|
15
|
-
|
22
|
+
stub_authorization! do |_user|
|
23
|
+
can [:admin, :manage], Spree.user_class
|
16
24
|
end
|
17
25
|
|
18
26
|
it "redirects to edit" do
|
19
|
-
|
27
|
+
get :show, id: user.id
|
20
28
|
expect(response).to redirect_to spree.edit_admin_user_path(user)
|
21
29
|
end
|
22
30
|
end
|
23
31
|
|
24
32
|
context '#authorize_admin' do
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
spree_post :index
|
30
|
-
expect(response).to render_template :index
|
31
|
-
end
|
33
|
+
context "with ability to admin users" do
|
34
|
+
stub_authorization! do |_user|
|
35
|
+
can [:manage], Spree.user_class
|
36
|
+
end
|
32
37
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
expect(response).to redirect_to(spree.edit_admin_user_path(mock_user))
|
38
|
-
end
|
38
|
+
it 'can visit index' do
|
39
|
+
post :index
|
40
|
+
expect(response).to be_success
|
41
|
+
end
|
39
42
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
it "allows admins to update a user's API key" do
|
44
|
+
expect {
|
45
|
+
put :generate_api_key, id: user.id
|
46
|
+
}.to change { user.reload.spree_api_key }
|
47
|
+
expect(response).to redirect_to(spree.edit_admin_user_path(user))
|
48
|
+
end
|
46
49
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
it "allows admins to clear a user's API key" do
|
51
|
+
user.generate_spree_api_key!
|
52
|
+
expect {
|
53
|
+
put :clear_api_key, id: user.id
|
54
|
+
}.to change{ user.reload.spree_api_key }.to(nil)
|
55
|
+
expect(response).to redirect_to(spree.edit_admin_user_path(user))
|
56
|
+
end
|
52
57
|
end
|
53
58
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
spree_post :update, { id: '9' }
|
58
|
-
expect(response).to redirect_to '/unauthorized'
|
59
|
-
end
|
59
|
+
context "without ability to admin users" do
|
60
|
+
stub_authorization! do |_user|
|
61
|
+
end
|
60
62
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
63
|
+
it 'denies access' do
|
64
|
+
post :index
|
65
|
+
expect(response).to redirect_to '/unauthorized'
|
66
|
+
end
|
65
67
|
end
|
66
68
|
end
|
67
69
|
|
68
70
|
describe "#create" do
|
69
71
|
let(:dummy_role) { Spree::Role.create(name: "dummyrole") }
|
70
72
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
73
|
+
# The created user
|
74
|
+
def user
|
75
|
+
Spree.user_class.last
|
76
|
+
end
|
77
|
+
|
78
|
+
stub_authorization! do |_user|
|
79
|
+
can :manage, Spree.user_class
|
75
80
|
end
|
76
81
|
|
77
82
|
context "when the user can manage roles" do
|
78
|
-
|
79
|
-
|
80
|
-
|
83
|
+
stub_authorization! do |_user|
|
84
|
+
can :manage, Spree.user_class
|
85
|
+
can :manage, Spree::Role
|
81
86
|
end
|
82
87
|
|
83
|
-
it "can
|
84
|
-
|
85
|
-
|
88
|
+
it "can create user with roles" do
|
89
|
+
post :create, { user: { first_name: "Bob", spree_role_ids: [dummy_role.id] } }
|
90
|
+
expect(user.spree_roles).to eq([dummy_role])
|
86
91
|
end
|
87
|
-
end
|
88
92
|
|
89
|
-
|
90
|
-
|
91
|
-
user.spree_roles
|
93
|
+
it "can create user without roles" do
|
94
|
+
post :create, { user: { first_name: "Bob" } }
|
95
|
+
expect(user.spree_roles).to eq([])
|
92
96
|
end
|
97
|
+
end
|
93
98
|
|
94
|
-
|
95
|
-
|
96
|
-
|
99
|
+
context "when the user cannot manage roles" do
|
100
|
+
it "cannot assign users roles" do
|
101
|
+
post :create, { user: { first_name: "Bob", spree_role_ids: [dummy_role.id] } }
|
102
|
+
expect(user.spree_roles).to eq([])
|
97
103
|
end
|
98
104
|
|
99
|
-
it "
|
100
|
-
|
101
|
-
|
102
|
-
end
|
103
|
-
|
104
|
-
it "cannot clear roles" do
|
105
|
-
expect(mock_user).to_not receive(:spree_roles=)
|
106
|
-
spree_post :create, { id: mock_user.id, user: { first_name: "Bob" } }
|
105
|
+
it "can create user without roles" do
|
106
|
+
post :create, { user: { first_name: "Bob" } }
|
107
|
+
expect(user.spree_roles).to eq([])
|
107
108
|
end
|
108
109
|
end
|
109
110
|
|
110
111
|
it "can create a shipping_address" do
|
111
|
-
|
112
|
-
|
113
|
-
))
|
114
|
-
spree_post :create, { user: { ship_address_attributes: { city: "New York" } } }
|
112
|
+
post :create, { user: { ship_address_attributes: valid_address_attributes } }
|
113
|
+
expect(user.reload.ship_address.city).to eq('New York')
|
115
114
|
end
|
116
115
|
|
117
116
|
it "can create a billing_address" do
|
118
|
-
|
119
|
-
|
120
|
-
))
|
121
|
-
spree_post :create, { user: { bill_address_attributes: { city: "New York" } } }
|
117
|
+
post :create, { user: { bill_address_attributes: valid_address_attributes } }
|
118
|
+
expect(user.reload.bill_address.city).to eq('New York')
|
122
119
|
end
|
123
120
|
|
124
121
|
it "can set stock locations" do
|
125
122
|
location = Spree::StockLocation.create(name: "my_location")
|
126
123
|
location_2 = Spree::StockLocation.create(name: "my_location_2")
|
127
|
-
|
128
|
-
|
124
|
+
post :create, { user: { stock_location_ids: [location.id, location_2.id] } }
|
125
|
+
expect(user.stock_locations).to match_array([location, location_2])
|
129
126
|
end
|
130
127
|
end
|
131
128
|
|
132
129
|
describe "#update" do
|
133
130
|
let(:dummy_role) { Spree::Role.create(name: "dummyrole") }
|
134
131
|
let(:ability) { Spree::Ability.new(user) }
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
allow(controller).to receive(:current_ability) { ability }
|
139
|
-
Spree::PermissionSets::UserManagement.new(ability).activate!
|
132
|
+
|
133
|
+
stub_authorization! do |_user|
|
134
|
+
can :manage, Spree.user_class
|
140
135
|
end
|
141
136
|
|
142
|
-
context "
|
143
|
-
|
137
|
+
context "when the user can manage roles" do
|
138
|
+
stub_authorization! do |_user|
|
139
|
+
can :manage, Spree.user_class
|
140
|
+
can :manage, Spree::Role
|
141
|
+
end
|
144
142
|
|
145
143
|
it "can set roles" do
|
146
|
-
expect
|
147
|
-
|
144
|
+
expect {
|
145
|
+
put :update, { id: user.id, user: { first_name: "Bob", spree_role_ids: [dummy_role.id] } }
|
146
|
+
}.to change { user.reload.spree_roles.to_a }.to([dummy_role])
|
148
147
|
end
|
149
148
|
|
150
149
|
it "can clear roles" do
|
151
|
-
|
152
|
-
|
150
|
+
user.spree_roles << dummy_role
|
151
|
+
expect {
|
152
|
+
put :update, { id: user.id, user: { first_name: "Bob", spree_role_ids: [] } }
|
153
|
+
}.to change { user.reload.spree_roles.to_a }.to([])
|
153
154
|
end
|
155
|
+
end
|
154
156
|
|
155
|
-
|
156
|
-
|
157
|
-
|
157
|
+
context "when the user cannot manage roles" do
|
158
|
+
it "cannot set roles" do
|
159
|
+
expect {
|
160
|
+
put :update, { id: user.id, user: { first_name: "Bob", spree_role_ids: [dummy_role.id] } }
|
161
|
+
}.not_to change { user.reload.spree_roles.to_a }
|
158
162
|
end
|
159
163
|
|
160
|
-
it "
|
161
|
-
|
162
|
-
expect
|
163
|
-
|
164
|
+
it "cannot clear roles" do
|
165
|
+
user.spree_roles << dummy_role
|
166
|
+
expect {
|
167
|
+
put :update, { id: user.id, user: { first_name: "Bob" } }
|
168
|
+
}.not_to change { user.reload.spree_roles.to_a }
|
164
169
|
end
|
165
170
|
end
|
166
171
|
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
172
|
+
context "allowed to update email" do
|
173
|
+
stub_authorization! do |_user|
|
174
|
+
can [:admin, :update, :update_email], Spree.user_class
|
175
|
+
end
|
171
176
|
|
172
|
-
|
173
|
-
|
174
|
-
|
177
|
+
it "can change email of a user" do
|
178
|
+
expect {
|
179
|
+
put :update, { id: user.id, user: { email: "bob@example.com" } }
|
180
|
+
}.to change { user.reload.email }.to("bob@example.com")
|
181
|
+
end
|
175
182
|
end
|
176
183
|
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
184
|
+
context "not allowed to update email" do
|
185
|
+
stub_authorization! do |_user|
|
186
|
+
can [:admin, :update], Spree.user_class
|
187
|
+
end
|
181
188
|
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
189
|
+
it "cannot change email of a user" do
|
190
|
+
expect {
|
191
|
+
put :update, { id: user.id, user: { email: "bob@example.com" } }
|
192
|
+
}.not_to change { user.reload.email }
|
193
|
+
end
|
186
194
|
end
|
187
195
|
|
188
|
-
it "
|
189
|
-
|
190
|
-
|
191
|
-
))
|
192
|
-
spree_put :update, { id: mock_user.id, user: { ship_address_attributes: { city: "New York" } } }
|
196
|
+
it "can update ship_address attributes" do
|
197
|
+
post :update, { id: user.id, user: { ship_address_attributes: valid_address_attributes } }
|
198
|
+
expect(user.reload.ship_address.city).to eq('New York')
|
193
199
|
end
|
194
200
|
|
195
|
-
it "
|
196
|
-
|
197
|
-
|
198
|
-
))
|
199
|
-
spree_put :update, { id: mock_user.id, user: { bill_address_attributes: { city: "New York" } } }
|
201
|
+
it "can update bill_address attributes" do
|
202
|
+
post :update, { id: user.id, user: { bill_address_attributes: valid_address_attributes } }
|
203
|
+
expect(user.reload.bill_address.city).to eq('New York')
|
200
204
|
end
|
201
205
|
|
202
206
|
it "can set stock locations" do
|
203
207
|
location = Spree::StockLocation.create(name: "my_location")
|
204
208
|
location_2 = Spree::StockLocation.create(name: "my_location_2")
|
205
|
-
|
206
|
-
|
209
|
+
post :update, { id: user.id, user: { stock_location_ids: [location.id, location_2.id] } }
|
210
|
+
expect(user.stock_locations).to match_array([location, location_2])
|
207
211
|
end
|
208
212
|
end
|
209
213
|
|
210
214
|
describe "#orders" do
|
211
|
-
|
212
|
-
|
213
|
-
user.orders << order
|
214
|
-
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
215
|
+
stub_authorization! do |_user|
|
216
|
+
can :manage, Spree.user_class
|
215
217
|
end
|
216
218
|
|
219
|
+
let(:order) { create(:order) }
|
220
|
+
before { user.orders << order }
|
221
|
+
|
217
222
|
it "assigns a list of the users orders" do
|
218
|
-
|
223
|
+
get :orders, { id: user.id }
|
219
224
|
expect(assigns[:orders].count).to eq 1
|
220
225
|
expect(assigns[:orders].first).to eq order
|
221
226
|
end
|
222
227
|
|
223
228
|
it "assigns a ransack search for Spree::Order" do
|
224
|
-
|
229
|
+
get :orders, { id: user.id }
|
225
230
|
expect(assigns[:search]).to be_a Ransack::Search
|
226
231
|
expect(assigns[:search].klass).to eq Spree::Order
|
227
232
|
end
|
228
233
|
end
|
229
234
|
|
230
235
|
describe "#items" do
|
231
|
-
|
232
|
-
|
233
|
-
user.orders << order
|
234
|
-
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
236
|
+
stub_authorization! do |_user|
|
237
|
+
can :manage, Spree.user_class
|
235
238
|
end
|
236
239
|
|
240
|
+
let(:order) { create(:order) }
|
241
|
+
before { user.orders << order }
|
242
|
+
|
237
243
|
it "assigns a list of the users orders" do
|
238
|
-
|
244
|
+
get :items, { id: user.id }
|
239
245
|
expect(assigns[:orders].count).to eq 1
|
240
246
|
expect(assigns[:orders].first).to eq order
|
241
247
|
end
|
242
248
|
|
243
249
|
it "assigns a ransack search for Spree::Order" do
|
244
|
-
|
250
|
+
get :items, { id: user.id }
|
245
251
|
expect(assigns[:search]).to be_a Ransack::Search
|
246
252
|
expect(assigns[:search].klass).to eq Spree::Order
|
247
253
|
end
|
248
254
|
end
|
249
255
|
end
|
250
|
-
|
251
|
-
def use_mock_user
|
252
|
-
allow(mock_user).to receive(:save).and_return(true)
|
253
|
-
allow(mock_user).to receive(:update_attributes).and_return(true)
|
254
|
-
allow(mock_user).to receive(:spree_roles).and_return([])
|
255
|
-
allow(Spree.user_class).to receive(:find).with(mock_user.id.to_s).and_return(mock_user)
|
256
|
-
allow(Spree.user_class).to receive(:new).and_return(mock_user)
|
257
|
-
end
|
@@ -14,7 +14,7 @@ module Spree
|
|
14
14
|
|
15
15
|
context "deleted is not requested" do
|
16
16
|
it "does not assign deleted variants for a requested product" do
|
17
|
-
|
17
|
+
get :index, product_id: product.slug
|
18
18
|
expect(assigns(:collection)).to include variant_1
|
19
19
|
expect(assigns(:collection)).not_to include variant_2
|
20
20
|
end
|
@@ -22,7 +22,7 @@ module Spree
|
|
22
22
|
|
23
23
|
context "deleted is requested" do
|
24
24
|
it "assigns deleted along with non-deleted variants for a requested product" do
|
25
|
-
|
25
|
+
get :index, product_id: product.slug, deleted: "on"
|
26
26
|
expect(assigns(:collection)).to include variant_1
|
27
27
|
expect(assigns(:collection)).to include variant_2
|
28
28
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe "
|
3
|
+
describe "Store", type: :feature, js: true do
|
4
4
|
stub_authorization!
|
5
5
|
|
6
6
|
let!(:store) do
|
@@ -11,19 +11,21 @@ describe "General Settings", type: :feature, js: true do
|
|
11
11
|
before(:each) do
|
12
12
|
visit spree.admin_path
|
13
13
|
click_link "Settings"
|
14
|
-
|
14
|
+
within('.admin-nav') do
|
15
|
+
click_link "Store"
|
16
|
+
end
|
15
17
|
end
|
16
18
|
|
17
|
-
context "visiting general settings" do
|
19
|
+
context "visiting general store settings" do
|
18
20
|
it "should have the right content" do
|
19
|
-
expect(page).to have_content("
|
21
|
+
expect(page).to have_content("SettingsStore")
|
20
22
|
expect(page).to have_field("store_name", with: "Test Store")
|
21
23
|
expect(page).to have_field("store_url", with: "test.example.org")
|
22
24
|
expect(page).to have_field("store_mail_from_address", with: "test@example.org")
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
26
|
-
context "editing general settings" do
|
28
|
+
context "editing general store settings" do
|
27
29
|
it "should be able to update the site name" do
|
28
30
|
fill_in "store_name", with: "Spree Demo Site99"
|
29
31
|
fill_in "store_mail_from_address", with: "spree@example.org"
|
@@ -44,15 +46,4 @@ describe "General Settings", type: :feature, js: true do
|
|
44
46
|
expect(page).to have_field("Site Name", with: "")
|
45
47
|
end
|
46
48
|
end
|
47
|
-
|
48
|
-
context "clearing the cache" do
|
49
|
-
it "should clear the cache" do
|
50
|
-
expect(page).to_not have_content(Spree.t(:clear_cache_ok))
|
51
|
-
expect(page).to have_content(Spree.t(:clear_cache_warning))
|
52
|
-
|
53
|
-
click_button "Clear Cache"
|
54
|
-
|
55
|
-
expect(page).to have_content(Spree.t(:clear_cache_ok))
|
56
|
-
end
|
57
|
-
end
|
58
49
|
end
|