Skip to content

Commit

Permalink
Add some login tests to the functional suite.
Browse files Browse the repository at this point in the history
  • Loading branch information
bamnet committed Jul 9, 2012
1 parent 5ca41b7 commit 29a3c61
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions test/functional/contents_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ def setup
request.env["devise.mapping"] = Devise.mappings[:user]
end

test "must sign in before new" do
get :new
assert_login_failure
end

test "should get generic new" do
sign_in users(:katie)
get :new
Expand Down
5 changes: 5 additions & 0 deletions test/functional/templates_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ def setup
request.env["devise.mapping"] = Devise.mappings[:user]
end

test "must sign in before new" do
get :new
assert_login_failure
end

test "should create template" do
sign_in users(:admin)
assert_difference('Template.count', 1) do
Expand Down
3 changes: 1 addition & 2 deletions test/functional/users_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ def setup

test "blank and regular user cannot list all users" do
get :index
assert_response :redirect
assert !assigns(:users)
assert_login_failure

sign_in users(:katie)
get :index
Expand Down
6 changes: 6 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@ class ActiveSupport::TestCase
fixtures :all

# Add more helper methods to be used by all tests here...
def assert_login_failure
assert_redirected_to root_url
assert flash[:notice]
assert flash[:notice].include? 'not authorized'
end

end

0 comments on commit 29a3c61

Please sign in to comment.