Sha256: e687b26f75ba297d865a2ea0442c203fb280dbfb388583acc2cfcb0b39325876

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 KB

Contents

require "spec_helper"

describe CanCan::CanDefinition do
  before(:each) do
    @conditions = {}
    @can = CanCan::CanDefinition.new(true, :read, Integer, @conditions, nil)
  end

  it "should return no association joins if none exist" do
    @can.associations_hash.should == {}
  end

  it "should return no association for joins if just attributes" do
    @conditions[:foo] = :bar
    @can.associations_hash.should == {}
  end

  it "should return single association for joins" do
    @conditions[:foo] = {:bar => 1}
    @can.associations_hash.should == {:foo => {}}
  end

  it "should return multiple associations for joins" do
    @conditions[:foo] = {:bar => 1}
    @conditions[:test] = {1 => 2}
    @can.associations_hash.should == {:foo => {}, :test => {}}
  end

  it "should return nested associations for joins" do
    @conditions[:foo] = {:bar => {1 => 2}}
    @can.associations_hash.should == {:foo => {:bar => {}}}
  end

  it "should return table names in conditions for association joins" do
    @conditions[:foo] = {:bar => 1}
    @conditions[:test] = 1
    @can.tableized_conditions.should == {:foos => {:bar => 1}, :test => 1}
  end

  it "should return no association joins if conditions is nil" do
    can = CanCan::CanDefinition.new(true, :read, Integer, nil, nil)
    can.associations_hash.should == {}
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cancan-1.3.2 spec/cancan/can_definition_spec.rb