<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>views/entry/by_collection_and_entry-map.js</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -28,9 +28,8 @@ class Store
   end
 
   def find_entry(collection, entry)
-    document = get('entry/by_collection', [collection, entry])
-    raise EntryNotFound unless document
-    document.to_atom_entry
+    document = get('entry/by_collection_and_entry', [collection, entry])
+    document ? document['value'].to_atom_entry : raise(EntryNotFound)
   end
 
   def create_entry(collection, entry)</diff>
      <filename>lib/store.rb</filename>
    </modified>
    <modified>
      <diff>@@ -44,6 +44,29 @@ describe 'Store' do
       store.database
     end
 
+    describe '#get' do
+      setup do
+        Store.class_eval { public :get }
+        @store = Store.new(TestDatabase)
+        @store.stubs(:database).returns(@database)
+      end
+
+      it 'query the given view with the given key and limit to a single row' do
+        @database.expects(:view).with('my_view/all', :key =&gt; 'the key', :count =&gt; 1).returns('rows' =&gt; [])
+        @store.get('my_view/all', 'the key')
+      end
+
+      it 'returns the first row' do
+        @database.stubs(:view).returns('rows' =&gt; ['foo', 'bar'])
+        @store.get('my_view/all', 'the key').should.equal 'foo'
+      end
+
+      it 'returns nil if no document was found' do
+        @database.stubs(:view).returns('rows' =&gt; [])
+        @store.get('my_view/all', 'the key').should.be.nil
+      end
+    end
+
     describe '#atom_collection_from' do
       it 'extracts the first row that is a collection an returns an Atom::Feed' do
         @store.atom_collection_from(@rows).should.be.an.instance_of(Atom::Feed)
@@ -117,25 +140,24 @@ describe 'Store' do
     end
 
     setup do
-      @rows = [{'title' =&gt; 'foo', 'content' =&gt; 'bar'}]
-      @database.stubs(:view).returns('rows' =&gt; @rows)
+      @doc = @rows.last
+      @store.stubs(:get).returns(@doc)
       Hash.any_instance.stubs(:to_atom_entry).returns(Atom::Entry.new)
     end
 
     it 'finds the entry using the view entry/by_collection' do
-      @database.expects(:view).with('entry/by_collection',
-        :key =&gt; ['my_collection', 'my_entry'], :count =&gt; 1).
-        returns('rows' =&gt; @rows)
+      @store.expects(:get).with('entry/by_collection_and_entry',
+        ['my_collection', 'my_entry']).returns(@doc)
       do_find
     end
 
     it 'raises EntryNotFound if no entry were found in the given collection' do
-      @database.stubs(:view).returns('rows' =&gt; [])
+      @store.stubs(:get).returns(nil)
       lambda { do_find }.should.raise EntryNotFound
     end
 
-    it 'coerce the document to an Atom::Entry using #to_atom_entry' do
-      @rows.first.expects(:to_atom_entry).returns('an atom entry')
+    it 'coerces the document to an Atom::Entry' do
+      @doc['value'].expects(:to_atom_entry).returns('an atom entry')
       do_find.should.equal 'an atom entry'
     end
   end</diff>
      <filename>test/store_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>8273188ad75219f3bed74f8b44d629dceba25a1b</id>
    </parent>
  </parents>
  <author>
    <name>Simon Rozet</name>
    <email>simon@rozet.name</email>
  </author>
  <url>http://github.com/sr/saloon/commit/c20cbf31cc055e22167e4d16464d948607e5e484</url>
  <id>c20cbf31cc055e22167e4d16464d948607e5e484</id>
  <committed-date>2008-10-06T04:39:15-07:00</committed-date>
  <authored-date>2008-10-06T04:29:08-07:00</authored-date>
  <message>fix #find_entry</message>
  <tree>7d0979fc4ae72f646546dbf4919502ff5ee9cd77</tree>
  <committer>
    <name>Simon Rozet</name>
    <email>simon@rozet.name</email>
  </committer>
</commit>
