Commit c7edb005c159f7890558deb94b4fd4fa801fa017

Authored by Leandro Santos
Committed by Daniela Feitosa
1 parent e927bd9d

make profile_editor_extras respond to procs properly

Conflicts:
	app/views/profile_editor/edit.html.erb

(ActionItem3152)
app/views/profile_editor/edit.html.erb
... ... @@ -53,7 +53,7 @@
53 53  
54 54 <%=
55 55 @plugins.dispatch(:profile_editor_extras).map do |content|
56   - if content.respond_to?(:call) then instance_eval(&content).html_safe else content.html_safe end
  56 + content.kind_of?(Proc) ? self.instance_eval(&content) : content
57 57 end.join("\n")
58 58 %>
59 59  
... ...
test/functional/profile_editor_controller_test.rb
... ... @@ -894,6 +894,23 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase
894 894 assert_tag :tag => 'input', :attributes => {:id => 'field_added_by_plugin', :value => 'value_of_field_added_by_plugin'}
895 895 end
896 896  
  897 + should 'add extra content with block provided by plugins on edit' do
  898 + class TestProfileEditPlugin < Noosfero::Plugin
  899 + def profile_editor_extras
  900 + lambda do
  901 + render :text => "<input id='field_added_by_plugin' value='value_of_field_added_by_plugin'/>"
  902 + end
  903 + end
  904 + end
  905 + Noosfero::Plugin.stubs(:all).returns([TestProfileEditPlugin.to_s])
  906 +
  907 + Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([TestProfileEditPlugin.new])
  908 +
  909 + get :edit, :profile => profile.identifier
  910 +
  911 + assert_tag :tag => 'input', :attributes => {:id => 'field_added_by_plugin', :value => 'value_of_field_added_by_plugin'}
  912 + end
  913 +
897 914 should 'show image upload field from profile editor' do
898 915 env = Environment.default
899 916 env.custom_person_fields = { }
... ...