From 6ffa3e979b28c7ba4aadb0e56cb84a7e40140454 Mon Sep 17 00:00:00 2001 From: Daniela Soares Feitosa Date: Wed, 8 Aug 2012 14:34:14 -0300 Subject: [PATCH] Removed template option when environment doesn't have any --- app/helpers/application_helper.rb | 1 + test/unit/application_helper_test.rb | 6 ++++++ 2 files changed, 7 insertions(+), 0 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b699c99..3a36cda 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1333,6 +1333,7 @@ module ApplicationHelper end def template_options(klass, field_name) + return '' if klass.templates.count == 0 return hidden_field_tag("#{field_name}[template_id]", klass.templates.first.id) if klass.templates.count == 1 counter = 0 diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index 562bee1..135bf17 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -242,6 +242,12 @@ class ApplicationHelperTest < ActiveSupport::TestCase assert_equal '/designs/templates/mytemplate/stylesheets/style.css', template_stylesheet_path end + should 'not display templates options when there is no template' do + [Person, Community, Enterprise].each do |klass| + assert_equal '', template_options(klass, 'profile_data') + end + end + should 'return nil if disable_categories is enabled' do env = fast_create(Environment, :name => 'env test') stubs(:environment).returns(env) -- libgit2 0.21.2