spree_frontend 3.2.1 → 3.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/spree_frontend.gemspec +2 -3
- metadata +10 -86
- data/spec/controllers/controller_extension_spec.rb +0 -126
- data/spec/controllers/controller_helpers_spec.rb +0 -122
- data/spec/controllers/spree/checkout_controller_spec.rb +0 -515
- data/spec/controllers/spree/checkout_controller_with_views_spec.rb +0 -36
- data/spec/controllers/spree/content_controller_spec.rb +0 -12
- data/spec/controllers/spree/current_order_tracking_spec.rb +0 -44
- data/spec/controllers/spree/home_controller_spec.rb +0 -47
- data/spec/controllers/spree/orders_controller_ability_spec.rb +0 -96
- data/spec/controllers/spree/orders_controller_spec.rb +0 -134
- data/spec/controllers/spree/orders_controller_transitions_spec.rb +0 -31
- data/spec/controllers/spree/products_controller_spec.rb +0 -87
- data/spec/controllers/spree/taxons_controller_spec.rb +0 -12
- data/spec/features/address_spec.rb +0 -93
- data/spec/features/automatic_promotion_adjustments_spec.rb +0 -47
- data/spec/features/caching/products_spec.rb +0 -59
- data/spec/features/caching/taxons_spec.rb +0 -22
- data/spec/features/cart_spec.rb +0 -132
- data/spec/features/checkout_spec.rb +0 -572
- data/spec/features/checkout_unshippable_spec.rb +0 -34
- data/spec/features/coupon_code_spec.rb +0 -88
- data/spec/features/currency_spec.rb +0 -18
- data/spec/features/delivery_spec.rb +0 -64
- data/spec/features/free_shipping_promotions_spec.rb +0 -59
- data/spec/features/locale_spec.rb +0 -60
- data/spec/features/microdata_spec.rb +0 -0
- data/spec/features/order_spec.rb +0 -107
- data/spec/features/page_promotions_spec.rb +0 -36
- data/spec/features/products_spec.rb +0 -334
- data/spec/features/taxons_spec.rb +0 -147
- data/spec/features/template_rendering_spec.rb +0 -19
- data/spec/fixtures/thinking-cat.jpg +0 -0
- data/spec/helpers/frontend_helper_spec.rb +0 -57
- data/spec/helpers/taxons_helper_spec.rb +0 -17
- data/spec/spec_helper.rb +0 -126
- data/spec/support/shared_contexts/checkout_setup.rb +0 -10
- data/spec/support/shared_contexts/custom_products.rb +0 -25
- data/spec/support/shared_contexts/product_prototypes.rb +0 -30
- data/spec/views/spree/checkout/_summary_spec.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 865f2224c34ca0b71d34f282ab6230615d9fe591
|
4
|
+
data.tar.gz: a3c3a5d51fc4a29f640f4b3c73263df3180f9e80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c226880c48e91a95fa51ab60dc7b2b45fb4f77fe7abd4d65917799c9cca38e8bfafc41ea2eadf7365bc9b0626306ad29b043e01eeb177a60d5f2dbbccf45f40
|
7
|
+
data.tar.gz: bed762b9f3ab66fe008310ae974f739a8e0ec1bd7ac6d130ca9a66ed8682d0bbc89a4c0053489b523d3cac7e9bc6747c74dbb85160cfb186d24fae0e470d3d73
|
data/spree_frontend.gemspec
CHANGED
@@ -15,8 +15,7 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.homepage = 'https://spreecommerce.com'
|
16
16
|
s.license = 'BSD-3-Clause'
|
17
17
|
|
18
|
-
s.files = `git ls-files`.split("\n")
|
19
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.files = `git ls-files`.split("\n").reject { |f| f.match(/^spec/) }
|
20
19
|
s.require_path = 'lib'
|
21
20
|
s.requirements << 'none'
|
22
21
|
|
@@ -25,7 +24,7 @@ Gem::Specification.new do |s|
|
|
25
24
|
|
26
25
|
s.add_dependency 'bootstrap-sass', '>= 3.3.5.1', '< 3.4'
|
27
26
|
s.add_dependency 'canonical-rails', '~> 0.1.0'
|
28
|
-
s.add_dependency 'jquery-rails', '~> 4.
|
27
|
+
s.add_dependency 'jquery-rails', '~> 4.3'
|
29
28
|
|
30
29
|
s.add_development_dependency 'capybara-accessible'
|
31
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_frontend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spree_api
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 3.2.
|
19
|
+
version: 3.2.2
|
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: 3.2.
|
26
|
+
version: 3.2.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: spree_core
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.2.
|
33
|
+
version: 3.2.2
|
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: 3.2.
|
40
|
+
version: 3.2.2
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bootstrap-sass
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,14 +78,14 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '4.
|
81
|
+
version: '4.3'
|
82
82
|
type: :runtime
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: '4.
|
88
|
+
version: '4.3'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: capybara-accessible
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -230,44 +230,6 @@ files:
|
|
230
230
|
- lib/tasks/rake_util.rb
|
231
231
|
- lib/tasks/taxon.rake
|
232
232
|
- script/rails
|
233
|
-
- spec/controllers/controller_extension_spec.rb
|
234
|
-
- spec/controllers/controller_helpers_spec.rb
|
235
|
-
- spec/controllers/spree/checkout_controller_spec.rb
|
236
|
-
- spec/controllers/spree/checkout_controller_with_views_spec.rb
|
237
|
-
- spec/controllers/spree/content_controller_spec.rb
|
238
|
-
- spec/controllers/spree/current_order_tracking_spec.rb
|
239
|
-
- spec/controllers/spree/home_controller_spec.rb
|
240
|
-
- spec/controllers/spree/orders_controller_ability_spec.rb
|
241
|
-
- spec/controllers/spree/orders_controller_spec.rb
|
242
|
-
- spec/controllers/spree/orders_controller_transitions_spec.rb
|
243
|
-
- spec/controllers/spree/products_controller_spec.rb
|
244
|
-
- spec/controllers/spree/taxons_controller_spec.rb
|
245
|
-
- spec/features/address_spec.rb
|
246
|
-
- spec/features/automatic_promotion_adjustments_spec.rb
|
247
|
-
- spec/features/caching/products_spec.rb
|
248
|
-
- spec/features/caching/taxons_spec.rb
|
249
|
-
- spec/features/cart_spec.rb
|
250
|
-
- spec/features/checkout_spec.rb
|
251
|
-
- spec/features/checkout_unshippable_spec.rb
|
252
|
-
- spec/features/coupon_code_spec.rb
|
253
|
-
- spec/features/currency_spec.rb
|
254
|
-
- spec/features/delivery_spec.rb
|
255
|
-
- spec/features/free_shipping_promotions_spec.rb
|
256
|
-
- spec/features/locale_spec.rb
|
257
|
-
- spec/features/microdata_spec.rb
|
258
|
-
- spec/features/order_spec.rb
|
259
|
-
- spec/features/page_promotions_spec.rb
|
260
|
-
- spec/features/products_spec.rb
|
261
|
-
- spec/features/taxons_spec.rb
|
262
|
-
- spec/features/template_rendering_spec.rb
|
263
|
-
- spec/fixtures/thinking-cat.jpg
|
264
|
-
- spec/helpers/frontend_helper_spec.rb
|
265
|
-
- spec/helpers/taxons_helper_spec.rb
|
266
|
-
- spec/spec_helper.rb
|
267
|
-
- spec/support/shared_contexts/checkout_setup.rb
|
268
|
-
- spec/support/shared_contexts/custom_products.rb
|
269
|
-
- spec/support/shared_contexts/product_prototypes.rb
|
270
|
-
- spec/views/spree/checkout/_summary_spec.rb
|
271
233
|
- spree_frontend.gemspec
|
272
234
|
- vendor/assets/javascripts/jquery.validate/additional-methods.min.js
|
273
235
|
- vendor/assets/javascripts/jquery.validate/jquery.validate.min.js
|
@@ -340,46 +302,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
340
302
|
requirements:
|
341
303
|
- none
|
342
304
|
rubyforge_project:
|
343
|
-
rubygems_version: 2.6.
|
305
|
+
rubygems_version: 2.6.12
|
344
306
|
signing_key:
|
345
307
|
specification_version: 4
|
346
308
|
summary: Frontend e-commerce functionality for the Spree project.
|
347
|
-
test_files:
|
348
|
-
- spec/controllers/controller_extension_spec.rb
|
349
|
-
- spec/controllers/controller_helpers_spec.rb
|
350
|
-
- spec/controllers/spree/checkout_controller_spec.rb
|
351
|
-
- spec/controllers/spree/checkout_controller_with_views_spec.rb
|
352
|
-
- spec/controllers/spree/content_controller_spec.rb
|
353
|
-
- spec/controllers/spree/current_order_tracking_spec.rb
|
354
|
-
- spec/controllers/spree/home_controller_spec.rb
|
355
|
-
- spec/controllers/spree/orders_controller_ability_spec.rb
|
356
|
-
- spec/controllers/spree/orders_controller_spec.rb
|
357
|
-
- spec/controllers/spree/orders_controller_transitions_spec.rb
|
358
|
-
- spec/controllers/spree/products_controller_spec.rb
|
359
|
-
- spec/controllers/spree/taxons_controller_spec.rb
|
360
|
-
- spec/features/address_spec.rb
|
361
|
-
- spec/features/automatic_promotion_adjustments_spec.rb
|
362
|
-
- spec/features/caching/products_spec.rb
|
363
|
-
- spec/features/caching/taxons_spec.rb
|
364
|
-
- spec/features/cart_spec.rb
|
365
|
-
- spec/features/checkout_spec.rb
|
366
|
-
- spec/features/checkout_unshippable_spec.rb
|
367
|
-
- spec/features/coupon_code_spec.rb
|
368
|
-
- spec/features/currency_spec.rb
|
369
|
-
- spec/features/delivery_spec.rb
|
370
|
-
- spec/features/free_shipping_promotions_spec.rb
|
371
|
-
- spec/features/locale_spec.rb
|
372
|
-
- spec/features/microdata_spec.rb
|
373
|
-
- spec/features/order_spec.rb
|
374
|
-
- spec/features/page_promotions_spec.rb
|
375
|
-
- spec/features/products_spec.rb
|
376
|
-
- spec/features/taxons_spec.rb
|
377
|
-
- spec/features/template_rendering_spec.rb
|
378
|
-
- spec/fixtures/thinking-cat.jpg
|
379
|
-
- spec/helpers/frontend_helper_spec.rb
|
380
|
-
- spec/helpers/taxons_helper_spec.rb
|
381
|
-
- spec/spec_helper.rb
|
382
|
-
- spec/support/shared_contexts/checkout_setup.rb
|
383
|
-
- spec/support/shared_contexts/custom_products.rb
|
384
|
-
- spec/support/shared_contexts/product_prototypes.rb
|
385
|
-
- spec/views/spree/checkout/_summary_spec.rb
|
309
|
+
test_files: []
|
@@ -1,126 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
# This test tests the functionality within
|
4
|
-
# spree/core/controller_helpers/respond_with.rb
|
5
|
-
# Rather than duck-punching the existing controllers, let's define a custom one:
|
6
|
-
class Spree::CustomController < Spree::BaseController
|
7
|
-
def index
|
8
|
-
respond_with(Spree::Address.new) do |format|
|
9
|
-
format.html { render plain: "neutral" }
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def create
|
14
|
-
# Just need a model with validations
|
15
|
-
# Address is good enough, so let's go with that
|
16
|
-
address = Spree::Address.new(params[:address])
|
17
|
-
respond_with(address)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe Spree::CustomController, type: :controller do
|
22
|
-
after do
|
23
|
-
Spree::CustomController.clear_overrides!
|
24
|
-
end
|
25
|
-
|
26
|
-
before do
|
27
|
-
@routes = ActionDispatch::Routing::RouteSet.new.tap do |r|
|
28
|
-
r.draw {
|
29
|
-
get 'index', to: 'spree/custom#index'
|
30
|
-
post 'create', to: 'spree/custom#create'
|
31
|
-
}
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "extension testing" do
|
36
|
-
context "index" do
|
37
|
-
context "specify symbol for handler instead of Proc" do
|
38
|
-
before do
|
39
|
-
Spree::CustomController.class_eval do
|
40
|
-
respond_override({index: {html: {success: :success_method}}})
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def success_method
|
45
|
-
render plain: 'success!!!'
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "GET" do
|
51
|
-
it "has value success" do
|
52
|
-
spree_get :index
|
53
|
-
expect(response).to be_success
|
54
|
-
assert (response.body =~ /success!!!/)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "render" do
|
60
|
-
before do
|
61
|
-
Spree::CustomController.instance_eval do
|
62
|
-
respond_override(index: { html: { success: lambda { render(plain: 'success!!!') } } })
|
63
|
-
respond_override(index: { html: { failure: lambda { render(plain: 'failure!!!') } } })
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe "GET" do
|
68
|
-
it "has value success" do
|
69
|
-
spree_get :index
|
70
|
-
expect(response).to be_success
|
71
|
-
assert (response.body =~ /success!!!/)
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context "redirect" do
|
77
|
-
before do
|
78
|
-
Spree::CustomController.instance_eval do
|
79
|
-
respond_override({index: {html: {success: lambda { redirect_to('/cart') }}}})
|
80
|
-
respond_override(index: { html: { failure: lambda { render(plain: 'failure!!!') } } })
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
describe "GET" do
|
85
|
-
it "has value success" do
|
86
|
-
spree_get :index
|
87
|
-
expect(response).to be_redirect
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
context "validation error" do
|
93
|
-
before do
|
94
|
-
Spree::CustomController.instance_eval do
|
95
|
-
respond_to :html
|
96
|
-
respond_override(create: { html: { success: lambda { render(plain: 'success!!!') } } })
|
97
|
-
respond_override(create: { html: { failure: lambda { render(plain: 'failure!!!') } } })
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
describe "POST" do
|
102
|
-
it "has value success" do
|
103
|
-
spree_post :create
|
104
|
-
expect(response).to be_success
|
105
|
-
assert (response.body =~ /success!/)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
context 'A different controllers respond_override. Regression test for #1301' do
|
111
|
-
before do
|
112
|
-
Spree::CheckoutController.instance_eval do
|
113
|
-
respond_override(index: { html: { success: lambda { render(plain: 'success!!!') } } })
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
describe "POST" do
|
118
|
-
it "should not effect the wrong controller" do
|
119
|
-
spree_get :index
|
120
|
-
assert (response.body =~ /neutral/)
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
@@ -1,122 +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
|
-
let!(:available_locales) { [:en, :de] }
|
9
|
-
let!(:available_locale) { :de }
|
10
|
-
let!(:unavailable_locale) { :ru }
|
11
|
-
|
12
|
-
before do
|
13
|
-
I18n.enforce_available_locales = false
|
14
|
-
expect(I18n).to receive(:available_locales).and_return(available_locales)
|
15
|
-
end
|
16
|
-
|
17
|
-
after do
|
18
|
-
Spree::Frontend::Config[:locale] = :en
|
19
|
-
Rails.application.config.i18n.default_locale = :en
|
20
|
-
I18n.locale = :en
|
21
|
-
I18n.enforce_available_locales = true
|
22
|
-
end
|
23
|
-
|
24
|
-
# Regression test for #1184
|
25
|
-
context 'when session locale not set' do
|
26
|
-
before(:each) do
|
27
|
-
session[:locale] = nil
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'when Spree::Frontend::Config[:locale] not present' do
|
31
|
-
before(:each) do
|
32
|
-
Spree::Frontend::Config[:locale] = nil
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'when rails application default locale not set' do
|
36
|
-
before(:each) do
|
37
|
-
Rails.application.config.i18n.default_locale = nil
|
38
|
-
end
|
39
|
-
|
40
|
-
it "sets the I18n default locale" do
|
41
|
-
spree_get :index
|
42
|
-
expect(I18n.locale).to eq(I18n.default_locale)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'when rails application default locale is set' do
|
47
|
-
context 'and not in available_locales' do
|
48
|
-
before(:each) do
|
49
|
-
Rails.application.config.i18n.default_locale = unavailable_locale
|
50
|
-
end
|
51
|
-
|
52
|
-
it "sets the I18n default locale" do
|
53
|
-
spree_get :index
|
54
|
-
expect(I18n.locale).to eq(I18n.default_locale)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
context 'and in available_locales' do
|
59
|
-
before(:each) do
|
60
|
-
Rails.application.config.i18n.default_locale = available_locale
|
61
|
-
end
|
62
|
-
|
63
|
-
it "sets the rails app locale" do
|
64
|
-
expect(I18n.locale).to eq(:en)
|
65
|
-
spree_get :index
|
66
|
-
expect(I18n.locale).to eq(available_locale)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'when Spree::Frontend::Config[:locale] is present' do
|
73
|
-
context 'and not in available_locales' do
|
74
|
-
before(:each) do
|
75
|
-
Spree::Frontend::Config[:locale] = unavailable_locale
|
76
|
-
end
|
77
|
-
|
78
|
-
it "sets the I18n default locale" do
|
79
|
-
spree_get :index
|
80
|
-
expect(I18n.locale).to eq(I18n.default_locale)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
context 'and not in available_locales' do
|
85
|
-
before(:each) do
|
86
|
-
Spree::Frontend::Config[:locale] = available_locale
|
87
|
-
end
|
88
|
-
|
89
|
-
it "sets the default locale based on Spree::Frontend::Config[:locale]" do
|
90
|
-
expect(I18n.locale).to eq(:en)
|
91
|
-
spree_get :index
|
92
|
-
expect(I18n.locale).to eq(available_locale)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
context 'when session locale is set' do
|
99
|
-
context 'and not in available_locales' do
|
100
|
-
before(:each) do
|
101
|
-
session[:locale] = unavailable_locale
|
102
|
-
end
|
103
|
-
|
104
|
-
it "sets the I18n default locale" do
|
105
|
-
spree_get :index
|
106
|
-
expect(I18n.locale).to eq(I18n.default_locale)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
context 'and in available_locales' do
|
111
|
-
before(:each) do
|
112
|
-
session[:locale] = available_locale
|
113
|
-
end
|
114
|
-
|
115
|
-
it "sets the session locale" do
|
116
|
-
expect(I18n.locale).to eq(:en)
|
117
|
-
spree_get :index
|
118
|
-
expect(I18n.locale).to eq(available_locale)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
@@ -1,515 +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
|
-
end
|
82
|
-
|
83
|
-
before do
|
84
|
-
# Must have *a* shipping method and a payment method so updating from address works
|
85
|
-
allow(order).to receive(:available_shipping_methods).
|
86
|
-
and_return [stub_model(Spree::ShippingMethod)]
|
87
|
-
allow(order).to receive(:available_payment_methods).
|
88
|
-
and_return [stub_model(Spree::PaymentMethod)]
|
89
|
-
allow(order).to receive(:ensure_available_shipping_rates).
|
90
|
-
and_return true
|
91
|
-
order.line_items << FactoryGirl.create(:line_item)
|
92
|
-
end
|
93
|
-
|
94
|
-
context "with the order in the cart state" do
|
95
|
-
before do
|
96
|
-
order.update_column(:state, "cart")
|
97
|
-
allow(order).to receive_messages user: user
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should assign order" do
|
101
|
-
spree_post :update, state: "address"
|
102
|
-
expect(assigns[:order]).not_to be_nil
|
103
|
-
end
|
104
|
-
|
105
|
-
it "should advance the state" do
|
106
|
-
spree_post_address
|
107
|
-
expect(order.reload.state).to eq("delivery")
|
108
|
-
end
|
109
|
-
|
110
|
-
it "should redirect the next state" do
|
111
|
-
spree_post_address
|
112
|
-
expect(response).to redirect_to spree.checkout_state_path("delivery")
|
113
|
-
end
|
114
|
-
|
115
|
-
context "current_user respond to save address method" do
|
116
|
-
it "calls persist order address on user" do
|
117
|
-
expect(user).to receive(:persist_order_address)
|
118
|
-
spree_post :update,
|
119
|
-
state: "address",
|
120
|
-
order: {
|
121
|
-
bill_address_attributes: address_params,
|
122
|
-
use_billing: true
|
123
|
-
},
|
124
|
-
save_user_address: "1"
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
context "current_user doesnt respond to persist_order_address" do
|
129
|
-
it "doesnt raise any error" do
|
130
|
-
expect do
|
131
|
-
spree_post :update,
|
132
|
-
state: "address",
|
133
|
-
order: {
|
134
|
-
bill_address_attributes: address_params,
|
135
|
-
use_billing: true
|
136
|
-
},
|
137
|
-
save_user_address: "1"
|
138
|
-
end.to_not raise_error
|
139
|
-
end
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
context "with the order in the address state" do
|
144
|
-
before do
|
145
|
-
order.update_columns(ship_address_id: create(:address).id, state: "address")
|
146
|
-
allow(order).to receive_messages user: user
|
147
|
-
end
|
148
|
-
|
149
|
-
context "with a billing and shipping address" do
|
150
|
-
let(:bill_address_params) do
|
151
|
-
order.bill_address.attributes.except("created_at", "updated_at")
|
152
|
-
end
|
153
|
-
let(:ship_address_params) do
|
154
|
-
order.ship_address.attributes.except("created_at", "updated_at")
|
155
|
-
end
|
156
|
-
let(:update_params) do
|
157
|
-
{
|
158
|
-
state: "address",
|
159
|
-
order: {
|
160
|
-
bill_address_attributes: bill_address_params,
|
161
|
-
ship_address_attributes: ship_address_params,
|
162
|
-
use_billing: false
|
163
|
-
}
|
164
|
-
}
|
165
|
-
end
|
166
|
-
|
167
|
-
before do
|
168
|
-
@expected_bill_address_id = order.bill_address.id
|
169
|
-
@expected_ship_address_id = order.ship_address.id
|
170
|
-
|
171
|
-
spree_post :update, update_params
|
172
|
-
order.reload
|
173
|
-
end
|
174
|
-
|
175
|
-
it "updates the same billing and shipping address" do
|
176
|
-
expect(order.bill_address.id).to eq(@expected_bill_address_id)
|
177
|
-
expect(order.ship_address.id).to eq(@expected_ship_address_id)
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
context "when in the confirm state" do
|
183
|
-
before do
|
184
|
-
allow(order).to receive_messages confirmation_required?: true
|
185
|
-
order.update_column(:state, "confirm")
|
186
|
-
allow(order).to receive_messages user: user
|
187
|
-
# An order requires a payment to reach the complete state
|
188
|
-
# This is because payment_required? is true on the order
|
189
|
-
create(:payment, amount: order.total, order: order)
|
190
|
-
order.payments.reload
|
191
|
-
end
|
192
|
-
|
193
|
-
# This inadvertently is a regression test for #2694
|
194
|
-
it "should redirect to the order view" do
|
195
|
-
spree_post :update, state: "confirm"
|
196
|
-
expect(response).to redirect_to spree.order_path(order)
|
197
|
-
end
|
198
|
-
|
199
|
-
it "should populate the flash message" do
|
200
|
-
spree_post :update, state: "confirm"
|
201
|
-
expect(flash.notice).to eq(Spree.t(:order_processed_successfully))
|
202
|
-
end
|
203
|
-
|
204
|
-
it "should remove completed order from current_order" do
|
205
|
-
spree_post :update, { state: "confirm" }, order_id: "foofah"
|
206
|
-
expect(assigns(:current_order)).to be_nil
|
207
|
-
expect(assigns(:order)).to eql controller.current_order
|
208
|
-
end
|
209
|
-
end
|
210
|
-
|
211
|
-
# Regression test for #4190
|
212
|
-
context "state_lock_version" do
|
213
|
-
let(:post_params) do
|
214
|
-
{
|
215
|
-
state: "address",
|
216
|
-
order: {
|
217
|
-
bill_address_attributes: order.bill_address.attributes.except("created_at", "updated_at"),
|
218
|
-
state_lock_version: 0,
|
219
|
-
use_billing: true
|
220
|
-
}
|
221
|
-
}
|
222
|
-
end
|
223
|
-
|
224
|
-
context "correct" do
|
225
|
-
it "should properly update and increment version" do
|
226
|
-
spree_post :update, post_params
|
227
|
-
expect(order.state_lock_version).to eq 1
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
context "incorrect" do
|
232
|
-
before do
|
233
|
-
order.update_columns(state_lock_version: 1, state: "address")
|
234
|
-
end
|
235
|
-
|
236
|
-
it "order should receieve ensure_valid_order_version callback" do
|
237
|
-
expect_any_instance_of(described_class).to receive(:ensure_valid_state_lock_version)
|
238
|
-
spree_post :update, post_params
|
239
|
-
end
|
240
|
-
|
241
|
-
it "order should receieve with_lock message" do
|
242
|
-
expect(order).to receive(:with_lock)
|
243
|
-
spree_post :update, post_params
|
244
|
-
end
|
245
|
-
|
246
|
-
it "redirects back to current state" do
|
247
|
-
spree_post :update, post_params
|
248
|
-
expect(response).to redirect_to spree.checkout_state_path('address')
|
249
|
-
expect(flash[:error]).to eq "The order has already been updated."
|
250
|
-
end
|
251
|
-
end
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
context "save unsuccessful" do
|
256
|
-
before do
|
257
|
-
allow(order).to receive_messages user: user
|
258
|
-
allow(order).to receive_messages update_attributes: false
|
259
|
-
end
|
260
|
-
|
261
|
-
it "should not assign order" do
|
262
|
-
spree_post :update, state: "address"
|
263
|
-
expect(assigns[:order]).not_to be_nil
|
264
|
-
end
|
265
|
-
|
266
|
-
it "should not change the order state" do
|
267
|
-
spree_post :update, state: 'address'
|
268
|
-
end
|
269
|
-
|
270
|
-
it "should render the edit template" do
|
271
|
-
spree_post :update, state: 'address'
|
272
|
-
expect(response).to render_template :edit
|
273
|
-
end
|
274
|
-
|
275
|
-
it "should render order in payment state when payment fails" do
|
276
|
-
order.update_column(:state, 'confirm')
|
277
|
-
allow(controller).to receive(:insufficient_payment?).and_return(true)
|
278
|
-
spree_post :update, state: 'confirm'
|
279
|
-
expect(order.state).to eq('payment')
|
280
|
-
end
|
281
|
-
end
|
282
|
-
|
283
|
-
context "when current_order is nil" do
|
284
|
-
before { allow(controller).to receive_messages current_order: nil }
|
285
|
-
|
286
|
-
it "should not change the state if order is completed" do
|
287
|
-
expect(order).not_to receive(:update_attribute)
|
288
|
-
spree_post :update, state: "confirm"
|
289
|
-
end
|
290
|
-
|
291
|
-
it "should redirect to the cart_path" do
|
292
|
-
spree_post :update, state: "confirm"
|
293
|
-
expect(response).to redirect_to spree.cart_path
|
294
|
-
end
|
295
|
-
end
|
296
|
-
|
297
|
-
context "Spree::Core::GatewayError" do
|
298
|
-
before do
|
299
|
-
allow(order).to receive_messages user: user
|
300
|
-
allow(order).to receive(:update_attributes).and_raise(Spree::Core::GatewayError.new("Invalid something or other."))
|
301
|
-
spree_post :update, state: "address"
|
302
|
-
end
|
303
|
-
|
304
|
-
it "should render the edit template and display exception message" do
|
305
|
-
expect(response).to render_template :edit
|
306
|
-
expect(flash.now[:error]).to eq(Spree.t(:spree_gateway_error_flash_for_checkout))
|
307
|
-
expect(assigns(:order).errors[:base]).to include("Invalid something or other.")
|
308
|
-
end
|
309
|
-
end
|
310
|
-
|
311
|
-
context "fails to transition from address" do
|
312
|
-
let(:order) do
|
313
|
-
FactoryGirl.create(:order_with_line_items).tap do |order|
|
314
|
-
order.next!
|
315
|
-
expect(order.state).to eq('address')
|
316
|
-
end
|
317
|
-
end
|
318
|
-
|
319
|
-
before do
|
320
|
-
allow(controller).to receive_messages current_order: order
|
321
|
-
allow(controller).to receive_messages check_authorization: true
|
322
|
-
end
|
323
|
-
|
324
|
-
context "when the country is not a shippable country" do
|
325
|
-
before do
|
326
|
-
order.ship_address.tap do |address|
|
327
|
-
# A different country which is not included in the list of shippable countries
|
328
|
-
address.country = FactoryGirl.create(:country, name: "Australia")
|
329
|
-
address.state_name = 'Victoria'
|
330
|
-
address.save
|
331
|
-
end
|
332
|
-
end
|
333
|
-
|
334
|
-
it "due to no available shipping rates for any of the shipments" do
|
335
|
-
expect(order.shipments.count).to eq(1)
|
336
|
-
order.shipments.first.shipping_rates.delete_all
|
337
|
-
|
338
|
-
spree_put :update, state: order.state, order: {}
|
339
|
-
expect(flash[:error]).to eq(Spree.t(:items_cannot_be_shipped))
|
340
|
-
expect(response).to redirect_to(spree.checkout_state_path('address'))
|
341
|
-
end
|
342
|
-
end
|
343
|
-
|
344
|
-
context "when the order is invalid" do
|
345
|
-
before do
|
346
|
-
allow(order).to receive_messages(update_from_params: true, next: nil)
|
347
|
-
order.errors.add(:base, 'Base error')
|
348
|
-
order.errors.add(:adjustments, 'error')
|
349
|
-
end
|
350
|
-
|
351
|
-
it "due to the order having errors" do
|
352
|
-
spree_put :update, state: order.state, order: {}
|
353
|
-
expect(flash[:error]).to eql("Base error\nAdjustments error")
|
354
|
-
expect(response).to redirect_to(spree.checkout_state_path('address'))
|
355
|
-
end
|
356
|
-
end
|
357
|
-
end
|
358
|
-
|
359
|
-
context "fails to transition from payment to complete" do
|
360
|
-
let(:order) do
|
361
|
-
FactoryGirl.create(:order_with_line_items).tap do |order|
|
362
|
-
until order.state == 'payment'
|
363
|
-
order.next!
|
364
|
-
end
|
365
|
-
# So that the confirmation step is skipped and we get straight to the action.
|
366
|
-
payment_method = FactoryGirl.create(:simple_credit_card_payment_method)
|
367
|
-
payment = FactoryGirl.create(:payment, payment_method: payment_method)
|
368
|
-
order.payments << payment
|
369
|
-
end
|
370
|
-
end
|
371
|
-
|
372
|
-
before do
|
373
|
-
allow(controller).to receive_messages current_order: order
|
374
|
-
allow(controller).to receive_messages check_authorization: true
|
375
|
-
end
|
376
|
-
|
377
|
-
it "when GatewayError is raised" do
|
378
|
-
allow_any_instance_of(Spree::Payment).to receive(:process!).and_raise(Spree::Core::GatewayError.new(Spree.t(:payment_processing_failed)))
|
379
|
-
spree_put :update, state: order.state, order: {}
|
380
|
-
expect(flash[:error]).to eq(Spree.t(:payment_processing_failed))
|
381
|
-
end
|
382
|
-
end
|
383
|
-
end
|
384
|
-
|
385
|
-
context "When last inventory item has been purchased" do
|
386
|
-
let(:product) { mock_model(Spree::Product, name: "Amazing Object") }
|
387
|
-
let(:variant) { mock_model(Spree::Variant) }
|
388
|
-
let(:line_item) { mock_model Spree::LineItem, insufficient_stock?: true, amount: 0 }
|
389
|
-
let(:order) { create(:order) }
|
390
|
-
|
391
|
-
before do
|
392
|
-
allow(order).to receive_messages(line_items: [line_item], state: "payment")
|
393
|
-
|
394
|
-
configure_spree_preferences do |config|
|
395
|
-
config.track_inventory_levels = true
|
396
|
-
end
|
397
|
-
end
|
398
|
-
|
399
|
-
context "and back orders are not allowed" do
|
400
|
-
before do
|
401
|
-
spree_post :update, state: "payment"
|
402
|
-
end
|
403
|
-
|
404
|
-
it "should redirect to cart" do
|
405
|
-
expect(response).to redirect_to spree.cart_path
|
406
|
-
end
|
407
|
-
|
408
|
-
it "should set flash message for no inventory" do
|
409
|
-
expect(flash[:error]).to eq(
|
410
|
-
Spree.t(:inventory_error_flash_for_insufficient_quantity, names: "'#{product.name}'"))
|
411
|
-
end
|
412
|
-
end
|
413
|
-
end
|
414
|
-
|
415
|
-
context "order doesn't have a delivery step" do
|
416
|
-
before do
|
417
|
-
allow(order).to receive_messages(checkout_steps: ["cart", "address", "payment"])
|
418
|
-
allow(order).to receive_messages state: "address"
|
419
|
-
allow(controller).to receive_messages check_authorization: true
|
420
|
-
end
|
421
|
-
|
422
|
-
it "doesn't set shipping address on the order" do
|
423
|
-
expect(order).to_not receive(:ship_address=)
|
424
|
-
spree_post :update, state: order.state
|
425
|
-
end
|
426
|
-
|
427
|
-
it "doesn't remove unshippable items before payment" do
|
428
|
-
expect { spree_post :update, state: "payment" }.
|
429
|
-
to_not change { order.line_items }
|
430
|
-
end
|
431
|
-
end
|
432
|
-
|
433
|
-
it "does remove unshippable items before payment" do
|
434
|
-
allow(order).to receive_messages payment_required?: true
|
435
|
-
allow(controller).to receive_messages check_authorization: true
|
436
|
-
|
437
|
-
expect { spree_post :update, state: "payment" }.
|
438
|
-
to change { order.reload.line_items.length }
|
439
|
-
end
|
440
|
-
|
441
|
-
context 'in the payment step' do
|
442
|
-
let(:order) { OrderWalkthrough.up_to(:payment) }
|
443
|
-
let(:payment_method_id) { Spree::PaymentMethod.first.id }
|
444
|
-
|
445
|
-
before do
|
446
|
-
expect(order.state).to eq 'payment'
|
447
|
-
allow(order).to receive_messages user: user
|
448
|
-
allow(order).to receive_messages confirmation_required?: true
|
449
|
-
end
|
450
|
-
|
451
|
-
it 'does not advance the order extra even when called twice' do
|
452
|
-
spree_put :update, state: 'payment',
|
453
|
-
order: { payments_attributes: [{ payment_method_id: payment_method_id }] }
|
454
|
-
order.reload
|
455
|
-
expect(order.state).to eq 'confirm'
|
456
|
-
spree_put :update, state: 'payment',
|
457
|
-
order: { payments_attributes: [{ payment_method_id: payment_method_id }] }
|
458
|
-
order.reload
|
459
|
-
expect(order.state).to eq 'confirm'
|
460
|
-
end
|
461
|
-
|
462
|
-
context 'with store credits payment' do
|
463
|
-
let(:user) { create(:user) }
|
464
|
-
let(:credit_amount) { order.total + 1.00 }
|
465
|
-
let(:put_attrs) do
|
466
|
-
{
|
467
|
-
state: 'payment',
|
468
|
-
apply_store_credit: 'Apply Store Credit',
|
469
|
-
order: {
|
470
|
-
payments_attributes: [{ payment_method_id: payment_method_id }],
|
471
|
-
}
|
472
|
-
}
|
473
|
-
end
|
474
|
-
before do
|
475
|
-
create(:store_credit_payment_method)
|
476
|
-
create(:store_credit, user: user, amount: credit_amount)
|
477
|
-
end
|
478
|
-
|
479
|
-
def expect_one_store_credit_payment(order, amount)
|
480
|
-
expect(order.payments.count).to eq 1
|
481
|
-
expect(order.payments.first.source).to be_a Spree::StoreCredit
|
482
|
-
expect(order.payments.first.amount).to eq amount
|
483
|
-
end
|
484
|
-
|
485
|
-
it 'can fully pay with store credits while removing other payment attributes' do
|
486
|
-
spree_put :update, put_attrs
|
487
|
-
|
488
|
-
order.reload
|
489
|
-
expect(order.state).to eq 'confirm'
|
490
|
-
expect_one_store_credit_payment(order, order.total)
|
491
|
-
end
|
492
|
-
|
493
|
-
it 'can fully pay with store credits while removing an existing card' do
|
494
|
-
credit_card = create(:credit_card, user: user, payment_method: Spree::PaymentMethod.first)
|
495
|
-
put_attrs[:order][:existing_card] = credit_card.id
|
496
|
-
spree_put :update, put_attrs
|
497
|
-
|
498
|
-
order.reload
|
499
|
-
expect(order.state).to eq 'confirm'
|
500
|
-
expect_one_store_credit_payment(order, order.total)
|
501
|
-
end
|
502
|
-
|
503
|
-
context 'partial payment' do
|
504
|
-
let(:credit_amount) { order.total - 1.00 }
|
505
|
-
it 'returns to payment for partial store credit' do
|
506
|
-
spree_put :update, put_attrs
|
507
|
-
|
508
|
-
order.reload
|
509
|
-
expect(order.state).to eq 'payment'
|
510
|
-
expect_one_store_credit_payment(order, credit_amount)
|
511
|
-
end
|
512
|
-
end
|
513
|
-
end
|
514
|
-
end
|
515
|
-
end
|