spree_backend 3.2.1 → 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/views/spree/admin/products/_form.html.erb +8 -8
- data/spree_backend.gemspec +2 -2
- metadata +9 -100
- data/spec/controllers/spree/admin/base_controller_spec.rb +0 -46
- data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +0 -185
- data/spec/controllers/spree/admin/general_settings_controller_spec.rb +0 -41
- data/spec/controllers/spree/admin/missing_products_controller_spec.rb +0 -18
- data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +0 -197
- data/spec/controllers/spree/admin/orders_controller_spec.rb +0 -296
- data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +0 -64
- data/spec/controllers/spree/admin/payments_controller_spec.rb +0 -97
- data/spec/controllers/spree/admin/products_controller_spec.rb +0 -99
- data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +0 -21
- data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +0 -21
- data/spec/controllers/spree/admin/promotions_controller_spec.rb +0 -44
- data/spec/controllers/spree/admin/refunds_controller_spec.rb +0 -32
- data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +0 -74
- data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -42
- data/spec/controllers/spree/admin/resource_controller_spec.rb +0 -252
- data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +0 -225
- data/spec/controllers/spree/admin/return_index_controller_spec.rb +0 -37
- data/spec/controllers/spree/admin/return_items_controller_spec.rb +0 -27
- data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +0 -14
- data/spec/controllers/spree/admin/stock_items_controller_spec.rb +0 -19
- data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +0 -41
- data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +0 -41
- data/spec/controllers/spree/admin/tax_categories_controller_spec.rb +0 -34
- data/spec/controllers/spree/admin/users_controller_spec.rb +0 -161
- data/spec/controllers/spree/admin/variants_controller_spec.rb +0 -32
- data/spec/features/admin/configuration/analytics_tracker_spec.rb +0 -47
- data/spec/features/admin/configuration/countries_spec.rb +0 -24
- data/spec/features/admin/configuration/general_settings_spec.rb +0 -44
- data/spec/features/admin/configuration/payment_methods_spec.rb +0 -63
- data/spec/features/admin/configuration/roles_spec.rb +0 -47
- data/spec/features/admin/configuration/shipping_methods_spec.rb +0 -62
- data/spec/features/admin/configuration/states_spec.rb +0 -68
- data/spec/features/admin/configuration/stock_locations_spec.rb +0 -48
- data/spec/features/admin/configuration/store_credit_categories_spec.rb +0 -50
- data/spec/features/admin/configuration/tax_categories_spec.rb +0 -56
- data/spec/features/admin/configuration/tax_rates_spec.rb +0 -18
- data/spec/features/admin/configuration/zones_spec.rb +0 -39
- data/spec/features/admin/homepage_spec.rb +0 -89
- data/spec/features/admin/locale_spec.rb +0 -31
- data/spec/features/admin/orders/adjustments_promotions_spec.rb +0 -53
- data/spec/features/admin/orders/adjustments_spec.rb +0 -130
- data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +0 -47
- data/spec/features/admin/orders/customer_details_spec.rb +0 -154
- data/spec/features/admin/orders/line_items_spec.rb +0 -51
- data/spec/features/admin/orders/listing_spec.rb +0 -224
- data/spec/features/admin/orders/log_entries_spec.rb +0 -55
- data/spec/features/admin/orders/new_order_spec.rb +0 -186
- data/spec/features/admin/orders/order_details_spec.rb +0 -662
- data/spec/features/admin/orders/payments_spec.rb +0 -231
- data/spec/features/admin/orders/risk_analysis_spec.rb +0 -48
- data/spec/features/admin/orders/shipments_spec.rb +0 -64
- data/spec/features/admin/orders/state_changes_spec.rb +0 -21
- data/spec/features/admin/products/edit/images_spec.rb +0 -86
- data/spec/features/admin/products/edit/products_spec.rb +0 -64
- data/spec/features/admin/products/edit/taxons_spec.rb +0 -41
- data/spec/features/admin/products/edit/variants_spec.rb +0 -56
- data/spec/features/admin/products/option_types_spec.rb +0 -114
- data/spec/features/admin/products/products_spec.rb +0 -445
- data/spec/features/admin/products/properties_spec.rb +0 -147
- data/spec/features/admin/products/prototypes_spec.rb +0 -112
- data/spec/features/admin/products/stock_management_spec.rb +0 -124
- data/spec/features/admin/products/taxonomies_spec.rb +0 -52
- data/spec/features/admin/products/variant_spec.rb +0 -50
- data/spec/features/admin/promotions/adjustments_spec.rb +0 -258
- data/spec/features/admin/promotions/option_value_rule_spec.rb +0 -70
- data/spec/features/admin/promotions/tiered_calculator_spec.rb +0 -70
- data/spec/features/admin/refund_reasons/refund_reasons_spec.rb +0 -57
- data/spec/features/admin/reimbursement_type/edit_reimbursement_type_spec.rb +0 -36
- data/spec/features/admin/reimbursement_type/new_reimbursement_type_spec.rb +0 -62
- data/spec/features/admin/reports_spec.rb +0 -61
- data/spec/features/admin/return_authorization_reasons/return_authorization_reasons_spec.rb +0 -63
- data/spec/features/admin/returns/customer_returns_spec.rb +0 -80
- data/spec/features/admin/returns/return_authorizations_spec.rb +0 -152
- data/spec/features/admin/stock_transfer_spec.rb +0 -75
- data/spec/features/admin/store_credits_spec.rb +0 -93
- data/spec/features/admin/taxons_spec.rb +0 -47
- data/spec/features/admin/users_spec.rb +0 -286
- data/spec/helpers/admin/base_helper_spec.rb +0 -30
- data/spec/helpers/admin/navigation_helper_spec.rb +0 -111
- data/spec/helpers/admin/promotion_rules_helper_spec.rb +0 -12
- data/spec/helpers/admin/stock_movements_helper_spec.rb +0 -30
- data/spec/models/spree/resource_spec.rb +0 -48
- data/spec/routing/admin_path_spec.rb +0 -22
- data/spec/spec_helper.rb +0 -144
- data/spec/support/appear_before_matcher.rb +0 -8
- data/spec/support/ror_ringer.jpeg +0 -0
- data/spec/test_views/spree/admin/submodule/posts/edit.html.erb +0 -1
- data/spec/test_views/spree/admin/submodule/posts/new.html.erb +0 -1
- data/spec/test_views/spree/admin/widgets/edit.html.erb +0 -1
- data/spec/test_views/spree/admin/widgets/new.html.erb +0 -1
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe "Adjustments Promotions", type: :feature do
|
|
4
|
-
stub_authorization!
|
|
5
|
-
|
|
6
|
-
before(:each) do
|
|
7
|
-
promotion = create(:promotion_with_item_adjustment,
|
|
8
|
-
name: "$10 off",
|
|
9
|
-
path: 'test',
|
|
10
|
-
code: "10_off",
|
|
11
|
-
starts_at: 1.day.ago,
|
|
12
|
-
expires_at: 1.day.from_now,
|
|
13
|
-
adjustment_rate: 10)
|
|
14
|
-
|
|
15
|
-
order = create(:order_with_totals)
|
|
16
|
-
line_item = order.line_items.first
|
|
17
|
-
# so we can be sure of a determinate price in our assertions
|
|
18
|
-
line_item.update_column(:price, 10)
|
|
19
|
-
|
|
20
|
-
visit spree.admin_order_adjustments_path(order)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
context "admin adding a promotion" do
|
|
24
|
-
context "successfully" do
|
|
25
|
-
it "should create a new adjustment", js: true do
|
|
26
|
-
fill_in "coupon_code", with: "10_off"
|
|
27
|
-
click_button "Add Coupon Code"
|
|
28
|
-
expect(page).to have_content("$10 off")
|
|
29
|
-
expect(page).to have_content("-$10.00")
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
context "for non-existing promotion" do
|
|
34
|
-
it "should show an error message", js: true do
|
|
35
|
-
fill_in "coupon_code", with: "does_not_exist"
|
|
36
|
-
click_button "Add Coupon Code"
|
|
37
|
-
expect(page).to have_content("doesn't exist.")
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
context "for already applied promotion" do
|
|
42
|
-
it "should show an error message", js: true do
|
|
43
|
-
fill_in "coupon_code", with: "10_off"
|
|
44
|
-
click_button "Add Coupon Code"
|
|
45
|
-
expect(page).to have_content('-$10.00')
|
|
46
|
-
|
|
47
|
-
fill_in "coupon_code", with: "10_off"
|
|
48
|
-
click_button "Add Coupon Code"
|
|
49
|
-
expect(page).to have_content("already been applied")
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
end
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe "Adjustments", type: :feature do
|
|
4
|
-
stub_authorization!
|
|
5
|
-
|
|
6
|
-
let!(:order) { create(:completed_order_with_totals, line_items_count: 5) }
|
|
7
|
-
let!(:line_item) do
|
|
8
|
-
line_item = order.line_items.first
|
|
9
|
-
# so we can be sure of a determinate price in our assertions
|
|
10
|
-
line_item.update_column(:price, 10)
|
|
11
|
-
line_item
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
let!(:tax_adjustment) do
|
|
15
|
-
create(:tax_adjustment,
|
|
16
|
-
adjustable: line_item,
|
|
17
|
-
state: 'closed',
|
|
18
|
-
order: order,
|
|
19
|
-
label: "VAT 5%",
|
|
20
|
-
amount: 10)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
let!(:adjustment) { order.adjustments.create!(order: order, label: 'Rebate', amount: 10) }
|
|
24
|
-
|
|
25
|
-
before(:each) do
|
|
26
|
-
# To ensure the order totals are correct
|
|
27
|
-
order.update_totals
|
|
28
|
-
order.persist_totals
|
|
29
|
-
|
|
30
|
-
visit spree.admin_orders_path
|
|
31
|
-
within_row(1) { click_on order.number }
|
|
32
|
-
click_on "Adjustments"
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
after :each do
|
|
36
|
-
order.reload.all_adjustments.each do |adjustment|
|
|
37
|
-
expect(adjustment.order_id).to equal(order.id)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
context "admin managing adjustments" do
|
|
42
|
-
it "should display the correct values for existing order adjustments" do
|
|
43
|
-
within_row(1) do
|
|
44
|
-
expect(column_text(2)).to eq("VAT 5%")
|
|
45
|
-
expect(column_text(3)).to eq("$10.00")
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it "only shows eligible adjustments" do
|
|
50
|
-
expect(page).not_to have_content("ineligible")
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
context "admin creating a new adjustment" do
|
|
55
|
-
before(:each) do
|
|
56
|
-
click_link "New Adjustment"
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
context "successfully" do
|
|
60
|
-
it "should create a new adjustment" do
|
|
61
|
-
fill_in "adjustment_amount", with: "10"
|
|
62
|
-
fill_in "adjustment_label", with: "rebate"
|
|
63
|
-
click_button "Continue"
|
|
64
|
-
expect(page).to have_content("successfully created!")
|
|
65
|
-
expect(page).to have_content("Total: $80.00")
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
context "with validation errors" do
|
|
70
|
-
it "should not create a new adjustment" do
|
|
71
|
-
fill_in "adjustment_amount", with: ""
|
|
72
|
-
fill_in "adjustment_label", with: ""
|
|
73
|
-
click_button "Continue"
|
|
74
|
-
expect(page).to have_content("Label can't be blank")
|
|
75
|
-
expect(page).to have_content("Amount is not a number")
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
context "admin editing an adjustment", js: true do
|
|
81
|
-
|
|
82
|
-
before(:each) do
|
|
83
|
-
within_row(2) { click_icon :edit }
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
context "successfully" do
|
|
87
|
-
it "should update the adjustment" do
|
|
88
|
-
fill_in "adjustment_amount", with: "99"
|
|
89
|
-
fill_in "adjustment_label", with: "rebate 99"
|
|
90
|
-
click_button "Continue"
|
|
91
|
-
expect(page).to have_content("successfully updated!")
|
|
92
|
-
expect(page).to have_content("rebate 99")
|
|
93
|
-
within(".adjustments") do
|
|
94
|
-
expect(page).to have_content("$99.00")
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
expect(page).to have_content("Total: $159.00")
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
|
|
101
|
-
context "with validation errors" do
|
|
102
|
-
it "should not update the adjustment" do
|
|
103
|
-
fill_in "adjustment_amount", with: ""
|
|
104
|
-
fill_in "adjustment_label", with: ""
|
|
105
|
-
click_button "Continue"
|
|
106
|
-
expect(page).to have_content("Label can't be blank")
|
|
107
|
-
expect(page).to have_content("Amount is not a number")
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
context "deleting an adjustment" do
|
|
113
|
-
it "should not be possible if adjustment is closed" do
|
|
114
|
-
within_row(1) do
|
|
115
|
-
expect(page).not_to have_css('.fa-delete')
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
it "should update the total", js: true do
|
|
120
|
-
accept_alert do
|
|
121
|
-
within_row(2) do
|
|
122
|
-
click_icon(:delete)
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
wait_for_ajax
|
|
127
|
-
expect(page).to have_content(/Total: ?\$170\.00/)
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
end
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe "Cancelling + Resuming", type: :feature do
|
|
4
|
-
|
|
5
|
-
stub_authorization!
|
|
6
|
-
|
|
7
|
-
let(:user) { double(id: 123, has_spree_role?: true, spree_api_key: 'fake') }
|
|
8
|
-
|
|
9
|
-
before do
|
|
10
|
-
allow_any_instance_of(Spree::Admin::BaseController).to receive(:try_spree_current_user).and_return(user)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
let(:order) do
|
|
14
|
-
order = create(:order)
|
|
15
|
-
order.update_columns({
|
|
16
|
-
state: 'complete',
|
|
17
|
-
completed_at: Time.current
|
|
18
|
-
})
|
|
19
|
-
order
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "can cancel an order" do
|
|
23
|
-
visit spree.edit_admin_order_path(order.number)
|
|
24
|
-
click_button 'Cancel'
|
|
25
|
-
within(".additional-info") do
|
|
26
|
-
within(".state") do
|
|
27
|
-
expect(page).to have_content("canceled")
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
context "with a cancelled order" do
|
|
33
|
-
before do
|
|
34
|
-
order.update_column(:state, 'canceled')
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it "can resume an order" do
|
|
38
|
-
visit spree.edit_admin_order_path(order.number)
|
|
39
|
-
click_button 'Resume'
|
|
40
|
-
within(".additional-info") do
|
|
41
|
-
within(".state") do
|
|
42
|
-
expect(page).to have_content("resumed")
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe "Customer Details", type: :feature, js: true do
|
|
4
|
-
stub_authorization!
|
|
5
|
-
|
|
6
|
-
let!(:country) { create(:country, name: 'United States of America', iso: 'US') }
|
|
7
|
-
let!(:state) { create(:state, name: "Alabama", country: country, abbr: 'AL') }
|
|
8
|
-
let!(:shipping_method) { create(:shipping_method, display_on: "front_end") }
|
|
9
|
-
let!(:order) { create(:order, state: 'complete', completed_at: "2011-02-01 12:36:15") }
|
|
10
|
-
let!(:product) { create(:product_in_stock) }
|
|
11
|
-
|
|
12
|
-
# We need a unique name that will appear for the customer dropdown
|
|
13
|
-
let!(:ship_address) { create(:address, country: country, state: state, first_name: "Rumpelstiltskin") }
|
|
14
|
-
let!(:bill_address) { create(:address, country: country, state: state, first_name: "Rumpelstiltskin") }
|
|
15
|
-
|
|
16
|
-
let!(:user) { create(:user, email: 'foobar@example.com', ship_address: ship_address, bill_address: bill_address) }
|
|
17
|
-
|
|
18
|
-
# Value attribute is dynamically set via JS, so not observable via a CSS/XPath selector
|
|
19
|
-
# As the browser might take time to make the values visible in the dom we need to
|
|
20
|
-
# "intelligiently" wait for that event o prevent a race.
|
|
21
|
-
def expect_form_value(id, value)
|
|
22
|
-
node = page.find(id)
|
|
23
|
-
wait_for_condition { node.value.eql?(value) }
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
context "brand new order" do
|
|
27
|
-
before do
|
|
28
|
-
allow(Spree.user_class).to receive(:find_by).and_return(user)
|
|
29
|
-
visit spree.new_admin_order_path
|
|
30
|
-
end
|
|
31
|
-
# Regression test for #3335 & #5317
|
|
32
|
-
it "associates a user when not using guest checkout" do
|
|
33
|
-
select2_search product.name, from: Spree.t(:name_or_sku)
|
|
34
|
-
within("table.stock-levels") do
|
|
35
|
-
fill_in "variant_quantity", with: 1
|
|
36
|
-
click_icon :add
|
|
37
|
-
end
|
|
38
|
-
wait_for_ajax
|
|
39
|
-
click_link "Customer"
|
|
40
|
-
targetted_select2 "foobar@example.com", from: "#s2id_customer_search"
|
|
41
|
-
# 5317 - Address prefills using user's default.
|
|
42
|
-
expect_form_value('#order_bill_address_attributes_firstname', user.bill_address.firstname)
|
|
43
|
-
expect_form_value('#order_bill_address_attributes_lastname', user.bill_address.lastname)
|
|
44
|
-
expect_form_value('#order_bill_address_attributes_address1', user.bill_address.address1)
|
|
45
|
-
expect_form_value('#order_bill_address_attributes_address2', user.bill_address.address2)
|
|
46
|
-
expect_form_value('#order_bill_address_attributes_city', user.bill_address.city)
|
|
47
|
-
expect_form_value('#order_bill_address_attributes_zipcode', user.bill_address.zipcode)
|
|
48
|
-
expect_form_value('#order_bill_address_attributes_country_id', user.bill_address.country_id.to_s)
|
|
49
|
-
expect_form_value('#order_bill_address_attributes_state_id', user.bill_address.state_id.to_s)
|
|
50
|
-
expect_form_value('#order_bill_address_attributes_phone', user.bill_address.phone)
|
|
51
|
-
click_button "Update"
|
|
52
|
-
expect(Spree::Order.last.user).to eq(user)
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
context "editing an order" do
|
|
57
|
-
before do
|
|
58
|
-
configure_spree_preferences do |config|
|
|
59
|
-
config.default_country_id = country.id
|
|
60
|
-
config.company = true
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
allow(Spree.user_class).to receive(:find_by).and_return(user)
|
|
64
|
-
visit spree.admin_orders_path
|
|
65
|
-
within('table#listing_orders') { click_icon(:edit) }
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
context "selected country has no state" do
|
|
69
|
-
before { create(:country, iso: "BRA", name: "Brazil") }
|
|
70
|
-
|
|
71
|
-
it "changes state field to text input" do
|
|
72
|
-
click_link "Customer"
|
|
73
|
-
|
|
74
|
-
within("#billing") do
|
|
75
|
-
targetted_select2 "Brazil", from: "#s2id_order_bill_address_attributes_country_id"
|
|
76
|
-
fill_in "order_bill_address_attributes_state_name", with: "Piaui"
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
click_button "Update"
|
|
80
|
-
expect(find_field("order_bill_address_attributes_state_name").value).to eq("Piaui")
|
|
81
|
-
end
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
it "should be able to update customer details for an existing order" do
|
|
85
|
-
order.ship_address = create(:address)
|
|
86
|
-
order.save!
|
|
87
|
-
|
|
88
|
-
click_link "Customer"
|
|
89
|
-
within("#shipping") { fill_in_address "ship" }
|
|
90
|
-
within("#billing") { fill_in_address "bill" }
|
|
91
|
-
|
|
92
|
-
click_button "Update"
|
|
93
|
-
click_link "Customer"
|
|
94
|
-
|
|
95
|
-
# Regression test for #2950 + #2433
|
|
96
|
-
# This act should transition the state of the order as far as it will go too
|
|
97
|
-
within("#order_tab_summary") do
|
|
98
|
-
expect(find(".state").text).to eq("complete")
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
it "should show validation errors" do
|
|
103
|
-
click_link "Customer"
|
|
104
|
-
click_button "Update"
|
|
105
|
-
expect(page).to have_content("Shipping address first name can't be blank")
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
it "updates order email for an existing order with a user" do
|
|
109
|
-
order.update_columns(ship_address_id: ship_address.id, bill_address_id: bill_address.id, state: "confirm", completed_at: nil)
|
|
110
|
-
previous_user = order.user
|
|
111
|
-
click_link "Customer"
|
|
112
|
-
fill_in "order_email", with: "newemail@example.com"
|
|
113
|
-
expect(order.user_id).to eq previous_user.id
|
|
114
|
-
expect(order.user.email).to eq previous_user.email
|
|
115
|
-
expect { click_button "Update" }.to change { order.reload.email }.to "newemail@example.com"
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
# Regression test for #942
|
|
119
|
-
context "errors when no shipping methods are available" do
|
|
120
|
-
before do
|
|
121
|
-
Spree::ShippingMethod.delete_all
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
specify do
|
|
125
|
-
click_link "Customer"
|
|
126
|
-
# Need to fill in valid information so it passes validations
|
|
127
|
-
fill_in "order_ship_address_attributes_firstname", with: "John 99"
|
|
128
|
-
fill_in "order_ship_address_attributes_lastname", with: "Doe"
|
|
129
|
-
fill_in "order_ship_address_attributes_lastname", with: "Company"
|
|
130
|
-
fill_in "order_ship_address_attributes_address1", with: "100 first lane"
|
|
131
|
-
fill_in "order_ship_address_attributes_address2", with: "#101"
|
|
132
|
-
fill_in "order_ship_address_attributes_city", with: "Bethesda"
|
|
133
|
-
fill_in "order_ship_address_attributes_zipcode", with: "20170"
|
|
134
|
-
|
|
135
|
-
page.select('Alabama', from: 'order_ship_address_attributes_state_id')
|
|
136
|
-
fill_in "order_ship_address_attributes_phone", with: "123-456-7890"
|
|
137
|
-
expect { click_button "Update" }.not_to raise_error
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
def fill_in_address(kind = "bill")
|
|
143
|
-
fill_in "First Name", with: "John 99"
|
|
144
|
-
fill_in "Last Name", with: "Doe"
|
|
145
|
-
fill_in "Company", with: "Company"
|
|
146
|
-
fill_in "Street Address", with: "100 first lane"
|
|
147
|
-
fill_in "Street Address (cont'd)", with: "#101"
|
|
148
|
-
fill_in "City", with: "Bethesda"
|
|
149
|
-
fill_in "Zip", with: "20170"
|
|
150
|
-
targetted_select2 country.name, from: "#s2id_order_#{kind}_address_attributes_country_id"
|
|
151
|
-
targetted_select2 state.name, from: "#s2id_order_#{kind}_address_attributes_state_id"
|
|
152
|
-
fill_in "Phone", with: "123-456-7890"
|
|
153
|
-
end
|
|
154
|
-
end
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
# Tests for #3958's features
|
|
4
|
-
describe "Order Line Items", type: :feature, js: true do
|
|
5
|
-
stub_authorization!
|
|
6
|
-
|
|
7
|
-
before do
|
|
8
|
-
# Removing the delivery step causes the order page to render a different
|
|
9
|
-
# partial, called _line_items, which shows line items rather than shipments
|
|
10
|
-
allow(Spree::Order).to receive_messages checkout_step_names: [:address, :payment, :confirm, :complete]
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
let!(:order) do
|
|
14
|
-
order = create(:order_with_line_items, line_items_count: 1)
|
|
15
|
-
order.shipments.destroy_all
|
|
16
|
-
order
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it "can edit a line item's quantity" do
|
|
20
|
-
visit spree.edit_admin_order_path(order)
|
|
21
|
-
within(".line-items") do
|
|
22
|
-
within_row(1) do
|
|
23
|
-
find(".edit-line-item").click
|
|
24
|
-
fill_in "quantity", with: 10
|
|
25
|
-
find(".save-line-item").click
|
|
26
|
-
within '.line-item-qty-show' do
|
|
27
|
-
expect(page).to have_content("10")
|
|
28
|
-
end
|
|
29
|
-
within '.line-item-total' do
|
|
30
|
-
expect(page).to have_content("$199.90")
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it "can delete a line item" do
|
|
37
|
-
visit spree.edit_admin_order_path(order)
|
|
38
|
-
|
|
39
|
-
product_name = find(".line-items tr:nth-child(1) .line-item-name").text
|
|
40
|
-
|
|
41
|
-
within(".line-items") do
|
|
42
|
-
within_row(1) do
|
|
43
|
-
accept_alert do
|
|
44
|
-
find(".delete-line-item").click
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
expect(page).not_to have_content(product_name)
|
|
50
|
-
end
|
|
51
|
-
end
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
describe "Orders Listing", type: :feature do
|
|
4
|
-
stub_authorization!
|
|
5
|
-
|
|
6
|
-
let(:order1) do
|
|
7
|
-
create :order_with_line_items,
|
|
8
|
-
created_at: 1.day.from_now,
|
|
9
|
-
completed_at: 1.day.from_now,
|
|
10
|
-
considered_risky: true,
|
|
11
|
-
number: "R100"
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
let(:order2) do
|
|
15
|
-
create :order,
|
|
16
|
-
created_at: 1.day.ago,
|
|
17
|
-
completed_at: 1.day.ago,
|
|
18
|
-
number: "R200"
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
before do
|
|
22
|
-
allow_any_instance_of(Spree::OrderInventory).to receive(:add_to_shipment)
|
|
23
|
-
# create the order instances after stubbing the `add_to_shipment` method
|
|
24
|
-
order1; order2
|
|
25
|
-
visit spree.admin_orders_path
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
describe "listing orders" do
|
|
29
|
-
it "should list existing orders" do
|
|
30
|
-
within_row(1) do
|
|
31
|
-
expect(column_text(2)).to eq "R100"
|
|
32
|
-
expect(find("td:nth-child(3)")).to have_css '.label-considered_risky'
|
|
33
|
-
expect(column_text(4)).to eq "cart"
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
within_row(2) do
|
|
37
|
-
expect(column_text(2)).to eq "R200"
|
|
38
|
-
expect(find("td:nth-child(3)")).to have_css '.label-considered_safe'
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it "should be able to sort the orders listing" do
|
|
43
|
-
# default is completed_at desc
|
|
44
|
-
within_row(1) { expect(page).to have_content("R100") }
|
|
45
|
-
within_row(2) { expect(page).to have_content("R200") }
|
|
46
|
-
|
|
47
|
-
click_link "Completed At"
|
|
48
|
-
|
|
49
|
-
# Completed at desc
|
|
50
|
-
within_row(1) { expect(page).to have_content("R200") }
|
|
51
|
-
within_row(2) { expect(page).to have_content("R100") }
|
|
52
|
-
|
|
53
|
-
within('table#listing_orders thead') { click_link "Number" }
|
|
54
|
-
|
|
55
|
-
# number asc
|
|
56
|
-
within_row(1) { expect(page).to have_content("R100") }
|
|
57
|
-
within_row(2) { expect(page).to have_content("R200") }
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
describe "searching orders" do
|
|
62
|
-
it "should be able to search orders" do
|
|
63
|
-
fill_in "q_number_cont", with: "R200"
|
|
64
|
-
click_on 'Filter Results'
|
|
65
|
-
within_row(1) do
|
|
66
|
-
expect(page).to have_content("R200")
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# Ensure that the other order doesn't show up
|
|
70
|
-
within("table#listing_orders") { expect(page).not_to have_content("R100") }
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it "should return both complete and incomplete orders when only complete orders is not checked" do
|
|
74
|
-
Spree::Order.create! email: "incomplete@example.com", completed_at: nil, state: 'cart'
|
|
75
|
-
click_on 'Filter'
|
|
76
|
-
uncheck "q_completed_at_not_null"
|
|
77
|
-
click_on 'Filter Results'
|
|
78
|
-
|
|
79
|
-
expect(page).to have_content("R200")
|
|
80
|
-
expect(page).to have_content("incomplete@example.com")
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it "should be able to filter risky orders" do
|
|
84
|
-
# Check risky and filter
|
|
85
|
-
check "q_considered_risky_eq"
|
|
86
|
-
click_on 'Filter Results'
|
|
87
|
-
|
|
88
|
-
# Insure checkbox still checked
|
|
89
|
-
expect(find("#q_considered_risky_eq")).to be_checked
|
|
90
|
-
# Insure we have the risky order, R100
|
|
91
|
-
within_row(1) do
|
|
92
|
-
expect(page).to have_content("R100")
|
|
93
|
-
end
|
|
94
|
-
# Insure the non risky order is not present
|
|
95
|
-
expect(page).not_to have_content("R200")
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
it "should be able to filter on variant_sku" do
|
|
99
|
-
click_on 'Filter'
|
|
100
|
-
fill_in "q_line_items_variant_sku_eq", with: order1.line_items.first.variant.sku
|
|
101
|
-
click_on 'Filter Results'
|
|
102
|
-
|
|
103
|
-
within_row(1) do
|
|
104
|
-
expect(page).to have_content(order1.number)
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
expect(page).not_to have_content(order2.number)
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
context "when pagination is really short" do
|
|
111
|
-
before do
|
|
112
|
-
@old_per_page = Spree::Config[:admin_orders_per_page]
|
|
113
|
-
Spree::Config[:admin_orders_per_page] = 1
|
|
114
|
-
end
|
|
115
|
-
|
|
116
|
-
after do
|
|
117
|
-
Spree::Config[:admin_orders_per_page] = @old_per_page
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
# Regression test for #4004
|
|
121
|
-
it "should be able to go from page to page for incomplete orders" do
|
|
122
|
-
Spree::Order.destroy_all
|
|
123
|
-
2.times { Spree::Order.create! email: "incomplete@example.com", completed_at: nil, state: 'cart' }
|
|
124
|
-
click_on 'Filter'
|
|
125
|
-
uncheck "q_completed_at_not_null"
|
|
126
|
-
click_on 'Filter Results'
|
|
127
|
-
within(".pagination") do
|
|
128
|
-
click_link "2"
|
|
129
|
-
end
|
|
130
|
-
expect(page).to have_content("incomplete@example.com")
|
|
131
|
-
expect(find("#q_completed_at_not_null")).not_to be_checked
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
it "should be able to search orders using only completed at input" do
|
|
136
|
-
fill_in "q_created_at_gt", with: Date.current
|
|
137
|
-
click_on 'Filter Results'
|
|
138
|
-
|
|
139
|
-
within_row(1) { expect(page).to have_content("R100") }
|
|
140
|
-
|
|
141
|
-
# Ensure that the other order doesn't show up
|
|
142
|
-
within("table#listing_orders") { expect(page).not_to have_content("R200") }
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
context "filter on promotions" do
|
|
146
|
-
let!(:promotion) { create(:promotion_with_item_adjustment) }
|
|
147
|
-
|
|
148
|
-
before do
|
|
149
|
-
order1.promotions << promotion
|
|
150
|
-
order1.save
|
|
151
|
-
visit spree.admin_orders_path
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
it "only shows the orders with the selected promotion" do
|
|
155
|
-
select promotion.name, from: "Promotion"
|
|
156
|
-
click_on 'Filter Results'
|
|
157
|
-
within_row(1) { expect(page).to have_content("R100") }
|
|
158
|
-
within("table#listing_orders") { expect(page).not_to have_content("R200") }
|
|
159
|
-
end
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
it "should be able to apply a ransack filter by clicking a quickfilter icon", js: true do
|
|
163
|
-
label_pending = page.find '.label-pending'
|
|
164
|
-
parent_td = label_pending.find(:xpath, '..')
|
|
165
|
-
|
|
166
|
-
# Click the quick filter Pending for order #R100
|
|
167
|
-
within(parent_td) do
|
|
168
|
-
find('.js-add-filter').click
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
expect(page).to have_content("R100")
|
|
172
|
-
expect(page).not_to have_content("R200")
|
|
173
|
-
end
|
|
174
|
-
|
|
175
|
-
context "filter on shipment state" do
|
|
176
|
-
it "only shows the orders with the selected shipment state" do
|
|
177
|
-
select Spree.t("payment_states.#{order1.shipment_state}"), from: "Shipment State"
|
|
178
|
-
click_on 'Filter Results'
|
|
179
|
-
within_row(1) { expect(page).to have_content("R100") }
|
|
180
|
-
within("table#listing_orders") { expect(page).not_to have_content("R200") }
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
context "filter on payment state" do
|
|
185
|
-
it "only shows the orders with the selected payment state" do
|
|
186
|
-
select Spree.t("payment_states.#{order1.payment_state}"), from: "Payment State"
|
|
187
|
-
click_on 'Filter Results'
|
|
188
|
-
within_row(1) { expect(page).to have_content("R100") }
|
|
189
|
-
within("table#listing_orders") { expect(page).not_to have_content("R200") }
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
# regression tests for https://github.com/spree/spree/issues/6888
|
|
194
|
-
context "per page dropdown", js: true do
|
|
195
|
-
before do
|
|
196
|
-
select "45", from: "per_page"
|
|
197
|
-
wait_for_ajax
|
|
198
|
-
expect(page).to have_select("per_page", selected: "45")
|
|
199
|
-
expect(page).to have_selector(:css, "select.per-page-selected-45")
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
it "adds per_page parameter to url" do
|
|
203
|
-
expect(current_url).to match(/per_page\=45/)
|
|
204
|
-
end
|
|
205
|
-
|
|
206
|
-
it "can be used with search filtering" do
|
|
207
|
-
click_on 'Filter'
|
|
208
|
-
fill_in "q_number_cont", with: "R200"
|
|
209
|
-
click_on 'Filter Results'
|
|
210
|
-
expect(page).not_to have_content("R100")
|
|
211
|
-
within_row(1) { expect(page).to have_content("R200") }
|
|
212
|
-
expect(current_url).to match(/per_page\=45/)
|
|
213
|
-
expect(page).to have_select("per_page", selected: "45")
|
|
214
|
-
select "60", from: "per_page"
|
|
215
|
-
wait_for_ajax
|
|
216
|
-
expect(page).to have_select("per_page", selected: "60")
|
|
217
|
-
expect(page).to have_selector(:css, "select.per-page-selected-60")
|
|
218
|
-
expect(page).not_to have_content("R100")
|
|
219
|
-
within_row(1) { expect(page).to have_content("R200") }
|
|
220
|
-
expect(current_url).to match(/per_page\=60/)
|
|
221
|
-
end
|
|
222
|
-
end
|
|
223
|
-
end
|
|
224
|
-
end
|