Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require File.dirname(__FILE__) + '/../spec_helper'
- describe UserController do
- before(:each) do
- @user = mock_model(User)
- @role = mock_model(Role)
- @user.stub!(:new_record?).and_return(false)
- @user.stub!(:valid?).and_return(true)
- @user.stub!(:roles).and_return([@role])
- User.stub!(:new).and_return(@user)
- Advertiser.stub!(:new).and_return(@user)
- User.stub!(:find).and_return(@user)
- end
- it "should render 'user/signup' on GET to signup" do
- get 'signup'
- response.should render_template(:signup)
- end
- it "should tell the User model to create a new User on POST to signup and then redirect to index" do
- @user.stub!(:save).and_return( true )
- @user.should_receive(:status=).with(USER_WAIT_APPROVAL).and_return( true )
- @user.stub!(:confirmation=).and_return( true )
- @user.should_receive(:name).and_return("Lee")
- @user.should_receive(:email).and_return("lma-admin@lma.com")
- @role.should_receive(:name).and_return("advertiser")
- post 'signup', {:user => {
- :login => "lma-admin", :email => "lma-admin@lma.com", \
- :first_name => "Bruce", :last_name => "Lee", \
- :company_name => "Jeet Kune Do", :city => "San Fracisco", \
- :phone_nr => "123-45678", :password => "LeeHoiChuen", \
- :password_confirmation => "LeeHoiChuen", \
- :country => "Estados Unidos", :type => "advertiser"}}
- response.should redirect_to(:action => 'index')
- end
- end
Add Comment
Please, Sign In to add comment