From 9b408177324c63b31b2a8f15bba3c598bf9c5ee3 Mon Sep 17 00:00:00 2001
From: "Butler, Alexis (UG - Computer Science)" <ab02259@surrey.ac.uk>
Date: Sat, 28 Nov 2020 14:14:00 +0000
Subject: [PATCH] Wrote and passed admin dash controller tests

---
 .../admin/dashboard_controller_test.rb          | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/test/controllers/admin/dashboard_controller_test.rb b/test/controllers/admin/dashboard_controller_test.rb
index f92ebc1..177c274 100644
--- a/test/controllers/admin/dashboard_controller_test.rb
+++ b/test/controllers/admin/dashboard_controller_test.rb
@@ -1,12 +1,25 @@
 require 'test_helper'
 class Admin::DashboardControllerTest < ActionDispatch::IntegrationTest
   test 'should get dashboard if logged in and admin' do
+    sign_in_as_admin
+    get admin_root_url
+    assert_response(:success)
+    assert_select 'h4' do
+      assert_select 'a', 4
+    end
   end
   test 'should not get dashboard if logged in but not admin' do
-
+    sign_in_as_tester
+    get admin_root_url
+    assert_response(:redirect)
+    assert_redirected_to(root_url)
+    assert_equal 'You must be admin to go there!', flash[:danger]
   end
   test 'should not get dashboard if not logged in' do
-
+    get admin_root_url
+    assert_response(:redirect)
+    assert_redirected_to(login_url)
+    assert_equal 'Login to view this content', flash[:danger]
   end
 
 end
-- 
GitLab