From a39aad9e64e75d4eb49298fe45d8ae648f39c1a6 Mon Sep 17 00:00:00 2001 From: Morgan Roderick Date: Wed, 2 Sep 2026 11:42:41 +0200 Subject: [PATCH] fix(unsubscribe): avoid DoubleRenderError for members with incomplete details MembersController#unsubscribe called authenticate_member! and then unconditionally redirected to subscriptions_path. For members whose profile is incomplete, finish_registration (inside authenticate_member!) already redirects to edit_member_details_path, so the second redirect raised AbstractController::DoubleRenderError (Rollbar item 660). Guard the second redirect with `unless performed?` and add a regression spec for the incomplete-details path. --- app/controllers/members_controller.rb | 3 +-- spec/controllers/members_controller_spec.rb | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb index c49a9d77a..fa659a3ea 100644 --- a/app/controllers/members_controller.rb +++ b/app/controllers/members_controller.rb @@ -38,8 +38,7 @@ def unsubscribe session[:member_id] = member.id authenticate_member! - - redirect_to subscriptions_path + redirect_to subscriptions_path unless performed? rescue StandardError redirect_to root_path, notice: 'Your token is invalid. ' end diff --git a/spec/controllers/members_controller_spec.rb b/spec/controllers/members_controller_spec.rb index d54c3fc5e..ab236da23 100644 --- a/spec/controllers/members_controller_spec.rb +++ b/spec/controllers/members_controller_spec.rb @@ -6,6 +6,13 @@ expect(response).to redirect_to(subscriptions_path) end + it 'does not render twice when the member has incomplete details' do + member = Fabricate.build(:member, about_you: nil) + member.save(validate: false) + get :unsubscribe, params: { token: member_token(member) } + expect(response).to redirect_to(edit_member_details_path) + end + it 'redirects to the root path when token is invalid' do get :unsubscribe, params: { token: 'foo' } expect(response).to redirect_to(root_path)