diff --git a/lib/radiator/accounts.ex b/lib/radiator/accounts.ex index 2ea5f3ad..7ed4fa82 100644 --- a/lib/radiator/accounts.ex +++ b/lib/radiator/accounts.ex @@ -313,7 +313,7 @@ defmodule Radiator.Accounts do %{data: data} = service -> data = Map.update!(data, :collection_mappings, fn mappings -> - Map.put(mappings, show_id, collection_id) + Map.put(mappings, show_id_to_collection_id(show_id), collection_id) end) |> Map.from_struct() @@ -323,6 +323,9 @@ defmodule Radiator.Accounts do end end + defp show_id_to_collection_id(show_id) when is_integer(show_id), do: Integer.to_string(show_id) + defp show_id_to_collection_id(show_id), do: show_id + ## Session @doc """ diff --git a/test/radiator/accounts_test.exs b/test/radiator/accounts_test.exs index ebcdcf3a..4e1ee632 100644 --- a/test/radiator/accounts_test.exs +++ b/test/radiator/accounts_test.exs @@ -711,5 +711,38 @@ defmodule Radiator.AccountsTest do service = Accounts.get_raindrop_tokens(web_service.user_id) assert service.data.collection_mappings == %{"#{show.id}" => 42} end + + test "can add multiple shows", %{ + web_service: web_service, + show: show + } do + Accounts.connect_show_with_raindrop(web_service.user_id, show.id, 42) + + second_show = PodcastFixtures.show_fixture() + third_show = PodcastFixtures.show_fixture() + + Accounts.connect_show_with_raindrop(web_service.user_id, second_show.id, 23) + Accounts.connect_show_with_raindrop(web_service.user_id, third_show.id, 666) + + service = Accounts.get_raindrop_tokens(web_service.user_id) + + assert service.data.collection_mappings == %{ + "#{show.id}" => 42, + "#{second_show.id}" => 23, + "#{third_show.id}" => 666 + } + end + + test "can override show", %{ + web_service: web_service, + show: show + } do + Accounts.connect_show_with_raindrop(web_service.user_id, show.id, 42) + + Accounts.connect_show_with_raindrop(web_service.user_id, show.id, 23) + service = Accounts.get_raindrop_tokens(web_service.user_id) + + assert service.data.collection_mappings == %{"#{show.id}" => 23} + end end end