2020-01-26 20:34:25 +01:00
|
|
|
defmodule Mobilizon.GraphQL.Resolvers.ConfigTest do
|
2020-01-26 21:36:50 +01:00
|
|
|
use Mobilizon.Web.ConnCase
|
2019-12-20 13:04:34 +01:00
|
|
|
alias Mobilizon.Actors
|
|
|
|
alias Mobilizon.Actors.Actor
|
2019-03-22 10:53:38 +01:00
|
|
|
|
2020-01-26 20:34:25 +01:00
|
|
|
alias Mobilizon.GraphQL.AbsintheHelpers
|
|
|
|
|
2019-03-22 10:53:38 +01:00
|
|
|
describe "Resolver: Get config" do
|
|
|
|
test "get_config/3 returns the instance config", context do
|
2019-12-20 13:04:34 +01:00
|
|
|
Cachex.clear("full_config")
|
|
|
|
Mobilizon.Config.clear_config_cache()
|
|
|
|
|
2019-03-22 10:53:38 +01:00
|
|
|
query = """
|
|
|
|
{
|
|
|
|
config {
|
|
|
|
name,
|
|
|
|
registrationsOpen
|
2019-12-20 13:04:34 +01:00
|
|
|
anonymous {
|
|
|
|
participation {
|
|
|
|
allowed,
|
|
|
|
validation {
|
|
|
|
email {
|
|
|
|
enabled,
|
|
|
|
confirmationRequired
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
actor_id
|
|
|
|
}
|
2019-03-22 10:53:38 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|
|
|
|
res =
|
|
|
|
context.conn
|
2019-12-20 13:04:34 +01: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 10:53:38 +01:00
|
|
|
|
2019-12-20 13:04:34 +01: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 10:53:38 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|