Permalink
Browse files

Reversed order of Maker#parents to fix Resource#resources.

  • Loading branch information...
baldowl committed Feb 2, 2009
1 parent ba4b959 commit 3d08d78514e8139a360ec23a0465fb2fa4ba1aa8
Showing with 6 additions and 2 deletions.
  1. +1 −1 lib/sinatras-hat/maker.rb
  2. +1 −1 spec/maker_spec.rb
  3. +4 −0 spec/resource_spec.rb
@@ -93,7 +93,7 @@ def prefix
end
def parents
- @parents ||= parent ? Array(parent) + parent.parents : []
+ @parents ||= parent ? parent.parents + Array(parent) : []
end
def resource_path(*args)
View
@@ -289,7 +289,7 @@ class Comment; end
grand_parent = new_maker(Article)
parent = new_maker(Article, :parent => grand_parent)
child = new_maker(Comment, :parent => parent)
- child.parents.should == [parent, grand_parent]
+ child.parents.should == [grand_parent, parent]
end
end
end
View
@@ -62,6 +62,10 @@
@resource = Sinatra::Hat::Resource.new(@grand_child)
end
+ it "returns nested resource path" do
+ @resource.path('/:id').should == "/articles/:article_id/comments/:comment_id/replies/:id"
+ end
+
it "can return path for model object" do
@resource.path('/:id', @reply).should == "/articles/#{@article.to_param}/comments/#{@comment.to_param}/replies/#{@reply.to_param}"
end

0 comments on commit 3d08d78

Please sign in to comment.