Skip to content

Commit

Permalink
Add model tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joshsmith committed Nov 15, 2017
1 parent 81c59bf commit d0ca9a4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/lib/code_corps/model/github_repo_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ defmodule CodeCorps.GithubRepoTest do
end
end

describe "update_changeset/2" do
test "when project added" do
attrs = @valid_attrs |> Map.put(:project_id, 1)
changeset = GithubRepo.update_changeset(%GithubRepo{}, attrs)
assert changeset.valid?
end

test "when project removed" do
attrs = @valid_attrs |> Map.put(:project_id, nil)
changeset = GithubRepo.update_changeset(%GithubRepo{sync_state: "synced"}, attrs)
assert changeset.valid?
assert changeset.changes[:sync_state] == "unsynced"
end
end

describe "update_sync_changeset/2" do
test "with valid attributes" do
GithubRepo.sync_states |> Enum.each(fn state ->
Expand Down

0 comments on commit d0ca9a4

Please sign in to comment.