Commit fee50636 authored by Alexander Strizhakov's avatar Alexander Strizhakov
Browse files

removing not needed invite update

parent d0696fdf
......@@ -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
end
defp not_overdue_date?(%{expires_at: expires_at} = invite) do
Date.compare(Date.utc_today(), expires_at) in [:lt, :eq] ||
(update_invite!(invite, %{used: true}) && false)
defp not_overdue_date?(%{expires_at: expires_at}) do
Date.compare(Date.utc_today(), expires_at) in [:lt, :eq]
end
@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")
invite = Repo.get_by(UserInviteToken, token: invite.token)
assert invite.used == true
refute invite.used
end
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment