solidus_frontend 2.8.6 → 2.9.0.rc.1
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/stylesheets/spree/frontend/screen.css.scss +9 -0
- data/app/controllers/spree/checkout_controller.rb +30 -20
- data/app/views/spree/checkout/payment/_gateway.html.erb +6 -5
- data/spec/controllers/spree/checkout_controller_spec.rb +13 -44
- data/spec/controllers/spree/checkout_controller_with_views_spec.rb +1 -1
- data/spec/controllers/spree/home_controller_spec.rb +1 -1
- data/spec/features/address_spec.rb +1 -1
- data/spec/features/automatic_promotion_adjustments_spec.rb +2 -2
- data/spec/features/caching/taxons_spec.rb +1 -1
- data/spec/features/checkout_spec.rb +34 -25
- data/spec/features/coupon_code_spec.rb +5 -5
- data/spec/features/currency_spec.rb +1 -1
- data/spec/features/first_order_promotion_spec.rb +59 -0
- data/spec/features/free_shipping_promotions_spec.rb +2 -2
- data/spec/features/products_spec.rb +8 -8
- data/spec/spec_helper.rb +0 -1
- metadata +9 -8
- data/spec/support/features/fill_in_with_force.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8433838a2873c9b431524473e84aa2bff727cd056016bc9b43b76763fb3c64d
|
4
|
+
data.tar.gz: e0f6e7187afd24eef8091e3d89297a7c9bac56fdae5bac30f93082929611a365
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5cf73de2990e034edbd78534e21ea21137f1b4c091aa5bd98d07464c6398f302203f878d633a2c15e7e9dc593f1fb12c7f7d76c2b98e5c97d108d32ebde7bfb
|
7
|
+
data.tar.gz: a7741d38043e4788005a833db5b02c9360cd4ccd2829553fc5cffff0dc320359a123a76dd68c839cc6a4f955e505d63c0ff1bcc36ee01fd02b55d93180b96f8f
|
@@ -1265,6 +1265,15 @@ table.order-summary {
|
|
1265
1265
|
|
1266
1266
|
}
|
1267
1267
|
|
1268
|
+
// # Logo
|
1269
|
+
#logo {
|
1270
|
+
padding: 20px 0;
|
1271
|
+
|
1272
|
+
> a {
|
1273
|
+
display: inline-block;
|
1274
|
+
}
|
1275
|
+
}
|
1276
|
+
|
1268
1277
|
@media only screen and (max-width: 767px) {
|
1269
1278
|
#empty-cart {
|
1270
1279
|
clear: both;
|
@@ -17,7 +17,7 @@ module Spree
|
|
17
17
|
|
18
18
|
before_action :associate_user
|
19
19
|
before_action :check_authorization
|
20
|
-
before_action :apply_coupon_code
|
20
|
+
before_action :apply_coupon_code
|
21
21
|
|
22
22
|
before_action :setup_for_current_state, only: [:edit, :update]
|
23
23
|
|
@@ -87,23 +87,11 @@ module Spree
|
|
87
87
|
end
|
88
88
|
|
89
89
|
def update_params
|
90
|
-
|
91
|
-
|
92
|
-
massaged_params.require(:order).permit(
|
93
|
-
permitted_checkout_address_attributes
|
94
|
-
)
|
95
|
-
when :delivery
|
96
|
-
massaged_params.require(:order).permit(
|
97
|
-
permitted_checkout_delivery_attributes
|
98
|
-
)
|
99
|
-
when :payment
|
100
|
-
massaged_params.require(:order).permit(
|
101
|
-
permitted_checkout_payment_attributes
|
102
|
-
)
|
90
|
+
if update_params = massaged_params[:order]
|
91
|
+
update_params.permit(permitted_checkout_attributes)
|
103
92
|
else
|
104
|
-
|
105
|
-
|
106
|
-
)
|
93
|
+
# We currently allow update requests without any parameters in them.
|
94
|
+
{}
|
107
95
|
end
|
108
96
|
end
|
109
97
|
|
@@ -231,9 +219,14 @@ module Spree
|
|
231
219
|
@wallet_payment_sources = try_spree_current_user.wallet.wallet_payment_sources
|
232
220
|
@default_wallet_payment_source = @wallet_payment_sources.detect(&:default) ||
|
233
221
|
@wallet_payment_sources.first
|
234
|
-
|
235
|
-
|
236
|
-
|
222
|
+
|
223
|
+
@payment_sources = Spree::DeprecatedInstanceVariableProxy.new(
|
224
|
+
self,
|
225
|
+
:deprecated_payment_sources,
|
226
|
+
:@payment_sources,
|
227
|
+
Spree::Deprecation,
|
228
|
+
"Please, do not use @payment_sources anymore, use @wallet_payment_sources instead."
|
229
|
+
)
|
237
230
|
end
|
238
231
|
end
|
239
232
|
|
@@ -263,5 +256,22 @@ module Spree
|
|
263
256
|
end
|
264
257
|
end
|
265
258
|
end
|
259
|
+
|
260
|
+
# This method returns payment sources of the current user. It is no more
|
261
|
+
# used into our frontend. We used to assign the content of this method
|
262
|
+
# into an ivar (@payment_sources) into the checkout payment step. This
|
263
|
+
# method is here only to be able to deprecate this ivar and will be removed.
|
264
|
+
#
|
265
|
+
# DO NOT USE THIS METHOD!
|
266
|
+
#
|
267
|
+
# @return [Array<Spree::PaymentSource>] Payment sources connected to
|
268
|
+
# current user wallet.
|
269
|
+
# @deprecated This method has been added to deprecate @payment_sources
|
270
|
+
# ivar and will be removed. Use @wallet_payment_sources instead.
|
271
|
+
def deprecated_payment_sources
|
272
|
+
try_spree_current_user.wallet.wallet_payment_sources
|
273
|
+
.map(&:payment_source)
|
274
|
+
.select { |ps| ps.is_a?(Spree::CreditCard) }
|
275
|
+
end
|
266
276
|
end
|
267
277
|
end
|
@@ -1,14 +1,15 @@
|
|
1
1
|
<%= image_tag 'credit_cards/credit_card.gif', id: 'credit-card-image' %>
|
2
2
|
<% param_prefix = "payment_source[#{payment_method.id}]" %>
|
3
3
|
|
4
|
-
<div class="field field-required">
|
4
|
+
<div class="field field-required card_name" data-hook="card_name">
|
5
5
|
<%= label_tag "name_on_card_#{payment_method.id}", t('spree.name_on_card') %>
|
6
|
-
<%= text_field_tag "#{param_prefix}[name]", "#{@order.billing_firstname} #{@order.billing_lastname}", { id: "name_on_card_#{payment_method.id}", autocomplete: "cc-name" } %>
|
6
|
+
<%= text_field_tag "#{param_prefix}[name]", "#{@order.billing_firstname} #{@order.billing_lastname}", { id: "name_on_card_#{payment_method.id}", autocomplete: "cc-name", class: 'cardName' } %>
|
7
7
|
</div>
|
8
8
|
|
9
|
-
<div class="field field-required" data-hook="card_number">
|
9
|
+
<div class="field field-required card_number" data-hook="card_number">
|
10
10
|
<%= label_tag "card_number", t('spree.card_number') %>
|
11
11
|
<%= text_field_tag "#{param_prefix}[number]", '', {id: 'card_number', class: 'required cardNumber', size: 19, maxlength: 19, autocomplete: "cc-number", type: "tel" } %>
|
12
|
+
|
12
13
|
<span id="card_type" style="display:none;">
|
13
14
|
( <span id="looks_like" ><%= t('spree.card_type_is') %> <span id="type"></span></span>
|
14
15
|
<span id="unrecognized"><%= t('spree.unrecognized_card_type') %></span>
|
@@ -16,12 +17,12 @@
|
|
16
17
|
</span>
|
17
18
|
</div>
|
18
19
|
|
19
|
-
<div class="field field-required" data-hook="card_expiration">
|
20
|
+
<div class="field field-required card_expiration" data-hook="card_expiration">
|
20
21
|
<%= label_tag "card_expiry", t('spree.expiration') %>
|
21
22
|
<%= text_field_tag "#{param_prefix}[expiry]", '', id: 'card_expiry', class: "required cardExpiry", placeholder: "MM / YY", type: "tel" %>
|
22
23
|
</div>
|
23
24
|
|
24
|
-
<div class="field field-required" data-hook="card_code">
|
25
|
+
<div class="field field-required card_code" data-hook="card_code">
|
25
26
|
<%= label_tag "card_code", t('spree.card_code') %>
|
26
27
|
<%= text_field_tag "#{param_prefix}[verification_value]", '', {id: 'card_code', class: 'required cardCode', size: 5, type: "tel", autocomplete: "off" } %>
|
27
28
|
<%= link_to "(#{t('spree.what_is_this')})", spree.cvv_path, target: '_blank', "data-hook" => "cvv_link", id: "cvv_link" %>
|
@@ -68,7 +68,7 @@ describe Spree::CheckoutController, type: :controller do
|
|
68
68
|
it 'should check if the user is authorized for :edit' do
|
69
69
|
expect(controller).to receive(:authorize!).with(:edit, order, token)
|
70
70
|
request.cookie_jar.signed[:guest_token] = token
|
71
|
-
post :update, params: { state: 'address'
|
71
|
+
post :update, params: { state: 'address' }
|
72
72
|
end
|
73
73
|
|
74
74
|
context "save successful" do
|
@@ -96,7 +96,7 @@ describe Spree::CheckoutController, type: :controller do
|
|
96
96
|
end
|
97
97
|
|
98
98
|
it "should assign order" do
|
99
|
-
post :update, params: { state: "address"
|
99
|
+
post :update, params: { state: "address" }
|
100
100
|
expect(assigns[:order]).not_to be_nil
|
101
101
|
end
|
102
102
|
|
@@ -271,31 +271,6 @@ describe Spree::CheckoutController, type: :controller do
|
|
271
271
|
expect(order.payments).to be_empty
|
272
272
|
end
|
273
273
|
end
|
274
|
-
|
275
|
-
context 'trying to change the address' do
|
276
|
-
let(:params) do
|
277
|
-
{
|
278
|
-
state: 'payment',
|
279
|
-
order: {
|
280
|
-
payments_attributes: [
|
281
|
-
{
|
282
|
-
payment_method_id: payment_method.id.to_s,
|
283
|
-
source_attributes: attributes_for(:credit_card)
|
284
|
-
}
|
285
|
-
],
|
286
|
-
ship_address_attributes: {
|
287
|
-
zipcode: 'TEST'
|
288
|
-
}
|
289
|
-
}
|
290
|
-
}
|
291
|
-
end
|
292
|
-
|
293
|
-
it 'does not change the address' do
|
294
|
-
expect do
|
295
|
-
post :update, params: params
|
296
|
-
end.not_to change { order.reload.ship_address.zipcode }
|
297
|
-
end
|
298
|
-
end
|
299
274
|
end
|
300
275
|
|
301
276
|
context "when in the confirm state" do
|
@@ -335,18 +310,16 @@ describe Spree::CheckoutController, type: :controller do
|
|
335
310
|
end
|
336
311
|
|
337
312
|
it "should not assign order" do
|
338
|
-
post :update, params: { state: "address",
|
313
|
+
post :update, params: { state: "address", email: '' }
|
339
314
|
expect(assigns[:order]).not_to be_nil
|
340
315
|
end
|
341
316
|
|
342
317
|
it "should not change the order state" do
|
343
|
-
|
344
|
-
post :update, params: { state: 'address', order: { bill_address_attributes: address_params } }
|
345
|
-
end.not_to change { order.reload.state }
|
318
|
+
post :update, params: { state: 'address' }
|
346
319
|
end
|
347
320
|
|
348
321
|
it "should render the edit template" do
|
349
|
-
post :update, params: { state: 'address'
|
322
|
+
post :update, params: { state: 'address' }
|
350
323
|
expect(response).to render_template :edit
|
351
324
|
end
|
352
325
|
end
|
@@ -369,7 +342,7 @@ describe Spree::CheckoutController, type: :controller do
|
|
369
342
|
before do
|
370
343
|
order.update_attributes! user: user
|
371
344
|
allow(order).to receive(:next).and_raise(Spree::Core::GatewayError.new("Invalid something or other."))
|
372
|
-
post :update, params: { state: "address"
|
345
|
+
post :update, params: { state: "address" }
|
373
346
|
end
|
374
347
|
|
375
348
|
it "should render the edit template and display exception message" do
|
@@ -400,7 +373,7 @@ describe Spree::CheckoutController, type: :controller do
|
|
400
373
|
end
|
401
374
|
|
402
375
|
it "due to the order having errors" do
|
403
|
-
put :update, params: { state: order.state, order: {
|
376
|
+
put :update, params: { state: order.state, order: {} }
|
404
377
|
expect(flash[:error]).to eq("Base error\nAdjustments error")
|
405
378
|
expect(response).to redirect_to(spree.checkout_state_path('address'))
|
406
379
|
end
|
@@ -414,7 +387,7 @@ describe Spree::CheckoutController, type: :controller do
|
|
414
387
|
end
|
415
388
|
|
416
389
|
it "due to no available shipping rates for any of the shipments" do
|
417
|
-
put :update, params: { state: "address", order: {
|
390
|
+
put :update, params: { state: "address", order: {} }
|
418
391
|
expect(flash[:error]).to eq(I18n.t('spree.items_cannot_be_shipped'))
|
419
392
|
expect(response).to redirect_to(spree.checkout_state_path('address'))
|
420
393
|
end
|
@@ -464,7 +437,7 @@ describe Spree::CheckoutController, type: :controller do
|
|
464
437
|
end
|
465
438
|
|
466
439
|
it "redirects the customer to the cart page with an error message" do
|
467
|
-
put :update, params: { state: order.state, order: {
|
440
|
+
put :update, params: { state: order.state, order: {} }
|
468
441
|
expect(flash[:error]).to eq(I18n.t('spree.insufficient_stock_for_order'))
|
469
442
|
expect(response).to redirect_to(spree.cart_path)
|
470
443
|
end
|
@@ -496,9 +469,7 @@ describe Spree::CheckoutController, type: :controller do
|
|
496
469
|
before do
|
497
470
|
allow(order).to receive_messages(line_items: [line_item], state: "payment")
|
498
471
|
|
499
|
-
|
500
|
-
config.track_inventory_levels = true
|
501
|
-
end
|
472
|
+
stub_spree_preferences(track_inventory_levels: true)
|
502
473
|
end
|
503
474
|
|
504
475
|
context "and back orders are not allowed" do
|
@@ -523,11 +494,9 @@ describe Spree::CheckoutController, type: :controller do
|
|
523
494
|
allow(controller).to receive_messages check_authorization: true
|
524
495
|
end
|
525
496
|
|
526
|
-
|
527
|
-
# It only tests whether it is set in the before action.
|
528
|
-
it "doesn't set a default shipping address on the order" do
|
497
|
+
it "doesn't set shipping address on the order" do
|
529
498
|
expect(order).to_not receive(:ship_address=)
|
530
|
-
post :update, params: { state: order.state
|
499
|
+
post :update, params: { state: order.state }
|
531
500
|
end
|
532
501
|
|
533
502
|
it "doesn't remove unshippable items before payment" do
|
@@ -542,7 +511,7 @@ describe Spree::CheckoutController, type: :controller do
|
|
542
511
|
allow(controller).to receive_messages check_authorization: true
|
543
512
|
|
544
513
|
expect {
|
545
|
-
post :update, params: { state: "payment"
|
514
|
+
post :update, params: { state: "payment" }
|
546
515
|
}.to change { order.line_items.to_a.size }.from(1).to(0)
|
547
516
|
end
|
548
517
|
|
@@ -16,7 +16,7 @@ describe Spree::CheckoutController, type: :controller do
|
|
16
16
|
# Regression test for https://github.com/spree/spree/issues/3246
|
17
17
|
context "when using GBP" do
|
18
18
|
before do
|
19
|
-
|
19
|
+
stub_spree_preferences(currency: "GBP")
|
20
20
|
end
|
21
21
|
|
22
22
|
context "when order is in delivery" do
|
@@ -18,7 +18,7 @@ describe Spree::HomeController, type: :controller do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
context "different layout specified in config" do
|
21
|
-
before {
|
21
|
+
before { stub_spree_preferences(layout: 'layouts/application') }
|
22
22
|
|
23
23
|
it "renders specified layout" do
|
24
24
|
get :index
|
@@ -24,7 +24,7 @@ describe "Address", type: :feature, inaccessible: true do
|
|
24
24
|
let!(:canada) { create(:country, name: "Canada", states_required: true, iso: "CA") }
|
25
25
|
let!(:uk) { create(:country, name: "United Kingdom", states_required: true, iso: "GB") }
|
26
26
|
|
27
|
-
before {
|
27
|
+
before { stub_spree_preferences(default_country_iso: uk.iso) }
|
28
28
|
|
29
29
|
context "but has no state" do
|
30
30
|
it "shows the state input field" do
|
@@ -40,10 +40,10 @@ describe "Automatic promotions", type: :feature, js: true do
|
|
40
40
|
it "automatically applies the promotion once the order crosses the threshold" do
|
41
41
|
fill_in "order_line_items_attributes_0_quantity", with: 10
|
42
42
|
click_button "Update"
|
43
|
-
expect(page).to have_content("Promotion ($10 off when you spend more than $100) -$10.00")
|
43
|
+
expect(page).to have_content("Promotion ($10 off when you spend more than $100) -$10.00", normalize_ws: true)
|
44
44
|
fill_in "order_line_items_attributes_0_quantity", with: 1
|
45
45
|
click_button "Update"
|
46
|
-
expect(page).not_to have_content("Promotion ($10 off when you spend more than $100) -$10.00")
|
46
|
+
expect(page).not_to have_content("Promotion ($10 off when you spend more than $100) -$10.00", normalize_ws: true)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -14,7 +14,7 @@ describe 'taxons', type: :feature, caching: true do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it "busts the cache when max_level_in_taxons_menu conf changes" do
|
17
|
-
|
17
|
+
stub_spree_preferences(max_level_in_taxons_menu: 5)
|
18
18
|
visit spree.root_path
|
19
19
|
expect(cache_writes.count).to eq(1)
|
20
20
|
end
|
@@ -211,6 +211,26 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
214
|
+
context "when order has only a void payment" do
|
215
|
+
let(:order) { Spree::TestingSupport::OrderWalkthrough.up_to(:payment) }
|
216
|
+
|
217
|
+
before do
|
218
|
+
user = create(:user)
|
219
|
+
order.user = user
|
220
|
+
order.recalculate
|
221
|
+
|
222
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(current_order: order)
|
223
|
+
allow_any_instance_of(Spree::CheckoutController).to receive_messages(try_spree_current_user: user)
|
224
|
+
end
|
225
|
+
|
226
|
+
it "does not allow successful order submission" do
|
227
|
+
visit spree.checkout_path
|
228
|
+
order.payments.first.update state: :void
|
229
|
+
click_button 'Place Order'
|
230
|
+
expect(page).to have_current_path spree.checkout_state_path(:payment)
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
214
234
|
# Regression test for https://github.com/spree/spree/issues/2694 and https://github.com/spree/spree/issues/4117
|
215
235
|
context "doesn't allow bad credit card numbers" do
|
216
236
|
let!(:payment_method) { create(:credit_card_payment_method) }
|
@@ -338,30 +358,21 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
338
358
|
it "selects first source available and customer moves on" do
|
339
359
|
expect(find("#use_existing_card_yes")).to be_checked
|
340
360
|
|
341
|
-
|
342
|
-
click_on "Save and Continue"
|
343
|
-
}.not_to change { Spree::CreditCard.count }
|
344
|
-
|
361
|
+
click_on "Save and Continue"
|
345
362
|
click_on "Place Order"
|
346
363
|
expect(page).to have_current_path(spree.order_path(Spree::Order.last))
|
364
|
+
expect(page).to have_current_path(spree.order_path(Spree::Order.last))
|
365
|
+
expect(page).to have_content("Ending in #{credit_card.last_digits}")
|
347
366
|
end
|
348
367
|
|
349
368
|
it "allows user to enter a new source" do
|
350
369
|
choose "use_existing_card_no"
|
370
|
+
fill_in_credit_card
|
351
371
|
|
352
|
-
|
353
|
-
fill_in_with_force "Card Number", with: '4111 1111 1111 1111'
|
354
|
-
fill_in "card_expiry", with: '04 / 20'
|
355
|
-
fill_in "Card Code", with: '123'
|
356
|
-
|
357
|
-
expect {
|
358
|
-
click_on "Save and Continue"
|
359
|
-
}.to change { Spree::CreditCard.count }.by 1
|
360
|
-
|
361
|
-
expect(Spree::CreditCard.last.address).to be_present
|
362
|
-
|
372
|
+
click_on "Save and Continue"
|
363
373
|
click_on "Place Order"
|
364
374
|
expect(page).to have_current_path(spree.order_path(Spree::Order.last))
|
375
|
+
expect(page).to have_content('Ending in 1111')
|
365
376
|
end
|
366
377
|
end
|
367
378
|
|
@@ -498,7 +509,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
498
509
|
end
|
499
510
|
end
|
500
511
|
|
501
|
-
context "order has only payment step" do
|
512
|
+
context "order has only payment step", js: true do
|
502
513
|
before do
|
503
514
|
create(:credit_card_payment_method)
|
504
515
|
@old_checkout_flow = Spree::Order.checkout_flow
|
@@ -523,10 +534,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
523
534
|
expect(page).to have_current_path(spree.checkout_state_path('payment'))
|
524
535
|
|
525
536
|
choose "Credit Card"
|
526
|
-
|
527
|
-
fill_in "Card Number", with: '4111 1111 1111 1111'
|
528
|
-
fill_in "card_expiry", with: '04 / 20'
|
529
|
-
fill_in "Card Code", with: '123'
|
537
|
+
fill_in_credit_card
|
530
538
|
click_button "Save and Continue"
|
531
539
|
|
532
540
|
expect(current_path).to eq spree.checkout_state_path('confirm')
|
@@ -582,7 +590,7 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
582
590
|
end
|
583
591
|
|
584
592
|
it "displays a thank you message" do
|
585
|
-
expect(page).to have_content(I18n.t('spree.thank_you_for_your_order'))
|
593
|
+
expect(page).to have_content(I18n.t('spree.thank_you_for_your_order'), normalize_ws: true)
|
586
594
|
end
|
587
595
|
|
588
596
|
it "does not display a thank you message on that order future visits" do
|
@@ -657,16 +665,17 @@ describe "Checkout", type: :feature, inaccessible: true do
|
|
657
665
|
click_on "Save and Continue"
|
658
666
|
click_on "Save and Continue"
|
659
667
|
|
660
|
-
fill_in_credit_card
|
668
|
+
fill_in_credit_card
|
661
669
|
click_on "Save and Continue"
|
662
670
|
|
663
671
|
expect(page).to have_current_path("/checkout/confirm")
|
664
672
|
end
|
665
673
|
end
|
666
674
|
|
667
|
-
def fill_in_credit_card(number:)
|
668
|
-
fill_in "
|
669
|
-
|
675
|
+
def fill_in_credit_card(number: "4111 1111 1111 1111")
|
676
|
+
fill_in "Name on card", with: 'Mary Doe'
|
677
|
+
fill_in_with_force "Card Number", with: number
|
678
|
+
fill_in_with_force "Expiration", with: "12 / 24"
|
670
679
|
fill_in "Card Code", with: "123"
|
671
680
|
end
|
672
681
|
|
@@ -69,14 +69,14 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
69
69
|
expect(page).to have_content(I18n.t('spree.coupon_code_not_found'))
|
70
70
|
fill_in "order_coupon_code", with: "onetwo"
|
71
71
|
click_button "Apply Code"
|
72
|
-
expect(page).to have_content("Promotion (Onetwo)
|
72
|
+
expect(page).to have_content("Promotion (Onetwo) -$10.00", normalize_ws: true)
|
73
73
|
end
|
74
74
|
|
75
75
|
context "with a promotion" do
|
76
76
|
it "applies a promotion to an order" do
|
77
77
|
fill_in "order_coupon_code", with: "onetwo"
|
78
78
|
click_button "Apply Code"
|
79
|
-
expect(page).to have_content("Promotion (Onetwo)
|
79
|
+
expect(page).to have_content("Promotion (Onetwo) -$10.00", normalize_ws: true)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -202,7 +202,7 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
202
202
|
# 20% of $40 = 8
|
203
203
|
# 20% of $20 = 4
|
204
204
|
# Therefore: promotion discount amount is $12.
|
205
|
-
expect(page).to have_content("Promotion (Onetwo) -$12.00")
|
205
|
+
expect(page).to have_content("Promotion (Onetwo) -$12.00", normalize_ws: true)
|
206
206
|
end
|
207
207
|
|
208
208
|
within '.cart-total' do
|
@@ -241,7 +241,7 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
241
241
|
click_button "Apply Code"
|
242
242
|
|
243
243
|
within '#cart_adjustments' do
|
244
|
-
expect(page).to have_content("Promotion (Onetwo) -$30.00")
|
244
|
+
expect(page).to have_content("Promotion (Onetwo) -$30.00", normalize_ws: true)
|
245
245
|
end
|
246
246
|
|
247
247
|
within '.cart-total' do
|
@@ -253,7 +253,7 @@ describe "Coupon code promotions", type: :feature, js: true do
|
|
253
253
|
click_button "Update"
|
254
254
|
|
255
255
|
within '#cart_adjustments' do
|
256
|
-
expect(page).to have_content("Promotion (Onetwo) -$60.00")
|
256
|
+
expect(page).to have_content("Promotion (Onetwo) -$60.00", normalize_ws: true)
|
257
257
|
end
|
258
258
|
|
259
259
|
within '.cart-total' do
|
@@ -14,7 +14,7 @@ describe "Switching currencies in backend", type: :feature do
|
|
14
14
|
click_link "RoR Mug"
|
15
15
|
click_button "Add To Cart"
|
16
16
|
# Now that we have an order...
|
17
|
-
|
17
|
+
stub_spree_preferences(currency: "AUD")
|
18
18
|
visit spree.root_path
|
19
19
|
end
|
20
20
|
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
RSpec.feature "First Order promotion" do
|
6
|
+
given!(:promotion) do
|
7
|
+
FactoryBot.create(
|
8
|
+
:promotion_with_first_order_rule,
|
9
|
+
:with_order_adjustment,
|
10
|
+
code: "FIRSTONEFREE",
|
11
|
+
per_code_usage_limit: 10
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
background do
|
16
|
+
create(:store)
|
17
|
+
product = FactoryBot.create(:product)
|
18
|
+
visit spree.root_path
|
19
|
+
click_link product.name
|
20
|
+
click_button "Add To Cart"
|
21
|
+
end
|
22
|
+
|
23
|
+
scenario "Adding first order promotion to cart and checking out as guest" do
|
24
|
+
fill_in "Coupon code", with: "FIRSTONEFREE"
|
25
|
+
click_button "Apply Code"
|
26
|
+
expect(page).to have_content("The coupon code was successfully applied to your order")
|
27
|
+
|
28
|
+
within("#cart_adjustments") do
|
29
|
+
expect(page).to have_content("-$10.00")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
scenario "Trying to reuse first order promotion" do
|
34
|
+
previous_user = FactoryBot.create(
|
35
|
+
:user,
|
36
|
+
email: "sam@tom.com"
|
37
|
+
)
|
38
|
+
_previous_order = create(:completed_order_with_totals, user: previous_user)
|
39
|
+
fill_in "Coupon code", with: "FIRSTONEFREE"
|
40
|
+
click_button "Apply Code"
|
41
|
+
expect(page).to have_content("The coupon code was successfully applied to your order")
|
42
|
+
click_on "Checkout"
|
43
|
+
fill_in "Customer E-Mail", with: "sam@tom.com"
|
44
|
+
fill_in_address
|
45
|
+
click_on "Save and Continue"
|
46
|
+
expect(page).to_not have_content("#summary-order-charges")
|
47
|
+
end
|
48
|
+
|
49
|
+
def fill_in_address
|
50
|
+
address = "order_bill_address_attributes"
|
51
|
+
fill_in "#{address}_firstname", with: "Ryan"
|
52
|
+
fill_in "#{address}_lastname", with: "Bigg"
|
53
|
+
fill_in "#{address}_address1", with: "143 Swan Street"
|
54
|
+
fill_in "#{address}_city", with: "Richmond"
|
55
|
+
select "United States of America", from: "#{address}_country_id"
|
56
|
+
fill_in "#{address}_zipcode", with: "12345"
|
57
|
+
fill_in "#{address}_phone", with: "(555) 555-5555"
|
58
|
+
end
|
59
|
+
end
|
@@ -52,8 +52,8 @@ describe "Free shipping promotions", type: :feature, js: true do
|
|
52
52
|
# Regression test for https://github.com/spree/spree/issues/4428
|
53
53
|
it "applies the free shipping promotion" do
|
54
54
|
within("#checkout-summary") do
|
55
|
-
expect(page).to have_content("Shipping total:
|
56
|
-
expect(page).to have_content("Promotion (Free Shipping): -$10.00")
|
55
|
+
expect(page).to have_content("Shipping total: $10.00", normalize_ws: true)
|
56
|
+
expect(page).to have_content("Promotion (Free Shipping): -$10.00", normalize_ws: true)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
@@ -93,7 +93,7 @@ describe "Visiting Products", type: :feature, inaccessible: true do
|
|
93
93
|
|
94
94
|
context "using Russian Rubles as a currency" do
|
95
95
|
before do
|
96
|
-
|
96
|
+
stub_spree_preferences(currency: "RUB")
|
97
97
|
end
|
98
98
|
|
99
99
|
let!(:product) do
|
@@ -199,8 +199,8 @@ describe "Visiting Products", type: :feature, inaccessible: true do
|
|
199
199
|
|
200
200
|
it "should be able to hide products without price" do
|
201
201
|
expect(page.all('ul.product-listing li').size).to eq(9)
|
202
|
-
|
203
|
-
|
202
|
+
stub_spree_preferences(show_products_without_price: false)
|
203
|
+
stub_spree_preferences(currency: "CAN")
|
204
204
|
visit spree.root_path
|
205
205
|
expect(page.all('ul.product-listing li').size).to eq(0)
|
206
206
|
end
|
@@ -224,7 +224,7 @@ describe "Visiting Products", type: :feature, inaccessible: true do
|
|
224
224
|
end
|
225
225
|
|
226
226
|
it "should be able to display products priced between 15 and 18 dollars across multiple pages" do
|
227
|
-
|
227
|
+
stub_spree_preferences(products_per_page: 2)
|
228
228
|
within(:css, '#taxonomies') { click_link "Ruby on Rails" }
|
229
229
|
check "Price_Range_$15.00_-_$18.00"
|
230
230
|
within(:css, '#sidebar_products_search') { click_button "Search" }
|
@@ -263,8 +263,8 @@ describe "Visiting Products", type: :feature, inaccessible: true do
|
|
263
263
|
|
264
264
|
it "shouldn't be able to put a product without a current price in the cart" do
|
265
265
|
product = FactoryBot.create(:base_product, description: nil, name: 'Sample', price: '19.99')
|
266
|
-
|
267
|
-
|
266
|
+
stub_spree_preferences(currency: "CAN")
|
267
|
+
stub_spree_preferences(show_products_without_price: true)
|
268
268
|
visit spree.product_path(product)
|
269
269
|
expect(page).to have_content "This product is not available in the selected currency."
|
270
270
|
expect(page).not_to have_content "add-to-cart-button"
|
@@ -272,8 +272,8 @@ describe "Visiting Products", type: :feature, inaccessible: true do
|
|
272
272
|
|
273
273
|
it "should be able to list products without a price" do
|
274
274
|
product = FactoryBot.create(:base_product, description: nil, name: 'Sample', price: '19.99')
|
275
|
-
|
276
|
-
|
275
|
+
stub_spree_preferences(currency: "CAN")
|
276
|
+
stub_spree_preferences(show_products_without_price: true)
|
277
277
|
visit spree.products_path
|
278
278
|
expect(page).to have_content(product.name)
|
279
279
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solidus_frontend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.9.0.rc.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Solidus Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: solidus_api
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.
|
19
|
+
version: 2.9.0.rc.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.
|
26
|
+
version: 2.9.0.rc.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: solidus_core
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: 2.9.0.rc.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 2.
|
40
|
+
version: 2.9.0.rc.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: canonical-rails
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -293,6 +293,7 @@ files:
|
|
293
293
|
- spec/features/checkout_unshippable_spec.rb
|
294
294
|
- spec/features/coupon_code_spec.rb
|
295
295
|
- spec/features/currency_spec.rb
|
296
|
+
- spec/features/first_order_promotion_spec.rb
|
296
297
|
- spec/features/free_shipping_promotions_spec.rb
|
297
298
|
- spec/features/locale_spec.rb
|
298
299
|
- spec/features/order_spec.rb
|
@@ -307,7 +308,6 @@ files:
|
|
307
308
|
- spec/helpers/order_helper_spec.rb
|
308
309
|
- spec/helpers/taxon_filters_helper_spec.rb
|
309
310
|
- spec/spec_helper.rb
|
310
|
-
- spec/support/features/fill_in_with_force.rb
|
311
311
|
- spec/support/shared_contexts/checkout_setup.rb
|
312
312
|
- spec/support/shared_contexts/custom_products.rb
|
313
313
|
- spec/support/shared_contexts/locales.rb
|
@@ -332,7 +332,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
332
332
|
version: 1.8.23
|
333
333
|
requirements:
|
334
334
|
- none
|
335
|
-
|
335
|
+
rubyforge_project:
|
336
|
+
rubygems_version: 2.7.3
|
336
337
|
signing_key:
|
337
338
|
specification_version: 4
|
338
339
|
summary: Cart and storefront for the Solidus e-commerce project.
|
@@ -1,12 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module FillInWithForce
|
4
|
-
def fill_in_with_force(locator, with:)
|
5
|
-
field_id = find_field(locator)[:id]
|
6
|
-
page.execute_script "document.getElementById('#{field_id}').value = '#{with}';"
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
RSpec.configure do |config|
|
11
|
-
config.include FillInWithForce, type: :feature
|
12
|
-
end
|