Sha256: 598f68bf3d8724ad7058eaa944239bb5b7f3672075413a0c5462e346ddbfa0a5

Contents?: true

Size: 1.37 KB

Versions: 5

Compression:

Stored size: 1.37 KB

Contents

require 'spec_helper'

describe "Field" do

  it "#model" do
    field = Puffer::Field.new 'user.profile.name', Post
    field.model.should == Profile
    field = Puffer::Field.new 'user.email', Post
    field.model.should == User
    field = Puffer::Field.new 'user', Post
    field.model.should == Post
    field = Puffer::Field.new 'title', Post
    field.model.should == Post
  end

  it "#name" do
    field = Puffer::Field.new 'user.profile.name', Post
    field.name.should == 'name'
  end

  it "#query_column" do
    field = Puffer::Field.new 'user.profile.name', Post
    field.query_column.should == 'profiles.name'
    field = Puffer::Field.new 'user.email', Post
    field.query_column.should == 'users.email'
    field = Puffer::Field.new 'user.full_name', Post
    field.query_column.should == nil
  end

  it "#column" do
    field = Puffer::Field.new 'user.profile.name', Post
    field.name.should == 'name'
    field = Puffer::Field.new 'user.full_name', Post
    field.column.should == nil
  end

  it '#type' do
    field = Puffer::Field.new 'user.created_at', Post
    field.type.should == :datetime
  end

  it '#type with virtual field' do
    field = Puffer::Field.new 'user.full_name', Post
    field.type.should == :string
  end

  it '#type was specified' do
    field = Puffer::Field.new 'user.full_name', Post, :type => :text
    field.type.should == :text
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
puffer-0.0.32 spec/lib/fields_spec.rb
puffer-0.0.31 spec/lib/fields_spec.rb
puffer-0.0.30 spec/lib/fields_spec.rb
puffer-0.0.29 spec/lib/fields_spec.rb
puffer-0.0.28 spec/lib/fields_spec.rb