Skip to content

Commit

Permalink
fix: fixes event route
Browse files Browse the repository at this point in the history
Co-authored-by: Gabriel <[email protected]>
  • Loading branch information
marcos-grocha and gctoledo committed Feb 4, 2025
1 parent 6ae1dd0 commit f0c50ce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

resources :speakers, only: [ :create ], param: :code do
get "events", on: :member
get "events/:event_code", to: "speakers#event", as: :events
get "event/:event_code", to: "speakers#event", as: :events
get "schedules/:event_code", to: "speakers#schedules", as: :schedules
get "schedule_item/:schedule_item_code", to: "speakers#schedule_item", as: :schedule_item
end
Expand Down
8 changes: 4 additions & 4 deletions spec/requests/api/v1/speaker_api_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
create(:schedule_item, schedule: schedule, responsible_email: "[email protected]")
speaker = Speaker.last

get "/api/v1/speakers/#{speaker.code}/events/#{event.code}"
get "/api/v1/speakers/#{speaker.code}/event/#{event.code}"

json_response = JSON.parse(response.body)
expect(json_response['name']).to eq 'Tropical Rails Fake'
Expand All @@ -255,7 +255,7 @@
schedule = create(:schedule, event: event)
create(:schedule_item, schedule: schedule, responsible_email: "[email protected]")

get "/api/v1/speakers/INVALID_CODE/events/#{event.code}"
get "/api/v1/speakers/INVALID_CODE/event/#{event.code}"

json_response = JSON.parse(response.body)
expect(json_response["error"]). to eq 'Código não pertence a nenhum palestrante.'
Expand All @@ -270,7 +270,7 @@
create(:schedule_item, schedule: schedule, responsible_email: "[email protected]")
speaker = Speaker.last

get "/api/v1/speakers/#{speaker.code}/events/INVALID_CODE"
get "/api/v1/speakers/#{speaker.code}/event/INVALID_CODE"

json_response = JSON.parse(response.body)
expect(json_response["error"]). to eq 'Palestrante não possui nenhum evento com esse código.'
Expand All @@ -286,7 +286,7 @@
speaker = Speaker.last
allow(Speaker).to receive(:find_by).and_raise(ActiveRecord::ActiveRecordError)

get "/api/v1/speakers/#{speaker.code}/events/#{event.code}"
get "/api/v1/speakers/#{speaker.code}/event/#{event.code}"

expect(response.status).to eq 500
end
Expand Down

0 comments on commit f0c50ce

Please sign in to comment.