Permalink
Browse files

added support for pages in templates/pages/

  • Loading branch information...
1 parent 4d98261 commit ba478a5e7d1690a779e31562dcaf29ed7687f630 cloudhead committed Jan 17, 2010
Showing with 17 additions and 13 deletions.
  1. +10 −12 lib/toto.rb
  2. +7 −1 test/toto_test.rb
View
@@ -83,27 +83,25 @@ def go route, type = :html
body, status = if Context.new.respond_to?(:"to_#{type}")
if route.first =~ /\d{4}/
- begin
- case route.size
- when 1..3
- [Context.new(archives(route * '-'), @config).render(:archives, type), 200]
- when 4
- [Context.new(article(route), @config).render(:article, type), 200]
- else http 400
- end
- rescue Errno::ENOENT => e
- $stderr.puts e
- http 404
+ case route.size
+ when 1..3
+ [Context.new(archives(route * '-'), @config).render(:archives, type), 200]
+ when 4
+ [Context.new(article(route), @config).render(:article, type), 200]
+ else http 400
end
elsif respond_to?(route = route.first.to_sym)
[Context.new(send(route, type), @config).render(route, type), 200]
else
- http 401
+ [Context.new({}, @config).render(route.to_sym, type), 200]
end
else
http 400
end
+ rescue Errno::ENOENT => e
+ body, status = http 404
+ ensure
return :body => body, :type => type, :status => status
end
View
@@ -29,6 +29,12 @@
end
end
+ context "GET /about" do
+ setup { @toto.get('/about') }
+ asserts("returns a 200") { topic.status }.equals 200
+ asserts("body is not empty") { not topic.body.empty? }
+ end
+
context "GET a single article" do
setup { @toto.get("/1900/05/17/the-wonderful-wizard-of-oz") }
asserts("returns a 200") { topic.status }.equals 200
@@ -56,7 +62,7 @@
context "GET to an unknown route" do
setup { @toto.get('/unknown') }
- should("returns a 401") { topic.status }.equals 401
+ should("returns a 404") { topic.status }.equals 404
end
context "Request is invalid" do

0 comments on commit ba478a5

Please sign in to comment.