Fork of Pleroma with site-specific changes and feature branches https://git.pleroma.social/pleroma/pleroma
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
765B

  1. # Pleroma: A lightweight social networking server
  2. # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
  3. # SPDX-License-Identifier: AGPL-3.0-only
  4. defmodule Pleroma.Tests.Helpers do
  5. @moduledoc """
  6. Helpers for use in tests.
  7. """
  8. defmacro __using__(_opts) do
  9. quote do
  10. def refresh_record(%{id: id, __struct__: model} = _),
  11. do: refresh_record(model, %{id: id})
  12. def refresh_record(model, %{id: id} = _) do
  13. Pleroma.Repo.get_by(model, id: id)
  14. end
  15. # Used for comparing json rendering during tests.
  16. def render_json(view, template, assigns) do
  17. assigns = Map.new(assigns)
  18. view.render(template, assigns)
  19. |> Poison.encode!()
  20. |> Poison.decode!()
  21. end
  22. end
  23. end
  24. end