searchable: refactor search_attributes helper methods into class.

Move the `search_attributes` helper methods inside the Searchable
concern into a SearchContext helper class. This is so we don't have to
pass `params` and `current_user` down through a bunch of different
helper methods, and so that these private helper methods don't pollute
the object's namespace.
This commit is contained in:
evazion
2022-09-21 04:15:38 -05:00
parent 91fca27126
commit 6a9a679149
2 changed files with 415 additions and 409 deletions

View File

@@ -19,7 +19,7 @@ class SearchableTest < ActiveSupport::TestCase
context "for a nonexistent attribute" do
should "raise an error" do
assert_raises(ArgumentError) do
Post.search_attribute(:answer, 42, User.anonymous)
Post.search_attributes({ answer: 42 }, :answer)
end
end
end