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
- def setup
- @controller = UserController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- end
- # Replace this with your real tests.
- def test_user_apply_with_no_email
- post :apply, :user => {:login => 'winson',
- :name => 'Winson'}
- assert_tag :tag => 'div', :attributes => {:class => 'errorExplanation'}, :content => "Email can't be blank"
- end
- def test_user_apply_not_meet_password_confirmation
- post :apply, :user => {:login => 'winson',
- :name => 'Winson',
- :email => 'winson@pbg4.org',
- :password => '123',
- :password_confirmation => '456'}
- assert_tag :tag => 'div', :attributes => {:class => 'errorExplanation'}, :content => "Password doesn't match confirmation"
- end
- def test_user_login
- assert_diff(User, :count) do
- post :apply, :user => {:login => 'winson',
- :name => 'Winson',
- :email => 'winson@pbg4.org',
- :password => '123',
- :password_confirmation => '123'}
- assert_response :redirect
- assert_redirected_to :action => 'show'
- end
- post :login, :user => {:login => 'winson', :password => '123'}
- assert_equal 'Login successfully.', flash[:notice]
- end
- end
Add Comment
Please, Sign In to add comment