Return a 404 response If @event is Not Found (#5798) [deploy]
This commit is contained in:
parent
29e46000a5
commit
cba4e99525
2 changed files with 9 additions and 1 deletions
|
|
@ -10,6 +10,6 @@ class EventsController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
@event = Event.find_by(slug: params[:id])
|
||||
@event = Event.find_by!(slug: params[:id])
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,10 +15,18 @@ RSpec.describe "Events", type: :request do
|
|||
get "/events"
|
||||
expect(response.body).not_to include(unpublished_event.title)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET events#show" do
|
||||
it "returns event show page" do
|
||||
get "/events/#{event.slug}"
|
||||
expect(response.body).to include event.title
|
||||
end
|
||||
|
||||
it "renders not_found" do
|
||||
expect do
|
||||
get "/events/NotSlug-#{event.slug}"
|
||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue