Created
December 26, 2009 02:29
-
-
Save durran/263819 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PetOwner < Mongoid::Document | |
field :title | |
has_one :address | |
end | |
class Address < Mongoid::Document | |
field :street | |
belongs_to :addressable, :inverse_of => :address | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
context "when address is a has one" do | |
before do | |
@owner = PetOwner.create(:title => "AKC") | |
@address = Address.new(:street => "Fido Street") | |
@owner.address = @address | |
@owner.save | |
end | |
it "is a single object and not an array" do | |
@from_db = PetOwner.find(@owner.id) | |
@from_db.address.should == @address | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment