Commit 4dcb9b6e35bbe2e478f14a82e82af26e32ad43b2

Authored by Antonio Terceiro
1 parent 6c2bf00e

ActionItem942: force display of mandatory fields on signup

app/helpers/application_helper.rb
@@ -686,7 +686,7 @@ module ApplicationHelper @@ -686,7 +686,7 @@ module ApplicationHelper
686 field_html += capture(&block) 686 field_html += capture(&block)
687 end 687 end
688 if (controller.action_name == 'signup') 688 if (controller.action_name == 'signup')
689 - if profile.signup_fields.include?(name) 689 + if profile.signup_fields.include?(name) || profile.required_fields.include?(name)
690 result = field_html 690 result = field_html
691 end 691 end
692 else 692 else
test/unit/application_helper_test.rb
@@ -332,6 +332,21 @@ class ApplicationHelperTest < Test::Unit::TestCase @@ -332,6 +332,21 @@ class ApplicationHelperTest < Test::Unit::TestCase
332 assert_equal '<span>SIGNUP_FIELD</span>', optional_field(profile, 'field', 'SIGNUP_FIELD') 332 assert_equal '<span>SIGNUP_FIELD</span>', optional_field(profile, 'field', 'SIGNUP_FIELD')
333 end 333 end
334 334
  335 + should 'display required fields on signup even if admin did not marked field to show up in signup' do
  336 + env = Environment.create!(:name => 'env test')
  337 + stubs(:environment).returns(env)
  338 +
  339 + controller = mock
  340 + stubs(:controller).returns(controller)
  341 + controller.expects(:action_name).returns('signup')
  342 +
  343 + stubs(:required).with('SIGNUP_FIELD').returns('<span>SIGNUP_FIELD</span>')
  344 + profile = Person.new
  345 + profile.stubs(:required_fields).returns(['field'])
  346 + profile.stubs(:signup_fields).returns([])
  347 + assert_equal '<span>SIGNUP_FIELD</span>', optional_field(profile, 'field', 'SIGNUP_FIELD')
  348 + end
  349 +
335 should 'not ask_to_join unless profile defined' do 350 should 'not ask_to_join unless profile defined' do
336 e = Environment.default 351 e = Environment.default
337 e.stubs(:enabled?).with(:disable_join_community_popup).returns(false) 352 e.stubs(:enabled?).with(:disable_join_community_popup).returns(false)