Skip to content

Instantly share code, notes, and snippets.


shankardevy/fetch_cart_test.exs Secret

Last active Aug 18, 2017
What would you like to do?
defmodule MangoWeb.Plugs.FetchCartTest do
use MangoWeb.ConnCase
alias Mango.Sales.Order
test "create and set cart on first visit" do
conn = get build_conn(), "/"
cart_id = get_session(conn, :cart_id)
assert %Order{status: "In Cart"} = conn.assigns.cart
assert cart_id ==
test "fetch cart from session on subsequent visit" do
conn = get build_conn(), "/" # first visit
cart_id = get_session(conn, :cart_id) # cart id from first visit
conn = get conn, "/" # second visit
assert cart_id ==
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment