|
|
|
|
@ -85,4 +85,18 @@ defmodule Plausible.Workers.SpikeNotifierTest do
|
|
|
|
|
|
|
|
|
|
assert_no_emails_delivered()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
test "adds a dashboard link if recipient has access to the site" do
|
|
|
|
|
user = insert(:user, email: "robert@example.com")
|
|
|
|
|
site = insert(:site, domain: "example.com", members: [user])
|
|
|
|
|
insert(:spike_notification, site: site, threshold: 10, recipients: ["robert@example.com"])
|
|
|
|
|
|
|
|
|
|
clickhouse_stub =
|
|
|
|
|
stub(Plausible.Stats.Clickhouse, :current_visitors, fn _site, _query -> 10 end)
|
|
|
|
|
|> stub(:top_sources, fn _site, _query, _limit, _page, _show_noref -> [] end)
|
|
|
|
|
|
|
|
|
|
SpikeNotifier.perform(nil, clickhouse_stub)
|
|
|
|
|
|
|
|
|
|
assert_email_delivered_with(html_body: ~r/View dashboard: <a href=\"http.+\/example.com/)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|