removing not needed invite update
This commit is contained in:
parent
d0696fdfd6
commit
fee50636d0
|
@ -96,9 +96,8 @@ def valid_invite?(%{invite_type: "reusable_date_limited"} = invite) do
|
||||||
not_overdue_date?(invite) and invite.uses < invite.max_use and not invite.used
|
not_overdue_date?(invite) and invite.uses < invite.max_use and not invite.used
|
||||||
end
|
end
|
||||||
|
|
||||||
defp not_overdue_date?(%{expires_at: expires_at} = invite) do
|
defp not_overdue_date?(%{expires_at: expires_at}) do
|
||||||
Date.compare(Date.utc_today(), expires_at) in [:lt, :eq] ||
|
Date.compare(Date.utc_today(), expires_at) in [:lt, :eq]
|
||||||
(update_invite!(invite, %{used: true}) && false)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@spec update_usage!(UserInviteToken.t()) :: nil | UserInviteToken.t() | no_return()
|
@spec update_usage!(UserInviteToken.t()) :: nil | UserInviteToken.t() | no_return()
|
||||||
|
|
|
@ -492,7 +492,7 @@ test "returns an error on overdue date", %{data: data} do
|
||||||
refute User.get_by_nickname("vinny")
|
refute User.get_by_nickname("vinny")
|
||||||
invite = Repo.get_by(UserInviteToken, token: invite.token)
|
invite = Repo.get_by(UserInviteToken, token: invite.token)
|
||||||
|
|
||||||
assert invite.used == true
|
refute invite.used
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue