Commit 6ffa3e979b28c7ba4aadb0e56cb84a7e40140454
1 parent
017d5562
Exists in
master
and in
28 other branches
Removed template option when environment doesn't have any
(ActionItem2378)
Showing
2 changed files
with
7 additions
and
0 deletions
Show diff stats
app/helpers/application_helper.rb
@@ -1333,6 +1333,7 @@ module ApplicationHelper | @@ -1333,6 +1333,7 @@ module ApplicationHelper | ||
1333 | end | 1333 | end |
1334 | 1334 | ||
1335 | def template_options(klass, field_name) | 1335 | def template_options(klass, field_name) |
1336 | + return '' if klass.templates.count == 0 | ||
1336 | return hidden_field_tag("#{field_name}[template_id]", klass.templates.first.id) if klass.templates.count == 1 | 1337 | return hidden_field_tag("#{field_name}[template_id]", klass.templates.first.id) if klass.templates.count == 1 |
1337 | 1338 | ||
1338 | counter = 0 | 1339 | counter = 0 |
test/unit/application_helper_test.rb
@@ -242,6 +242,12 @@ class ApplicationHelperTest < ActiveSupport::TestCase | @@ -242,6 +242,12 @@ class ApplicationHelperTest < ActiveSupport::TestCase | ||
242 | assert_equal '/designs/templates/mytemplate/stylesheets/style.css', template_stylesheet_path | 242 | assert_equal '/designs/templates/mytemplate/stylesheets/style.css', template_stylesheet_path |
243 | end | 243 | end |
244 | 244 | ||
245 | + should 'not display templates options when there is no template' do | ||
246 | + [Person, Community, Enterprise].each do |klass| | ||
247 | + assert_equal '', template_options(klass, 'profile_data') | ||
248 | + end | ||
249 | + end | ||
250 | + | ||
245 | should 'return nil if disable_categories is enabled' do | 251 | should 'return nil if disable_categories is enabled' do |
246 | env = fast_create(Environment, :name => 'env test') | 252 | env = fast_create(Environment, :name => 'env test') |
247 | stubs(:environment).returns(env) | 253 | stubs(:environment).returns(env) |