You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 8, 2026. It is now read-only.
Follow the readme from the above repo to run the specs.
Generate the sandbox application and start the server in dev mode.
The specs runs fine with the following(Bear with this failure for the moment!)
....
expected: "payment"
got: "complete"
(compared using ==)
# ./spec/replicate_issue_spec.rb:128:in `block (4 levels) in <top (required)>'
Finished in 24.13 seconds (files took 0.88129 seconds to load)
3 examples, 1 failure, 1 pending
Copy the db/development.sqlite3 as db/production.sqlite3 and include the secret_key_base value in sandbox/environment.yml. This prepares for the prod run.
Run in prod mode: RAILS_ENV=production rails s -e production
2 specs now fail:
Failures:
1) Order update with an empty order and then taking it through to the PAYMENT state remains in the payment state when updating payment using the checkout API when requesting to stagnate
Failure/Error: expect(response.code).to eq(200)
expected: 200
got: 500
(compared using ==)
# ./spec/replicate_issue_spec.rb:126:in `block (4 levels) in <top (required)>'
2) Order update with an empty order and then taking it through to the PAYMENT state remains transitions to the complete state when updating payment using the checkout API
Failure/Error: expect(response.code).to eq(200)
expected: 200
got: 500
(compared using ==)
# ./spec/replicate_issue_spec.rb:142:in `block (4 levels) in <top (required)>'
Finished in 13.72 seconds (files took 0.11461 seconds to load)
3 examples, 2 failures, 1 pending
Analysis
The issue occurs due to the following reasons:
The production mode uses the config config.eager_load = true, which loads the ActionController::Metal class_eval in the app/controllers/metal_decorator.rb file.
The CheckoutsController uses the before_action for update:
before_action:associate_user,only: :update
This causes the try_spree_current_user > spree_current_user > @spree_current_user ||= env['warden'].user sequence to be called.
According to this, rails wraps env within the request object.
Calling Spree::Api
checkouts#updatefrom the sandbox in production mode causes an exception in Metal decorator. This runs fine indevmode.Context
Code in question:
Reproduction
Get the latest spree source from github master. (92c6808aabec0af6fb57d91965b899c7c4fcfda1)
Clone `git@github.com:saravanak/spree_8569.git
Follow the readme from the above repo to run the specs.
Generate the sandbox application and start the server in dev mode.
The specs runs fine with the following(Bear with this failure for the moment!)
Copy the
db/development.sqlite3asdb/production.sqlite3and include thesecret_key_basevalue insandbox/environment.yml. This prepares for the prod run.Run in prod mode:
RAILS_ENV=production rails s -e production2 specs now fail:
Analysis
The issue occurs due to the following reasons:
The
productionmode uses the configconfig.eager_load = true, which loads theActionController::Metalclass_eval in theapp/controllers/metal_decorator.rbfile.The
CheckoutsControlleruses thebefore_actionforupdate:This causes the
try_spree_current_user>spree_current_user>@spree_current_user ||= env['warden'].usersequence to be called.According to this, rails wraps
envwithin therequestobject.Possible Fix
Change
envtorequest.env: