Skip to content

Commit 898ef58

Browse files
committed
Reject nil path
1 parent 788ad9c commit 898ef58

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/ltree.ex

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ defmodule Hierarch.LTree do
7474
"""
7575
def concat(one, another) do
7676
[one, another]
77-
|> Enum.reject(fn(label) -> label == "" end)
77+
|> Enum.reject(fn(label) -> label == nil or label == "" end)
7878
|> join()
7979
end
8080
end

test/hierarch_test.exs

+7
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ defmodule HierarchTest do
2727
assert catelog.path == parent.id
2828
end
2929

30+
test "builds a child of the root" do
31+
parent = %Catelog{name: "Top", path: nil} |> Repo.insert!
32+
catelog = Catelog.build_child_of(parent, %{name: "Top.Science"})
33+
34+
assert catelog.path == parent.id
35+
end
36+
3037
test "builds a root" do
3138
catelog = Catelog.build_child_of(nil, %{name: "Top.Science"})
3239

0 commit comments

Comments
 (0)