X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=test%2Fweb%2Ftwitter_api%2Ftwitter_api_controller_test.exs;h=90718cfb4351c5f342f2bec19bc3c874c314635e;hb=17d01869ea82e1b0ad4b78479cabe0637d04d1cf;hp=e7293e384bad926ba56b9fb8f3bd78defed94ee3;hpb=fe511a6c653f24f95dd3bed5941724e3d0155f3a;p=akkoma diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index e7293e384..90718cfb4 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -270,7 +270,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do test "returns one status", %{conn: conn} do user = insert(:user) {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey!"}) - actor = Repo.get_by!(User, ap_id: activity.data["actor"]) + actor = User.get_cached_by_ap_id(activity.data["actor"]) conn = conn @@ -720,7 +720,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do |> with_credentials(current_user.nickname, "test") |> post("/api/friendships/create.json", %{user_id: followed.id}) - current_user = User.get_by_id(current_user.id) + current_user = User.get_cached_by_id(current_user.id) assert User.ap_followers(followed) in current_user.following assert json_response(conn, 200) == @@ -735,8 +735,8 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do |> with_credentials(current_user.nickname, "test") |> post("/api/friendships/create.json", %{user_id: followed.id}) - current_user = User.get_by_id(current_user.id) - followed = User.get_by_id(followed.id) + current_user = User.get_cached_by_id(current_user.id) + followed = User.get_cached_by_id(followed.id) refute User.ap_followers(followed) in current_user.following @@ -765,7 +765,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do |> with_credentials(current_user.nickname, "test") |> post("/api/friendships/destroy.json", %{user_id: followed.id}) - current_user = User.get_by_id(current_user.id) + current_user = User.get_cached_by_id(current_user.id) assert current_user.following == [current_user.ap_id] assert json_response(conn, 200) == @@ -789,7 +789,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do |> with_credentials(current_user.nickname, "test") |> post("/api/blocks/create.json", %{user_id: blocked.id}) - current_user = User.get_by_id(current_user.id) + current_user = User.get_cached_by_id(current_user.id) assert User.blocks?(current_user, blocked) assert json_response(conn, 200) == @@ -816,7 +816,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do |> with_credentials(current_user.nickname, "test") |> post("/api/blocks/destroy.json", %{user_id: blocked.id}) - current_user = User.get_by_id(current_user.id) + current_user = User.get_cached_by_id(current_user.id) assert current_user.info.blocks == [] assert json_response(conn, 200) == @@ -847,7 +847,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do |> with_credentials(current_user.nickname, "test") |> post("/api/qvitter/update_avatar.json", %{img: avatar_image}) - current_user = User.get_by_id(current_user.id) + current_user = User.get_cached_by_id(current_user.id) assert is_map(current_user.avatar) assert json_response(conn, 200) == @@ -956,7 +956,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do |> post(request_path) activity = Activity.get_by_id(note_activity.id) - activity_user = User.get_by_ap_id(note_activity.data["actor"]) + activity_user = User.get_cached_by_ap_id(note_activity.data["actor"]) assert json_response(response, 200) == ActivityView.render("activity.json", %{ @@ -994,7 +994,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do |> post(request_path) activity = Activity.get_by_id(note_activity.id) - activity_user = User.get_by_ap_id(note_activity.data["actor"]) + activity_user = User.get_cached_by_ap_id(note_activity.data["actor"]) assert json_response(response, 200) == ActivityView.render("activity.json", %{ @@ -1022,7 +1022,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do user = json_response(conn, 200) - fetched_user = User.get_by_nickname("lain") + fetched_user = User.get_cached_by_nickname("lain") assert user == UserView.render("show.json", %{user: fetched_user}) end @@ -1064,7 +1064,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do test "it sends an email to user", %{user: user} do token_record = Repo.get_by(Pleroma.PasswordResetToken, user_id: user.id) - email = Pleroma.UserEmail.password_reset_email(user, token_record.token) + email = Pleroma.Emails.UserEmail.password_reset_email(user, token_record.token) notify_email = Pleroma.Config.get([:instance, :notify_email]) instance_name = Pleroma.Config.get([:instance, :name]) @@ -1116,7 +1116,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do test "it confirms the user account", %{conn: conn, user: user} do get(conn, "/api/account/confirm_email/#{user.id}/#{user.info.confirmation_token}") - user = User.get_by_id(user.id) + user = User.get_cached_by_id(user.id) refute user.info.confirmation_pending refute user.info.confirmation_token @@ -1170,7 +1170,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do |> assign(:user, user) |> post("/api/account/resend_confirmation_email?email=#{user.email}") - email = Pleroma.UserEmail.account_confirmation_email(user) + email = Pleroma.Emails.UserEmail.account_confirmation_email(user) notify_email = Pleroma.Config.get([:instance, :notify_email]) instance_name = Pleroma.Config.get([:instance, :name]) @@ -1611,6 +1611,34 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do assert json_response(conn, 200) == UserView.render("user.json", %{user: user, for: user}) end + + # Broken before the change to class="emoji" and non- in the DB + @tag :skip + test "it formats emojos", %{conn: conn} do + user = insert(:user) + + conn = + conn + |> assign(:user, user) + |> post("/api/account/update_profile.json", %{ + "bio" => "I love our :moominmamma:​" + }) + + assert response = json_response(conn, 200) + + assert %{ + "description" => "I love our :moominmamma:", + "description_html" => + ~s{I love our moominmamma "success"} - fetched_user = User.get_by_id(current_user.id) + fetched_user = User.get_cached_by_id(current_user.id) assert Pbkdf2.checkpw("newpass", fetched_user.password_hash) == true end end @@ -1783,8 +1811,8 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do {:ok, _activity} = ActivityPub.follow(other_user, user) - user = User.get_by_id(user.id) - other_user = User.get_by_id(other_user.id) + user = User.get_cached_by_id(user.id) + other_user = User.get_cached_by_id(other_user.id) assert User.following?(other_user, user) == false @@ -1823,8 +1851,8 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do {:ok, _activity} = ActivityPub.follow(other_user, user) - user = User.get_by_id(user.id) - other_user = User.get_by_id(other_user.id) + user = User.get_cached_by_id(user.id) + other_user = User.get_cached_by_id(other_user.id) assert User.following?(other_user, user) == false @@ -1846,8 +1874,8 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do {:ok, _activity} = ActivityPub.follow(other_user, user) - user = User.get_by_id(user.id) - other_user = User.get_by_id(other_user.id) + user = User.get_cached_by_id(user.id) + other_user = User.get_cached_by_id(other_user.id) assert User.following?(other_user, user) == false @@ -1916,7 +1944,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do describe "POST /api/media/metadata/create" do setup do object = insert(:note) - user = User.get_by_ap_id(object.data["actor"]) + user = User.get_cached_by_ap_id(object.data["actor"]) %{object: object, user: user} end