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:
Maikel Linke
2023-02-08 17:18:08 +11:00
parent ecc2c7ba43
commit 7fe913713a
2 changed files with 8 additions and 1 deletions

View File

@@ -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')

View File

@@ -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