diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-01-30 18:42:14 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2012-01-30 18:42:14 +0000 |
commit | 3d27bf5318ef22d5d66e1863a62c3c6c1f203d66 (patch) | |
tree | 41da619407d5a38bd1538434597fc34fdb23d310 /test | |
parent | a03c585a84d3197e0c35617dc78c9e3ca264c56a (diff) | |
download | redmine-3d27bf5318ef22d5d66e1863a62c3c6c1f203d66.tar.gz redmine-3d27bf5318ef22d5d66e1863a62c3c6c1f203d66.zip |
Adds export of all wiki pages to a PDF file (#3463).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8734 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/wiki_controller_test.rb | 17 | ||||
-rw-r--r-- | test/integration/routing/wiki_test.rb | 9 |
2 files changed, 24 insertions, 2 deletions
diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 3665a75fd..59b1a4319 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -618,12 +618,13 @@ class WikiControllerTest < ActionController::TestCase assert_tag 'a', :attributes => { :href => '/projects/ecookbook/activity.atom?show_wiki_edits=1'} end - def test_export + def test_export_to_html @request.session[:user_id] = 2 get :export, :project_id => 'ecookbook' assert_response :success assert_not_nil assigns(:pages) + assert assigns(:pages).any? assert_equal "text/html", @response.content_type assert_select "a[name=?]", "CookBook_documentation" @@ -631,7 +632,19 @@ class WikiControllerTest < ActionController::TestCase assert_select "a[name=?]", "Page_with_an_inline_image" end - def test_export_without_permission + def test_export_to_pdf + @request.session[:user_id] = 2 + get :export, :project_id => 'ecookbook', :format => 'pdf' + + assert_response :success + assert_not_nil assigns(:pages) + assert assigns(:pages).any? + assert_equal 'application/pdf', @response.content_type + assert_equal 'attachment; filename="ecookbook.pdf"', @response.headers['Content-Disposition'] + assert @response.body.starts_with?('%PDF') + end + + def test_export_without_permission_should_redirect get :export, :project_id => 'ecookbook' assert_response 302 diff --git a/test/integration/routing/wiki_test.rb b/test/integration/routing/wiki_test.rb index 1445442b5..35ee4310c 100644 --- a/test/integration/routing/wiki_test.rb +++ b/test/integration/routing/wiki_test.rb @@ -29,6 +29,11 @@ class RoutingWikiTest < ActionController::IntegrationTest :id => 'lalala' } ) assert_routing( + { :method => 'get', :path => "/projects/567/wiki/lalala.pdf" }, + { :controller => 'wiki', :action => 'show', :project_id => '567', + :id => 'lalala', :format => 'pdf' } + ) + assert_routing( { :method => 'get', :path => "/projects/1/wiki/CookBook_documentation/diff" }, { :controller => 'wiki', :action => 'diff', :project_id => '1', :id => 'CookBook_documentation' } @@ -60,6 +65,10 @@ class RoutingWikiTest < ActionController::IntegrationTest { :controller => 'wiki', :action => 'export', :project_id => '567' } ) assert_routing( + { :method => 'get', :path => "/projects/567/wiki/export.pdf" }, + { :controller => 'wiki', :action => 'export', :project_id => '567', :format => 'pdf' } + ) + assert_routing( { :method => 'get', :path => "/projects/567/wiki/index" }, { :controller => 'wiki', :action => 'index', :project_id => '567' } ) |