mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 05:29:17 -06:00
0e65c2b3c8
Previously, it was sending notifications in site's default locale.
46 lines
1.3 KiB
Ruby
46 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe PushNotificationPusher do
|
|
|
|
it "returns badges url by default" do
|
|
expect(PushNotificationPusher.get_badge).to eq("/assets/push-notifications/discourse.png")
|
|
end
|
|
|
|
it "returns custom badges url" do
|
|
upload = Fabricate(:upload)
|
|
SiteSetting.push_notifications_icon = upload
|
|
|
|
expect(PushNotificationPusher.get_badge)
|
|
.to eq(UrlHelper.absolute(upload.url))
|
|
end
|
|
|
|
it "sends notification in user's locale" do
|
|
SiteSetting.allow_user_locale = true
|
|
user = Fabricate(:user, locale: 'pt_BR')
|
|
PushSubscription.create!(user_id: user.id, data: "{\"endpoint\": \"endpoint\"}")
|
|
|
|
PushNotificationPusher.expects(:send_notification).with(user, { "endpoint" => "endpoint" }, {
|
|
title: "system mencionou você em \"Topic\" - Discourse",
|
|
body: "description",
|
|
badge: "/assets/push-notifications/discourse.png",
|
|
icon: "/assets/push-notifications/mentioned.png",
|
|
tag: "test.localhost-1",
|
|
base_url: "http://test.localhost",
|
|
url: "https://example.com/t/1/2",
|
|
hide_when_active: true
|
|
}).once
|
|
|
|
PushNotificationPusher.push(user, {
|
|
topic_title: 'Topic',
|
|
username: 'system',
|
|
excerpt: 'description',
|
|
topic_id: 1,
|
|
post_url: "https://example.com/t/1/2",
|
|
notification_type: 1
|
|
})
|
|
end
|
|
|
|
end
|