SHARE
TWEET

Untitled

a guest Mar 17th, 2018 245 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top