Commit 6e6ba4e8586c66fcecd37bf7263590aae6289a10

Authored by Joenio Costa
1 parent d90a9743

check if Article exists before trying to get its ID

resolves issue #79
plugins/metadata/lib/metadata_plugin.rb
... ... @@ -23,7 +23,7 @@ class MetadataPlugin < Noosfero::Plugin
23 23 },
24 24 content_viewer: {
25 25 variable: proc do
26   - if profile and profile.home_page_id == @page.id
  26 + if profile and @page and profile.home_page_id == @page.id
27 27 @profile
28 28 elsif @page.respond_to? :encapsulated_file
29 29 @page.encapsulated_file
... ...
plugins/metadata/test/functional/content_viewer_controller_test.rb
... ... @@ -48,4 +48,13 @@ class ContentViewerControllerTest < ActionController::TestCase
48 48 assert_tag tag: 'meta', attributes: { property: 'og:image', content: /\/images\/x.png/ }
49 49 end
50 50  
  51 + should 'render not_found page properly' do
  52 + assert_equal false, Article.exists?(:slug => 'non-existing-page')
  53 + assert_nothing_raised do
  54 + get :view_page, profile: profile.identifier, page: [ 'non-existing-page' ]
  55 + assert_response 404 # not found
  56 + assert_template 'not_found'
  57 + end
  58 + end
  59 +
51 60 end
... ...