From f375bbf5b8e3dc463b71dfc9fe02299da695d92f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Wed, 12 Feb 2014 16:17:20 +0100 Subject: accept Content-Type change via rack response --- lib/zorglub/node.rb | 2 +- spec/node_spec.rb | 5 +++++ spec/spec_helper.rb | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/zorglub/node.rb b/lib/zorglub/node.rb index 8b1bee0..0e4ef20 100644 --- a/lib/zorglub/node.rb +++ b/lib/zorglub/node.rb @@ -276,7 +276,7 @@ module Zorglub catch(:stop_realize) { feed! response.write @content - response.header['Content-Type'] = ( @mime || 'text/html' ) + response.header['Content-Type'] ||= ( @mime || 'text/html' ) response.finish response } diff --git a/spec/node_spec.rb b/spec/node_spec.rb index 3b2ecc3..058e626 100644 --- a/spec/node_spec.rb +++ b/spec/node_spec.rb @@ -166,6 +166,11 @@ describe Zorglub do r.header['Content-type'].should == 'text/view' end # + it "should be able to override through rack response mime-type" do + r = Node0.my_call '/do_content_type' + r.header['Content-type'].should == 'text/mine' + end + # it "partial should render correctly" do Node0.partial({},:do_partial, 1, 2).should == 'partial_content' end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a88a25c..eea6bfe 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -60,6 +60,10 @@ class Node0 < Zorglub::Node def do_render engine! 'real' end + def do_content_type + engine! 'real' + response.header['Content-Type'] = 'text/mine' + end def do_partial a1, a2 engine! 'real' end -- cgit v1.1-2-g2b99