diff --git a/app/controllers/public/content_viewer_controller.rb b/app/controllers/public/content_viewer_controller.rb index 85c4c63..8bd6d12 100644 --- a/app/controllers/public/content_viewer_controller.rb +++ b/app/controllers/public/content_viewer_controller.rb @@ -7,13 +7,14 @@ class ContentViewerController < PublicController if path.blank? @page = profile.home_page - # FIXME need to do something when the user didn't set a homepage + if @page.nil? + render :action => 'no_home_page' + end else @page = profile.articles.find_by_path(path) - end - - if @page.nil? - render_not_found(@path) + if @page.nil? + render_not_found(@path) + end end end diff --git a/test/functional/content_viewer_controller_test.rb b/test/functional/content_viewer_controller_test.rb index 19690e8..e919739 100644 --- a/test/functional/content_viewer_controller_test.rb +++ b/test/functional/content_viewer_controller_test.rb @@ -28,11 +28,25 @@ class ContentViewerControllerTest < Test::Unit::TestCase end def test_should_display_homepage - flunk 'pending' + a = profile.articles.build(:name => 'test') + a.save! + profile.home_page = a + profile.save! + + get :view_page, :profile => profile.identifier, :page => [ 'test'] + + assert_response :success + assert_template 'view_page' + assert_equal a, assigns(:page) end def test_should_display_something_else_for_empty_homepage - flunk 'pending' + profile.articles.destroy_all + + get :view_page, :profile => profile.identifier, :page => [] + + assert_response :success + assert_template 'no_home_page' end def test_should_get_not_found_error_for_unexisting_page -- libgit2 0.21.2