Created
February 3, 2010 15:22
-
-
Save floehopper/293677 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
@user = User.new(params[:user]) | |
if @user.save_without_session_maintenance | |
@user.company.update_attributes(:owner_user_id => @user.id) | |
flash[:notice] = "Company registered!" | |
redirect_to login_url | |
else | |
render :action => :new | |
end | |
end | |
# attempt by Tom | |
User.any_instance.stubs(:save_without_session_maintenance).returns(true) #This is correct | |
company = mock('company') | |
user = mock('user') | |
User.any_instance.expects(:company).once.returns(company).expects(:update_attributes).with(:owner_user_id).returns(true) | |
post :create | |
# attempt by James | |
User.any_instance.stubs(:save_without_session_maintenance).returns(true) | |
company = mock('company') | |
user = mock('user', :id => 1) | |
User.any_instance.expects(:company).once.returns(company) | |
company.expects(:update_attributes).with(:owner_user_id => user.id).returns(true) | |
post :create |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment