solidus_frontend 2.10.3 → 2.11.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_frontend might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree/frontend/checkout/address.js +1 -1
- data/app/assets/javascripts/spree/frontend/checkout/coupon-code.js +1 -1
- data/app/controllers/spree/checkout_controller.rb +9 -5
- data/app/controllers/spree/orders_controller.rb +9 -9
- data/app/controllers/spree/products_controller.rb +1 -1
- data/app/views/spree/address/_form.html.erb +15 -8
- data/app/views/spree/address/_form_hidden.html.erb +6 -2
- data/app/views/spree/checkout/payment/_gateway.html.erb +1 -1
- data/app/views/spree/orders/_form.html.erb +1 -1
- data/app/views/spree/shared/_address.html.erb +1 -1
- data/app/views/spree/shared/_image.html.erb +3 -2
- data/config/initializers/canonical_rails.rb +1 -1
- data/solidus_frontend.gemspec +6 -6
- metadata +11 -54
- data/script/rails +0 -10
- data/spec/controllers/controller_helpers_spec.rb +0 -29
- data/spec/controllers/locale_controller_spec.rb +0 -57
- data/spec/controllers/spree/checkout_controller_spec.rb +0 -610
- data/spec/controllers/spree/checkout_controller_with_views_spec.rb +0 -37
- data/spec/controllers/spree/content_controller_spec.rb +0 -9
- data/spec/controllers/spree/current_order_tracking_spec.rb +0 -47
- data/spec/controllers/spree/home_controller_spec.rb +0 -29
- data/spec/controllers/spree/orders_controller_ability_spec.rb +0 -90
- data/spec/controllers/spree/orders_controller_spec.rb +0 -254
- data/spec/controllers/spree/orders_controller_transitions_spec.rb +0 -33
- data/spec/controllers/spree/products_controller_spec.rb +0 -38
- data/spec/controllers/spree/taxons_controller_spec.rb +0 -14
- data/spec/features/address_spec.rb +0 -78
- data/spec/features/automatic_promotion_adjustments_spec.rb +0 -49
- data/spec/features/caching/products_spec.rb +0 -48
- data/spec/features/caching/taxons_spec.rb +0 -21
- data/spec/features/cart_spec.rb +0 -85
- data/spec/features/checkout_confirm_insufficient_stock_spec.rb +0 -71
- data/spec/features/checkout_spec.rb +0 -758
- data/spec/features/checkout_unshippable_spec.rb +0 -37
- data/spec/features/coupon_code_spec.rb +0 -266
- data/spec/features/currency_spec.rb +0 -20
- data/spec/features/first_order_promotion_spec.rb +0 -59
- data/spec/features/free_shipping_promotions_spec.rb +0 -60
- data/spec/features/locale_spec.rb +0 -26
- data/spec/features/order_spec.rb +0 -73
- data/spec/features/products_spec.rb +0 -291
- data/spec/features/promotion_code_invalidation_spec.rb +0 -54
- data/spec/features/quantity_promotions_spec.rb +0 -130
- data/spec/features/taxons_spec.rb +0 -158
- data/spec/features/template_rendering_spec.rb +0 -20
- data/spec/fixtures/thinking-cat.jpg +0 -0
- data/spec/generators/solidus/views/override_generator_spec.rb +0 -50
- data/spec/helpers/base_helper_spec.rb +0 -13
- data/spec/helpers/order_helper_spec.rb +0 -14
- data/spec/helpers/taxon_filters_helper_spec.rb +0 -12
- data/spec/spec_helper.rb +0 -106
- data/spec/support/shared_contexts/checkout_setup.rb +0 -12
- data/spec/support/shared_contexts/custom_products.rb +0 -28
- data/spec/support/shared_contexts/locales.rb +0 -16
- data/spec/views/spree/checkout/_summary_spec.rb +0 -11
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
# This spec is useful for when we just want to make sure a view is rendering correctly
|
6
|
-
# Walking through the entire checkout process is rather tedious, don't you think?
|
7
|
-
describe Spree::CheckoutController, type: :controller do
|
8
|
-
render_views
|
9
|
-
let(:token) { 'some_token' }
|
10
|
-
let(:user) { stub_model(Spree::LegacyUser) }
|
11
|
-
|
12
|
-
before do
|
13
|
-
allow(controller).to receive_messages try_spree_current_user: user
|
14
|
-
end
|
15
|
-
|
16
|
-
# Regression test for https://github.com/spree/spree/issues/3246
|
17
|
-
context "when using GBP" do
|
18
|
-
before do
|
19
|
-
stub_spree_preferences(currency: "GBP")
|
20
|
-
end
|
21
|
-
|
22
|
-
context "when order is in delivery" do
|
23
|
-
before do
|
24
|
-
# Using a let block won't acknowledge the currency setting
|
25
|
-
# Therefore we just do it like this...
|
26
|
-
order = Spree::TestingSupport::OrderWalkthrough.up_to(:address)
|
27
|
-
allow(controller).to receive_messages current_order: order
|
28
|
-
end
|
29
|
-
|
30
|
-
it "displays rate cost in correct currency" do
|
31
|
-
get :edit
|
32
|
-
html = Nokogiri::HTML(response.body)
|
33
|
-
expect(html.css('.rate-cost').text).to eq "£10.00"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe 'current order tracking', type: :controller do
|
6
|
-
let!(:store) { create(:store) }
|
7
|
-
let(:user) { create(:user) }
|
8
|
-
|
9
|
-
controller(Spree::StoreController) do
|
10
|
-
def index
|
11
|
-
head :ok
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:order) { FactoryBot.create(:order) }
|
16
|
-
|
17
|
-
it 'automatically tracks who the order was created by & IP address' do
|
18
|
-
allow(controller).to receive_messages(try_spree_current_user: user)
|
19
|
-
get :index
|
20
|
-
expect(controller.current_order(create_order_if_necessary: true).created_by).to eq controller.try_spree_current_user
|
21
|
-
expect(controller.current_order.last_ip_address).to eq "0.0.0.0"
|
22
|
-
end
|
23
|
-
|
24
|
-
context "current order creation" do
|
25
|
-
before { allow(controller).to receive_messages(try_spree_current_user: user) }
|
26
|
-
|
27
|
-
it "doesn't create a new order out of the blue" do
|
28
|
-
expect {
|
29
|
-
get :index
|
30
|
-
}.not_to change { Spree::Order.count }
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe Spree::OrdersController, type: :controller do
|
36
|
-
let(:user) { create(:user) }
|
37
|
-
|
38
|
-
before { allow(controller).to receive_messages(try_spree_current_user: user) }
|
39
|
-
|
40
|
-
describe Spree::OrdersController do
|
41
|
-
it "doesn't create a new order out of the blue" do
|
42
|
-
expect {
|
43
|
-
get :edit
|
44
|
-
}.not_to change { Spree::Order.count }
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Spree::HomeController, type: :controller do
|
6
|
-
it "provides current user to the searcher class" do
|
7
|
-
user = mock_model(Spree.user_class, last_incomplete_spree_order: nil, spree_api_key: 'fake')
|
8
|
-
allow(controller).to receive_messages try_spree_current_user: user
|
9
|
-
expect_any_instance_of(Spree::Config.searcher_class).to receive(:current_user=).with(user)
|
10
|
-
get :index
|
11
|
-
expect(response.status).to eq(200)
|
12
|
-
end
|
13
|
-
|
14
|
-
context "layout" do
|
15
|
-
it "renders default layout" do
|
16
|
-
get :index
|
17
|
-
expect(response).to render_template(layout: 'spree/layouts/spree_application')
|
18
|
-
end
|
19
|
-
|
20
|
-
context "different layout specified in config" do
|
21
|
-
before { stub_spree_preferences(layout: 'layouts/application') }
|
22
|
-
|
23
|
-
it "renders specified layout" do
|
24
|
-
get :index
|
25
|
-
expect(response).to render_template(layout: 'layouts/application')
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
module Spree
|
6
|
-
describe OrdersController, type: :controller do
|
7
|
-
ORDER_TOKEN = 'ORDER_TOKEN'
|
8
|
-
|
9
|
-
let!(:store) { create(:store) }
|
10
|
-
let(:order) { Spree::Order.create }
|
11
|
-
let(:variant) { create(:variant) }
|
12
|
-
|
13
|
-
it 'should understand order routes with token' do
|
14
|
-
expect(spree.token_order_path('R123456', 'ABCDEF')).to eq('/orders/R123456/token/ABCDEF')
|
15
|
-
end
|
16
|
-
|
17
|
-
context 'when an order exists in the cookies.signed' do
|
18
|
-
let(:token) { 'some_token' }
|
19
|
-
|
20
|
-
before do
|
21
|
-
allow(controller).to receive_messages current_order: order
|
22
|
-
end
|
23
|
-
|
24
|
-
context '#populate' do
|
25
|
-
it 'should check if user is authorized for :update' do
|
26
|
-
expect(controller).to receive(:authorize!).with(:update, order, token)
|
27
|
-
post :populate, params: { variant_id: variant.id, token: token }
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context '#edit' do
|
32
|
-
it 'should check if user is authorized for :read' do
|
33
|
-
expect(controller).to receive(:authorize!).with(:read, order, token)
|
34
|
-
get :edit, params: { token: token }
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
context '#update' do
|
39
|
-
it 'should check if user is authorized for :update' do
|
40
|
-
allow(order).to receive :update
|
41
|
-
expect(controller).to receive(:authorize!).with(:update, order, token)
|
42
|
-
post :update, params: { order: { email: "foo@bar.com" }, token: token }
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context '#empty' do
|
47
|
-
it 'should check if user is authorized for :update' do
|
48
|
-
expect(controller).to receive(:authorize!).with(:update, order, token)
|
49
|
-
post :empty, params: { token: token }
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
context "#show" do
|
54
|
-
let(:specified_order) { create(:order) }
|
55
|
-
|
56
|
-
it "should check against the specified order" do
|
57
|
-
expect(controller).to receive(:authorize!).with(:read, specified_order, token)
|
58
|
-
get :show, params: { id: specified_order.number, token: token }
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
context 'when no authenticated user' do
|
64
|
-
let(:order) { create(:order, number: 'R123') }
|
65
|
-
|
66
|
-
context '#show' do
|
67
|
-
context 'when token parameter present' do
|
68
|
-
it 'always ooverride existing token when passing a new one' do
|
69
|
-
cookies.signed[:guest_token] = "soo wrong"
|
70
|
-
get :show, params: { id: 'R123', token: order.guest_token }
|
71
|
-
expect(cookies.signed[:guest_token]).to eq(order.guest_token)
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'should store as guest_token in session' do
|
75
|
-
get :show, params: { id: 'R123', token: order.guest_token }
|
76
|
-
expect(cookies.signed[:guest_token]).to eq(order.guest_token)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
context 'when no token present' do
|
81
|
-
it 'should respond with 404' do
|
82
|
-
expect {
|
83
|
-
get :show, params: { id: 'R123' }
|
84
|
-
}.to raise_error(ActiveRecord::RecordNotFound)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
@@ -1,254 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
describe Spree::OrdersController, type: :controller do
|
6
|
-
let!(:store) { create(:store) }
|
7
|
-
let(:user) { create(:user) }
|
8
|
-
|
9
|
-
context "Order model mock" do
|
10
|
-
let(:order) do
|
11
|
-
Spree::Order.create!
|
12
|
-
end
|
13
|
-
let(:variant) { create(:variant) }
|
14
|
-
|
15
|
-
before do
|
16
|
-
allow(controller).to receive_messages(try_spree_current_user: user)
|
17
|
-
end
|
18
|
-
|
19
|
-
context "#populate" do
|
20
|
-
it "should create a new order when none specified" do
|
21
|
-
post :populate, params: { variant_id: variant.id }
|
22
|
-
expect(response).to be_redirect
|
23
|
-
expect(cookies.signed[:guest_token]).not_to be_blank
|
24
|
-
|
25
|
-
order_by_token = Spree::Order.find_by(guest_token: cookies.signed[:guest_token])
|
26
|
-
assigned_order = assigns[:order]
|
27
|
-
|
28
|
-
expect(assigned_order).to eq order_by_token
|
29
|
-
expect(assigned_order).to be_persisted
|
30
|
-
end
|
31
|
-
|
32
|
-
context "with Variant" do
|
33
|
-
it "should handle population" do
|
34
|
-
expect do
|
35
|
-
post :populate, params: { variant_id: variant.id, quantity: 5 }
|
36
|
-
end.to change { user.orders.count }.by(1)
|
37
|
-
order = user.orders.last
|
38
|
-
expect(response).to redirect_to spree.cart_path
|
39
|
-
expect(order.line_items.size).to eq(1)
|
40
|
-
line_item = order.line_items.first
|
41
|
-
expect(line_item.variant_id).to eq(variant.id)
|
42
|
-
expect(line_item.quantity).to eq(5)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "shows an error when population fails" do
|
46
|
-
request.env["HTTP_REFERER"] = spree.root_path
|
47
|
-
allow_any_instance_of(Spree::LineItem).to(
|
48
|
-
receive(:valid?).and_return(false)
|
49
|
-
)
|
50
|
-
allow_any_instance_of(Spree::LineItem).to(
|
51
|
-
receive_message_chain(:errors, :full_messages).
|
52
|
-
and_return(["Order population failed"])
|
53
|
-
)
|
54
|
-
|
55
|
-
post :populate, params: { variant_id: variant.id, quantity: 5 }
|
56
|
-
|
57
|
-
expect(response).to redirect_to(spree.root_path)
|
58
|
-
expect(flash[:error]).to eq("Order population failed")
|
59
|
-
end
|
60
|
-
|
61
|
-
it "shows an error when quantity is invalid" do
|
62
|
-
request.env["HTTP_REFERER"] = spree.root_path
|
63
|
-
|
64
|
-
post(
|
65
|
-
:populate,
|
66
|
-
params: { variant_id: variant.id, quantity: -1 }
|
67
|
-
)
|
68
|
-
|
69
|
-
expect(response).to redirect_to(spree.root_path)
|
70
|
-
expect(flash[:error]).to eq(
|
71
|
-
I18n.t('spree.please_enter_reasonable_quantity')
|
72
|
-
)
|
73
|
-
end
|
74
|
-
|
75
|
-
context "when quantity is empty string" do
|
76
|
-
it "should populate order with 1 of given variant" do
|
77
|
-
expect do
|
78
|
-
post :populate, params: { variant_id: variant.id, quantity: '' }
|
79
|
-
end.to change { Spree::Order.count }.by(1)
|
80
|
-
order = Spree::Order.last
|
81
|
-
expect(response).to redirect_to spree.cart_path
|
82
|
-
expect(order.line_items.size).to eq(1)
|
83
|
-
line_item = order.line_items.first
|
84
|
-
expect(line_item.variant_id).to eq(variant.id)
|
85
|
-
expect(line_item.quantity).to eq(1)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
context "when quantity is nil" do
|
90
|
-
it "should populate order with 1 of given variant" do
|
91
|
-
expect do
|
92
|
-
post :populate, params: { variant_id: variant.id, quantity: nil }
|
93
|
-
end.to change { Spree::Order.count }.by(1)
|
94
|
-
order = Spree::Order.last
|
95
|
-
expect(response).to redirect_to spree.cart_path
|
96
|
-
expect(order.line_items.size).to eq(1)
|
97
|
-
line_item = order.line_items.first
|
98
|
-
expect(line_item.variant_id).to eq(variant.id)
|
99
|
-
expect(line_item.quantity).to eq(1)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
context '#edit' do
|
106
|
-
before do
|
107
|
-
allow(controller).to receive :authorize!
|
108
|
-
allow(controller).to receive_messages current_order: order
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'should render cart' do
|
112
|
-
get :edit, params: { id: order.number }
|
113
|
-
|
114
|
-
expect(flash[:error]).to be_nil
|
115
|
-
expect(response).to be_ok
|
116
|
-
end
|
117
|
-
|
118
|
-
context 'with another order number than the current_order' do
|
119
|
-
let(:other_order) { create(:completed_order_with_totals) }
|
120
|
-
|
121
|
-
it 'should display error message' do
|
122
|
-
get :edit, params: { id: other_order.number }
|
123
|
-
|
124
|
-
expect(flash[:error]).to eq "You may only edit your current shopping cart."
|
125
|
-
expect(response).to redirect_to cart_path
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
context "#update" do
|
131
|
-
context "with authorization" do
|
132
|
-
before do
|
133
|
-
allow(controller).to receive :authorize!
|
134
|
-
allow(controller).to receive_messages current_order: order
|
135
|
-
end
|
136
|
-
|
137
|
-
it "should render the edit view (on failure)" do
|
138
|
-
# email validation is only after address state
|
139
|
-
order.update_column(:state, "delivery")
|
140
|
-
put :update, params: { order: { email: "" } }
|
141
|
-
expect(response).to render_template :edit
|
142
|
-
end
|
143
|
-
|
144
|
-
it "should redirect to cart path (on success)" do
|
145
|
-
allow(order).to receive(:update).and_return true
|
146
|
-
put :update
|
147
|
-
expect(response).to redirect_to(spree.cart_path)
|
148
|
-
end
|
149
|
-
|
150
|
-
it "should advance the order if :checkout button is pressed" do
|
151
|
-
allow(order).to receive(:update).and_return true
|
152
|
-
expect(order).to receive(:next)
|
153
|
-
put :update, params: { checkout: true }
|
154
|
-
expect(response).to redirect_to checkout_state_path('address')
|
155
|
-
end
|
156
|
-
|
157
|
-
context 'trying to apply a coupon code' do
|
158
|
-
let(:order) { create(:order_with_line_items, state: 'cart') }
|
159
|
-
let(:coupon_code) { "coupon_code" }
|
160
|
-
|
161
|
-
context "when coupon code is empty" do
|
162
|
-
let(:coupon_code) { "" }
|
163
|
-
|
164
|
-
it 'does not try to apply coupon code' do
|
165
|
-
expect(Spree::PromotionHandler::Coupon).not_to receive :new
|
166
|
-
|
167
|
-
put :update, params: { state: order.state, order: { coupon_code: coupon_code } }
|
168
|
-
|
169
|
-
expect(response).to redirect_to(spree.cart_path)
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
context "when coupon code is applied" do
|
174
|
-
let(:promotion_handler) { instance_double('Spree::PromotionHandler::Coupon', error: nil, success: 'Coupon Applied!') }
|
175
|
-
|
176
|
-
it "continues checkout flow normally" do
|
177
|
-
expect(Spree::Deprecation).to receive(:warn)
|
178
|
-
|
179
|
-
expect(Spree::PromotionHandler::Coupon)
|
180
|
-
.to receive_message_chain(:new, :apply)
|
181
|
-
.and_return(promotion_handler)
|
182
|
-
|
183
|
-
put :update, params: { state: order.state, order: { coupon_code: coupon_code } }
|
184
|
-
|
185
|
-
expect(response).to redirect_to(spree.cart_path)
|
186
|
-
expect(flash.now[:success]).to eq('Coupon Applied!')
|
187
|
-
end
|
188
|
-
|
189
|
-
context "when coupon code is not applied" do
|
190
|
-
let(:promotion_handler) { instance_double('Spree::PromotionHandler::Coupon', error: 'Some error', success: false) }
|
191
|
-
|
192
|
-
it "render cart with coupon error" do
|
193
|
-
expect(Spree::Deprecation).to receive(:warn)
|
194
|
-
|
195
|
-
expect(Spree::PromotionHandler::Coupon)
|
196
|
-
.to receive_message_chain(:new, :apply)
|
197
|
-
.and_return(promotion_handler)
|
198
|
-
|
199
|
-
put :update, params: { state: order.state, order: { coupon_code: coupon_code } }
|
200
|
-
|
201
|
-
expect(response).to render_template :edit
|
202
|
-
expect(flash.now[:error]).to eq('Some error')
|
203
|
-
end
|
204
|
-
end
|
205
|
-
end
|
206
|
-
end
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
context "#empty" do
|
211
|
-
before do
|
212
|
-
allow(controller).to receive :authorize!
|
213
|
-
end
|
214
|
-
|
215
|
-
it "should destroy line items in the current order" do
|
216
|
-
allow(controller).to receive(:current_order).and_return(order)
|
217
|
-
expect(order).to receive(:empty!)
|
218
|
-
put :empty
|
219
|
-
expect(response).to redirect_to(spree.cart_path)
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
# Regression test for https://github.com/spree/spree/issues/2750
|
224
|
-
context "#update" do
|
225
|
-
before do
|
226
|
-
allow(user).to receive :last_incomplete_spree_order
|
227
|
-
allow(controller).to receive :set_current_order
|
228
|
-
end
|
229
|
-
|
230
|
-
it "cannot update a blank order" do
|
231
|
-
put :update, params: { order: { email: "foo" } }
|
232
|
-
expect(flash[:error]).to eq(I18n.t('spree.order_not_found'))
|
233
|
-
expect(response).to redirect_to(spree.root_path)
|
234
|
-
end
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
context "line items quantity is 0" do
|
239
|
-
let(:order) { Spree::Order.create(store: store) }
|
240
|
-
let(:variant) { create(:variant) }
|
241
|
-
let!(:line_item) { order.contents.add(variant, 1) }
|
242
|
-
|
243
|
-
before do
|
244
|
-
allow(controller).to receive :authorize!
|
245
|
-
allow(controller).to receive_messages(current_order: order)
|
246
|
-
end
|
247
|
-
|
248
|
-
it "removes line items on update" do
|
249
|
-
expect(order.line_items.count).to eq 1
|
250
|
-
put :update, params: { order: { line_items_attributes: { "0" => { id: line_item.id, quantity: 0 } } } }
|
251
|
-
expect(order.reload.line_items.count).to eq 0
|
252
|
-
end
|
253
|
-
end
|
254
|
-
end
|