Guest User

Untitled

a guest
Mar 17th, 2018
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. require 'test_helper'
  2.  
  3. class AccountsControllerTest < ActionController::TestCase
  4.  
  5. def setup
  6. @valid_params = {:username => "foo",
  7. :password => "secret",
  8. :password_confirmation => "secret",
  9. :email => "foo@example.com"}
  10. end
  11.  
  12. def test_new
  13. get :new
  14. assert_template 'new'
  15. end
  16.  
  17. def test_create_invalid
  18. Account.any_instance.stubs(:valid?).returns(false)
  19. post :create
  20. assert_template 'new'
  21. end
  22.  
  23. def test_create_valid
  24. account = Account.new(@valid_params)
  25. account.errors.inspect if !account.valid?
  26. post :create, :account => account
  27. assert_redirected_to root_url
  28. assert_equal assigns['account'].id, session['account_id']
  29. end
  30. end
Add Comment
Please, Sign In to add comment