Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rspec spec/model/user_spec.rb
- describe "validation" do
- context "when user is from google" do
- before do
- @user = User.new(email: "example@gmail.com")
- @user.authentications.build(provider: "google", uid: "1234")
- end
- it "should be valid" do
- @user.valid?.should be_true
- end
- it "should save" do
- @user.save.should be_true
- end
- end
- context "when user is from twitter" do
- before do
- @user = User.new(email: nil)
- @user.authentications.build(provider: "twitter", uid: "1234")
- end
- it "should be valid" do
- @user.valid?.should be_true
- end
- it "should save" do
- @user.save.should be_true
- end
- end
- end
- (rdb:1) @user.errors
- #<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={}>
- (rdb:1) @user.valid?
- false
- (rdb:1) @user.errors
- #<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"]}>
- (rdb:1)
- def password_required?
- authentications.empty? && (!persisted? || password.present? || password_confirmation.present?)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement