diff --git a/lib/mix/tasks/hex.publish.ex b/lib/mix/tasks/hex.publish.ex index 6159b077..30335b8c 100644 --- a/lib/mix/tasks/hex.publish.ex +++ b/lib/mix/tasks/hex.publish.ex @@ -290,7 +290,7 @@ defmodule Mix.Tasks.Hex.Publish do end) Hex.Shell.info("") - owner_prompt_selection(MapSet.new(organizations)) + owner_prompt_selection(Map.new(organizations)) end defp owner_prompt_selection(organizations) do diff --git a/test/mix/tasks/hex.publish_test.exs b/test/mix/tasks/hex.publish_test.exs index 9122feef..cf0cb2b0 100644 --- a/test/mix/tasks/hex.publish_test.exs +++ b/test/mix/tasks/hex.publish_test.exs @@ -431,6 +431,36 @@ defmodule Mix.Tasks.Hex.PublishTest do purge([ReleaseMeta.MixProject]) end + test "create with organization prompt" do + Process.put(:hex_test_app_name, :publish_with_organization_prompt) + Mix.Project.push(ReleaseSimple.MixProject) + + in_tmp(fn -> + set_home_tmp() + setup_auth("user", "hunter42") + File.write!("myfile.txt", "hello") + + send(self(), {:mix_shell_input, :prompt, "2"}) + send(self(), {:mix_shell_input, :yes?, true}) + send(self(), {:mix_shell_input, :prompt, "hunter42"}) + + Mix.Tasks.Hex.Publish.run(["package", "--no-progress", "--replace"]) + + assert_received {:mix_shell, :info, + ["You are a member of one or multiple organizations. " <> _]} + + assert_received {:mix_shell, :info, ["Publishing package using http://" <> _]} + assert_received {:mix_shell, :info, ["Transferring ownership to testorg..."]} + + assert {:ok, {200, body, _headers}} = + Hex.API.Package.get("hexpm", "publish_with_organization_prompt") + + assert "testorg" in Enum.map(body["owners"], & &1["username"]) + end) + after + purge([ReleaseSimple.MixProject]) + end + test "create package with :organization config" do Process.put(:hex_test_app_name, :publish_with_org_config) Mix.Project.push(ReleaseRepo.MixProject) diff --git a/test/support/case.ex b/test/support/case.ex index 083f677f..7e64a563 100644 --- a/test/support/case.ex +++ b/test/support/case.ex @@ -394,7 +394,7 @@ defmodule HexTest.Case do |> Plug.Conn.resp(201, Hex.Utils.safe_serialize_erlang(body)) %Plug.Conn{method: "GET", request_path: "/api/users/me"} -> - body = %{"organizations" => %{}} + body = %{"organizations" => [%{"name" => repo}]} conn |> Plug.Conn.put_resp_header("content-type", "application/vnd.hex+erlang")