Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

test for finding association when the key isn't an integer

  • Loading branch information...
commit 0ce261f4fd3a07a8dbcbef35e51820a20fd825cd 1 parent dd23943
@snovotny snovotny authored
Showing with 25 additions and 0 deletions.
  1. +25 −0 spec/textual_keys_spec.rb
View
25 spec/textual_keys_spec.rb
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.