require File.dirname(__FILE__) + "/../test_helper" class SmokeTest < ActionController::IntegrationTest test "home page" do get "/" assert_response :success end test "login" do get "shop/signonForm.shtml" assert_response :success end test "new account" do get "shop/newAccountForm.shtml" assert_response :success end test "failed validation on new account" do post "shop/newAccount.shtml", :account => {:username => "incomplete"} assert_response :success assert_select "li", "Email can't be blank" end test "successful new account" do post "shop/newAccount.shtml", :account => {:username => 'jsmith', :password => 'smitty', :password_confirmation => 'smitty', :email => 'jsmith@email.com', :first_name => 'john', :last_name => 'smith', :status => 'OK', :address_line_1 => '75 Apple Tree Lane', :city => 'Los Angeles', :state => 'California', :zip => '992010', :country => 'USA', :phone => '123-456' } assert_redirected_to :controller => 'shop', :action => 'index' end test "view cart" do get "shop/viewCart.shtml" assert_response :success end test "shop homepage" do get "shop/index.shtml" assert_response :success end test "show fish category" do get "shop/viewCategory.shtml?category=FISH" assert_response :success end test "show dogs category" do get "shop/viewCategory.shtml?category=DOGS" assert_response :success end test "show cats category" do get "shop/viewCategory.shtml?category=CATS" assert_response :success end test "show birds category" do get "shop/viewCategory.shtml?category=BIRDS" assert_response :success end test "show reptiles category" do get "shop/viewCategory.shtml?category=REPTILES" assert_response :success end test "show fish product FI-SW-01" do get "shop/viewProduct.shtml?product=FI-SW-01" assert_response :success end test "show cat product FL-DSH-01" do get "shop/viewProduct.shtml?product=FL-DSH-01" assert_response :success end test "show item EST-1" do get "shop/viewItem.shtml?item=EST-1" assert_response :success end test "show item EST-14" do get "shop/viewItem.shtml?item=EST-14" assert_response :success end test "show item EST-28" do get "shop/viewItem.shtml?item=EST-28" assert_response :success end test "add item EST-7 to cart" do get "shop/addItemToCart.shtml?workingItem=EST-7" assert_response :success end test "failed login" do post "shop/signon.shtml", :username => "not_a_user", :password => "bad_password" assert_response :success assert_select ".message", :text => "Invalid username or password. Signon failed." end test "successful login" do post "shop/signon.shtml", :username => "j2ee", :password => "j2ee" assert_response :success assert_template "shop/index" end test "logout" do get "shop/signoff.shtml" assert_response :success end test "cart summary" do get "shop/addItemToCart.shtml?workingItem=EST-7" assert_response :success assert_select "a[href=/shop/checkout.shtml]" get "shop/checkout.shtml" assert_response :success end test "new order when not logged in" do get "shop/addItemToCart.shtml?workingItem=EST-7" assert_response :success get "shop/newOrderForm.shtml" assert_response :success assert_select ".message", :text => "You must sign on before attempting to check out. Please sign on and try checking out again." end test "new order" do post "shop/signon.shtml", :username => "j2ee", :password => "j2ee" get "shop/addItemToCart.shtml?workingItem=EST-7" assert_response :success get "shop/newOrderForm.shtml" assert_response :success assert_select "b", :text => "Payment Details" end test "confirm order" do post "shop/signon.shtml", :username => "j2ee", :password => "j2ee" get "shop/addItemToCart.shtml?workingItem=EST-7" assert_response :success get "shop/newOrderForm.shtml" assert_response :success post "shop/newOrder.shtml", "order.cardType" => "Visa", "order.creditCard" => "999 9999 9999 9999", "order.expiryDate" => "12/03", "order.billToFirstName" => "ABC", "order.billToLastName" => "XYX", "order.billAddress1" => "901 San Antonio Road", "order.billAddress2" => "MS UCUP02-206", "order.billCity" => "Palo Alto", "order.billState" => "CA", "order.billZip" => "94303", "order.billCountry" => "USA" assert_response :success assert_select "body center b", :text => "Please confirm the information below and then press continue..." end test "edit account" do post "shop/signon.shtml", :username => "j2ee", :password => "j2ee" get "shop/editAccountForm.shtml" assert_response :success assert_select "h3", :text => "User Information" end test "update cart quantities" do get "shop/addItemToCart.shtml?workingItem=EST-7" assert_response :success post "shop/updateCartQuantities.shtml", :"EST-7" => "5" assert_response :success assert_select "input[type=text][name=EST-7][value=5]" end test "remove from cart" do get "shop/addItemToCart.shtml?workingItem=EST-14" assert_response :success assert_select "input[type=text][name=EST-14]" get "shop/removeItemFromCart.shtml?workingItem=EST-14" assert_response :success assert_select "input[type=text][name=EST-14]", :count => 0 end test "listing orders" do post "shop/signon.shtml", :username => "j2ee", :password => "j2ee" get "shop/listOrders.shtml" assert_response :success end test "show order" do order = Order.create! get "shop/viewOrder.shtml?orderId=#{order.id}" assert_response :success end test "search products" do get "shop/searchProducts.shtml", :keyword => "angel" assert_response :success assert_template "products/search" end end