pleroma/test/support/helpers.ex
Maksim Pechnikov 89b3729afa fix warnings
2018-12-12 09:09:19 +03:00

26 lines
606 B
Elixir

defmodule Pleroma.Tests.Helpers do
@moduledoc """
Helpers for use in tests.
"""
defmacro __using__(_opts) do
quote do
def refresh_record(%{id: id, __struct__: model} = _),
do: refresh_record(model, %{id: id})
def refresh_record(model, %{id: id} = _) do
Pleroma.Repo.get_by(model, id: id)
end
# Used for comparing json rendering during tests.
def render_json(view, template, assigns) do
assigns = Map.new(assigns)
view.render(template, assigns)
|> Poison.encode!()
|> Poison.decode!()
end
end
end
end