noosfero | 2 new commits pushed to repository
Bráulio Bhavamitra
gitlab at gitlab.com
Wed Jan 28 19:45:10 BRST 2015
Bráulio Bhavamitra pushed to refs/heads/master at <a href="https://gitlab.com/noosfero/noosfero">Noosfero / noosfero</a>
Commits:
<a href="https://gitlab.com/noosfero/noosfero/commit/e8a3a54e2ff1f5115a7f79d9fc044df988c5d6d1">e8a3a54e</a> by Eduardo Passos
show only visible and enabled enterprises
Created a scope to show only visible and enabled enterprises on environment statistics block.
Bug fix from #2783
- - - - -
<a href="https://gitlab.com/noosfero/noosfero/commit/cc9cebd9957b41045787db143b09bf58c3f613c5">cc9cebd9</a> by Bráulio Bhavamitra
Merge branch 'enterprises' into 'master'
Only shows visible and enabled enterprises on environment statistics block
See merge request !441
- - - - -
Changes:
=====================================
app/models/profile.rb
=====================================
--- a/app/models/profile.rb
+++ b/app/models/profile.rb
@@ -123,6 +123,7 @@ class Profile < ActiveRecord::Base
scope :visible, :conditions => { :visible => true }
scope :disabled, :conditions => { :visible => false }
scope :public, :conditions => { :visible => true, :public_profile => true }
+ scope :enabled, :conditions => { :enabled => true }
# Subclasses must override this method
scope :more_popular
=====================================
plugins/statistics/lib/statistics_block.rb
=====================================
--- a/plugins/statistics/lib/statistics_block.rb
+++ b/plugins/statistics/lib/statistics_block.rb
@@ -85,7 +85,7 @@ class StatisticsBlock < Block
def enterprises
if owner.kind_of?(Environment) || owner.kind_of?(Person)
- owner.enterprises.visible.count
+ owner.enterprises.visible.enabled.count
else
0
end
=====================================
plugins/statistics/test/unit/statistics_block_test.rb
=====================================
--- a/plugins/statistics/test/unit/statistics_block_test.rb
+++ b/plugins/statistics/test/unit/statistics_block_test.rb
@@ -126,6 +126,19 @@ class StatisticsBlockTest < ActiveSupport::TestCase
assert_equal 2, b.enterprises
end
+ should 'return the amount of enabled enterprises' do
+ b = StatisticsBlock.new
+ e = fast_create(Environment)
+
+ fast_create(Enterprise, :environment_id => e.id)
+ fast_create(Enterprise, :environment_id => e.id)
+ fast_create(Enterprise, :enabled => false, :environment_id => e.id)
+
+ b.expects(:owner).at_least_once.returns(e)
+
+ assert_equal 2, b.enterprises
+ end
+
should 'categories return the amount of categories of the Environment' do
b = StatisticsBlock.new
e = fast_create(Environment)
=====================================
test/unit/profile_test.rb
=====================================
--- a/test/unit/profile_test.rb
+++ b/test/unit/profile_test.rb
@@ -1989,4 +1989,14 @@ class ProfileTest < ActiveSupport::TestCase
assert_equal true, profile.disable
assert_equal false, profile.visible?
end
+
+ should 'fetch enabled profiles' do
+ p1 = fast_create(Profile, :enabled => true)
+ p2 = fast_create(Profile, :enabled => true)
+ p3 = fast_create(Profile, :enabled => false)
+
+ assert_includes Profile.enabled, p1
+ assert_includes Profile.enabled, p2
+ assert_not_includes Profile.enabled, p3
+ end
end
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150128/90da5078/attachment-0001.html>
More information about the Noosfero-dev
mailing list