From ed789b83fc38017ac8a3b2f5f4779424d729952a Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Thu, 19 Jul 2007 19:30:18 +0000 Subject: [PATCH] ActionItem9: implementing VirtualCommunity#has_terms_of_use? --- app/models/virtual_community.rb | 6 +++++- test/unit/virtual_community_test.rb | 8 ++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/app/models/virtual_community.rb b/app/models/virtual_community.rb index c553695..4217284 100644 --- a/app/models/virtual_community.rb +++ b/app/models/virtual_community.rb @@ -62,7 +62,11 @@ class VirtualCommunity < ActiveRecord::Base def terms_of_use=(value) self.settings['terms_of_use'] = value end - + + def has_terms_of_use? + ! self.settings['terms_of_use'].nil? + end + # ################################################# # Validations # ################################################# diff --git a/test/unit/virtual_community_test.rb b/test/unit/virtual_community_test.rb index 435c922..fa520a6 100644 --- a/test/unit/virtual_community_test.rb +++ b/test/unit/virtual_community_test.rb @@ -65,10 +65,18 @@ class VirtualCommunityTest < Test::Unit::TestCase def test_terms_of_use v = VirtualCommunity.new(:name => 'My test virtual community') + assert_nil v.terms_of_use v.terms_of_use = 'To be part of this virtual community, you must accept the following terms: ...' assert v.save id = v.id assert_equal 'To be part of this virtual community, you must accept the following terms: ...', VirtualCommunity.find(id).terms_of_use end + def test_has_terms_of_use + v = VirtualCommunity.new + assert !v.has_terms_of_use? + v.terms_of_use = 'some terms of use' + assert v.has_terms_of_use? + end + end -- libgit2 0.21.2