+
+ test "an announce activity" do
+ user = insert(:user)
+ other_user = insert(:user, %{nickname: "shp"})
+
+ {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!"})
+ {:ok, announce, _object} = CommonAPI.repeat(activity.id, other_user)
+
+ convo_id = TwitterAPI.context_to_conversation_id(activity.data["object"]["context"])
+
+ activity = Repo.get(Activity, activity.id)
+
+ result = ActivityView.render("activity.json", activity: announce)
+
+ expected = %{
+ "activity_type" => "repeat",
+ "created_at" => announce.data["published"] |> Utils.date_to_asctime(),
+ "external_url" => announce.data["id"],
+ "id" => announce.id,
+ "is_local" => true,
+ "is_post_verb" => false,
+ "statusnet_html" => "shp retweeted a status.",
+ "text" => "shp retweeted a status.",
+ "uri" => "tag:#{announce.data["id"]}:objectType=note",
+ "user" => UserView.render("show.json", user: other_user),
+ "retweeted_status" => ActivityView.render("activity.json", activity: activity),
+ "statusnet_conversation_id" => convo_id
+ }
+
+ assert result == expected
+ end
+
+ test "A follow activity" do
+ user = insert(:user)
+ other_user = insert(:user, %{nickname: "shp"})
+
+ {:ok, follower} = User.follow(user, other_user)
+ {:ok, follow} = ActivityPub.follow(follower, other_user)
+
+ result = ActivityView.render("activity.json", activity: follow)
+
+ expected = %{
+ "activity_type" => "follow",
+ "attentions" => [],
+ "created_at" => follow.data["published"] |> Utils.date_to_asctime(),
+ "external_url" => follow.data["id"],
+ "id" => follow.id,
+ "in_reply_to_status_id" => nil,
+ "is_local" => true,
+ "is_post_verb" => false,
+ "statusnet_html" => "#{user.nickname} started following shp",
+ "text" => "#{user.nickname} started following shp",
+ "user" => UserView.render("show.json", user: user)
+ }
+
+ assert result == expected
+ end
+
+ test "a delete activity" do
+ user = insert(:user)
+
+ {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!"})
+ {:ok, delete} = CommonAPI.delete(activity.id, user)
+
+ result = ActivityView.render("activity.json", activity: delete)
+
+ expected = %{
+ "activity_type" => "delete",
+ "attentions" => [],
+ "created_at" => delete.data["published"] |> Utils.date_to_asctime(),
+ "external_url" => delete.data["id"],
+ "id" => delete.id,
+ "in_reply_to_status_id" => nil,
+ "is_local" => true,
+ "is_post_verb" => false,
+ "statusnet_html" => "deleted notice {{tag",
+ "text" => "deleted notice {{tag",
+ "uri" => delete.data["object"],
+ "user" => UserView.render("show.json", user: user)
+ }
+
+ assert result == expected
+ end