Advertisement
Guest User

Untitled

a guest
Jun 13th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. rspec spec/model/user_spec.rb
  2.  
  3. describe "validation" do
  4. context "when user is from google" do
  5. before do
  6. @user = User.new(email: "example@gmail.com")
  7. @user.authentications.build(provider: "google", uid: "1234")
  8. end
  9.  
  10. it "should be valid" do
  11. @user.valid?.should be_true
  12. end
  13.  
  14. it "should save" do
  15. @user.save.should be_true
  16. end
  17. end
  18.  
  19. context "when user is from twitter" do
  20. before do
  21. @user = User.new(email: nil)
  22. @user.authentications.build(provider: "twitter", uid: "1234")
  23. end
  24.  
  25. it "should be valid" do
  26. @user.valid?.should be_true
  27. end
  28.  
  29. it "should save" do
  30. @user.save.should be_true
  31. end
  32. end
  33. end
  34.  
  35. (rdb:1) @user.errors
  36. #<ActiveModel::Errors:0x0000000ca98e98 @base=#<User id: nil, email: "example@gmail.com", encrypted_password: "", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, created_at: nil, updated_at: nil, admin: nil, given_names: nil, surname: nil, dob: nil, address: nil, suburb: nil, state: nil, country: nil, phone: nil, interests: nil, venue_manager: nil, nickname: nil, data_entry: nil>, @messages={}>
  37. (rdb:1) @user.valid?
  38. false
  39. (rdb:1) @user.errors
  40. #<ActiveModel::Errors:0x0000000ca98e98 @base=#<User id: nil, email: "example@gmail.com", encrypted_password: "", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, created_at: nil, updated_at: nil, admin: nil, given_names: nil, surname: nil, dob: nil, address: nil, suburb: nil, state: nil, country: nil, phone: nil, interests: nil, venue_manager: nil, nickname: nil, data_entry: nil>, @messages={:encrypted_password=>["can't be blank"]}>
  41. (rdb:1)
  42.  
  43. def password_required?
  44. authentications.empty? && (!persisted? || password.present? || password_confirmation.present?)
  45. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement