search: refactor to pass in the current user explicitly.

This commit is contained in:
evazion
2022-09-22 04:16:28 -05:00
parent b56b6c554b
commit 88ac91f5f3
82 changed files with 233 additions and 280 deletions

View File

@@ -1,12 +1,6 @@
require 'test_helper'
class SearchableTest < ActiveSupport::TestCase
def assert_search_equals(results, current_user: User.anonymous, **params)
as(current_user) do
assert_equal(Array(results).map(&:id), subject.search(**params).ids)
end
end
context "#search method" do
subject { Post }
@@ -19,7 +13,7 @@ class SearchableTest < ActiveSupport::TestCase
context "for a nonexistent attribute" do
should "raise an error" do
assert_raises(ArgumentError) do
Post.search_attributes({ answer: 42 }, :answer)
Post.search_attributes({ answer: 42 }, [:answer], current_user: User.anonymous)
end
end
end