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