mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
DEV: Apply syntax_tree formatting to spec/*
This commit is contained in:
@ -5,17 +5,18 @@ RSpec.describe PushNotificationController do
|
||||
|
||||
context "when logged out" do
|
||||
it "should not allow subscribe" do
|
||||
post '/push_notifications/subscribe.json', params: {
|
||||
username: "test",
|
||||
subscription: {
|
||||
endpoint: "endpoint",
|
||||
keys: {
|
||||
p256dh: "256dh",
|
||||
auth: "auth"
|
||||
}
|
||||
},
|
||||
send_confirmation: false
|
||||
}
|
||||
post "/push_notifications/subscribe.json",
|
||||
params: {
|
||||
username: "test",
|
||||
subscription: {
|
||||
endpoint: "endpoint",
|
||||
keys: {
|
||||
p256dh: "256dh",
|
||||
auth: "auth",
|
||||
},
|
||||
},
|
||||
send_confirmation: false,
|
||||
}
|
||||
|
||||
expect(response.status).to eq(403)
|
||||
end
|
||||
@ -25,35 +26,31 @@ RSpec.describe PushNotificationController do
|
||||
before { sign_in(user) }
|
||||
|
||||
it "should subscribe" do
|
||||
post '/push_notifications/subscribe.json', params: {
|
||||
username: user.username,
|
||||
subscription: {
|
||||
endpoint: "endpoint",
|
||||
keys: {
|
||||
p256dh: "256dh",
|
||||
auth: "auth"
|
||||
}
|
||||
},
|
||||
send_confirmation: false
|
||||
}
|
||||
post "/push_notifications/subscribe.json",
|
||||
params: {
|
||||
username: user.username,
|
||||
subscription: {
|
||||
endpoint: "endpoint",
|
||||
keys: {
|
||||
p256dh: "256dh",
|
||||
auth: "auth",
|
||||
},
|
||||
},
|
||||
send_confirmation: false,
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(user.push_subscriptions.count).to eq(1)
|
||||
end
|
||||
|
||||
it "should fix duplicate subscriptions" do
|
||||
subscription = {
|
||||
endpoint: "endpoint",
|
||||
keys: {
|
||||
p256dh: "256dh",
|
||||
auth: "auth"
|
||||
}
|
||||
}
|
||||
subscription = { endpoint: "endpoint", keys: { p256dh: "256dh", auth: "auth" } }
|
||||
PushSubscription.create user: user, data: subscription.to_json
|
||||
post '/push_notifications/subscribe.json', params: {
|
||||
post "/push_notifications/subscribe.json",
|
||||
params: {
|
||||
username: user.username,
|
||||
subscription: subscription,
|
||||
send_confirmation: false
|
||||
send_confirmation: false,
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
@ -62,17 +59,18 @@ RSpec.describe PushNotificationController do
|
||||
|
||||
it "should not create duplicate subscriptions" do
|
||||
2.times do
|
||||
post '/push_notifications/subscribe.json', params: {
|
||||
username: user.username,
|
||||
subscription: {
|
||||
endpoint: "endpoint",
|
||||
keys: {
|
||||
p256dh: "256dh",
|
||||
auth: "auth"
|
||||
post "/push_notifications/subscribe.json",
|
||||
params: {
|
||||
username: user.username,
|
||||
subscription: {
|
||||
endpoint: "endpoint",
|
||||
keys: {
|
||||
p256dh: "256dh",
|
||||
auth: "auth",
|
||||
},
|
||||
},
|
||||
send_confirmation: false,
|
||||
}
|
||||
},
|
||||
send_confirmation: false
|
||||
}
|
||||
end
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
@ -83,26 +81,28 @@ RSpec.describe PushNotificationController do
|
||||
sub = { endpoint: "endpoint", keys: { p256dh: "256dh", auth: "auth" } }
|
||||
PushSubscription.create!(user: user, data: sub.to_json)
|
||||
|
||||
post '/push_notifications/unsubscribe.json', params: {
|
||||
username: user.username,
|
||||
subscription: sub
|
||||
}
|
||||
post "/push_notifications/unsubscribe.json",
|
||||
params: {
|
||||
username: user.username,
|
||||
subscription: sub,
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(user.push_subscriptions).to eq([])
|
||||
end
|
||||
|
||||
it "should unsubscribe without subscription" do
|
||||
post '/push_notifications/unsubscribe.json', params: {
|
||||
username: user.username,
|
||||
subscription: {
|
||||
endpoint: "endpoint",
|
||||
keys: {
|
||||
p256dh: "256dh",
|
||||
auth: "auth"
|
||||
}
|
||||
}
|
||||
}
|
||||
post "/push_notifications/unsubscribe.json",
|
||||
params: {
|
||||
username: user.username,
|
||||
subscription: {
|
||||
endpoint: "endpoint",
|
||||
keys: {
|
||||
p256dh: "256dh",
|
||||
auth: "auth",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(user.push_subscriptions).to eq([])
|
||||
|
Reference in New Issue
Block a user