Correctly initialise WebPush connection (#2417)

The `ipaddr` arg here is being interpreted as a positional arg (since
the keyword arg doesn't exist), which results in an invalid connection
object. This was causing push notifications to silently fail.

We should initialise the property on the object instead.
This commit is contained in:
Kevin McConnell
2026-01-22 20:03:02 +00:00
committed by GitHub
parent 8ba6a97014
commit 23fe40fa81
4 changed files with 73 additions and 1 deletions
@@ -0,0 +1,26 @@
require "test_helper"
class WebPush::PersistentRequestTest < ActiveSupport::TestCase
PUBLIC_TEST_IP = "142.250.185.206"
ENDPOINT = "https://fcm.googleapis.com/fcm/send/test123"
test "pins connection to endpoint_ip" do
request = stub_request(:post, ENDPOINT)
.with(ipaddr: PUBLIC_TEST_IP)
.to_return(status: 201)
notification = WebPush::Notification.new(
title: "Test",
body: "Test notification",
path: "/test",
badge: 0,
endpoint: ENDPOINT,
endpoint_ip: PUBLIC_TEST_IP,
p256dh_key: "BNcRdreALRFXTkOOUHK1EtK2wtaz5Ry4YfYCA_0QTpQtUbVlUls0VJXg7A8u-Ts1XbjhazAkj7I99e8QcYP7DkM",
auth_key: "tBHItJI5svbpez7KI4CCXg"
)
notification.deliver
assert_requested request
end
end