Commit 60f220f46b2b2c7bde95b18dbe35302051008c16

Authored by Rodrigo Souto
1 parent af8e08a4

[stoa] Signup form extra content hotspot

app/views/account/_signup_form.rhtml
... ... @@ -73,6 +73,8 @@
73 73 <%= render :partial => 'profile_editor/person_form', :locals => {:f => f} %>
74 74 <% end %>
75 75  
  76 + <%= @plugins.map(:signup_extra_contents).collect { |content| instance_eval(&content) }.join("") %>
  77 +
76 78 <% unless @terms_of_use.blank? %>
77 79 <div id='terms-of-use-box' class='formfieldline'>
78 80 <%= labelled_check_box(_('I accept the %s') % link_to(_('terms of use'), {:controller => 'home', :action => 'terms'}, :target => '_blank'), 'user[terms_accepted]') %>
... ...
lib/noosfero/plugin.rb
... ... @@ -238,4 +238,10 @@ class Noosfero::Plugin
238 238 def comment_saved(comment)
239 239 end
240 240  
  241 + # -> Adds fields to the signup form
  242 + # returns = lambda block that creates a html code
  243 + def signup_extra_contents
  244 + nil
  245 + end
  246 +
241 247 end
... ...
test/functional/account_controller_test.rb
... ... @@ -737,6 +737,27 @@ class AccountControllerTest &lt; ActionController::TestCase
737 737 end
738 738 end
739 739  
  740 + should 'add extra content on signup forms from plugins' do
  741 + class Plugin1 < Noosfero::Plugin
  742 + def signup_extra_contents
  743 + lambda {"<strong>Plugin1 text</strong>"}
  744 + end
  745 + end
  746 + class Plugin2 < Noosfero::Plugin
  747 + def signup_extra_contents
  748 + lambda {"<strong>Plugin2 text</strong>"}
  749 + end
  750 + end
  751 +
  752 + Environment.default.enable_plugin(Plugin1.name)
  753 + Environment.default.enable_plugin(Plugin2.name)
  754 +
  755 + get :signup
  756 +
  757 + assert_tag :tag => 'strong', :content => 'Plugin1 text'
  758 + assert_tag :tag => 'strong', :content => 'Plugin2 text'
  759 + end
  760 +
740 761 protected
741 762 def new_user(options = {}, extra_options ={})
742 763 data = {:profile_data => person_data}
... ...