solidus_frontend 1.0.7 → 1.1.0.beta1

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.

Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/frontend/checkout/address.js.coffee +6 -5
  3. data/app/controllers/spree/checkout_controller.rb +5 -3
  4. data/app/controllers/spree/store_controller.rb +2 -1
  5. data/app/views/spree/address/_form.html.erb +15 -15
  6. data/lib/spree/frontend.rb +0 -2
  7. metadata +9 -79
  8. data/CHANGELOG.md +0 -1
  9. data/Gemfile +0 -6
  10. data/Rakefile +0 -15
  11. data/lib/spree/frontend/preference_rescue.rb +0 -25
  12. data/script/rails +0 -9
  13. data/solidus_frontend.gemspec +0 -30
  14. data/spec/controllers/controller_extension_spec.rb +0 -126
  15. data/spec/controllers/controller_helpers_spec.rb +0 -26
  16. data/spec/controllers/spree/checkout_controller_spec.rb +0 -447
  17. data/spec/controllers/spree/checkout_controller_with_views_spec.rb +0 -36
  18. data/spec/controllers/spree/content_controller_spec.rb +0 -7
  19. data/spec/controllers/spree/current_order_tracking_spec.rb +0 -44
  20. data/spec/controllers/spree/home_controller_spec.rb +0 -27
  21. data/spec/controllers/spree/orders_controller_ability_spec.rb +0 -104
  22. data/spec/controllers/spree/orders_controller_spec.rb +0 -134
  23. data/spec/controllers/spree/orders_controller_transitions_spec.rb +0 -31
  24. data/spec/controllers/spree/products_controller_spec.rb +0 -36
  25. data/spec/controllers/spree/taxons_controller_spec.rb +0 -12
  26. data/spec/features/address_spec.rb +0 -76
  27. data/spec/features/automatic_promotion_adjustments_spec.rb +0 -47
  28. data/spec/features/caching/products_spec.rb +0 -55
  29. data/spec/features/caching/taxons_spec.rb +0 -22
  30. data/spec/features/cart_spec.rb +0 -81
  31. data/spec/features/checkout_spec.rb +0 -513
  32. data/spec/features/checkout_unshippable_spec.rb +0 -35
  33. data/spec/features/coupon_code_spec.rb +0 -227
  34. data/spec/features/currency_spec.rb +0 -18
  35. data/spec/features/free_shipping_promotions_spec.rb +0 -59
  36. data/spec/features/locale_spec.rb +0 -60
  37. data/spec/features/order_spec.rb +0 -73
  38. data/spec/features/products_spec.rb +0 -260
  39. data/spec/features/promotion_code_invalidation_spec.rb +0 -51
  40. data/spec/features/quantity_promotions_spec.rb +0 -128
  41. data/spec/features/taxons_spec.rb +0 -135
  42. data/spec/features/template_rendering_spec.rb +0 -19
  43. data/spec/fixtures/thinking-cat.jpg +0 -0
  44. data/spec/helpers/base_helper_spec.rb +0 -11
  45. data/spec/spec_helper.rb +0 -121
  46. data/spec/support/shared_contexts/checkout_setup.rb +0 -9
  47. data/spec/support/shared_contexts/custom_products.rb +0 -25
  48. data/spec/support/shared_contexts/product_prototypes.rb +0 -30
  49. data/spec/views/spree/checkout/_summary_spec.rb +0 -11
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # In this file, we want to test that the controller helpers function correctly
4
- # So we need to use one of the controllers inside Spree.
5
- # ProductsController is good.
6
- describe Spree::ProductsController, :type => :controller do
7
-
8
- before do
9
- I18n.enforce_available_locales = false
10
- expect(I18n).to receive(:available_locales).and_return([:en, :de])
11
- Spree::Frontend::Config[:locale] = :de
12
- end
13
-
14
- after do
15
- Spree::Frontend::Config[:locale] = :en
16
- I18n.locale = :en
17
- I18n.enforce_available_locales = true
18
- end
19
-
20
- # Regression test for #1184
21
- it "sets the default locale based off Spree::Frontend::Config[:locale]" do
22
- expect(I18n.locale).to eq(:en)
23
- spree_get :index
24
- expect(I18n.locale).to eq(:de)
25
- end
26
- end
@@ -1,447 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Spree::CheckoutController, :type => :controller do
4
- let(:token) { 'some_token' }
5
- let(:user) { stub_model(Spree::LegacyUser) }
6
- let(:order) { FactoryGirl.create(:order_with_totals) }
7
-
8
- let(:address_params) do
9
- address = FactoryGirl.build(:address)
10
- address.attributes.except("created_at", "updated_at")
11
- end
12
-
13
- before do
14
- allow(controller).to receive_messages try_spree_current_user: user
15
- allow(controller).to receive_messages spree_current_user: user
16
- allow(controller).to receive_messages current_order: order
17
- end
18
-
19
- context "#edit" do
20
- it 'should check if the user is authorized for :edit' do
21
- expect(controller).to receive(:authorize!).with(:edit, order, token)
22
- request.cookie_jar.signed[:guest_token] = token
23
- spree_get :edit, { state: 'address' }
24
- end
25
-
26
- it "should redirect to the cart path unless checkout_allowed?" do
27
- allow(order).to receive_messages :checkout_allowed? => false
28
- spree_get :edit, { :state => "delivery" }
29
- expect(response).to redirect_to(spree.cart_path)
30
- end
31
-
32
- it "should redirect to the cart path if current_order is nil" do
33
- allow(controller).to receive(:current_order).and_return(nil)
34
- spree_get :edit, { :state => "delivery" }
35
- expect(response).to redirect_to(spree.cart_path)
36
- end
37
-
38
- it "should redirect to cart if order is completed" do
39
- allow(order).to receive_messages(:completed? => true)
40
- spree_get :edit, { :state => "address" }
41
- expect(response).to redirect_to(spree.cart_path)
42
- end
43
-
44
- # Regression test for #2280
45
- it "should redirect to current step trying to access a future step" do
46
- order.update_column(:state, "address")
47
- spree_get :edit, { :state => "delivery" }
48
- expect(response).to redirect_to spree.checkout_state_path("address")
49
- end
50
-
51
- context "when entering the checkout" do
52
- before do
53
- # The first step for checkout controller is address
54
- # Transitioning into this state first is required
55
- order.update_column(:state, "address")
56
- end
57
-
58
- it "should associate the order with a user" do
59
- order.update_column :user_id, nil
60
- expect(order).to receive(:associate_user!).with(user)
61
- spree_get :edit, {}, order_id: 1
62
- end
63
- end
64
- end
65
-
66
- context "#update" do
67
- it 'should check if the user is authorized for :edit' do
68
- expect(controller).to receive(:authorize!).with(:edit, order, token)
69
- request.cookie_jar.signed[:guest_token] = token
70
- spree_post :update, { state: 'address' }
71
- end
72
-
73
- context "save successful" do
74
- def spree_post_address
75
- spree_post :update, {
76
- :state => "address",
77
- :order => {
78
- :bill_address_attributes => address_params,
79
- :use_billing => true
80
- }
81
- }
82
- end
83
-
84
- let!(:payment_method) { create(:credit_card_payment_method) }
85
- before do
86
- # Must have *a* shipping method and a payment method so updating from address works
87
- allow(order).to receive_messages ensure_available_shipping_rates: true
88
- order.line_items << FactoryGirl.create(:line_item)
89
- end
90
-
91
- context "with the order in the cart state" do
92
- before do
93
- order.update_column(:state, "cart")
94
- allow(order).to receive_messages :user => user
95
- end
96
-
97
- it "should assign order" do
98
- spree_post :update, {:state => "address"}
99
- expect(assigns[:order]).not_to be_nil
100
- end
101
-
102
- it "should advance the state" do
103
- spree_post_address
104
- expect(order.reload.state).to eq("delivery")
105
- end
106
-
107
- it "should redirect the next state" do
108
- spree_post_address
109
- expect(response).to redirect_to spree.checkout_state_path("delivery")
110
- end
111
-
112
- context "current_user respond to save address method" do
113
- it "calls persist order address on user" do
114
- expect(user).to receive(:persist_order_address)
115
- spree_post :update, {
116
- :state => "address",
117
- :order => {
118
- :bill_address_attributes => address_params,
119
- :use_billing => true
120
- },
121
- :save_user_address => "1"
122
- }
123
- end
124
- end
125
-
126
- context "current_user doesnt respond to persist_order_address" do
127
- it "doesnt raise any error" do
128
- expect {
129
- spree_post :update, {
130
- :state => "address",
131
- :order => {
132
- :bill_address_attributes => address_params,
133
- :use_billing => true
134
- },
135
- :save_user_address => "1"
136
- }
137
- }.to_not raise_error
138
- end
139
- end
140
- end
141
-
142
- context "with the order in the address state" do
143
- before do
144
- order.update_columns(ship_address_id: create(:address).id, state: "address")
145
- allow(order).to receive_messages user: user
146
- end
147
-
148
- context "with a billing and shipping address" do
149
- before do
150
- @expected_bill_address_id = order.bill_address.id
151
- @expected_ship_address_id = order.ship_address.id
152
-
153
- spree_post :update, {
154
- :state => "address",
155
- :order => {
156
- :bill_address_attributes => order.bill_address.attributes.except("created_at", "updated_at"),
157
- :ship_address_attributes => order.ship_address.attributes.except("created_at", "updated_at"),
158
- :use_billing => false
159
- }
160
- }
161
-
162
- order.reload
163
- end
164
-
165
- it "updates the same billing and shipping address" do
166
- expect(order.bill_address.id).to eq(@expected_bill_address_id)
167
- expect(order.ship_address.id).to eq(@expected_ship_address_id)
168
- end
169
- end
170
- end
171
-
172
- context "when in the payment state" do
173
- let(:order) { create(:order_with_line_items) }
174
- let(:payment_method) { create(:credit_card_payment_method) }
175
-
176
- let(:params) do
177
- {
178
- state: 'payment',
179
- order: {
180
- payments_attributes: [
181
- {
182
- payment_method_id: payment_method.id.to_s,
183
- source_attributes: attributes_for(:credit_card)
184
- }
185
- ]
186
- }
187
- }
188
- end
189
-
190
- before do
191
- order.update_attributes! user: user
192
- 3.times { order.next! } # should put us in the payment state
193
- end
194
-
195
- context 'with a permitted payment method' do
196
- it 'sets the payment amount' do
197
- post :update, params
198
- order.reload
199
- expect(order.state).to eq('confirm')
200
- expect(order.payments.size).to eq(1)
201
- expect(order.payments.first.amount).to eq(order.total)
202
- end
203
- end
204
-
205
- context 'with an unpermitted payment method' do
206
- before { payment_method.update!(display_on: "back_end") }
207
-
208
- it 'sets the payment amount' do
209
- expect {
210
- post :update, params
211
- }.to raise_error(ActiveRecord::RecordNotFound)
212
-
213
- expect(order.state).to eq('payment')
214
- expect(order.payments).to be_empty
215
- end
216
- end
217
- end
218
-
219
- context "when in the confirm state" do
220
- before do
221
- allow(order).to receive_messages :confirmation_required? => true
222
- order.update_column(:state, "confirm")
223
- allow(order).to receive_messages :user => user
224
- # An order requires a payment to reach the complete state
225
- # This is because payment_required? is true on the order
226
- create(:payment, :amount => order.total, :order => order)
227
- order.create_proposed_shipments
228
- order.payments.reload
229
- end
230
-
231
- # This inadvertently is a regression test for #2694
232
- it "should redirect to the order view" do
233
- spree_post :update, {:state => "confirm"}
234
- expect(response).to redirect_to spree.order_path(order)
235
- end
236
-
237
- it "should populate the flash message" do
238
- spree_post :update, {:state => "confirm"}
239
- expect(flash.notice).to eq(Spree.t(:order_processed_successfully))
240
- end
241
-
242
- it "should remove completed order from current_order" do
243
- spree_post :update, {:state => "confirm"}, {:order_id => "foofah"}
244
- expect(assigns(:current_order)).to be_nil
245
- expect(assigns(:order)).to eql controller.current_order
246
- end
247
- end
248
- end
249
-
250
- context "save unsuccessful" do
251
- before do
252
- allow(order).to receive_messages :user => user
253
- allow(order).to receive_messages :update_attributes => false
254
- end
255
-
256
- it "should not assign order" do
257
- spree_post :update, {:state => "address"}
258
- expect(assigns[:order]).not_to be_nil
259
- end
260
-
261
- it "should not change the order state" do
262
- spree_post :update, { :state => 'address' }
263
- end
264
-
265
- it "should render the edit template" do
266
- spree_post :update, { :state => 'address' }
267
- expect(response).to render_template :edit
268
- end
269
- end
270
-
271
- context "when current_order is nil" do
272
- before { allow(controller).to receive_messages :current_order => nil }
273
-
274
- it "should not change the state if order is completed" do
275
- expect(order).not_to receive(:update_attribute)
276
- spree_post :update, {:state => "confirm"}
277
- end
278
-
279
- it "should redirect to the cart_path" do
280
- spree_post :update, {:state => "confirm"}
281
- expect(response).to redirect_to spree.cart_path
282
- end
283
- end
284
-
285
- context "Spree::Core::GatewayError" do
286
- before do
287
- allow(order).to receive_messages :user => user
288
- allow(order).to receive(:update_attributes).and_raise(Spree::Core::GatewayError.new("Invalid something or other."))
289
- spree_post :update, {:state => "address"}
290
- end
291
-
292
- it "should render the edit template and display exception message" do
293
- expect(response).to render_template :edit
294
- expect(flash.now[:error]).to eq(Spree.t(:spree_gateway_error_flash_for_checkout))
295
- expect(assigns(:order).errors[:base]).to include("Invalid something or other.")
296
- end
297
- end
298
-
299
- context "fails to transition from address" do
300
- let(:order) do
301
- FactoryGirl.create(:order_with_line_items).tap do |order|
302
- order.next!
303
- expect(order.state).to eq('address')
304
- end
305
- end
306
-
307
- before do
308
- allow(controller).to receive_messages :current_order => order
309
- allow(controller).to receive_messages :check_authorization => true
310
- end
311
-
312
- context "when the order is invalid" do
313
- before do
314
- allow(order).to receive_messages :update_attributes => true, :next => nil
315
- order.errors.add :base, 'Base error'
316
- order.errors.add :adjustments, 'error'
317
- end
318
-
319
- it "due to the order having errors" do
320
- spree_put :update, :state => order.state, :order => {}
321
- expect(flash[:error]).to eq("Base error\nAdjustments error")
322
- expect(response).to redirect_to(spree.checkout_state_path('address'))
323
- end
324
- end
325
- end
326
-
327
- context "fails to transition to complete from confirm" do
328
- let(:order) do
329
- FactoryGirl.create(:order_with_line_items).tap do |order|
330
- order.next!
331
- end
332
- end
333
-
334
- before do
335
- allow(controller).to receive_messages :current_order => order
336
- allow(controller).to receive_messages :check_authorization => true
337
- end
338
-
339
- context "when the country is not a shippable country" do
340
- before do
341
- order.ship_address.tap do |address|
342
- # A different country which is not included in the list of shippable countries
343
- address.country = FactoryGirl.create(:country, :name => "Australia")
344
- address.state_name = 'Victoria'
345
- address.save
346
- end
347
-
348
- payment_method = FactoryGirl.create(:simple_credit_card_payment_method)
349
- payment = FactoryGirl.create(:payment, :payment_method => payment_method)
350
- order.payments << payment
351
- end
352
-
353
- it "due to no available shipping rates for any of the shipments" do
354
- expect(order.shipments.count).to eq(1)
355
- order.shipments.first.shipping_rates.delete_all
356
- order.update_attributes(state: 'confirm')
357
- spree_put :update, state: order.state, :order => {}
358
- expect(flash[:error]).to eq(Spree.t(:items_cannot_be_shipped))
359
- expect(response).to redirect_to(spree.checkout_state_path('confirm'))
360
- end
361
- end
362
- end
363
-
364
- context "when GatewayError is raised" do
365
- let(:order) do
366
- FactoryGirl.create(:order_with_line_items).tap do |order|
367
- until order.state == 'payment'
368
- order.next!
369
- end
370
- # So that the confirmation step is skipped and we get straight to the action.
371
- payment_method = FactoryGirl.create(:simple_credit_card_payment_method)
372
- payment = FactoryGirl.create(:payment, payment_method: payment_method, amount: order.total)
373
- order.payments << payment
374
- order.next!
375
- end
376
- end
377
-
378
- before do
379
- allow(controller).to receive_messages :current_order => order
380
- allow(controller).to receive_messages :check_authorization => true
381
- end
382
-
383
- it "fails to transition from payment to complete" do
384
- allow_any_instance_of(Spree::Payment).to receive(:process!).and_raise(Spree::Core::GatewayError.new(Spree.t(:payment_processing_failed)))
385
- spree_put :update, state: order.state, :order => {}
386
- expect(flash[:error]).to eq(Spree.t(:payment_processing_failed))
387
- end
388
- end
389
- end
390
-
391
- context "When last inventory item has been purchased" do
392
- let(:product) { mock_model(Spree::Product, :name => "Amazing Object") }
393
- let(:variant) { mock_model(Spree::Variant) }
394
- let(:line_item) { mock_model Spree::LineItem, :insufficient_stock? => true, :amount => 0 }
395
- let(:order) { create(:order) }
396
-
397
- before do
398
- allow(order).to receive_messages(:line_items => [line_item], :state => "payment")
399
-
400
- configure_spree_preferences do |config|
401
- config.track_inventory_levels = true
402
- end
403
- end
404
-
405
- context "and back orders are not allowed" do
406
- before do
407
- spree_post :update, { :state => "payment" }
408
- end
409
-
410
- it "should redirect to cart" do
411
- expect(response).to redirect_to spree.cart_path
412
- end
413
-
414
- it "should set flash message for no inventory" do
415
- expect(flash[:error]).to eq(Spree.t(:inventory_error_flash_for_insufficient_quantity , :names => "'#{product.name}'" ))
416
- end
417
- end
418
- end
419
-
420
- context "order doesn't have a delivery step" do
421
- before do
422
- allow(order).to receive_messages(:checkout_steps => ["cart", "address", "payment"])
423
- allow(order).to receive_messages state: "address"
424
- allow(controller).to receive_messages :check_authorization => true
425
- end
426
-
427
- it "doesn't set shipping address on the order" do
428
- expect(order).to_not receive(:ship_address=)
429
- spree_post :update, state: order.state
430
- end
431
-
432
- it "doesn't remove unshippable items before payment" do
433
- expect {
434
- spree_post :update, { :state => "payment" }
435
- }.to_not change { order.line_items }
436
- end
437
- end
438
-
439
- it "does remove unshippable items before payment" do
440
- allow(order).to receive_messages :payment_required? => true
441
- allow(controller).to receive_messages :check_authorization => true
442
-
443
- expect {
444
- spree_post :update, { :state => "payment" }
445
- }.to change { order.line_items }
446
- end
447
- end