fix warnings
This commit is contained in:
parent
2999a08e35
commit
89b3729afa
32 changed files with 203 additions and 183 deletions
|
|
@ -19,6 +19,7 @@ defmodule Pleroma.Web.ConnCase do
|
|||
quote do
|
||||
# Import conveniences for testing with connections
|
||||
use Phoenix.ConnTest
|
||||
use Pleroma.Tests.Helpers
|
||||
import Pleroma.Web.Router.Helpers
|
||||
|
||||
# The default endpoint for testing
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ defmodule Pleroma.DataCase do
|
|||
import Ecto.Changeset
|
||||
import Ecto.Query
|
||||
import Pleroma.DataCase
|
||||
use Pleroma.Tests.Helpers
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
25
test/support/helpers.ex
Normal file
25
test/support/helpers.ex
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue