From dda4ea04820e7f4f84257d87817748591b4e9a09 Mon Sep 17 00:00:00 2001 From: Ariejan de Vroom Date: Thu, 16 Sep 2010 17:05:29 +0200 Subject: [PATCH 1/2] Minor syntax changes to get the tests up and running on 1.8.7 --- lib/toto.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/toto.rb b/lib/toto.rb index 3740fc2..0f77c5e 100644 --- a/lib/toto.rb +++ b/lib/toto.rb @@ -97,7 +97,8 @@ def / self[:root] end - def go route, type = :html, env + def go route, type, env + type ||= :html route << self./ if route.empty? type, path = type =~ /html|xml|json/ ? type.to_sym : :html, route.join('/') context = lambda do |data, page| @@ -335,7 +336,7 @@ def call env path, mime = @request.path_info.split('.') route = (path || '/').split('/').reject {|i| i.empty? } - response = @site.go(route, *(mime ? mime : []), env) + response = @site.go(route, mime ? mime : [], env) @response.body = [response[:body]] @response['Content-Length'] = response[:body].length.to_s unless response[:body].empty? From abec5ec91ae4133cc40a46d4e1afc1f9b141b759 Mon Sep 17 00:00:00 2001 From: Ariejan de Vroom Date: Fri, 17 Sep 2010 08:54:14 +0200 Subject: [PATCH 2/2] Fix for issue 57 When adding a `*.builder` file to the `templates` directory the file is not picked up unless you also create a `*.rhtml` file in the `pages` directory. This fixes issue 57. --- lib/toto.rb | 8 ++++++-- test/templates/custom.builder | 10 ++++++++++ test/toto_test.rb | 7 +++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 test/templates/custom.builder diff --git a/lib/toto.rb b/lib/toto.rb index 0f77c5e..0766de9 100644 --- a/lib/toto.rb +++ b/lib/toto.rb @@ -166,8 +166,12 @@ def title end def render page, type - content = to_html page, @config - type == :html ? to_html(:layout, @config, &Proc.new { content }) : send(:"to_#{type}", page) + if type == :html + content = to_html page, @config + to_html(:layout, @config, &Proc.new { content }) + else + send(:"to_#{type}", page) + end end def to_xml page diff --git a/test/templates/custom.builder b/test/templates/custom.builder new file mode 100644 index 0000000..e9cab34 --- /dev/null +++ b/test/templates/custom.builder @@ -0,0 +1,10 @@ +xml.instruct! +xml.custom do + xml.title @config[:title] + xml.id @config[:url] + + xml.child do + xml.name "Testing Baby" + end +end + diff --git a/test/toto_test.rb b/test/toto_test.rb index 8b1ed62..7b1bb73 100644 --- a/test/toto_test.rb +++ b/test/toto_test.rb @@ -102,6 +102,13 @@ asserts("summary shouldn't be empty") { topic.body }.includes_html("summary" => /.{10,}/) end + context "GET /custom.xml (custom XML)" do + setup { @toto.get('/custom.xml') } + asserts("content type is set properly") { topic.content_type }.equals "application/xml" + asserts("body should be valid xml") { topic.body }.includes_html("custom > child" => /.+/) + asserts("summary shouldn't be empty") { topic.body }.includes_html("name" => /.{10,}/) + end + context "GET to a repo name" do setup do class Toto::Repo