2020-01-26 19:34:25 +00:00
|
|
|
defmodule Mobilizon.GraphQL.Resolvers.ConfigTest do
|
2020-01-26 20:36:50 +00:00
|
|
|
use Mobilizon.Web.ConnCase
|
2019-12-20 12:04:34 +00:00
|
|
|
alias Mobilizon.Actors
|
|
|
|
alias Mobilizon.Actors.Actor
|
2019-03-22 09:53:38 +00:00
|
|
|
|
2020-01-26 19:34:25 +00:00
|
|
|
alias Mobilizon.GraphQL.AbsintheHelpers
|
|
|
|
|
2019-03-22 09:53:38 +00:00
|
|
|
describe "Resolver: Get config" do
|
|
|
|
test "get_config/3 returns the instance config", context do
|
2019-12-20 12:04:34 +00:00
|
|
|
Cachex.clear("full_config")
|
|
|
|
Mobilizon.Config.clear_config_cache()
|
|
|
|
|
2019-03-22 09:53:38 +00:00
|
|
|
query = """
|
|
|
|
{
|
|
|
|
config {
|
|
|
|
name,
|
|
|
|
registrationsOpen
|
2019-12-20 12:04:34 +00:00
|
|
|
anonymous {
|
|
|
|
participation {
|
|
|
|
allowed,
|
|
|
|
validation {
|
|
|
|
email {
|
|
|
|
enabled,
|
|
|
|
confirmationRequired
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
actor_id
|
|
|
|
}
|
2019-03-22 09:53:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
|
|
|
res =
|
|
|
|
context.conn
|
2019-12-20 12:04:34 +00:00
|
|
|
|> AbsintheHelpers.graphql_query(query: query)
|
|
|
|
|
|
|
|
assert res["data"]["config"]["name"] == "Test instance"
|
|
|
|
assert res["data"]["config"]["registrationsOpen"] == true
|
|
|
|
|
|
|
|
assert res["data"]["config"]["anonymous"]["participation"]["validation"]["email"]["enabled"] ==
|
|
|
|
true
|
|
|
|
|
|
|
|
assert res["data"]["config"]["anonymous"]["participation"]["validation"]["email"][
|
|
|
|
"confirmationRequired"
|
|
|
|
] == true
|
2019-03-22 09:53:38 +00:00
|
|
|
|
2019-12-20 12:04:34 +00:00
|
|
|
{:ok, %Actor{id: actor_id}} = Actors.get_or_create_internal_actor("anonymous")
|
|
|
|
assert res["data"]["config"]["anonymous"]["actor_id"] == to_string(actor_id)
|
2019-03-22 09:53:38 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|