From 88d7dc832d0af811810d6945b343476cf3e9040b Mon Sep 17 00:00:00 2001 From: Alexey Verkhovsky Date: Fri, 21 Jan 2005 19:41:46 +0000 Subject: [PATCH] Setting Content-Type to UTF-8, to be consistent with meta-data in the HTML itself --- app/controllers/application.rb | 6 +++++- test/functional/application_test.rb | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 test/functional/application_test.rb diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 09219455..2540e8a3 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -7,6 +7,7 @@ class ApplicationController < ActionController::Base # implements Instiki's legacy URLs require 'url_rewriting_hack' + before_filter :set_utf8_http_header after_filter :remember_location # For injecting a different wiki model implementation. Intended for use in tests @@ -31,7 +32,6 @@ class ApplicationController < ActionController::Base @@REMEMBER_NOT = ['locked', 'save'] def remember_location -logger.debug @request.method if @response.headers['Status'] == '200 OK' unless @@REMEMBER_NOT.include? action_name or @request.method != :get @session[:return_to] = url_for @@ -54,4 +54,8 @@ logger.debug @request.method end end + def set_utf8_http_header + @response.headers['Content-Type'] = 'text/html; charset=UTF-8' + end + end diff --git a/test/functional/application_test.rb b/test/functional/application_test.rb new file mode 100644 index 00000000..84767958 --- /dev/null +++ b/test/functional/application_test.rb @@ -0,0 +1,26 @@ +# Unit tests for ApplicationController (the abstract controller class) + +require File.dirname(__FILE__) + '/../test_helper' +require 'wiki_controller' +require 'rexml/document' + +# Need some concrete class to test the abstract class features +class WikiController; def rescue_action(e) logger.error(e); raise e end; end + +class ApplicationTest < Test::Unit::TestCase + + def setup + setup_test_wiki + setup_controller_test(WikiController) + end + + def tear_down + tear_down_wiki + end + + def test_utf8_header + r = process('show', 'web' => 'wiki1', 'id' => 'HomePage') + assert_equal 'text/html; charset=UTF-8', r.headers['Content-Type'] + end + +end