Skip to content

Commit 8d572e6

Browse files
committed
Corrected fields type and cleanup
1 parent 95a2974 commit 8d572e6

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

lib/zexbox/jira_client.ex

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ defmodule Zexbox.JiraClient do
4444

4545
client = build_client()
4646

47-
case jira_post(client, "/rest/api/3/search/jql", %{
48-
"jql" => query,
49-
"maxResults" => 50,
50-
"fields" => ["key", "id", "self", "status", "summary"]
51-
}) do
47+
case jira_get(client, "/rest/api/3/issue/search",
48+
jql: query,
49+
maxResults: 50,
50+
fields: ["key", "id", "self", "status", "summary"]
51+
) do
5252
{:ok, body} ->
5353
base_url = config(:jira_base_url, nil)
5454
issues = Map.get(body, "issues", [])
@@ -136,8 +136,6 @@ defmodule Zexbox.JiraClient do
136136
jira_post(client, "/rest/api/3/issue/#{issue_key}/comment", %{"body" => comment})
137137
end
138138

139-
# --- Private helpers ---
140-
141139
defp find_transition(transitions, status_name) do
142140
case Enum.find(transitions, fn t ->
143141
to_name = get_in(t, ["to", "name"]) || ""

test/zexbox/jira_client_test.exs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ defmodule Zexbox.JiraClientTest do
3636
describe "search_latest_issues/2" do
3737
test_with_mock "returns issues with url keys added on success", Req,
3838
new: fn _opts -> :mock_client end,
39-
post: fn :mock_client, _opts ->
39+
get: fn :mock_client, _opts ->
4040
{:ok,
4141
%{
4242
status: 200,
@@ -58,15 +58,15 @@ defmodule Zexbox.JiraClientTest do
5858

5959
test_with_mock "returns empty list when no issues found", Req,
6060
new: fn _opts -> :mock_client end,
61-
post: fn :mock_client, _opts ->
61+
get: fn :mock_client, _opts ->
6262
{:ok, %{status: 200, body: %{"issues" => []}}}
6363
end do
6464
assert {:ok, []} = JiraClient.search_latest_issues("status = Open")
6565
end
6666

6767
test_with_mock "returns error on non-2xx response", Req,
6868
new: fn _opts -> :mock_client end,
69-
post: fn :mock_client, _opts ->
69+
get: fn :mock_client, _opts ->
7070
{:ok, %{status: 401, body: %{"message" => "Unauthorized"}}}
7171
end do
7272
assert {:error, reason} = JiraClient.search_latest_issues("status = Open")
@@ -75,7 +75,7 @@ defmodule Zexbox.JiraClientTest do
7575

7676
test_with_mock "returns error on request failure", Req,
7777
new: fn _opts -> :mock_client end,
78-
post: fn :mock_client, _opts ->
78+
get: fn :mock_client, _opts ->
7979
{:error, %{reason: :econnrefused}}
8080
end do
8181
assert {:error, _reason} = JiraClient.search_latest_issues("status = Open")

0 commit comments

Comments
 (0)