Skip to content

Commit 972c892

Browse files
authored
Merge pull request #2517 from mroderick/fix-error-656-undefined-method-event-for-nil
fix: return 404 when invitation not found by token
2 parents dc84bf1 + 6c83d92 commit 972c892

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

app/controllers/invitations_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def cancel_meeting
8888

8989
def set_invitation
9090
@invitation = Invitation.find_by(token: params[:token])
91+
raise ActionController::RoutingError, 'Invitation not found' unless @invitation
9192
end
9293

9394
def load_invitation
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
RSpec.describe InvitationsController do
2+
let(:event) { Fabricate(:event) }
3+
4+
describe 'GET #show' do
5+
context 'with invalid token' do
6+
it 'returns http not found' do
7+
get :show, params: { event_id: event.id, token: 'invalid_token' }
8+
expect(response).to have_http_status(:not_found)
9+
end
10+
end
11+
end
12+
13+
describe 'POST #attend' do
14+
context 'with invalid token' do
15+
it 'returns http not found' do
16+
post :attend, params: { event_id: event.id, token: 'invalid_token' }
17+
expect(response).to have_http_status(:not_found)
18+
end
19+
end
20+
end
21+
22+
describe 'POST #reject' do
23+
context 'with invalid token' do
24+
it 'returns http not found' do
25+
post :reject, params: { event_id: event.id, token: 'invalid_token' }
26+
expect(response).to have_http_status(:not_found)
27+
end
28+
end
29+
end
30+
end

0 commit comments

Comments
 (0)