logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://anongit.hacktivis.me/git/pleroma.git/

autolinker_to_linkify_test.exs (2302B)


  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Repo.Migrations.AutolinkerToLinkifyTest do
  5. use Pleroma.DataCase, async: true
  6. import Pleroma.Factory
  7. import Pleroma.Tests.Helpers
  8. alias Pleroma.ConfigDB
  9. setup_all do: require_migration("20200716195806_autolinker_to_linkify")
  10. test "change/0 converts auto_linker opts for Pleroma.Formatter", %{migration: migration} do
  11. autolinker_opts = [
  12. extra: true,
  13. validate_tld: true,
  14. class: false,
  15. strip_prefix: false,
  16. new_window: false,
  17. rel: "testing"
  18. ]
  19. insert(:config, group: :auto_linker, key: :opts, value: autolinker_opts)
  20. migration.change()
  21. assert nil == ConfigDB.get_by_params(%{group: :auto_linker, key: :opts})
  22. %{value: new_opts} = ConfigDB.get_by_params(%{group: :pleroma, key: Pleroma.Formatter})
  23. assert Keyword.equal?(new_opts,
  24. class: false,
  25. extra: true,
  26. new_window: false,
  27. rel: "testing",
  28. strip_prefix: false
  29. )
  30. clear_config(Pleroma.Formatter, new_opts)
  31. assert new_opts == Pleroma.Config.get(Pleroma.Formatter)
  32. {text, _mentions, []} =
  33. Pleroma.Formatter.linkify(
  34. "https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7\n\nOmg will COVID finally end Black Friday???"
  35. )
  36. assert text ==
  37. "<a href=\"https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7\" rel=\"testing\">https://www.businessinsider.com/walmart-will-close-stores-on-thanksgiving-ending-black-friday-tradition-2020-7</a>\n\nOmg will COVID finally end Black Friday???"
  38. end
  39. test "transform_opts/1 returns a list of compatible opts", %{migration: migration} do
  40. old_opts = [
  41. extra: true,
  42. validate_tld: true,
  43. class: false,
  44. strip_prefix: false,
  45. new_window: false,
  46. rel: "qqq"
  47. ]
  48. expected_opts = [
  49. class: false,
  50. extra: true,
  51. new_window: false,
  52. rel: "qqq",
  53. strip_prefix: false
  54. ]
  55. assert Keyword.equal?(migration.transform_opts(old_opts), expected_opts)
  56. end
  57. end