Sha256: 710f1119b7bca58c54342b509e8663a39f58e434051a947351b88a5b1fe02778

Contents?: true

Size: 771 Bytes

Versions: 1

Compression:

Stored size: 771 Bytes

Contents

require "spec_helper"

describe Mongoid::Criteria do

  describe "#each" do

    before :each do
      Game.destroy_all
      Person.destroy_all
      @person1 = Person.create(:title => "Sir", :age => 100, :aliases => ["D", "Durran"], :ssn => "666666666")
      @person2 = Person.create(:title => "Madam", :age => 1, :ssn => "098-76-5434")
      @person1.create_game(:score => 10)
      @person2.create_game(:score => 20)
    end

    it "without includes" do
      criteria = Person.all
      criteria.collect(&:title).should == ["Sir", "Madam"]
    end

    it "with includes" do
      criteria = Person.includes(:game)
      criteria.collect(&:title).should == ["Sir", "Madam"]
      criteria.collect(&:game).should == [@person1.game, @person2.game]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid-eager-loading-0.1.2 spec/mongoid-eager-loading/mongoid/criteria_spec.rb