Commit ed789b83fc38017ac8a3b2f5f4779424d729952a

Authored by AntonioTerceiro
1 parent fa264ba7

ActionItem9: implementing VirtualCommunity#has_terms_of_use?



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@105 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/virtual_community.rb
... ... @@ -62,7 +62,11 @@ class VirtualCommunity < ActiveRecord::Base
62 62 def terms_of_use=(value)
63 63 self.settings['terms_of_use'] = value
64 64 end
65   -
  65 +
  66 + def has_terms_of_use?
  67 + ! self.settings['terms_of_use'].nil?
  68 + end
  69 +
66 70 # #################################################
67 71 # Validations
68 72 # #################################################
... ...
test/unit/virtual_community_test.rb
... ... @@ -65,10 +65,18 @@ class VirtualCommunityTest < Test::Unit::TestCase
65 65  
66 66 def test_terms_of_use
67 67 v = VirtualCommunity.new(:name => 'My test virtual community')
  68 + assert_nil v.terms_of_use
68 69 v.terms_of_use = 'To be part of this virtual community, you must accept the following terms: ...'
69 70 assert v.save
70 71 id = v.id
71 72 assert_equal 'To be part of this virtual community, you must accept the following terms: ...', VirtualCommunity.find(id).terms_of_use
72 73 end
73 74  
  75 + def test_has_terms_of_use
  76 + v = VirtualCommunity.new
  77 + assert !v.has_terms_of_use?
  78 + v.terms_of_use = 'some terms of use'
  79 + assert v.has_terms_of_use?
  80 + end
  81 +
74 82 end
... ...