From 75c4ceb4a2e5b59607a4688a2519e2f784aaa8f6 Mon Sep 17 00:00:00 2001 From: Sadposter Date: Fri, 5 Apr 2019 15:14:19 +0100 Subject: [PATCH] Add tests for subscriptions --- test/notification_test.exs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/notification_test.exs b/test/notification_test.exs index 12b4292aa..3a11d493b 100644 --- a/test/notification_test.exs +++ b/test/notification_test.exs @@ -29,6 +29,18 @@ defmodule Pleroma.NotificationTest do assert notification.activity_id == activity.id assert other_notification.activity_id == activity.id end + + + test "it creates a notification for subscribed users" do + user = insert(:user) + subscriber = insert(:user) + + {:ok, _, _} = TwitterAPI.subscribe(subscriber, %{"user_id" => user.id}) + {:ok, status} = TwitterAPI.create_status(user, %{"status" => "Akariiiin"}) + {:ok, [notification]} = Notification.create_notifications(status) + + assert notification.user_id == subscriber.id + end end describe "create_notification" do @@ -84,6 +96,16 @@ defmodule Pleroma.NotificationTest do {:ok, dupe} = TwitterAPI.repeat(user, status.id) assert nil == Notification.create_notification(dupe, retweeted_user) end + + test "it doesn't create duplicate notifications for follow+subscribed users" do + user = insert(:user) + subscriber = insert(:user) + + {:ok, _, _, _} = TwitterAPI.follow(subscriber, %{"user_id" => user.id}) + {:ok, _, _} = TwitterAPI.subscribe(subscriber, %{"user_id" => user.id}) + {:ok, status} = TwitterAPI.create_status(user, %{"status" => "Akariiiin"}) + {:ok, [_notif]} = Notification.create_notifications(status) + end end describe "get notification" do