ap_id: [String.t()],
order_by: term(),
select: term(),
- limit: pos_integer()
+ limit: pos_integer(),
+ actor_types: [String.t()]
}
| map()
where(query, [u], u.is_admin == ^bool)
end
+ defp compose_query({:actor_types, actor_types}, query) when is_list(actor_types) do
+ where(query, [u], u.actor_type in ^actor_types)
+ end
+
defp compose_query({:is_moderator, bool}, query) do
where(query, [u], u.is_moderator == ^bool)
end
assert user2 in users
end
+ test "it returns users by actor_types" do
+ user_service = insert(:user, actor_type: "Service")
+ user_application = insert(:user, actor_type: "Application")
+ user1 = insert(:user)
+ user2 = insert(:user)
+
+ {:ok, [^user_service], 1} = Search.user(%{actor_types: ["Service"]})
+ {:ok, [^user_application], 1} = Search.user(%{actor_types: ["Application"]})
+ {:ok, [^user1, ^user2], 2} = Search.user(%{actor_types: ["Person"]})
+
+ {:ok, [^user_service, ^user1, ^user2], 3} =
+ Search.user(%{actor_types: ["Person", "Service"]})
+ end
+
test "it returns user by display name" do
user = insert(:user, name: "Display name")
insert(:user)