Skip to content

Commit

Permalink
Use expect for nested params in auth/setup#update (#33657)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjankowski authored Jan 21, 2025
1 parent 7543c90 commit 45149cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/auth/setup_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ def set_user
end

def user_params
params.require(:user).permit(:email)
params.expect(user: [:email])
end
end
11 changes: 11 additions & 0 deletions spec/requests/auth/setup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,15 @@
end
end
end

describe 'PUT /auth/setup' do
before { sign_in Fabricate(:user, confirmed_at: nil) }

it 'gracefully handles invalid nested params' do
put '/auth/setup?user=invalid'

expect(response)
.to have_http_status(400)
end
end
end

0 comments on commit 45149cd

Please sign in to comment.