Sha256: d738035a04da9f216de9716d2aac04fe89c8ec2a2fdc4efee8602a310466cb17

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

describe Customer do
  it { should have_one(:user).dependent(:destroy) }
  it { should respond_to :user }
  it { should respond_to :email }

  describe 'model valid' do
    before do
      @customer = Customer.new
      @user = User.new
      @customer.user = @user
    end
    it 'throws errors when user has no email is not correct' do
      @customer.should_not be_valid
    end

    it 'is valid when user has no errors' do
      @customer.email = 'test@test.com'
      @customer.should be_valid
    end
  end

  describe 'user autobuild' do
    before do
      @customer = Customer.new
    end

    it 'has to have a user already' do
      @customer.user.should be_present
    end
  end

  describe 'setters' do
    before do
      @customer = Customer.new(email: 'test@test.com')
    end
    it 'saves the user with its corresponding fields' do
      @customer.save
      @customer.user.email.should eql @customer.email
    end
  end

  describe 'deep_inspect' do
    before do
      @customer = Customer.new(email: 'test@test.com')
      @customer.save
    end
    it 'inspects both the user and the userable' do
      @customer.deep_inspect.should include @customer.inspect
      @customer.deep_inspect.should include @customer.user.inspect
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
acts_as_user-1.2.6 spec/models/active_record/customer_spec.rb
acts_as_user-1.2.5 spec/models/active_record/customer_spec.rb