diff --git a/test/functional/features_controller_test.rb b/test/functional/features_controller_test.rb index f788708..afc6b5f 100644 --- a/test/functional/features_controller_test.rb +++ b/test/functional/features_controller_test.rb @@ -102,8 +102,6 @@ class FeaturesControllerTest < Test::Unit::TestCase assert_equal true, e.custom_person_fields['cell_phone']['required'] end - should 'disable check_box for required if active is not checked' - should 'list possible enterprise fields' do uses_host 'anhetegua.net' Enterprise.expects(:fields).returns(['contact_person', 'contact_email']).at_least_once diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index e0733ba..db49892 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -263,6 +263,73 @@ class ApplicationHelperTest < Test::Unit::TestCase assert_equal '', profile_sex_icon(Person.new(:sex => 'male')) end + should 'display field on signup' do + env = Environment.create!(:name => 'env test') + stubs(:environment).returns(env) + + controller = mock + stubs(:controller).returns(controller) + controller.expects(:action_name).returns('signup') + + profile = Person.new + profile.expects(:signup_fields).returns(['field']) + assert_equal 'SIGNUP_FIELD', custom_field(profile, 'field', 'SIGNUP_FIELD') + end + + should 'not display field on signup' do + env = Environment.create!(:name => 'env test') + stubs(:environment).returns(env) + + controller = mock + stubs(:controller).returns(controller) + controller.expects(:action_name).returns('signup') + + profile = Person.new + profile.expects(:signup_fields).returns([]) + assert_equal '', custom_field(profile, 'field', 'SIGNUP_FIELD') + end + + should 'display active fields' do + env = Environment.create!(:name => 'env test') + stubs(:environment).returns(env) + + controller = mock + stubs(:controller).returns(controller) + controller.expects(:action_name).returns('edit') + + profile = Person.new + profile.expects(:active_fields).returns(['field']) + assert_equal 'SIGNUP_FIELD', custom_field(profile, 'field', 'SIGNUP_FIELD') + end + + should 'not display active fields' do + env = Environment.create!(:name => 'env test') + stubs(:environment).returns(env) + + controller = mock + stubs(:controller).returns(controller) + controller.expects(:action_name).returns('edit') + + profile = Person.new + profile.expects(:active_fields).returns([]) + assert_equal '', custom_field(profile, 'field', 'SIGNUP_FIELD') + end + + should 'display required fields' do + env = Environment.create!(:name => 'env test') + stubs(:environment).returns(env) + + controller = mock + stubs(:controller).returns(controller) + controller.expects(:action_name).returns('edit') + + stubs(:required).with('SIGNUP_FIELD').returns('SIGNUP_FIELD') + profile = Person.new + profile.expects(:active_fields).returns(['field']) + profile.expects(:required_fields).returns(['field']) + assert_equal 'SIGNUP_FIELD', custom_field(profile, 'field', 'SIGNUP_FIELD') + end + protected def url_for(args = {}) -- libgit2 0.21.2