Skip to content

Instantly share code, notes, and snippets.

@ch1ago
Created July 30, 2011 17:42
Show Gist options
  • Select an option

  • Save ch1ago/1115777 to your computer and use it in GitHub Desktop.

Select an option

Save ch1ago/1115777 to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
protect_from_forgery
helper_method :is_manager?, :current_cart, :cc
protected
def current_cart
@current_cart ||= session[:cart_key] ? Cart.where(w).first : Cart.new
end
end
#how do I setup the @cart variable if the correct call for it is in the ApplicationController?
require 'test_helper'
class CartsControllerTest < ActionController::TestCase
setup do
@cart = carts(:one)
# ???????????
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:carts)
end
test "should show cart" do
get :show, :id => :current
assert_response :success
end
test "should update cart" do
put :update, :id => :current, :cart => @cart.attributes
assert_redirected_to cart_path(assigns(:cart))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment