defmodule ToweropsWeb.Plugs.DetectEUUserTest do use ToweropsWeb.ConnCase, async: true alias ToweropsWeb.Plugs.DetectEUUser describe "call/2" do test "requires cookie consent on localhost", %{conn: conn} do conn = conn |> init_test_session(%{}) |> Map.put(:host, "localhost") |> DetectEUUser.call([]) assert conn.assigns.requires_cookie_consent == true end test "does not require consent when consent cookie is present", %{conn: conn} do conn = conn |> init_test_session(%{}) |> Map.put(:host, "localhost") |> Plug.Conn.put_req_header("cookie", "cookie_consent=accepted") |> DetectEUUser.call([]) assert conn.assigns.requires_cookie_consent == false end end end