diff options
| author | lain <lain@soykaf.club> | 2019-03-25 13:37:32 +0100 | 
|---|---|---|
| committer | lain <lain@soykaf.club> | 2019-03-25 13:37:32 +0100 | 
| commit | 037fefe21871ee0a1926286c87c334ea1d339394 (patch) | |
| tree | 2775b91de5652ddd5baa3e32861ac9cac4bc40be /test/web/twitter_api | |
| parent | f6fab01ba7a08fe0e5147f82d9e3dd294922dc93 (diff) | |
| parent | b028b0f97d4b6310b1402b3b876aa8f8b286bc4d (diff) | |
| download | pleroma-037fefe21871ee0a1926286c87c334ea1d339394.tar.gz pleroma-037fefe21871ee0a1926286c87c334ea1d339394.zip | |
Merge remote-tracking branch 'origin/develop' into features/mastoapi/2.6.0-conversations
Diffstat (limited to 'test/web/twitter_api')
| -rw-r--r-- | test/web/twitter_api/twitter_api_test.exs | 16 | ||||
| -rw-r--r-- | test/web/twitter_api/util_controller_test.exs | 23 | ||||
| -rw-r--r-- | test/web/twitter_api/views/activity_view_test.exs | 15 | 
3 files changed, 30 insertions, 24 deletions
| diff --git a/test/web/twitter_api/twitter_api_test.exs b/test/web/twitter_api/twitter_api_test.exs index c8dd3fd7a..b823bfd68 100644 --- a/test/web/twitter_api/twitter_api_test.exs +++ b/test/web/twitter_api/twitter_api_test.exs @@ -445,22 +445,6 @@ defmodule Pleroma.Web.TwitterAPI.TwitterAPITest do      :ok    end -  describe "context_to_conversation_id" do -    test "creates a mapping object" do -      conversation_id = TwitterAPI.context_to_conversation_id("random context") -      object = Object.get_by_ap_id("random context") - -      assert conversation_id == object.id -    end - -    test "returns an existing mapping for an existing object" do -      {:ok, object} = Object.context_mapping("random context") |> Repo.insert() -      conversation_id = TwitterAPI.context_to_conversation_id("random context") - -      assert conversation_id == object.id -    end -  end -    describe "fetching a user by uri" do      test "fetches a user by uri" do        id = "https://mastodon.social/users/lambadalambda" diff --git a/test/web/twitter_api/util_controller_test.exs b/test/web/twitter_api/util_controller_test.exs index 6e8a25056..832fdc096 100644 --- a/test/web/twitter_api/util_controller_test.exs +++ b/test/web/twitter_api/util_controller_test.exs @@ -75,6 +75,29 @@ defmodule Pleroma.Web.TwitterAPI.UtilControllerTest do    end    describe "GET /api/statusnet/config.json" do +    test "returns the state of safe_dm_mentions flag", %{conn: conn} do +      option = Pleroma.Config.get([:instance, :safe_dm_mentions]) +      Pleroma.Config.put([:instance, :safe_dm_mentions], true) + +      response = +        conn +        |> get("/api/statusnet/config.json") +        |> json_response(:ok) + +      assert response["site"]["safeDMMentionsEnabled"] == "1" + +      Pleroma.Config.put([:instance, :safe_dm_mentions], false) + +      response = +        conn +        |> get("/api/statusnet/config.json") +        |> json_response(:ok) + +      assert response["site"]["safeDMMentionsEnabled"] == "0" + +      Pleroma.Config.put([:instance, :safe_dm_mentions], option) +    end +      test "it returns the managed config", %{conn: conn} do        Pleroma.Config.put([:instance, :managed_config], false)        Pleroma.Config.put([:fe], theme: "rei-ayanami-towel") diff --git a/test/web/twitter_api/views/activity_view_test.exs b/test/web/twitter_api/views/activity_view_test.exs index 6f0786b1c..a1776b3e6 100644 --- a/test/web/twitter_api/views/activity_view_test.exs +++ b/test/web/twitter_api/views/activity_view_test.exs @@ -12,7 +12,6 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do    alias Pleroma.Web.CommonAPI    alias Pleroma.Web.CommonAPI.Utils    alias Pleroma.Web.TwitterAPI.ActivityView -  alias Pleroma.Web.TwitterAPI.TwitterAPI    alias Pleroma.Web.TwitterAPI.UserView    import Pleroma.Factory @@ -82,7 +81,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do      result = ActivityView.render("activity.json", activity: activity)      assert result["statusnet_html"] == -             "<a class=\"hashtag\" data-tag=\"bike\" href=\"http://localhost:4001/tag/bike\">#Bike</a> log - Commute Tuesday<br /><a href=\"https://pla.bike/posts/20181211/\">https://pla.bike/posts/20181211/</a><br /><a class=\"hashtag\" data-tag=\"cycling\" href=\"http://localhost:4001/tag/cycling\">#cycling</a> <a class=\"hashtag\" data-tag=\"chscycling\" href=\"http://localhost:4001/tag/chscycling\">#CHScycling</a> <a class=\"hashtag\" data-tag=\"commute\" href=\"http://localhost:4001/tag/commute\">#commute</a><br />MVIMG_20181211_054020.jpg" +             "<a class=\"hashtag\" data-tag=\"bike\" href=\"http://localhost:4001/tag/bike\" rel=\"tag\">#Bike</a> log - Commute Tuesday<br /><a href=\"https://pla.bike/posts/20181211/\">https://pla.bike/posts/20181211/</a><br /><a class=\"hashtag\" data-tag=\"cycling\" href=\"http://localhost:4001/tag/cycling\" rel=\"tag\">#cycling</a> <a class=\"hashtag\" data-tag=\"chscycling\" href=\"http://localhost:4001/tag/chscycling\" rel=\"tag\">#CHScycling</a> <a class=\"hashtag\" data-tag=\"commute\" href=\"http://localhost:4001/tag/commute\" rel=\"tag\">#commute</a><br />MVIMG_20181211_054020.jpg"      assert result["text"] ==               "#Bike log - Commute Tuesday\nhttps://pla.bike/posts/20181211/\n#cycling #CHScycling #commute\nMVIMG_20181211_054020.jpg" @@ -129,7 +128,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do      result = ActivityView.render("activity.json", activity: activity) -    convo_id = TwitterAPI.context_to_conversation_id(activity.data["object"]["context"]) +    convo_id = Utils.context_to_conversation_id(activity.data["object"]["context"])      expected = %{        "activity_type" => "post", @@ -177,12 +176,12 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do      other_user = insert(:user, %{nickname: "shp"})      {:ok, activity} = CommonAPI.post(user, %{"status" => "Hey @shp!"}) -    convo_id = TwitterAPI.context_to_conversation_id(activity.data["object"]["context"]) +    convo_id = Utils.context_to_conversation_id(activity.data["object"]["context"])      mocks = [        { -        TwitterAPI, -        [], +        Utils, +        [:passthrough],          [context_to_conversation_id: fn _ -> false end]        },        { @@ -197,7 +196,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do        assert result["statusnet_conversation_id"] == convo_id        assert result["user"] -      refute called(TwitterAPI.context_to_conversation_id(:_)) +      refute called(Utils.context_to_conversation_id(:_))        refute called(User.get_cached_by_ap_id(user.ap_id))        refute called(User.get_cached_by_ap_id(other_user.ap_id))      end @@ -280,7 +279,7 @@ defmodule Pleroma.Web.TwitterAPI.ActivityViewTest do      {: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"]) +    convo_id = Utils.context_to_conversation_id(activity.data["object"]["context"])      activity = Repo.get(Activity, activity.id) | 
