Work around Addresses to bring them properly through GraphQL
Got caught with https://github.com/absinthe-graphql/absinthe/issues/601 at some point, that's why fields are renamed Fix tests Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
d338b853b4
commit
9a881ed4d9
@ -29,6 +29,16 @@ export const FETCH_EVENT = gql`
|
|||||||
category,
|
category,
|
||||||
# online_address,
|
# online_address,
|
||||||
# phone_address,
|
# phone_address,
|
||||||
|
physicalAddress {
|
||||||
|
description,
|
||||||
|
floor,
|
||||||
|
street,
|
||||||
|
locality,
|
||||||
|
postal_code,
|
||||||
|
region,
|
||||||
|
country,
|
||||||
|
geom
|
||||||
|
}
|
||||||
organizerActor {
|
organizerActor {
|
||||||
avatarUrl,
|
avatarUrl,
|
||||||
preferredUsername,
|
preferredUsername,
|
||||||
@ -64,6 +74,9 @@ export const FETCH_EVENTS = gql`
|
|||||||
publishAt,
|
publishAt,
|
||||||
# online_address,
|
# online_address,
|
||||||
# phone_address,
|
# phone_address,
|
||||||
|
physicalAddress {
|
||||||
|
description
|
||||||
|
}
|
||||||
organizerActor {
|
organizerActor {
|
||||||
avatarUrl,
|
avatarUrl,
|
||||||
preferredUsername,
|
preferredUsername,
|
||||||
|
13
js/src/types/address.model.ts
Normal file
13
js/src/types/address.model.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
export interface IAddress {
|
||||||
|
description: string;
|
||||||
|
floor: string;
|
||||||
|
street: string;
|
||||||
|
locality: string;
|
||||||
|
postal_code: string;
|
||||||
|
region: string;
|
||||||
|
country: string;
|
||||||
|
geom: {
|
||||||
|
lat: number;
|
||||||
|
lon: number;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,5 @@
|
|||||||
import { Actor, IActor } from './actor.model';
|
import { Actor, IActor } from './actor.model';
|
||||||
|
import {IAddress} from "@/types/address.model";
|
||||||
|
|
||||||
export enum EventStatus {
|
export enum EventStatus {
|
||||||
TENTATIVE,
|
TENTATIVE,
|
||||||
@ -67,8 +68,9 @@ export interface IEvent {
|
|||||||
attributedTo: IActor;
|
attributedTo: IActor;
|
||||||
participants: IParticipant[];
|
participants: IParticipant[];
|
||||||
|
|
||||||
// online_address: Address;
|
onlineAddress?: string;
|
||||||
// phone_address: string;
|
phoneAddress?: string;
|
||||||
|
physicalAddress?: IAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -90,4 +92,6 @@ export class EventModel implements IEvent {
|
|||||||
visibility: EventVisibility = EventVisibility.PUBLIC;
|
visibility: EventVisibility = EventVisibility.PUBLIC;
|
||||||
attributedTo: IActor = new Actor();
|
attributedTo: IActor = new Actor();
|
||||||
organizerActor: IActor = new Actor();
|
organizerActor: IActor = new Actor();
|
||||||
|
onlineAddress: string = '';
|
||||||
|
phoneAddress: string = '';
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,15 @@
|
|||||||
<div>
|
<div>
|
||||||
<span>{{ event.beginsOn | formatDate }} - {{ event.endsOn | formatDate }}</span>
|
<span>{{ event.beginsOn | formatDate }} - {{ event.endsOn | formatDate }}</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="address" v-if="event.physicalAddress">
|
||||||
|
<h3 class="subtitle">Adresse</h3>
|
||||||
|
<address>
|
||||||
|
<span>{{ event.physicalAddress.description }}</span><br>
|
||||||
|
<span>{{ event.physicalAddress.floor }} {{ event.physicalAddress.street }}</span><br>
|
||||||
|
<span>{{ event.physicalAddress.postal_code }} {{ event.physicalAddress.locality }}</span><br>
|
||||||
|
<span>{{ event.physicalAddress.region }} {{ event.physicalAddress.country }}</span>
|
||||||
|
</address>
|
||||||
|
</div>
|
||||||
<p v-if="actorIsOrganizer()">
|
<p v-if="actorIsOrganizer()">
|
||||||
<translate>You are an organizer.</translate>
|
<translate>You are an organizer.</translate>
|
||||||
</p>
|
</p>
|
||||||
|
@ -76,11 +76,11 @@ export default class CreateGroup extends Vue {
|
|||||||
latitude: addressData.latitude,
|
latitude: addressData.latitude,
|
||||||
longitude: addressData.longitude,
|
longitude: addressData.longitude,
|
||||||
},
|
},
|
||||||
addressCountry: addressData.country,
|
country: addressData.country,
|
||||||
addressLocality: addressData.city,
|
locality: addressData.city,
|
||||||
addressRegion: addressData.administrative_area_level_1,
|
region: addressData.administrative_area_level_1,
|
||||||
postalCode: addressData.postal_code,
|
postal_code: addressData.postal_code,
|
||||||
streetAddress: `${addressData.street_number} ${addressData.route}`,
|
street: `${addressData.street_number} ${addressData.route}`,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,14 +8,14 @@ defmodule Mobilizon.Addresses.Address do
|
|||||||
# alias Mobilizon.Actors.Actor
|
# alias Mobilizon.Actors.Actor
|
||||||
|
|
||||||
schema "addresses" do
|
schema "addresses" do
|
||||||
field(:addressCountry, :string)
|
field(:country, :string)
|
||||||
field(:addressLocality, :string)
|
field(:locality, :string)
|
||||||
field(:addressRegion, :string)
|
field(:region, :string)
|
||||||
field(:description, :string)
|
field(:description, :string)
|
||||||
field(:floor, :string)
|
field(:floor, :string)
|
||||||
field(:geom, Geo.PostGIS.Geometry)
|
field(:geom, Geo.PostGIS.Geometry)
|
||||||
field(:postalCode, :string)
|
field(:postal_code, :string)
|
||||||
field(:streetAddress, :string)
|
field(:street, :string)
|
||||||
has_one(:event, Event, foreign_key: :physical_address_id)
|
has_one(:event, Event, foreign_key: :physical_address_id)
|
||||||
# has_one(:group, Actor)
|
# has_one(:group, Actor)
|
||||||
|
|
||||||
@ -29,11 +29,11 @@ defmodule Mobilizon.Addresses.Address do
|
|||||||
:description,
|
:description,
|
||||||
:floor,
|
:floor,
|
||||||
:geom,
|
:geom,
|
||||||
:addressCountry,
|
:country,
|
||||||
:addressLocality,
|
:locality,
|
||||||
:addressRegion,
|
:region,
|
||||||
:postalCode,
|
:postal_code,
|
||||||
:streetAddress
|
:street
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -11,6 +11,16 @@ defmodule Mobilizon.Addresses do
|
|||||||
|
|
||||||
@geom_types [:point]
|
@geom_types [:point]
|
||||||
|
|
||||||
|
@doc false
|
||||||
|
def data() do
|
||||||
|
Dataloader.Ecto.new(Repo, query: &query/2)
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc false
|
||||||
|
def query(queryable, _params) do
|
||||||
|
queryable
|
||||||
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Returns the list of addresses.
|
Returns the list of addresses.
|
||||||
|
|
||||||
@ -168,7 +178,7 @@ defmodule Mobilizon.Addresses do
|
|||||||
|
|
||||||
query =
|
query =
|
||||||
if country = Keyword.get(options, :country, nil),
|
if country = Keyword.get(options, :country, nil),
|
||||||
do: from(a in query, where: ilike(a.addressCountry, ^"%#{country}%")),
|
do: from(a in query, where: ilike(a.country, ^"%#{country}%")),
|
||||||
else: query
|
else: query
|
||||||
|
|
||||||
Repo.all(query)
|
Repo.all(query)
|
||||||
@ -198,7 +208,7 @@ defmodule Mobilizon.Addresses do
|
|||||||
|
|
||||||
query =
|
query =
|
||||||
if country,
|
if country,
|
||||||
do: from(a in query, where: ilike(a.addressCountry, ^"%#{country}%")),
|
do: from(a in query, where: ilike(a.country, ^"%#{country}%")),
|
||||||
else: query
|
else: query
|
||||||
|
|
||||||
Repo.all(query)
|
Repo.all(query)
|
||||||
|
@ -4,7 +4,7 @@ defmodule MobilizonWeb.Schema do
|
|||||||
"""
|
"""
|
||||||
use Absinthe.Schema
|
use Absinthe.Schema
|
||||||
|
|
||||||
alias Mobilizon.{Actors, Events, Users}
|
alias Mobilizon.{Actors, Events, Users, Addresses}
|
||||||
alias Mobilizon.Actors.{Actor, Follower, Member}
|
alias Mobilizon.Actors.{Actor, Follower, Member}
|
||||||
alias Mobilizon.Events.{Event, Comment, Participant}
|
alias Mobilizon.Events.{Event, Comment, Participant}
|
||||||
|
|
||||||
@ -107,6 +107,7 @@ defmodule MobilizonWeb.Schema do
|
|||||||
|> Dataloader.add_source(Actors, Actors.data())
|
|> Dataloader.add_source(Actors, Actors.data())
|
||||||
|> Dataloader.add_source(Users, Users.data())
|
|> Dataloader.add_source(Users, Users.data())
|
||||||
|> Dataloader.add_source(Events, Events.data())
|
|> Dataloader.add_source(Events, Events.data())
|
||||||
|
|> Dataloader.add_source(Addresses, Addresses.data())
|
||||||
|
|
||||||
Map.put(ctx, :loader, loader)
|
Map.put(ctx, :loader, loader)
|
||||||
end
|
end
|
||||||
|
@ -5,49 +5,37 @@ defmodule MobilizonWeb.Schema.AddressType do
|
|||||||
use Absinthe.Schema.Notation
|
use Absinthe.Schema.Notation
|
||||||
alias MobilizonWeb.Resolvers
|
alias MobilizonWeb.Resolvers
|
||||||
|
|
||||||
object :physical_address do
|
object :address do
|
||||||
field(:type, :address_type)
|
field(:geom, :point, description: "The geocoordinates for the point where this address is")
|
||||||
field(:geom, :point)
|
field(:floor, :string, description: "The floor this event is at")
|
||||||
field(:floor, :string)
|
field(:street, :string, description: "The address's street name (with number)")
|
||||||
field(:streetAddress, :string)
|
field(:locality, :string, description: "The address's locality")
|
||||||
field(:addressLocality, :string)
|
field(:postal_code, :string)
|
||||||
field(:postalCode, :string)
|
field(:region, :string)
|
||||||
field(:addressRegion, :string)
|
field(:country, :string)
|
||||||
field(:addressCountry, :string)
|
|
||||||
field(:description, :string)
|
field(:description, :string)
|
||||||
field(:name, :string)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
object :phone_address do
|
object :phone_address do
|
||||||
field(:type, :address_type)
|
|
||||||
field(:phone, :string)
|
field(:phone, :string)
|
||||||
field(:info, :string)
|
field(:info, :string)
|
||||||
end
|
end
|
||||||
|
|
||||||
object :online_address do
|
object :online_address do
|
||||||
field(:type, :address_type)
|
|
||||||
field(:url, :string)
|
field(:url, :string)
|
||||||
field(:info, :string)
|
field(:info, :string)
|
||||||
end
|
end
|
||||||
|
|
||||||
@desc "The list of types an address can be"
|
|
||||||
enum :address_type do
|
|
||||||
value(:physical, description: "The address is physical, like a postal address")
|
|
||||||
value(:url, description: "The address is on the Web, like an URL")
|
|
||||||
value(:phone, description: "The address is a phone number for a conference")
|
|
||||||
value(:other, description: "The address is something else")
|
|
||||||
end
|
|
||||||
|
|
||||||
object :address_queries do
|
object :address_queries do
|
||||||
@desc "Search for an address"
|
@desc "Search for an address"
|
||||||
field :search_address, type: list_of(:physical_address) do
|
field :search_address, type: list_of(:address) do
|
||||||
arg(:query, non_null(:string))
|
arg(:query, non_null(:string))
|
||||||
|
|
||||||
resolve(&Resolvers.Address.search/3)
|
resolve(&Resolvers.Address.search/3)
|
||||||
end
|
end
|
||||||
|
|
||||||
@desc "Reverse geocode coordinates"
|
@desc "Reverse geocode coordinates"
|
||||||
field :reverse_geocode, type: list_of(:physical_address) do
|
field :reverse_geocode, type: list_of(:address) do
|
||||||
arg(:longitude, non_null(:float))
|
arg(:longitude, non_null(:float))
|
||||||
arg(:latitude, non_null(:float))
|
arg(:latitude, non_null(:float))
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ defmodule MobilizonWeb.Schema.EventType do
|
|||||||
Schema representation for Event
|
Schema representation for Event
|
||||||
"""
|
"""
|
||||||
use Absinthe.Schema.Notation
|
use Absinthe.Schema.Notation
|
||||||
alias Mobilizon.Actors
|
alias Mobilizon.{Actors, Addresses}
|
||||||
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
import Absinthe.Resolution.Helpers, only: [dataloader: 1]
|
||||||
import_types(MobilizonWeb.Schema.AddressType)
|
import_types(MobilizonWeb.Schema.AddressType)
|
||||||
import_types(MobilizonWeb.Schema.Events.ParticipantType)
|
import_types(MobilizonWeb.Schema.Events.ParticipantType)
|
||||||
@ -27,7 +27,12 @@ defmodule MobilizonWeb.Schema.EventType do
|
|||||||
# TODO replace me with banner
|
# TODO replace me with banner
|
||||||
field(:large_image, :string, description: "A large picture for the event")
|
field(:large_image, :string, description: "A large picture for the event")
|
||||||
field(:publish_at, :datetime, description: "When the event was published")
|
field(:publish_at, :datetime, description: "When the event was published")
|
||||||
field(:physical_address, :physical_address, description: "The type of the event's address")
|
|
||||||
|
field(:physical_address, :address,
|
||||||
|
resolve: dataloader(Addresses),
|
||||||
|
description: "The type of the event's address"
|
||||||
|
)
|
||||||
|
|
||||||
field(:online_address, :online_address, description: "Online address of the event")
|
field(:online_address, :online_address, description: "Online address of the event")
|
||||||
field(:phone_address, :phone_address, description: "Phone address for the event")
|
field(:phone_address, :phone_address, description: "Phone address for the event")
|
||||||
|
|
||||||
|
@ -44,11 +44,11 @@ defmodule MobilizonWeb.JsonLD.ObjectView do
|
|||||||
"name" => address.description,
|
"name" => address.description,
|
||||||
"address" => %{
|
"address" => %{
|
||||||
"@type" => "PostalAddress",
|
"@type" => "PostalAddress",
|
||||||
"streetAddress" => address.streetAddress,
|
"streetAddress" => address.street,
|
||||||
"addressLocality" => address.addressLocality,
|
"addressLocality" => address.locality,
|
||||||
"postalCode" => address.postalCode,
|
"postalCode" => address.postal_code,
|
||||||
"addressRegion" => address.addressRegion,
|
"addressRegion" => address.region,
|
||||||
"addressCountry" => address.addressCountry
|
"addressCountry" => address.country
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -63,14 +63,14 @@ defmodule Mobilizon.Service.Geospatial.Addok do
|
|||||||
features
|
features
|
||||||
|> Enum.map(fn %{"geometry" => geometry, "properties" => properties} ->
|
|> Enum.map(fn %{"geometry" => geometry, "properties" => properties} ->
|
||||||
%Address{
|
%Address{
|
||||||
addressCountry: Map.get(properties, "country"),
|
country: Map.get(properties, "country"),
|
||||||
addressLocality: Map.get(properties, "city"),
|
locality: Map.get(properties, "city"),
|
||||||
addressRegion: Map.get(properties, "state"),
|
region: Map.get(properties, "state"),
|
||||||
description: Map.get(properties, "name") || streetAddress(properties),
|
description: Map.get(properties, "name") || streetAddress(properties),
|
||||||
floor: Map.get(properties, "floor"),
|
floor: Map.get(properties, "floor"),
|
||||||
geom: Map.get(geometry, "coordinates") |> Provider.coordinates(),
|
geom: Map.get(geometry, "coordinates") |> Provider.coordinates(),
|
||||||
postalCode: Map.get(properties, "postcode"),
|
postal_code: Map.get(properties, "postcode"),
|
||||||
streetAddress: properties |> streetAddress()
|
street: properties |> streetAddress()
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
@ -96,14 +96,14 @@ defmodule Mobilizon.Service.Geospatial.GoogleMaps do
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
%Address{
|
%Address{
|
||||||
addressCountry: Map.get(components, "country"),
|
country: Map.get(components, "country"),
|
||||||
addressLocality: Map.get(components, "locality"),
|
locality: Map.get(components, "locality"),
|
||||||
addressRegion: Map.get(components, "administrative_area_level_1"),
|
region: Map.get(components, "administrative_area_level_1"),
|
||||||
description: description,
|
description: description,
|
||||||
floor: nil,
|
floor: nil,
|
||||||
geom: [lon, lat] |> Provider.coordinates(),
|
geom: [lon, lat] |> Provider.coordinates(),
|
||||||
postalCode: Map.get(components, "postal_code"),
|
postal_code: Map.get(components, "postal_code"),
|
||||||
streetAddress: street_address(components)
|
street: street_address(components)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -103,14 +103,14 @@ defmodule Mobilizon.Service.Geospatial.MapQuest do
|
|||||||
|
|
||||||
defp produceAddress(address, lat, lng) do
|
defp produceAddress(address, lat, lng) do
|
||||||
%Address{
|
%Address{
|
||||||
addressCountry: Map.get(address, "adminArea1"),
|
country: Map.get(address, "adminArea1"),
|
||||||
addressLocality: Map.get(address, "adminArea5"),
|
locality: Map.get(address, "adminArea5"),
|
||||||
addressRegion: Map.get(address, "adminArea3"),
|
region: Map.get(address, "adminArea3"),
|
||||||
description: Map.get(address, "street"),
|
description: Map.get(address, "street"),
|
||||||
floor: Map.get(address, "floor"),
|
floor: Map.get(address, "floor"),
|
||||||
geom: [lng, lat] |> Provider.coordinates(),
|
geom: [lng, lat] |> Provider.coordinates(),
|
||||||
postalCode: Map.get(address, "postalCode"),
|
postal_code: Map.get(address, "postalCode"),
|
||||||
streetAddress: Map.get(address, "street")
|
street: Map.get(address, "street")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -67,14 +67,14 @@ defmodule Mobilizon.Service.Geospatial.Nominatim do
|
|||||||
@spec process_data(map()) :: Address.t()
|
@spec process_data(map()) :: Address.t()
|
||||||
defp process_data(%{"address" => address} = body) do
|
defp process_data(%{"address" => address} = body) do
|
||||||
%Address{
|
%Address{
|
||||||
addressCountry: Map.get(address, "country"),
|
country: Map.get(address, "country"),
|
||||||
addressLocality: Map.get(address, "city"),
|
locality: Map.get(address, "city"),
|
||||||
addressRegion: Map.get(address, "state"),
|
region: Map.get(address, "state"),
|
||||||
description: Map.get(body, "display_name"),
|
description: Map.get(body, "display_name"),
|
||||||
floor: Map.get(address, "floor"),
|
floor: Map.get(address, "floor"),
|
||||||
geom: [Map.get(body, "lon"), Map.get(body, "lat")] |> Provider.coordinates(),
|
geom: [Map.get(body, "lon"), Map.get(body, "lat")] |> Provider.coordinates(),
|
||||||
postalCode: Map.get(address, "postcode"),
|
postal_code: Map.get(address, "postcode"),
|
||||||
streetAddress: street_address(address)
|
street: street_address(address)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -65,14 +65,14 @@ defmodule Mobilizon.Service.Geospatial.Photon do
|
|||||||
features
|
features
|
||||||
|> Enum.map(fn %{"geometry" => geometry, "properties" => properties} ->
|
|> Enum.map(fn %{"geometry" => geometry, "properties" => properties} ->
|
||||||
%Address{
|
%Address{
|
||||||
addressCountry: Map.get(properties, "country"),
|
country: Map.get(properties, "country"),
|
||||||
addressLocality: Map.get(properties, "city"),
|
locality: Map.get(properties, "city"),
|
||||||
addressRegion: Map.get(properties, "state"),
|
region: Map.get(properties, "state"),
|
||||||
description: Map.get(properties, "name") || streetAddress(properties),
|
description: Map.get(properties, "name") || streetAddress(properties),
|
||||||
floor: Map.get(properties, "floor"),
|
floor: Map.get(properties, "floor"),
|
||||||
geom: Map.get(geometry, "coordinates") |> Provider.coordinates(),
|
geom: Map.get(geometry, "coordinates") |> Provider.coordinates(),
|
||||||
postalCode: Map.get(properties, "postcode"),
|
postal_code: Map.get(properties, "postcode"),
|
||||||
streetAddress: properties |> streetAddress()
|
street: properties |> streetAddress()
|
||||||
}
|
}
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
defmodule Mobilizon.Repo.Migrations.RenameAddressFields do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def change do
|
||||||
|
rename(table(:addresses), :addressCountry, to: :country)
|
||||||
|
rename(table(:addresses), :addressLocality, to: :locality)
|
||||||
|
rename(table(:addresses), :addressRegion, to: :region)
|
||||||
|
rename(table(:addresses), :postalCode, to: :postal_code)
|
||||||
|
rename(table(:addresses), :streetAddress, to: :street)
|
||||||
|
end
|
||||||
|
end
|
@ -7,23 +7,23 @@ defmodule Mobilizon.AddressesTest do
|
|||||||
alias Mobilizon.Addresses.Address
|
alias Mobilizon.Addresses.Address
|
||||||
|
|
||||||
@valid_attrs %{
|
@valid_attrs %{
|
||||||
addressCountry: "some addressCountry",
|
country: "some addressCountry",
|
||||||
addressLocality: "some addressLocality",
|
locality: "some addressLocality",
|
||||||
addressRegion: "some addressRegion",
|
region: "some addressRegion",
|
||||||
description: "some description",
|
description: "some description",
|
||||||
floor: "some floor",
|
floor: "some floor",
|
||||||
postalCode: "some postalCode",
|
postal_code: "some postalCode",
|
||||||
streetAddress: "some streetAddress",
|
street: "some streetAddress",
|
||||||
geom: %Geo.Point{coordinates: {10, -10}, srid: 4326}
|
geom: %Geo.Point{coordinates: {10, -10}, srid: 4326}
|
||||||
}
|
}
|
||||||
@update_attrs %{
|
@update_attrs %{
|
||||||
addressCountry: "some updated addressCountry",
|
country: "some updated addressCountry",
|
||||||
addressLocality: "some updated addressLocality",
|
locality: "some updated addressLocality",
|
||||||
addressRegion: "some updated addressRegion",
|
region: "some updated addressRegion",
|
||||||
description: "some updated description",
|
description: "some updated description",
|
||||||
floor: "some updated floor",
|
floor: "some updated floor",
|
||||||
postalCode: "some updated postalCode",
|
postal_code: "some updated postalCode",
|
||||||
streetAddress: "some updated streetAddress",
|
street: "some updated streetAddress",
|
||||||
geom: %Geo.Point{coordinates: {20, -20}, srid: 4326}
|
geom: %Geo.Point{coordinates: {20, -20}, srid: 4326}
|
||||||
}
|
}
|
||||||
# @invalid_attrs %{
|
# @invalid_attrs %{
|
||||||
@ -58,25 +58,25 @@ defmodule Mobilizon.AddressesTest do
|
|||||||
|
|
||||||
test "create_address/1 with valid data creates a address" do
|
test "create_address/1 with valid data creates a address" do
|
||||||
assert {:ok, %Address{} = address} = Addresses.create_address(@valid_attrs)
|
assert {:ok, %Address{} = address} = Addresses.create_address(@valid_attrs)
|
||||||
assert address.addressCountry == "some addressCountry"
|
assert address.country == "some addressCountry"
|
||||||
assert address.addressLocality == "some addressLocality"
|
assert address.locality == "some addressLocality"
|
||||||
assert address.addressRegion == "some addressRegion"
|
assert address.region == "some addressRegion"
|
||||||
assert address.description == "some description"
|
assert address.description == "some description"
|
||||||
assert address.floor == "some floor"
|
assert address.floor == "some floor"
|
||||||
assert address.postalCode == "some postalCode"
|
assert address.postal_code == "some postalCode"
|
||||||
assert address.streetAddress == "some streetAddress"
|
assert address.street == "some streetAddress"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "update_address/2 with valid data updates the address" do
|
test "update_address/2 with valid data updates the address" do
|
||||||
address = address_fixture()
|
address = address_fixture()
|
||||||
assert {:ok, %Address{} = address} = Addresses.update_address(address, @update_attrs)
|
assert {:ok, %Address{} = address} = Addresses.update_address(address, @update_attrs)
|
||||||
assert address.addressCountry == "some updated addressCountry"
|
assert address.country == "some updated addressCountry"
|
||||||
assert address.addressLocality == "some updated addressLocality"
|
assert address.locality == "some updated addressLocality"
|
||||||
assert address.addressRegion == "some updated addressRegion"
|
assert address.region == "some updated addressRegion"
|
||||||
assert address.description == "some updated description"
|
assert address.description == "some updated description"
|
||||||
assert address.floor == "some updated floor"
|
assert address.floor == "some updated floor"
|
||||||
assert address.postalCode == "some updated postalCode"
|
assert address.postal_code == "some updated postalCode"
|
||||||
assert address.streetAddress == "some updated streetAddress"
|
assert address.street == "some updated streetAddress"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "delete_address/1 deletes the address" do
|
test "delete_address/1 deletes the address" do
|
||||||
|
@ -35,10 +35,10 @@ defmodule Mobilizon.Service.Geospatial.AddokTest do
|
|||||||
test "returns a valid address from search" do
|
test "returns a valid address from search" do
|
||||||
use_cassette "geospatial/addok/search" do
|
use_cassette "geospatial/addok/search" do
|
||||||
assert %Address{
|
assert %Address{
|
||||||
addressLocality: "Lyon",
|
locality: "Lyon",
|
||||||
description: "10 Rue Jangot",
|
description: "10 Rue Jangot",
|
||||||
postalCode: "69007",
|
postal_code: "69007",
|
||||||
streetAddress: "10 Rue Jangot",
|
street: "10 Rue Jangot",
|
||||||
geom: %Geo.Point{coordinates: {4.842569, 45.751718}, properties: %{}, srid: 4326}
|
geom: %Geo.Point{coordinates: {4.842569, 45.751718}, properties: %{}, srid: 4326}
|
||||||
} == Addok.search("10 rue Jangot") |> hd
|
} == Addok.search("10 rue Jangot") |> hd
|
||||||
end
|
end
|
||||||
@ -47,10 +47,10 @@ defmodule Mobilizon.Service.Geospatial.AddokTest do
|
|||||||
test "returns a valid address from reverse geocode" do
|
test "returns a valid address from reverse geocode" do
|
||||||
use_cassette "geospatial/addok/geocode" do
|
use_cassette "geospatial/addok/geocode" do
|
||||||
assert %Address{
|
assert %Address{
|
||||||
addressLocality: "Lyon",
|
locality: "Lyon",
|
||||||
description: "10 Rue Jangot",
|
description: "10 Rue Jangot",
|
||||||
postalCode: "69007",
|
postal_code: "69007",
|
||||||
streetAddress: "10 Rue Jangot",
|
street: "10 Rue Jangot",
|
||||||
geom: %Geo.Point{coordinates: {4.842569, 45.751718}, properties: %{}, srid: 4326}
|
geom: %Geo.Point{coordinates: {4.842569, 45.751718}, properties: %{}, srid: 4326}
|
||||||
} == Addok.geocode(4.842569, 45.751718) |> hd
|
} == Addok.geocode(4.842569, 45.751718) |> hd
|
||||||
end
|
end
|
||||||
|
@ -42,12 +42,12 @@ defmodule Mobilizon.Service.Geospatial.GoogleMapsTest do
|
|||||||
test "returns a valid address from search" do
|
test "returns a valid address from search" do
|
||||||
use_cassette "geospatial/google_maps/search" do
|
use_cassette "geospatial/google_maps/search" do
|
||||||
assert %Address{
|
assert %Address{
|
||||||
addressLocality: "Lyon",
|
locality: "Lyon",
|
||||||
description: "10 Rue Jangot, 69007 Lyon, France",
|
description: "10 Rue Jangot, 69007 Lyon, France",
|
||||||
addressRegion: "Auvergne-Rhône-Alpes",
|
region: "Auvergne-Rhône-Alpes",
|
||||||
addressCountry: "France",
|
country: "France",
|
||||||
postalCode: "69007",
|
postal_code: "69007",
|
||||||
streetAddress: "10 Rue Jangot",
|
street: "10 Rue Jangot",
|
||||||
geom: %Geo.Point{
|
geom: %Geo.Point{
|
||||||
coordinates: {4.8424032, 45.75164940000001},
|
coordinates: {4.8424032, 45.75164940000001},
|
||||||
properties: %{},
|
properties: %{},
|
||||||
@ -60,12 +60,12 @@ defmodule Mobilizon.Service.Geospatial.GoogleMapsTest do
|
|||||||
test "returns a valid address from reverse geocode" do
|
test "returns a valid address from reverse geocode" do
|
||||||
use_cassette "geospatial/google_maps/geocode" do
|
use_cassette "geospatial/google_maps/geocode" do
|
||||||
assert %Address{
|
assert %Address{
|
||||||
addressLocality: "Lyon",
|
locality: "Lyon",
|
||||||
description: "10 Rue Jangot, 69007 Lyon, France",
|
description: "10 Rue Jangot, 69007 Lyon, France",
|
||||||
addressRegion: "Auvergne-Rhône-Alpes",
|
region: "Auvergne-Rhône-Alpes",
|
||||||
addressCountry: "France",
|
country: "France",
|
||||||
postalCode: "69007",
|
postal_code: "69007",
|
||||||
streetAddress: "10 Rue Jangot",
|
street: "10 Rue Jangot",
|
||||||
geom: %Geo.Point{
|
geom: %Geo.Point{
|
||||||
coordinates: {4.8424967, 45.751725},
|
coordinates: {4.8424967, 45.751725},
|
||||||
properties: %{},
|
properties: %{},
|
||||||
|
@ -45,12 +45,12 @@ defmodule Mobilizon.Service.Geospatial.MapQuestTest do
|
|||||||
test "returns a valid address from search" do
|
test "returns a valid address from search" do
|
||||||
use_cassette "geospatial/map_quest/search" do
|
use_cassette "geospatial/map_quest/search" do
|
||||||
assert %Address{
|
assert %Address{
|
||||||
addressLocality: "Lyon",
|
locality: "Lyon",
|
||||||
description: "10 Rue Jangot",
|
description: "10 Rue Jangot",
|
||||||
addressRegion: "Auvergne-Rhône-Alpes",
|
region: "Auvergne-Rhône-Alpes",
|
||||||
addressCountry: "FR",
|
country: "FR",
|
||||||
postalCode: "69007",
|
postal_code: "69007",
|
||||||
streetAddress: "10 Rue Jangot",
|
street: "10 Rue Jangot",
|
||||||
geom: %Geo.Point{
|
geom: %Geo.Point{
|
||||||
coordinates: {4.842566, 45.751714},
|
coordinates: {4.842566, 45.751714},
|
||||||
properties: %{},
|
properties: %{},
|
||||||
@ -65,12 +65,12 @@ defmodule Mobilizon.Service.Geospatial.MapQuestTest do
|
|||||||
test "returns a valid address from reverse geocode" do
|
test "returns a valid address from reverse geocode" do
|
||||||
use_cassette "geospatial/map_quest/geocode" do
|
use_cassette "geospatial/map_quest/geocode" do
|
||||||
assert %Address{
|
assert %Address{
|
||||||
addressLocality: "Lyon",
|
locality: "Lyon",
|
||||||
description: "10 Rue Jangot",
|
description: "10 Rue Jangot",
|
||||||
addressRegion: "Auvergne-Rhône-Alpes",
|
region: "Auvergne-Rhône-Alpes",
|
||||||
addressCountry: "FR",
|
country: "FR",
|
||||||
postalCode: "69007",
|
postal_code: "69007",
|
||||||
streetAddress: "10 Rue Jangot",
|
street: "10 Rue Jangot",
|
||||||
geom: %Geo.Point{
|
geom: %Geo.Point{
|
||||||
coordinates: {4.842569, 45.751718},
|
coordinates: {4.842569, 45.751718},
|
||||||
properties: %{},
|
properties: %{},
|
||||||
|
@ -28,13 +28,13 @@ defmodule Mobilizon.Service.Geospatial.NominatimTest do
|
|||||||
test "returns a valid address from search" do
|
test "returns a valid address from search" do
|
||||||
use_cassette "geospatial/nominatim/search" do
|
use_cassette "geospatial/nominatim/search" do
|
||||||
assert %Address{
|
assert %Address{
|
||||||
addressLocality: "Lyon",
|
locality: "Lyon",
|
||||||
description:
|
description:
|
||||||
"10, Rue Jangot, La Guillotière, Lyon 7e Arrondissement, Lyon, Métropole de Lyon, Departemental constituency of Rhône, Auvergne-Rhône-Alpes, Metropolitan France, 69007, France",
|
"10, Rue Jangot, La Guillotière, Lyon 7e Arrondissement, Lyon, Métropole de Lyon, Departemental constituency of Rhône, Auvergne-Rhône-Alpes, Metropolitan France, 69007, France",
|
||||||
addressRegion: "Auvergne-Rhône-Alpes",
|
region: "Auvergne-Rhône-Alpes",
|
||||||
addressCountry: "France",
|
country: "France",
|
||||||
postalCode: "69007",
|
postal_code: "69007",
|
||||||
streetAddress: "10 Rue Jangot",
|
street: "10 Rue Jangot",
|
||||||
geom: %Geo.Point{
|
geom: %Geo.Point{
|
||||||
coordinates: {4.8425657, 45.7517141},
|
coordinates: {4.8425657, 45.7517141},
|
||||||
properties: %{},
|
properties: %{},
|
||||||
@ -47,13 +47,13 @@ defmodule Mobilizon.Service.Geospatial.NominatimTest do
|
|||||||
test "returns a valid address from reverse geocode" do
|
test "returns a valid address from reverse geocode" do
|
||||||
use_cassette "geospatial/nominatim/geocode" do
|
use_cassette "geospatial/nominatim/geocode" do
|
||||||
assert %Address{
|
assert %Address{
|
||||||
addressLocality: "Lyon",
|
locality: "Lyon",
|
||||||
description:
|
description:
|
||||||
"10, Rue Jangot, La Guillotière, Lyon 7e Arrondissement, Lyon, Métropole de Lyon, Circonscription départementale du Rhône, Auvergne-Rhône-Alpes, France métropolitaine, 69007, France",
|
"10, Rue Jangot, La Guillotière, Lyon 7e Arrondissement, Lyon, Métropole de Lyon, Circonscription départementale du Rhône, Auvergne-Rhône-Alpes, France métropolitaine, 69007, France",
|
||||||
addressRegion: "Auvergne-Rhône-Alpes",
|
region: "Auvergne-Rhône-Alpes",
|
||||||
addressCountry: "France",
|
country: "France",
|
||||||
postalCode: "69007",
|
postal_code: "69007",
|
||||||
streetAddress: "10 Rue Jangot",
|
street: "10 Rue Jangot",
|
||||||
geom: %Geo.Point{
|
geom: %Geo.Point{
|
||||||
coordinates: {4.8425657, 45.7517141},
|
coordinates: {4.8425657, 45.7517141},
|
||||||
properties: %{},
|
properties: %{},
|
||||||
|
@ -26,12 +26,12 @@ defmodule Mobilizon.Service.Geospatial.PhotonTest do
|
|||||||
test "returns a valid address from search" do
|
test "returns a valid address from search" do
|
||||||
use_cassette "geospatial/photon/search" do
|
use_cassette "geospatial/photon/search" do
|
||||||
assert %Address{
|
assert %Address{
|
||||||
addressLocality: "Lyon",
|
locality: "Lyon",
|
||||||
description: "10 Rue Jangot",
|
description: "10 Rue Jangot",
|
||||||
addressRegion: "Auvergne-Rhône-Alpes",
|
region: "Auvergne-Rhône-Alpes",
|
||||||
addressCountry: "France",
|
country: "France",
|
||||||
postalCode: "69007",
|
postal_code: "69007",
|
||||||
streetAddress: "10 Rue Jangot",
|
street: "10 Rue Jangot",
|
||||||
geom: %Geo.Point{
|
geom: %Geo.Point{
|
||||||
coordinates: {4.8425657, 45.7517141},
|
coordinates: {4.8425657, 45.7517141},
|
||||||
properties: %{},
|
properties: %{},
|
||||||
@ -45,12 +45,12 @@ defmodule Mobilizon.Service.Geospatial.PhotonTest do
|
|||||||
# test "returns a valid address from reverse geocode" do
|
# test "returns a valid address from reverse geocode" do
|
||||||
# use_cassette "geospatial/photon/geocode" do
|
# use_cassette "geospatial/photon/geocode" do
|
||||||
# assert %Address{
|
# assert %Address{
|
||||||
# addressLocality: "Lyon",
|
# locality: "Lyon",
|
||||||
# description: "",
|
# description: "",
|
||||||
# addressRegion: "Auvergne-Rhône-Alpes",
|
# region: "Auvergne-Rhône-Alpes",
|
||||||
# addressCountry: "France",
|
# country: "France",
|
||||||
# postalCode: "69007",
|
# postal_code: "69007",
|
||||||
# streetAddress: "10 Rue Jangot",
|
# street: "10 Rue Jangot",
|
||||||
# geom: %Geo.Point{
|
# geom: %Geo.Point{
|
||||||
# coordinates: {4.8425657, 45.7517141},
|
# coordinates: {4.8425657, 45.7517141},
|
||||||
# properties: %{},
|
# properties: %{},
|
||||||
|
@ -10,6 +10,7 @@ defmodule MobilizonWeb.Resolvers.AddressResolverTest do
|
|||||||
query = """
|
query = """
|
||||||
{
|
{
|
||||||
searchAddress(query: "10 Rue Jangot") {
|
searchAddress(query: "10 Rue Jangot") {
|
||||||
|
street,
|
||||||
description,
|
description,
|
||||||
geom
|
geom
|
||||||
}
|
}
|
||||||
|
@ -72,11 +72,11 @@ defmodule Mobilizon.Factory do
|
|||||||
description: sequence("MyAddress"),
|
description: sequence("MyAddress"),
|
||||||
geom: %Geo.Point{coordinates: {45.75, 4.85}, srid: 4326},
|
geom: %Geo.Point{coordinates: {45.75, 4.85}, srid: 4326},
|
||||||
floor: "Myfloor",
|
floor: "Myfloor",
|
||||||
addressCountry: "My Country",
|
country: "My Country",
|
||||||
addressLocality: "My Locality",
|
locality: "My Locality",
|
||||||
addressRegion: "My Region",
|
region: "My Region",
|
||||||
postalCode: "My Postal Code",
|
postal_code: "My Postal Code",
|
||||||
streetAddress: "My Street Address"
|
street: "My Street Address"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user