Sha256: de387cb77e077885f47c53919f07bcf87e56989d8f603eaa1a2feb20d123e878

Contents?: true

Size: 1.4 KB

Versions: 3

Compression:

Stored size: 1.4 KB

Contents

require 'spec_helper'

describe "Fields" do

end

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.column.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

3 entries across 3 versions & 1 rubygems

Version Path
puffer-0.0.23 spec/lib/fields_spec.rb
puffer-0.0.22 spec/lib/fields_spec.rb
puffer-0.0.21 spec/lib/fields_spec.rb