From 7d6f99505a0af4bdc5030c8c15877d6c125f73eb Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Sun, 15 Jun 2025 07:41:52 +0200 Subject: [PATCH] fix unit tests for new message type --- LICENSE | 21 +++++++++++++++++++++ mix.exs | 1 + test/scopes_web/live/message_live_test.exs | 12 +++++++----- test/support/fixtures/core_fixtures.ex | 2 +- 4 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ac7c3da --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (C) 2024 team@cyberconcepts.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/mix.exs b/mix.exs index 62570a6..0012073 100644 --- a/mix.exs +++ b/mix.exs @@ -9,6 +9,7 @@ defmodule Scopes.MixProject do elixirc_paths: elixirc_paths(Mix.env()), start_permanent: Mix.env() == :prod, aliases: aliases(), + consolidate_protocols: Mix.env() != :test, deps: deps() ] end diff --git a/test/scopes_web/live/message_live_test.exs b/test/scopes_web/live/message_live_test.exs index 7bf58fc..6523c85 100644 --- a/test/scopes_web/live/message_live_test.exs +++ b/test/scopes_web/live/message_live_test.exs @@ -4,9 +4,11 @@ defmodule ScopesWeb.MessageLiveTest do import Phoenix.LiveViewTest import Scopes.CoreFixtures - @create_attrs %{data: %{}, domain: "some domain", item: "some item", action: "some action", class: "some class"} - @update_attrs %{data: %{}, domain: "some updated domain", item: "some updated item", action: "some updated action", class: "some updated class"} - @invalid_attrs %{data: nil, domain: nil, item: nil, action: nil, class: nil} + defimpl Phoenix.HTML.Safe, for: Map, do: (def to_iodata(%{}), do: "{}") + + @create_attrs %{domain: "some domain", item: "some item", action: "some action", class: "some class"} + @update_attrs %{domain: "some updated domain", item: "some updated item", action: "some updated action", class: "some updated class"} + @invalid_attrs %{domain: nil, item: nil, action: nil, class: nil} defp create_message(_) do message = message_fixture() @@ -14,7 +16,7 @@ defmodule ScopesWeb.MessageLiveTest do end describe "Index" do - setup [:create_message] + setup [:create_message, :register_and_log_in_user] test "lists all messages", %{conn: conn, message: message} do {:ok, _index_live, html} = live(conn, ~p"/messages") @@ -78,7 +80,7 @@ defmodule ScopesWeb.MessageLiveTest do end describe "Show" do - setup [:create_message] + setup [:create_message, :register_and_log_in_user] test "displays message", %{conn: conn, message: message} do {:ok, _show_live, html} = live(conn, ~p"/messages/#{message}") diff --git a/test/support/fixtures/core_fixtures.ex b/test/support/fixtures/core_fixtures.ex index dffc5b8..069544d 100644 --- a/test/support/fixtures/core_fixtures.ex +++ b/test/support/fixtures/core_fixtures.ex @@ -13,7 +13,7 @@ defmodule Scopes.CoreFixtures do |> Enum.into(%{ action: "some action", class: "some class", - data: %{}, + #data: %{}, domain: "some domain", item: "some item" })