Guest User

Untitled

a guest
Apr 13th, 2018
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. test "new user form exists" do
  2. # Verify the form exists correctly.
  3. get :new
  4. assert_response :success
  5. assert_select 'form#new_user'
  6. assert_select 'input#username'
  7. assert_select 'input#password1'
  8. assert_select 'input#password2'
  9. assert_select 'input#email'
  10. end
  11.  
  12. test "creating a user account" do
  13. username = 'testuser'
  14. password = 'abc123'
  15. email = 'test@user.com'
  16.  
  17. # Verify that no user exists with this username or email.
  18. assert_nil User.find_by_username(username)
  19. assert_nil User.find_by_email(email)
  20.  
  21. # Create the new user.
  22. post :create, :username => username, :password1 => password, :password2 => password, :email => email
  23. assert_response :redirect
  24. assert_redirected_to :controller => :entries, :action => :index
  25.  
  26. # Verify the new user exists.
  27. new_user = User.authenticate(username, password)
  28. assert new_user
  29. assert_equal email, new_user.email
  30. end
Add Comment
Please, Sign In to add comment