Sha256: 023e26bd68c8da990f1550b1181f247b79e0c36bf4277afe21ea7c6be72019e2
Contents?: true
Size: 979 Bytes
Versions: 6
Compression:
Stored size: 979 Bytes
Contents
require 'spec_helper' class Foo < ActiveRecord::Base belongs_to :that has_many :foo_bars has_many :bars, :through => :foo_bars has_one :noob end class Bar < ActiveRecord::Base has_many :foo_bars has_many :foos, :through => :foo_bars end describe ConnectionManager::Associations do it "should add associations as keys to @defined_associations" do Foo.defined_associations.keys.should eql([:belongs_to,:has_many,:has_one]) Bar.defined_associations.keys.should eql([:has_many]) end context "defined_association values" do it "should be an array of association options (which are Arrays as well)" do Foo.defined_associations[:belongs_to].should eql([[:that]]) Foo.defined_associations[:has_many].should eql([[:foo_bars],[:bars, {:through=>:foo_bars, :extend=>[]}]]) # when options are present active_record addes the :extend option defaulted to [] Foo.defined_associations[:has_one].should eql([[:noob]]) end end end
Version data entries
6 entries across 6 versions & 1 rubygems