proposal.test.exs (2048B)
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.Proposal do 19 use ZenflowsTest.Help.EctoCase, async: true 20 21 alias Zenflows.VF.Proposal 22 23 setup do 24 %{params: %{ 25 name: Factory.str("name"), 26 has_beginning: DateTime.utc_now(), 27 has_end: DateTime.utc_now(), 28 unit_based: Factory.bool(), 29 note: Factory.str("note"), 30 eligible_location_id: Factory.build(:spatial_thing).id, 31 }} 32 end 33 34 test "create Proposal", %{params: params} do 35 assert {:ok, %Proposal{} = prop} = 36 params 37 |> Proposal.changeset() 38 |> Repo.insert() 39 40 assert prop.name == params.name 41 assert prop.has_beginning == params.has_beginning 42 assert prop.has_end == params.has_end 43 assert prop.unit_based == params.unit_based 44 assert prop.note == params.note 45 assert prop.eligible_location_id == params.eligible_location_id 46 end 47 48 test "update Proposal", %{params: params} do 49 assert {:ok, %Proposal{} = prop} = 50 :proposal 51 |> Factory.insert!() 52 |> Proposal.changeset(params) 53 |> Repo.update() 54 55 assert prop.name == params.name 56 assert prop.has_beginning == params.has_beginning 57 assert prop.has_end == params.has_end 58 assert prop.unit_based == params.unit_based 59 assert prop.note == params.note 60 assert prop.eligible_location_id == params.eligible_location_id 61 end 62 end