Sha256: 3c679c4bb55280b5970db6b44542b9fcd3c1351f5037ac623bd6bf23e04d91cb

Contents?: true

Size: 839 Bytes

Versions: 13

Compression:

Stored size: 839 Bytes

Contents

# encoding: UTF-8

require 'spec_helper'

describe ArelHelpers::ArelTable do
  it "should add the [] function to the model and allow attribute access" do
    Post[:id].tap do |post_id|
      post_id.should be_a(Arel::Attribute)
      post_id.name.should == :id
      post_id.relation.name.should == "posts"
    end
  end

  it "should not interfere with associations" do
    post = Post.create(title: "I'm a little teapot")
    post.comments[0].should be_nil
  end

  it "should allow retrieving associated records" do
    post = Post.create(title: "I'm a little teapot")
    comment = post.comments.create
    post.reload.comments[0].id.should == comment.id
  end

  it "does not interfere with ActiveRecord::Relation objects" do
    Post.all[0].should be_nil
    p = Post.create(title: 'foo')
    Post.all[0].id.should == p.id
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
arel-helpers-2.11.0 spec/arel_table_spec.rb
arel-helpers-2.10.0 spec/arel_table_spec.rb
arel-helpers-2.9.1 spec/arel_table_spec.rb
arel-helpers-2.9.0 spec/arel_table_spec.rb
arel-helpers-2.8.0 spec/arel_table_spec.rb
arel-helpers-2.7.0 spec/arel_table_spec.rb
arel-helpers-2.6.1 spec/arel_table_spec.rb
arel-helpers-2.6.0 spec/arel_table_spec.rb
arel-helpers-2.5.0 spec/arel_table_spec.rb
arel-helpers-2.4.0 spec/arel_table_spec.rb
arel-helpers-2.3.0 spec/arel_table_spec.rb
arel-helpers-2.2.0 spec/arel_table_spec.rb
arel-helpers-2.1.1 spec/arel_table_spec.rb