Commit cc9cebd9957b41045787db143b09bf58c3f613c5
Exists in
master
and in
29 other branches
Merge branch 'enterprises' into 'master'
Only shows visible and enabled enterprises on environment statistics block See merge request !441
Showing
4 changed files
with
25 additions
and
1 deletions
Show diff stats
app/models/profile.rb
... | ... | @@ -123,6 +123,7 @@ class Profile < ActiveRecord::Base |
123 | 123 | scope :visible, :conditions => { :visible => true } |
124 | 124 | scope :disabled, :conditions => { :visible => false } |
125 | 125 | scope :public, :conditions => { :visible => true, :public_profile => true } |
126 | + scope :enabled, :conditions => { :enabled => true } | |
126 | 127 | |
127 | 128 | # Subclasses must override this method |
128 | 129 | scope :more_popular | ... | ... |
plugins/statistics/lib/statistics_block.rb
plugins/statistics/test/unit/statistics_block_test.rb
... | ... | @@ -126,6 +126,19 @@ class StatisticsBlockTest < ActiveSupport::TestCase |
126 | 126 | assert_equal 2, b.enterprises |
127 | 127 | end |
128 | 128 | |
129 | + should 'return the amount of enabled enterprises' do | |
130 | + b = StatisticsBlock.new | |
131 | + e = fast_create(Environment) | |
132 | + | |
133 | + fast_create(Enterprise, :environment_id => e.id) | |
134 | + fast_create(Enterprise, :environment_id => e.id) | |
135 | + fast_create(Enterprise, :enabled => false, :environment_id => e.id) | |
136 | + | |
137 | + b.expects(:owner).at_least_once.returns(e) | |
138 | + | |
139 | + assert_equal 2, b.enterprises | |
140 | + end | |
141 | + | |
129 | 142 | should 'categories return the amount of categories of the Environment' do |
130 | 143 | b = StatisticsBlock.new |
131 | 144 | e = fast_create(Environment) | ... | ... |
test/unit/profile_test.rb
... | ... | @@ -1989,4 +1989,14 @@ class ProfileTest < ActiveSupport::TestCase |
1989 | 1989 | assert_equal true, profile.disable |
1990 | 1990 | assert_equal false, profile.visible? |
1991 | 1991 | end |
1992 | + | |
1993 | + should 'fetch enabled profiles' do | |
1994 | + p1 = fast_create(Profile, :enabled => true) | |
1995 | + p2 = fast_create(Profile, :enabled => true) | |
1996 | + p3 = fast_create(Profile, :enabled => false) | |
1997 | + | |
1998 | + assert_includes Profile.enabled, p1 | |
1999 | + assert_includes Profile.enabled, p2 | |
2000 | + assert_not_includes Profile.enabled, p3 | |
2001 | + end | |
1992 | 2002 | end | ... | ... |