diff options
author | Roger Braun <roger@rogerbraun.net> | 2017-11-12 14:23:39 +0100 |
---|---|---|
committer | Roger Braun <roger@rogerbraun.net> | 2017-11-12 14:25:15 +0100 |
commit | 5fc6e9d467f69af155627cccaa27616fe7ffc61f (patch) | |
tree | f9f5cf0d8c93d22eeb232fb3579d84d1c732ef71 /test/notification_test.exs | |
parent | d293ceb1b535ab749fa841e18c1fa2ee63972afb (diff) | |
parent | 08bc31674218cd7ce634b008b7766b48e49c52e3 (diff) | |
download | pleroma-5fc6e9d467f69af155627cccaa27616fe7ffc61f.tar.gz pleroma-5fc6e9d467f69af155627cccaa27616fe7ffc61f.zip |
Merge branch 'develop' of git.pleroma.social:pleroma/pleroma into develop
Diffstat (limited to 'test/notification_test.exs')
-rw-r--r-- | test/notification_test.exs | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/test/notification_test.exs b/test/notification_test.exs index 77fdb532f..eee1c9fa3 100644 --- a/test/notification_test.exs +++ b/test/notification_test.exs @@ -31,4 +31,65 @@ defmodule Pleroma.NotificationTest do assert nil == Notification.create_notification(activity, user) end end + + describe "get notification" do + test "it gets a notification that belongs to the user" do + user = insert(:user) + other_user = insert(:user) + + {:ok, activity} = TwitterAPI.create_status(user, %{"status" => "hey @#{other_user.nickname}"}) + {:ok, [notification]} = Notification.create_notifications(activity) + {:ok, notification} = Notification.get(other_user, notification.id) + + assert notification.user_id == other_user.id + end + + test "it returns error if the notification doesn't belong to the user" do + user = insert(:user) + other_user = insert(:user) + + {:ok, activity} = TwitterAPI.create_status(user, %{"status" => "hey @#{other_user.nickname}"}) + {:ok, [notification]} = Notification.create_notifications(activity) + {:error, notification} = Notification.get(user, notification.id) + end + end + + describe "dismiss notification" do + test "it dismisses a notification that belongs to the user" do + user = insert(:user) + other_user = insert(:user) + + {:ok, activity} = TwitterAPI.create_status(user, %{"status" => "hey @#{other_user.nickname}"}) + {:ok, [notification]} = Notification.create_notifications(activity) + {:ok, notification} = Notification.dismiss(other_user, notification.id) + + assert notification.user_id == other_user.id + end + + test "it returns error if the notification doesn't belong to the user" do + user = insert(:user) + other_user = insert(:user) + + {:ok, activity} = TwitterAPI.create_status(user, %{"status" => "hey @#{other_user.nickname}"}) + {:ok, [notification]} = Notification.create_notifications(activity) + {:error, notification} = Notification.dismiss(user, notification.id) + end + end + + describe "clear notification" do + test "it clears all notifications belonging to the user" do + user = insert(:user) + other_user = insert(:user) + third_user = insert(:user) + + {:ok, activity} = TwitterAPI.create_status(user, %{"status" => "hey @#{other_user.nickname} and @#{third_user.nickname} !"}) + {:ok, _notifs} = Notification.create_notifications(activity) + {:ok, activity} = TwitterAPI.create_status(user, %{"status" => "hey again @#{other_user.nickname} and @#{third_user.nickname} !"}) + {:ok, _notifs} = Notification.create_notifications(activity) + Notification.clear(other_user) + + assert Notification.for_user(other_user) == [] + assert Notification.for_user(third_user) != [] + end + end end |