X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;ds=sidebyside;f=test%2Fweb%2Ftwitter_api%2Ftwitter_api_test.exs;h=522cfd11d182a98327dc0041a510f3e336c417d4;hb=9ba4a1c5fe1cbc6f028f04be9c953a189a08bd09;hp=ec13b89d40f5bb8df7877873b69e4928b072e39c;hpb=42ef7cd227ba075fbd05e9625dc880feddee4417;p=akkoma
diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs
index ec13b89d4..522cfd11d 100644
--- a/test/web/twitter_api/twitter_api_test.exs
+++ b/test/web/twitter_api/twitter_api_test.exs
@@ -10,7 +10,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
test "create a status" do
user = insert(:user)
- _mentioned_user = insert(:user, %{nickname: "shp", ap_id: "shp"})
+ mentioned_user = insert(:user, %{nickname: "shp", ap_id: "shp"})
object_data = %{
"type" => "Image",
@@ -35,7 +35,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
{:ok, activity = %Activity{}} = TwitterAPI.create_status(user, input)
expected_text =
- "Hello again, @shp.<script></script>
This is on another :moominmamma: line. #2hu #epic #phantasmagoric
image.jpg"
+ "Hello again, @shp.<script></script>
This is on another :moominmamma: line. #2hu #epic #phantasmagoric
image.jpg"
assert get_in(activity.data, ["object", "content"]) == expected_text
assert get_in(activity.data, ["object", "type"]) == "Note"
@@ -182,13 +182,15 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
end
test "upload a file" do
+ user = insert(:user)
+
file = %Plug.Upload{
content_type: "image/jpg",
path: Path.absname("test/fixtures/image.jpg"),
filename: "an_image.jpg"
}
- response = TwitterAPI.upload(file)
+ response = TwitterAPI.upload(file, user)
assert is_binary(response)
end
@@ -244,7 +246,6 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
"nickname" => "lain",
"email" => "lain@wired.jp",
"fullname" => "lain iwakura",
- "bio" => "close the world.",
"password" => "bear",
"confirm" => "bear"
}
@@ -257,6 +258,53 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do
UserView.render("show.json", %{user: fetched_user})
end
+ test "it registers a new user with empty string in bio and returns the user." do
+ data = %{
+ "nickname" => "lain",
+ "email" => "lain@wired.jp",
+ "fullname" => "lain iwakura",
+ "bio" => "",
+ "password" => "bear",
+ "confirm" => "bear"
+ }
+
+ {:ok, user} = TwitterAPI.register_user(data)
+
+ fetched_user = Repo.get_by(User, nickname: "lain")
+
+ assert UserView.render("show.json", %{user: user}) ==
+ UserView.render("show.json", %{user: fetched_user})
+ end
+
+ test "it registers a new user and parses mentions in the bio" do
+ data1 = %{
+ "nickname" => "john",
+ "email" => "john@gmail.com",
+ "fullname" => "John Doe",
+ "bio" => "test",
+ "password" => "bear",
+ "confirm" => "bear"
+ }
+
+ {:ok, user1} = TwitterAPI.register_user(data1)
+
+ data2 = %{
+ "nickname" => "lain",
+ "email" => "lain@wired.jp",
+ "fullname" => "lain iwakura",
+ "bio" => "@john test",
+ "password" => "bear",
+ "confirm" => "bear"
+ }
+
+ {:ok, user2} = TwitterAPI.register_user(data2)
+
+ expected_text =
+ "@john test"
+
+ assert user2.bio == expected_text
+ end
+
@moduletag skip: "needs 'registrations_open: false' in config"
test "it registers a new user via invite token and returns the user." do
{:ok, token} = UserInviteToken.create_token()