Sha256: dd2c21f7f8592fa7e8621828e02d45e55b2080e5109fc368b8a80e9cde35e2e8

Contents?: true

Size: 623 Bytes

Versions: 23

Compression:

Stored size: 623 Bytes

Contents

require File.expand_path("../../spec_helper", __FILE__)

describe "Has many associations" do
  before do
    @user      = User.create :name => "Fred"
    @addresses = (0..2).map { Address.create :user_id => @user.id }
  end

  it "returns the objects whose foreign keys match the object's id" do
    found = @user.addresses.all.sort { |a, b| a.id <=> b.id }
    found.should == @addresses.sort { |a, b| a.id <=> b.id }
  end

  it "accepts class_name and foreign_key overrides" do
    found = @user.addresses_override.all.sort { |a, b| a.id <=> b.id }
    found.should == @addresses.sort { |a, b| a.id <=> b.id }
  end
end

Version data entries

23 entries across 23 versions & 7 rubygems

Version Path
ihoka-friendly-0.8.0.pre spec/integration/has_many_spec.rb
ihoka-friendly-0.7.1.2 spec/integration/has_many_spec.rb
ihoka-friendly-0.7.1.1 spec/integration/has_many_spec.rb
ihoka-friendly-0.7.1 spec/integration/has_many_spec.rb
ihoka-friendly-0.7.0 spec/integration/has_many_spec.rb
friendly-0.6.0 spec/integration/has_many_spec.rb
honkster-friendly-0.5.3 spec/integration/has_many_spec.rb
honkster-friendly-0.5.2 spec/integration/has_many_spec.rb
honkster-friendly-0.5.1 spec/integration/has_many_spec.rb
wayne-friendly-0.5.1 spec/integration/has_many_spec.rb
wego-friendly-0.5.1 spec/integration/has_many_spec.rb
arunthampi-friendly-0.5.1 spec/integration/has_many_spec.rb
friendly_postgres-0.5.1 spec/integration/has_many_spec.rb
friendly-0.5.1 spec/integration/has_many_spec.rb
friendly-0.5.0 spec/integration/has_many_spec.rb
friendly_postgres-0.4.5 spec/integration/has_many_spec.rb
friendly-0.4.5 spec/integration/has_many_spec.rb
friendly-0.4.4 spec/integration/has_many_spec.rb
friendly_postgres-0.4.3 spec/integration/has_many_spec.rb
friendly-0.4.3 spec/integration/has_many_spec.rb