Skip to content
This repository has been archived by the owner on Sep 2, 2019. It is now read-only.

Commit

Permalink
test for finding association when the key isn't an integer
Browse files Browse the repository at this point in the history
  • Loading branch information
snovotny committed Jul 21, 2012
1 parent dd23943 commit 0ce261f
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions spec/textual_keys_spec.rb
Expand Up @@ -26,4 +26,29 @@ class Foo
Foo.first.hostname.should == "hostname1"
end
end

describe "textual keys" do
it "should find associated objects using textual key" do
class Cart
include DataMapper::Resource
property :id, String, :key => true, :unique_index => true
has n, :items
end

class Item
include DataMapper::Resource
property :id, String, :key => true, :unique_index => true
property :description, String
belongs_to :cart
end
DataMapper.finalize

cart = Cart.create(:id => "6e0fbb69-4e29-4719-a067-a850b5685317")
item = cart.items.create(:id => "246ffaed-f060-4a0c-83ef-39008899c0db", :description => "test item")

Cart.get("6e0fbb69-4e29-4719-a067-a850b5685317").items.should == [item]
end
end


end

0 comments on commit 0ce261f

Please sign in to comment.