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