Add groups back
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
cac4dd3ca3
commit
90de5a105b
@ -4,6 +4,7 @@
|
|||||||
<v-flex xs12 sm6 offset-sm3>
|
<v-flex xs12 sm6 offset-sm3>
|
||||||
<v-progress-circular v-if="loading" indeterminate color="primary"></v-progress-circular>
|
<v-progress-circular v-if="loading" indeterminate color="primary"></v-progress-circular>
|
||||||
<v-card v-if="!loading">
|
<v-card v-if="!loading">
|
||||||
|
<v-card-media :src="actor.banner" height="400px">
|
||||||
<v-layout column class="media">
|
<v-layout column class="media">
|
||||||
<v-card-title>
|
<v-card-title>
|
||||||
<v-btn icon @click="$router.go(-1)">
|
<v-btn icon @click="$router.go(-1)">
|
||||||
@ -40,6 +41,7 @@
|
|||||||
</v-layout>
|
</v-layout>
|
||||||
</v-container>
|
</v-container>
|
||||||
</v-layout>
|
</v-layout>
|
||||||
|
</v-card-media>
|
||||||
<v-list three-line>
|
<v-list three-line>
|
||||||
<v-list-tile>
|
<v-list-tile>
|
||||||
<v-list-tile-action>
|
<v-list-tile-action>
|
||||||
|
@ -6,7 +6,15 @@
|
|||||||
<v-flex xs12>
|
<v-flex xs12>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
label="Title"
|
label="Title"
|
||||||
v-model="group.title"
|
v-model="group.preferred_username"
|
||||||
|
:counter="100"
|
||||||
|
required
|
||||||
|
></v-text-field>
|
||||||
|
</v-flex>
|
||||||
|
<v-flex xs12>
|
||||||
|
<v-text-field
|
||||||
|
label="Title"
|
||||||
|
v-model="group.name"
|
||||||
:counter="100"
|
:counter="100"
|
||||||
required
|
required
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
@ -14,7 +22,7 @@
|
|||||||
<v-flex md6>
|
<v-flex md6>
|
||||||
<v-text-field
|
<v-text-field
|
||||||
label="Description"
|
label="Description"
|
||||||
v-model="group.description"
|
v-model="group.summary"
|
||||||
multiLine
|
multiLine
|
||||||
required
|
required
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
@ -22,34 +30,34 @@
|
|||||||
<v-flex md6>
|
<v-flex md6>
|
||||||
<vue-markdown class="markdown-render"
|
<vue-markdown class="markdown-render"
|
||||||
:watches="['show','html','breaks','linkify','emoji','typographer','toc']"
|
:watches="['show','html','breaks','linkify','emoji','typographer','toc']"
|
||||||
:source="group.description"
|
:source="group.summary"
|
||||||
:show="true" :html="false" :breaks="true" :linkify="true"
|
:show="true" :html="false" :breaks="true" :linkify="true"
|
||||||
:emoji="true" :typographer="true" :toc="false"
|
:emoji="true" :typographer="true" :toc="false"
|
||||||
></vue-markdown>
|
></vue-markdown>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
<v-flex md12>
|
<!--<v-flex md12>-->
|
||||||
<vuetify-google-autocomplete
|
<!--<vuetify-google-autocomplete-->
|
||||||
id="map"
|
<!--id="map"-->
|
||||||
append-icon="search"
|
<!--append-icon="search"-->
|
||||||
classname="form-control"
|
<!--classname="form-control"-->
|
||||||
placeholder="Start typing"
|
<!--placeholder="Start typing"-->
|
||||||
enable-geolocation
|
<!--enable-geolocation-->
|
||||||
v-on:placechanged="getAddressData"
|
<!--v-on:placechanged="getAddressData"-->
|
||||||
>
|
<!-->-->
|
||||||
</vuetify-google-autocomplete>
|
<!--</vuetify-google-autocomplete>-->
|
||||||
</v-flex>
|
<!--</v-flex>-->
|
||||||
<v-flex md12>
|
<!--<v-flex md12>-->
|
||||||
<v-select
|
<!--<v-select-->
|
||||||
v-bind:items="categories"
|
<!--v-bind:items="categories"-->
|
||||||
v-model="group.category"
|
<!--v-model="group.category"-->
|
||||||
item-text="title"
|
<!--item-text="title"-->
|
||||||
item-value="@id"
|
<!--item-value="@id"-->
|
||||||
label="Categories"
|
<!--label="Categories"-->
|
||||||
single-line
|
<!--single-line-->
|
||||||
bottom
|
<!--bottom-->
|
||||||
types="(cities)"
|
<!--types="(cities)"-->
|
||||||
></v-select>
|
<!--></v-select>-->
|
||||||
</v-flex>
|
<!--</v-flex>-->
|
||||||
</v-layout>
|
</v-layout>
|
||||||
</v-form>
|
</v-form>
|
||||||
<v-btn color="primary" @click="create">Create group</v-btn>
|
<v-btn color="primary" @click="create">Create group</v-btn>
|
||||||
@ -72,9 +80,10 @@
|
|||||||
return {
|
return {
|
||||||
e1: 0,
|
e1: 0,
|
||||||
group: {
|
group: {
|
||||||
title: '',
|
preferred_username: '',
|
||||||
description: '',
|
name: '',
|
||||||
category: null,
|
summary: '',
|
||||||
|
// category: null,
|
||||||
},
|
},
|
||||||
categories: [],
|
categories: [],
|
||||||
};
|
};
|
||||||
|
@ -14,21 +14,20 @@
|
|||||||
<v-container fill-height fluid>
|
<v-container fill-height fluid>
|
||||||
<v-layout fill-height>
|
<v-layout fill-height>
|
||||||
<v-flex xs12 align-end flexbox>
|
<v-flex xs12 align-end flexbox>
|
||||||
<span class="headline">{{ group.title }}</span>
|
<span class="headline">{{ group.username }}</span>
|
||||||
</v-flex>
|
</v-flex>
|
||||||
</v-layout>
|
</v-layout>
|
||||||
</v-container>
|
</v-container>
|
||||||
</v-card-media>
|
</v-card-media>
|
||||||
<v-card-title>
|
<v-card-title>
|
||||||
<div>
|
<div>
|
||||||
<span class="grey--text">{{ group.startDate | formatDate }} à {{ group.location }}</span><br>
|
<p>{{ group.summary }}</p>
|
||||||
<p>{{ group.description }}</p>
|
|
||||||
<p v-if="group.organizer">Organisé par <router-link :to="{name: 'Account', params: {'id': group.organizer.id}}">{{ group.organizer.username }}</router-link></p>
|
<p v-if="group.organizer">Organisé par <router-link :to="{name: 'Account', params: {'id': group.organizer.id}}">{{ group.organizer.username }}</router-link></p>
|
||||||
</div>
|
</div>
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
<v-btn flat color="green" @click="joinGroup(group.id)"><v-icon v-if="group.locked">lock</v-icon>Join</v-btn>
|
<v-btn flat color="green" @click="joinGroup(group.id)"><v-icon v-if="group.locked">lock</v-icon>Join</v-btn>
|
||||||
<v-btn flat color="orange" @click="viewEvent(group.id)">Explore</v-btn>
|
<v-btn flat color="orange" @click="viewActor(group)">Explore</v-btn>
|
||||||
<v-btn flat color="red" @click="deleteEvent(group.id)">Delete</v-btn>
|
<v-btn flat color="red" @click="deleteEvent(group.id)">Delete</v-btn>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
</v-card>
|
</v-card>
|
||||||
@ -53,10 +52,14 @@
|
|||||||
this.fetchData();
|
this.fetchData();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
username_with_domain(actor) {
|
||||||
|
return actor.username + (actor.domain === null ? '' : `@${actor.domain}`)
|
||||||
|
},
|
||||||
fetchData() {
|
fetchData() {
|
||||||
eventFetch('/groups', this.$store)
|
eventFetch('/groups', this.$store)
|
||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
|
console.log(data);
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.groups = data.data;
|
this.groups = data.data;
|
||||||
});
|
});
|
||||||
@ -67,8 +70,8 @@
|
|||||||
.then(response => response.json())
|
.then(response => response.json())
|
||||||
.then(() => router.push('/groups'));
|
.then(() => router.push('/groups'));
|
||||||
},
|
},
|
||||||
viewEvent(id) {
|
viewActor(actor) {
|
||||||
this.$router.push({ name: 'Group', params: { id } })
|
this.$router.push({ name: 'Account', params: { name: this.username_with_domain(actor) } })
|
||||||
},
|
},
|
||||||
joinGroup(id) {
|
joinGroup(id) {
|
||||||
const router = this.$router;
|
const router = this.$router;
|
||||||
|
@ -64,6 +64,8 @@ defmodule Eventos.Actors.Actor do
|
|||||||
field :private_key, :string
|
field :private_key, :string
|
||||||
field :manually_approves_followers, :boolean, default: false
|
field :manually_approves_followers, :boolean, default: false
|
||||||
field :suspended, :boolean, default: false
|
field :suspended, :boolean, default: false
|
||||||
|
field :avatar_url, :string
|
||||||
|
field :banner_url, :string
|
||||||
many_to_many :followers, Actor, join_through: Follower
|
many_to_many :followers, Actor, join_through: Follower
|
||||||
has_many :organized_events, Event, [foreign_key: :organizer_actor_id]
|
has_many :organized_events, Event, [foreign_key: :organizer_actor_id]
|
||||||
many_to_many :memberships, Actor, join_through: Member
|
many_to_many :memberships, Actor, join_through: Member
|
||||||
@ -75,7 +77,7 @@ defmodule Eventos.Actors.Actor do
|
|||||||
@doc false
|
@doc false
|
||||||
def changeset(%Actor{} = actor, attrs) do
|
def changeset(%Actor{} = actor, attrs) do
|
||||||
actor
|
actor
|
||||||
|> Ecto.Changeset.cast(attrs, [:url, :outbox_url, :inbox_url, :following_url, :followers_url, :type, :name, :domain, :summary, :preferred_username, :public_key, :private_key, :manually_approves_followers, :suspended])
|
|> Ecto.Changeset.cast(attrs, [:url, :outbox_url, :inbox_url, :shared_inbox_url, :following_url, :followers_url, :type, :name, :domain, :summary, :preferred_username, :public_key, :private_key, :manually_approves_followers, :suspended, :avatar_url, :banner_url])
|
||||||
|> validate_required([:preferred_username, :public_key, :suspended, :url])
|
|> validate_required([:preferred_username, :public_key, :suspended, :url])
|
||||||
|> unique_constraint(:prefered_username, name: :actors_preferred_username_domain_index)
|
|> unique_constraint(:prefered_username, name: :actors_preferred_username_domain_index)
|
||||||
end
|
end
|
||||||
@ -91,8 +93,8 @@ defmodule Eventos.Actors.Actor do
|
|||||||
def remote_actor_creation(params) do
|
def remote_actor_creation(params) do
|
||||||
changes =
|
changes =
|
||||||
%Actor{}
|
%Actor{}
|
||||||
|> Ecto.Changeset.cast(params, [:url, :outbox_url, :inbox_url, :following_url, :followers_url, :type, :name, :domain, :summary, :preferred_username, :public_key, :manually_approves_followers])
|
|> Ecto.Changeset.cast(params, [:url, :outbox_url, :inbox_url, :shared_inbox_url, :following_url, :followers_url, :type, :name, :domain, :summary, :preferred_username, :public_key, :manually_approves_followers, :avatar_url, :banner_url])
|
||||||
|> validate_required([:url, :outbox_url, :inbox_url, :type, :name, :domain, :summary, :preferred_username, :public_key])
|
|> validate_required([:url, :outbox_url, :inbox_url, :type, :name, :domain, :preferred_username, :public_key])
|
||||||
|> unique_constraint(:preferred_username, name: :actors_preferred_username_domain_index)
|
|> unique_constraint(:preferred_username, name: :actors_preferred_username_domain_index)
|
||||||
|> validate_length(:summary, max: 5000)
|
|> validate_length(:summary, max: 5000)
|
||||||
|> validate_length(:preferred_username, max: 100)
|
|> validate_length(:preferred_username, max: 100)
|
||||||
@ -103,6 +105,21 @@ defmodule Eventos.Actors.Actor do
|
|||||||
changes
|
changes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def group_creation(%Actor{} = actor, params) do
|
||||||
|
actor
|
||||||
|
|> Ecto.Changeset.cast(params, [:url, :outbox_url, :inbox_url, :shared_inbox_url, :type, :name, :domain, :summary, :preferred_username, :avatar_url, :banner_url])
|
||||||
|
|> put_change(:outbox_url, "#{EventosWeb.Endpoint.url()}/@#{params["prefered_username"]}/outbox")
|
||||||
|
|> put_change(:inbox_url, "#{EventosWeb.Endpoint.url()}/@#{params["prefered_username"]}/inbox")
|
||||||
|
|> put_change(:shared_inbox_url, "#{EventosWeb.Endpoint.url()}/inbox")
|
||||||
|
|> put_change(:url, "#{EventosWeb.Endpoint.url()}/@#{params["prefered_username"]}")
|
||||||
|
|> put_change(:domain, nil)
|
||||||
|
|> put_change(:type, "Group")
|
||||||
|
|> validate_required([:url, :outbox_url, :inbox_url, :type, :name, :preferred_username])
|
||||||
|
|> validate_length(:summary, max: 5000)
|
||||||
|
|> validate_length(:preferred_username, max: 100)
|
||||||
|
|> put_change(:local, true)
|
||||||
|
end
|
||||||
|
|
||||||
def get_or_fetch_by_url(url) do
|
def get_or_fetch_by_url(url) do
|
||||||
if user = Actors.get_actor_by_url(url) do
|
if user = Actors.get_actor_by_url(url) do
|
||||||
user
|
user
|
||||||
|
@ -126,6 +126,31 @@ defmodule Eventos.Actors do
|
|||||||
"acct:#{actor_to_local_name_and_domain(actor)}"
|
"acct:#{actor_to_local_name_and_domain(actor)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
List the groups
|
||||||
|
"""
|
||||||
|
def list_groups do
|
||||||
|
Repo.all(from a in Actor, where: a.type == "Group")
|
||||||
|
end
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Creates a group.
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
iex> create_group(%{field: value})
|
||||||
|
{:ok, %Actor{}}
|
||||||
|
|
||||||
|
iex> create_group(%{field: bad_value})
|
||||||
|
{:error, %Ecto.Changeset{}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
def create_group(attrs \\ %{}) do
|
||||||
|
%Actor{}
|
||||||
|
|> Actor.group_creation(attrs)
|
||||||
|
|> Repo.insert()
|
||||||
|
end
|
||||||
|
|
||||||
alias Eventos.Actors.User
|
alias Eventos.Actors.User
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
@ -151,7 +176,7 @@ defmodule Eventos.Actors do
|
|||||||
|
|
||||||
def insert_or_update_actor(data) do
|
def insert_or_update_actor(data) do
|
||||||
cs = Actor.remote_actor_creation(data)
|
cs = Actor.remote_actor_creation(data)
|
||||||
Repo.insert(cs, on_conflict: [set: [public_key: data.public_key]], conflict_target: [:preferred_username, :domain])
|
Repo.insert(cs, on_conflict: [set: [public_key: data.public_key, avatar_url: data.avatar_url, banner: data.banner_url, name: data.name]], conflict_target: [:preferred_username, :domain])
|
||||||
end
|
end
|
||||||
|
|
||||||
# def increase_event_count(%Actor{} = actor) do
|
# def increase_event_count(%Actor{} = actor) do
|
||||||
|
@ -1,46 +1,26 @@
|
|||||||
#defmodule EventosWeb.GroupController do
|
defmodule EventosWeb.GroupController do
|
||||||
# @moduledoc """
|
@moduledoc """
|
||||||
# Controller for Groups
|
Controller for Groups
|
||||||
# """
|
"""
|
||||||
# use EventosWeb, :controller
|
use EventosWeb, :controller
|
||||||
#
|
|
||||||
# alias Eventos.Actors
|
alias Eventos.Actors
|
||||||
# alias Eventos.Actors.Actor
|
alias Eventos.Actors.Actor
|
||||||
#
|
|
||||||
# action_fallback EventosWeb.FallbackController
|
action_fallback EventosWeb.FallbackController
|
||||||
#
|
|
||||||
# def index(conn, _params) do
|
def index(conn, _params) do
|
||||||
# groups = Actors.list_groups()
|
groups = Actors.list_groups()
|
||||||
# render(conn, "index.json", groups: groups)
|
render(conn, EventosWeb.ActorView, "index.json", actors: groups)
|
||||||
# end
|
end
|
||||||
#
|
|
||||||
# def create(conn, %{"group" => group_params}) do
|
def create(conn, %{"group" => group_params}) do
|
||||||
# group_params = Map.put(group_params, "url", "h")
|
with actor_admin = Guardian.Plug.current_resource(conn).actor,
|
||||||
# with {:ok, %Group{} = group} <- Actors.create_group(group_params) do
|
{:ok, %Actor{} = group} <- Actors.create_group(group_params) do
|
||||||
# conn
|
conn
|
||||||
# |> put_status(:created)
|
|> put_status(:created)
|
||||||
# |> put_resp_header("location", group_path(conn, :show, group))
|
|> put_resp_header("location", actor_path(conn, :show, group))
|
||||||
# |> render("show_simple.json", group: group)
|
|> render(EventosWeb.ActorView, "acccount_basic.json", actor: group)
|
||||||
# end
|
end
|
||||||
# end
|
end
|
||||||
#
|
end
|
||||||
# def show(conn, %{"id" => id}) do
|
|
||||||
# group = Actors.get_group_full!(id)
|
|
||||||
# render(conn, "show.json", group: group)
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# def update(conn, %{"id" => id, "group" => group_params}) do
|
|
||||||
# group = Actors.get_group!(id)
|
|
||||||
#
|
|
||||||
# with {:ok, %Actor{} = group} <- Actors.update_group(group, group_params) do
|
|
||||||
# render(conn, "show_simple.json", group: group)
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# def delete(conn, %{"id" => id}) do
|
|
||||||
# group = Actors.get_group!(id)
|
|
||||||
# with {:ok, %Actor{}} <- Actors.delete_group(group) do
|
|
||||||
# send_resp(conn, :no_content, "")
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#end
|
|
||||||
|
@ -37,7 +37,7 @@ defmodule EventosWeb.Router do
|
|||||||
|
|
||||||
post "/users", UserController, :register
|
post "/users", UserController, :register
|
||||||
post "/login", UserSessionController, :sign_in
|
post "/login", UserSessionController, :sign_in
|
||||||
#resources "/groups", GroupController, only: [:index, :show]
|
get "/groups", GroupController, :index
|
||||||
get "/events", EventController, :index
|
get "/events", EventController, :index
|
||||||
get "/events/search/:name", EventController, :search
|
get "/events/search/:name", EventController, :search
|
||||||
get "/events/:username/:slug", EventController, :show
|
get "/events/:username/:slug", EventController, :show
|
||||||
@ -79,7 +79,7 @@ defmodule EventosWeb.Router do
|
|||||||
resources "/participant", ParticipantController
|
resources "/participant", ParticipantController
|
||||||
resources "/bots", BotController, except: [:new, :edit, :show]
|
resources "/bots", BotController, except: [:new, :edit, :show]
|
||||||
#resources "/requests", EventRequestController
|
#resources "/requests", EventRequestController
|
||||||
#resources "/groups", GroupController, except: [:index, :show]
|
post "/groups", GroupController, :create
|
||||||
#post "/groups/:id/request", GroupRequestController, :create_for_group
|
#post "/groups/:id/request", GroupRequestController, :create_for_group
|
||||||
resources "/members", MemberController
|
resources "/members", MemberController
|
||||||
#resources "/requests", GroupRequestController
|
#resources "/requests", GroupRequestController
|
||||||
|
@ -27,6 +27,7 @@ defmodule EventosWeb.ActorView do
|
|||||||
# public_key: actor.public_key,
|
# public_key: actor.public_key,
|
||||||
suspended: actor.suspended,
|
suspended: actor.suspended,
|
||||||
url: actor.url,
|
url: actor.url,
|
||||||
|
avatar: actor.avatar_url,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -40,6 +41,8 @@ defmodule EventosWeb.ActorView do
|
|||||||
# public_key: actor.public_key,
|
# public_key: actor.public_key,
|
||||||
suspended: actor.suspended,
|
suspended: actor.suspended,
|
||||||
url: actor.url,
|
url: actor.url,
|
||||||
|
avatar: actor.avatar_url,
|
||||||
|
banner: actor.banner_url,
|
||||||
organized_events: render_many(actor.organized_events, EventView, "event_for_actor.json")
|
organized_events: render_many(actor.organized_events, EventView, "event_for_actor.json")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -249,21 +249,6 @@ defmodule Eventos.Service.ActivityPub do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def user_data_from_user_object(data) do
|
def user_data_from_user_object(data) do
|
||||||
Logger.debug("user_data_from_user_object")
|
|
||||||
Logger.debug(inspect data)
|
|
||||||
avatar =
|
|
||||||
data["icon"]["url"] &&
|
|
||||||
%{
|
|
||||||
"type" => "Image",
|
|
||||||
"url" => [%{"href" => data["icon"]["url"]}]
|
|
||||||
}
|
|
||||||
|
|
||||||
banner =
|
|
||||||
data["image"]["url"] &&
|
|
||||||
%{
|
|
||||||
"type" => "Image",
|
|
||||||
"url" => [%{"href" => data["image"]["url"]}]
|
|
||||||
}
|
|
||||||
name = if String.trim(data["name"]) === "" do
|
name = if String.trim(data["name"]) === "" do
|
||||||
data["preferredUsername"]
|
data["preferredUsername"]
|
||||||
else
|
else
|
||||||
@ -275,9 +260,9 @@ defmodule Eventos.Service.ActivityPub do
|
|||||||
info: %{
|
info: %{
|
||||||
"ap_enabled" => true,
|
"ap_enabled" => true,
|
||||||
"source_data" => data,
|
"source_data" => data,
|
||||||
"banner" => banner
|
|
||||||
},
|
},
|
||||||
avatar: avatar,
|
avatar_url: data["icon"]["url"],
|
||||||
|
banner_url: data["image"]["url"],
|
||||||
name: name,
|
name: name,
|
||||||
preferred_username: data["preferredUsername"],
|
preferred_username: data["preferredUsername"],
|
||||||
follower_address: data["followers"],
|
follower_address: data["followers"],
|
||||||
@ -287,12 +272,15 @@ defmodule Eventos.Service.ActivityPub do
|
|||||||
outbox_url: data["outbox"],
|
outbox_url: data["outbox"],
|
||||||
following_url: data["following"],
|
following_url: data["following"],
|
||||||
followers_url: data["followers"],
|
followers_url: data["followers"],
|
||||||
shared_inbox_url: data["sharedInbox"],
|
shared_inbox_url: data["endpoints"]["sharedInbox"],
|
||||||
domain: URI.parse(data["id"]).host,
|
domain: URI.parse(data["id"]).host,
|
||||||
manually_approves_followers: data["manuallyApprovesFollowers"],
|
manually_approves_followers: data["manuallyApprovesFollowers"],
|
||||||
type: data["type"],
|
type: data["type"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Logger.debug("user_data_from_user_object")
|
||||||
|
Logger.debug(inspect user_data)
|
||||||
|
|
||||||
{:ok, user_data}
|
{:ok, user_data}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
defmodule Eventos.Repo.Migrations.AddAvatarAndBannerToActor do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def up do
|
||||||
|
alter table(:actors) do
|
||||||
|
add :avatar_url, :string
|
||||||
|
add :banner_url, :string
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down do
|
||||||
|
alter table(:actors) do
|
||||||
|
remove :avatar_url
|
||||||
|
remove :banner_url
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,15 @@
|
|||||||
|
defmodule Eventos.Repo.Migrations.MakeActorPublicKeyNullable do
|
||||||
|
use Ecto.Migration
|
||||||
|
|
||||||
|
def up do
|
||||||
|
alter table(:actors) do
|
||||||
|
modify :public_key, :text, null: true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down do
|
||||||
|
alter table(:actors) do
|
||||||
|
modify :public_key, :text, null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -1,153 +0,0 @@
|
|||||||
defmodule Eventos.AccountsTest do
|
|
||||||
use Eventos.DataCase
|
|
||||||
|
|
||||||
alias Eventos.Accounts
|
|
||||||
|
|
||||||
describe "accounts" do
|
|
||||||
alias Eventos.Accounts.Account
|
|
||||||
|
|
||||||
@valid_attrs %{description: "some description", display_name: "some display_name", domain: "some domain", private_key: "some private_key", public_key: "some public_key", suspended: true, uri: "some uri", url: "some url", username: "some username"}
|
|
||||||
@update_attrs %{description: "some updated description", display_name: "some updated display_name", domain: "some updated domain", private_key: "some updated private_key", public_key: "some updated public_key", suspended: false, uri: "some updated uri", url: "some updated url", username: "some updated username"}
|
|
||||||
@invalid_attrs %{description: nil, display_name: nil, domain: nil, private_key: nil, public_key: nil, suspended: nil, uri: nil, url: nil, username: nil}
|
|
||||||
|
|
||||||
def account_fixture(attrs \\ %{}) do
|
|
||||||
{:ok, account} =
|
|
||||||
attrs
|
|
||||||
|> Enum.into(@valid_attrs)
|
|
||||||
|> Accounts.create_account()
|
|
||||||
|
|
||||||
account
|
|
||||||
end
|
|
||||||
|
|
||||||
test "list_accounts/0 returns all accounts" do
|
|
||||||
account = account_fixture()
|
|
||||||
assert Accounts.list_accounts() == [account]
|
|
||||||
end
|
|
||||||
|
|
||||||
test "get_account!/1 returns the account with given id" do
|
|
||||||
account = account_fixture()
|
|
||||||
assert Accounts.get_account!(account.id) == account
|
|
||||||
end
|
|
||||||
|
|
||||||
test "create_account/1 with valid data creates a account" do
|
|
||||||
assert {:ok, %Account{} = account} = Accounts.create_account(@valid_attrs)
|
|
||||||
assert account.description == "some description"
|
|
||||||
assert account.display_name == "some display_name"
|
|
||||||
assert account.domain == "some domain"
|
|
||||||
assert account.private_key == "some private_key"
|
|
||||||
assert account.public_key == "some public_key"
|
|
||||||
assert account.suspended
|
|
||||||
assert account.uri == "some uri"
|
|
||||||
assert account.url == "some url"
|
|
||||||
assert account.username == "some username"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "create_account/1 with invalid data returns error changeset" do
|
|
||||||
assert {:error, %Ecto.Changeset{}} = Accounts.create_account(@invalid_attrs)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "update_account/2 with valid data updates the account" do
|
|
||||||
account = account_fixture()
|
|
||||||
assert {:ok, account} = Accounts.update_account(account, @update_attrs)
|
|
||||||
assert %Account{} = account
|
|
||||||
assert account.description == "some updated description"
|
|
||||||
assert account.display_name == "some updated display_name"
|
|
||||||
assert account.domain == "some updated domain"
|
|
||||||
assert account.private_key == "some updated private_key"
|
|
||||||
assert account.public_key == "some updated public_key"
|
|
||||||
refute account.suspended
|
|
||||||
assert account.uri == "some updated uri"
|
|
||||||
assert account.url == "some updated url"
|
|
||||||
assert account.username == "some updated username"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "update_account/2 with invalid data returns error changeset" do
|
|
||||||
account = account_fixture()
|
|
||||||
assert {:error, %Ecto.Changeset{}} = Accounts.update_account(account, @invalid_attrs)
|
|
||||||
assert account == Accounts.get_account!(account.id)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "delete_account/1 deletes the account" do
|
|
||||||
account = account_fixture()
|
|
||||||
assert {:ok, %Account{}} = Accounts.delete_account(account)
|
|
||||||
assert_raise Ecto.NoResultsError, fn -> Accounts.get_account!(account.id) end
|
|
||||||
end
|
|
||||||
|
|
||||||
test "change_account/1 returns a account changeset" do
|
|
||||||
account = account_fixture()
|
|
||||||
assert %Ecto.Changeset{} = Accounts.change_account(account)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "users" do
|
|
||||||
alias Eventos.Accounts.{User, Account}
|
|
||||||
|
|
||||||
@account_valid_attrs %{description: "some description", display_name: "some display_name", domain: "some domain", private_key: "some private_key", public_key: "some public_key", suspended: true, uri: "some uri", url: "some url", username: "some username"}
|
|
||||||
@valid_attrs %{email: "foo@bar.tld", password_hash: "some password_hash", role: 42}
|
|
||||||
@update_attrs %{email: "foo@fighters.tld", password_hash: "some updated password_hash", role: 43}
|
|
||||||
@invalid_attrs %{email: nil, password_hash: nil, role: nil}
|
|
||||||
|
|
||||||
def user_fixture(attrs \\ %{}) do
|
|
||||||
{:ok, account} =
|
|
||||||
attrs
|
|
||||||
|> Enum.into(@account_valid_attrs)
|
|
||||||
|> Accounts.create_account()
|
|
||||||
valid_attrs_with_account_id = Map.put(@valid_attrs, :account_id, account.id)
|
|
||||||
{:ok, user} =
|
|
||||||
attrs
|
|
||||||
|> Enum.into(valid_attrs_with_account_id)
|
|
||||||
|> Accounts.create_user()
|
|
||||||
|
|
||||||
user
|
|
||||||
end
|
|
||||||
|
|
||||||
test "list_users/0 returns all users" do
|
|
||||||
user = user_fixture()
|
|
||||||
assert Accounts.list_users() == [user]
|
|
||||||
end
|
|
||||||
|
|
||||||
test "get_user!/1 returns the user with given id" do
|
|
||||||
user = user_fixture()
|
|
||||||
assert Accounts.get_user!(user.id) == user
|
|
||||||
end
|
|
||||||
|
|
||||||
test "create_user/1 with valid data creates a user" do
|
|
||||||
{:ok, %Account{} = account} = Accounts.create_account(@account_valid_attrs)
|
|
||||||
attrs = Map.put(@valid_attrs, :account_id, account.id)
|
|
||||||
assert {:ok, %User{} = user} = Accounts.create_user(attrs)
|
|
||||||
assert user.email == "foo@bar.tld"
|
|
||||||
assert user.password_hash == "some password_hash"
|
|
||||||
assert user.role == 42
|
|
||||||
end
|
|
||||||
|
|
||||||
test "create_user/1 with invalid data returns error changeset" do
|
|
||||||
assert {:error, %Ecto.Changeset{}} = Accounts.create_user(@invalid_attrs)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "update_user/2 with valid data updates the user" do
|
|
||||||
user = user_fixture()
|
|
||||||
assert {:ok, user} = Accounts.update_user(user, @update_attrs)
|
|
||||||
assert %User{} = user
|
|
||||||
assert user.email == "foo@fighters.tld"
|
|
||||||
assert user.password_hash == "some updated password_hash"
|
|
||||||
assert user.role == 43
|
|
||||||
end
|
|
||||||
|
|
||||||
test "update_user/2 with invalid data returns error changeset" do
|
|
||||||
user = user_fixture()
|
|
||||||
assert {:error, %Ecto.Changeset{}} = Accounts.update_user(user, @invalid_attrs)
|
|
||||||
assert user == Accounts.get_user!(user.id)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "delete_user/1 deletes the user" do
|
|
||||||
user = user_fixture()
|
|
||||||
assert {:ok, %User{}} = Accounts.delete_user(user)
|
|
||||||
assert_raise Ecto.NoResultsError, fn -> Accounts.get_user!(user.id) end
|
|
||||||
end
|
|
||||||
|
|
||||||
test "change_user/1 returns a user changeset" do
|
|
||||||
user = user_fixture()
|
|
||||||
assert %Ecto.Changeset{} = Accounts.change_user(user)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
@ -3,6 +3,177 @@ defmodule Eventos.ActorsTest do
|
|||||||
|
|
||||||
alias Eventos.Actors
|
alias Eventos.Actors
|
||||||
|
|
||||||
|
describe "actors" do
|
||||||
|
alias Eventos.Actors.Actor
|
||||||
|
|
||||||
|
@valid_attrs %{description: "some description", display_name: "some display_name", domain: "some domain", private_key: "some private_key", public_key: "some public_key", suspended: true, uri: "some uri", url: "some url", username: "some username"}
|
||||||
|
@update_attrs %{description: "some updated description", display_name: "some updated display_name", domain: "some updated domain", private_key: "some updated private_key", public_key: "some updated public_key", suspended: false, uri: "some updated uri", url: "some updated url", username: "some updated username"}
|
||||||
|
@invalid_attrs %{description: nil, display_name: nil, domain: nil, private_key: nil, public_key: nil, suspended: nil, uri: nil, url: nil, username: nil}
|
||||||
|
|
||||||
|
def actor_fixture(attrs \\ %{}) do
|
||||||
|
{:ok, actor} =
|
||||||
|
attrs
|
||||||
|
|> Enum.into(@valid_attrs)
|
||||||
|
|> Actors.create_actor()
|
||||||
|
|
||||||
|
actor
|
||||||
|
end
|
||||||
|
|
||||||
|
test "list_actors/0 returns all actors" do
|
||||||
|
actor = actor_fixture()
|
||||||
|
assert Actors.list_actors() == [actor]
|
||||||
|
end
|
||||||
|
|
||||||
|
test "get_actor!/1 returns the actor with given id" do
|
||||||
|
actor = actor_fixture()
|
||||||
|
assert Actors.get_actor!(actor.id) == actor
|
||||||
|
end
|
||||||
|
|
||||||
|
test "create_actor/1 with valid data creates a actor" do
|
||||||
|
assert {:ok, %Actor{} = actor} = Actors.create_actor(@valid_attrs)
|
||||||
|
assert actor.description == "some description"
|
||||||
|
assert actor.display_name == "some display_name"
|
||||||
|
assert actor.domain == "some domain"
|
||||||
|
assert actor.private_key == "some private_key"
|
||||||
|
assert actor.public_key == "some public_key"
|
||||||
|
assert actor.suspended
|
||||||
|
assert actor.uri == "some uri"
|
||||||
|
assert actor.url == "some url"
|
||||||
|
assert actor.username == "some username"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "create_actor/1 with invalid data returns error changeset" do
|
||||||
|
assert {:error, %Ecto.Changeset{}} = Actors.create_actor(@invalid_attrs)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "update_actor/2 with valid data updates the actor" do
|
||||||
|
actor = actor_fixture()
|
||||||
|
assert {:ok, actor} = Actors.update_actor(actor, @update_attrs)
|
||||||
|
assert %Actor{} = actor
|
||||||
|
assert actor.description == "some updated description"
|
||||||
|
assert actor.display_name == "some updated display_name"
|
||||||
|
assert actor.domain == "some updated domain"
|
||||||
|
assert actor.private_key == "some updated private_key"
|
||||||
|
assert actor.public_key == "some updated public_key"
|
||||||
|
refute actor.suspended
|
||||||
|
assert actor.uri == "some updated uri"
|
||||||
|
assert actor.url == "some updated url"
|
||||||
|
assert actor.username == "some updated username"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "update_actor/2 with invalid data returns error changeset" do
|
||||||
|
actor = actor_fixture()
|
||||||
|
assert {:error, %Ecto.Changeset{}} = Actors.update_actor(actor, @invalid_attrs)
|
||||||
|
assert actor == Actors.get_actor!(actor.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "delete_actor/1 deletes the actor" do
|
||||||
|
actor = actor_fixture()
|
||||||
|
assert {:ok, %Actor{}} = Actors.delete_actor(actor)
|
||||||
|
assert_raise Ecto.NoResultsError, fn -> Actors.get_actor!(actor.id) end
|
||||||
|
end
|
||||||
|
|
||||||
|
test "change_actor/1 returns a actor changeset" do
|
||||||
|
actor = actor_fixture()
|
||||||
|
assert %Ecto.Changeset{} = Actors.change_actor(actor)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "users" do
|
||||||
|
alias Eventos.Actors.{User, Actor}
|
||||||
|
|
||||||
|
@actor_valid_attrs %{description: "some description", display_name: "some display_name", domain: "some domain", private_key: "some private_key", public_key: "some public_key", suspended: true, uri: "some uri", url: "some url", username: "some username"}
|
||||||
|
@valid_attrs %{email: "foo@bar.tld", password_hash: "some password_hash", role: 42}
|
||||||
|
@update_attrs %{email: "foo@fighters.tld", password_hash: "some updated password_hash", role: 43}
|
||||||
|
@invalid_attrs %{email: nil, password_hash: nil, role: nil}
|
||||||
|
|
||||||
|
def user_fixture(attrs \\ %{}) do
|
||||||
|
{:ok, actor} =
|
||||||
|
attrs
|
||||||
|
|> Enum.into(@actor_valid_attrs)
|
||||||
|
|> Actors.create_actor()
|
||||||
|
valid_attrs_with_actor_id = Map.put(@valid_attrs, :actor_id, actor.id)
|
||||||
|
{:ok, user} =
|
||||||
|
attrs
|
||||||
|
|> Enum.into(valid_attrs_with_actor_id)
|
||||||
|
|> Actors.create_user()
|
||||||
|
|
||||||
|
user
|
||||||
|
end
|
||||||
|
|
||||||
|
test "list_users/0 returns all users" do
|
||||||
|
user = user_fixture()
|
||||||
|
assert Actors.list_users() == [user]
|
||||||
|
end
|
||||||
|
|
||||||
|
test "get_user!/1 returns the user with given id" do
|
||||||
|
user = user_fixture()
|
||||||
|
assert Actors.get_user!(user.id) == user
|
||||||
|
end
|
||||||
|
|
||||||
|
test "create_user/1 with valid data creates a user" do
|
||||||
|
{:ok, %Actor{} = actor} = Actors.create_actor(@actor_valid_attrs)
|
||||||
|
attrs = Map.put(@valid_attrs, :actor_id, actor.id)
|
||||||
|
assert {:ok, %User{} = user} = Actors.create_user(attrs)
|
||||||
|
assert user.email == "foo@bar.tld"
|
||||||
|
assert user.password_hash == "some password_hash"
|
||||||
|
assert user.role == 42
|
||||||
|
end
|
||||||
|
|
||||||
|
test "create_user/1 with invalid data returns error changeset" do
|
||||||
|
assert {:error, %Ecto.Changeset{}} = Actors.create_user(@invalid_attrs)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "update_user/2 with valid data updates the user" do
|
||||||
|
user = user_fixture()
|
||||||
|
assert {:ok, user} = Actors.update_user(user, @update_attrs)
|
||||||
|
assert %User{} = user
|
||||||
|
assert user.email == "foo@fighters.tld"
|
||||||
|
assert user.password_hash == "some updated password_hash"
|
||||||
|
assert user.role == 43
|
||||||
|
end
|
||||||
|
|
||||||
|
test "update_user/2 with invalid data returns error changeset" do
|
||||||
|
user = user_fixture()
|
||||||
|
assert {:error, %Ecto.Changeset{}} = Actors.update_user(user, @invalid_attrs)
|
||||||
|
assert user == Actors.get_user!(user.id)
|
||||||
|
end
|
||||||
|
|
||||||
|
test "delete_user/1 deletes the user" do
|
||||||
|
user = user_fixture()
|
||||||
|
assert {:ok, %User{}} = Actors.delete_user(user)
|
||||||
|
assert_raise Ecto.NoResultsError, fn -> Actors.get_user!(user.id) end
|
||||||
|
end
|
||||||
|
|
||||||
|
test "change_user/1 returns a user changeset" do
|
||||||
|
user = user_fixture()
|
||||||
|
assert %Ecto.Changeset{} = Actors.change_user(user)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "groups" do
|
||||||
|
|
||||||
|
alias Eventos.Actors
|
||||||
|
alias Eventos.Actors.Actor
|
||||||
|
|
||||||
|
@valid_attrs %{summary: "some description", suspended: true, preferred_username: "some-title", name: "Some Title"}
|
||||||
|
@update_attrs %{summary: "some updated description", suspended: false, preferred_username: "some-updated-title", name: "Some Updated Title"}
|
||||||
|
@invalid_attrs %{summary: nil, suspended: nil, preferred_username: nil, name: nil}
|
||||||
|
|
||||||
|
test "create_group/1 with valid data creates a group" do
|
||||||
|
assert {:ok, %Actor{} = group} = Actors.create_group(@valid_attrs)
|
||||||
|
assert group.summary == "some description"
|
||||||
|
refute group.suspended
|
||||||
|
assert group.preferred_username == "some-title"
|
||||||
|
end
|
||||||
|
|
||||||
|
test "create_group/1 with invalid data returns error changeset" do
|
||||||
|
assert {:error, %Ecto.Changeset{}} = Actors.create_group(@invalid_attrs)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
alias Eventos.Actors
|
||||||
|
|
||||||
describe "bots" do
|
describe "bots" do
|
||||||
alias Eventos.Actors.Bot
|
alias Eventos.Actors.Bot
|
||||||
|
|
||||||
|
@ -1,193 +0,0 @@
|
|||||||
defmodule Eventos.GroupsTest do
|
|
||||||
use Eventos.DataCase
|
|
||||||
|
|
||||||
alias Eventos.Groups
|
|
||||||
|
|
||||||
describe "groups" do
|
|
||||||
alias Eventos.Groups.Group
|
|
||||||
|
|
||||||
@valid_attrs %{description: "some description", suspended: true, title: "some title", uri: "some uri", url: "some url"}
|
|
||||||
@update_attrs %{description: "some updated description", suspended: false, title: "some updated title", uri: "some updated uri", url: "some updated url"}
|
|
||||||
@invalid_attrs %{description: nil, suspended: nil, title: nil, uri: nil, url: nil}
|
|
||||||
|
|
||||||
def group_fixture(attrs \\ %{}) do
|
|
||||||
{:ok, group} =
|
|
||||||
attrs
|
|
||||||
|> Enum.into(@valid_attrs)
|
|
||||||
|> Groups.create_group()
|
|
||||||
|
|
||||||
group
|
|
||||||
end
|
|
||||||
|
|
||||||
test "list_groups/0 returns all groups" do
|
|
||||||
group = group_fixture()
|
|
||||||
assert Groups.list_groups() == [group]
|
|
||||||
end
|
|
||||||
|
|
||||||
test "get_group!/1 returns the group with given id" do
|
|
||||||
group = group_fixture()
|
|
||||||
assert Groups.get_group!(group.id) == group
|
|
||||||
end
|
|
||||||
|
|
||||||
test "create_group/1 with valid data creates a group" do
|
|
||||||
assert {:ok, %Group{} = group} = Groups.create_group(@valid_attrs)
|
|
||||||
assert group.description == "some description"
|
|
||||||
assert group.suspended
|
|
||||||
assert group.title == "some title"
|
|
||||||
assert group.uri == "some uri"
|
|
||||||
assert group.url == "some url"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "create_group/1 with invalid data returns error changeset" do
|
|
||||||
assert {:error, %Ecto.Changeset{}} = Groups.create_group(@invalid_attrs)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "update_group/2 with valid data updates the group" do
|
|
||||||
group = group_fixture()
|
|
||||||
assert {:ok, group} = Groups.update_group(group, @update_attrs)
|
|
||||||
assert %Group{} = group
|
|
||||||
assert group.description == "some updated description"
|
|
||||||
refute group.suspended
|
|
||||||
assert group.title == "some updated title"
|
|
||||||
assert group.uri == "some updated uri"
|
|
||||||
assert group.url == "some updated url"
|
|
||||||
end
|
|
||||||
|
|
||||||
test "update_group/2 with invalid data returns error changeset" do
|
|
||||||
group = group_fixture()
|
|
||||||
assert {:error, %Ecto.Changeset{}} = Groups.update_group(group, @invalid_attrs)
|
|
||||||
assert group == Groups.get_group!(group.id)
|
|
||||||
end
|
|
||||||
|
|
||||||
test "delete_group/1 deletes the group" do
|
|
||||||
group = group_fixture()
|
|
||||||
assert {:ok, %Group{}} = Groups.delete_group(group)
|
|
||||||
assert_raise Ecto.NoResultsError, fn -> Groups.get_group!(group.id) end
|
|
||||||
end
|
|
||||||
|
|
||||||
test "change_group/1 returns a group changeset" do
|
|
||||||
group = group_fixture()
|
|
||||||
assert %Ecto.Changeset{} = Groups.change_group(group)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
#
|
|
||||||
# describe "members" do
|
|
||||||
# alias Eventos.Groups.Member
|
|
||||||
#
|
|
||||||
# @valid_attrs %{role: 42}
|
|
||||||
# @update_attrs %{role: 43}
|
|
||||||
# @invalid_attrs %{role: nil}
|
|
||||||
#
|
|
||||||
# def member_fixture(attrs \\ %{}) do
|
|
||||||
# {:ok, member} =
|
|
||||||
# attrs
|
|
||||||
# |> Enum.into(@valid_attrs)
|
|
||||||
# |> Groups.create_member()
|
|
||||||
#
|
|
||||||
# member
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# test "list_members/0 returns all members" do
|
|
||||||
# member = member_fixture()
|
|
||||||
# assert Groups.list_members() == [member]
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# test "get_member!/1 returns the member with given id" do
|
|
||||||
# member = member_fixture()
|
|
||||||
# assert Groups.get_member!(member.id) == member
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# test "create_member/1 with valid data creates a member" do
|
|
||||||
# assert {:ok, %Member{} = member} = Groups.create_member(@valid_attrs)
|
|
||||||
# assert member.role == 42
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# test "create_member/1 with invalid data returns error changeset" do
|
|
||||||
# assert {:error, %Ecto.Changeset{}} = Groups.create_member(@invalid_attrs)
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# test "update_member/2 with valid data updates the member" do
|
|
||||||
# member = member_fixture()
|
|
||||||
# assert {:ok, member} = Groups.update_member(member, @update_attrs)
|
|
||||||
# assert %Member{} = member
|
|
||||||
# assert member.role == 43
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# test "update_member/2 with invalid data returns error changeset" do
|
|
||||||
# member = member_fixture()
|
|
||||||
# assert {:error, %Ecto.Changeset{}} = Groups.update_member(member, @invalid_attrs)
|
|
||||||
# assert member == Groups.get_member!(member.id)
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# test "delete_member/1 deletes the member" do
|
|
||||||
# member = member_fixture()
|
|
||||||
# assert {:ok, %Member{}} = Groups.delete_member(member)
|
|
||||||
# assert_raise Ecto.NoResultsError, fn -> Groups.get_member!(member.id) end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# test "change_member/1 returns a member changeset" do
|
|
||||||
# member = member_fixture()
|
|
||||||
# assert %Ecto.Changeset{} = Groups.change_member(member)
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# describe "requests" do
|
|
||||||
# alias Eventos.Groups.Request
|
|
||||||
#
|
|
||||||
# @valid_attrs %{state: 42}
|
|
||||||
# @update_attrs %{state: 43}
|
|
||||||
# @invalid_attrs %{state: nil}
|
|
||||||
#
|
|
||||||
# def request_fixture(attrs \\ %{}) do
|
|
||||||
# {:ok, request} =
|
|
||||||
# attrs
|
|
||||||
# |> Enum.into(@valid_attrs)
|
|
||||||
# |> Groups.create_request()
|
|
||||||
#
|
|
||||||
# request
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# test "list_requests/0 returns all requests" do
|
|
||||||
# request = request_fixture()
|
|
||||||
# assert Groups.list_requests() == [request]
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# test "get_request!/1 returns the request with given id" do
|
|
||||||
# request = request_fixture()
|
|
||||||
# assert Groups.get_request!(request.id) == request
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# test "create_request/1 with valid data creates a request" do
|
|
||||||
# assert {:ok, %Request{} = request} = Groups.create_request(@valid_attrs)
|
|
||||||
# assert request.state == 42
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# test "create_request/1 with invalid data returns error changeset" do
|
|
||||||
# assert {:error, %Ecto.Changeset{}} = Groups.create_request(@invalid_attrs)
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# test "update_request/2 with valid data updates the request" do
|
|
||||||
# request = request_fixture()
|
|
||||||
# assert {:ok, request} = Groups.update_request(request, @update_attrs)
|
|
||||||
# assert %Request{} = request
|
|
||||||
# assert request.state == 43
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# test "update_request/2 with invalid data returns error changeset" do
|
|
||||||
# request = request_fixture()
|
|
||||||
# assert {:error, %Ecto.Changeset{}} = Groups.update_request(request, @invalid_attrs)
|
|
||||||
# assert request == Groups.get_request!(request.id)
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# test "delete_request/1 deletes the request" do
|
|
||||||
# request = request_fixture()
|
|
||||||
# assert {:ok, %Request{}} = Groups.delete_request(request)
|
|
||||||
# assert_raise Ecto.NoResultsError, fn -> Groups.get_request!(request.id) end
|
|
||||||
# end
|
|
||||||
#
|
|
||||||
# test "change_request/1 returns a request changeset" do
|
|
||||||
# request = request_fixture()
|
|
||||||
# assert %Ecto.Changeset{} = Groups.change_request(request)
|
|
||||||
# end
|
|
||||||
# end
|
|
||||||
end
|
|
@ -6,19 +6,19 @@ defmodule Eventos.Factory do
|
|||||||
use ExMachina.Ecto, repo: Eventos.Repo
|
use ExMachina.Ecto, repo: Eventos.Repo
|
||||||
|
|
||||||
def user_factory do
|
def user_factory do
|
||||||
%Eventos.Accounts.User{
|
%Eventos.Actors.User{
|
||||||
password_hash: "Jane Smith",
|
password_hash: "Jane Smith",
|
||||||
email: sequence(:email, &"email-#{&1}@example.com"),
|
email: sequence(:email, &"email-#{&1}@example.com"),
|
||||||
role: 0,
|
role: 0,
|
||||||
account: build(:account)
|
actor: build(:actor)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def account_factory do
|
def actor_factory do
|
||||||
{:ok, {_, pubkey}} = RsaEx.generate_keypair("4096")
|
{:ok, {_, pubkey}} = RsaEx.generate_keypair("4096")
|
||||||
username = sequence("thomas")
|
username = sequence("thomas")
|
||||||
%Eventos.Accounts.Account{
|
%Eventos.Actors.Actor{
|
||||||
username: username,
|
preferred_username: username,
|
||||||
domain: nil,
|
domain: nil,
|
||||||
public_key: pubkey,
|
public_key: pubkey,
|
||||||
url: EventosWeb.Endpoint.url() <> "/@#{username}"
|
url: EventosWeb.Endpoint.url() <> "/@#{username}"
|
||||||
@ -46,7 +46,7 @@ defmodule Eventos.Factory do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def event_factory do
|
def event_factory do
|
||||||
account = build(:account)
|
actor = build(:actor)
|
||||||
slug = sequence("my-event")
|
slug = sequence("my-event")
|
||||||
|
|
||||||
%Eventos.Events.Event{
|
%Eventos.Events.Event{
|
||||||
@ -55,10 +55,10 @@ defmodule Eventos.Factory do
|
|||||||
description: "My desc",
|
description: "My desc",
|
||||||
begins_on: nil,
|
begins_on: nil,
|
||||||
ends_on: nil,
|
ends_on: nil,
|
||||||
organizer_account: account,
|
organizer_actor: actor,
|
||||||
category: build(:category),
|
category: build(:category),
|
||||||
address: build(:address),
|
address: build(:address),
|
||||||
url: EventosWeb.Endpoint.url() <> "/@" <> account.username <> "/" <> slug
|
url: EventosWeb.Endpoint.url() <> "/@" <> actor.username <> "/" <> slug
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -78,12 +78,13 @@ defmodule Eventos.Factory do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def group_factory do
|
def group_factory do
|
||||||
%Eventos.Groups.Group{
|
username = sequence("My Group")
|
||||||
title: sequence("My Group"),
|
%Eventos.Actors.Actor{
|
||||||
description: "My group",
|
preferred_username: username,
|
||||||
|
summary: "My group",
|
||||||
suspended: false,
|
suspended: false,
|
||||||
url: "https://",
|
url: EventosWeb.Endpoint.url() <> "/@#{username}",
|
||||||
address: build(:address)
|
type: "Group",
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user