logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma

metadata_test.exs (1643B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Web.MetadataTest do
  5. use Pleroma.DataCase, async: true
  6. import Pleroma.Factory
  7. describe "restrict indexing remote users" do
  8. test "for remote user" do
  9. user = insert(:user, local: false)
  10. assert Pleroma.Web.Metadata.build_tags(%{user: user}) =~
  11. "<meta content=\"noindex, noarchive\" name=\"robots\">"
  12. end
  13. test "for local user" do
  14. user = insert(:user, discoverable: false)
  15. assert Pleroma.Web.Metadata.build_tags(%{user: user}) =~
  16. "<meta content=\"noindex, noarchive\" name=\"robots\">"
  17. end
  18. test "for local user set to discoverable" do
  19. user = insert(:user, discoverable: true)
  20. refute Pleroma.Web.Metadata.build_tags(%{user: user}) =~
  21. "<meta content=\"noindex, noarchive\" name=\"robots\">"
  22. end
  23. end
  24. describe "no metadata for private instances" do
  25. test "for local user set to discoverable" do
  26. clear_config([:instance, :public], false)
  27. user = insert(:user, bio: "This is my secret fedi account bio", discoverable: true)
  28. assert "" = Pleroma.Web.Metadata.build_tags(%{user: user})
  29. end
  30. test "search exclusion metadata is included" do
  31. clear_config([:instance, :public], false)
  32. user = insert(:user, bio: "This is my secret fedi account bio", discoverable: false)
  33. assert ~s(<meta content="noindex, noarchive" name="robots">) ==
  34. Pleroma.Web.Metadata.build_tags(%{user: user})
  35. end
  36. end
  37. end