This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
defmodule DecentralisedBookIndex.Metadata.AuthorRolesTest do
|
||||
use DecentralisedBookIndex.DataCase, async: true
|
||||
|
||||
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")
|
||||
|
||||
assert {:ok, author_role} = Metadata.create_author_role(author.id, 1, "role")
|
||||
|
||||
{:ok, author_role} =
|
||||
author_role
|
||||
|> Ash.load(:author)
|
||||
|
||||
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")
|
||||
|
||||
{:ok, author_role} = Metadata.create_author_role(author.id, 1, "")
|
||||
|
||||
refute author_role.role
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user