mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-02 02:11:33 +00:00
Use same parameters for report job as for original
The Enterprise Fee Summary report modified the `params` object. So when we pass the same `params` a second time to the report class it doesn't find the same values. In some cases that would lead to a server error. The next commit implements a better solution though.
This commit is contained in:
@@ -8,7 +8,8 @@ module Reporting
|
||||
|
||||
def initialize(user, params = {}, render: false)
|
||||
super(user, params, render: render)
|
||||
p = params[:q]
|
||||
# Clone hash before modifying it:
|
||||
p = params[:q].clone
|
||||
if p.present?
|
||||
p['start_at'] = p.delete('completed_at_gt')
|
||||
p['end_at'] = p.delete('completed_at_lt')
|
||||
|
||||
@@ -99,6 +99,12 @@ describe Reporting::Reports::EnterpriseFeeSummary::Base do
|
||||
let!(:second_customer_order) { prepare_order(customer: customer) }
|
||||
let!(:other_customer_order) { prepare_order(customer: another_customer) }
|
||||
|
||||
it "doesn't delete params" do
|
||||
params = ActionController::Parameters.new("completed_at_gt" => "2023-02-08+00:00")
|
||||
described_class.new(current_user, params)
|
||||
expect(params["completed_at_gt"]).to eq "2023-02-08+00:00"
|
||||
end
|
||||
|
||||
it "groups and sorts entries correctly" do
|
||||
totals = subject.query_result
|
||||
|
||||
|
||||
Reference in New Issue
Block a user