Commit 6c191c6cedc3b81d3bb6a012f85e23496d22edd0

Authored by MoisesMachado
1 parent da607601

ActionItem6: some untis tests of enterprise model made

git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@318 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/enterprise_controller.rb
@@ -40,6 +40,7 @@ class EnterpriseController < ApplicationController @@ -40,6 +40,7 @@ class EnterpriseController < ApplicationController
40 40
41 def edit 41 def edit
42 @enterprise = @my_enterprises.find(params[:id]) 42 @enterprise = @my_enterprises.find(params[:id])
  43 + @validation_entities = Organization.find(:all) - [@enterprise]
43 end 44 end
44 45
45 def update 46 def update
app/views/enterprise/show.rhtml
@@ -13,4 +13,4 @@ @@ -13,4 +13,4 @@
13 <%= link_to _('Edit enterprise'), :action => 'edit', :id => @enterprise %> 13 <%= link_to _('Edit enterprise'), :action => 'edit', :id => @enterprise %>
14 <%= link_to _('Delete enterprise'), :action => 'destroy', :id => @enterprise %> 14 <%= link_to _('Delete enterprise'), :action => 'destroy', :id => @enterprise %>
15 <%= link_to _('Register new enterprise'), :action => 'register_form' %> 15 <%= link_to _('Register new enterprise'), :action => 'register_form' %>
16 -<%= link_to _('Affiliate'), :action => 'affiliate' %> 16 +<%= link_to _('Affiliate'), :action => 'affiliate' unless @my_enterprises.include?(@enterprise) %>
test/unit/enterprise_test.rb
@@ -45,23 +45,4 @@ class EnterpriseTest &lt; Test::Unit::TestCase @@ -45,23 +45,4 @@ class EnterpriseTest &lt; Test::Unit::TestCase
45 p1.identifier = 'bli' 45 p1.identifier = 'bli'
46 end 46 end
47 end 47 end
48 -  
49 - def test_numericality_year  
50 - count = Enterprise.count  
51 -  
52 - e = Enterprise.new(:identifier => 'test_numericality_year', :name => 'numeric_year')  
53 - e.foundation_year = 'xxxx'  
54 - e.valid?  
55 - assert e.errors.invalid?(:foundation_year)  
56 -  
57 - e.foundation_year = 20.07  
58 - e.valid?  
59 - assert e.errors.invalid?(:foundation_year)  
60 -  
61 - e.foundation_year = 2007  
62 - e.valid?  
63 - assert ! e.errors.invalid?(:foundation_year)  
64 -  
65 - end  
66 -  
67 end 48 end
test/unit/organization_info_test.rb
@@ -3,8 +3,20 @@ require File.dirname(__FILE__) + &#39;/../test_helper&#39; @@ -3,8 +3,20 @@ require File.dirname(__FILE__) + &#39;/../test_helper&#39;
3 class OrganizationInfoTest < Test::Unit::TestCase 3 class OrganizationInfoTest < Test::Unit::TestCase
4 fixtures :organization_infos 4 fixtures :organization_infos
5 5
6 - # Replace this with your real tests.  
7 - def test_truth  
8 - assert true 6 + def test_numericality_year
  7 + count = OrganizationInfo.count
  8 +
  9 + oi = OrganizationInfo.new
  10 + oi.foundation_year = 'xxxx'
  11 + oi.valid?
  12 + assert oi.errors.invalid?(:foundation_year)
  13 +
  14 + oi.foundation_year = 20.07
  15 + oi.valid?
  16 + assert oi.errors.invalid?(:foundation_year)
  17 +
  18 + oi.foundation_year = 2007
  19 + oi.valid?
  20 + assert ! oi.errors.invalid?(:foundation_year)
9 end 21 end
10 end 22 end