solidus_backend 1.0.2 → 1.0.3
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/CHANGELOG.md +1 -0
- data/Gemfile +6 -0
- data/Rakefile +15 -0
- data/script/rails +9 -0
- data/solidus_backend.gemspec +28 -0
- data/spec/controllers/spree/admin/base_controller_spec.rb +24 -0
- data/spec/controllers/spree/admin/cancellations_controller_spec.rb +77 -0
- data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +234 -0
- data/spec/controllers/spree/admin/general_settings_controller_spec.rb +41 -0
- data/spec/controllers/spree/admin/missing_products_controller_spec.rb +18 -0
- data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +80 -0
- data/spec/controllers/spree/admin/orders_controller_spec.rb +472 -0
- data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +49 -0
- data/spec/controllers/spree/admin/payments_controller_spec.rb +175 -0
- data/spec/controllers/spree/admin/products_controller_spec.rb +45 -0
- data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +21 -0
- data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +18 -0
- data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +21 -0
- data/spec/controllers/spree/admin/promotions_controller_spec.rb +122 -0
- data/spec/controllers/spree/admin/refunds_controller_spec.rb +32 -0
- data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +75 -0
- data/spec/controllers/spree/admin/reports_controller_spec.rb +134 -0
- data/spec/controllers/spree/admin/resource_controller_spec.rb +166 -0
- data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +226 -0
- data/spec/controllers/spree/admin/return_items_controller_spec.rb +27 -0
- data/spec/controllers/spree/admin/root_controller_spec.rb +41 -0
- data/spec/controllers/spree/admin/search_controller_spec.rb +104 -0
- data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +14 -0
- data/spec/controllers/spree/admin/stock_items_controller_spec.rb +50 -0
- data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +41 -0
- data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +331 -0
- data/spec/controllers/spree/admin/store_credits_controller_spec.rb +309 -0
- data/spec/controllers/spree/admin/users_controller_spec.rb +236 -0
- data/spec/controllers/spree/admin/variants_controller_spec.rb +32 -0
- data/spec/features/admin/configuration/analytics_tracker_spec.rb +54 -0
- data/spec/features/admin/configuration/countries_spec.rb +22 -0
- data/spec/features/admin/configuration/general_settings_spec.rb +45 -0
- data/spec/features/admin/configuration/payment_methods_spec.rb +125 -0
- data/spec/features/admin/configuration/shipping_methods_spec.rb +64 -0
- data/spec/features/admin/configuration/states_spec.rb +64 -0
- data/spec/features/admin/configuration/stock_locations_spec.rb +50 -0
- data/spec/features/admin/configuration/tax_categories_spec.rb +56 -0
- data/spec/features/admin/configuration/tax_rates_spec.rb +30 -0
- data/spec/features/admin/configuration/taxonomies_spec.rb +52 -0
- data/spec/features/admin/configuration/zones_spec.rb +39 -0
- data/spec/features/admin/homepage_spec.rb +78 -0
- data/spec/features/admin/locale_spec.rb +30 -0
- data/spec/features/admin/orders/adjustments_promotions_spec.rb +53 -0
- data/spec/features/admin/orders/adjustments_spec.rb +126 -0
- data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +48 -0
- data/spec/features/admin/orders/cancelling_inventory_spec.rb +48 -0
- data/spec/features/admin/orders/customer_details_spec.rb +163 -0
- data/spec/features/admin/orders/line_items_spec.rb +50 -0
- data/spec/features/admin/orders/listing_spec.rb +130 -0
- data/spec/features/admin/orders/log_entries_spec.rb +55 -0
- data/spec/features/admin/orders/new_order_spec.rb +185 -0
- data/spec/features/admin/orders/order_details_spec.rb +533 -0
- data/spec/features/admin/orders/payments_spec.rb +228 -0
- data/spec/features/admin/orders/risk_analysis_spec.rb +47 -0
- data/spec/features/admin/orders/shipments_spec.rb +65 -0
- data/spec/features/admin/payments/store_credits_spec.rb +21 -0
- data/spec/features/admin/products/edit/images_spec.rb +87 -0
- data/spec/features/admin/products/edit/products_spec.rb +66 -0
- data/spec/features/admin/products/edit/taxons_spec.rb +43 -0
- data/spec/features/admin/products/edit/variants_spec.rb +61 -0
- data/spec/features/admin/products/option_types_spec.rb +114 -0
- data/spec/features/admin/products/products_spec.rb +392 -0
- data/spec/features/admin/products/properties_spec.rb +139 -0
- data/spec/features/admin/products/prototypes_spec.rb +110 -0
- data/spec/features/admin/products/stock_management_spec.rb +82 -0
- data/spec/features/admin/products/variant_spec.rb +51 -0
- data/spec/features/admin/promotion_adjustments_spec.rb +220 -0
- data/spec/features/admin/promotions/tiered_calculator_spec.rb +69 -0
- data/spec/features/admin/reports_spec.rb +61 -0
- data/spec/features/admin/stock_transfer_spec.rb +86 -0
- data/spec/features/admin/store_credits_spec.rb +82 -0
- data/spec/features/admin/taxons_spec.rb +31 -0
- data/spec/features/admin/users_spec.rb +270 -0
- data/spec/helpers/admin/base_helper_spec.rb +24 -0
- data/spec/helpers/admin/navigation_helper_spec.rb +73 -0
- data/spec/helpers/admin/reimbursements_helper_spec.rb +34 -0
- data/spec/helpers/admin/stock_movements_helper_spec.rb +29 -0
- data/spec/helpers/admin/store_credit_events_helper_spec.rb +95 -0
- data/spec/helpers/promotion_rules_helper_spec.rb +12 -0
- data/spec/spec_helper.rb +108 -0
- data/spec/support/appear_before_matcher.rb +8 -0
- data/spec/support/ror_ringer.jpeg +0 -0
- data/spec/test_views/spree/admin/widgets/edit.html.erb +1 -0
- data/spec/test_views/spree/admin/widgets/new.html.erb +1 -0
- metadata +95 -6
@@ -0,0 +1,185 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "New Order", :type => :feature do
|
4
|
+
let!(:product) { create(:product_in_stock) }
|
5
|
+
let!(:state) { create(:state) }
|
6
|
+
let!(:store) { create(:store) }
|
7
|
+
let!(:user) { create(:user, ship_address: create(:address), bill_address: create(:address)) }
|
8
|
+
let!(:payment_method) { create(:check_payment_method) }
|
9
|
+
let!(:shipping_method) { create(:shipping_method, cost: 0.0) }
|
10
|
+
|
11
|
+
stub_authorization!
|
12
|
+
|
13
|
+
before do
|
14
|
+
visit spree.admin_path
|
15
|
+
click_on "Orders"
|
16
|
+
click_on "New Order"
|
17
|
+
end
|
18
|
+
|
19
|
+
it "does check if you have a billing address before letting you add shipments" do
|
20
|
+
click_on "Shipments"
|
21
|
+
expect(page).to have_content 'Please fill in customer info'
|
22
|
+
expect(current_path).to eql(spree.edit_admin_order_customer_path(Spree::Order.last))
|
23
|
+
end
|
24
|
+
|
25
|
+
it "completes new order succesfully without using the cart", js: true do
|
26
|
+
click_on 'Cart'
|
27
|
+
select2_search product.name, from: Spree.t(:name_or_sku)
|
28
|
+
|
29
|
+
fill_in_quantity("table.stock-levels", "quantity_0", 2)
|
30
|
+
|
31
|
+
click_icon :plus
|
32
|
+
click_on "Customer Details"
|
33
|
+
|
34
|
+
within "#select-customer" do
|
35
|
+
targetted_select2_search user.email, from: "#s2id_customer_search"
|
36
|
+
end
|
37
|
+
|
38
|
+
check "order_use_billing"
|
39
|
+
fill_in_address
|
40
|
+
click_on "Update"
|
41
|
+
|
42
|
+
click_on "Payments"
|
43
|
+
click_on "Update"
|
44
|
+
|
45
|
+
expect(current_path).to eql(spree.admin_order_payments_path(Spree::Order.last))
|
46
|
+
|
47
|
+
click_on "Confirm"
|
48
|
+
click_on "Complete"
|
49
|
+
|
50
|
+
expect(current_path).to eql(spree.edit_admin_order_path(Spree::Order.last))
|
51
|
+
|
52
|
+
click_on "Payments"
|
53
|
+
click_icon "capture"
|
54
|
+
|
55
|
+
click_on "Shipments"
|
56
|
+
click_on "ship"
|
57
|
+
|
58
|
+
within '.carton-state' do
|
59
|
+
expect(page).to have_content('SHIPPED')
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context "adding new item to the order", js: true do
|
64
|
+
it "inventory items show up just fine and are also registered as shipments" do
|
65
|
+
click_on 'Cart'
|
66
|
+
select2_search product.name, from: Spree.t(:name_or_sku)
|
67
|
+
|
68
|
+
fill_in_quantity('table.stock-levels', 'quantity_0', 2)
|
69
|
+
|
70
|
+
click_icon :plus
|
71
|
+
|
72
|
+
within(".line-items") do
|
73
|
+
expect(page).to have_content(product.name)
|
74
|
+
end
|
75
|
+
|
76
|
+
click_on "Customer Details"
|
77
|
+
|
78
|
+
within "#select-customer" do
|
79
|
+
targetted_select2_search user.email, from: "#s2id_customer_search"
|
80
|
+
end
|
81
|
+
|
82
|
+
check "order_use_billing"
|
83
|
+
fill_in_address
|
84
|
+
click_on "Update"
|
85
|
+
|
86
|
+
click_on "Shipments"
|
87
|
+
|
88
|
+
within(".stock-contents") do
|
89
|
+
expect(page).to have_content(product.name)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# Regression test for #3958
|
95
|
+
context "without a delivery step", js: true do
|
96
|
+
before do
|
97
|
+
allow(Spree::Order).to receive_messages checkout_step_names: [:address, :payment, :confirm, :complete]
|
98
|
+
end
|
99
|
+
|
100
|
+
it "can still see line items" do
|
101
|
+
click_on 'Cart'
|
102
|
+
select2_search product.name, from: Spree.t(:name_or_sku)
|
103
|
+
|
104
|
+
fill_in_quantity('table.stock-levels', 'quantity_0', 1)
|
105
|
+
|
106
|
+
click_icon :plus
|
107
|
+
|
108
|
+
within(".line-items") do
|
109
|
+
within(".line-item-name") do
|
110
|
+
expect(page).to have_content(product.name)
|
111
|
+
end
|
112
|
+
within(".line-item-qty-show") do
|
113
|
+
expect(page).to have_content("1")
|
114
|
+
end
|
115
|
+
within(".line-item-price") do
|
116
|
+
expect(page).to have_content(product.price)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
# Regression test for #3336
|
123
|
+
context "start by customer address" do
|
124
|
+
it "completes order fine", js: true do
|
125
|
+
click_on "Customer Details"
|
126
|
+
|
127
|
+
within "#select-customer" do
|
128
|
+
targetted_select2_search user.email, from: "#s2id_customer_search"
|
129
|
+
end
|
130
|
+
|
131
|
+
check "order_use_billing"
|
132
|
+
fill_in_address
|
133
|
+
click_on "Update"
|
134
|
+
|
135
|
+
click_on "Shipments"
|
136
|
+
|
137
|
+
select2_search product.name, from: Spree.t(:name_or_sku)
|
138
|
+
|
139
|
+
click_icon :plus
|
140
|
+
|
141
|
+
expect(page).to have_css('.stock-item')
|
142
|
+
|
143
|
+
click_on "Payments"
|
144
|
+
click_on "Continue"
|
145
|
+
|
146
|
+
within(".additional-info .state") do
|
147
|
+
expect(page).to have_content("CONFIRM")
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
# Regression test for #5327
|
153
|
+
context "customer with default credit card", js: true do
|
154
|
+
before do
|
155
|
+
create(:credit_card, default: true, user: user)
|
156
|
+
end
|
157
|
+
it "transitions to delivery not to complete" do
|
158
|
+
click_on 'Cart'
|
159
|
+
select2_search product.name, from: Spree.t(:name_or_sku)
|
160
|
+
within("table.stock-levels") do
|
161
|
+
find('.variant_quantity').set(1)
|
162
|
+
end
|
163
|
+
|
164
|
+
click_icon :plus
|
165
|
+
|
166
|
+
expect(page).to have_css('.line-item')
|
167
|
+
|
168
|
+
click_link "Customer Details"
|
169
|
+
targetted_select2 user.email, from: "#s2id_customer_search"
|
170
|
+
click_button "Update"
|
171
|
+
expect(Spree::Order.last.state).to eq 'delivery'
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
def fill_in_address(kind = "bill")
|
176
|
+
fill_in "First Name", with: "John 99"
|
177
|
+
fill_in "Last Name", with: "Doe"
|
178
|
+
fill_in "Street Address", with: "100 first lane"
|
179
|
+
fill_in "Street Address (cont'd)", with: "#101"
|
180
|
+
fill_in "City", with: "Bethesda"
|
181
|
+
fill_in "Zip", with: "20170"
|
182
|
+
targetted_select2_search state.name, from: "#s2id_order_#{kind}_address_attributes_state_id"
|
183
|
+
fill_in "Phone", with: "123-456-7890"
|
184
|
+
end
|
185
|
+
end
|
@@ -0,0 +1,533 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "Order Details", type: :feature, js: true do
|
5
|
+
let!(:stock_location) { create(:stock_location_with_items) }
|
6
|
+
let!(:product) { create(:product, :name => 'spree t-shirt', :price => 20.00) }
|
7
|
+
let!(:tote) { create(:product, :name => "Tote", :price => 15.00) }
|
8
|
+
let(:order) { create(:order, :state => 'complete', :completed_at => "2011-02-01 12:36:15", :number => "R100") }
|
9
|
+
let(:state) { create(:state) }
|
10
|
+
#let(:shipment) { create(:shipment, :order => order, :stock_location => stock_location) }
|
11
|
+
let!(:shipping_method) { create(:shipping_method, :name => "Default") }
|
12
|
+
|
13
|
+
before do
|
14
|
+
order.shipments.create(stock_location_id: stock_location.id)
|
15
|
+
order.contents.add(product.master, 2)
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'as Admin' do
|
19
|
+
stub_authorization!
|
20
|
+
|
21
|
+
|
22
|
+
context "cart edit page" do
|
23
|
+
before do
|
24
|
+
product.master.stock_items.first.update_column(:count_on_hand, 100)
|
25
|
+
visit spree.cart_admin_order_path(order)
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
it "should allow me to edit order details" do
|
30
|
+
expect(page).to have_content("spree t-shirt")
|
31
|
+
expect(page).to have_content("$40.00")
|
32
|
+
|
33
|
+
within_row(1) do
|
34
|
+
click_icon :edit
|
35
|
+
fill_in "quantity", :with => "1"
|
36
|
+
end
|
37
|
+
click_icon :ok
|
38
|
+
|
39
|
+
within("#order_total") do
|
40
|
+
expect(page).to have_content("$20.00")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
it "can add an item to a shipment" do
|
45
|
+
select2_search "spree t-shirt", :from => Spree.t(:name_or_sku)
|
46
|
+
within("table.stock-levels") do
|
47
|
+
fill_in "quantity_0", :with => 2
|
48
|
+
end
|
49
|
+
|
50
|
+
click_icon :plus
|
51
|
+
|
52
|
+
within("#order_total") do
|
53
|
+
expect(page).to have_content("$80.00")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it "can remove an item from a shipment" do
|
58
|
+
expect(page).to have_content("spree t-shirt")
|
59
|
+
|
60
|
+
within_row(1) do
|
61
|
+
accept_alert do
|
62
|
+
click_icon :trash
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
expect(page).to have_content("YOUR ORDER IS EMPTY") # wait for page refresh
|
67
|
+
expect(page).not_to have_content("spree t-shirt")
|
68
|
+
end
|
69
|
+
|
70
|
+
# Regression test for #3862
|
71
|
+
it "can cancel removing an item from a shipment" do
|
72
|
+
expect(page).to have_content("spree t-shirt")
|
73
|
+
|
74
|
+
within_row(1) do
|
75
|
+
# Click "cancel" on confirmation dialog
|
76
|
+
dismiss_alert do
|
77
|
+
click_icon :trash
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
expect(page).to have_content("spree t-shirt")
|
82
|
+
end
|
83
|
+
|
84
|
+
it "can add tracking information" do
|
85
|
+
visit spree.edit_admin_order_path(order)
|
86
|
+
|
87
|
+
within(".show-tracking") do
|
88
|
+
click_icon :edit
|
89
|
+
end
|
90
|
+
fill_in "tracking", :with => "FOOBAR"
|
91
|
+
click_icon :check
|
92
|
+
|
93
|
+
expect(page).not_to have_css("input[name=tracking]")
|
94
|
+
expect(page).to have_content("Tracking: FOOBAR")
|
95
|
+
end
|
96
|
+
|
97
|
+
it "can change the shipping method" do
|
98
|
+
order = create(:completed_order_with_totals)
|
99
|
+
visit spree.edit_admin_order_path(order)
|
100
|
+
within("table.index tr.show-method") do
|
101
|
+
click_icon :edit
|
102
|
+
end
|
103
|
+
select2 "Default", :from => "Shipping Method"
|
104
|
+
click_icon :check
|
105
|
+
|
106
|
+
expect(page).not_to have_css('#selected_shipping_rate_id')
|
107
|
+
expect(page).to have_content("Default")
|
108
|
+
end
|
109
|
+
|
110
|
+
it "will show the variant sku" do
|
111
|
+
order = create(:completed_order_with_totals)
|
112
|
+
visit spree.edit_admin_order_path(order)
|
113
|
+
sku = order.line_items.first.variant.sku
|
114
|
+
expect(page).to have_content("SKU: #{sku}")
|
115
|
+
end
|
116
|
+
|
117
|
+
context "with special_instructions present" do
|
118
|
+
let(:order) { create(:order, :state => 'complete', :completed_at => "2011-02-01 12:36:15", :number => "R100", :special_instructions => "Very special instructions here") }
|
119
|
+
it "will show the special_instructions" do
|
120
|
+
visit spree.edit_admin_order_path(order)
|
121
|
+
expect(page).to have_content("Very special instructions here")
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
context "variant doesn't track inventory" do
|
126
|
+
before do
|
127
|
+
tote.master.update_column :track_inventory, false
|
128
|
+
# make sure there's no stock level for any item
|
129
|
+
tote.master.stock_items.update_all count_on_hand: 0, backorderable: false
|
130
|
+
end
|
131
|
+
|
132
|
+
it "adds variant to order just fine" do
|
133
|
+
select2_search tote.name, :from => Spree.t(:name_or_sku)
|
134
|
+
within("table.stock-levels") do
|
135
|
+
fill_in "variant_quantity", :with => 1
|
136
|
+
end
|
137
|
+
|
138
|
+
click_icon :plus
|
139
|
+
|
140
|
+
within(".line-items") do
|
141
|
+
expect(page).to have_content(tote.name)
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
context "variant out of stock and not backorderable" do
|
147
|
+
before do
|
148
|
+
product.master.stock_items.first.update_column(:backorderable, false)
|
149
|
+
product.master.stock_items.first.update_column(:count_on_hand, 0)
|
150
|
+
end
|
151
|
+
|
152
|
+
it "doesn't display the out of stock variant in the search results" do
|
153
|
+
select2_search_without_selection product.name, from: ".variant_autocomplete"
|
154
|
+
|
155
|
+
expect(page).to have_selector('.select2-no-results')
|
156
|
+
within(".select2-no-results") do
|
157
|
+
expect(page).to have_content("NO MATCHES FOUND")
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
|
164
|
+
context 'Shipment edit page' do
|
165
|
+
let!(:stock_location2) { create(:stock_location_with_items, name: 'Clarksville') }
|
166
|
+
|
167
|
+
before do
|
168
|
+
product.master.stock_items.first.update_column(:backorderable, true)
|
169
|
+
product.master.stock_items.first.update_column(:count_on_hand, 100)
|
170
|
+
product.master.stock_items.last.update_column(:count_on_hand, 100)
|
171
|
+
end
|
172
|
+
|
173
|
+
context 'splitting to location' do
|
174
|
+
before { visit spree.edit_admin_order_path(order) }
|
175
|
+
# can not properly implement until poltergeist supports checking alert text
|
176
|
+
# see https://github.com/teampoltergeist/poltergeist/pull/516
|
177
|
+
it 'should warn you if you have not selected a location or shipment'
|
178
|
+
|
179
|
+
context 'there is enough stock at the other location' do
|
180
|
+
it 'should allow me to make a split' do
|
181
|
+
expect(order.shipments.count).to eq(1)
|
182
|
+
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
183
|
+
|
184
|
+
within_row(1) { click_icon 'arrows-h' }
|
185
|
+
targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
|
186
|
+
click_icon :ok
|
187
|
+
|
188
|
+
expect(page).to have_css('.shipment', count: 2)
|
189
|
+
|
190
|
+
expect(order.shipments.count).to eq(2)
|
191
|
+
expect(order.shipments.last.backordered?).to eq(false)
|
192
|
+
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(1)
|
193
|
+
expect(order.shipments.last.inventory_units_for(product.master).count).to eq(1)
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'should allow me to make a transfer via splitting off all stock' do
|
197
|
+
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
198
|
+
|
199
|
+
within_row(1) { click_icon 'arrows-h' }
|
200
|
+
targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
|
201
|
+
fill_in 'item_quantity', with: 2
|
202
|
+
click_icon :ok
|
203
|
+
|
204
|
+
expect(page).to have_content("PENDING PACKAGE FROM 'CLARKSVILLE'")
|
205
|
+
|
206
|
+
expect(order.shipments.count).to eq(1)
|
207
|
+
expect(order.shipments.last.backordered?).to eq(false)
|
208
|
+
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
209
|
+
expect(order.shipments.first.stock_location.id).to eq(stock_location2.id)
|
210
|
+
end
|
211
|
+
|
212
|
+
it 'should allow me to split more than I have if available there' do
|
213
|
+
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
214
|
+
|
215
|
+
within_row(1) { click_icon 'arrows-h' }
|
216
|
+
targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
|
217
|
+
fill_in 'item_quantity', with: 5
|
218
|
+
click_icon :ok
|
219
|
+
|
220
|
+
expect(page).to have_content("PENDING PACKAGE FROM 'CLARKSVILLE'")
|
221
|
+
|
222
|
+
expect(order.shipments.count).to eq(1)
|
223
|
+
expect(order.shipments.last.backordered?).to eq(false)
|
224
|
+
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(5)
|
225
|
+
expect(order.shipments.first.stock_location.id).to eq(stock_location2.id)
|
226
|
+
end
|
227
|
+
|
228
|
+
it 'should not split anything if the input quantity is garbage' do
|
229
|
+
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
230
|
+
|
231
|
+
within_row(1) { click_icon 'arrows-h' }
|
232
|
+
targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
|
233
|
+
fill_in 'item_quantity', with: 'ff'
|
234
|
+
click_icon :ok
|
235
|
+
|
236
|
+
wait_for_ajax
|
237
|
+
|
238
|
+
expect(order.shipments.count).to eq(1)
|
239
|
+
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
240
|
+
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
241
|
+
end
|
242
|
+
|
243
|
+
it 'should not allow less than or equal to zero qty' do
|
244
|
+
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
245
|
+
|
246
|
+
within_row(1) { click_icon 'arrows-h' }
|
247
|
+
targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
|
248
|
+
fill_in 'item_quantity', with: 0
|
249
|
+
click_icon :ok
|
250
|
+
|
251
|
+
wait_for_ajax
|
252
|
+
|
253
|
+
expect(order.shipments.count).to eq(1)
|
254
|
+
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
255
|
+
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
256
|
+
|
257
|
+
|
258
|
+
fill_in 'item_quantity', with: -1
|
259
|
+
click_icon :ok
|
260
|
+
|
261
|
+
wait_for_ajax
|
262
|
+
|
263
|
+
expect(order.shipments.count).to eq(1)
|
264
|
+
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
265
|
+
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
266
|
+
end
|
267
|
+
|
268
|
+
context 'A shipment has shipped' do
|
269
|
+
|
270
|
+
it 'should not show or let me back to the cart page, nor show the shipment edit buttons' do
|
271
|
+
order = create(:order, :state => 'payment', :number => "R100")
|
272
|
+
order.shipments.create!(stock_location_id: stock_location.id, state: 'shipped')
|
273
|
+
|
274
|
+
visit spree.cart_admin_order_path(order)
|
275
|
+
|
276
|
+
expect(page.current_path).to eq(spree.edit_admin_order_path(order))
|
277
|
+
expect(page).not_to have_text 'Cart'
|
278
|
+
expect(page).not_to have_selector('.fa-arrows-h')
|
279
|
+
expect(page).not_to have_selector('.fa-trash')
|
280
|
+
end
|
281
|
+
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
context 'there is not enough stock at the other location' do
|
286
|
+
context 'and it cannot backorder' do
|
287
|
+
it 'should not allow me to split stock' do
|
288
|
+
product.master.stock_items.last.update_column(:backorderable, false)
|
289
|
+
product.master.stock_items.last.update_column(:count_on_hand, 0)
|
290
|
+
|
291
|
+
within_row(1) { click_icon 'arrows-h' }
|
292
|
+
targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
|
293
|
+
fill_in 'item_quantity', with: 2
|
294
|
+
click_icon :ok
|
295
|
+
|
296
|
+
wait_for_ajax
|
297
|
+
|
298
|
+
expect(order.shipments.count).to eq(1)
|
299
|
+
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
300
|
+
expect(order.shipments.first.stock_location.id).to eq(stock_location.id)
|
301
|
+
end
|
302
|
+
|
303
|
+
end
|
304
|
+
|
305
|
+
context 'but it can backorder' do
|
306
|
+
it 'should allow me to split and backorder the stock' do
|
307
|
+
product.master.stock_items.last.update_column(:count_on_hand, 0)
|
308
|
+
product.master.stock_items.last.update_column(:backorderable, true)
|
309
|
+
|
310
|
+
within_row(1) { click_icon 'arrows-h' }
|
311
|
+
targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
|
312
|
+
fill_in 'item_quantity', with: 2
|
313
|
+
click_icon :ok
|
314
|
+
|
315
|
+
expect(page).to have_content("PENDING PACKAGE FROM 'CLARKSVILLE'")
|
316
|
+
|
317
|
+
expect(order.shipments.count).to eq(1)
|
318
|
+
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
319
|
+
expect(order.shipments.first.stock_location.id).to eq(stock_location2.id)
|
320
|
+
end
|
321
|
+
end
|
322
|
+
end
|
323
|
+
|
324
|
+
context 'multiple items in cart' do
|
325
|
+
it 'should have no problem splitting if multiple items are in the from shipment' do
|
326
|
+
order.contents.add(create(:variant), 2)
|
327
|
+
expect(order.shipments.count).to eq(1)
|
328
|
+
expect(order.shipments.first.manifest.count).to eq(2)
|
329
|
+
|
330
|
+
within_row(1) { click_icon 'arrows-h' }
|
331
|
+
targetted_select2 stock_location2.name, from: '#s2id_item_stock_location'
|
332
|
+
click_icon :ok
|
333
|
+
|
334
|
+
expect(page).to have_css('.shipment', count: 2)
|
335
|
+
|
336
|
+
expect(order.shipments.count).to eq(2)
|
337
|
+
expect(order.shipments.last.backordered?).to eq(false)
|
338
|
+
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(1)
|
339
|
+
expect(order.shipments.last.inventory_units_for(product.master).count).to eq(1)
|
340
|
+
end
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
|
345
|
+
context 'splitting to shipment' do
|
346
|
+
before do
|
347
|
+
@shipment2 = order.shipments.create(stock_location_id: stock_location2.id)
|
348
|
+
visit spree.edit_admin_order_path(order)
|
349
|
+
end
|
350
|
+
|
351
|
+
it 'should delete the old shipment if enough are split off' do
|
352
|
+
expect(order.shipments.count).to eq(2)
|
353
|
+
|
354
|
+
within_row(1) { click_icon 'arrows-h' }
|
355
|
+
targetted_select2 @shipment2.number, from: '#s2id_item_stock_location'
|
356
|
+
fill_in 'item_quantity', with: 2
|
357
|
+
click_icon :ok
|
358
|
+
|
359
|
+
wait_for_ajax
|
360
|
+
|
361
|
+
expect(order.shipments.count).to eq(1)
|
362
|
+
expect(order.shipments.last.inventory_units_for(product.master).count).to eq(2)
|
363
|
+
end
|
364
|
+
|
365
|
+
context 'receiving shipment can not backorder' do
|
366
|
+
before { product.master.stock_items.last.update_column(:backorderable, false) }
|
367
|
+
|
368
|
+
it 'should not allow a split if the receiving shipment qty plus the incoming is greater than the count_on_hand' do
|
369
|
+
expect(order.shipments.count).to eq(2)
|
370
|
+
|
371
|
+
within_row(1) { click_icon 'arrows-h' }
|
372
|
+
targetted_select2 @shipment2.number, from: '#s2id_item_stock_location'
|
373
|
+
fill_in 'item_quantity', with: 1
|
374
|
+
click_icon :ok
|
375
|
+
|
376
|
+
wait_for_ajax
|
377
|
+
|
378
|
+
within_row(1) { click_icon 'arrows-h' }
|
379
|
+
targetted_select2 @shipment2.number, from: '#s2id_item_stock_location'
|
380
|
+
fill_in 'item_quantity', with: 200
|
381
|
+
click_icon :ok
|
382
|
+
|
383
|
+
wait_for_ajax
|
384
|
+
|
385
|
+
expect(order.shipments.count).to eq(2)
|
386
|
+
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(1)
|
387
|
+
expect(order.shipments.last.inventory_units_for(product.master).count).to eq(1)
|
388
|
+
end
|
389
|
+
|
390
|
+
it 'should not allow a shipment to split stock to itself' do
|
391
|
+
within_row(1) { click_icon 'arrows-h' }
|
392
|
+
targetted_select2 order.shipments.first.number, from: '#s2id_item_stock_location'
|
393
|
+
fill_in 'item_quantity', with: 1
|
394
|
+
click_icon :ok
|
395
|
+
|
396
|
+
wait_for_ajax
|
397
|
+
|
398
|
+
expect(order.shipments.count).to eq(2)
|
399
|
+
expect(order.shipments.first.inventory_units_for(product.master).count).to eq(2)
|
400
|
+
end
|
401
|
+
|
402
|
+
it 'should split fine if more than one line_item is in the receiving shipment' do
|
403
|
+
variant2 = create(:variant)
|
404
|
+
order.contents.add(variant2, 2, shipment: @shipment2)
|
405
|
+
|
406
|
+
within_row(1) { click_icon 'arrows-h' }
|
407
|
+
targetted_select2 @shipment2.number, from: '#s2id_item_stock_location'
|
408
|
+
fill_in 'item_quantity', with: 1
|
409
|
+
click_icon :ok
|
410
|
+
|
411
|
+
wait_for_ajax
|
412
|
+
|
413
|
+
expect(order.shipments.count).to eq(2)
|
414
|
+
expect(order.shipments.first.inventory_units_for(product.master).count).to eq 1
|
415
|
+
expect(order.shipments.last.inventory_units_for(product.master).count).to eq 1
|
416
|
+
expect(order.shipments.first.inventory_units_for(variant2).count).to eq 0
|
417
|
+
expect(order.shipments.last.inventory_units_for(variant2).count).to eq 2
|
418
|
+
end
|
419
|
+
end
|
420
|
+
|
421
|
+
context 'receiving shipment can backorder' do
|
422
|
+
it 'should add more to the backorder' do
|
423
|
+
product.master.stock_items.last.update_column(:backorderable, true)
|
424
|
+
product.master.stock_items.last.update_column(:count_on_hand, 0)
|
425
|
+
expect(@shipment2.reload.backordered?).to eq(false)
|
426
|
+
|
427
|
+
|
428
|
+
within_row(1) { click_icon 'arrows-h' }
|
429
|
+
targetted_select2 @shipment2.number, from: '#s2id_item_stock_location'
|
430
|
+
fill_in 'item_quantity', with: 1
|
431
|
+
click_icon :ok
|
432
|
+
|
433
|
+
wait_for_ajax
|
434
|
+
|
435
|
+
expect(@shipment2.reload.backordered?).to eq(true)
|
436
|
+
|
437
|
+
within_row(1) { click_icon 'arrows-h' }
|
438
|
+
targetted_select2 @shipment2.number, from: '#s2id_item_stock_location'
|
439
|
+
fill_in 'item_quantity', with: 1
|
440
|
+
click_icon :ok
|
441
|
+
|
442
|
+
wait_for_ajax
|
443
|
+
|
444
|
+
expect(order.shipments.count).to eq(1)
|
445
|
+
expect(order.shipments.last.inventory_units_for(product.master).count).to eq(2)
|
446
|
+
expect(@shipment2.reload.backordered?).to eq(true)
|
447
|
+
end
|
448
|
+
end
|
449
|
+
end
|
450
|
+
end
|
451
|
+
end
|
452
|
+
|
453
|
+
context 'with only read permissions' do
|
454
|
+
before do
|
455
|
+
allow_any_instance_of(Spree::Admin::BaseController).to receive(:spree_current_user).and_return(nil)
|
456
|
+
end
|
457
|
+
|
458
|
+
custom_authorization! do |user|
|
459
|
+
can [:admin, :index, :read, :edit], Spree::Order
|
460
|
+
end
|
461
|
+
it "should not display forbidden links" do
|
462
|
+
visit spree.edit_admin_order_path(order)
|
463
|
+
|
464
|
+
expect(page).not_to have_button('cancel')
|
465
|
+
expect(page).not_to have_button('Resend')
|
466
|
+
|
467
|
+
# Order Tabs
|
468
|
+
expect(page).not_to have_link('Adjustments')
|
469
|
+
expect(page).not_to have_link('Payments')
|
470
|
+
expect(page).not_to have_link('Return Authorizations')
|
471
|
+
|
472
|
+
# Order item actions
|
473
|
+
expect(page).not_to have_css('.delete-item')
|
474
|
+
expect(page).not_to have_css('.split-item')
|
475
|
+
expect(page).not_to have_css('.edit-item')
|
476
|
+
expect(page).not_to have_css('.edit-tracking')
|
477
|
+
|
478
|
+
expect(page).not_to have_css('#add-line-item')
|
479
|
+
end
|
480
|
+
end
|
481
|
+
|
482
|
+
context 'as Fakedispatch' do
|
483
|
+
custom_authorization! do |user|
|
484
|
+
# allow dispatch to :admin, :index, and :edit on Spree::Order
|
485
|
+
can [:admin, :edit, :index, :read], Spree::Order
|
486
|
+
# allow dispatch to :index, :show, :create and :update shipments on the admin
|
487
|
+
can [:admin, :manage, :read, :ship], Spree::Shipment
|
488
|
+
end
|
489
|
+
|
490
|
+
before do
|
491
|
+
allow(Spree.user_class).to receive(:find_by).
|
492
|
+
with(hash_including(:spree_api_key)).
|
493
|
+
and_return(Spree.user_class.new)
|
494
|
+
end
|
495
|
+
|
496
|
+
it 'should not display order tabs or edit buttons without ability' do
|
497
|
+
visit spree.edit_admin_order_path(order)
|
498
|
+
|
499
|
+
# Order Form
|
500
|
+
expect(page).not_to have_css('.edit-item')
|
501
|
+
# Order Tabs
|
502
|
+
expect(page).not_to have_link('Adjustments')
|
503
|
+
expect(page).not_to have_link('Payments')
|
504
|
+
expect(page).not_to have_link('Return Authorizations')
|
505
|
+
end
|
506
|
+
|
507
|
+
it "can change the shipping method" do
|
508
|
+
order = create(:completed_order_with_totals)
|
509
|
+
visit spree.edit_admin_order_path(order)
|
510
|
+
within("table.index tr.show-method") do
|
511
|
+
click_icon :edit
|
512
|
+
end
|
513
|
+
select2 "Default", :from => "Shipping Method"
|
514
|
+
click_icon :check
|
515
|
+
|
516
|
+
expect(page).not_to have_css('#selected_shipping_rate_id')
|
517
|
+
expect(page).to have_content("Default")
|
518
|
+
end
|
519
|
+
|
520
|
+
it 'can ship' do
|
521
|
+
order = create(:order_ready_to_ship)
|
522
|
+
order.refresh_shipment_rates
|
523
|
+
visit spree.edit_admin_order_path(order)
|
524
|
+
|
525
|
+
find(".ship-shipment-button").click
|
526
|
+
wait_for_ajax
|
527
|
+
|
528
|
+
within '.carton-state' do
|
529
|
+
expect(page).to have_content('SHIPPED')
|
530
|
+
end
|
531
|
+
end
|
532
|
+
end
|
533
|
+
end
|