Make sure draft events are not selected in search

Closes https://framagit.org/framasoft/mobilizon/-/issues/807

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2021-07-28 10:13:24 +02:00
parent acd921432f
commit 011128b0fb
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773
2 changed files with 14 additions and 0 deletions

View file

@ -531,6 +531,7 @@ defmodule Mobilizon.Events do
|> events_for_ends_on(args) |> events_for_ends_on(args)
|> events_for_tags(args) |> events_for_tags(args)
|> events_for_location(args) |> events_for_location(args)
|> filter_draft()
|> filter_local_or_from_followed_instances_events() |> filter_local_or_from_followed_instances_events()
|> filter_public_visibility() |> filter_public_visibility()
|> event_order_begins_on_asc() |> event_order_begins_on_asc()

View file

@ -205,6 +205,19 @@ defmodule Mobilizon.GraphQL.Resolvers.SearchTest do
assert hd(res["data"]["searchEvents"]["elements"])["uuid"] == assert hd(res["data"]["searchEvents"]["elements"])["uuid"] ==
event.uuid event.uuid
end end
test "doesn't find drafts", %{conn: conn} do
insert(:event, title: "A draft event", draft: true)
res =
AbsintheHelpers.graphql_query(conn,
query: @search_events_query,
variables: %{term: "draft"}
)
assert res["errors"] == nil
assert res["data"]["searchEvents"]["total"] == 0
end
end end
describe "search_persons/3" do describe "search_persons/3" do