Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require File.dirname(__FILE__) '/../test_helper'
- require 'user_controller'
- # Re-raise errors caught by the controller.
- class UserController; def rescue_action(e) raise e end; end
- class UserControllerTest < Test::Unit::TestCase
- fixtures :users
- def setup
- @controller = UserController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- end
- # Replace this with your real tests.
- def test_truth
- assert true
- end
- def test_account_homepage
- get :index, {}, { :user_id => users(:a).id }
- assert_response :success
- end
- def test_account_homepage_no_login
- get :index
- assert_redirected_to :action => 'login'
- end
- def test_register_logged_in
- get :register, {}, { :user_id => users(:a).id }
- assert_redirected_to :account_url
- end
- def test_register
- get :register
- assert_response :success
- end
- def test_bad_registration
- post :register
- assert_not_nil assigns['user'].errors
- end
- # Breaks on the line below def
- def test_good_registration
- post :register, { :username => 'test', :password => 'testpass', :email => 'test@email.com' }
- #breakpoint
- assert_nil assigns['user'].errors
- assert_redirected_to :account_url
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement