Sha256: eefca2772481ba25a2304055d04213783e65f277a61b717f8303b0712ba78d39

Contents?: true

Size: 1.36 KB

Versions: 4

Compression:

Stored size: 1.36 KB

Contents

require 'rails_helper'

describe SpudUser, :type => :model do

  describe ".full_name" do
    it "should return the full name if the first and last name are not blank" do
      u = FactoryGirl.build(:spud_user)
      expect(u.full_name).to  eq("#{u.first_name} #{u.last_name}")
    end
  
    it "should return only the last name if the first name is blank" do
      u = FactoryGirl.build(:spud_user, :first_name => nil)
      expect(u.full_name).to  eq(u.last_name)
    end
  
    it "should return only the first name if the last name is blank" do
      u = FactoryGirl.build(:spud_user, :last_name => nil)
      expect(u.full_name).to  eq(u.first_name)
    end
  
    it "should return the login if the first and last name are blank" do
      u = FactoryGirl.build(:spud_user, :first_name => nil, :last_name => nil)
      expect(u.full_name).to  eq(u.login)
    end
  end

  it { should_not allow_value('').for(:login) }
  it { should ensure_length_of(:login).is_at_least(3) }
  it { should ensure_length_of(:password).is_at_least(4) }
  it { should_not allow_value('@mail.com').for(:email) }
  it { should_not allow_value('mail.com').for(:email) }
  it { should allow_value('test@mail.com').for(:email) }

  it "must match password confirmation before saving a new user" do
    u = FactoryGirl.build(:spud_user, :password_confirmation => '')
    expect(u.save).to eq(false)
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tb_core-1.3.3 spec/models/spud_user_spec.rb
tb_core-1.3.2 spec/models/spud_user_spec.rb
tb_core-1.3.1 spec/models/spud_user_spec.rb
tb_core-1.3.0 spec/models/spud_user_spec.rb