Created
June 27, 2013 18:06
-
-
Save kshsieh/5878822 to your computer and use it in GitHub Desktop.
false positive
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
# test in users controller spec | |
# testing update with a guest account | |
context "updating guest account" do | |
before :each do | |
email = "[email protected]" | |
User.check_and_create_guest(email) | |
user = User.find_by_email(email) | |
controller.stub :current_user => user | |
end | |
it "should promote to Guest and create User" do | |
put :update, {:user => {:password => 'mynewpassword'} } | |
debugger | |
User.find_by_email("[email protected]").type.should == nil | |
end | |
end | |
# just wanted to see if this works | |
def update | |
respond_to do |format| | |
if @user.update_attributes(params[:user]) | |
if @user.guest? | |
@user.promote_to_user | |
end | |
if params[:user][:password].present? | |
# this logic needed b/c devise wants to log us out after password changes | |
user = User.reset_password_by_token(params[:user]) | |
@user = current_user | |
sign_out(@user) | |
sign_in(@user, :event => :authentication) | |
end | |
flash[:notice] = I18n.t("account_updated") | |
format.html { redirect_to account_url(anchor: 'account') } | |
format.js | |
else | |
format.html { render 'edit' } | |
format.js | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment