|> 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)
NaiveDateTime.from_iso8601!(act.data["published"])
end).data["published"]
- assert first_group["status"] == StatusView.render("show.json", %{activity: first_status})
+ assert first_group["status"] ==
+ stringify_keys(StatusView.render("show.json", %{activity: first_status}))
- assert first_group["account"]["id"] == target_user.id
+ assert(first_group["account"]["id"] == target_user.id)
assert length(first_group["actors"]) == 1
assert hd(first_group["actors"])["id"] == reporter.id
NaiveDateTime.from_iso8601!(act.data["published"])
end).data["published"]
- assert second_group["status"] == %{
- "id" => second_status.data["id"],
- "content" => second_status.object.data["content"],
- "published" => second_status.object.data["published"]
- }
+ assert second_group["status"] ==
+ stringify_keys(StatusView.render("show.json", %{activity: second_status}))
assert second_group["account"]["id"] == target_user.id
NaiveDateTime.from_iso8601!(act.data["published"])
end).data["published"]
- assert third_group["status"] == %{
- "id" => third_status.data["id"],
- "content" => third_status.object.data["content"],
- "published" => third_status.object.data["published"]
- }
+ assert third_group["status"] ==
+ stringify_keys(StatusView.render("show.json", %{activity: third_status}))
assert third_group["account"]["id"] == target_user.id