Add anonymous and remote participations
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
defmodule Mobilizon.Service.Geospatial.AddokTest do
|
||||
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
|
||||
|
||||
use Mobilizon.DataCase, async: false
|
||||
use Mobilizon.DataCase
|
||||
|
||||
import Mock
|
||||
|
||||
@@ -9,28 +9,31 @@ defmodule Mobilizon.Service.Geospatial.AddokTest do
|
||||
alias Mobilizon.Config
|
||||
alias Mobilizon.Service.Geospatial.Addok
|
||||
|
||||
@httpoison_headers [
|
||||
{"User-Agent",
|
||||
"#{Config.instance_name()} #{Config.instance_hostname()} - Mobilizon #{
|
||||
Mix.Project.config()[:version]
|
||||
}"}
|
||||
]
|
||||
setup do
|
||||
# Config.instance_user_agent/0 makes database calls so because of ownership connection
|
||||
# we need to define it like this instead of a constant
|
||||
# See https://hexdocs.pm/ecto_sql/Ecto.Adapters.SQL.Sandbox.html
|
||||
{:ok,
|
||||
httpoison_headers: [
|
||||
{"User-Agent", Config.instance_user_agent()}
|
||||
]}
|
||||
end
|
||||
|
||||
@endpoint get_in(Application.get_env(:mobilizon, Addok), [:endpoint])
|
||||
@fake_endpoint "https://domain.tld"
|
||||
|
||||
describe "search address" do
|
||||
test "produces a valid search address" do
|
||||
test "produces a valid search address", %{httpoison_headers: httpoison_headers} do
|
||||
with_mock HTTPoison, get: fn _url, _headers -> "{}" end do
|
||||
Addok.search("10 Rue Jangot")
|
||||
|
||||
assert_called(
|
||||
HTTPoison.get("#{@endpoint}/search/?q=10%20Rue%20Jangot&limit=10", @httpoison_headers)
|
||||
HTTPoison.get("#{@endpoint}/search/?q=10%20Rue%20Jangot&limit=10", httpoison_headers)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
test "produces a valid search address with options" do
|
||||
test "produces a valid search address with options", %{httpoison_headers: httpoison_headers} do
|
||||
with_mock HTTPoison, get: fn _url, _headers -> "{}" end do
|
||||
Addok.search("10 Rue Jangot",
|
||||
endpoint: @fake_endpoint,
|
||||
@@ -41,7 +44,7 @@ defmodule Mobilizon.Service.Geospatial.AddokTest do
|
||||
assert_called(
|
||||
HTTPoison.get(
|
||||
"#{@fake_endpoint}/search/?q=10%20Rue%20Jangot&limit=5&lat=49&lon=12",
|
||||
@httpoison_headers
|
||||
httpoison_headers
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user