From 5d3fdbc08223a1b8b6f36f2621214285c383b840 Mon Sep 17 00:00:00 2001 From: eal Date: Wed, 30 May 2018 16:33:37 +0300 Subject: MastoAPI: Add streaming for lists. --- test/list_test.exs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'test') diff --git a/test/list_test.exs b/test/list_test.exs index ced012093..da3b88024 100644 --- a/test/list_test.exs +++ b/test/list_test.exs @@ -74,4 +74,20 @@ defmodule Pleroma.ListTest do assert list_two in lists refute list_three in lists end + + test "getting all lists the user is a member of" do + user = insert(:user) + other_user = insert(:user) + {:ok, list_one} = Pleroma.List.create("title", user) + {:ok, list_two} = Pleroma.List.create("other title", user) + {:ok, list_three} = Pleroma.List.create("third title", other_user) + {:ok, list_one} = Pleroma.List.follow(list_one, other_user) + {:ok, list_two} = Pleroma.List.follow(list_two, other_user) + {:ok, list_three} = Pleroma.List.follow(list_three, user) + + lists = Pleroma.List.get_lists_from_activity(%Pleroma.Activity{actor: other_user.ap_id}) + assert list_one in lists + assert list_two in lists + refute list_three in lists + end end -- cgit v1.2.3 From 87566b6e2f48ee2b82d4af7ccb6200ff8bc721d1 Mon Sep 17 00:00:00 2001 From: eal Date: Sun, 3 Jun 2018 22:01:37 +0300 Subject: user.ex: add domain blocks. --- test/user_test.exs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test') diff --git a/test/user_test.exs b/test/user_test.exs index 8c8cfd673..200352981 100644 --- a/test/user_test.exs +++ b/test/user_test.exs @@ -361,6 +361,27 @@ defmodule Pleroma.UserTest do end end + describe "domain blocking" do + test "blocks domains" do + user = insert(:user) + collateral_user = insert(:user, %{ap_id: "https://awful-and-rude-instance.com/user/bully"}) + + {:ok, user} = User.block_domain(user, "awful-and-rude-instance.com") + + assert User.blocks?(user, collateral_user) + end + + test "unblocks domains" do + user = insert(:user) + collateral_user = insert(:user, %{ap_id: "https://awful-and-rude-instance.com/user/bully"}) + + {:ok, user} = User.block_domain(user, "awful-and-rude-instance.com") + {:ok, user} = User.unblock_domain(user, "awful-and-rude-instance.com") + + refute User.blocks?(user, collateral_user) + end + end + test "get recipients from activity" do actor = insert(:user) user = insert(:user, local: true) -- cgit v1.2.3 From 4856962434ffd36826a4fc3052b867e751efc828 Mon Sep 17 00:00:00 2001 From: eal Date: Sun, 3 Jun 2018 22:21:23 +0300 Subject: MastoAPI: add domain blocking. --- .../mastodon_api/mastodon_api_controller_test.exs | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'test') diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 2abcf0dfe..eaae0b54f 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -780,6 +780,46 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do assert [%{"id" => ^other_user_id}] = json_response(conn, 200) end + test "blocking / unblocking a domain", %{conn: conn} do + user = insert(:user) + other_user = insert(:user, %{ap_id: "https://dogwhistle.zone/@pundit"}) + + conn = + conn + |> assign(:user, user) + |> post("/api/v1/domain_blocks", %{"domain" => "dogwhistle.zone"}) + + assert %{} = json_response(conn, 200) + user = User.get_cached_by_ap_id(user.ap_id) + assert User.blocks?(user, other_user) + + conn = + build_conn() + |> assign(:user, user) + |> delete("/api/v1/domain_blocks", %{"domain" => "dogwhistle.zone"}) + + assert %{} = json_response(conn, 200) + user = User.get_cached_by_ap_id(user.ap_id) + refute User.blocks?(user, other_user) + end + + test "getting a list of domain blocks" do + user = insert(:user) + + {:ok, user} = User.block_domain(user, "bad.site") + {:ok, user} = User.block_domain(user, "even.worse.site") + + conn = + conn + |> assign(:user, user) + |> get("/api/v1/domain_blocks") + + domain_blocks = json_response(conn, 200) + + assert "bad.site" in domain_blocks + assert "even.worse.site" in domain_blocks + end + test "unimplemented mute endpoints" do user = insert(:user) other_user = insert(:user) -- cgit v1.2.3 From 3f0440ac3c38b88fe449da9b8281d1dbadfa36d1 Mon Sep 17 00:00:00 2001 From: Sir_Boops Date: Sun, 15 Apr 2018 17:37:51 -0600 Subject: Dedupe uploads --- test/upload_test.exs | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'test') diff --git a/test/upload_test.exs b/test/upload_test.exs index d68b3e7ba..645f10293 100644 --- a/test/upload_test.exs +++ b/test/upload_test.exs @@ -3,40 +3,45 @@ defmodule Pleroma.UploadTest do use Pleroma.DataCase describe "Storing a file" do - test "copies the file to the configured folder" do + test "copies the file to the configured folder with deduping" do + File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg") + file = %Plug.Upload{ content_type: "image/jpg", - path: Path.absname("test/fixtures/image.jpg"), + path: Path.absname("test/fixtures/image_tmp.jpg"), filename: "an [image.jpg" } - data = Upload.store(file) - assert data["name"] == "an [image.jpg" + data = Upload.store(file, true) - assert List.first(data["url"])["href"] == - "http://localhost:4001/media/#{data["uuid"]}/an%20%5Bimage.jpg" + assert data["name"] == + "e7a6d0cf595bff76f14c9a98b6c199539559e8b844e02e51e5efcfd1f614a2df.jpeg" end - test "fixes an incorrect content type" do + test "copies the file to the configured folder without deduping" do + File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg") + file = %Plug.Upload{ - content_type: "application/octet-stream", - path: Path.absname("test/fixtures/image.jpg"), + content_type: "image/jpg", + path: Path.absname("test/fixtures/image_tmp.jpg"), filename: "an [image.jpg" } - data = Upload.store(file) - assert hd(data["url"])["mediaType"] == "image/jpeg" + data = Upload.store(file, false) + assert data["name"] == "an [image.jpg" end - test "does not modify a valid content type" do + test "fixes incorrect content type" do + File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg") + file = %Plug.Upload{ - content_type: "image/png", - path: Path.absname("test/fixtures/image.jpg"), + content_type: "application/octet-stream", + path: Path.absname("test/fixtures/image_tmp.jpg"), filename: "an [image.jpg" } - data = Upload.store(file) - assert hd(data["url"])["mediaType"] == "image/png" + data = Upload.store(file, true) + assert hd(data["url"])["mediaType"] == "image/jpeg" end end end -- cgit v1.2.3 From c99b9b9d926b30e417c2a44fa3f0f64029f76b2d Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Mon, 28 May 2018 17:45:23 +0000 Subject: testsuite: add mastodon api tests --- .../mastodon_api/mastodon_api_controller_test.exs | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'test') diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index 566f5acfc..e45b5c9c2 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -4,6 +4,7 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do alias Pleroma.Web.TwitterAPI.TwitterAPI alias Pleroma.{Repo, User, Activity, Notification} alias Pleroma.Web.{OStatus, CommonAPI} + alias Pleroma.Web.ActivityPub.ActivityPub import Pleroma.Factory import ExUnit.CaptureLog @@ -644,6 +645,63 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do end end + describe "locked accounts" do + test "/api/v1/follow_requests works" do + user = insert(:user, %{info: %{"locked" => true}}) + other_user = insert(:user) + + {:ok, activity} = ActivityPub.follow(other_user, user) + + conn = + build_conn() + |> assign(:user, user) + |> get("/api/v1/follow_requests") + + assert [relationship] = json_response(conn, 200) + assert to_string(other_user.id) == relationship["id"] + end + + test "/api/v1/follow_requests/:id/authorize works" do + user = insert(:user, %{info: %{"locked" => true}}) + other_user = insert(:user) + + {:ok, activity} = ActivityPub.follow(other_user, user) + + conn = + build_conn() + |> assign(:user, user) + |> post("/api/v1/follow_requests/#{other_user.id}/authorize") + + assert relationship = json_response(conn, 200) + assert to_string(other_user.id) == relationship["id"] + + user = Repo.get(User, user.id) + other_user = Repo.get(User, other_user.id) + + assert User.following?(other_user, user) == true + end + + test "/api/v1/follow_requests/:id/reject works" do + user = insert(:user, %{info: %{"locked" => true}}) + other_user = insert(:user) + + {:ok, activity} = ActivityPub.follow(other_user, user) + + conn = + build_conn() + |> assign(:user, user) + |> post("/api/v1/follow_requests/#{other_user.id}/reject") + + assert relationship = json_response(conn, 200) + assert to_string(other_user.id) == relationship["id"] + + user = Repo.get(User, user.id) + other_user = Repo.get(User, other_user.id) + + assert User.following?(other_user, user) == false + end + end + test "account fetching", %{conn: conn} do user = insert(:user) -- cgit v1.2.3 From a0c5b42e293959c7bc448f171fc38c2c26f91d18 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Mon, 28 May 2018 17:51:50 +0000 Subject: tests: assert the state prior to mutating it as well as afterward --- test/web/mastodon_api/mastodon_api_controller_test.exs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test') diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs index e45b5c9c2..d1812457d 100644 --- a/test/web/mastodon_api/mastodon_api_controller_test.exs +++ b/test/web/mastodon_api/mastodon_api_controller_test.exs @@ -652,6 +652,11 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do {:ok, activity} = ActivityPub.follow(other_user, user) + user = Repo.get(User, user.id) + other_user = Repo.get(User, other_user.id) + + assert User.following?(other_user, user) == false + conn = build_conn() |> assign(:user, user) @@ -667,6 +672,11 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do {:ok, activity} = ActivityPub.follow(other_user, user) + user = Repo.get(User, user.id) + other_user = Repo.get(User, other_user.id) + + assert User.following?(other_user, user) == false + conn = build_conn() |> assign(:user, user) -- cgit v1.2.3 From 993312cdb3ec219f1cf29e14be97f2b98bc90a9c Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Mon, 28 May 2018 18:19:20 +0000 Subject: twitterapi: add profile setting for locked/unlocked accounts --- .../twitter_api/twitter_api_controller_test.exs | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test') diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index 68f4331df..6a29d583c 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -762,6 +762,38 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do assert json_response(conn, 200) == UserView.render("user.json", %{user: user, for: user}) end + + test "it locks an account", %{conn: conn} do + user = insert(:user) + + conn = + conn + |> assign(:user, user) + |> post("/api/account/update_profile.json", %{ + "locked" => "true" + }) + + user = Repo.get!(User, user.id) + assert user.info["locked"] == true + + assert json_response(conn, 200) == UserView.render("user.json", %{user: user, for: user}) + end + + test "it unlocks an account", %{conn: conn} do + user = insert(:user) + + conn = + conn + |> assign(:user, user) + |> post("/api/account/update_profile.json", %{ + "locked" => "false" + }) + + user = Repo.get!(User, user.id) + assert user.info["locked"] == false + + assert json_response(conn, 200) == UserView.render("user.json", %{user: user, for: user}) + end end defp valid_user(_context) do -- cgit v1.2.3 From d116af3bee6dcad1cb5c33030bdff72335791065 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Wed, 6 Jun 2018 23:46:55 +0000 Subject: tests: add tests for /api/pleroma/friend_requests --- .../twitter_api/twitter_api_controller_test.exs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'test') diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index 6a29d583c..ac8ccfbc3 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -958,4 +958,26 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do :timer.sleep(1000) end end + + describe "GET /api/pleroma/friend_requests" do + test "it lists friend requests" do + user = insert(:user, %{info: %{"locked" => true}}) + other_user = insert(:user) + + {:ok, activity} = ActivityPub.follow(other_user, user) + + user = Repo.get(User, user.id) + other_user = Repo.get(User, other_user.id) + + assert User.following?(other_user, user) == false + + conn = + build_conn() + |> assign(:user, user) + |> get("/api/pleroma/friend_requests") + + assert [relationship] = json_response(conn, 200) + assert other_user.id == relationship["id"] + end + end end -- cgit v1.2.3 From f8e0942745636f0f51e5ff57d1b40f79ee82f87b Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Thu, 7 Jun 2018 00:04:03 +0000 Subject: twitter api: add approve/deny endpoints --- .../twitter_api/twitter_api_controller_test.exs | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'test') diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index ac8ccfbc3..bd11551df 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -980,4 +980,50 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do assert other_user.id == relationship["id"] end end + + describe "POST /api/pleroma/friendships/approve" do + test "it approves a friend request" do + user = insert(:user, %{info: %{"locked" => true}}) + other_user = insert(:user) + + {:ok, activity} = ActivityPub.follow(other_user, user) + + user = Repo.get(User, user.id) + other_user = Repo.get(User, other_user.id) + + assert User.following?(other_user, user) == false + + conn = + build_conn() + |> assign(:user, user) + |> post("/api/pleroma/friendships/approve", %{"user_id" => to_string(other_user.id)}) + + assert relationship = json_response(conn, 200) + assert other_user.id == relationship["id"] + assert relationship["follows_you"] == true + end + end + + describe "POST /api/pleroma/friendships/deny" do + test "it denies a friend request" do + user = insert(:user, %{info: %{"locked" => true}}) + other_user = insert(:user) + + {:ok, activity} = ActivityPub.follow(other_user, user) + + user = Repo.get(User, user.id) + other_user = Repo.get(User, other_user.id) + + assert User.following?(other_user, user) == false + + conn = + build_conn() + |> assign(:user, user) + |> post("/api/pleroma/friendships/deny", %{"user_id" => to_string(other_user.id)}) + + assert relationship = json_response(conn, 200) + assert other_user.id == relationship["id"] + assert relationship["follows_you"] == false + end + end end -- cgit v1.2.3 From c773f42ca4814276b56cba743883b38cec0c9e8c Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Thu, 7 Jun 2018 19:43:52 +0000 Subject: tests: update twitterapi user view tests for new locked variable --- test/web/twitter_api/views/user_view_test.exs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/web/twitter_api/views/user_view_test.exs b/test/web/twitter_api/views/user_view_test.exs index 9f8bf4cdc..eea743b32 100644 --- a/test/web/twitter_api/views/user_view_test.exs +++ b/test/web/twitter_api/views/user_view_test.exs @@ -59,7 +59,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "statusnet_profile_url" => user.ap_id, "cover_photo" => banner, "background_image" => nil, - "is_local" => true + "is_local" => true, + "locked" => false } assert represented == UserView.render("show.json", %{user: user}) @@ -94,7 +95,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "statusnet_profile_url" => user.ap_id, "cover_photo" => banner, "background_image" => nil, - "is_local" => true + "is_local" => true, + "locked" => false } assert represented == UserView.render("show.json", %{user: user, for: follower}) @@ -130,7 +132,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "statusnet_profile_url" => follower.ap_id, "cover_photo" => banner, "background_image" => nil, - "is_local" => true + "is_local" => true, + "locked" => false } assert represented == UserView.render("show.json", %{user: follower, for: user}) @@ -173,7 +176,8 @@ defmodule Pleroma.Web.TwitterAPI.UserViewTest do "statusnet_profile_url" => user.ap_id, "cover_photo" => banner, "background_image" => nil, - "is_local" => true + "is_local" => true, + "locked" => false } blocker = Repo.get(User, blocker.id) -- cgit v1.2.3 From 1555c66650967c5023b2a4f7a44a683d803091c6 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Wed, 13 Jun 2018 21:29:55 -0400 Subject: Add unretweet TwAPI endpoint and cleanup AP.unannounce --- test/web/activity_pub/activity_pub_test.exs | 4 +-- .../twitter_api/twitter_api_controller_test.exs | 34 ++++++++++++++++++++++ test/web/twitter_api/twitter_api_test.exs | 11 +++++++ 3 files changed, 46 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/web/activity_pub/activity_pub_test.exs b/test/web/activity_pub/activity_pub_test.exs index 081c202b1..bc33b4dfc 100644 --- a/test/web/activity_pub/activity_pub_test.exs +++ b/test/web/activity_pub/activity_pub_test.exs @@ -318,11 +318,9 @@ defmodule Pleroma.Web.ActivityPub.ActivityPubTest do {:ok, announce_activity, object} = ActivityPub.announce(user, object) assert object.data["announcement_count"] == 1 - {:ok, unannounce_activity, activity, object} = ActivityPub.unannounce(user, object) + {:ok, unannounce_activity, object} = ActivityPub.unannounce(user, object) assert object.data["announcement_count"] == 0 - assert activity == announce_activity - assert unannounce_activity.data["to"] == [ User.ap_followers(user), announce_activity.data["actor"] diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index 68f4331df..6866a362f 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -580,6 +580,40 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do end end + describe "POST /api/statuses/unretweet/:id" do + setup [:valid_user] + + test "without valid credentials", %{conn: conn} do + note_activity = insert(:note_activity) + conn = post(conn, "/api/statuses/retweet/#{note_activity.id}.json") + assert json_response(conn, 403) == %{"error" => "Invalid credentials."} + end + + test "with credentials", %{conn: conn, user: current_user} do + note_activity = insert(:note_activity) + + request_path = "/api/statuses/retweet/#{note_activity.id}.json" + + _response = + conn + |> with_credentials(current_user.nickname, "test") + |> post(request_path) + + request_path = String.replace(request_path, "retweet", "unretweet") + + response = + conn + |> with_credentials(current_user.nickname, "test") + |> post(request_path) + + activity = Repo.get(Activity, note_activity.id) + activity_user = Repo.get_by(User, ap_id: note_activity.data["actor"]) + + assert json_response(response, 200) == + ActivityRepresenter.to_map(activity, %{user: activity_user, for: current_user}) + end + end + describe "POST /api/account/register" do test "it creates a new user", %{conn: conn} do data = %{ diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index edacb312d..06c1ba6ec 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -228,6 +228,17 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do assert status == updated_activity end + test "it unretweets an already retweeted status" do + user = insert(:user) + note_activity = insert(:note_activity) + + {:ok, _status} = TwitterAPI.repeat(user, note_activity.id) + {:ok, status} = TwitterAPI.unrepeat(user, note_activity.id) + updated_activity = Activity.get_by_ap_id(note_activity.data["id"]) + + assert status == updated_activity + end + test "it registers a new user and returns the user." do data = %{ "nickname" => "lain", -- cgit v1.2.3 From fc15f30a3c53860af35eb39c6893428df966fb96 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Wed, 13 Jun 2018 21:45:27 -0400 Subject: fixup test --- test/web/twitter_api/twitter_api_controller_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index 6866a362f..197e35d13 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -585,7 +585,7 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do test "without valid credentials", %{conn: conn} do note_activity = insert(:note_activity) - conn = post(conn, "/api/statuses/retweet/#{note_activity.id}.json") + conn = post(conn, "/api/statuses/unretweet/#{note_activity.id}.json") assert json_response(conn, 403) == %{"error" => "Invalid credentials."} end -- cgit v1.2.3 From 0a95b5594b654dbec73a9e50e340f4975aa3e8e5 Mon Sep 17 00:00:00 2001 From: Francis Dinh Date: Thu, 14 Jun 2018 12:12:38 -0400 Subject: Add missing file extension if file does not have one --- test/upload_test.exs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test') diff --git a/test/upload_test.exs b/test/upload_test.exs index 645f10293..09aa5e068 100644 --- a/test/upload_test.exs +++ b/test/upload_test.exs @@ -43,5 +43,18 @@ defmodule Pleroma.UploadTest do data = Upload.store(file, true) assert hd(data["url"])["mediaType"] == "image/jpeg" end + + test "adds missing extension" do + File.cp!("test/fixtures/image.jpg", "test/fixtures/image_tmp.jpg") + + file = %Plug.Upload{ + content_type: "image/jpg", + path: Path.absname("test/fixtures/image_tmp.jpg"), + filename: "an [image" + } + + data = Upload.store(file, false) + assert data["name"] == "an [image.jpg" + end end end -- cgit v1.2.3 From 72c2915ecd0b6578d72b3c9796f4adc8cce83d86 Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 15 Jun 2018 21:37:29 +0200 Subject: Pleroma.Web.MastodonAPI.StatusView: Fix status.json so it renders threads --- test/web/mastodon_api/status_view_test.exs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/web/mastodon_api/status_view_test.exs b/test/web/mastodon_api/status_view_test.exs index d9a0a8a95..d28c3cbad 100644 --- a/test/web/mastodon_api/status_view_test.exs +++ b/test/web/mastodon_api/status_view_test.exs @@ -64,11 +64,11 @@ defmodule Pleroma.Web.MastodonAPI.StatusViewTest do status = StatusView.render("status.json", %{activity: activity}) - assert status.in_reply_to_id == note.id + assert status.in_reply_to_id == to_string(note.id) [status] = StatusView.render("index.json", %{activities: [activity], as: :activity}) - assert status.in_reply_to_id == note.id + assert status.in_reply_to_id == to_string(note.id) end test "contains mentions" do -- cgit v1.2.3