Guest User

Untitled

a guest
May 5th, 2018
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. ## UserControllerSpec
  2.  
  3. describe "handling POST /users" do
  4. it "should not save a valid user if recaptcha is not correct" do
  5. #pending
  6. controller.stub!(:verify_recaptcha).and_return(false)
  7. @user = true
  8. @user.should_not_receive(:save)
  9. create_user
  10. end
  11.  
  12. it "should save a valid user if recaptcha is not correct" do
  13. #pending
  14. controller.stub!(:verify_recaptcha).and_return(true)
  15. @user = true
  16. @user.should_receive(:save)
  17. create_user
  18. end
  19.  
  20. end
  21.  
  22. def create_user(options = {})
  23. post :create, :user => { :login => 'quire', :email => 'quire@example.com',
  24. :password => 'quire69', :password_confirmation => 'quire69', :tos_and_privacy_policy => '1' }.merge(options)
  25. end
  26.  
  27. ##UserController
  28.  
  29. def create
  30. logout_keeping_session!
  31. @user = User.new(params[:user])
  32. success = verify_recaptcha(@user) && @user && @user.save
  33. if success && @user.errors.empty?
  34. spawn do
  35. UserMailer.deliver_signup_notification(@user)
  36. end
  37. redirect_back_or_default('/')
  38. flash[:notice] = "Thanks for signing up! Please check your email to complete the sign up process."
  39. else
  40. flash[:error] = "We couldn't set up that account, sorry. Please try again, or email us at support@konnect.me"
  41. render :action => 'new'
  42. end
  43. end
Add Comment
Please, Sign In to add comment