Sha256: a318781e54909739bc6bd40b007b4ccae6daf041903ec077cc12479256c19626

Contents?: true

Size: 669 Bytes

Versions: 2

Compression:

Stored size: 669 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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arel-helpers-2.1.0 spec/arel_table_spec.rb
arel-helpers-2.0.2 spec/arel_table_spec.rb