From 89cbd9df697e98b124da33156e676d6602d24088 Mon Sep 17 00:00:00 2001 From: tynka Date: Fri, 12 Jun 2026 11:47:11 +0200 Subject: [PATCH 1/2] AO3-6789 Return 404 when accessing challenge on nonexistent collection --- .../challenge_signups_controller.rb | 4 ++++ .../challenge_signups_controller_spec.rb | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/app/controllers/challenge_signups_controller.rb b/app/controllers/challenge_signups_controller.rb index e456e3ecda..1a0d956df4 100644 --- a/app/controllers/challenge_signups_controller.rb +++ b/app/controllers/challenge_signups_controller.rb @@ -17,6 +17,10 @@ class ChallengeSignupsController < ApplicationController before_action :check_signup_in_collection, only: [:show, :edit, :update, :destroy, :confirm_delete] def load_challenge + unless @collection + raise ActiveRecord::RecordNotFound, "Couldn't find collection named '#{params[:collection_id]}'" + end + @challenge = @collection.challenge no_challenge and return unless @challenge end diff --git a/spec/controllers/challenge_signups_controller_spec.rb b/spec/controllers/challenge_signups_controller_spec.rb index 4f269dde81..4c4e9571bf 100644 --- a/spec/controllers/challenge_signups_controller_spec.rb +++ b/spec/controllers/challenge_signups_controller_spec.rb @@ -46,6 +46,25 @@ "What challenge did you want to sign up for?") end end + + context "when collection does not exist" do + it "raises a RecordNotFound error" do + fake_login + expect do + get :new, params: { collection_id: "nonexistent_collection" } + end.to raise_error ActiveRecord::RecordNotFound + end + end + end + + describe "summary" do + context "when collection does not exist" do + it "raises a RecordNotFound error" do + expect do + get :summary, params: { collection_id: "nonexistent_collection" } + end.to raise_error ActiveRecord::RecordNotFound + end + end end describe "show" do From 800ea674f3553bf83635fbbafb7f6d0145cdd9d4 Mon Sep 17 00:00:00 2001 From: tynka Date: Fri, 12 Jun 2026 11:54:28 +0200 Subject: [PATCH 2/2] AO3-6789 Fix reviewdog --- app/controllers/challenge_signups_controller.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/controllers/challenge_signups_controller.rb b/app/controllers/challenge_signups_controller.rb index 1a0d956df4..a330c61436 100644 --- a/app/controllers/challenge_signups_controller.rb +++ b/app/controllers/challenge_signups_controller.rb @@ -17,10 +17,8 @@ class ChallengeSignupsController < ApplicationController before_action :check_signup_in_collection, only: [:show, :edit, :update, :destroy, :confirm_delete] def load_challenge - unless @collection - raise ActiveRecord::RecordNotFound, "Couldn't find collection named '#{params[:collection_id]}'" - end - + raise ActiveRecord::RecordNotFound, "Couldn't find collection named '#{params[:collection_id]}'" unless @collection + @challenge = @collection.challenge no_challenge and return unless @challenge end