-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
72 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
priv/repo/migrations/20200421121617_remove_timestamp_captures_tags.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
defmodule AppApi.Repo.Migrations.RemoveTimestampCapturesTags do | ||
use Ecto.Migration | ||
|
||
def change do | ||
alter table(:captures_tags) do | ||
remove :inserted_at | ||
remove :updated_at | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
defmodule AppApi.TagsTest do | ||
use AppApi.DataCase | ||
|
||
alias AppApi.Tags | ||
|
||
describe "tags" do | ||
alias AppApi.Tags.Tag | ||
|
||
@valid_attrs %{id_person: 42, text: "tag1"} | ||
@invalid_attrs %{id_person: 42, text: ""} | ||
|
||
def tag_fixture(attrs \\ %{}) do | ||
attrs | ||
|> Enum.into(@valid_attrs) | ||
|> Tags.create_tag() | ||
end | ||
|
||
test "get_default_tags/0 returns all tags" do | ||
tag = tag_fixture(%{id_person: nil}) | ||
assert Tags.get_default_tags() == [tag] | ||
end | ||
|
||
test "get_tags_by_id_person/1 returns all tags for a person" do | ||
tag1 = tag_fixture(%{text: "a", id_person: 32}) | ||
tag2 = tag_fixture(%{text: "b", id_person: 32}) | ||
assert Tags.get_tags_by_id_person(32) == [tag1, tag2] # order by tag name | ||
end | ||
|
||
test "create tag with wrong attr return an error" do | ||
assert catch_error(Tags.create_tag(@invalid_attrs)) | ||
end | ||
|
||
test "create_tag/1 with valid data creates a tag" do | ||
assert %Tag{} = tag = Tags.create_tag(@valid_attrs) | ||
assert tag.id_person == 42 | ||
assert tag.text == "tag1" | ||
end | ||
end | ||
end |