From c7edb005c159f7890558deb94b4fd4fa801fa017 Mon Sep 17 00:00:00 2001 From: Leandro Nunes dos Santos Date: Mon, 2 Jun 2014 10:13:18 -0300 Subject: [PATCH] make profile_editor_extras respond to procs properly --- app/views/profile_editor/edit.html.erb | 2 +- test/functional/profile_editor_controller_test.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/views/profile_editor/edit.html.erb b/app/views/profile_editor/edit.html.erb index 594cb2d..e27da93 100644 --- a/app/views/profile_editor/edit.html.erb +++ b/app/views/profile_editor/edit.html.erb @@ -53,7 +53,7 @@ <%= @plugins.dispatch(:profile_editor_extras).map do |content| - if content.respond_to?(:call) then instance_eval(&content).html_safe else content.html_safe end + content.kind_of?(Proc) ? self.instance_eval(&content) : content end.join("\n") %> diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb index 29604a5..a6b0f28 100644 --- a/test/functional/profile_editor_controller_test.rb +++ b/test/functional/profile_editor_controller_test.rb @@ -894,6 +894,23 @@ class ProfileEditorControllerTest < ActionController::TestCase assert_tag :tag => 'input', :attributes => {:id => 'field_added_by_plugin', :value => 'value_of_field_added_by_plugin'} end + should 'add extra content with block provided by plugins on edit' do + class TestProfileEditPlugin < Noosfero::Plugin + def profile_editor_extras + lambda do + render :text => "" + end + end + end + Noosfero::Plugin.stubs(:all).returns([TestProfileEditPlugin.to_s]) + + Noosfero::Plugin::Manager.any_instance.stubs(:enabled_plugins).returns([TestProfileEditPlugin.new]) + + get :edit, :profile => profile.identifier + + assert_tag :tag => 'input', :attributes => {:id => 'field_added_by_plugin', :value => 'value_of_field_added_by_plugin'} + end + should 'show image upload field from profile editor' do env = Environment.default env.custom_person_fields = { } -- libgit2 0.21.2