X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fweb%2Ftwitter_api%2Fviews%2Fnotification_view_test.exs;h=8367fc6c7616047d6095e29653523ba0a3044f9a;hb=b73a1a33de76dc848037a5d0e951866bd21f92c4;hp=33aaa89e114e741cd8f5d05277f1b1508f961b30;hpb=3f7b02e7c4570681f965827888cba65b2a319f03;p=akkoma diff --git a/test/web/twitter_api/views/notification_view_test.exs b/test/web/twitter_api/views/notification_view_test.exs index 33aaa89e1..8367fc6c7 100644 --- a/test/web/twitter_api/views/notification_view_test.exs +++ b/test/web/twitter_api/views/notification_view_test.exs @@ -1,3 +1,7 @@ +# Pleroma: A lightweight social networking server +# Copyright © 2017-2018 Pleroma Authors +# SPDX-License-Identifier: AGPL-3.0-only + defmodule Pleroma.Web.TwitterAPI.NotificationViewTest do use Pleroma.DataCase @@ -8,7 +12,6 @@ defmodule Pleroma.Web.TwitterAPI.NotificationViewTest do alias Pleroma.Web.TwitterAPI.ActivityView alias Pleroma.Web.CommonAPI.Utils alias Pleroma.Web.ActivityPub.ActivityPub - alias Pleroma.Builders.UserBuilder import Pleroma.Factory @@ -24,7 +27,7 @@ defmodule Pleroma.Web.TwitterAPI.NotificationViewTest do {:ok, follower} = User.follow(follower, user) {:ok, activity} = ActivityPub.follow(follower, user) - Cachex.set(:user_cache, "user_info:#{user.id}", User.user_info(Repo.get!(User, user.id))) + Cachex.put(:user_cache, "user_info:#{user.id}", User.user_info(Repo.get!(User, user.id))) [follow_notif] = Notification.for_user(user) represented = %{ @@ -36,14 +39,17 @@ defmodule Pleroma.Web.TwitterAPI.NotificationViewTest do "ntype" => "follow" } - assert represented == NotificationView.render("notification.json", %{notification: follow_notif, for: user}) + assert represented == + NotificationView.render("notification.json", %{notification: follow_notif, for: user}) end test "A mention notification" do user = insert(:user) other_user = insert(:user) - {:ok, activity} = TwitterAPI.create_status(other_user, %{"status" => "Päivää, @#{user.nickname}"}) + {:ok, activity} = + TwitterAPI.create_status(other_user, %{"status" => "Päivää, @#{user.nickname}"}) + [notification] = Notification.for_user(user) represented = %{ @@ -55,7 +61,8 @@ defmodule Pleroma.Web.TwitterAPI.NotificationViewTest do "ntype" => "mention" } - assert represented == NotificationView.render("notification.json", %{notification: notification, for: user}) + assert represented == + NotificationView.render("notification.json", %{notification: notification, for: user}) end test "A retweet notification" do @@ -63,7 +70,7 @@ defmodule Pleroma.Web.TwitterAPI.NotificationViewTest do user = User.get_cached_by_ap_id(note_activity.data["actor"]) repeater = insert(:user) - {:ok, activity} = TwitterAPI.repeat(repeater, note_activity.id) + {:ok, _activity} = TwitterAPI.repeat(repeater, note_activity.id) [notification] = Notification.for_user(user) represented = %{ @@ -71,11 +78,13 @@ defmodule Pleroma.Web.TwitterAPI.NotificationViewTest do "from_profile" => UserView.render("show.json", %{user: repeater, for: user}), "id" => notification.id, "is_seen" => 0, - "notice" => ActivityView.render("activity.json", %{activity: notification.activity, for: user}), + "notice" => + ActivityView.render("activity.json", %{activity: notification.activity, for: user}), "ntype" => "repeat" } - assert represented == NotificationView.render("notification.json", %{notification: notification, for: user}) + assert represented == + NotificationView.render("notification.json", %{notification: notification, for: user}) end test "A like notification" do @@ -83,7 +92,7 @@ defmodule Pleroma.Web.TwitterAPI.NotificationViewTest do user = User.get_cached_by_ap_id(note_activity.data["actor"]) liker = insert(:user) - {:ok, activity} = TwitterAPI.fav(liker, note_activity.id) + {:ok, _activity} = TwitterAPI.fav(liker, note_activity.id) [notification] = Notification.for_user(user) represented = %{ @@ -91,10 +100,12 @@ defmodule Pleroma.Web.TwitterAPI.NotificationViewTest do "from_profile" => UserView.render("show.json", %{user: liker, for: user}), "id" => notification.id, "is_seen" => 0, - "notice" => ActivityView.render("activity.json", %{activity: notification.activity, for: user}), + "notice" => + ActivityView.render("activity.json", %{activity: notification.activity, for: user}), "ntype" => "like" } - assert represented == NotificationView.render("notification.json", %{notification: notification, for: user}) + assert represented == + NotificationView.render("notification.json", %{notification: notification, for: user}) end end