Fix publishing a new status (Fixes: #14)

master
Milton Mazzarri 2019-03-20 09:48:37 -05:00
parent a27c030376
commit 33d6c68884
No known key found for this signature in database
GPG Key ID: 9F4193F2B5A558FE
4 changed files with 12 additions and 4 deletions

View File

@ -152,7 +152,7 @@ defmodule Hunter.Api.HTTPClient do
end
def create_status(conn, status, options) do
body = Keyword.put(options, :status, status)
body = options |> Keyword.put(:status, status) |> Map.new()
"/api/v1/statuses"
|> process_url(conn)
@ -352,7 +352,7 @@ defmodule Hunter.Api.HTTPClient do
defp get_headers(nil), do: []
defp get_headers(%Hunter.Client{bearer_token: token}) do
[{"Authorization", "Bearer #{token}"}]
[{:Authorization, "Bearer #{token}"}]
end
defp get_headers(headers) when is_list(headers), do: headers

View File

@ -69,7 +69,7 @@ defmodule Hunter.Application do
website \\ nil,
options \\ []
) do
save? = Keyword.get(options, :save?, false)
{save?, options} = Keyword.pop(options, :save?, false)
base_url = Keyword.get(options, :api_base_url, Config.api_base_url())
app = Config.hunter_api().create_app(client_name, redirect_uris, scopes, website, base_url)

View File

@ -103,7 +103,7 @@ defmodule Hunter.Status do
"""
@spec create_status(Hunter.Client.t(), String.t(), Keyword.t()) :: Hunter.Status.t() | no_return
def create_status(conn, status, options \\ []) do
Config.hunter_api().create_status(conn, status, Map.new(options))
Config.hunter_api().create_status(conn, status, options)
end
@doc """

View File

@ -24,4 +24,12 @@ defmodule Hunter.StatusTest do
assert [timeline | []] = Status.public_timeline(@conn, limit: 1, local: true)
end
test "should allow to create new status" do
expect(Hunter.ApiMock, :create_status, fn _conn, status, _opts ->
%Hunter.Status{content: status}
end)
assert %Hunter.Status{content: "hello"} = Status.create_status(@conn, "hello")
end
end