Commit 9c3ef78d7df71c8ca8727a436a233a341b526fce
1 parent
c68dd701
Exists in
master
and in
29 other branches
adding virtual_community stuff
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@4 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
4 changed files
with
60 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,12 @@ |
1 | +class VirtualCommunity < ActiveRecord::Base | |
2 | + validates_presence_of :domain | |
3 | + validates_format_of :domain, :with => /^(\w+\.)+\w+$/ | |
4 | + | |
5 | + validates_presence_of :identifier | |
6 | + validates_format_of :identifier, :with => /^[a-z][a-z0-9_]+[a-z0-9]$/ | |
7 | + | |
8 | + serialize :features | |
9 | + def features | |
10 | + self[:features] ||= {} | |
11 | + end | |
12 | +end | ... | ... |
... | ... | @@ -0,0 +1,13 @@ |
1 | +class CreateVirtualCommunities < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + create_table :virtual_communities do |t| | |
4 | + t.column :name, :string | |
5 | + t.column :domain, :string | |
6 | + t.column :features, :text | |
7 | + end | |
8 | + end | |
9 | + | |
10 | + def self.down | |
11 | + drop_table :virtual_communities | |
12 | + end | |
13 | +end | ... | ... |
... | ... | @@ -0,0 +1,26 @@ |
1 | +require File.dirname(__FILE__) + '/../test_helper' | |
2 | + | |
3 | +class VirtualCommunityTest < Test::Unit::TestCase | |
4 | + fixtures :virtual_communities | |
5 | + | |
6 | + def test_features | |
7 | + c = VirtualCommunity.new | |
8 | + assert_kind_of Hash, c.features | |
9 | + end | |
10 | + | |
11 | + def test_domain_validation | |
12 | + c = VirtualCommunity.new | |
13 | + c.valid? | |
14 | + assert c.errors.invalid?(:domain) | |
15 | + | |
16 | + c.domain = 'bliblibli' | |
17 | + c.valid? | |
18 | + assert c.errors.invalid?(:domain) | |
19 | + | |
20 | + c.domain = 'test.net' | |
21 | + c.valid? | |
22 | + assert ! c.errors.invalid?(:domain) | |
23 | + end | |
24 | + | |
25 | + | |
26 | +end | ... | ... |