Skip to content

Commit

Permalink
update endpoints to patch
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLucqs committed Oct 14, 2024
1 parent 34f0e2f commit 0ec8231
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions backend/lib/peach_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ defmodule PeachWeb.Router do
scope "/api", PeachWeb do
pipe_through(:api)
post "/events/create", EventController, :create
put "/events/:id/name", EventController, :update_event_name
put "/events/:id/description", EventController, :update_event_description
put "/events/:id/location", EventController, :update_event_location
put "/events/:id/cover", EventController, :update_event_cover
put "/events/:id/treasury", EventController, :update_event_treasury
patch "/events/:id/name", EventController, :update_event_name
patch "/events/:id/description", EventController, :update_event_description
patch "/events/:id/location", EventController, :update_event_location
patch "/events/:id/cover", EventController, :update_event_cover
patch "/events/:id/treasury", EventController, :update_event_treasury
end

# Enable LiveDashboard and Swoosh mailbox preview in development
Expand Down
4 changes: 2 additions & 2 deletions backend/test/peach_web/controllers/update_event_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ defmodule PeachWeb.EventUpdateControllertest do
expected_event = @original_event

Enum.reduce(updated_fields, expected_event, fn {field, value}, acc ->
conn = put(conn, "/api/events/1/#{field}", %{"#{field}" => value})
conn = patch(conn, "/api/events/1/#{field}", %{"#{field}" => value})
acc = Map.replace(acc, String.to_atom(field), value)

# Assert response status
Expand Down Expand Up @@ -62,7 +62,7 @@ defmodule PeachWeb.EventUpdateControllertest do
expected_event = @original_event

Enum.each(updated_fields, fn {field, value} ->
conn = put(conn, "/api/events/1/#{field}", %{"#{field}" => value})
conn = patch(conn, "/api/events/1/#{field}", %{"#{field}" => value})

# Assert response status
assert conn.status == 400
Expand Down

0 comments on commit 0ec8231

Please sign in to comment.