Update the JSON API endpoint to /authors for Author.
This commit is contained in:
@@ -14,7 +14,7 @@ defmodule DecentralisedBookIndex.Metadata do
|
|||||||
related :publisher, :read, primary?: true
|
related :publisher, :read, primary?: true
|
||||||
end
|
end
|
||||||
|
|
||||||
base_route "/author", Metadata.Author do
|
base_route "/authors", Metadata.Author do
|
||||||
get :read
|
get :read
|
||||||
index :search
|
index :search
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ defmodule DecentralisedBookIndex.SyncTasks.SyncAuthorsTask do
|
|||||||
alias DecentralisedBookIndex.Metadata.DBIServer
|
alias DecentralisedBookIndex.Metadata.DBIServer
|
||||||
|
|
||||||
def sync(%DBIServer{} = server) do
|
def sync(%DBIServer{} = server) do
|
||||||
url = "#{server.url}/api/v1/json/author"
|
url = "#{server.url}/api/v1/json/authors"
|
||||||
FetchJsons.get(url, sync_author_closure(server))
|
FetchJsons.get(url, sync_author_closure(server))
|
||||||
|
|
||||||
server
|
server
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ defmodule DecentralisedBookIndex.Sync.ApiClients.FetchJsonTest do
|
|||||||
test "get an author" do
|
test "get an author" do
|
||||||
{:ok, author} = Metadata.create_author("Author", "An description")
|
{:ok, author} = Metadata.create_author("Author", "An description")
|
||||||
|
|
||||||
assert {:ok, data} = FetchJson.get("#{@test_server_endpoint}/api/v1/json/author/#{author.id}")
|
assert {:ok, data} = FetchJson.get("#{@test_server_endpoint}/api/v1/json/authors/#{author.id}")
|
||||||
assert data["data"]["id"] == author.id
|
assert data["data"]["id"] == author.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ defmodule DecentralisedBookIndex.Sync.ApiClients.FetchJsonsTest do
|
|||||||
Metadata.create_author!("Author#{number}", "An description#{number}")
|
Metadata.create_author!("Author#{number}", "An description#{number}")
|
||||||
end
|
end
|
||||||
|
|
||||||
assert {:ok, records} = FetchJsons.get("#{@test_server_endpoint}/api/v1/json/author")
|
assert {:ok, records} = FetchJsons.get("#{@test_server_endpoint}/api/v1/json/authors")
|
||||||
assert length(records) == 11
|
assert length(records) == 11
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ defmodule DecentralisedBookIndex.Sync.ApiClients.FetchJsonsTest do
|
|||||||
end
|
end
|
||||||
|
|
||||||
assert {:ok, records} =
|
assert {:ok, records} =
|
||||||
FetchJsons.get("#{@test_server_endpoint}/api/v1/json/author", get_author_names)
|
FetchJsons.get("#{@test_server_endpoint}/api/v1/json/authors", get_author_names)
|
||||||
|
|
||||||
assert length(records) == 11
|
assert length(records) == 11
|
||||||
assert Enum.all?(records, fn author -> String.contains?(author, "Author") end)
|
assert Enum.all?(records, fn author -> String.contains?(author, "Author") end)
|
||||||
|
|||||||
Reference in New Issue
Block a user