diff --git a/test/functional/application_test.rb b/test/functional/application_test.rb index 5530c1b0..92f7cb43 100755 --- a/test/functional/application_test.rb +++ b/test/functional/application_test.rb @@ -1,8 +1,8 @@ # Unit tests for ApplicationController (the abstract controller class) -require File.dirname(__FILE__) + '/../test_helper' +#require File.dirname(__FILE__) + '/../test_helper' require 'wiki_controller' -require 'rexml/document' +#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 @@ -10,6 +10,8 @@ class WikiController; def rescue_action(e) logger.error(e); raise e end; end class ApplicationTest < Test::Unit::TestCase fixtures :webs, :pages, :revisions, :system + Mime::LOOKUP["text/html"] = HTML + def setup @controller = WikiController.new @request = ActionController::TestRequest.new @@ -34,11 +36,30 @@ class ApplicationTest < Test::Unit::TestCase assert_equal 'application/xhtml+xml; charset=utf-8', @response.headers['type'] end + def test_accept_header_xhtml + @request.user_agent = 'Mozilla/5.0' + @request.env.update({'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' }) + get :show, :web => 'wiki1', :id => 'HomePage' + assert_equal 'application/xhtml+xml; charset=utf-8', @response.headers['type'] + end + + def test_accept_header_html + @request.user_agent = 'Foo' + @request.env.update({'HTTP_ACCEPT' => 'text/html,application/xml;q=0.9,*/*;q=0.8' }) + get :show, :web => 'wiki1', :id => 'HomePage' + assert_equal 'text/html; charset=utf-8', @response.headers['type'] + end + def test_tex_mime_type get :tex, :web => 'wiki1', :id => 'HomePage' assert_equal 'text/plain; charset=utf-8', @response.headers['type'] end + def test_atom_mime_type + get :atom_with_content, :web => 'wiki1' + assert_equal 'application/atom+xml; charset=utf-8', @response.headers['type'] + end + def test_connect_to_model_unknown_wiki get :show, :web => 'unknown_wiki', :id => 'HomePage' assert_response :missing