Commit c3ee273285cbaab0e787755321383abbba562498
1 parent
dc8aa572
Exists in
master
and in
22 other branches
Do not say "n enteprises" if they are disabled
ActionItem1598
Showing
2 changed files
with
16 additions
and
5 deletions
Show diff stats
app/models/environment_statistics_block.rb
... | ... | @@ -17,11 +17,12 @@ class EnvironmentStatisticsBlock < Block |
17 | 17 | enterprises = owner.enterprises.visible.count |
18 | 18 | communities = owner.communities.visible.count |
19 | 19 | |
20 | - info = [ | |
21 | - n_('One user', '%{num} users', users) % { :num => users }, | |
22 | - n__('One enterprise', '%{num} enterprises', enterprises) % { :num => enterprises }, | |
23 | - n__('One community', '%{num} communities', communities) % { :num => communities }, | |
24 | - ] | |
20 | + info = [] | |
21 | + info << (n_('One user', '%{num} users', users) % { :num => users }) | |
22 | + unless owner.enabled?('disable_asset_enterprises') | |
23 | + info << (n__('One enterprise', '%{num} enterprises', enterprises) % { :num => enterprises }) | |
24 | + end | |
25 | + info << (n__('One community', '%{num} communities', communities) % { :num => communities }) | |
25 | 26 | |
26 | 27 | block_title(title) + content_tag('ul', info.map {|item| content_tag('li', item) }.join("\n")) |
27 | 28 | end | ... | ... |
test/unit/environment_statistics_block_test.rb
... | ... | @@ -83,4 +83,14 @@ class EnvironmentStatisticsBlockTest < Test::Unit::TestCase |
83 | 83 | assert_match /One community/, content |
84 | 84 | end |
85 | 85 | |
86 | + should 'not display enterprises if disabled' do | |
87 | + env = Environment.new | |
88 | + env.enable('disable_asset_enterprises') | |
89 | + | |
90 | + block = EnvironmentStatisticsBlock.new | |
91 | + block.stubs(:owner).returns(env) | |
92 | + | |
93 | + assert_no_match /enterprises/i, block.content | |
94 | + end | |
95 | + | |
86 | 96 | end | ... | ... |