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
|
||||
end
|
||||
|
||||
base_route "/author", Metadata.Author do
|
||||
base_route "/authors", Metadata.Author do
|
||||
get :read
|
||||
index :search
|
||||
end
|
||||
|
||||
@@ -6,7 +6,7 @@ defmodule DecentralisedBookIndex.SyncTasks.SyncAuthorsTask do
|
||||
alias DecentralisedBookIndex.Metadata.DBIServer
|
||||
|
||||
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))
|
||||
|
||||
server
|
||||
|
||||
@@ -11,7 +11,7 @@ defmodule DecentralisedBookIndex.Sync.ApiClients.FetchJsonTest do
|
||||
test "get an author" do
|
||||
{: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
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ defmodule DecentralisedBookIndex.Sync.ApiClients.FetchJsonsTest do
|
||||
Metadata.create_author!("Author#{number}", "An description#{number}")
|
||||
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
|
||||
end
|
||||
|
||||
@@ -28,7 +28,7 @@ defmodule DecentralisedBookIndex.Sync.ApiClients.FetchJsonsTest do
|
||||
end
|
||||
|
||||
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 Enum.all?(records, fn author -> String.contains?(author, "Author") end)
|
||||
|
||||
Reference in New Issue
Block a user