From dc1d0e1e2c591cb58c72a01882f197ea0fa207f0 Mon Sep 17 00:00:00 2001
From: "Butler, Alexis (UG - Computer Science)" <ab02259@surrey.ac.uk>
Date: Sat, 28 Nov 2020 14:41:37 +0000
Subject: [PATCH] first couple product admin controller tests

---
 .../admin/products_controller_test.rb         | 31 ++++++++++++++++---
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/test/controllers/admin/products_controller_test.rb b/test/controllers/admin/products_controller_test.rb
index d21c142..71fd05a 100644
--- a/test/controllers/admin/products_controller_test.rb
+++ b/test/controllers/admin/products_controller_test.rb
@@ -1,16 +1,37 @@
 require 'test_helper'
-#TODO: write product admin tests
+#TODO: finish product admin tests
 class Admin::ProductsControllerTest < ActionDispatch::IntegrationTest
-  test "should get index" do
+  test 'should get table of all products' do
+    sign_in_as_admin
+    get admin_products_url
+    assert_response(:success)
+    assert_select 'body.products' do
+      assert_select 'a.btn.btn-sm.btn-danger', Product.count
+    end
   end
+  test 'should not get prod table if not admin' do
+    sign_in_as_tester
+    get admin_products_url
+    assert_response(:redirect)
+    assert_redirected_to(root_url)
+    assert_equal 'You must be admin to go there!', flash[:danger]
+  end
+  test 'should get new product form' do
+
+  end
+  test 'should not get new prod form if not admin' do
 
-  test "should get create" do
   end
+  test 'should create a new product' do
 
-  test "should get new" do
   end
+  test 'should not create a new product if not admin' do
 
-  test "should get destroy" do
   end
+  test 'should delete a product' do
 
+  end
+  test 'should not delete a product if not admin' do
+
+  end
 end
-- 
GitLab