public
Fork of yrashk/zoid
Description: Zoid is a minimalistic REST-based webapp framework on top of StrokeDB
Clone URL: git://github.com/crossblaim/zoid.git
Initial DocumentNotFound routing has been added
yrashk (author)
Wed Apr 30 21:38:02 -0700 2008
commit  5fa78ef541fcc5fdeed5a6e4a9e3a1cd570c7332
tree    9a775ee45b3bdfd867988f49d5a70b821beb84a6
parent  4644ec5255fd548bb8c8ed0303d3937df09f2a1d
...
1
2
 
 
 
3
4
5
...
14
15
16
17
 
18
19
20
...
1
2
3
4
5
6
7
8
...
17
18
19
 
20
21
22
23
0
@@ -1,5 +1,8 @@
0
 module Zoid
0
   nsurl "http://strokedb.com/zoid"
0
+
0
+ DocumentNotFound = StrokeDB::Meta.new
0
+
0
   Application = StrokeDB::Meta.new do
0
     validates_presence_of :name
0
     validates_presence_of :nsurl
0
@@ -14,7 +17,7 @@ module Zoid
0
           entity
0
         end
0
       when /^\/(\w+)\/#{StrokeDB::UUID_RE}$/
0
- store.find($2)
0
+ app_module.const_get($1.camelize).find($2) || DocumentNotFound.new(:path => path)
0
       when /^\/(\w+)\/#{StrokeDB::UUID_RE}.#{StrokeDB::UUID_RE}$/
0
         store.find($2,$3)
0
       end
...
4
5
6
 
7
8
9
...
33
34
35
 
 
 
 
 
36
37
38
...
4
5
6
7
8
9
10
...
34
35
36
37
38
39
40
41
42
43
44
0
@@ -4,6 +4,7 @@ module RoutingExample
0
   nsurl 'http://strokedb.com/zoid/spec#routing'
0
   remove_const(:SomeName) if defined?(SomeName)
0
   SomeName = StrokeDB::Meta.new
0
+ AnotherMeta = StrokeDB::Meta.new
0
   SomeView = StrokeDB::View.create!("SomeView") do |view|
0
     def view.map(key,val)
0
     end
0
@@ -33,6 +34,11 @@ describe Zoid::Application, "router" do
0
     @app.route_for('GET', "/some_name/#{doc.uuid}").should == doc
0
   end
0
 
0
+ it "should route GET + /name/uuid to DocumentNotFound document if specified UUID with given meta was not found" do
0
+ doc = RoutingExample::AnotherMeta.create!
0
+ @app.route_for('GET', "/some_name/#{doc.uuid}").should be_a_kind_of(Zoid::DocumentNotFound)
0
+ end
0
+
0
   it "should route GET + /name/uuid.version to a named entity with specified UUID" do
0
     doc = RoutingExample::SomeName.create!.versions.current
0
     @app.route_for('GET', "/some_name/#{doc.uuid}.#{doc.version}").should == doc

Comments

    No one has commented yet.