File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -62,6 +62,21 @@ defmodule CodeCorps.ProjectTest do
6262 changeset = Project . create_changeset ( % Project { } , % { organization_id: 1 } )
6363 assert { :ok , 1 } == changeset |> fetch_change ( :organization_id )
6464 end
65+
66+ test "associates the ordered default task lists to the project" do
67+ organization = insert ( :organization )
68+ changeset = Project . create_changeset (
69+ % Project { } ,
70+ % { organization_id: organization . id , title: "Title" }
71+ )
72+
73+ { _ , project } = Repo . insert ( changeset )
74+
75+ task_list_orders = for task_list <- project . task_lists , do: task_list . order
76+
77+ assert Enum . all? ( task_list_orders ) , "some of the orders are not set (nil)"
78+ assert task_list_orders == Enum . sort ( task_list_orders ) , "task lists order does not correspond to their position"
79+ end
6580 end
6681
6782 describe "update_changeset/2" do
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ defmodule CodeCorps.TaskList do
22 use CodeCorps.Web , :model
33 import EctoOrdered
44
5+ alias CodeCorps.TaskList
6+
57 schema "task_lists" do
68 field :inbox , :boolean , default: false
79 field :name , :string
@@ -33,7 +35,7 @@ defmodule CodeCorps.TaskList do
3335 name: "Done" ,
3436 position: 4
3537 }
36- ]
38+ ] |> Enum . map ( fn ( params ) -> changeset ( % TaskList { } , params ) end )
3739 end
3840
3941 @ doc """
You can’t perform that action at this time.
0 commit comments