Merge branch 'develop' into issue/1342
This commit is contained in:
commit
95e6a2acd9
55 changed files with 1159 additions and 417 deletions
|
|
@ -23,6 +23,7 @@ defmodule Pleroma.Web.ChannelCase do
|
|||
quote do
|
||||
# Import conveniences for testing with channels
|
||||
use Phoenix.ChannelTest
|
||||
use Pleroma.Tests.Helpers
|
||||
|
||||
# The default endpoint for testing
|
||||
@endpoint Pleroma.Web.Endpoint
|
||||
|
|
|
|||
|
|
@ -43,6 +43,18 @@ defmodule Pleroma.Factory do
|
|||
}
|
||||
end
|
||||
|
||||
def user_relationship_factory(attrs \\ %{}) do
|
||||
source = attrs[:source] || insert(:user)
|
||||
target = attrs[:target] || insert(:user)
|
||||
relationship_type = attrs[:relationship_type] || :block
|
||||
|
||||
%Pleroma.UserRelationship{
|
||||
source_id: source.id,
|
||||
target_id: target.id,
|
||||
relationship_type: relationship_type
|
||||
}
|
||||
end
|
||||
|
||||
def note_factory(attrs \\ %{}) do
|
||||
text = sequence(:text, &"This is :moominmamma: note #{&1}")
|
||||
|
||||
|
|
|
|||
|
|
@ -75,6 +75,23 @@ defmodule Pleroma.Tests.Helpers do
|
|||
|> Poison.decode!()
|
||||
end
|
||||
|
||||
def stringify_keys(nil), do: nil
|
||||
|
||||
def stringify_keys(key) when key in [true, false], do: key
|
||||
def stringify_keys(key) when is_atom(key), do: Atom.to_string(key)
|
||||
|
||||
def stringify_keys(map) when is_map(map) do
|
||||
map
|
||||
|> Enum.map(fn {k, v} -> {stringify_keys(k), stringify_keys(v)} end)
|
||||
|> Enum.into(%{})
|
||||
end
|
||||
|
||||
def stringify_keys([head | rest] = list) when is_list(list) do
|
||||
[stringify_keys(head) | stringify_keys(rest)]
|
||||
end
|
||||
|
||||
def stringify_keys(key), do: key
|
||||
|
||||
defmacro guards_config(config_path) do
|
||||
quote do
|
||||
initial_setting = Pleroma.Config.get(config_path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue