diff --git a/test/controllers/products_controller_test.rb b/test/controllers/products_controller_test.rb index ed2b52f65591495f66e8f54c95fc1fddde040600..a14503d88b7f7ee735974c0535ba3e2b7955e96b 100644 --- a/test/controllers/products_controller_test.rb +++ b/test/controllers/products_controller_test.rb @@ -1,19 +1,36 @@ require 'test_helper' -#TODO: Finish writing product controller tests class ProductsControllerTest < ActionDispatch::IntegrationTest test 'should show all products' do - + get root_url + assert_response(:success) + assert_select 'div.productTable' do + assert_select 'article.product', 2 + end end test 'should show specific product' do - + get product_url(products(:one)) + assert_response(:success) end test 'should show product reviews' do - + get product_url(products(:one)) + assert_response(:success) + assert_select 'article.productDetails' do + assert_select 'strong', 3 # The only thing on the product detail view page that is strong is the review rating + end end test 'should show review creation form if logged in' do - + sign_in_as_tester + get product_url(products(:one)) + assert_response(:success) + assert_select 'article.productDetails' do + assert_select 'input' + end end test 'should not have review form if not logged in' do - + get product_url(products(:one)) + assert_response(:success) + assert_select 'article.productDetails' do + assert_select 'input', 0 + end end end