diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 5e38d494..a3ae9894 100755 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -182,13 +182,13 @@ class WikiController < ApplicationController def pdf page = wiki.read_page(@web_name, @page_name) - safe_page_name = page.name.gsub(/\W/, '') - file_name = "#{safe_page_name}-#{web.address}-#{page.created_at.strftime("%Y-%m-%d-%H-%M")}" + safe_page_name = @page.name.gsub(/\W/, '') + file_name = "#{safe_page_name}-#{@web.address}-#{@page.created_at.strftime("%Y-%m-%d-%H-%M")}" file_path = EXPORT_DIRECTORY + file_name export_page_to_tex(file_path + '.tex') unless FileTest.exists?(file_path + '.tex') convert_tex_to_pdf(file_path + '.tex') - send_export(file_name + '.pdf', file_path + '.pdf') + send_file(file_name + '.pdf') end def print diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index eac4e3d9..6eda9b16 100755 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -4,6 +4,10 @@ require File.dirname(__FILE__) + '/../test_helper' require 'wiki_controller' require 'rexml/document' +unless RedClothForTex.available? + $stderr.puts 'Warning: latex is not available, skipping all related tests' +end + # Raise errors beyond the default web-based presentation class WikiController; def rescue_action(e) logger.error(e); raise e end; end @@ -257,6 +261,13 @@ class WikiControllerTest < Test::Unit::TestCase end + def test_pdf + if RedClothForTex.available? + process('pdf', 'web' => 'wiki1', 'id' => 'HomePage') + end + end + + def test_print process('print', 'web' => 'wiki1', 'id' => 'HomePage') assert_success