searchable: fix searching for polymorphic attributes.
Fix not being able to use the full set of search operators on polymorphic `model_id` and `model_type` attributes. Before things like `search[model_type]=Post` worked, but `search[model_type_not_eq]=Post` or other `model_type_*` operators didn't.
This commit is contained in:
@@ -65,8 +65,9 @@ class ActiveSupport::TestCase
|
||||
CurrentUser.scoped(user, &block)
|
||||
end
|
||||
|
||||
def assert_search_equals(expected_results, current_user: CurrentUser.user, **params)
|
||||
results = subject.class.search(params, current_user)
|
||||
def assert_search_equals(expected_results, current_user: User.anonymous, **params)
|
||||
klass = subject.is_a?(ApplicationRecord) ? subject.class : subject
|
||||
results = klass.search(params, current_user)
|
||||
|
||||
assert_equal(Array(expected_results).map(&:id), results.ids)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user