Commit 4055244823591fa1870f41050c1440057a35c13a
1 parent
b71b8f5d
Exists in
staging
and in
42 other branches
ActionItem31: displaying home page
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@978 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
2 changed files
with
22 additions
and
7 deletions
Show diff stats
app/controllers/public/content_viewer_controller.rb
| ... | ... | @@ -7,13 +7,14 @@ class ContentViewerController < PublicController |
| 7 | 7 | |
| 8 | 8 | if path.blank? |
| 9 | 9 | @page = profile.home_page |
| 10 | - # FIXME need to do something when the user didn't set a homepage | |
| 10 | + if @page.nil? | |
| 11 | + render :action => 'no_home_page' | |
| 12 | + end | |
| 11 | 13 | else |
| 12 | 14 | @page = profile.articles.find_by_path(path) |
| 13 | - end | |
| 14 | - | |
| 15 | - if @page.nil? | |
| 16 | - render_not_found(@path) | |
| 15 | + if @page.nil? | |
| 16 | + render_not_found(@path) | |
| 17 | + end | |
| 17 | 18 | end |
| 18 | 19 | end |
| 19 | 20 | ... | ... |
test/functional/content_viewer_controller_test.rb
| ... | ... | @@ -28,11 +28,25 @@ class ContentViewerControllerTest < Test::Unit::TestCase |
| 28 | 28 | end |
| 29 | 29 | |
| 30 | 30 | def test_should_display_homepage |
| 31 | - flunk 'pending' | |
| 31 | + a = profile.articles.build(:name => 'test') | |
| 32 | + a.save! | |
| 33 | + profile.home_page = a | |
| 34 | + profile.save! | |
| 35 | + | |
| 36 | + get :view_page, :profile => profile.identifier, :page => [ 'test'] | |
| 37 | + | |
| 38 | + assert_response :success | |
| 39 | + assert_template 'view_page' | |
| 40 | + assert_equal a, assigns(:page) | |
| 32 | 41 | end |
| 33 | 42 | |
| 34 | 43 | def test_should_display_something_else_for_empty_homepage |
| 35 | - flunk 'pending' | |
| 44 | + profile.articles.destroy_all | |
| 45 | + | |
| 46 | + get :view_page, :profile => profile.identifier, :page => [] | |
| 47 | + | |
| 48 | + assert_response :success | |
| 49 | + assert_template 'no_home_page' | |
| 36 | 50 | end |
| 37 | 51 | |
| 38 | 52 | def test_should_get_not_found_error_for_unexisting_page | ... | ... |