+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
defmodule Pleroma.Web.TwitterAPI.NotificationViewTest do
use Pleroma.DataCase
- alias Pleroma.{User, Notification}
+ alias Pleroma.User
+ alias Pleroma.Notification
alias Pleroma.Web.TwitterAPI.TwitterAPI
alias Pleroma.Web.TwitterAPI.NotificationView
alias Pleroma.Web.TwitterAPI.UserView
alias Pleroma.Web.TwitterAPI.ActivityView
alias Pleroma.Web.CommonAPI.Utils
alias Pleroma.Web.ActivityPub.ActivityPub
- alias Pleroma.Builders.UserBuilder
import Pleroma.Factory
{: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 = %{
"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 = %{
"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
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 = %{
"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
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 = %{
"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