mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Remove Rails 5.0 controller spec workaround
We added a method to work around a bug. But that's not needed any more.
This commit is contained in:
@@ -122,10 +122,8 @@ describe Admin::SchedulesController, type: :controller do
|
||||
|
||||
spree_put :update, format: :json, id: coordinated_schedule.id,
|
||||
order_cycle_ids: [coordinated_order_cycle.id, coordinated_order_cycle2.id]
|
||||
reset_controller_environment
|
||||
spree_put :update, format: :json, id: coordinated_schedule.id,
|
||||
order_cycle_ids: [coordinated_order_cycle.id]
|
||||
reset_controller_environment
|
||||
spree_put :update, format: :json, id: coordinated_schedule.id,
|
||||
order_cycle_ids: [coordinated_order_cycle.id]
|
||||
end
|
||||
|
||||
@@ -23,9 +23,6 @@ module Spree
|
||||
expect(return_authorization.amount.to_s).to eq "20.2"
|
||||
expect(return_authorization.reason.to_s).to eq "broken"
|
||||
|
||||
# Reset the test controller between requests
|
||||
reset_controller_environment
|
||||
|
||||
# Update return authorization
|
||||
spree_put :update, order_id: order.number,
|
||||
id: return_authorization.id,
|
||||
|
||||
@@ -24,13 +24,5 @@ module OpenFoodNetwork
|
||||
|
||||
allow(controller).to receive_messages(spree_current_user: @enterprise_user)
|
||||
end
|
||||
|
||||
def reset_controller_environment
|
||||
# Rails 5.0 introduced a bug in controller tests (fixed in 5.2) where the controller's
|
||||
# environment is essentially cached if multiple requests are made in the same `it` block,
|
||||
# meaning subsequent requests will not be handled well. This resets the environment.
|
||||
# This edge case is quite rare though; normally we only do one request per test.
|
||||
@request.env.delete("RAW_POST_DATA")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user