solidus_backend 2.9.6 → 2.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree/backend.js +5 -1
- data/app/assets/javascripts/spree/backend/adjustments.js +1 -1
- data/app/assets/javascripts/spree/backend/admin.js +18 -29
- data/app/assets/javascripts/spree/backend/collections/states.js +1 -1
- data/app/assets/javascripts/spree/backend/components/admin_nav.js +24 -0
- data/app/assets/javascripts/spree/backend/components/selectable_table.js +5 -0
- data/app/assets/javascripts/spree/backend/components/selectable_table/return_items.js +5 -0
- data/app/assets/javascripts/spree/backend/components/selectable_table/summary.js +7 -0
- data/app/assets/javascripts/spree/backend/components/sortable_table.js +31 -25
- data/app/assets/javascripts/spree/backend/components/tabs.js +1 -1
- data/app/assets/javascripts/spree/backend/models/order.js +11 -2
- data/app/assets/javascripts/spree/backend/models/payment.js +1 -1
- data/app/assets/javascripts/spree/backend/models/shipment.js +1 -1
- data/app/assets/javascripts/spree/backend/models/stock_item.js +1 -1
- data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +2 -2
- data/app/assets/javascripts/spree/backend/option_value_picker.js +2 -2
- data/app/assets/javascripts/spree/backend/orders/cart.js +6 -0
- data/app/assets/javascripts/spree/backend/product_picker.js +2 -2
- data/app/assets/javascripts/spree/backend/routes.js +40 -21
- data/app/assets/javascripts/spree/backend/shipments.js +5 -67
- data/app/assets/javascripts/spree/backend/shipping_methods/stock_locations_picker.js +18 -0
- data/app/assets/javascripts/spree/backend/stock_management.js +4 -2
- data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +2 -2
- data/app/assets/javascripts/spree/backend/taxons.js +3 -3
- data/app/assets/javascripts/spree/backend/templates/index.js +2 -1
- data/app/assets/javascripts/spree/backend/templates/orders/customer_details/autocomplete.hbs +2 -2
- data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +5 -1
- data/app/assets/javascripts/spree/backend/templates/tables/return_item_sum_amount.hbs +7 -0
- data/app/assets/javascripts/spree/backend/templates/tables/selectable_label.hbs +6 -0
- data/app/assets/javascripts/spree/backend/user_picker.js +3 -4
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js +2 -2
- data/app/assets/javascripts/spree/backend/views/cart/empty_cart_button.js +29 -0
- data/app/assets/javascripts/spree/backend/views/cart/line_item_table.js +5 -0
- data/app/assets/javascripts/spree/backend/views/index.js +5 -0
- data/app/assets/javascripts/spree/backend/views/order/address.js +8 -6
- data/app/assets/javascripts/spree/backend/views/order/customer_select.js +2 -3
- data/app/assets/javascripts/spree/backend/views/order/details_adjustments.js +4 -1
- data/app/assets/javascripts/spree/backend/views/stock/edit_stock_item_row.js +4 -0
- data/app/assets/javascripts/spree/backend/views/tables/return_items.js +9 -0
- data/app/assets/javascripts/spree/backend/views/tables/selectable_table.js +70 -0
- data/app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js +32 -0
- data/app/assets/javascripts/spree/backend/views/tables/selectable_table/summary.js +45 -0
- data/app/assets/stylesheets/spree/backend/_bootstrap_custom.scss +2 -0
- data/app/assets/stylesheets/spree/backend/components/_breadcrumb.scss +3 -3
- data/app/assets/stylesheets/spree/backend/components/_messages.scss +4 -0
- data/app/assets/stylesheets/spree/backend/components/_navigation.scss +181 -49
- data/app/assets/stylesheets/spree/backend/globals/{_mixins.css → _mixins.scss} +0 -0
- data/app/assets/stylesheets/spree/backend/globals/_variables.scss +2 -0
- data/app/assets/stylesheets/spree/backend/sections/_orders.scss +5 -1
- data/app/assets/stylesheets/spree/backend/sections/_style_guide.scss +4 -0
- data/app/assets/stylesheets/spree/backend/shared/_forms.scss +1 -0
- data/app/assets/stylesheets/spree/backend/shared/_header.scss +5 -1
- data/app/assets/stylesheets/spree/backend/shared/_layout.scss +0 -9
- data/app/controllers/spree/admin/adjustments_controller.rb +1 -1
- data/app/controllers/spree/admin/base_controller.rb +7 -1
- data/app/controllers/spree/admin/cancellations_controller.rb +2 -0
- data/app/controllers/spree/admin/customer_returns_controller.rb +4 -4
- data/app/controllers/spree/admin/images_controller.rb +2 -1
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +2 -0
- data/app/controllers/spree/admin/orders_controller.rb +9 -4
- data/app/controllers/spree/admin/payment_methods_controller.rb +4 -4
- data/app/controllers/spree/admin/payments_controller.rb +5 -3
- data/app/controllers/spree/admin/product_properties_controller.rb +2 -2
- data/app/controllers/spree/admin/products_controller.rb +19 -25
- data/app/controllers/spree/admin/promotion_codes_controller.rb +9 -4
- data/app/controllers/spree/admin/refunds_controller.rb +19 -0
- data/app/controllers/spree/admin/resource_controller.rb +39 -10
- data/app/controllers/spree/admin/return_authorizations_controller.rb +1 -1
- data/app/controllers/spree/admin/root_controller.rb +1 -1
- data/app/controllers/spree/admin/search_controller.rb +1 -2
- data/app/controllers/spree/admin/stock_items_controller.rb +6 -5
- data/app/controllers/spree/admin/stock_locations_controller.rb +4 -0
- data/app/controllers/spree/admin/stock_movements_controller.rb +7 -0
- data/app/controllers/spree/admin/style_guide_controller.rb +1 -1
- data/app/controllers/spree/admin/taxons/attachment_controller.rb +20 -0
- data/app/controllers/spree/admin/taxons_controller.rb +12 -1
- data/app/controllers/spree/admin/users/api_key_controller.rb +29 -0
- data/app/controllers/spree/admin/users_controller.rb +43 -22
- data/app/controllers/spree/admin/variants_controller.rb +4 -2
- data/app/controllers/spree/admin/zones_controller.rb +1 -1
- data/app/helpers/spree/admin/base_helper.rb +4 -0
- data/app/helpers/spree/admin/customer_returns_helper.rb +1 -1
- data/app/helpers/spree/admin/navigation_helper.rb +4 -3
- data/app/helpers/spree/admin/orders_helper.rb +8 -4
- data/app/helpers/spree/admin/stock_movements_helper.rb +8 -4
- data/app/helpers/spree/promotion_rules_helper.rb +1 -1
- data/app/views/spree/admin/customer_returns/_return_item_selection.html.erb +2 -3
- data/app/views/spree/admin/customer_returns/new.html.erb +1 -1
- data/app/views/spree/admin/images/index.html.erb +25 -21
- data/app/views/spree/admin/option_types/_option_value_fields.html.erb +8 -1
- data/app/views/spree/admin/option_types/edit.html.erb +4 -2
- data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +1 -0
- data/app/views/spree/admin/orders/customer_details/_form.html.erb +13 -13
- data/app/views/spree/admin/orders/edit.html.erb +3 -4
- data/app/views/spree/admin/orders/index.html.erb +23 -13
- data/app/views/spree/admin/payment_methods/_form.html.erb +7 -2
- data/app/views/spree/admin/payment_methods/new.html.erb +1 -1
- data/app/views/spree/admin/payments/index.html.erb +3 -1
- data/app/views/spree/admin/prices/_master_variant_table.html.erb +41 -41
- data/app/views/spree/admin/prices/_table.html.erb +3 -3
- data/app/views/spree/admin/product_properties/_product_property_fields.html.erb +7 -2
- data/app/views/spree/admin/product_properties/index.html.erb +14 -2
- data/app/views/spree/admin/products/_form.html.erb +13 -2
- data/app/views/spree/admin/products/index.html.erb +1 -1
- data/app/views/spree/admin/promotion_code_batches/new.html.erb +1 -1
- data/app/views/spree/admin/promotion_codes/index.html.erb +1 -1
- data/app/views/spree/admin/promotion_codes/new.html.erb +1 -1
- data/app/views/spree/admin/promotions/_actions.html.erb +2 -1
- data/app/views/spree/admin/promotions/_activations_new.html.erb +1 -1
- data/app/views/spree/admin/promotions/_rules.html.erb +1 -1
- data/app/views/spree/admin/promotions/edit.html.erb +2 -2
- data/app/views/spree/admin/promotions/index.html.erb +13 -6
- data/app/views/spree/admin/return_authorizations/_form.html.erb +3 -10
- data/app/views/spree/admin/return_authorizations/index.html.erb +1 -1
- data/app/views/spree/admin/return_authorizations/new.html.erb +1 -1
- data/app/views/spree/admin/search/users.json.jbuilder +15 -1
- data/app/views/spree/admin/shared/_address.html.erb +6 -6
- data/app/views/spree/admin/shared/_address_form.html.erb +15 -8
- data/app/views/spree/admin/shared/_calculator_fields.html.erb +5 -0
- data/app/views/spree/admin/shared/_navigation.html.erb +3 -0
- data/app/views/spree/admin/shared/_new_resource_links.html.erb +1 -1
- data/app/views/spree/admin/shared/_order_submenu.html.erb +6 -6
- data/app/views/spree/admin/shared/_payments_tabs.html.erb +1 -1
- data/app/views/spree/admin/shared/_settings_checkout_tabs.html.erb +5 -5
- data/app/views/spree/admin/shared/_settings_sub_menu.html.erb +7 -7
- data/app/views/spree/admin/shared/_shipping_tabs.html.erb +3 -3
- data/app/views/spree/admin/shared/_taxes_tabs.html.erb +2 -2
- data/app/views/spree/admin/shared/preference_fields/_encrypted_string.html.erb +12 -0
- data/app/views/spree/admin/shipping_methods/_form.html.erb +19 -1
- data/app/views/spree/admin/stock_items/_stock_management.html.erb +1 -1
- data/app/views/spree/admin/stock_locations/edit.html.erb +1 -1
- data/app/views/spree/admin/stock_locations/index.html.erb +4 -2
- data/app/views/spree/admin/stock_movements/index.html.erb +30 -1
- data/app/views/spree/admin/store_credit_reasons/index.html.erb +1 -1
- data/app/views/spree/admin/store_credits/index.html.erb +1 -1
- data/app/views/spree/admin/stores/_form.html.erb +6 -0
- data/app/views/spree/admin/style_guide/topics/tables/_building_tables.html.erb +27 -3
- data/app/views/spree/admin/tax_categories/_form.html.erb +1 -0
- data/app/views/spree/admin/tax_rates/_form.html.erb +1 -1
- data/app/views/spree/admin/taxonomies/new.html.erb +1 -1
- data/app/views/spree/admin/taxons/_form.html.erb +1 -5
- data/app/views/spree/admin/taxons/attachment_forms/_paperclip.html.erb +16 -0
- data/app/views/spree/admin/users/_form.html.erb +14 -12
- data/app/views/spree/admin/users/_tabs.html.erb +1 -1
- data/app/views/spree/admin/users/edit.html.erb +5 -6
- data/app/views/spree/admin/users/items.html.erb +5 -3
- data/app/views/spree/admin/users/orders.html.erb +5 -3
- data/app/views/spree/admin/variants/_table_filter.html.erb +1 -1
- data/app/views/spree/admin/variants/index.html.erb +2 -2
- data/app/views/spree/layouts/admin.html.erb +1 -2
- data/config/initializers/form_builder.rb +2 -2
- data/config/routes.rb +4 -6
- data/lib/spree/backend.rb +1 -0
- data/lib/spree/backend/config.rb +9 -0
- data/lib/spree/backend/engine.rb +5 -5
- data/{app/models → lib}/spree/backend_configuration.rb +19 -3
- data/solidus_backend.gemspec +5 -4
- data/vendor/assets/stylesheets/solidus_admin/bootstrap/_variables.scss +1 -1
- metadata +44 -124
- data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +0 -35
- data/app/assets/javascripts/spree/backend/templates/variants/autocomplete_stock.hbs +0 -56
- data/app/views/spree/admin/orders/_add_product.html.erb +0 -12
- data/script/rails +0 -10
- data/spec/controllers/spree/admin/base_controller_spec.rb +0 -26
- data/spec/controllers/spree/admin/cancellations_controller_spec.rb +0 -83
- data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +0 -235
- data/spec/controllers/spree/admin/locale_controller_spec.rb +0 -45
- data/spec/controllers/spree/admin/missing_products_controller_spec.rb +0 -18
- data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +0 -128
- data/spec/controllers/spree/admin/orders_controller_spec.rb +0 -408
- data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +0 -95
- data/spec/controllers/spree/admin/payments_controller_spec.rb +0 -194
- data/spec/controllers/spree/admin/prices_controller_spec.rb +0 -45
- data/spec/controllers/spree/admin/product_properties_controller_spec.rb +0 -71
- data/spec/controllers/spree/admin/products_controller_spec.rb +0 -270
- data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +0 -23
- data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +0 -32
- data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +0 -36
- data/spec/controllers/spree/admin/promotions_controller_spec.rb +0 -122
- data/spec/controllers/spree/admin/refunds_controller_spec.rb +0 -35
- data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +0 -137
- data/spec/controllers/spree/admin/resource_controller_spec.rb +0 -190
- data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +0 -291
- data/spec/controllers/spree/admin/return_items_controller_spec.rb +0 -29
- data/spec/controllers/spree/admin/root_controller_spec.rb +0 -43
- data/spec/controllers/spree/admin/search_controller_spec.rb +0 -106
- data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +0 -16
- data/spec/controllers/spree/admin/stock_items_controller_spec.rb +0 -52
- data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +0 -44
- data/spec/controllers/spree/admin/store_credits_controller_spec.rb +0 -311
- data/spec/controllers/spree/admin/users_controller_spec.rb +0 -264
- data/spec/controllers/spree/admin/variants_controller_spec.rb +0 -71
- data/spec/features/admin/configuration/payment_methods_spec.rb +0 -167
- data/spec/features/admin/configuration/shipping_methods_spec.rb +0 -114
- data/spec/features/admin/configuration/stock_locations_spec.rb +0 -54
- data/spec/features/admin/configuration/store_spec.rb +0 -62
- data/spec/features/admin/configuration/tax_categories_spec.rb +0 -58
- data/spec/features/admin/configuration/tax_rates_spec.rb +0 -31
- data/spec/features/admin/configuration/taxonomies_spec.rb +0 -54
- data/spec/features/admin/configuration/zones_spec.rb +0 -41
- data/spec/features/admin/homepage_spec.rb +0 -86
- data/spec/features/admin/javascript_format_money_spec.rb +0 -22
- data/spec/features/admin/locale_spec.rb +0 -34
- data/spec/features/admin/orders/adjustments_promotions_spec.rb +0 -55
- data/spec/features/admin/orders/adjustments_spec.rb +0 -130
- data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +0 -45
- data/spec/features/admin/orders/cancelling_inventory_spec.rb +0 -50
- data/spec/features/admin/orders/customer_details_spec.rb +0 -204
- data/spec/features/admin/orders/customer_returns_spec.rb +0 -28
- data/spec/features/admin/orders/line_items_spec.rb +0 -52
- data/spec/features/admin/orders/listing_spec.rb +0 -186
- data/spec/features/admin/orders/log_entries_spec.rb +0 -56
- data/spec/features/admin/orders/new_order_spec.rb +0 -331
- data/spec/features/admin/orders/new_refund_spec.rb +0 -35
- data/spec/features/admin/orders/order_details_spec.rb +0 -581
- data/spec/features/admin/orders/payments_spec.rb +0 -330
- data/spec/features/admin/orders/return_authorizations_spec.rb +0 -27
- data/spec/features/admin/orders/return_payment_state_spec.rb +0 -65
- data/spec/features/admin/orders/risk_analysis_spec.rb +0 -49
- data/spec/features/admin/orders/shipments_spec.rb +0 -145
- data/spec/features/admin/payments/store_credits_spec.rb +0 -23
- data/spec/features/admin/products/edit/images_spec.rb +0 -76
- data/spec/features/admin/products/edit/products_spec.rb +0 -92
- data/spec/features/admin/products/edit/taxons_spec.rb +0 -51
- data/spec/features/admin/products/edit/variants_spec.rb +0 -63
- data/spec/features/admin/products/option_types_spec.rb +0 -116
- data/spec/features/admin/products/pricing_spec.rb +0 -127
- data/spec/features/admin/products/products_spec.rb +0 -336
- data/spec/features/admin/products/properties_spec.rb +0 -141
- data/spec/features/admin/products/stock_management_spec.rb +0 -101
- data/spec/features/admin/products/variant_spec.rb +0 -89
- data/spec/features/admin/promotion_adjustments_spec.rb +0 -277
- data/spec/features/admin/promotions/option_value_rule_spec.rb +0 -90
- data/spec/features/admin/promotions/product_rule_spec.rb +0 -35
- data/spec/features/admin/promotions/promotion_categories_spec.rb +0 -83
- data/spec/features/admin/promotions/promotion_spec.rb +0 -52
- data/spec/features/admin/promotions/tiered_calculator_spec.rb +0 -76
- data/spec/features/admin/promotions/user_rule_spec.rb +0 -42
- data/spec/features/admin/reimbursements_spec.rb +0 -18
- data/spec/features/admin/store_credits_spec.rb +0 -132
- data/spec/features/admin/stores_spec.rb +0 -37
- data/spec/features/admin/style_guide_spec.rb +0 -14
- data/spec/features/admin/taxons_spec.rb +0 -78
- data/spec/features/admin/users_spec.rb +0 -402
- data/spec/helpers/admin/base_helper_spec.rb +0 -49
- data/spec/helpers/admin/navigation_helper_spec.rb +0 -139
- data/spec/helpers/admin/stock_movements_helper_spec.rb +0 -29
- data/spec/helpers/admin/store_credit_events_helper_spec.rb +0 -97
- data/spec/helpers/promotion_rules_helper_spec.rb +0 -14
- data/spec/javascripts/fixtures/_boot.html.erb +0 -8
- data/spec/javascripts/fixtures/number_with_currency/with_currency_select.html.erb +0 -3
- data/spec/javascripts/fixtures/number_with_currency/without_select.html.erb +0 -3
- data/spec/javascripts/format_money_spec.js +0 -48
- data/spec/javascripts/spec_helper.js +0 -13
- data/spec/javascripts/support/show_errors.js +0 -8
- data/spec/javascripts/support/with_translations.js +0 -11
- data/spec/javascripts/translation_spec.js +0 -58
- data/spec/javascripts/views/number_with_currency_spec.js +0 -72
- data/spec/models/spree/backend_configuration/menu_item_spec.rb +0 -17
- data/spec/models/spree/backend_configuration_spec.rb +0 -22
- data/spec/spec_helper.rb +0 -122
- data/spec/support/appear_before_matcher.rb +0 -10
- data/spec/support/feature/base_feature_helper.rb +0 -12
- data/spec/support/feature/order_feature_helper.rb +0 -27
- data/spec/support/ror_ringer.jpeg +0 -0
- data/spec/teaspoon_env.rb +0 -51
- data/spec/test_views/spree/admin/widgets/edit.html.erb +0 -1
- data/spec/test_views/spree/admin/widgets/new.html.erb +0 -1
- data/spec/views/spree/admin/shared/navigation_footer_spec.rb +0 -67
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
describe "Log entries", type: :feature do
|
|
6
|
-
stub_authorization!
|
|
7
|
-
|
|
8
|
-
let!(:payment) { create(:payment) }
|
|
9
|
-
|
|
10
|
-
context "with a successful log entry" do
|
|
11
|
-
before do
|
|
12
|
-
response = ActiveMerchant::Billing::Response.new(
|
|
13
|
-
true,
|
|
14
|
-
"Transaction successful",
|
|
15
|
-
transid: "ABCD1234"
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
payment.log_entries.create(
|
|
19
|
-
details: response.to_yaml
|
|
20
|
-
)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "shows a successful attempt" do
|
|
24
|
-
visit spree.admin_order_payments_path(payment.order)
|
|
25
|
-
click_on payment.number
|
|
26
|
-
|
|
27
|
-
within("#listing_log_entries") do
|
|
28
|
-
expect(page).to have_content("Transaction successful")
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
context "with a failed log entry" do
|
|
34
|
-
before do
|
|
35
|
-
response = ActiveMerchant::Billing::Response.new(
|
|
36
|
-
false,
|
|
37
|
-
"Transaction failed",
|
|
38
|
-
transid: "ABCD1234"
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
payment.log_entries.create(
|
|
42
|
-
source: payment.source,
|
|
43
|
-
details: response.to_yaml
|
|
44
|
-
)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it "shows a failed attempt" do
|
|
48
|
-
visit spree.admin_order_payments_path(payment.order)
|
|
49
|
-
click_on payment.number
|
|
50
|
-
|
|
51
|
-
within("#listing_log_entries") do
|
|
52
|
-
expect(page).to have_content("Transaction failed")
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
describe "New Order", type: :feature do
|
|
6
|
-
include OrderFeatureHelper
|
|
7
|
-
|
|
8
|
-
let!(:product) { create(:product_in_stock) }
|
|
9
|
-
let!(:state) { create(:state, state_code: 'CA') }
|
|
10
|
-
let!(:store) { create(:store) }
|
|
11
|
-
let!(:user) { create(:user, ship_address: create(:address), bill_address: create(:address)) }
|
|
12
|
-
let!(:payment_method) { create(:check_payment_method) }
|
|
13
|
-
let!(:shipping_method) { create(:shipping_method, cost: 0.0) }
|
|
14
|
-
|
|
15
|
-
stub_authorization!
|
|
16
|
-
|
|
17
|
-
before do
|
|
18
|
-
visit spree.admin_path
|
|
19
|
-
click_on "Orders"
|
|
20
|
-
click_on "New Order"
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "does check if you have a billing address before letting you add shipments" do
|
|
24
|
-
click_on "Shipments"
|
|
25
|
-
expect(page).to have_content 'Please fill in customer info'
|
|
26
|
-
expect(current_path).to eql(spree.edit_admin_order_customer_path(Spree::Order.last))
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "default line item quantity is 1", js: true do
|
|
30
|
-
within ".line-items" do
|
|
31
|
-
expect(page).to have_field 'quantity', with: '1'
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it "completes new order succesfully without using the cart", js: true do
|
|
36
|
-
add_line_item product.name
|
|
37
|
-
|
|
38
|
-
click_on "Customer"
|
|
39
|
-
|
|
40
|
-
within "#select-customer" do
|
|
41
|
-
targetted_select2_search user.email, from: "#s2id_customer_search"
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
expect(page).to have_checked_field('order_use_billing')
|
|
45
|
-
fill_in_address
|
|
46
|
-
click_on "Update"
|
|
47
|
-
|
|
48
|
-
click_on "Payments"
|
|
49
|
-
click_on "Update"
|
|
50
|
-
|
|
51
|
-
expect(current_path).to eql(spree.admin_order_payments_path(Spree::Order.last))
|
|
52
|
-
|
|
53
|
-
click_on "Confirm"
|
|
54
|
-
click_on "Complete Order"
|
|
55
|
-
|
|
56
|
-
expect(current_path).to eql(spree.edit_admin_order_path(Spree::Order.last))
|
|
57
|
-
|
|
58
|
-
click_on "Payments"
|
|
59
|
-
click_icon "capture"
|
|
60
|
-
|
|
61
|
-
click_on "Shipments"
|
|
62
|
-
click_on "Ship"
|
|
63
|
-
|
|
64
|
-
within '.carton-state' do
|
|
65
|
-
expect(page).to have_content('Shipped')
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it 'can create split payments', js: true do
|
|
70
|
-
add_line_item product.name
|
|
71
|
-
|
|
72
|
-
click_on "Customer"
|
|
73
|
-
|
|
74
|
-
within "#select-customer" do
|
|
75
|
-
targetted_select2_search user.email, from: "#s2id_customer_search"
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
expect(page).to have_checked_field('order_use_billing')
|
|
79
|
-
fill_in_address
|
|
80
|
-
click_on "Update"
|
|
81
|
-
|
|
82
|
-
click_on "Payments"
|
|
83
|
-
fill_in "Amount", with: '10.00'
|
|
84
|
-
click_on 'Update'
|
|
85
|
-
|
|
86
|
-
click_on 'New Payment'
|
|
87
|
-
fill_in "Amount", with: '29.98'
|
|
88
|
-
click_on 'Update'
|
|
89
|
-
|
|
90
|
-
expect(page).to have_content("$10.00")
|
|
91
|
-
expect(page).to have_content("$29.98")
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
context "adding new item to the order", js: true do
|
|
95
|
-
it "inventory items show up just fine and are also registered as shipments" do
|
|
96
|
-
add_line_item product.name
|
|
97
|
-
|
|
98
|
-
within(".line-items") do
|
|
99
|
-
expect(page).to have_content(product.name)
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
click_on "Customer"
|
|
103
|
-
|
|
104
|
-
within "#select-customer" do
|
|
105
|
-
targetted_select2_search user.email, from: "#s2id_customer_search"
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
expect(page).to have_checked_field('order_use_billing')
|
|
109
|
-
fill_in_address
|
|
110
|
-
click_on "Update"
|
|
111
|
-
|
|
112
|
-
click_on "Shipments"
|
|
113
|
-
|
|
114
|
-
within(".stock-contents") do
|
|
115
|
-
expect(page).to have_content(product.name)
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
# Regression test for https://github.com/spree/spree/issues/3958
|
|
121
|
-
context "without a delivery step", js: true do
|
|
122
|
-
before do
|
|
123
|
-
allow(Spree::Order).to receive_messages checkout_step_names: [:address, :payment, :confirm, :complete]
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
it "can still see line items" do
|
|
127
|
-
add_line_item product.name
|
|
128
|
-
|
|
129
|
-
within(".line-items") do
|
|
130
|
-
within(".line-item-name") do
|
|
131
|
-
expect(page).to have_content(product.name)
|
|
132
|
-
end
|
|
133
|
-
within(".line-item-qty-show") do
|
|
134
|
-
expect(page).to have_content("1")
|
|
135
|
-
end
|
|
136
|
-
within(".line-item-price") do
|
|
137
|
-
expect(page).to have_content(product.price)
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
# Regression test for https://github.com/spree/spree/issues/3336
|
|
144
|
-
context "start by customer address" do
|
|
145
|
-
it "completes order fine", js: true do
|
|
146
|
-
click_on "Customer"
|
|
147
|
-
|
|
148
|
-
within "#select-customer" do
|
|
149
|
-
targetted_select2_search user.email, from: "#s2id_customer_search"
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
expect(page).to have_checked_field('order_use_billing')
|
|
153
|
-
fill_in_address
|
|
154
|
-
click_on "Update"
|
|
155
|
-
|
|
156
|
-
# Automatically redirected to Shipments page
|
|
157
|
-
select2_search product.name, from: I18n.t('spree.name_or_sku')
|
|
158
|
-
|
|
159
|
-
click_icon :plus
|
|
160
|
-
|
|
161
|
-
expect(page).to have_css('.stock-item')
|
|
162
|
-
|
|
163
|
-
click_on "Payments"
|
|
164
|
-
click_on "Continue"
|
|
165
|
-
|
|
166
|
-
within(".additional-info") do
|
|
167
|
-
expect(page).to have_content("Confirm")
|
|
168
|
-
end
|
|
169
|
-
end
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
# Regression test for https://github.com/spree/spree/issues/5327
|
|
173
|
-
context "customer with default credit card", js: true do
|
|
174
|
-
let!(:credit_card) { create(:credit_card, user: user) }
|
|
175
|
-
|
|
176
|
-
before do
|
|
177
|
-
user.wallet.add(credit_card)
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
it "transitions to delivery not to complete" do
|
|
181
|
-
add_line_item product.name
|
|
182
|
-
|
|
183
|
-
expect(page).to have_css('.line-item')
|
|
184
|
-
|
|
185
|
-
click_link "Customer"
|
|
186
|
-
targetted_select2 user.email, from: "#s2id_customer_search"
|
|
187
|
-
click_button "Update"
|
|
188
|
-
expect(page).to have_css('.order-state', text: 'Delivery')
|
|
189
|
-
end
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
context "customer with attempted XSS", js: true do
|
|
193
|
-
let(:xss_string) { %(<script>throw("XSS")</script>) }
|
|
194
|
-
before do
|
|
195
|
-
user.update!(email: xss_string)
|
|
196
|
-
end
|
|
197
|
-
it "displays the user's email escaped without executing" do
|
|
198
|
-
click_on "Customer"
|
|
199
|
-
targetted_select2_search user.email, from: "#s2id_customer_search"
|
|
200
|
-
expect(page).to have_field("Customer E-Mail", with: xss_string)
|
|
201
|
-
end
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
context 'with a checkout_zone set as the country of Canada' do
|
|
205
|
-
let!(:canada) { create(:country, iso: 'CA', states_required: true) }
|
|
206
|
-
let!(:canada_state) { create(:state, country: canada) }
|
|
207
|
-
let!(:checkout_zone) { create(:zone, name: 'Checkout Zone', countries: [canada]) }
|
|
208
|
-
|
|
209
|
-
before do
|
|
210
|
-
Spree::Country.update_all(states_required: true)
|
|
211
|
-
stub_spree_preferences(checkout_zone: checkout_zone.name)
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
context 'and default_country_iso of the United States' do
|
|
215
|
-
before do
|
|
216
|
-
stub_spree_preferences(default_country_iso: Spree::Country.find_by!(iso: 'US').iso)
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
it 'the shipping address country select includes only options for Canada' do
|
|
220
|
-
visit spree.new_admin_order_path
|
|
221
|
-
click_link 'Customer'
|
|
222
|
-
within '#shipping' do
|
|
223
|
-
expect(page).to have_select(
|
|
224
|
-
'Country',
|
|
225
|
-
options: ['Canada']
|
|
226
|
-
)
|
|
227
|
-
end
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
it 'does not show any shipping address state' do
|
|
231
|
-
visit spree.new_admin_order_path
|
|
232
|
-
click_link 'Customer'
|
|
233
|
-
within '#shipping' do
|
|
234
|
-
expect(page).to have_select(
|
|
235
|
-
'State',
|
|
236
|
-
disabled: true,
|
|
237
|
-
visible: false,
|
|
238
|
-
options: ['']
|
|
239
|
-
)
|
|
240
|
-
end
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
it 'the billing address country select includes only options for Canada' do
|
|
244
|
-
visit spree.new_admin_order_path
|
|
245
|
-
click_link 'Customer'
|
|
246
|
-
within '#billing' do
|
|
247
|
-
expect(page).to have_select(
|
|
248
|
-
'Country',
|
|
249
|
-
options: ['Canada']
|
|
250
|
-
)
|
|
251
|
-
end
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
it 'does not show any billing address state' do
|
|
255
|
-
visit spree.new_admin_order_path
|
|
256
|
-
click_link 'Customer'
|
|
257
|
-
within '#billing' do
|
|
258
|
-
expect(page).to have_select(
|
|
259
|
-
'State',
|
|
260
|
-
disabled: true,
|
|
261
|
-
visible: false,
|
|
262
|
-
options: ['']
|
|
263
|
-
)
|
|
264
|
-
end
|
|
265
|
-
end
|
|
266
|
-
end
|
|
267
|
-
|
|
268
|
-
context 'and default_country_iso of Canada' do
|
|
269
|
-
before do
|
|
270
|
-
stub_spree_preferences(default_country_iso: Spree::Country.find_by!(iso: 'CA').iso)
|
|
271
|
-
end
|
|
272
|
-
|
|
273
|
-
it 'defaults the shipping address country to Canada' do
|
|
274
|
-
visit spree.new_admin_order_path
|
|
275
|
-
click_link 'Customer'
|
|
276
|
-
within '#shipping' do
|
|
277
|
-
expect(page).to have_select(
|
|
278
|
-
'Country',
|
|
279
|
-
selected: 'Canada',
|
|
280
|
-
options: ['Canada']
|
|
281
|
-
)
|
|
282
|
-
end
|
|
283
|
-
end
|
|
284
|
-
|
|
285
|
-
it 'shows relevant shipping address states' do
|
|
286
|
-
visit spree.new_admin_order_path
|
|
287
|
-
click_link 'Customer'
|
|
288
|
-
within '#shipping' do
|
|
289
|
-
expect(page).to have_select(
|
|
290
|
-
'State',
|
|
291
|
-
options: [''] + canada.states.map(&:name)
|
|
292
|
-
)
|
|
293
|
-
end
|
|
294
|
-
end
|
|
295
|
-
|
|
296
|
-
it 'defaults the billing address country to Canada' do
|
|
297
|
-
visit spree.new_admin_order_path
|
|
298
|
-
click_link 'Customer'
|
|
299
|
-
within '#billing' do
|
|
300
|
-
expect(page).to have_select(
|
|
301
|
-
'Country',
|
|
302
|
-
selected: 'Canada',
|
|
303
|
-
options: ['Canada']
|
|
304
|
-
)
|
|
305
|
-
end
|
|
306
|
-
end
|
|
307
|
-
|
|
308
|
-
it 'shows relevant billing address states' do
|
|
309
|
-
visit spree.new_admin_order_path
|
|
310
|
-
click_link 'Customer'
|
|
311
|
-
within '#billing' do
|
|
312
|
-
expect(page).to have_select(
|
|
313
|
-
'State',
|
|
314
|
-
options: [''] + canada.states.map(&:name)
|
|
315
|
-
)
|
|
316
|
-
end
|
|
317
|
-
end
|
|
318
|
-
end
|
|
319
|
-
end
|
|
320
|
-
|
|
321
|
-
def fill_in_address
|
|
322
|
-
fill_in "First Name", with: "John 99"
|
|
323
|
-
fill_in "Last Name", with: "Doe"
|
|
324
|
-
fill_in "Street Address", with: "100 first lane"
|
|
325
|
-
fill_in "Street Address (cont'd)", with: "#101"
|
|
326
|
-
fill_in "City", with: "Bethesda"
|
|
327
|
-
fill_in "Zip Code", with: "20170"
|
|
328
|
-
select state.name, from: "State"
|
|
329
|
-
fill_in "Phone", with: "123-456-7890"
|
|
330
|
-
end
|
|
331
|
-
end
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
RSpec.describe 'New Refund creation', :js do
|
|
6
|
-
stub_authorization!
|
|
7
|
-
|
|
8
|
-
let(:order) { create :order_ready_to_ship }
|
|
9
|
-
let(:payment) { order.payments.first }
|
|
10
|
-
let(:amount) { '10.99' }
|
|
11
|
-
let!(:reason) { create :refund_reason }
|
|
12
|
-
|
|
13
|
-
it 'creates a new refund' do
|
|
14
|
-
visit spree.new_admin_order_payment_refund_path(order, payment)
|
|
15
|
-
expect(page).not_to have_selector 'td', text: amount
|
|
16
|
-
within '.new_refund' do
|
|
17
|
-
fill_in 'refund_amount', with: amount
|
|
18
|
-
select reason.name, from: 'Reason'
|
|
19
|
-
click_button 'Refund'
|
|
20
|
-
end
|
|
21
|
-
expect(page).to have_content 'Refund has been successfully created!'
|
|
22
|
-
expect(page).to have_selector 'td', text: amount
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
it 'disables the button at submit' do
|
|
26
|
-
visit spree.new_admin_order_payment_refund_path(order, payment)
|
|
27
|
-
page.execute_script "$('form').submit(function(e) { e.preventDefault()})"
|
|
28
|
-
within '.new_refund' do
|
|
29
|
-
fill_in 'refund_amount', with: amount
|
|
30
|
-
select reason.name, from: 'Reason'
|
|
31
|
-
click_button 'Refund'
|
|
32
|
-
expect(find('input[type="submit"]')).to be_disabled
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
@@ -1,581 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'spec_helper'
|
|
4
|
-
|
|
5
|
-
describe "Order Details", type: :feature, js: true do
|
|
6
|
-
include OrderFeatureHelper
|
|
7
|
-
|
|
8
|
-
let!(:stock_location) { create(:stock_location_with_items) }
|
|
9
|
-
let!(:product) { create(:product, name: 'spree t-shirt', price: 20.00) }
|
|
10
|
-
let(:order) { create(:order, state: 'complete', completed_at: "2011-02-01 12:36:15", number: "R100") }
|
|
11
|
-
let(:state) { create(:state) }
|
|
12
|
-
let(:line_item) { order.line_items.first }
|
|
13
|
-
|
|
14
|
-
let!(:shipment1) do
|
|
15
|
-
order.shipments.create(stock_location_id: stock_location.id)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
before do
|
|
19
|
-
order.contents.add(product.master, 2)
|
|
20
|
-
# order.contents.add causes things (like line items & shipments) to get
|
|
21
|
-
# cached, and these are going to change during this spec so we go ahead and
|
|
22
|
-
# reload now
|
|
23
|
-
order.reload
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
context 'as Admin' do
|
|
27
|
-
stub_authorization!
|
|
28
|
-
|
|
29
|
-
context "cart edit page" do
|
|
30
|
-
let(:track_inventory) { true }
|
|
31
|
-
let(:backorderable) { true }
|
|
32
|
-
let(:count_on_hand) { 100 }
|
|
33
|
-
|
|
34
|
-
before do
|
|
35
|
-
product.master.update_columns(track_inventory: track_inventory)
|
|
36
|
-
product.master.stock_items.update_all(count_on_hand: count_on_hand, backorderable: backorderable)
|
|
37
|
-
|
|
38
|
-
visit spree.cart_admin_order_path(order)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it "should allow me to edit order details" do
|
|
42
|
-
expect(page).to have_content("spree t-shirt")
|
|
43
|
-
expect(page).to have_content("$40.00")
|
|
44
|
-
|
|
45
|
-
within('tr', text: line_item.sku) do
|
|
46
|
-
click_icon :edit
|
|
47
|
-
fill_in "quantity", with: "1"
|
|
48
|
-
end
|
|
49
|
-
click_icon :ok
|
|
50
|
-
|
|
51
|
-
within("#order_total") do
|
|
52
|
-
expect(page).to have_content("$20.00")
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it "can add an item" do
|
|
57
|
-
add_line_item "spree t-shirt", quantity: 2
|
|
58
|
-
|
|
59
|
-
within("#order_total") do
|
|
60
|
-
expect(page).to have_content("$80.00")
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
it "can remove an item from a shipment" do
|
|
65
|
-
expect(page).to have_content("spree t-shirt")
|
|
66
|
-
|
|
67
|
-
within('tr', text: line_item.sku) do
|
|
68
|
-
accept_confirm "Are you sure you want to delete this record?" do
|
|
69
|
-
click_icon :trash
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
expect(page).not_to have_content("spree t-shirt")
|
|
74
|
-
|
|
75
|
-
# Should have a new item row
|
|
76
|
-
expect(page).to have_field('quantity')
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
# Regression test for https://github.com/spree/spree/issues/3862
|
|
80
|
-
it "can cancel removing an item from a shipment" do
|
|
81
|
-
expect(page).to have_content("spree t-shirt")
|
|
82
|
-
|
|
83
|
-
within('tr', text: line_item.sku) do
|
|
84
|
-
# Click "cancel" on confirmation dialog
|
|
85
|
-
dismiss_confirm "Are you sure you want to delete this record?" do
|
|
86
|
-
click_icon :trash
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
expect(page).to have_content("spree t-shirt")
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
it "can add tracking information" do
|
|
94
|
-
visit spree.edit_admin_order_path(order)
|
|
95
|
-
|
|
96
|
-
within("tr", text: "Tracking Number") do
|
|
97
|
-
click_icon :edit
|
|
98
|
-
fill_in "tracking", with: "FOOBAR"
|
|
99
|
-
click_icon :check
|
|
100
|
-
|
|
101
|
-
expect(page).not_to have_css("input")
|
|
102
|
-
expect(page).to have_content("Tracking Number FOOBAR")
|
|
103
|
-
end
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
context "with a completed order" do
|
|
107
|
-
let!(:order) { create(:completed_order_with_totals) }
|
|
108
|
-
let(:shipment1) { order.shipments[0] }
|
|
109
|
-
|
|
110
|
-
it "can change the shipping method" do
|
|
111
|
-
visit spree.edit_admin_order_path(order)
|
|
112
|
-
|
|
113
|
-
within("tr", text: "Shipping Method") do
|
|
114
|
-
click_icon :edit
|
|
115
|
-
select "UPS Ground $100.00"
|
|
116
|
-
click_icon :check
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
expect(page).not_to have_css('#selected_shipping_rate_id')
|
|
120
|
-
expect(page).to have_content("UPS Ground")
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
it "can use admin-only shipping methods" do
|
|
124
|
-
create(:shipping_method, name: "Admin Free Shipping", cost: 0, available_to_users: false)
|
|
125
|
-
|
|
126
|
-
visit spree.edit_admin_order_path(order)
|
|
127
|
-
|
|
128
|
-
within("tr", text: "Shipping Method") do
|
|
129
|
-
click_icon :edit
|
|
130
|
-
select "Admin Free Shipping $0.00"
|
|
131
|
-
click_icon :check
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
expect(page).not_to have_css('#selected_shipping_rate_id')
|
|
135
|
-
expect(page).to have_no_content("UPS Ground")
|
|
136
|
-
expect(page).to have_content("Admin Free Shipping")
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
it "will show the variant sku" do
|
|
140
|
-
visit spree.edit_admin_order_path(order)
|
|
141
|
-
sku = order.line_items.first.variant.sku
|
|
142
|
-
expect(page).to have_content("SKU: #{sku}")
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
context "with special_instructions present" do
|
|
147
|
-
let(:order) { create(:order, state: 'complete', completed_at: "2011-02-01 12:36:15", number: "R100", special_instructions: "Very special instructions here") }
|
|
148
|
-
it "will show the special_instructions" do
|
|
149
|
-
visit spree.edit_admin_order_path(order)
|
|
150
|
-
expect(page).to have_content("Very special instructions here")
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
context "variant doesn't track inventory" do
|
|
155
|
-
let(:track_inventory) { false }
|
|
156
|
-
let(:backorderable) { false }
|
|
157
|
-
let(:count_on_hand) { 0 }
|
|
158
|
-
|
|
159
|
-
it "adds variant to order just fine" do
|
|
160
|
-
add_line_item "spree t-shirt"
|
|
161
|
-
|
|
162
|
-
within(".line-items") do
|
|
163
|
-
expect(page).to have_content("spree t-shirt")
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
context "variant out of stock and not backorderable" do
|
|
169
|
-
let(:backorderable) { false }
|
|
170
|
-
let(:count_on_hand) { 0 }
|
|
171
|
-
|
|
172
|
-
it "doesn't display the out of stock variant in the search results" do
|
|
173
|
-
click_on 'Add Item'
|
|
174
|
-
select2_search_without_selection product.name, from: ".select-variant"
|
|
175
|
-
|
|
176
|
-
expect(page).to have_selector('.select2-no-results')
|
|
177
|
-
within(".select2-no-results") do
|
|
178
|
-
expect(page).to have_content("No matches found")
|
|
179
|
-
end
|
|
180
|
-
end
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
context 'Shipment edit page' do
|
|
185
|
-
let!(:stock_location2) { create(:stock_location_with_items, name: 'Clarksville') }
|
|
186
|
-
|
|
187
|
-
before do
|
|
188
|
-
product.master.stock_items.first.update_column(:backorderable, true)
|
|
189
|
-
product.master.stock_items.first.update_column(:count_on_hand, 100)
|
|
190
|
-
product.master.stock_items.last.update_column(:count_on_hand, 100)
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
context 'splitting to location' do
|
|
194
|
-
it 'should warn you if you have not selected a location or shipment' do
|
|
195
|
-
visit spree.edit_admin_order_path(order)
|
|
196
|
-
|
|
197
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
|
198
|
-
accept_alert 'Please select the split destination.' do
|
|
199
|
-
click_icon :ok
|
|
200
|
-
end
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
context 'there is enough stock at the other location' do
|
|
204
|
-
it 'should allow me to make a split' do
|
|
205
|
-
expect(order.shipments.count).to eq(1)
|
|
206
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
|
207
|
-
|
|
208
|
-
visit spree.edit_admin_order_path(order)
|
|
209
|
-
|
|
210
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
|
211
|
-
complete_split_to(stock_location2)
|
|
212
|
-
|
|
213
|
-
expect(page).to have_css('.shipment', count: 2)
|
|
214
|
-
|
|
215
|
-
expect(order.shipments.count).to eq(2)
|
|
216
|
-
expect(order.shipments.last.backordered?).to eq(false)
|
|
217
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(1)
|
|
218
|
-
expect(order.shipments.last.inventory_units_for(product.master).count).to eq(1)
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
it 'should allow me to make a transfer via splitting off all stock' do
|
|
222
|
-
visit spree.edit_admin_order_path(order)
|
|
223
|
-
|
|
224
|
-
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
|
225
|
-
|
|
226
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
|
227
|
-
complete_split_to(stock_location2, quantity: 2)
|
|
228
|
-
|
|
229
|
-
expect(page).to have_content("Pending package from 'Clarksville'")
|
|
230
|
-
|
|
231
|
-
expect(order.shipments.count).to eq(1)
|
|
232
|
-
expect(order.shipments.last.backordered?).to eq(false)
|
|
233
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
|
234
|
-
expect(order.shipments.first.stock_location.id).to eq(stock_location2.id)
|
|
235
|
-
end
|
|
236
|
-
|
|
237
|
-
it 'should not allow me to split more than I had in the original shipment' do
|
|
238
|
-
visit spree.edit_admin_order_path(order)
|
|
239
|
-
|
|
240
|
-
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
|
241
|
-
|
|
242
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
|
243
|
-
complete_split_to(stock_location2, quantity: 5)
|
|
244
|
-
|
|
245
|
-
expect(page).to have_content("Pending package from 'Clarksville'")
|
|
246
|
-
|
|
247
|
-
expect(order.shipments.count).to eq(1)
|
|
248
|
-
expect(order.shipments.last.backordered?).to eq(false)
|
|
249
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
|
250
|
-
expect(order.shipments.first.stock_location.id).to eq(stock_location2.id)
|
|
251
|
-
end
|
|
252
|
-
|
|
253
|
-
it 'should not allow less than or equal to zero qty' do
|
|
254
|
-
visit spree.edit_admin_order_path(order)
|
|
255
|
-
|
|
256
|
-
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
|
257
|
-
|
|
258
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
|
259
|
-
|
|
260
|
-
accept_alert "Quantity must be greater than 0" do
|
|
261
|
-
complete_split_to(stock_location2, quantity: 0)
|
|
262
|
-
end
|
|
263
|
-
|
|
264
|
-
expect(order.shipments.count).to eq(1)
|
|
265
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
|
266
|
-
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
|
267
|
-
|
|
268
|
-
fill_in 'item_quantity', with: -1
|
|
269
|
-
|
|
270
|
-
accept_alert "Quantity must be greater than 0" do
|
|
271
|
-
click_icon :ok
|
|
272
|
-
end
|
|
273
|
-
|
|
274
|
-
expect(order.shipments.count).to eq(1)
|
|
275
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
|
276
|
-
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
|
277
|
-
end
|
|
278
|
-
|
|
279
|
-
context 'A shipment has shipped' do
|
|
280
|
-
it 'should not show or let me back to the cart page, nor show the shipment edit buttons' do
|
|
281
|
-
order = create(:order, state: 'payment')
|
|
282
|
-
order.shipments.create!(stock_location_id: stock_location.id, state: 'shipped')
|
|
283
|
-
|
|
284
|
-
visit spree.cart_admin_order_path(order)
|
|
285
|
-
|
|
286
|
-
expect(page.current_path).to eq(spree.edit_admin_order_path(order))
|
|
287
|
-
expect(page).not_to have_text 'Cart'
|
|
288
|
-
expect(page).not_to have_selector('.fa-arrows-h')
|
|
289
|
-
expect(page).not_to have_selector('.fa-trash')
|
|
290
|
-
end
|
|
291
|
-
end
|
|
292
|
-
end
|
|
293
|
-
|
|
294
|
-
context 'there is not enough stock at the other location' do
|
|
295
|
-
context 'and it cannot backorder' do
|
|
296
|
-
it 'should not allow me to split stock' do
|
|
297
|
-
product.master.stock_items.last.update_column(:backorderable, false)
|
|
298
|
-
product.master.stock_items.last.update_column(:count_on_hand, 0)
|
|
299
|
-
|
|
300
|
-
visit spree.edit_admin_order_path(order)
|
|
301
|
-
|
|
302
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
|
303
|
-
accept_alert "Desired shipment not enough stock in desired stock location" do
|
|
304
|
-
complete_split_to(stock_location2, quantity: 2)
|
|
305
|
-
end
|
|
306
|
-
|
|
307
|
-
expect(order.shipments.count).to eq(1)
|
|
308
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
|
309
|
-
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
|
310
|
-
end
|
|
311
|
-
end
|
|
312
|
-
|
|
313
|
-
context 'but it can backorder' do
|
|
314
|
-
it 'should allow me to split and backorder the stock' do
|
|
315
|
-
product.master.stock_items.last.update_column(:count_on_hand, 0)
|
|
316
|
-
product.master.stock_items.last.update_column(:backorderable, true)
|
|
317
|
-
|
|
318
|
-
visit spree.edit_admin_order_path(order)
|
|
319
|
-
|
|
320
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
|
321
|
-
complete_split_to(stock_location2, quantity: 2)
|
|
322
|
-
|
|
323
|
-
expect(page).to have_content("Pending package from 'Clarksville'")
|
|
324
|
-
|
|
325
|
-
expect(order.shipments.count).to eq(1)
|
|
326
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
|
327
|
-
expect(order.shipments.first.stock_location.id).to eq(stock_location2.id)
|
|
328
|
-
end
|
|
329
|
-
end
|
|
330
|
-
end
|
|
331
|
-
|
|
332
|
-
context 'multiple items in cart' do
|
|
333
|
-
it 'should have no problem splitting if multiple items are in the from shipment' do
|
|
334
|
-
order.contents.add(create(:variant), 2)
|
|
335
|
-
order.reload
|
|
336
|
-
|
|
337
|
-
visit spree.edit_admin_order_path(order)
|
|
338
|
-
|
|
339
|
-
expect(order.shipments.count).to eq(1)
|
|
340
|
-
expect(order.shipments.first.manifest.count).to eq(2)
|
|
341
|
-
|
|
342
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
|
343
|
-
complete_split_to(stock_location2)
|
|
344
|
-
|
|
345
|
-
expect(page).to have_css('.shipment', count: 2)
|
|
346
|
-
|
|
347
|
-
expect(order.shipments.count).to eq(2)
|
|
348
|
-
expect(order.shipments.last.backordered?).to eq(false)
|
|
349
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(1)
|
|
350
|
-
expect(order.shipments.last.inventory_units_for(product.master).count).to eq(1)
|
|
351
|
-
end
|
|
352
|
-
end
|
|
353
|
-
end
|
|
354
|
-
|
|
355
|
-
context 'removing an item' do
|
|
356
|
-
let!(:shipment2) { order.shipments.create(stock_location_id: stock_location2.id) }
|
|
357
|
-
|
|
358
|
-
it "removes only the one item" do
|
|
359
|
-
order.line_items[0].inventory_units[0].update!(shipment: shipment2)
|
|
360
|
-
visit spree.edit_admin_order_path(order)
|
|
361
|
-
|
|
362
|
-
expect(page).to have_css('.stock-item', count: 2)
|
|
363
|
-
|
|
364
|
-
within '[data-hook=admin_shipment_form]', text: shipment2.number do
|
|
365
|
-
accept_confirm "Are you sure you want to delete this record?" do
|
|
366
|
-
click_icon :trash
|
|
367
|
-
end
|
|
368
|
-
end
|
|
369
|
-
|
|
370
|
-
expect(page).to have_css('.stock-item', count: 1)
|
|
371
|
-
end
|
|
372
|
-
end
|
|
373
|
-
|
|
374
|
-
context 'splitting to shipment' do
|
|
375
|
-
let!(:shipment2) { order.shipments.create(stock_location_id: stock_location2.id) }
|
|
376
|
-
|
|
377
|
-
it 'should delete the old shipment if enough are split off' do
|
|
378
|
-
expect(order.shipments.count).to eq(2)
|
|
379
|
-
|
|
380
|
-
visit spree.edit_admin_order_path(order)
|
|
381
|
-
|
|
382
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
|
383
|
-
complete_split_to(shipment2, quantity: 2)
|
|
384
|
-
|
|
385
|
-
expect(page).not_to have_content(/Move .* to/)
|
|
386
|
-
|
|
387
|
-
expect(page).to have_css("#shipment_#{shipment2.id}", count: 1)
|
|
388
|
-
|
|
389
|
-
expect(order.shipments.count).to eq(1)
|
|
390
|
-
expect(order.shipments.last.inventory_units_for(product.master).count).to eq(2)
|
|
391
|
-
end
|
|
392
|
-
|
|
393
|
-
context 'receiving shipment can not backorder' do
|
|
394
|
-
before { product.master.stock_items.last.update_column(:backorderable, false) }
|
|
395
|
-
|
|
396
|
-
it 'should not allow a split if the receiving shipment qty plus the incoming is greater than the count_on_hand' do
|
|
397
|
-
expect(order.shipments.count).to eq(2)
|
|
398
|
-
|
|
399
|
-
visit spree.edit_admin_order_path(order)
|
|
400
|
-
expect(page).to have_css('.item-name', text: product.name, count: 1)
|
|
401
|
-
|
|
402
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
|
403
|
-
complete_split_to(shipment2, quantity: 1)
|
|
404
|
-
|
|
405
|
-
expect(page).to have_css('.item-name', text: product.name, count: 2)
|
|
406
|
-
|
|
407
|
-
within(all('.stock-contents', count: 2).first) do
|
|
408
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
|
409
|
-
|
|
410
|
-
accept_alert("Desired shipment not enough stock in desired stock location") do
|
|
411
|
-
complete_split_to(shipment2, quantity: 200)
|
|
412
|
-
end
|
|
413
|
-
end
|
|
414
|
-
|
|
415
|
-
expect(order.shipments.count).to eq(2)
|
|
416
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(1)
|
|
417
|
-
expect(order.shipments.last.inventory_units_for(product.master).count).to eq(1)
|
|
418
|
-
end
|
|
419
|
-
|
|
420
|
-
it 'should not allow a shipment to split stock to itself' do
|
|
421
|
-
visit spree.edit_admin_order_path(order)
|
|
422
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
|
423
|
-
click_on 'Choose Location'
|
|
424
|
-
within '.select2-results' do
|
|
425
|
-
expect(page).to have_content(shipment2.number)
|
|
426
|
-
expect(page).not_to have_content(shipment1.number)
|
|
427
|
-
end
|
|
428
|
-
end
|
|
429
|
-
|
|
430
|
-
it 'should split fine if more than one line_item is in the receiving shipment' do
|
|
431
|
-
variant2 = create(:variant)
|
|
432
|
-
order.contents.add(variant2, 2, shipment: shipment2)
|
|
433
|
-
order.reload
|
|
434
|
-
|
|
435
|
-
visit spree.edit_admin_order_path(order)
|
|
436
|
-
|
|
437
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
|
438
|
-
complete_split_to(shipment2, quantity: 1)
|
|
439
|
-
|
|
440
|
-
expect(page).not_to have_content(/Move .* to/)
|
|
441
|
-
expect(page).to have_css('.shipment', count: 2)
|
|
442
|
-
|
|
443
|
-
expect(order.shipments.count).to eq(2)
|
|
444
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq 1
|
|
445
|
-
expect(order.shipments.last.inventory_units_for(product.master).count).to eq 1
|
|
446
|
-
expect(order.shipments.first.inventory_units_for(variant2).count).to eq 0
|
|
447
|
-
expect(order.shipments.last.inventory_units_for(variant2).count).to eq 2
|
|
448
|
-
end
|
|
449
|
-
end
|
|
450
|
-
|
|
451
|
-
context 'receiving shipment can backorder' do
|
|
452
|
-
it 'should add more to the backorder' do
|
|
453
|
-
shipment1.inventory_units.update_all(state: :on_hand)
|
|
454
|
-
product.master.stock_items.last.update_column(:backorderable, true)
|
|
455
|
-
product.master.stock_items.last.update_column(:count_on_hand, 0)
|
|
456
|
-
expect(shipment2.reload).not_to be_backordered
|
|
457
|
-
|
|
458
|
-
visit spree.edit_admin_order_path(order)
|
|
459
|
-
|
|
460
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
|
461
|
-
complete_split_to(shipment2, quantity: 1)
|
|
462
|
-
|
|
463
|
-
expect(page).to have_content("1 x Backordered")
|
|
464
|
-
|
|
465
|
-
within('.stock-contents', text: "1 x On hand") do
|
|
466
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
|
467
|
-
complete_split_to(shipment2, quantity: 1)
|
|
468
|
-
end
|
|
469
|
-
|
|
470
|
-
# Empty shipment should be removed
|
|
471
|
-
expect(page).to have_css('.stock-contents', count: 1)
|
|
472
|
-
expect(page).to have_content("2 x Backordered")
|
|
473
|
-
end
|
|
474
|
-
end
|
|
475
|
-
end
|
|
476
|
-
|
|
477
|
-
describe 'line item sort order' do
|
|
478
|
-
let(:product2) { create(:product) }
|
|
479
|
-
let(:product3) { create(:product) }
|
|
480
|
-
|
|
481
|
-
before do
|
|
482
|
-
# grab this one first and then create others that should end up before
|
|
483
|
-
# and after
|
|
484
|
-
@middle_line_item = order.line_items[0]
|
|
485
|
-
|
|
486
|
-
@first_line_item = order.contents.add(product2.master)
|
|
487
|
-
@first_line_item.update_columns(created_at: 1.day.ago)
|
|
488
|
-
@last_line_item = order.contents.add(product3.master)
|
|
489
|
-
@last_line_item.update_columns(created_at: 1.day.from_now)
|
|
490
|
-
end
|
|
491
|
-
|
|
492
|
-
it 'orders the items in a shipment by created_at' do
|
|
493
|
-
visit spree.edit_admin_order_path(order)
|
|
494
|
-
|
|
495
|
-
stock_items = page.all(:css, '.stock-item', count: 3)
|
|
496
|
-
|
|
497
|
-
expect(stock_items[0]).to have_text(@first_line_item.variant.sku)
|
|
498
|
-
expect(stock_items[1]).to have_text(@middle_line_item.variant.sku)
|
|
499
|
-
expect(stock_items[2]).to have_text(@last_line_item.variant.sku)
|
|
500
|
-
end
|
|
501
|
-
end
|
|
502
|
-
end
|
|
503
|
-
end
|
|
504
|
-
|
|
505
|
-
context 'with only read permissions' do
|
|
506
|
-
before do
|
|
507
|
-
allow_any_instance_of(Spree::Admin::BaseController).to receive(:try_spree_current_user).and_return(nil)
|
|
508
|
-
end
|
|
509
|
-
|
|
510
|
-
custom_authorization! do |_user|
|
|
511
|
-
can [:admin, :index, :read, :edit], Spree::Order
|
|
512
|
-
end
|
|
513
|
-
it "should not display forbidden links" do
|
|
514
|
-
visit spree.edit_admin_order_path(order)
|
|
515
|
-
|
|
516
|
-
expect(page).not_to have_button('cancel')
|
|
517
|
-
expect(page).not_to have_button('Resend')
|
|
518
|
-
|
|
519
|
-
# Order Tabs
|
|
520
|
-
expect(page).not_to have_link('Adjustments')
|
|
521
|
-
expect(page).not_to have_link('Payments')
|
|
522
|
-
expect(page).not_to have_link('Return Authorizations')
|
|
523
|
-
|
|
524
|
-
# Order item actions
|
|
525
|
-
expect(page).not_to have_css('.delete-item')
|
|
526
|
-
expect(page).not_to have_css('.split-item')
|
|
527
|
-
expect(page).not_to have_css('.edit-tracking')
|
|
528
|
-
|
|
529
|
-
expect(page).not_to have_css('#add-line-item')
|
|
530
|
-
end
|
|
531
|
-
end
|
|
532
|
-
|
|
533
|
-
context 'as Fakedispatch' do
|
|
534
|
-
custom_authorization! do |_user|
|
|
535
|
-
# allow dispatch to :admin, :index, and :edit on Spree::Order
|
|
536
|
-
can [:admin, :edit, :index, :read], Spree::Order
|
|
537
|
-
# allow dispatch to :index, :show, :create and :update shipments on the admin
|
|
538
|
-
can [:admin, :manage, :read, :ship], Spree::Shipment
|
|
539
|
-
end
|
|
540
|
-
|
|
541
|
-
before do
|
|
542
|
-
allow(Spree.user_class).to receive(:find_by).
|
|
543
|
-
with(hash_including(:spree_api_key)).
|
|
544
|
-
and_return(Spree.user_class.new)
|
|
545
|
-
end
|
|
546
|
-
|
|
547
|
-
it 'should not display order tabs or edit buttons without ability' do
|
|
548
|
-
visit spree.edit_admin_order_path(order)
|
|
549
|
-
|
|
550
|
-
# Order Tabs
|
|
551
|
-
expect(page).not_to have_link('Adjustments')
|
|
552
|
-
expect(page).not_to have_link('Payments')
|
|
553
|
-
expect(page).not_to have_link('Return Authorizations')
|
|
554
|
-
end
|
|
555
|
-
|
|
556
|
-
it "can change the shipping method" do
|
|
557
|
-
order = create(:completed_order_with_totals)
|
|
558
|
-
visit spree.edit_admin_order_path(order)
|
|
559
|
-
within("tr", text: "Shipping Method") do
|
|
560
|
-
click_icon :edit
|
|
561
|
-
end
|
|
562
|
-
select "UPS Ground $100.00"
|
|
563
|
-
click_icon :check
|
|
564
|
-
|
|
565
|
-
expect(page).not_to have_css('#selected_shipping_rate_id')
|
|
566
|
-
expect(page).to have_content("UPS Ground")
|
|
567
|
-
end
|
|
568
|
-
|
|
569
|
-
it 'can ship' do
|
|
570
|
-
order = create(:order_ready_to_ship)
|
|
571
|
-
order.refresh_shipment_rates
|
|
572
|
-
visit spree.edit_admin_order_path(order)
|
|
573
|
-
|
|
574
|
-
find(".ship-shipment-button").click
|
|
575
|
-
|
|
576
|
-
within '.carton-state' do
|
|
577
|
-
expect(page).to have_content('Shipped')
|
|
578
|
-
end
|
|
579
|
-
end
|
|
580
|
-
end
|
|
581
|
-
end
|