Advertisement
Guest User

Untitled

a guest
Jul 30th, 2017
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. require File.dirname(__FILE__) '/../test_helper'
  2. require 'user_controller'
  3.  
  4. # Re-raise errors caught by the controller.
  5. class UserController; def rescue_action(e) raise e end; end
  6.  
  7. class UserControllerTest < Test::Unit::TestCase
  8. fixtures :users
  9.  
  10. def setup
  11. @controller = UserController.new
  12. @request = ActionController::TestRequest.new
  13. @response = ActionController::TestResponse.new
  14. end
  15.  
  16. # Replace this with your real tests.
  17. def test_truth
  18. assert true
  19. end
  20.  
  21. def test_account_homepage
  22. get :index, {}, { :user_id => users(:a).id }
  23. assert_response :success
  24. end
  25.  
  26. def test_account_homepage_no_login
  27. get :index
  28. assert_redirected_to :action => 'login'
  29. end
  30.  
  31. def test_register_logged_in
  32. get :register, {}, { :user_id => users(:a).id }
  33. assert_redirected_to :account_url
  34. end
  35.  
  36. def test_register
  37. get :register
  38. assert_response :success
  39. end
  40.  
  41. def test_bad_registration
  42. post :register
  43. assert_not_nil assigns['user'].errors
  44. end
  45.  
  46. # Breaks on the line below def
  47. def test_good_registration
  48. post :register, { :username => 'test', :password => 'testpass', :email => 'test@email.com' }
  49. #breakpoint
  50. assert_nil assigns['user'].errors
  51. assert_redirected_to :account_url
  52. end
  53. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement