From 5cc5c9943cbc9a53246dda98958e99d004f0dfa9 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 20 Jun 2023 15:13:05 +0200 Subject: [PATCH] fix(participant): handle re-confirming participation Signed-off-by: Thomas Citharel --- lib/graphql/resolvers/participant.ex | 3 +++ test/graphql/resolvers/participant_test.exs | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/lib/graphql/resolvers/participant.ex b/lib/graphql/resolvers/participant.ex index e752c0a51..f488e88c8 100644 --- a/lib/graphql/resolvers/participant.ex +++ b/lib/graphql/resolvers/participant.ex @@ -282,6 +282,9 @@ defmodule Mobilizon.GraphQL.Resolvers.Participant do {:error, dgettext("errors", "Participation is confirmed but not approved yet by an organizer")} + {:has_participant, %Participant{role: :participant}} -> + {:error, dgettext("errors", "Participation is already confirmed")} + {:has_participant, nil} -> {:error, dgettext("errors", "This token is invalid")} diff --git a/test/graphql/resolvers/participant_test.exs b/test/graphql/resolvers/participant_test.exs index bd431f14b..8c8201d8b 100644 --- a/test/graphql/resolvers/participant_test.exs +++ b/test/graphql/resolvers/participant_test.exs @@ -1136,6 +1136,15 @@ defmodule Mobilizon.GraphQL.Resolvers.ParticipantTest do assert %Participant{role: :participant} = event.id |> Events.list_participants_for_event() |> Map.get(:elements) |> hd() + res = + conn + |> AbsintheHelpers.graphql_query( + query: @confirmation_mutation, + variables: %{confirmationToken: confirmation_token} + ) + + assert hd(res["errors"])["message"] == "Participation is already confirmed" + assert_email_sent(to: @email) end