File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
test/lib/code_corps/model Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -45,7 +45,7 @@ defmodule CodeCorps.GithubRepo do
4545 |> validate_inclusion ( :sync_state , sync_states ( ) )
4646 end
4747
48- defp sync_states do
48+ def sync_states do
4949 ~w{
5050 unsynced
5151 fetching_pull_requests errored_fetching_pull_requests
Original file line number Diff line number Diff line change @@ -25,6 +25,23 @@ defmodule CodeCorps.GithubRepoTest do
2525 end
2626 end
2727
28+ describe "update_sync_changeset/2" do
29+ test "with valid attributes" do
30+ GithubRepo . sync_states |> Enum . each ( fn state ->
31+ attrs = @ valid_attrs |> Map . put ( :sync_state , state )
32+ changeset = GithubRepo . update_sync_changeset ( % GithubRepo { } , attrs )
33+ assert changeset . valid?
34+ end )
35+ end
36+
37+ test "with invalid attributes" do
38+ attrs = @ valid_attrs |> Map . put ( :sync_state , "not_a_valid_sync_state" )
39+ changeset = GithubRepo . update_sync_changeset ( % GithubRepo { } , attrs )
40+ refute changeset . valid?
41+ assert changeset . errors [ :sync_state ] == { "is invalid" , [ validation: :inclusion ] }
42+ end
43+ end
44+
2845 test "deletes associated ProjectGithubRepo records when deleting GithubRepo" do
2946 github_repo = insert ( :github_repo )
3047 insert_pair ( :project_github_repo , github_repo: github_repo )
You can’t perform that action at this time.
0 commit comments