Commit 3829248f22e2b4b7a54a3349a9c39f5abf63856b

Authored by Daniela Feitosa
1 parent 3a110cba

Fixed test

(ActionItem2748)
app/helpers/application_helper.rb
... ... @@ -1424,7 +1424,7 @@ module ApplicationHelper
1424 1424 end
1425 1425  
1426 1426 def filter_html(html, source)
1427   - if @plugins && source.has_macro?
  1427 + if @plugins && source && source.has_macro?
1428 1428 html = convert_macro(html, source) unless @plugins.enabled_macros.blank?
1429 1429 #TODO This parse should be done through the macro infra, but since there
1430 1430 # are old things that do not support it we are keeping this hot spot.
... ...
test/unit/application_helper_test.rb
... ... @@ -814,7 +814,7 @@ class ApplicationHelperTest < ActiveSupport::TestCase
814 814 assert_no_match /Test1/, parsed_html
815 815 end
816 816  
817   - should 'not convert macro if there is no macro plugin active' do
  817 + should 'not convert macro if source is nil' do
818 818 profile = create_user('testuser').person
819 819 article = fast_create(Article, :profile_id => profile.id)
820 820 class Plugin1 < Noosfero::Plugin; end
... ... @@ -822,11 +822,24 @@ class ApplicationHelperTest &lt; ActiveSupport::TestCase
822 822 environment = Environment.default
823 823 environment.enable_plugin(Plugin1)
824 824 @plugins = Noosfero::Plugin::Manager.new(environment, self)
825   -
  825 +
826 826 expects(:convert_macro).never
827 827 filter_html(article.body, nil)
828 828 end
829 829  
  830 + should 'not convert macro if there is no macro plugin active' do
  831 + profile = create_user('testuser').person
  832 + article = fast_create(Article, :profile_id => profile.id)
  833 + class Plugin1 < Noosfero::Plugin; end
  834 +
  835 + environment = Environment.default
  836 + environment.enable_plugin(Plugin1)
  837 + @plugins = Noosfero::Plugin::Manager.new(environment, self)
  838 +
  839 + expects(:convert_macro).never
  840 + filter_html(article.body, article)
  841 + end
  842 +
830 843 protected
831 844 include NoosferoTestHelper
832 845  
... ...