Commit 8beb32abe01de832279d813e0f27ff1cb845057d
1 parent
2917f48f
Exists in
theme-brasil-digital-from-staging
and in
9 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
@@ -313,7 +313,11 @@ class AccountController < ApplicationController | @@ -313,7 +313,11 @@ class AccountController < ApplicationController | ||
313 | session[:notice] = nil # consume the notice | 313 | session[:notice] = nil # consume the notice |
314 | end | 314 | end |
315 | 315 | ||
316 | - @plugins.each { |plugin| user_data.merge!(plugin.user_data_extras) } | 316 | + @plugins.each do |plugin| |
317 | + user_data_extras = plugin.user_data_extras | ||
318 | + user_data_extras = instance_exec(&user_data_extras) if user_data_extras.kind_of?(Proc) | ||
319 | + user_data.merge!(user_data_extras) | ||
320 | + end | ||
317 | 321 | ||
318 | render :text => user_data.to_json, :layout => false, :content_type => "application/javascript" | 322 | render :text => user_data.to_json, :layout => false, :content_type => "application/javascript" |
319 | end | 323 | end |
test/functional/account_controller_test.rb
@@ -717,7 +717,9 @@ class AccountControllerTest < ActionController::TestCase | @@ -717,7 +717,9 @@ class AccountControllerTest < ActionController::TestCase | ||
717 | 717 | ||
718 | class Plugin2 < Noosfero::Plugin | 718 | class Plugin2 < Noosfero::Plugin |
719 | def user_data_extras | 719 | def user_data_extras |
720 | - {:test => 5} | 720 | + proc do |
721 | + {:test => 5} | ||
722 | + end | ||
721 | end | 723 | end |
722 | end | 724 | end |
723 | Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) | 725 | Noosfero::Plugin.stubs(:all).returns([Plugin1.name, Plugin2.name]) |