diff --git a/lib/radiator/outline.ex b/lib/radiator/outline.ex index bfe9b8a2..4493b062 100644 --- a/lib/radiator/outline.ex +++ b/lib/radiator/outline.ex @@ -212,7 +212,8 @@ defmodule Radiator.Outline do content: content, parent_id: binaray_uuid_to_ecto_uuid(parent_id), prev_id: binaray_uuid_to_ecto_uuid(prev_id), - level: level + level: level, + episode_id: episode_id } end) diff --git a/test/radiator/outline_test.exs b/test/radiator/outline_test.exs index b3b45abe..7188404c 100644 --- a/test/radiator/outline_test.exs +++ b/test/radiator/outline_test.exs @@ -349,6 +349,34 @@ defmodule Radiator.OutlineTest do node.level end) end + + test "associated the correct level", %{ + node_1: node_1, + node_2: node_2, + node_3: node_3, + node_4: node_4, + node_5: node_5, + node_6: node_6, + nested_node_1: nested_node_1, + nested_node_2: nested_node_2, + parent_node: parent_node + } do + {:ok, tree} = Outline.get_node_tree(parent_node.episode_id) + assert_level_for_node(tree, parent_node, 0) + assert_level_for_node(tree, node_1, 1) + assert_level_for_node(tree, node_2, 1) + assert_level_for_node(tree, node_3, 1) + assert_level_for_node(tree, node_4, 1) + assert_level_for_node(tree, node_5, 1) + assert_level_for_node(tree, node_6, 1) + assert_level_for_node(tree, nested_node_1, 2) + assert_level_for_node(tree, nested_node_2, 2) + end + end + + defp assert_level_for_node(tree, node, level) do + node = Enum.filter(tree, fn n -> n.uuid == node.uuid end) |> List.first() + assert node.level == level end defp complex_node_fixture(_) do