From 43aadecc9978961368a565caf4bc9e87b3880371 Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Sun, 1 Feb 2009 16:17:14 -0600 Subject: [PATCH] Links in Published Webs Links in the 'show' action should be to the 'show' action. Links in the 'published' action should be to the 'published' action. Try to focus, Distler! --- lib/url_generator.rb | 14 +++++++++++--- test/functional/wiki_controller_test.rb | 7 +++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/lib/url_generator.rb b/lib/url_generator.rb index 690d1b2b..41717b0a 100644 --- a/lib/url_generator.rb +++ b/lib/url_generator.rb @@ -85,14 +85,22 @@ class UrlGenerator < AbstractUrlGenerator end when :publish if known_page - web = Web.find_by_address(web_address) - action = web.published? ? 'published' : 'show' - href = @controller.url_for :controller => 'wiki', :web => web_address, :action => action, + href = @controller.url_for :controller => 'wiki', :web => web_address, :action => 'published', :id => name %{#{text}} else %{#{text}} end + when :show + if known_page + href = @controller.url_for :controller => 'wiki', :web => web_address, :action => 'show', + :id => name + %{#{text}} + else + href = @controller.url_for :controller => 'wiki', :web => web_address, :action => 'new', + :id => name + %{#{text}?} + end else if known_page web = Web.find_by_address(web_address) diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index d7f867ef..666d5fe8 100755 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -319,6 +319,13 @@ class WikiControllerTest < Test::Unit::TestCase assert_response(:success) assert_equal @home, r.template_objects['page'] + assert_match /That Way<\/a>/, r.body + + r = process('show', 'web' => 'wiki1', 'id' => 'HomePage') + + assert_response(:success) + assert_equal @home, r.template_objects['page'] + assert_match /That Way<\/a>/, r.body end