From 4c9b1154d788ef2ca326a5da6af24f9e06f4ffcb Mon Sep 17 00:00:00 2001 From: Lily Barrett Date: Thu, 28 May 2026 15:58:34 -0400 Subject: [PATCH 1/3] WIP set up flag for Smartling integration work --- config/dev.exs | 11 +++ config/test.exs | 12 +++ .../plugs/put_flags_in_assigns_hook.ex | 24 +++++ .../plugs/put_flags_in_session_plug.ex | 30 +++++++ lib/dotcom_web/router.ex | 89 ++++++++++++------- mix.exs | 2 +- .../plugs/put_flags_in_session_plug_test.exs | 31 +++++++ 7 files changed, 165 insertions(+), 34 deletions(-) create mode 100644 lib/dotcom_web/plugs/put_flags_in_assigns_hook.ex create mode 100644 lib/dotcom_web/plugs/put_flags_in_session_plug.ex create mode 100644 test/dotcom_web/plugs/put_flags_in_session_plug_test.exs diff --git a/config/dev.exs b/config/dev.exs index 6d349ddf56..4f21887dcf 100644 --- a/config/dev.exs +++ b/config/dev.exs @@ -37,3 +37,14 @@ config :phoenix_live_view, # Initialize plugs at runtime for faster development compilation config :phoenix, :plug_init_mode, :runtime + +config :laboratory, + features: [ + {:use_smartling_translations, "Smartling translations", + "Uses Smartling's translation workflows"} + ], + cookie: [ + # one month, + max_age: 3600 * 24 * 30, + http_only: true + ] diff --git a/config/test.exs b/config/test.exs index a8bb820a96..acd2dcb8bd 100644 --- a/config/test.exs +++ b/config/test.exs @@ -66,3 +66,15 @@ config :recaptcha, http_client: Recaptcha.Http.MockClient config :tesla, adapter: Tesla.Mock + +config :laboratory, + features: [ + {:test_flag, "Cool Bean", "cool bean for test"}, + {:use_smartling_translations, "Smartling translations", + "Uses Smartling's translation workflows"} + ], + cookie: [ + # one month, + max_age: 3600 * 24 * 30, + http_only: true + ] diff --git a/lib/dotcom_web/plugs/put_flags_in_assigns_hook.ex b/lib/dotcom_web/plugs/put_flags_in_assigns_hook.ex new file mode 100644 index 0000000000..f0d0c1c62d --- /dev/null +++ b/lib/dotcom_web/plugs/put_flags_in_assigns_hook.ex @@ -0,0 +1,24 @@ +defmodule DotcomWeb.PutFlagsInAssignsHook do + @moduledoc """ + Grabs Laboratory flags from session and makes them available as assigns + """ + + import Phoenix.Component + + def on_mount(:default, _params, session, socket) do + flags = Application.get_env(:laboratory, :features) |> Enum.map(fn {key, _, _} -> key end) + + socket = + Enum.reduce(flags, socket, fn flag, socket -> + value = + case session_value = session[Atom.to_string(flag)] do + nil -> nil + _ -> session_value + end + + socket |> assign(flag, value) + end) + + {:cont, socket} + end +end diff --git a/lib/dotcom_web/plugs/put_flags_in_session_plug.ex b/lib/dotcom_web/plugs/put_flags_in_session_plug.ex new file mode 100644 index 0000000000..83cfaf333e --- /dev/null +++ b/lib/dotcom_web/plugs/put_flags_in_session_plug.ex @@ -0,0 +1,30 @@ +defmodule DotcomWeb.Plug.PutFlagsInSessionPlug do + @moduledoc """ + Reads in Laboratory flags and makes them available on live view sessions. + Necessary because cookies are hard to access from LiveView. + """ + import Plug.Conn + + def init(_) do + %{} + end + + def call(conn, _opts) do + conn = fetch_cookies(conn) + flags = Application.get_env(:laboratory, :features) |> Enum.map(fn {key, _, _} -> key end) + + Enum.reduce(flags, conn, fn flag, conn -> + value = + case conn.cookies[Atom.to_string(flag)] do + nil -> false + "true" -> true + end + + conn + # Makes it available in LiveView + |> put_session(flag, value) + # Makes it available in traditional controllers + |> assign(flag, value) + end) + end +end diff --git a/lib/dotcom_web/router.ex b/lib/dotcom_web/router.ex index 84f1880174..53c6ad8b59 100644 --- a/lib/dotcom_web/router.ex +++ b/lib/dotcom_web/router.ex @@ -2,6 +2,12 @@ defmodule DotcomWeb.Router do @moduledoc false # remove this comment, it is here to try and fix github (don't ask) use DotcomWeb, :router + + pipeline :get_flags do + # pipe_through(:browser) + plug DotcomWeb.Plugs.PutFlagsInSessionPlug + end + use Plug.ErrorHandler alias DotcomWeb.ControllerHelpers @@ -26,6 +32,7 @@ defmodule DotcomWeb.Router do pipeline :browser do plug(:accepts, ["html"]) plug(:fetch_session) + plug(:get_flags) plug(:fetch_flash) plug(:fetch_cookies) plug(:put_root_layout, {DotcomWeb.LayoutView, :root}) @@ -92,22 +99,30 @@ defmodule DotcomWeb.Router do get("/*path", WwwRedirector, []) end - scope "/", DotcomWeb do - import Phoenix.LiveView.Router - pipe_through([:browser, :browser_live]) + scope "/lab", Laboratory do + forward "/", Router + end - live_session :alerts, layout: {DotcomWeb.LayoutView, :live} do - live("/alerts/subway", SubwayAlertsLive) - live("/alerts/commuter-rail", CommuterRailAlertsLive) + live_session :default, on_mount: DotcomWeb.Plugs.PutFlagsInAssignsHook do + scope "/", DotcomWeb do + import Phoenix.LiveView.Router + pipe_through([:browser, :browser_live]) + + live_session :alerts, layout: {DotcomWeb.LayoutView, :live} do + live("/alerts/subway", SubwayAlertsLive) + live("/alerts/commuter-rail", CommuterRailAlertsLive) + end end end - scope "/schedules/bostonstadium", DotcomWeb do - import Phoenix.LiveView.Router - pipe_through([:browser, :browser_live]) + live_session :default, on_mount: DotcomWeb.Plugs.PutFlagsInAssignsHook do + scope "/schedules/bostonstadium", DotcomWeb do + import Phoenix.LiveView.Router + pipe_through([:browser, :browser_live]) - live_session :world_cup do - live "/", WorldCupTimetableLive + live_session :world_cup do + live "/", WorldCupTimetableLive + end end end @@ -302,40 +317,48 @@ defmodule DotcomWeb.Router do # get("/vote", VoteController, :show) end - scope "/", DotcomWeb do - import Phoenix.LiveDashboard.Router + live_session :default, on_mount: DotcomWeb.Plugs.PutFlagsInAssignsHook do + scope "/", DotcomWeb do + import Phoenix.LiveDashboard.Router - pipe_through([:browser, :browser_live, :basic_auth_readonly]) - live_dashboard("/dashboard") + pipe_through([:browser, :browser_live, :basic_auth_readonly]) + live_dashboard("/dashboard") + end end - scope "/", DotcomWeb do - import Phoenix.LiveView.Router - pipe_through([:browser, :browser_live]) + live_session :default, on_mount: DotcomWeb.Plugs.PutFlagsInAssignsHook do + scope "/", DotcomWeb do + import Phoenix.LiveView.Router + pipe_through([:browser, :browser_live]) - live_session :rider, layout: {DotcomWeb.LayoutView, :live} do - live("/search", SearchPageLive) - live("/trip-planner", TripPlannerLive) + live_session :rider, layout: {DotcomWeb.LayoutView, :live} do + live("/search", SearchPageLive) + live("/trip-planner", TripPlannerLive) + end end end - scope "/departures", DotcomWeb do - import Phoenix.LiveView.Router - pipe_through([:browser, :browser_live]) + live_session :default, on_mount: DotcomWeb.Plugs.PutFlagsInAssignsHook do + scope "/departures", DotcomWeb do + import Phoenix.LiveView.Router + pipe_through([:browser, :browser_live]) - live_session :departures do - live "/", ScheduleFinderLive + live_session :departures do + live "/", ScheduleFinderLive + end end end - scope "/preview", DotcomWeb do - import Phoenix.LiveView.Router - pipe_through([:browser, :browser_live, :basic_auth_readonly]) + live_session :default, on_mount: DotcomWeb.Plugs.PutFlagsInAssignsHook do + scope "/preview", DotcomWeb do + import Phoenix.LiveView.Router + pipe_through([:browser, :browser_live, :basic_auth_readonly]) - live_session :default, layout: {DotcomWeb.LayoutView, :preview} do - live "/", PreviewLive - live "/schedules/bostonstadium", WorldCupTimetableLive - live "/stop-map", StopMapLive + live_session :default, layout: {DotcomWeb.LayoutView, :preview} do + live "/", PreviewLive + live "/schedules/bostonstadium", WorldCupTimetableLive + live "/stop-map", StopMapLive + end end end diff --git a/mix.exs b/mix.exs index 05c75fd52e..845a5ec89b 100644 --- a/mix.exs +++ b/mix.exs @@ -16,7 +16,7 @@ defmodule DotCom.Mixfile do start_permanent: Mix.env() == :prod, test_coverage: [tool: ExCoveralls], dialyzer: [ - plt_add_apps: [:mix, :phoenix_live_reload, :mbta_metro], + plt_add_apps: [:mix, :phoenix_live_reload, :mbta_metro, :laboratory], flags: [:unmatched_returns] ], deps: deps(), diff --git a/test/dotcom_web/plugs/put_flags_in_session_plug_test.exs b/test/dotcom_web/plugs/put_flags_in_session_plug_test.exs new file mode 100644 index 0000000000..d97e3fdae0 --- /dev/null +++ b/test/dotcom_web/plugs/put_flags_in_session_plug_test.exs @@ -0,0 +1,31 @@ +defmodule DotcomWeb.Plugs.PutFlagsInSessionPlugTest do + use DotcomWeb.ConnCase, async: true + use Plug.Test + + # describe "Put Flags in Session Plug" do + # test "flag is false if it has not been set", %{conn: conn} do + # conn = + # conn + # |> Plug.Test.init_test_session(%{}) + # |> fetch_session() + # |> bypass_through(DotcomWeb.Router, :get_flags) + # |> get("/") + + # assert conn.assigns.test_flag == false + # assert conn.private.plug_session["test_flag"] == false + # end + + # test "flag is true if it has been set", %{conn: conn} do + # conn = + # conn + # |> put_resp_cookie("test_flag", "true") + # |> Plug.Test.init_test_session(%{}) + # |> fetch_session() + # |> bypass_through(DotcomWeb.Router, :get_flags) + # |> get("/") + + # assert conn.assigns.test_flag == true + # assert conn.private.plug_session["test_flag"] == true + # end + # end +end From d29fabade34ac356374b88e94220b19eecae4111 Mon Sep 17 00:00:00 2001 From: Lily Barrett Date: Wed, 3 Jun 2026 11:16:56 -0400 Subject: [PATCH 2/3] WIP incorporating Laboratory flags --- .../plugs/put_flags_in_assigns_hook.ex | 2 +- ...ession_plug.ex => put_flags_in_session.ex} | 2 +- lib/dotcom_web/router.ex | 100 ++++++++---------- mix.exs | 5 +- ...test.exs => put_flags_in_session_test.exs} | 7 +- 5 files changed, 56 insertions(+), 60 deletions(-) rename lib/dotcom_web/plugs/{put_flags_in_session_plug.ex => put_flags_in_session.ex} (93%) rename test/dotcom_web/plugs/{put_flags_in_session_plug_test.exs => put_flags_in_session_test.exs} (86%) diff --git a/lib/dotcom_web/plugs/put_flags_in_assigns_hook.ex b/lib/dotcom_web/plugs/put_flags_in_assigns_hook.ex index f0d0c1c62d..8a7e2198fd 100644 --- a/lib/dotcom_web/plugs/put_flags_in_assigns_hook.ex +++ b/lib/dotcom_web/plugs/put_flags_in_assigns_hook.ex @@ -1,4 +1,4 @@ -defmodule DotcomWeb.PutFlagsInAssignsHook do +defmodule DotcomWeb.Plugs.PutFlagsInAssignsHook do @moduledoc """ Grabs Laboratory flags from session and makes them available as assigns """ diff --git a/lib/dotcom_web/plugs/put_flags_in_session_plug.ex b/lib/dotcom_web/plugs/put_flags_in_session.ex similarity index 93% rename from lib/dotcom_web/plugs/put_flags_in_session_plug.ex rename to lib/dotcom_web/plugs/put_flags_in_session.ex index 83cfaf333e..2247fa4a8b 100644 --- a/lib/dotcom_web/plugs/put_flags_in_session_plug.ex +++ b/lib/dotcom_web/plugs/put_flags_in_session.ex @@ -1,4 +1,4 @@ -defmodule DotcomWeb.Plug.PutFlagsInSessionPlug do +defmodule DotcomWeb.Plugs.PutFlagsInSession do @moduledoc """ Reads in Laboratory flags and makes them available on live view sessions. Necessary because cookies are hard to access from LiveView. diff --git a/lib/dotcom_web/router.ex b/lib/dotcom_web/router.ex index 53c6ad8b59..ea4c154e33 100644 --- a/lib/dotcom_web/router.ex +++ b/lib/dotcom_web/router.ex @@ -3,11 +3,6 @@ defmodule DotcomWeb.Router do # remove this comment, it is here to try and fix github (don't ask) use DotcomWeb, :router - pipeline :get_flags do - # pipe_through(:browser) - plug DotcomWeb.Plugs.PutFlagsInSessionPlug - end - use Plug.ErrorHandler alias DotcomWeb.ControllerHelpers @@ -23,6 +18,10 @@ defmodule DotcomWeb.Router do end end + pipeline :get_flags do + plug DotcomWeb.Plugs.PutFlagsInSession + end + pipeline :secure do if force_ssl = Application.compile_env(:dotcom, :secure_pipeline)[:force_ssl] do plug(Plug.SSL, force_ssl) @@ -99,30 +98,29 @@ defmodule DotcomWeb.Router do get("/*path", WwwRedirector, []) end - scope "/lab", Laboratory do + scope "/_flags", Laboratory do + pipe_through(:browser) forward "/", Router end - live_session :default, on_mount: DotcomWeb.Plugs.PutFlagsInAssignsHook do - scope "/", DotcomWeb do - import Phoenix.LiveView.Router - pipe_through([:browser, :browser_live]) - - live_session :alerts, layout: {DotcomWeb.LayoutView, :live} do - live("/alerts/subway", SubwayAlertsLive) - live("/alerts/commuter-rail", CommuterRailAlertsLive) - end + scope "/", DotcomWeb do + import Phoenix.LiveView.Router + pipe_through([:browser, :browser_live]) + + live_session :alerts, + layout: {DotcomWeb.LayoutView, :live}, + on_mount: DotcomWeb.Plugs.PutFlagsInAssignsHook do + live("/alerts/subway", SubwayAlertsLive) + live("/alerts/commuter-rail", CommuterRailAlertsLive) end end - live_session :default, on_mount: DotcomWeb.Plugs.PutFlagsInAssignsHook do - scope "/schedules/bostonstadium", DotcomWeb do - import Phoenix.LiveView.Router - pipe_through([:browser, :browser_live]) + scope "/schedules/bostonstadium", DotcomWeb do + import Phoenix.LiveView.Router + pipe_through([:browser, :browser_live]) - live_session :world_cup do - live "/", WorldCupTimetableLive - end + live_session :world_cup, on_mount: DotcomWeb.Plugs.PutFlagsInAssignsHook do + live "/", WorldCupTimetableLive end end @@ -317,48 +315,44 @@ defmodule DotcomWeb.Router do # get("/vote", VoteController, :show) end - live_session :default, on_mount: DotcomWeb.Plugs.PutFlagsInAssignsHook do - scope "/", DotcomWeb do - import Phoenix.LiveDashboard.Router + scope "/", DotcomWeb do + import Phoenix.LiveDashboard.Router - pipe_through([:browser, :browser_live, :basic_auth_readonly]) - live_dashboard("/dashboard") - end + pipe_through([:browser, :browser_live, :basic_auth_readonly]) + live_dashboard("/dashboard") end - live_session :default, on_mount: DotcomWeb.Plugs.PutFlagsInAssignsHook do - scope "/", DotcomWeb do - import Phoenix.LiveView.Router - pipe_through([:browser, :browser_live]) - - live_session :rider, layout: {DotcomWeb.LayoutView, :live} do - live("/search", SearchPageLive) - live("/trip-planner", TripPlannerLive) - end + scope "/", DotcomWeb do + import Phoenix.LiveView.Router + pipe_through([:browser, :browser_live]) + + live_session :rider, + layout: {DotcomWeb.LayoutView, :live}, + on_mount: DotcomWeb.Plugs.PutFlagsInAssignsHook do + live("/search", SearchPageLive) + live("/trip-planner", TripPlannerLive) end end - live_session :default, on_mount: DotcomWeb.Plugs.PutFlagsInAssignsHook do - scope "/departures", DotcomWeb do - import Phoenix.LiveView.Router - pipe_through([:browser, :browser_live]) + scope "/departures", DotcomWeb do + import Phoenix.LiveView.Router + pipe_through([:browser, :browser_live]) - live_session :departures do - live "/", ScheduleFinderLive - end + live_session :departures, on_mount: DotcomWeb.Plugs.PutFlagsInAssignsHook do + live "/", ScheduleFinderLive end end - live_session :default, on_mount: DotcomWeb.Plugs.PutFlagsInAssignsHook do - scope "/preview", DotcomWeb do - import Phoenix.LiveView.Router - pipe_through([:browser, :browser_live, :basic_auth_readonly]) + scope "/preview", DotcomWeb do + import Phoenix.LiveView.Router + pipe_through([:browser, :browser_live, :basic_auth_readonly]) - live_session :default, layout: {DotcomWeb.LayoutView, :preview} do - live "/", PreviewLive - live "/schedules/bostonstadium", WorldCupTimetableLive - live "/stop-map", StopMapLive - end + live_session :default, + layout: {DotcomWeb.LayoutView, :preview}, + on_mount: DotcomWeb.Plugs.PutFlagsInAssignsHook do + live "/", PreviewLive + live "/schedules/bostonstadium", WorldCupTimetableLive + live "/stop-map", StopMapLive end end diff --git a/mix.exs b/mix.exs index 845a5ec89b..69e1ef4711 100644 --- a/mix.exs +++ b/mix.exs @@ -73,7 +73,7 @@ defmodule DotCom.Mixfile do mod: {Dotcom.Application, []}, # a list of OTP applications your application depends on which are not included in :deps extra_applications: extra_apps, - included_applications: [:mbta_metro] + included_applications: [:mbta_metro, :laboratory] ] end @@ -177,7 +177,8 @@ defmodule DotCom.Mixfile do {:uuid, "1.1.8"}, {:wallaby, "0.30.12", [runtime: false, only: [:dev, :test]]}, {:yaml_elixir, "2.12.1", only: [:dev]}, - {:ymlr, "5.1.4", only: [:dev]} + {:ymlr, "5.1.4", only: [:dev]}, + {:laboratory, [github: "paulswartz/laboratory", ref: "cookie_opts"]} ] end end diff --git a/test/dotcom_web/plugs/put_flags_in_session_plug_test.exs b/test/dotcom_web/plugs/put_flags_in_session_test.exs similarity index 86% rename from test/dotcom_web/plugs/put_flags_in_session_plug_test.exs rename to test/dotcom_web/plugs/put_flags_in_session_test.exs index d97e3fdae0..ddc5b0de82 100644 --- a/test/dotcom_web/plugs/put_flags_in_session_plug_test.exs +++ b/test/dotcom_web/plugs/put_flags_in_session_test.exs @@ -1,6 +1,7 @@ -defmodule DotcomWeb.Plugs.PutFlagsInSessionPlugTest do - use DotcomWeb.ConnCase, async: true - use Plug.Test +defmodule DotcomWeb.Plugs.PutFlagsInSessionTest do + # use DotcomWeb.ConnCase, async: true + + # import DotcomWeb.Plugs.PutFlagsInSession # describe "Put Flags in Session Plug" do # test "flag is false if it has not been set", %{conn: conn} do From 0e5df024986a35f4343ce5827c8d5de430313a1c Mon Sep 17 00:00:00 2001 From: Lily Barrett Date: Thu, 4 Jun 2026 11:13:58 -0400 Subject: [PATCH 3/3] Update package --- mix.exs | 2 +- mix.lock | 3 +- .../plugs/put_flags_in_session_test.exs | 50 +++++++++---------- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/mix.exs b/mix.exs index 69e1ef4711..221d52da93 100644 --- a/mix.exs +++ b/mix.exs @@ -178,7 +178,7 @@ defmodule DotCom.Mixfile do {:wallaby, "0.30.12", [runtime: false, only: [:dev, :test]]}, {:yaml_elixir, "2.12.1", only: [:dev]}, {:ymlr, "5.1.4", only: [:dev]}, - {:laboratory, [github: "paulswartz/laboratory", ref: "cookie_opts"]} + {:laboratory, [github: "lilybarrett/laboratory", ref: "update_cowboy_version"]} ] end end diff --git a/mix.lock b/mix.lock index 3bd22b2cd2..a4746edf50 100644 --- a/mix.lock +++ b/mix.lock @@ -16,7 +16,7 @@ "combine": {:hex, :combine, "0.10.0", "eff8224eeb56498a2af13011d142c5e7997a80c8f5b97c499f84c841032e429f", [:mix], [], "hexpm", "1b1dbc1790073076580d0d1d64e42eae2366583e7aecd455d1215b0d16f2451b"}, "content_security_policy": {:git, "https://github.com/unill-io/content_security_policy.git", "921fdb9693f68996299af0f6a52288932d3d27c0", [tag: "v1.1.1"]}, "cors_plug": {:hex, :cors_plug, "3.0.3", "7c3ac52b39624bc616db2e937c282f3f623f25f8d550068b6710e58d04a0e330", [:mix], [{:plug, "~> 1.13", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "3f2d759e8c272ed3835fab2ef11b46bddab8c1ab9528167bd463b6452edf830d"}, - "cowboy": {:hex, :cowboy, "2.14.2", "4008be1df6ade45e4f2a4e9e2d22b36d0b5aba4e20b0a0d7049e28d124e34847", [:make, :rebar3], [{:cowlib, ">= 2.16.0 and < 3.0.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, ">= 1.8.0 and < 3.0.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "569081da046e7b41b5df36aa359be71a0c8874e5b9cff6f747073fc57baf1ab9"}, + "cowboy": {:hex, :cowboy, "2.15.0", "9cfe86ed7117bf045e10adbedb0170af7be57f2a3637e7be143433d8dd267396", [:make, :rebar3], [{:cowlib, ">= 2.16.0 and < 3.0.0", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, ">= 1.8.0 and < 3.0.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "179fb65140fb440a17b767ad53b755081506f9596c4db5c49c0396d8c8643668"}, "cowboy_telemetry": {:hex, :cowboy_telemetry, "0.4.0", "f239f68b588efa7707abce16a84d0d2acf3a0f50571f8bb7f56a15865aae820c", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "7d98bac1ee4565d31b62d59f8823dfd8356a169e7fcbb83831b8a5397404c9de"}, "cowlib": {:hex, :cowlib, "2.16.0", "54592074ebbbb92ee4746c8a8846e5605052f29309d3a873468d76cdf932076f", [:make, :rebar3], [], "hexpm", "7f478d80d66b747344f0ea7708c187645cfcc08b11aa424632f78e25bf05db51"}, "crc": {:hex, :crc, "0.10.6", "a52243715da06265399ade929b12e6807a82ddbd04231d8bd3069480aa890f01", [:mix, :rebar3], [{:elixir_make, "~> 0.6", [hex: :elixir_make, repo: "hexpm", optional: false]}], "hexpm", "9e832833d48a5fff03cb7488f8aa5c08adda0a5fa8188bbe124cb17c4e39a00d"}, @@ -70,6 +70,7 @@ "iso8601": {:hex, :iso8601, "1.3.4", "7b1f095f86f6cf65e1e5a77872e8e8bf69bd58d4c3a415b3f77d9cc9423ecbb9", [:rebar3], [], "hexpm", "a334469c07f1c219326bc891a95f5eec8eb12dd8071a3fff56a7843cb20fae34"}, "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, "jsx": {:hex, :jsx, "3.1.0", "d12516baa0bb23a59bb35dccaf02a1bd08243fcbb9efe24f2d9d056ccff71268", [:rebar3], [], "hexpm", "0c5cc8fdc11b53cc25cf65ac6705ad39e54ecc56d1c22e4adb8f5a53fb9427f3"}, + "laboratory": {:git, "https://github.com/lilybarrett/laboratory.git", "af848bd59563ccb6aa014415d674693e5a8c0e50", [ref: "update_cowboy_version"]}, "lazy_html": {:hex, :lazy_html, "0.1.10", "ffe42a0b4e70859cf21a33e12a251e0c76c1dff76391609bd56702a0ef5bc429", [:make, :mix], [{:cc_precompiler, "~> 0.1", [hex: :cc_precompiler, repo: "hexpm", optional: false]}, {:elixir_make, "~> 0.9.0", [hex: :elixir_make, repo: "hexpm", optional: false]}, {:fine, "~> 0.1.0", [hex: :fine, repo: "hexpm", optional: false]}], "hexpm", "50f67e5faa09d45a99c1ddf3fac004f051997877dc8974c5797bb5ccd8e27058"}, "live_isolated_component": {:hex, :live_isolated_component, "0.10.0", "e38b0b8dc5ff39f1d581fa2a05c7928d0475a854e246aee87fc2bc22726ff356", [:mix], [{:phoenix, "~> 1.7.0 or ~> 1.8.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 1.0.0 or ~> 1.1.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "170bb70fa89db7e94f95407523352cd619d0f17886017c188f93cfe728550725"}, "logster": {:hex, :logster, "1.1.1", "d6fddac540dd46adde0c894024500867fe63b0043713f842c62da5815e21db10", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}, {:plug, "~> 1.0", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "d18e852c430812ad1c9756998ebe46ec814c724e6eb551a512d7e3f8dee24cef"}, diff --git a/test/dotcom_web/plugs/put_flags_in_session_test.exs b/test/dotcom_web/plugs/put_flags_in_session_test.exs index ddc5b0de82..0de220c551 100644 --- a/test/dotcom_web/plugs/put_flags_in_session_test.exs +++ b/test/dotcom_web/plugs/put_flags_in_session_test.exs @@ -1,32 +1,32 @@ defmodule DotcomWeb.Plugs.PutFlagsInSessionTest do - # use DotcomWeb.ConnCase, async: true + use DotcomWeb.ConnCase, async: true - # import DotcomWeb.Plugs.PutFlagsInSession + import DotcomWeb.Plugs.PutFlagsInSession - # describe "Put Flags in Session Plug" do - # test "flag is false if it has not been set", %{conn: conn} do - # conn = - # conn - # |> Plug.Test.init_test_session(%{}) - # |> fetch_session() - # |> bypass_through(DotcomWeb.Router, :get_flags) - # |> get("/") + describe "Put Flags in Session Plug" do + test "flag is false if it has not been set", %{conn: conn} do + conn = + conn + |> Plug.Test.init_test_session(%{}) + |> fetch_session() + |> bypass_through(DotcomWeb.Router, :get_flags) + |> get("/") - # assert conn.assigns.test_flag == false - # assert conn.private.plug_session["test_flag"] == false - # end + assert conn.assigns.test_flag == false + assert conn.private.plug_session["test_flag"] == false + end - # test "flag is true if it has been set", %{conn: conn} do - # conn = - # conn - # |> put_resp_cookie("test_flag", "true") - # |> Plug.Test.init_test_session(%{}) - # |> fetch_session() - # |> bypass_through(DotcomWeb.Router, :get_flags) - # |> get("/") + test "flag is true if it has been set", %{conn: conn} do + conn = + conn + |> put_resp_cookie("test_flag", "true") + |> Plug.Test.init_test_session(%{}) + |> fetch_session() + |> bypass_through(DotcomWeb.Router, :get_flags) + |> get("/") - # assert conn.assigns.test_flag == true - # assert conn.private.plug_session["test_flag"] == true - # end - # end + assert conn.assigns.test_flag == true + assert conn.private.plug_session["test_flag"] == true + end + end end