8000 Handle missing RSVP confirmation huddl id by mwoods79 · Pull Request #142 · huddlz-hq/huddlz · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/huddlz/notifications/senders/rsvp_confirmation.ex
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ defmodule Huddlz.Notifications.Senders.RsvpConfirmation do
Ash.get!(Huddl, id, authorize?: false, load: [:group])
end

defp fetch_huddl!(_) do
raise ArgumentError, "RsvpConfirmation requires payload key \"huddl_id\" with a binary UUID"
end

defp format_starts_at(%DateTime{} = dt) do
Calendar.strftime(dt, "%a %b %-d, %Y at %-I:%M %p UTC")
end
Expand Down
16 changes: 16 additions & 0 deletions test/huddlz/notifications/senders/rsvp_confirmation_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,21 @@ defmodule Huddlz.Notifications.Senders.RsvpConfirmationTest do
assert email.text_body =~ "Sat & Sun"
refute email.text_body =~ "<"
end

test "raises a clear error when huddl_id is missing" do
user = generate(user())

assert_raise ArgumentError, ~r/requires payload key "huddl_id"/, fn ->
RsvpConfirmation.build(user, %{})
end
end

test "raises a clear error when huddl_id is not binary" do
user = generate(user())

assert_raise ArgumentError, ~r/requires payload key "huddl_id"/, fn ->
RsvpConfirmation.build(user, %{"huddl_id" => 123})
end
end
end
end
Loading
0