Commit e9584878c472a9278bfca2671ead78ec08442122

Authored by AntonioTerceiro
1 parent 7c86f010

ActionItem3: making possible to disable all features



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@91 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/virtual_community.rb
... ... @@ -38,7 +38,11 @@ class VirtualCommunity < ActiveRecord::Base
38 38 self.settings["#{feature}_enabled"] == true
39 39 end
40 40  
  41 + # enables the features identified by <tt>features</tt>, which is expected to
  42 + # be an Enumarable object containing the identifiers of the desired features.
  43 + # Passing <tt>nil</tt> is the same as passing an empty Array.
41 44 def enabled_features=(features)
  45 + features ||= []
42 46 self.class.available_features.keys.each do |feature|
43 47 if features.include? feature
44 48 self.enable(feature)
... ...
test/unit/virtual_community_test.rb
... ... @@ -44,6 +44,12 @@ class VirtualCommunityTest &lt; Test::Unit::TestCase
44 44 assert v.enabled?('feature1') && v.enabled?('feature2') && !v.enabled?('feature3')
45 45 end
46 46  
  47 + def test_enabled_features_no_features_enabled
  48 + v = virtual_communities(:colivre_net)
  49 + v.enabled_features = nil
  50 + assert !v.enabled?('feature1') && !v.enabled?('feature2') && !v.enabled?('feature3')
  51 + end
  52 +
47 53 def test_name_is_mandatory
48 54 v = VirtualCommunity.new
49 55 v.valid?
... ...