diff options
Diffstat (limited to 'test/web/twitter_api')
4 files changed, 34 insertions, 13 deletions
| diff --git a/test/web/twitter_api/representers/activity_representer_test.exs b/test/web/twitter_api/representers/activity_representer_test.exs index 385bf8e84..98a1705b0 100644 --- a/test/web/twitter_api/representers/activity_representer_test.exs +++ b/test/web/twitter_api/representers/activity_representer_test.exs @@ -75,17 +75,17 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do      date = DateTime.from_naive!(~N[2016-05-24 13:26:08.003], "Etc/UTC") |> DateTime.to_iso8601      {:ok, convo_object} = Object.context_mapping("2hu") |> Repo.insert - +    to = [ +      User.ap_followers(user), +      "https://www.w3.org/ns/activitystreams#Public", +      mentioned_user.ap_id +    ]      activity = %Activity{        id: 1,        data: %{          "type" => "Create",          "id" => "id", -        "to" => [ -          User.ap_followers(user), -          "https://www.w3.org/ns/activitystreams#Public", -          mentioned_user.ap_id -        ], +        "to" => to,          "actor" => User.ap_id(user),          "object" => %{            "published" => date, @@ -108,7 +108,8 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do          "published" => date,          "context" => "2hu"        }, -      local: false +      local: false, +      recipients: to      }      expected_html = "<span>2hu</span><br />alert('YAY')Some <img height='32px' width='32px' alt='2hu' title='2hu' src='corndog.png' /> content mentioning <a href=\"#{mentioned_user.ap_id}\">@shp</a>" @@ -134,7 +135,7 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ActivityRepresenterTest do        "favorited" => false,        "repeated" => false,        "external_url" => "some url", -      "tags" => ["content", "mentioning", "nsfw"], +      "tags" => ["nsfw", "content", "mentioning"],        "activity_type" => "post",        "possibly_sensitive" => true,        "uri" => activity.data["object"]["id"] diff --git a/test/web/twitter_api/representers/object_representer_test.exs b/test/web/twitter_api/representers/object_representer_test.exs index 791b30237..ac8184407 100644 --- a/test/web/twitter_api/representers/object_representer_test.exs +++ b/test/web/twitter_api/representers/object_representer_test.exs @@ -28,4 +28,24 @@ defmodule Pleroma.Web.TwitterAPI.Representers.ObjectReprenterTest do      assert expected_object == ObjectRepresenter.to_map(object)    end + +  test "represents mastodon-style attachments" do +    object = %Object{ +      id: nil, +      data: %{ +        "mediaType" => "image/png", +        "name" => "blabla", "type" => "Document", +        "url" => "http://mastodon.example.org/system/media_attachments/files/000/000/001/original/8619f31c6edec470.png" +      } +    } + +    expected_object = %{ +      url: "http://mastodon.example.org/system/media_attachments/files/000/000/001/original/8619f31c6edec470.png", +      mimetype: "image/png", +      oembed: false, +      id: nil +    } + +    assert expected_object == ObjectRepresenter.to_map(object) +  end  end diff --git a/test/web/twitter_api/twitter_api_controller_test.exs b/test/web/twitter_api/twitter_api_controller_test.exs index f02e2c59e..d3040f0dc 100644 --- a/test/web/twitter_api/twitter_api_controller_test.exs +++ b/test/web/twitter_api/twitter_api_controller_test.exs @@ -376,9 +376,10 @@ defmodule Pleroma.Web.TwitterAPI.ControllerTest do      end      test "with credentials", %{conn: conn, user: current_user} do +      avatar_image = File.read!("test/fixtures/avatar_data_uri")        conn = conn        |> with_credentials(current_user.nickname, "test") -      |> post("/api/qvitter/update_avatar.json", %{img: Pleroma.Web.ActivityPub.ActivityPubTest.data_uri}) +      |> post("/api/qvitter/update_avatar.json", %{img: avatar_image})        current_user = Repo.get(User, current_user.id)        assert is_map(current_user.avatar) diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index 4aec99575..6b0b182a3 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -38,9 +38,9 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do      assert get_in(activity.data, ["object", "type"]) == "Note"      assert get_in(activity.data, ["object", "actor"]) == user.ap_id      assert get_in(activity.data, ["actor"]) == user.ap_id -    assert Enum.member?(get_in(activity.data, ["to"]), User.ap_followers(user)) +    assert Enum.member?(get_in(activity.data, ["cc"]), User.ap_followers(user))      assert Enum.member?(get_in(activity.data, ["to"]), "https://www.w3.org/ns/activitystreams#Public") -    assert Enum.member?(get_in(activity.data, ["to"]), "shp") +    assert Enum.member?(get_in(activity.data, ["cc"]), "shp")      assert activity.local == true      assert %{"moominmamma" => "http://localhost:4001/finmoji/128px/moominmamma-128.png"} = activity.data["object"]["emoji"] @@ -80,7 +80,6 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do      assert get_in(reply.data, ["object", "context"]) == get_in(activity.data, ["object", "context"])      assert get_in(reply.data, ["object", "inReplyTo"]) == get_in(activity.data, ["object", "id"])      assert get_in(reply.data, ["object", "inReplyToStatusId"]) == activity.id -    assert Enum.member?(get_in(reply.data, ["to"]), user.ap_id)    end    test "fetch public statuses, excluding remote ones." do @@ -99,7 +98,7 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do      %{ public: activity, user: user } = ActivityBuilder.public_and_non_public      insert(:note_activity, %{local: false}) -    follower = insert(:user, following: [User.ap_followers(user)]) +    follower = insert(:user, following: [user.follower_address])      statuses = TwitterAPI.fetch_public_and_external_statuses(follower) | 
