Commit 484934812c1a786f79fb619342b17216c09144f8
Committed by
Daniela Feitosa
1 parent
de7aba86
Exists in
master
and in
29 other branches
Handle optional fields for not logged users in login form
Showing
2 changed files
with
18 additions
and
1 deletions
Show diff stats
app/helpers/application_helper.rb
@@ -871,7 +871,7 @@ module ApplicationHelper | @@ -871,7 +871,7 @@ module ApplicationHelper | ||
871 | field_html += capture(&block) | 871 | field_html += capture(&block) |
872 | end | 872 | end |
873 | 873 | ||
874 | - if controller.action_name == 'signup' || controller.action_name == 'new_community' || (controller.controller_name == "enterprise_registration" && controller.action_name == 'index') | 874 | + if controller.action_name == 'signup' || controller.action_name == 'new_community' || (controller.controller_name == "enterprise_registration" && controller.action_name == 'index') || (controller.controller_name == 'home' && controller.action_name == 'index' && user.nil?) |
875 | if profile.signup_fields.include?(name) | 875 | if profile.signup_fields.include?(name) |
876 | result = field_html | 876 | result = field_html |
877 | end | 877 | end |
test/unit/application_helper_test.rb
@@ -360,6 +360,23 @@ class ApplicationHelperTest < ActionView::TestCase | @@ -360,6 +360,23 @@ class ApplicationHelperTest < ActionView::TestCase | ||
360 | assert_equal 'SIGNUP_FIELD', optional_field(enterprise, 'field', 'SIGNUP_FIELD') | 360 | assert_equal 'SIGNUP_FIELD', optional_field(enterprise, 'field', 'SIGNUP_FIELD') |
361 | end | 361 | end |
362 | 362 | ||
363 | + should 'display field on home for a not logged user' do | ||
364 | + env = create(Environment, :name => 'env test') | ||
365 | + stubs(:environment).returns(env) | ||
366 | + | ||
367 | + controller = mock | ||
368 | + stubs(:controller).returns(controller) | ||
369 | + controller.stubs(:controller_name).returns('home') | ||
370 | + controller.stubs(:action_name).returns('index') | ||
371 | + | ||
372 | + stubs(:user).returns(nil) | ||
373 | + | ||
374 | + | ||
375 | + person = Person.new | ||
376 | + person.expects(:signup_fields).returns(['field']) | ||
377 | + assert_equal 'SIGNUP_FIELD', optional_field(person, 'field', 'SIGNUP_FIELD') | ||
378 | + end | ||
379 | + | ||
363 | should 'display field on community creation' do | 380 | should 'display field on community creation' do |
364 | env = create(Environment, :name => 'env test') | 381 | env = create(Environment, :name => 'env test') |
365 | stubs(:environment).returns(env) | 382 | stubs(:environment).returns(env) |