Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Allows HttpMock to ignore query params from url path if given the option #395

Merged
merged 4 commits into from
Jan 24, 2024
Merged

Conversation

muhammadnawzad
Copy link
Contributor

Recently, I encountered an issue where date-time values within query parameters were not accurately detected and parsed, leading to inaccuracies in the mocks I had. I had to either change the business logic to not use date-time values in query parameters, or to change the way the date-time values were parsed. For me, the former was not an option, so I had to change the way the date-time values were parsed.

Currently ActiveResource::HttpMock does not provide a way to omit the query parameters from the URL when matching a request, while I understand that this is probably not a common use case since it will lead to a lot of issues when the mocked URL is not specific enough, I still think it would be useful to have the option to omit the query parameters from the URL when matching a request.

In this PR I have added a options parameter, which defaults to {}. When the options[:omit_query_params] is set to true, the query parameters will be omitted from the URL when matching a request. This does not change the default behavior of the ActiveResource::HttpMock class, rather it adds an option to change the behavior. In addition, I have also added a method remove_query_params_from_path to remove the query parameters.

I hope this is not too much of a niche use case, and that this PR can be merged. If not, I would love to hear your feedback on this.

@rafaelfranca rafaelfranca merged commit c7fc06f into rails:main Jan 24, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants