[noosfero/noosfero][master] check if Article exists before trying to get its ID
Joenio Costa
gitlab at gitlab.com
Thu Jun 11 00:49:09 BRT 2015
Joenio Costa pushed to branch master at Noosfero / noosfero
Commits:
6e6ba4e8 by Joenio Costa at 2015-06-11T00:43:32Z
check if Article exists before trying to get its ID
resolves issue #79
- - - - -
2 changed files:
- plugins/metadata/lib/metadata_plugin.rb
- plugins/metadata/test/functional/content_viewer_controller_test.rb
Changes:
=====================================
plugins/metadata/lib/metadata_plugin.rb
=====================================
--- a/plugins/metadata/lib/metadata_plugin.rb
+++ b/plugins/metadata/lib/metadata_plugin.rb
@@ -23,7 +23,7 @@ class MetadataPlugin < Noosfero::Plugin
},
content_viewer: {
variable: proc do
- if profile and profile.home_page_id == @page.id
+ if profile and @page and profile.home_page_id == @page.id
@profile
elsif @page.respond_to? :encapsulated_file
@page.encapsulated_file
=====================================
plugins/metadata/test/functional/content_viewer_controller_test.rb
=====================================
--- a/plugins/metadata/test/functional/content_viewer_controller_test.rb
+++ b/plugins/metadata/test/functional/content_viewer_controller_test.rb
@@ -48,4 +48,13 @@ class ContentViewerControllerTest < ActionController::TestCase
assert_tag tag: 'meta', attributes: { property: 'og:image', content: /\/images\/x.png/ }
end
+ should 'render not_found page properly' do
+ assert_equal false, Article.exists?(:slug => 'non-existing-page')
+ assert_nothing_raised do
+ get :view_page, profile: profile.identifier, page: [ 'non-existing-page' ]
+ assert_response 404 # not found
+ assert_template 'not_found'
+ end
+ end
+
end
View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/6e6ba4e8586c66fcecd37bf7263590aae6289a10
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150611/5376e340/attachment.html>
More information about the Noosfero-dev
mailing list