From ca0712d0c65fe9aa313b7087fff7a8eccd6cb25a Mon Sep 17 00:00:00 2001 From: codevictory Date: Sun, 16 May 2021 20:15:55 +0300 Subject: [PATCH] Visitor table altered: bus -> shared (car). --- lib/runosaari/registration/visitor.ex | 6 +-- .../templates/page/privacy.html.eex | 2 +- .../templates/visitor/form.html.eex | 4 +- .../templates/visitor/index.html.eex | 4 +- .../templates/visitor/show.html.eex | 6 +-- .../20210516164418_change_bus_to_shared.exs | 10 +++++ test/runosaari/registration_test.exs | 40 ++++++++++++++++--- .../controllers/visitor_controller_test.exs | 6 +-- 8 files changed, 59 insertions(+), 19 deletions(-) create mode 100644 priv/repo/migrations/20210516164418_change_bus_to_shared.exs diff --git a/lib/runosaari/registration/visitor.ex b/lib/runosaari/registration/visitor.ex index 5d621f3..a699e93 100644 --- a/lib/runosaari/registration/visitor.ex +++ b/lib/runosaari/registration/visitor.ex @@ -4,7 +4,7 @@ defmodule Runosaari.Registration.Visitor do schema "visitors" do field :accom, :boolean, default: false - field :bus, :boolean, default: false + field :shared, :boolean, default: false field :date1, :boolean, default: false field :date2, :boolean, default: false field :date3, :boolean, default: false @@ -19,7 +19,7 @@ defmodule Runosaari.Registration.Visitor do @doc false def changeset(visitor, attrs) do visitor - |> cast(attrs, [:fname, :lname, :email, :tel, :date1, :date2, :date3, :bus, :accom]) - |> validate_required([:fname, :lname, :email, :tel, :date1, :date2, :date3, :bus, :accom]) + |> cast(attrs, [:fname, :lname, :email, :tel, :date1, :date2, :date3, :shared, :accom]) + |> validate_required([:fname, :lname, :email, :tel, :date1, :date2, :date3, :shared, :accom]) end end diff --git a/lib/runosaari_web/templates/page/privacy.html.eex b/lib/runosaari_web/templates/page/privacy.html.eex index 5072759..b3c30ff 100644 --- a/lib/runosaari_web/templates/page/privacy.html.eex +++ b/lib/runosaari_web/templates/page/privacy.html.eex @@ -40,7 +40,7 @@
  • henkilön nimi
  • yhteystiedot (sähköpostiosoite, puhelinnumero)
  • halukkuus osallistua tapahtumapäiviin 22.7. torstai, 23.7. perjantai ja/tai 24.7. lauantai
  • -
  • tarve bussikuljetukselle
  • +
  • halukkuus kimppakyyti järjestelylle
  • tarve majoitukselle
  • diff --git a/lib/runosaari_web/templates/visitor/form.html.eex b/lib/runosaari_web/templates/visitor/form.html.eex index 16b700c..4eec929 100644 --- a/lib/runosaari_web/templates/visitor/form.html.eex +++ b/lib/runosaari_web/templates/visitor/form.html.eex @@ -40,8 +40,8 @@ <%= label form, :date3, "Lauantai 24.7." %>
    - <%= checkbox form, :bus %> - <%= label form, :bus, "Olen kiinnostunut bussikuljetuksesta" %> + <%= checkbox form, :shared %> + <%= label form, :shared, "Olen kiinnostunut kimppakyydeistä (Turku-Livonsaari)" %>
    <%= checkbox form, :accom %> diff --git a/lib/runosaari_web/templates/visitor/index.html.eex b/lib/runosaari_web/templates/visitor/index.html.eex index a22238f..f3f70a4 100644 --- a/lib/runosaari_web/templates/visitor/index.html.eex +++ b/lib/runosaari_web/templates/visitor/index.html.eex @@ -11,7 +11,7 @@ Torstai Perjantai Lauantai - Bussi + Kimppakyyti Majoitus @@ -27,7 +27,7 @@ <%= visitor.date1 %> <%= visitor.date2 %> <%= visitor.date3 %> - <%= visitor.bus %> + <%= visitor.shared %> <%= visitor.accom %> diff --git a/lib/runosaari_web/templates/visitor/show.html.eex b/lib/runosaari_web/templates/visitor/show.html.eex index abf2256..3120226 100644 --- a/lib/runosaari_web/templates/visitor/show.html.eex +++ b/lib/runosaari_web/templates/visitor/show.html.eex @@ -39,12 +39,12 @@
  • - Bus: - <%= @visitor.bus %> + Kimppakyyti: + <%= @visitor.shared %>
  • - Accom: + Majoitus: <%= @visitor.accom %>
  • diff --git a/priv/repo/migrations/20210516164418_change_bus_to_shared.exs b/priv/repo/migrations/20210516164418_change_bus_to_shared.exs new file mode 100644 index 0000000..897021e --- /dev/null +++ b/priv/repo/migrations/20210516164418_change_bus_to_shared.exs @@ -0,0 +1,10 @@ +defmodule Runosaari.Repo.Migrations.ChangeBusToShared do + use Ecto.Migration + + def change do + alter table("visitors") do + remove :bus + add :shared, :boolean, default: false, null: false + end + end +end diff --git a/test/runosaari/registration_test.exs b/test/runosaari/registration_test.exs index a604b49..375a478 100644 --- a/test/runosaari/registration_test.exs +++ b/test/runosaari/registration_test.exs @@ -132,9 +132,39 @@ defmodule Runosaari.RegistrationTest do describe "visitors" do alias Runosaari.Registration.Visitor - @valid_attrs %{accom: true, bus: true, date1: true, date2: true, date3: true, email: "some email", fname: "some fname", lname: "some lname", tel: "some tel"} - @update_attrs %{accom: false, bus: false, date1: false, date2: false, date3: false, email: "some updated email", fname: "some updated fname", lname: "some updated lname", tel: "some updated tel"} - @invalid_attrs %{accom: nil, bus: nil, date1: nil, date2: nil, date3: nil, email: nil, fname: nil, lname: nil, tel: nil} + @valid_attrs %{ + accom: true, + shared: true, + date1: true, + date2: true, + date3: true, + email: "some email", + fname: "some fname", + lname: "some lname", + tel: "some tel" + } + @update_attrs %{ + accom: false, + shared: false, + date1: false, + date2: false, + date3: false, + email: "some updated email", + fname: "some updated fname", + lname: "some updated lname", + tel: "some updated tel" + } + @invalid_attrs %{ + accom: nil, + shared: nil, + date1: nil, + date2: nil, + date3: nil, + email: nil, + fname: nil, + lname: nil, + tel: nil + } def visitor_fixture(attrs \\ %{}) do {:ok, visitor} = @@ -158,7 +188,7 @@ defmodule Runosaari.RegistrationTest do test "create_visitor/1 with valid data creates a visitor" do assert {:ok, %Visitor{} = visitor} = Registration.create_visitor(@valid_attrs) assert visitor.accom == true - assert visitor.bus == true + assert visitor.shared == true assert visitor.date1 == true assert visitor.date2 == true assert visitor.date3 == true @@ -176,7 +206,7 @@ defmodule Runosaari.RegistrationTest do visitor = visitor_fixture() assert {:ok, %Visitor{} = visitor} = Registration.update_visitor(visitor, @update_attrs) assert visitor.accom == false - assert visitor.bus == false + assert visitor.shared == false assert visitor.date1 == false assert visitor.date2 == false assert visitor.date3 == false diff --git a/test/runosaari_web/controllers/visitor_controller_test.exs b/test/runosaari_web/controllers/visitor_controller_test.exs index b865015..89ed9b6 100644 --- a/test/runosaari_web/controllers/visitor_controller_test.exs +++ b/test/runosaari_web/controllers/visitor_controller_test.exs @@ -5,7 +5,7 @@ defmodule RunosaariWeb.VisitorControllerTest do @create_attrs %{ accom: true, - bus: true, + shared: true, date1: true, date2: true, date3: true, @@ -16,7 +16,7 @@ defmodule RunosaariWeb.VisitorControllerTest do } @update_attrs %{ accom: false, - bus: false, + shared: false, date1: false, date2: false, date3: false, @@ -27,7 +27,7 @@ defmodule RunosaariWeb.VisitorControllerTest do } @invalid_attrs %{ accom: nil, - bus: nil, + shared: nil, date1: nil, date2: nil, date3: nil,