Fix publishing a new status (Fixes: #14)
parent
a27c030376
commit
33d6c68884
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 """
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue