solidus_frontend 2.9.5 → 2.9.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f647b50dc184e8ecd61a6e6cd3766306157e9793135ec3fc76b7073cce2e032
4
- data.tar.gz: a48fce4086cafbcb66a34d6a2d2fc3b3e29fe5ba9b8c9321cfb86935a7f34986
3
+ metadata.gz: 59a3b04e427501e6c465c89d3a7a5278be8b999ab29dbbe0af9841df1d1032c8
4
+ data.tar.gz: f62b17d100120614790bf81f0f0f202f1b55918489b242f8b89cb311406f96a2
5
5
  SHA512:
6
- metadata.gz: b8318ce8e4bfe6f7467c40f54411ffc1296ac70aea640beea75a5d21c6f254d0046304b25284b01f36ea2cae7f6d959a711e7ef600125df6e4874316b22b5088
7
- data.tar.gz: d17f4516dbfed0880d5385e320d21ba2311eb48c003e77f458ac267dbe2af27e03764b8584e2a3a7cdc2e9eb89552d60ee35774ac388cd07fded637e3c89c3f8
6
+ metadata.gz: 7385f7eb310a92fcb4eaf18b2fd377cf08ee0c863bd806724dd860ad70d99dceadb59807edf6dcd6b8d2608a12e1064f301c912664d44616c235f6ac79e6ec6e
7
+ data.tar.gz: dda5bfdd5c4c33f6bbdda2692d24a24ec0953686c4ebfec47137451fd830a7a36e884b1577fef5a24f03c0007f95401820c6118ac38e2ed6452215f449d22454
@@ -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, only: [:update]
21
21
 
22
22
  before_action :setup_for_current_state, only: [:edit, :update]
23
23
 
@@ -87,11 +87,23 @@ module Spree
87
87
  end
88
88
 
89
89
  def update_params
90
- if update_params = massaged_params[:order]
91
- update_params.permit(permitted_checkout_attributes)
90
+ case params[:state].to_sym
91
+ when :address
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
+ )
92
103
  else
93
- # We currently allow update requests without any parameters in them.
94
- {}
104
+ massaged_params.fetch(:order, {}).permit(
105
+ permitted_checkout_confirm_attributes
106
+ )
95
107
  end
96
108
  end
97
109
 
@@ -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', order: { bill_address_attributes: address_params } }
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", order: { bill_address_attributes: address_params } }
100
100
  expect(assigns[:order]).not_to be_nil
101
101
  end
102
102
 
@@ -271,6 +271,31 @@ 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
274
299
  end
275
300
 
276
301
  context "when in the confirm state" do
@@ -310,16 +335,18 @@ describe Spree::CheckoutController, type: :controller do
310
335
  end
311
336
 
312
337
  it "should not assign order" do
313
- post :update, params: { state: "address", email: '' }
338
+ post :update, params: { state: "address", order: { email: ''} }
314
339
  expect(assigns[:order]).not_to be_nil
315
340
  end
316
341
 
317
342
  it "should not change the order state" do
318
- post :update, params: { state: 'address' }
343
+ expect do
344
+ post :update, params: { state: 'address', order: { bill_address_attributes: address_params } }
345
+ end.not_to change { order.reload.state }
319
346
  end
320
347
 
321
348
  it "should render the edit template" do
322
- post :update, params: { state: 'address' }
349
+ post :update, params: { state: 'address', order: { bill_address_attributes: address_params } }
323
350
  expect(response).to render_template :edit
324
351
  end
325
352
  end
@@ -342,7 +369,7 @@ describe Spree::CheckoutController, type: :controller do
342
369
  before do
343
370
  order.update_attributes! user: user
344
371
  allow(order).to receive(:next).and_raise(Spree::Core::GatewayError.new("Invalid something or other."))
345
- post :update, params: { state: "address" }
372
+ post :update, params: { state: "address", order: { bill_address_attributes: address_params } }
346
373
  end
347
374
 
348
375
  it "should render the edit template and display exception message" do
@@ -373,7 +400,7 @@ describe Spree::CheckoutController, type: :controller do
373
400
  end
374
401
 
375
402
  it "due to the order having errors" do
376
- put :update, params: { state: order.state, order: {} }
403
+ put :update, params: { state: order.state, order: { bill_address_attributes: address_params } }
377
404
  expect(flash[:error]).to eq("Base error\nAdjustments error")
378
405
  expect(response).to redirect_to(spree.checkout_state_path('address'))
379
406
  end
@@ -387,7 +414,7 @@ describe Spree::CheckoutController, type: :controller do
387
414
  end
388
415
 
389
416
  it "due to no available shipping rates for any of the shipments" do
390
- put :update, params: { state: "address", order: {} }
417
+ put :update, params: { state: "address", order: { bill_address_attributes: address_params } }
391
418
  expect(flash[:error]).to eq(I18n.t('spree.items_cannot_be_shipped'))
392
419
  expect(response).to redirect_to(spree.checkout_state_path('address'))
393
420
  end
@@ -437,7 +464,7 @@ describe Spree::CheckoutController, type: :controller do
437
464
  end
438
465
 
439
466
  it "redirects the customer to the cart page with an error message" do
440
- put :update, params: { state: order.state, order: {} }
467
+ put :update, params: { state: order.state, order: { bill_address_attributes: address_params } }
441
468
  expect(flash[:error]).to eq(I18n.t('spree.insufficient_stock_for_order'))
442
469
  expect(response).to redirect_to(spree.cart_path)
443
470
  end
@@ -494,9 +521,11 @@ describe Spree::CheckoutController, type: :controller do
494
521
  allow(controller).to receive_messages check_authorization: true
495
522
  end
496
523
 
497
- it "doesn't set shipping address on the order" do
524
+ # This does not test whether the shipping address is set via params.
525
+ # It only tests whether it is set in the before action.
526
+ it "doesn't set a default shipping address on the order" do
498
527
  expect(order).to_not receive(:ship_address=)
499
- post :update, params: { state: order.state }
528
+ post :update, params: { state: order.state, order: { bill_address_attributes: address_params } }
500
529
  end
501
530
 
502
531
  it "doesn't remove unshippable items before payment" do
@@ -511,7 +540,7 @@ describe Spree::CheckoutController, type: :controller do
511
540
  allow(controller).to receive_messages check_authorization: true
512
541
 
513
542
  expect {
514
- post :update, params: { state: "payment" }
543
+ post :update, params: { state: "payment", order: { email: "johndoe@example.com"} }
515
544
  }.to change { order.line_items.to_a.size }.from(1).to(0)
516
545
  end
517
546
 
@@ -374,6 +374,14 @@ describe "Checkout", type: :feature, inaccessible: true do
374
374
  expect(page).to have_current_path(spree.order_path(Spree::Order.last))
375
375
  expect(page).to have_content('Ending in 1111')
376
376
  end
377
+
378
+ it "allows user to save a billing address associated to the credit card" do
379
+ choose "use_existing_card_no"
380
+ fill_in_credit_card
381
+
382
+ click_on "Save and Continue"
383
+ expect(Spree::CreditCard.last.address).to be_present
384
+ end
377
385
  end
378
386
 
379
387
  # regression for https://github.com/spree/spree/issues/2921
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.9.5
4
+ version: 2.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Solidus Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-04 00:00:00.000000000 Z
11
+ date: 2020-07-16 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.9.5
19
+ version: 2.9.6
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.9.5
26
+ version: 2.9.6
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.9.5
33
+ version: 2.9.6
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.9.5
40
+ version: 2.9.6
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: canonical-rails
43
43
  requirement: !ruby/object:Gem::Requirement