tests: fix regression in 6d867de20.

6d867de20 caused an exception in the ApiKeysController, which calls
respond_with with two arguments: `respond_with(CurrentUser.user, @api_key)`.
`options[0]` referred to the second argument, which was incorrect.
This commit is contained in:
evazion
2021-02-05 02:53:52 -06:00
parent 620c9e9ac9
commit 327deb9cbb

View File

@@ -29,15 +29,13 @@ class ApplicationController < ActionController::Base
private
def respond_with(subject, *options, &block)
def respond_with(subject, *args, model: model_name, **options, &block)
if params[:action] == "index" && is_redirect?(subject)
redirect_to_show(subject)
return
end
model = options[0]&.delete(:model)
if subject.respond_to?(:includes) && (request.format.json? || request.format.xml?)
model ||= model_name
associations = ParameterBuilder.includes_parameters(params[:only], model)
subject = subject.includes(associations)
end