Skip to content
Browse files

Adding the actual tests - doh

  • Loading branch information...
1 parent f97d659 commit cbc7512e51993cfe64400c3284e9d9d3287e55b8 @frankieroberto frankieroberto committed with carlosantoniodasilva Mar 14, 2011
View
7 test/fixtures/admins.yml
@@ -1,7 +1,4 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
-# one:
-# column: value
-#
-# two:
-# column: value
+bob:
+ email: bob@bob.com
View
18 test/functional/admins_controller_test.rb
@@ -2,6 +2,22 @@
class AdminsControllerTest < ActionController::TestCase
-
+
+ test "should get index page when authenticated as an admin" do
+ sign_in admins(:bob)
+ get :index
+ assert_response :success
+ end
+
+ test "should redirect to login page when viewing index page whilst authenticated as a user" do
+ sign_in users(:john)
+ get :index
+ assert_redirected_to new_admin_session_path
+ end
+
+ test "should redirect to login page when viewing index page whilst not authenticated" do
+ get :index
+ assert_redirected_to new_admin_session_path
+ end
end
View
17 test/functional/home_controller_test.rb
@@ -2,6 +2,21 @@
class HomeControllerTest < ActionController::TestCase
-
+ test "should get home page" do
+ get :index
+ assert_response :success
+ end
+
+ test "should get token page when authenticated as a user" do
+ sign_in users(:john)
+ get :token
+ assert_response :success
+ end
+
+ test "should redirect to login page when viewing token page whilst not authenticated" do
+ get :token
+ assert_redirected_to new_user_session_path
+ end
+
end
View
4 test/test_helper.rb
@@ -11,3 +11,7 @@ class ActiveSupport::TestCase
# Add more helper methods to be used by all tests here...
end
+
+class ActionController::TestCase
+ include Devise::TestHelpers
+end

0 comments on commit cbc7512

Please sign in to comment.
Something went wrong with that request. Please try again.