Add policies for AuthorRole resource.
This commit is contained in:
@@ -3,11 +3,16 @@ defmodule DecentralisedBookIndex.Metadata.AuthorRolesTest do
|
||||
|
||||
alias DecentralisedBookIndex.Metadata
|
||||
|
||||
describe "create action" do
|
||||
test "an author's role must belongs to an author" do
|
||||
{:ok, author} = Metadata.create_author("Author", "An description")
|
||||
setup do
|
||||
user = generate(user(role: :moderator))
|
||||
%{user: user}
|
||||
end
|
||||
|
||||
assert {:ok, author_role} = Metadata.create_author_role(author.id, 1, "role")
|
||||
describe "create action" do
|
||||
test "an author's role must belongs to an author", %{user: user} do
|
||||
{:ok, author} = Metadata.create_author("Author", "An description", nil, nil, actor: user)
|
||||
|
||||
assert {:ok, author_role} = Metadata.create_author_role(author.id, 1, "role", actor: user)
|
||||
|
||||
{:ok, author_role} =
|
||||
author_role
|
||||
@@ -16,22 +21,22 @@ defmodule DecentralisedBookIndex.Metadata.AuthorRolesTest do
|
||||
assert author.id == author_role.author_id
|
||||
end
|
||||
|
||||
test "an author's role can be blank" do
|
||||
{:ok, author} = Metadata.create_author("Author", "An description")
|
||||
test "an author's role can be blank", %{user: user} do
|
||||
{:ok, author} = Metadata.create_author("Author", "An description", nil, nil, actor: user)
|
||||
|
||||
{:ok, author_role} = Metadata.create_author_role(author.id, 1, "")
|
||||
{:ok, author_role} = Metadata.create_author_role(author.id, 1, "", actor: user)
|
||||
|
||||
refute author_role.role
|
||||
end
|
||||
end
|
||||
|
||||
describe "author's avatar image" do
|
||||
test "update avatar image" do
|
||||
test "update avatar image", %{user: user} do
|
||||
avatar_url = "/images/avatar.avif"
|
||||
|
||||
{:ok, author} = Metadata.create_author("Author", "An description")
|
||||
{:ok, author} = Metadata.create_author("Author", "An description", nil, nil, actor: user)
|
||||
|
||||
assert {:ok, author} = Metadata.assign_author_avatar_image(author, avatar_url)
|
||||
assert {:ok, author} = Metadata.assign_author_avatar_image(author, avatar_url, actor: user)
|
||||
|
||||
assert author.avatar_url == avatar_url
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user