solidus_backend 2.10.5 → 2.11.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_backend might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree/backend.js +4 -1
- data/app/assets/javascripts/spree/backend/adjustments.js +1 -1
- data/app/assets/javascripts/spree/backend/admin.js +18 -29
- data/app/assets/javascripts/spree/backend/collections/states.js +1 -1
- data/app/assets/javascripts/spree/backend/components/selectable_table.js +5 -0
- data/app/assets/javascripts/spree/backend/components/selectable_table/return_items.js +5 -0
- data/app/assets/javascripts/spree/backend/components/selectable_table/summary.js +7 -0
- data/app/assets/javascripts/spree/backend/components/sortable_table.js +31 -25
- data/app/assets/javascripts/spree/backend/models/order.js +3 -3
- data/app/assets/javascripts/spree/backend/models/payment.js +1 -1
- data/app/assets/javascripts/spree/backend/models/shipment.js +1 -1
- data/app/assets/javascripts/spree/backend/models/stock_item.js +1 -1
- data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +2 -2
- data/app/assets/javascripts/spree/backend/option_value_picker.js +2 -2
- data/app/assets/javascripts/spree/backend/product_picker.js +2 -2
- data/app/assets/javascripts/spree/backend/routes.js +40 -21
- data/app/assets/javascripts/spree/backend/shipments.js +5 -5
- data/app/assets/javascripts/spree/backend/shipping_methods/stock_locations_picker.js +18 -0
- data/app/assets/javascripts/spree/backend/stock_management.js +4 -2
- data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +2 -2
- data/app/assets/javascripts/spree/backend/taxons.js +3 -3
- data/app/assets/javascripts/spree/backend/templates/index.js +2 -0
- data/app/assets/javascripts/spree/backend/templates/orders/customer_details/autocomplete.hbs +2 -2
- data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +5 -1
- data/app/assets/javascripts/spree/backend/templates/tables/return_item_sum_amount.hbs +7 -0
- data/app/assets/javascripts/spree/backend/templates/tables/selectable_label.hbs +6 -0
- data/app/assets/javascripts/spree/backend/user_picker.js +3 -4
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js +2 -2
- data/app/assets/javascripts/spree/backend/views/cart/empty_cart_button.js +2 -2
- data/app/assets/javascripts/spree/backend/views/index.js +4 -0
- data/app/assets/javascripts/spree/backend/views/order/address.js +1 -1
- data/app/assets/javascripts/spree/backend/views/order/customer_select.js +2 -3
- data/app/assets/javascripts/spree/backend/views/order/details_adjustments.js +4 -1
- data/app/assets/javascripts/spree/backend/views/stock/edit_stock_item_row.js +4 -0
- data/app/assets/javascripts/spree/backend/views/tables/return_items.js +9 -0
- data/app/assets/javascripts/spree/backend/views/tables/selectable_table.js +70 -0
- data/app/assets/javascripts/spree/backend/views/tables/selectable_table/sum_return_item_amount.js +32 -0
- data/app/assets/javascripts/spree/backend/views/tables/selectable_table/summary.js +45 -0
- data/app/assets/stylesheets/spree/backend/components/_navigation.scss +4 -5
- data/app/assets/stylesheets/spree/backend/sections/_orders.scss +5 -1
- data/app/assets/stylesheets/spree/backend/sections/_style_guide.scss +4 -0
- data/app/assets/stylesheets/spree/backend/shared/_forms.scss +1 -0
- data/app/controllers/spree/admin/base_controller.rb +6 -0
- data/app/controllers/spree/admin/cancellations_controller.rb +2 -0
- data/app/controllers/spree/admin/customer_returns_controller.rb +4 -4
- data/app/controllers/spree/admin/images_controller.rb +2 -1
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +2 -0
- data/app/controllers/spree/admin/orders_controller.rb +7 -2
- data/app/controllers/spree/admin/payments_controller.rb +3 -1
- data/app/controllers/spree/admin/product_properties_controller.rb +1 -1
- data/app/controllers/spree/admin/products_controller.rb +18 -24
- data/app/controllers/spree/admin/promotion_codes_controller.rb +9 -4
- data/app/controllers/spree/admin/refunds_controller.rb +19 -0
- data/app/controllers/spree/admin/resource_controller.rb +27 -7
- data/app/controllers/spree/admin/return_authorizations_controller.rb +1 -1
- data/app/controllers/spree/admin/root_controller.rb +1 -1
- data/app/controllers/spree/admin/search_controller.rb +1 -2
- data/app/controllers/spree/admin/stock_items_controller.rb +6 -5
- data/app/controllers/spree/admin/stock_locations_controller.rb +4 -0
- data/app/controllers/spree/admin/stock_movements_controller.rb +7 -0
- data/app/controllers/spree/admin/taxons_controller.rb +12 -1
- data/app/controllers/spree/admin/users/api_key_controller.rb +29 -0
- data/app/controllers/spree/admin/users_controller.rb +37 -20
- data/app/controllers/spree/admin/variants_controller.rb +4 -2
- data/app/controllers/spree/admin/zones_controller.rb +1 -1
- data/app/helpers/spree/admin/base_helper.rb +4 -0
- data/app/helpers/spree/admin/customer_returns_helper.rb +1 -1
- data/app/helpers/spree/admin/navigation_helper.rb +1 -1
- data/app/helpers/spree/admin/orders_helper.rb +8 -4
- data/app/helpers/spree/admin/stock_movements_helper.rb +8 -4
- data/app/views/spree/admin/customer_returns/_return_item_selection.html.erb +2 -3
- data/app/views/spree/admin/images/index.html.erb +25 -21
- data/app/views/spree/admin/option_types/_option_value_fields.html.erb +8 -1
- data/app/views/spree/admin/option_types/edit.html.erb +3 -1
- data/app/views/spree/admin/orders/customer_details/_form.html.erb +13 -13
- data/app/views/spree/admin/orders/index.html.erb +23 -13
- data/app/views/spree/admin/payment_methods/_form.html.erb +7 -2
- data/app/views/spree/admin/payments/index.html.erb +3 -1
- data/app/views/spree/admin/prices/_master_variant_table.html.erb +3 -3
- data/app/views/spree/admin/prices/_table.html.erb +3 -3
- data/app/views/spree/admin/product_properties/_product_property_fields.html.erb +7 -2
- data/app/views/spree/admin/product_properties/index.html.erb +14 -2
- data/app/views/spree/admin/products/_form.html.erb +13 -2
- data/app/views/spree/admin/products/index.html.erb +1 -1
- data/app/views/spree/admin/promotion_codes/index.html.erb +1 -1
- data/app/views/spree/admin/promotions/_actions.html.erb +1 -1
- data/app/views/spree/admin/promotions/_activations_new.html.erb +1 -1
- data/app/views/spree/admin/promotions/_rules.html.erb +1 -1
- data/app/views/spree/admin/promotions/edit.html.erb +2 -2
- data/app/views/spree/admin/promotions/index.html.erb +12 -5
- data/app/views/spree/admin/return_authorizations/_form.html.erb +3 -10
- data/app/views/spree/admin/return_authorizations/index.html.erb +1 -1
- data/app/views/spree/admin/search/users.json.jbuilder +15 -1
- data/app/views/spree/admin/shared/_address.html.erb +6 -6
- data/app/views/spree/admin/shared/_address_form.html.erb +15 -8
- data/app/views/spree/admin/shared/_order_submenu.html.erb +4 -4
- data/app/views/spree/admin/shared/_payments_tabs.html.erb +1 -1
- data/app/views/spree/admin/shared/_settings_checkout_tabs.html.erb +5 -5
- data/app/views/spree/admin/shared/_settings_sub_menu.html.erb +6 -6
- data/app/views/spree/admin/shared/_shipping_tabs.html.erb +3 -3
- data/app/views/spree/admin/shared/_taxes_tabs.html.erb +2 -2
- data/app/views/spree/admin/shared/preference_fields/_encrypted_string.html.erb +12 -0
- data/app/views/spree/admin/shipping_methods/_form.html.erb +18 -0
- data/app/views/spree/admin/stock_items/_stock_management.html.erb +1 -1
- data/app/views/spree/admin/stock_locations/edit.html.erb +1 -1
- data/app/views/spree/admin/stock_locations/index.html.erb +3 -1
- data/app/views/spree/admin/stock_movements/index.html.erb +30 -1
- data/app/views/spree/admin/stores/_form.html.erb +6 -0
- data/app/views/spree/admin/style_guide/topics/tables/_building_tables.html.erb +27 -3
- data/app/views/spree/admin/tax_categories/_form.html.erb +1 -0
- data/app/views/spree/admin/users/_form.html.erb +2 -2
- data/app/views/spree/admin/users/_tabs.html.erb +1 -1
- data/app/views/spree/admin/users/edit.html.erb +4 -4
- data/app/views/spree/admin/users/items.html.erb +5 -3
- data/app/views/spree/admin/users/orders.html.erb +5 -3
- data/app/views/spree/admin/variants/_table_filter.html.erb +1 -1
- data/app/views/spree/admin/variants/index.html.erb +2 -2
- data/config/initializers/form_builder.rb +2 -2
- data/lib/spree/backend/engine.rb +0 -2
- data/lib/spree/backend_configuration.rb +14 -1
- data/solidus_backend.gemspec +4 -4
- metadata +21 -120
- data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +0 -35
- data/script/rails +0 -10
- data/spec/controllers/spree/admin/base_controller_spec.rb +0 -26
- data/spec/controllers/spree/admin/cancellations_controller_spec.rb +0 -83
- data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +0 -235
- data/spec/controllers/spree/admin/locale_controller_spec.rb +0 -45
- data/spec/controllers/spree/admin/missing_products_controller_spec.rb +0 -18
- data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +0 -128
- data/spec/controllers/spree/admin/orders_controller_spec.rb +0 -408
- data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +0 -95
- data/spec/controllers/spree/admin/payments_controller_spec.rb +0 -194
- data/spec/controllers/spree/admin/prices_controller_spec.rb +0 -45
- data/spec/controllers/spree/admin/product_properties_controller_spec.rb +0 -71
- data/spec/controllers/spree/admin/products_controller_spec.rb +0 -270
- data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +0 -23
- data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +0 -32
- data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +0 -36
- data/spec/controllers/spree/admin/promotions_controller_spec.rb +0 -122
- data/spec/controllers/spree/admin/refunds_controller_spec.rb +0 -35
- data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +0 -137
- data/spec/controllers/spree/admin/resource_controller_spec.rb +0 -201
- data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +0 -291
- data/spec/controllers/spree/admin/return_items_controller_spec.rb +0 -29
- data/spec/controllers/spree/admin/root_controller_spec.rb +0 -43
- data/spec/controllers/spree/admin/search_controller_spec.rb +0 -106
- data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +0 -16
- data/spec/controllers/spree/admin/stock_items_controller_spec.rb +0 -52
- data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +0 -44
- data/spec/controllers/spree/admin/store_credits_controller_spec.rb +0 -311
- data/spec/controllers/spree/admin/users_controller_spec.rb +0 -287
- data/spec/controllers/spree/admin/variants_controller_spec.rb +0 -71
- data/spec/features/admin/configuration/payment_methods_spec.rb +0 -176
- data/spec/features/admin/configuration/shipping_methods_spec.rb +0 -126
- data/spec/features/admin/configuration/stock_locations_spec.rb +0 -54
- data/spec/features/admin/configuration/store_spec.rb +0 -62
- data/spec/features/admin/configuration/tax_categories_spec.rb +0 -58
- data/spec/features/admin/configuration/tax_rates_spec.rb +0 -31
- data/spec/features/admin/configuration/taxonomies_spec.rb +0 -61
- data/spec/features/admin/configuration/zones_spec.rb +0 -41
- data/spec/features/admin/homepage_spec.rb +0 -86
- data/spec/features/admin/javascript_format_money_spec.rb +0 -22
- data/spec/features/admin/locale_spec.rb +0 -34
- data/spec/features/admin/orders/adjustments_promotions_spec.rb +0 -55
- data/spec/features/admin/orders/adjustments_spec.rb +0 -130
- data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +0 -45
- data/spec/features/admin/orders/cancelling_inventory_spec.rb +0 -50
- data/spec/features/admin/orders/customer_details_spec.rb +0 -203
- data/spec/features/admin/orders/customer_returns_spec.rb +0 -41
- data/spec/features/admin/orders/line_items_spec.rb +0 -52
- data/spec/features/admin/orders/listing_spec.rb +0 -186
- data/spec/features/admin/orders/log_entries_spec.rb +0 -56
- data/spec/features/admin/orders/new_order_spec.rb +0 -379
- data/spec/features/admin/orders/new_refund_spec.rb +0 -35
- data/spec/features/admin/orders/order_details_spec.rb +0 -591
- data/spec/features/admin/orders/payments_spec.rb +0 -330
- data/spec/features/admin/orders/return_authorizations_spec.rb +0 -56
- data/spec/features/admin/orders/return_payment_state_spec.rb +0 -65
- data/spec/features/admin/orders/risk_analysis_spec.rb +0 -49
- data/spec/features/admin/orders/shipments_spec.rb +0 -145
- data/spec/features/admin/payments/store_credits_spec.rb +0 -23
- data/spec/features/admin/products/edit/images_spec.rb +0 -76
- data/spec/features/admin/products/edit/products_spec.rb +0 -92
- data/spec/features/admin/products/edit/taxons_spec.rb +0 -57
- data/spec/features/admin/products/edit/variants_spec.rb +0 -63
- data/spec/features/admin/products/option_types_spec.rb +0 -116
- data/spec/features/admin/products/pricing_spec.rb +0 -127
- data/spec/features/admin/products/products_spec.rb +0 -348
- data/spec/features/admin/products/properties_spec.rb +0 -141
- data/spec/features/admin/products/stock_management_spec.rb +0 -101
- data/spec/features/admin/products/variant_spec.rb +0 -89
- data/spec/features/admin/promotion_adjustments_spec.rb +0 -286
- data/spec/features/admin/promotions/option_value_rule_spec.rb +0 -90
- data/spec/features/admin/promotions/product_rule_spec.rb +0 -35
- data/spec/features/admin/promotions/promotion_categories_spec.rb +0 -83
- data/spec/features/admin/promotions/promotion_code_batches_spec.rb +0 -37
- data/spec/features/admin/promotions/promotion_code_spec.rb +0 -31
- data/spec/features/admin/promotions/promotion_spec.rb +0 -52
- data/spec/features/admin/promotions/tiered_calculator_spec.rb +0 -76
- data/spec/features/admin/promotions/user_rule_spec.rb +0 -42
- data/spec/features/admin/reimbursements_spec.rb +0 -18
- data/spec/features/admin/store_credits_spec.rb +0 -132
- data/spec/features/admin/stores_spec.rb +0 -37
- data/spec/features/admin/style_guide_spec.rb +0 -14
- data/spec/features/admin/taxons_spec.rb +0 -90
- data/spec/features/admin/users_spec.rb +0 -412
- data/spec/fixtures/files/ror_ringer.jpeg +0 -0
- data/spec/helpers/admin/base_helper_spec.rb +0 -49
- data/spec/helpers/admin/navigation_helper_spec.rb +0 -139
- data/spec/helpers/admin/stock_movements_helper_spec.rb +0 -29
- data/spec/helpers/admin/store_credit_events_helper_spec.rb +0 -97
- data/spec/helpers/promotion_rules_helper_spec.rb +0 -14
- data/spec/javascripts/fixtures/_boot.html.erb +0 -8
- data/spec/javascripts/fixtures/number_with_currency/with_currency_select.html.erb +0 -3
- data/spec/javascripts/fixtures/number_with_currency/without_select.html.erb +0 -3
- data/spec/javascripts/format_money_spec.js +0 -48
- data/spec/javascripts/spec_helper.js +0 -13
- data/spec/javascripts/support/show_errors.js +0 -8
- data/spec/javascripts/support/with_translations.js +0 -11
- data/spec/javascripts/translation_spec.js +0 -58
- data/spec/javascripts/views/number_with_currency_spec.js +0 -72
- data/spec/lib/spree/backend_configuration/menu_item_spec.rb +0 -17
- data/spec/lib/spree/backend_configuration_spec.rb +0 -22
- data/spec/spec_helper.rb +0 -123
- data/spec/support/appear_before_matcher.rb +0 -10
- data/spec/support/feature/base_feature_helper.rb +0 -17
- data/spec/support/feature/order_feature_helper.rb +0 -27
- data/spec/teaspoon_env.rb +0 -51
- data/spec/test_views/spree/admin/widgets/edit.html.erb +0 -1
- data/spec/test_views/spree/admin/widgets/new.html.erb +0 -1
- data/spec/views/spree/admin/shared/navigation_footer_spec.rb +0 -67
@@ -1,591 +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
|
-
it "can remove all items with empty cart" do
|
80
|
-
expect(page).to have_content("spree t-shirt")
|
81
|
-
|
82
|
-
accept_confirm "Are you sure you want to delete this record?" do
|
83
|
-
click_on 'Empty Cart'
|
84
|
-
end
|
85
|
-
|
86
|
-
expect(page).not_to have_content("spree t-shirt")
|
87
|
-
|
88
|
-
# Should have a new item row
|
89
|
-
expect(page).to have_field('quantity')
|
90
|
-
end
|
91
|
-
|
92
|
-
# Regression test for https://github.com/spree/spree/issues/3862
|
93
|
-
it "can cancel removing an item from a shipment" do
|
94
|
-
expect(page).to have_content("spree t-shirt")
|
95
|
-
|
96
|
-
within('tr', text: line_item.sku) do
|
97
|
-
# Click "cancel" on confirmation dialog
|
98
|
-
dismiss_confirm "Are you sure you want to delete this record?" do
|
99
|
-
click_icon :trash
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
expect(page).to have_content("spree t-shirt")
|
104
|
-
end
|
105
|
-
|
106
|
-
it "can add tracking information" do
|
107
|
-
visit spree.edit_admin_order_path(order)
|
108
|
-
|
109
|
-
within("tr", text: "Tracking Number") do
|
110
|
-
click_icon :edit
|
111
|
-
fill_in "tracking", with: "FOOBAR"
|
112
|
-
click_icon :check
|
113
|
-
|
114
|
-
expect(page).not_to have_css("input")
|
115
|
-
expect(page).to have_content("Tracking Number FOOBAR")
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
context "with a completed order" do
|
120
|
-
let!(:order) { create(:completed_order_with_totals) }
|
121
|
-
let(:shipment1) { order.shipments[0] }
|
122
|
-
|
123
|
-
it "can change the shipping method" do
|
124
|
-
visit spree.edit_admin_order_path(order)
|
125
|
-
|
126
|
-
within("tr", text: "Shipping Method") do
|
127
|
-
click_icon :edit
|
128
|
-
select "UPS Ground $100.00"
|
129
|
-
click_icon :check
|
130
|
-
end
|
131
|
-
|
132
|
-
expect(page).not_to have_css('#selected_shipping_rate_id')
|
133
|
-
expect(page).to have_content("UPS Ground")
|
134
|
-
end
|
135
|
-
|
136
|
-
it "can use admin-only shipping methods" do
|
137
|
-
create(:shipping_method, name: "Admin Free Shipping", cost: 0, available_to_users: false)
|
138
|
-
|
139
|
-
visit spree.edit_admin_order_path(order)
|
140
|
-
|
141
|
-
within("tr", text: "Shipping Method") do
|
142
|
-
click_icon :edit
|
143
|
-
select "Admin Free Shipping $0.00"
|
144
|
-
click_icon :check
|
145
|
-
end
|
146
|
-
|
147
|
-
expect(page).not_to have_css('#selected_shipping_rate_id')
|
148
|
-
expect(page).to have_no_content("UPS Ground")
|
149
|
-
expect(page).to have_content("Admin Free Shipping")
|
150
|
-
end
|
151
|
-
|
152
|
-
it "will show the variant sku" do
|
153
|
-
visit spree.edit_admin_order_path(order)
|
154
|
-
sku = order.line_items.first.variant.sku
|
155
|
-
expect(page).to have_content("SKU: #{sku}")
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
context "with special_instructions present" do
|
160
|
-
let(:order) { create(:order, state: 'complete', completed_at: "2011-02-01 12:36:15", number: "R100", special_instructions: "Very special instructions here") }
|
161
|
-
it "will show the special_instructions" do
|
162
|
-
visit spree.edit_admin_order_path(order)
|
163
|
-
expect(page).to have_content("Very special instructions here")
|
164
|
-
end
|
165
|
-
end
|
166
|
-
|
167
|
-
context "variant doesn't track inventory" do
|
168
|
-
let(:track_inventory) { false }
|
169
|
-
let(:backorderable) { false }
|
170
|
-
let(:count_on_hand) { 0 }
|
171
|
-
|
172
|
-
it "adds variant to order just fine" do
|
173
|
-
add_line_item "spree t-shirt"
|
174
|
-
|
175
|
-
within(".line-items") do
|
176
|
-
expect(page).to have_content("spree t-shirt")
|
177
|
-
end
|
178
|
-
end
|
179
|
-
end
|
180
|
-
|
181
|
-
context "variant out of stock and not backorderable" do
|
182
|
-
let(:backorderable) { false }
|
183
|
-
let(:count_on_hand) { 0 }
|
184
|
-
|
185
|
-
it "doesn't display the out of stock variant in the search results" do
|
186
|
-
click_on 'Add Item'
|
187
|
-
select2_search_without_selection product.name, from: ".select-variant"
|
188
|
-
|
189
|
-
expect(page).to have_selector('.select2-no-results')
|
190
|
-
within(".select2-no-results") do
|
191
|
-
expect(page).to have_content("No matches found")
|
192
|
-
end
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
context 'Shipment edit page' do
|
198
|
-
let!(:stock_location2) { create(:stock_location_with_items, name: 'Clarksville') }
|
199
|
-
|
200
|
-
before do
|
201
|
-
product.master.stock_items.first.update_column(:backorderable, true)
|
202
|
-
product.master.stock_items.first.update_column(:count_on_hand, 100)
|
203
|
-
product.master.stock_items.last.update_column(:count_on_hand, 100)
|
204
|
-
end
|
205
|
-
|
206
|
-
context 'splitting to location' do
|
207
|
-
it 'should warn you if you have not selected a location or shipment' do
|
208
|
-
visit spree.edit_admin_order_path(order)
|
209
|
-
|
210
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
211
|
-
accept_alert 'Please select the split destination.' do
|
212
|
-
click_icon :ok
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
context 'there is enough stock at the other location' do
|
217
|
-
it 'should allow me to make a split' do
|
218
|
-
expect(order.shipments.count).to eq(1)
|
219
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
220
|
-
|
221
|
-
visit spree.edit_admin_order_path(order)
|
222
|
-
|
223
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
224
|
-
complete_split_to(stock_location2)
|
225
|
-
|
226
|
-
expect(page).to have_css('.shipment', count: 2)
|
227
|
-
|
228
|
-
expect(order.shipments.count).to eq(2)
|
229
|
-
expect(order.shipments.last.backordered?).to eq(false)
|
230
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(1)
|
231
|
-
expect(order.shipments.last.inventory_units_for(product.master).count).to eq(1)
|
232
|
-
end
|
233
|
-
|
234
|
-
it 'should allow me to make a transfer via splitting off all stock' do
|
235
|
-
visit spree.edit_admin_order_path(order)
|
236
|
-
|
237
|
-
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
238
|
-
|
239
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
240
|
-
complete_split_to(stock_location2, quantity: 2)
|
241
|
-
|
242
|
-
expect(page).to have_content("Pending package from 'Clarksville'")
|
243
|
-
|
244
|
-
expect(order.shipments.count).to eq(1)
|
245
|
-
expect(order.shipments.last.backordered?).to eq(false)
|
246
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
247
|
-
expect(order.shipments.first.stock_location.id).to eq(stock_location2.id)
|
248
|
-
end
|
249
|
-
|
250
|
-
it 'should not allow me to split more than I had in the original shipment' do
|
251
|
-
visit spree.edit_admin_order_path(order)
|
252
|
-
|
253
|
-
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
254
|
-
|
255
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
256
|
-
complete_split_to(stock_location2, quantity: 5)
|
257
|
-
|
258
|
-
expect(page).to have_content("Pending package from 'Clarksville'")
|
259
|
-
|
260
|
-
expect(order.shipments.count).to eq(1)
|
261
|
-
expect(order.shipments.last.backordered?).to eq(false)
|
262
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
263
|
-
expect(order.shipments.first.stock_location.id).to eq(stock_location2.id)
|
264
|
-
end
|
265
|
-
|
266
|
-
it 'should not allow less than or equal to zero qty' do
|
267
|
-
visit spree.edit_admin_order_path(order)
|
268
|
-
|
269
|
-
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
270
|
-
|
271
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
272
|
-
|
273
|
-
accept_alert "Quantity must be greater than 0" do
|
274
|
-
complete_split_to(stock_location2, quantity: 0)
|
275
|
-
end
|
276
|
-
|
277
|
-
expect(order.shipments.count).to eq(1)
|
278
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
279
|
-
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
280
|
-
|
281
|
-
fill_in 'item_quantity', with: -1
|
282
|
-
|
283
|
-
accept_alert "Quantity must be greater than 0" do
|
284
|
-
click_icon :ok
|
285
|
-
end
|
286
|
-
|
287
|
-
expect(order.shipments.count).to eq(1)
|
288
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
289
|
-
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
290
|
-
end
|
291
|
-
|
292
|
-
context 'A shipment has shipped' do
|
293
|
-
it 'should not show or let me back to the cart page, nor show the shipment edit buttons' do
|
294
|
-
order = create(:shipped_order, state: 'payment', stock_location: stock_location)
|
295
|
-
|
296
|
-
visit spree.cart_admin_order_path(order)
|
297
|
-
|
298
|
-
expect(page.current_path).to eq(spree.edit_admin_order_path(order))
|
299
|
-
expect(page).not_to have_text 'Cart'
|
300
|
-
expect(page).not_to have_selector('.fa-arrows-h')
|
301
|
-
expect(page).not_to have_selector('.fa-trash')
|
302
|
-
end
|
303
|
-
end
|
304
|
-
end
|
305
|
-
|
306
|
-
context 'there is not enough stock at the other location' do
|
307
|
-
context 'and it cannot backorder' do
|
308
|
-
it 'should not allow me to split stock' do
|
309
|
-
product.master.stock_items.last.update_column(:backorderable, false)
|
310
|
-
product.master.stock_items.last.update_column(:count_on_hand, 0)
|
311
|
-
|
312
|
-
visit spree.edit_admin_order_path(order)
|
313
|
-
|
314
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
315
|
-
accept_alert "Desired shipment not enough stock in desired stock location" do
|
316
|
-
complete_split_to(stock_location2, quantity: 2)
|
317
|
-
end
|
318
|
-
|
319
|
-
expect(order.shipments.count).to eq(1)
|
320
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
321
|
-
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
322
|
-
end
|
323
|
-
end
|
324
|
-
|
325
|
-
context 'but it can backorder' do
|
326
|
-
it 'should allow me to split and backorder the stock' do
|
327
|
-
product.master.stock_items.last.update_column(:count_on_hand, 0)
|
328
|
-
product.master.stock_items.last.update_column(:backorderable, true)
|
329
|
-
|
330
|
-
visit spree.edit_admin_order_path(order)
|
331
|
-
|
332
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
333
|
-
complete_split_to(stock_location2, quantity: 2)
|
334
|
-
|
335
|
-
expect(page).to have_content("Pending package from 'Clarksville'")
|
336
|
-
|
337
|
-
expect(order.shipments.count).to eq(1)
|
338
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
339
|
-
expect(order.shipments.first.stock_location.id).to eq(stock_location2.id)
|
340
|
-
end
|
341
|
-
end
|
342
|
-
end
|
343
|
-
|
344
|
-
context 'multiple items in cart' do
|
345
|
-
it 'should have no problem splitting if multiple items are in the from shipment' do
|
346
|
-
order.contents.add(create(:variant), 2)
|
347
|
-
order.reload
|
348
|
-
|
349
|
-
visit spree.edit_admin_order_path(order)
|
350
|
-
|
351
|
-
expect(order.shipments.count).to eq(1)
|
352
|
-
expect(order.shipments.first.manifest.count).to eq(2)
|
353
|
-
|
354
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
355
|
-
complete_split_to(stock_location2)
|
356
|
-
|
357
|
-
expect(page).to have_css('.shipment', count: 2)
|
358
|
-
|
359
|
-
expect(order.shipments.count).to eq(2)
|
360
|
-
expect(order.shipments.last.backordered?).to eq(false)
|
361
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(1)
|
362
|
-
expect(order.shipments.last.inventory_units_for(product.master).count).to eq(1)
|
363
|
-
end
|
364
|
-
end
|
365
|
-
end
|
366
|
-
|
367
|
-
context 'removing an item' do
|
368
|
-
let!(:shipment2) { order.shipments.create(stock_location_id: stock_location2.id) }
|
369
|
-
|
370
|
-
it "removes only the one item" do
|
371
|
-
order.line_items[0].inventory_units[0].update!(shipment: shipment2)
|
372
|
-
visit spree.edit_admin_order_path(order)
|
373
|
-
|
374
|
-
expect(page).to have_css('.stock-item', count: 2)
|
375
|
-
|
376
|
-
within '[data-hook=admin_shipment_form]', text: shipment2.number do
|
377
|
-
accept_confirm "Are you sure you want to delete this record?" do
|
378
|
-
click_icon :trash
|
379
|
-
end
|
380
|
-
end
|
381
|
-
|
382
|
-
expect(page).to have_css('.stock-item', count: 1)
|
383
|
-
end
|
384
|
-
end
|
385
|
-
|
386
|
-
context 'splitting to shipment' do
|
387
|
-
let!(:shipment2) { order.shipments.create(stock_location_id: stock_location2.id) }
|
388
|
-
|
389
|
-
it 'should delete the old shipment if enough are split off' do
|
390
|
-
expect(order.shipments.count).to eq(2)
|
391
|
-
|
392
|
-
visit spree.edit_admin_order_path(order)
|
393
|
-
|
394
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
395
|
-
complete_split_to(shipment2, quantity: 2)
|
396
|
-
|
397
|
-
expect(page).not_to have_content(/Move .* to/)
|
398
|
-
|
399
|
-
expect(page).to have_css("#shipment_#{shipment2.id}", count: 1)
|
400
|
-
|
401
|
-
expect(order.shipments.count).to eq(1)
|
402
|
-
expect(order.shipments.last.inventory_units_for(product.master).count).to eq(2)
|
403
|
-
end
|
404
|
-
|
405
|
-
context 'receiving shipment can not backorder' do
|
406
|
-
before { product.master.stock_items.last.update_column(:backorderable, false) }
|
407
|
-
|
408
|
-
it 'should not allow a split if the receiving shipment qty plus the incoming is greater than the count_on_hand' do
|
409
|
-
expect(order.shipments.count).to eq(2)
|
410
|
-
|
411
|
-
visit spree.edit_admin_order_path(order)
|
412
|
-
expect(page).to have_css('.item-name', text: product.name, count: 1)
|
413
|
-
|
414
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
415
|
-
complete_split_to(shipment2, quantity: 1)
|
416
|
-
|
417
|
-
expect(page).to have_css('.item-name', text: product.name, count: 2)
|
418
|
-
|
419
|
-
within(all('.stock-contents', count: 2).first) do
|
420
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
421
|
-
|
422
|
-
accept_alert("Desired shipment not enough stock in desired stock location") do
|
423
|
-
complete_split_to(shipment2, quantity: 200)
|
424
|
-
end
|
425
|
-
end
|
426
|
-
|
427
|
-
expect(order.shipments.count).to eq(2)
|
428
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(1)
|
429
|
-
expect(order.shipments.last.inventory_units_for(product.master).count).to eq(1)
|
430
|
-
end
|
431
|
-
|
432
|
-
it 'should not allow a shipment to split stock to itself' do
|
433
|
-
visit spree.edit_admin_order_path(order)
|
434
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
435
|
-
click_on 'Choose Location'
|
436
|
-
within '.select2-results' do
|
437
|
-
expect(page).to have_content(shipment2.number)
|
438
|
-
expect(page).not_to have_content(shipment1.number)
|
439
|
-
end
|
440
|
-
end
|
441
|
-
|
442
|
-
it 'should split fine if more than one line_item is in the receiving shipment' do
|
443
|
-
variant2 = create(:variant)
|
444
|
-
order.contents.add(variant2, 2, shipment: shipment2)
|
445
|
-
order.reload
|
446
|
-
|
447
|
-
visit spree.edit_admin_order_path(order)
|
448
|
-
|
449
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
450
|
-
complete_split_to(shipment2, quantity: 1)
|
451
|
-
|
452
|
-
expect(page).not_to have_content(/Move .* to/)
|
453
|
-
expect(page).to have_css('.shipment', count: 2)
|
454
|
-
|
455
|
-
expect(order.shipments.count).to eq(2)
|
456
|
-
expect(order.shipments.first.inventory_units_for(product.master).count).to eq 1
|
457
|
-
expect(order.shipments.last.inventory_units_for(product.master).count).to eq 1
|
458
|
-
expect(order.shipments.first.inventory_units_for(variant2).count).to eq 0
|
459
|
-
expect(order.shipments.last.inventory_units_for(variant2).count).to eq 2
|
460
|
-
end
|
461
|
-
end
|
462
|
-
|
463
|
-
context 'receiving shipment can backorder' do
|
464
|
-
it 'should add more to the backorder' do
|
465
|
-
shipment1.inventory_units.update_all(state: :on_hand)
|
466
|
-
product.master.stock_items.last.update_column(:backorderable, true)
|
467
|
-
product.master.stock_items.last.update_column(:count_on_hand, 0)
|
468
|
-
expect(shipment2.reload).not_to be_backordered
|
469
|
-
|
470
|
-
visit spree.edit_admin_order_path(order)
|
471
|
-
|
472
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
473
|
-
complete_split_to(shipment2, quantity: 1)
|
474
|
-
|
475
|
-
expect(page).to have_content("1 x Backordered")
|
476
|
-
|
477
|
-
within('.stock-contents', text: "1 x On hand") do
|
478
|
-
within('tr', text: line_item.sku) { click_icon 'arrows-h' }
|
479
|
-
complete_split_to(shipment2, quantity: 1)
|
480
|
-
end
|
481
|
-
|
482
|
-
# Empty shipment should be removed
|
483
|
-
expect(page).to have_css('.stock-contents', count: 1)
|
484
|
-
expect(page).to have_content("2 x Backordered")
|
485
|
-
end
|
486
|
-
end
|
487
|
-
end
|
488
|
-
|
489
|
-
describe 'line item sort order' do
|
490
|
-
let(:product2) { create(:product) }
|
491
|
-
let(:product3) { create(:product) }
|
492
|
-
|
493
|
-
before do
|
494
|
-
# grab this one first and then create others that should end up before
|
495
|
-
# and after
|
496
|
-
@middle_line_item = order.line_items[0]
|
497
|
-
|
498
|
-
@first_line_item = order.contents.add(product2.master)
|
499
|
-
@first_line_item.update_columns(created_at: 1.day.ago)
|
500
|
-
@last_line_item = order.contents.add(product3.master)
|
501
|
-
@last_line_item.update_columns(created_at: 1.day.from_now)
|
502
|
-
end
|
503
|
-
|
504
|
-
it 'orders the items in a shipment by created_at' do
|
505
|
-
visit spree.edit_admin_order_path(order)
|
506
|
-
|
507
|
-
stock_items = page.all(:css, '.stock-item', count: 3)
|
508
|
-
|
509
|
-
expect(stock_items[0]).to have_text(@first_line_item.variant.sku)
|
510
|
-
expect(stock_items[1]).to have_text(@middle_line_item.variant.sku)
|
511
|
-
expect(stock_items[2]).to have_text(@last_line_item.variant.sku)
|
512
|
-
end
|
513
|
-
end
|
514
|
-
end
|
515
|
-
end
|
516
|
-
|
517
|
-
context 'with only read permissions' do
|
518
|
-
before do
|
519
|
-
allow_any_instance_of(Spree::Admin::BaseController).to receive(:try_spree_current_user).and_return(nil)
|
520
|
-
end
|
521
|
-
|
522
|
-
custom_authorization! do |_user|
|
523
|
-
can [:admin, :index, :read, :edit], Spree::Order
|
524
|
-
end
|
525
|
-
it "should not display forbidden links" do
|
526
|
-
visit spree.edit_admin_order_path(order)
|
527
|
-
|
528
|
-
expect(page).not_to have_button('cancel')
|
529
|
-
expect(page).not_to have_button('Resend')
|
530
|
-
|
531
|
-
# Order Tabs
|
532
|
-
expect(page).not_to have_link('Adjustments')
|
533
|
-
expect(page).not_to have_link('Payments')
|
534
|
-
expect(page).not_to have_link('Return Authorizations')
|
535
|
-
|
536
|
-
# Order item actions
|
537
|
-
expect(page).not_to have_css('.delete-item')
|
538
|
-
expect(page).not_to have_css('.split-item')
|
539
|
-
expect(page).not_to have_css('.edit-tracking')
|
540
|
-
end
|
541
|
-
end
|
542
|
-
|
543
|
-
context 'as Fakedispatch' do
|
544
|
-
custom_authorization! do |_user|
|
545
|
-
# allow dispatch to :admin, :index, and :edit on Spree::Order
|
546
|
-
can [:admin, :edit, :index, :read], Spree::Order
|
547
|
-
# allow dispatch to :index, :show, :create and :update shipments on the admin
|
548
|
-
can [:admin, :manage, :read, :ship], Spree::Shipment
|
549
|
-
end
|
550
|
-
|
551
|
-
before do
|
552
|
-
allow(Spree.user_class).to receive(:find_by).
|
553
|
-
with(hash_including(:spree_api_key)).
|
554
|
-
and_return(Spree.user_class.new)
|
555
|
-
end
|
556
|
-
|
557
|
-
it 'should not display order tabs or edit buttons without ability' do
|
558
|
-
visit spree.edit_admin_order_path(order)
|
559
|
-
|
560
|
-
# Order Tabs
|
561
|
-
expect(page).not_to have_link('Adjustments')
|
562
|
-
expect(page).not_to have_link('Payments')
|
563
|
-
expect(page).not_to have_link('Return Authorizations')
|
564
|
-
end
|
565
|
-
|
566
|
-
it "can change the shipping method" do
|
567
|
-
order = create(:completed_order_with_totals)
|
568
|
-
visit spree.edit_admin_order_path(order)
|
569
|
-
within("tr", text: "Shipping Method") do
|
570
|
-
click_icon :edit
|
571
|
-
end
|
572
|
-
select "UPS Ground $100.00"
|
573
|
-
click_icon :check
|
574
|
-
|
575
|
-
expect(page).not_to have_css('#selected_shipping_rate_id')
|
576
|
-
expect(page).to have_content("UPS Ground")
|
577
|
-
end
|
578
|
-
|
579
|
-
it 'can ship' do
|
580
|
-
order = create(:order_ready_to_ship)
|
581
|
-
order.refresh_shipment_rates
|
582
|
-
visit spree.edit_admin_order_path(order)
|
583
|
-
|
584
|
-
find(".ship-shipment-button").click
|
585
|
-
|
586
|
-
within '.carton-state' do
|
587
|
-
expect(page).to have_content('Shipped')
|
588
|
-
end
|
589
|
-
end
|
590
|
-
end
|
591
|
-
end
|