proposed_to.test.exs (1631B)
1 # Zenflows is designed to implement the Valueflows vocabulary, 2 # written and maintained by srfsh <info@dyne.org>. 3 # Copyright (C) 2021-2023 Dyne.org foundation <foundation@dyne.org>. 4 # 5 # This program is free software: you can redistribute it and/or modify 6 # it under the terms of the GNU Affero General Public License as published by 7 # the Free Software Foundation, either version 3 of the License, or 8 # (at your option) any later version. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 # GNU Affero General Public License for more details. 14 # 15 # You should have received a copy of the GNU Affero General Public License 16 # along with this program. If not, see <https://www.gnu.org/licenses/>. 17 18 defmodule ZenflowsTest.VF.ProposedTo do 19 use ZenflowsTest.Help.EctoCase, async: true 20 21 alias Zenflows.VF.ProposedTo 22 23 setup do 24 %{params: %{ 25 proposed_to_id: Factory.insert!(:agent).id, 26 proposed_id: Factory.insert!(:proposal).id, 27 }} 28 end 29 30 test "create ProposedTo", %{params: params} do 31 assert {:ok, %ProposedTo{} = prop_to} = 32 params 33 |> ProposedTo.changeset() 34 |> Repo.insert() 35 36 assert prop_to.proposed_to_id == params.proposed_to_id 37 assert prop_to.proposed_id == params.proposed_id 38 end 39 40 test "update ProposedTo", %{params: params} do 41 assert {:ok, %ProposedTo{} = prop_to} = 42 :proposed_to 43 |> Factory.insert!() 44 |> ProposedTo.changeset(params) 45 |> Repo.update() 46 47 assert prop_to.proposed_to_id == params.proposed_to_id 48 assert prop_to.proposed_id == params.proposed_id 49 end 50 end