From 3829248f22e2b4b7a54a3349a9c39f5abf63856b Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Mon, 25 Nov 2013 09:21:22 +0000 Subject: [PATCH] Fixed test --- app/helpers/application_helper.rb | 2 +- test/unit/application_helper_test.rb | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index c8c7542..57f9536 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1424,7 +1424,7 @@ module ApplicationHelper end def filter_html(html, source) - if @plugins && source.has_macro? + if @plugins && source && source.has_macro? html = convert_macro(html, source) unless @plugins.enabled_macros.blank? #TODO This parse should be done through the macro infra, but since there # are old things that do not support it we are keeping this hot spot. diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index 980cacd..f46865f 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -814,7 +814,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase assert_no_match /Test1/, parsed_html end - should 'not convert macro if there is no macro plugin active' do + should 'not convert macro if source is nil' do profile = create_user('testuser').person article = fast_create(Article, :profile_id => profile.id) class Plugin1 < Noosfero::Plugin; end @@ -822,11 +822,24 @@ class ApplicationHelperTest < ActiveSupport::TestCase environment = Environment.default environment.enable_plugin(Plugin1) @plugins = Noosfero::Plugin::Manager.new(environment, self) - + expects(:convert_macro).never filter_html(article.body, nil) end + should 'not convert macro if there is no macro plugin active' do + profile = create_user('testuser').person + article = fast_create(Article, :profile_id => profile.id) + class Plugin1 < Noosfero::Plugin; end + + environment = Environment.default + environment.enable_plugin(Plugin1) + @plugins = Noosfero::Plugin::Manager.new(environment, self) + + expects(:convert_macro).never + filter_html(article.body, article) + end + protected include NoosferoTestHelper -- libgit2 0.21.2