From e9584878c472a9278bfca2671ead78ec08442122 Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Wed, 18 Jul 2007 17:29:26 +0000 Subject: [PATCH] ActionItem3: making possible to disable all features --- app/models/virtual_community.rb | 4 ++++ test/unit/virtual_community_test.rb | 6 ++++++ 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/app/models/virtual_community.rb b/app/models/virtual_community.rb index a9b0d6b..327f802 100644 --- a/app/models/virtual_community.rb +++ b/app/models/virtual_community.rb @@ -38,7 +38,11 @@ class VirtualCommunity < ActiveRecord::Base self.settings["#{feature}_enabled"] == true end + # enables the features identified by features, which is expected to + # be an Enumarable object containing the identifiers of the desired features. + # Passing nil is the same as passing an empty Array. def enabled_features=(features) + features ||= [] self.class.available_features.keys.each do |feature| if features.include? feature self.enable(feature) diff --git a/test/unit/virtual_community_test.rb b/test/unit/virtual_community_test.rb index 6a57ad1..4a84716 100644 --- a/test/unit/virtual_community_test.rb +++ b/test/unit/virtual_community_test.rb @@ -44,6 +44,12 @@ class VirtualCommunityTest < Test::Unit::TestCase assert v.enabled?('feature1') && v.enabled?('feature2') && !v.enabled?('feature3') end + def test_enabled_features_no_features_enabled + v = virtual_communities(:colivre_net) + v.enabled_features = nil + assert !v.enabled?('feature1') && !v.enabled?('feature2') && !v.enabled?('feature3') + end + def test_name_is_mandatory v = VirtualCommunity.new v.valid? -- libgit2 0.21.2