rename project from SimpleshopTheme to Berrypod

All modules, configs, paths, and references updated.
836 tests pass, zero warnings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
jamey
2026-02-18 21:23:15 +00:00
parent c65e777832
commit 9528700862
300 changed files with 23932 additions and 1349 deletions

View File

@@ -0,0 +1,99 @@
defmodule BerrypodWeb.Plugs.CountryDetectTest do
use BerrypodWeb.ConnCase, async: true
alias BerrypodWeb.Plugs.CountryDetect
defp with_cookies(conn) do
Plug.Conn.fetch_cookies(conn)
end
describe "call/2" do
test "detects GB from en-GB header", %{conn: conn} do
conn =
conn
|> init_test_session(%{})
|> with_cookies()
|> put_req_header("accept-language", "en-GB,en;q=0.9")
|> CountryDetect.call([])
assert get_session(conn, "country_code") == "GB"
end
test "detects DE from de-DE header", %{conn: conn} do
conn =
conn
|> init_test_session(%{})
|> with_cookies()
|> put_req_header("accept-language", "de-DE,de;q=0.9,en;q=0.8")
|> CountryDetect.call([])
assert get_session(conn, "country_code") == "DE"
end
test "detects FR from fr-FR header", %{conn: conn} do
conn =
conn
|> init_test_session(%{})
|> with_cookies()
|> put_req_header("accept-language", "fr-FR,fr;q=0.9")
|> CountryDetect.call([])
assert get_session(conn, "country_code") == "FR"
end
test "defaults to GB when no country in header", %{conn: conn} do
conn =
conn
|> init_test_session(%{})
|> with_cookies()
|> put_req_header("accept-language", "en;q=0.9")
|> CountryDetect.call([])
assert get_session(conn, "country_code") == "GB"
end
test "defaults to GB when no Accept-Language header", %{conn: conn} do
conn =
conn
|> init_test_session(%{})
|> with_cookies()
|> CountryDetect.call([])
assert get_session(conn, "country_code") == "GB"
end
test "does not overwrite existing country_code in session", %{conn: conn} do
conn =
conn
|> init_test_session(%{"country_code" => "US"})
|> with_cookies()
|> put_req_header("accept-language", "en-GB,en;q=0.9")
|> CountryDetect.call([])
assert get_session(conn, "country_code") == "US"
end
test "cookie overrides session country", %{conn: conn} do
conn =
conn
|> init_test_session(%{"country_code" => "GB"})
|> put_req_cookie("shipping_country", "DE")
|> with_cookies()
|> CountryDetect.call([])
assert get_session(conn, "country_code") == "DE"
end
test "cookie overrides Accept-Language detection", %{conn: conn} do
conn =
conn
|> init_test_session(%{})
|> put_req_cookie("shipping_country", "US")
|> with_cookies()
|> put_req_header("accept-language", "en-GB,en;q=0.9")
|> CountryDetect.call([])
assert get_session(conn, "country_code") == "US"
end
end
end