Commit df49d0370604ea29397ef74537e75373be1fef9f
1 parent
5de43a78
Exists in
master
and in
27 other branches
Accept proc in user_data_extras from plugins
Showing
2 changed files
with
8 additions
and
2 deletions
Show diff stats
app/controllers/public/account_controller.rb
... | ... | @@ -315,7 +315,11 @@ class AccountController < ApplicationController |
315 | 315 | session[:notice] = nil # consume the notice |
316 | 316 | end |
317 | 317 | |
318 | - @plugins.each { |plugin| user_data.merge!(plugin.user_data_extras) } | |
318 | + @plugins.each do |plugin| | |
319 | + user_data_extras = plugin.user_data_extras | |
320 | + user_data_extras = instance_exec(&user_data_extras) if user_data_extras.kind_of?(Proc) | |
321 | + user_data.merge!(user_data_extras) | |
322 | + end | |
319 | 323 | |
320 | 324 | render :text => user_data.to_json, :layout => false, :content_type => "application/javascript" |
321 | 325 | end | ... | ... |
test/functional/account_controller_test.rb
... | ... | @@ -712,7 +712,9 @@ class AccountControllerTest < ActionController::TestCase |
712 | 712 | |
713 | 713 | class Plugin2 < Noosfero::Plugin |
714 | 714 | def user_data_extras |
715 | - {:test => 5} | |
715 | + proc do | |
716 | + {:test => 5} | |
717 | + end | |
716 | 718 | end |
717 | 719 | end |
718 | 720 | Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) | ... | ... |