Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Guarino committed Nov 13, 2017
1 parent c3790a2 commit 79b2de5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/cereal/builders/entity_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ defmodule Cereal.Builders.EntityTest do
assert Entity.build(context) == expected
end

test "it will conditionally drop excluded fields", %{context: context} do
data = %TestModel.User{id: 1, name: "Dummy"}
opts = %{excludes: [user: "name"]}
context = %{context | data: data, serializer: UserSerializer, opts: opts}
expected = %Entity{id: 1, type: "user", attributes: %{not_an_attr: true}}

assert Entity.build(context) == expected
end

test "it will build a deeply nested entity", %{context: context} do
user = %TestModel.User{id: 1, name: "Johnny User"}
comments = [%TestModel.Comment{id: 1, user: user, text: "A comment"}]
Expand Down

0 comments on commit 79b2de5

Please sign in to comment.