Commit 3eec4c1ad8f65f27c8ee2df306596f1696d0be6a

Authored by MoisesMachado
1 parent aaa4b82e

ActionItem6: functional tests of enterprise controller now passes


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@325 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/enterprise_controller.rb
@@ -34,6 +34,8 @@ class EnterpriseController < ApplicationController @@ -34,6 +34,8 @@ class EnterpriseController < ApplicationController
34 redirect_to :action => 'index' 34 redirect_to :action => 'index'
35 else 35 else
36 flash[:notice] = _('Enterprise was not created') 36 flash[:notice] = _('Enterprise was not created')
  37 + @vitual_communities = VirtualCommunity.find(:all)
  38 + @validation_entities = Organization.find(:all)
37 render :action => 'register_form' 39 render :action => 'register_form'
38 end 40 end
39 end 41 end
@@ -49,6 +51,7 @@ class EnterpriseController < ApplicationController @@ -49,6 +51,7 @@ class EnterpriseController < ApplicationController
49 redirect_to :action => 'index' 51 redirect_to :action => 'index'
50 else 52 else
51 flash[:notice] = _('Could not update the enterprise') 53 flash[:notice] = _('Could not update the enterprise')
  54 + @validation_entities = Organization.find(:all) - [@enterprise]
52 render :action => 'edit' 55 render :action => 'edit'
53 end 56 end
54 end 57 end
@@ -65,6 +68,7 @@ class EnterpriseController < ApplicationController @@ -65,6 +68,7 @@ class EnterpriseController < ApplicationController
65 redirect_to :action => 'index' 68 redirect_to :action => 'index'
66 end 69 end
67 70
  71 +
68 protected 72 protected
69 73
70 def logon 74 def logon
app/models/profile.rb
@@ -23,6 +23,8 @@ class Profile < ActiveRecord::Base @@ -23,6 +23,8 @@ class Profile < ActiveRecord::Base
23 community 23 community
24 ] 24 ]
25 25
  26 + acts_as_taggable
  27 +
26 has_many :domains, :as => :owner 28 has_many :domains, :as => :owner
27 belongs_to :virtual_community 29 belongs_to :virtual_community
28 has_many :affiliations 30 has_many :affiliations
app/views/enterprise/_form.rhtml
@@ -27,3 +27,6 @@ @@ -27,3 +27,6 @@
27 27
28 <p><label for="validation_entity"><%= _('Validation Entity') %></label><br/> 28 <p><label for="validation_entity"><%= _('Validation Entity') %></label><br/>
29 <%= select 'validation_entity', 'id', @validation_entities.map{|v| [v.name, v.id] } %></p> 29 <%= select 'validation_entity', 'id', @validation_entities.map{|v| [v.name, v.id] } %></p>
  30 +
  31 +<p><label for="tag_list"><%= _('Tags') %></label><br/>
  32 +<%= text_field 'enterprise', 'tag_list', 'size' => 20 %></p>
app/views/enterprise/show.rhtml
@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 <p> <%= _('Legal Form: ') %> <%= @enterprise.organization_info.legal_form %> </p> 9 <p> <%= _('Legal Form: ') %> <%= @enterprise.organization_info.legal_form %> </p>
10 <p> <%= _('Economic activity: ') %> <%= @enterprise.organization_info.economic_activity %> </p> 10 <p> <%= _('Economic activity: ') %> <%= @enterprise.organization_info.economic_activity %> </p>
11 <p> <%= _('Management infomation: ') %> <%= @enterprise.organization_info.management_information %> </p> 11 <p> <%= _('Management infomation: ') %> <%= @enterprise.organization_info.management_information %> </p>
  12 +<p> <%= _('Tags:') %> <%= @enterprise.tag_list %> </p>
12 13
13 <%= link_to _('Edit enterprise'), :action => 'edit', :id => @enterprise %> 14 <%= link_to _('Edit enterprise'), :action => 'edit', :id => @enterprise %>
14 <%= link_to _('Delete enterprise'), :action => 'destroy', :id => @enterprise %> 15 <%= link_to _('Delete enterprise'), :action => 'destroy', :id => @enterprise %>
test/functional/enterprise_controller_test.rb
@@ -5,7 +5,7 @@ require &#39;enterprise_controller&#39; @@ -5,7 +5,7 @@ require &#39;enterprise_controller&#39;
5 class EnterpriseController; def rescue_action(e) raise e end; end 5 class EnterpriseController; def rescue_action(e) raise e end; end
6 6
7 class EnterpriseControllerTest < Test::Unit::TestCase 7 class EnterpriseControllerTest < Test::Unit::TestCase
8 - fixtures :users 8 + all_fixtures
9 9
10 def setup 10 def setup
11 @controller = EnterpriseController.new 11 @controller = EnterpriseController.new
@@ -16,9 +16,9 @@ class EnterpriseControllerTest &lt; Test::Unit::TestCase @@ -16,9 +16,9 @@ class EnterpriseControllerTest &lt; Test::Unit::TestCase
16 def test_logged_index 16 def test_logged_index
17 login_as 'ze' 17 login_as 'ze'
18 get :index 18 get :index
19 - assert_response :success 19 + assert_response :redirect
20 20
21 - assert_kind_of Array, assigns(:pending_enterprises) 21 + assert_kind_of Array, assigns(:my_pending_enterprises)
22 end 22 end
23 23
24 def test_not_logged_index 24 def test_not_logged_index
@@ -30,6 +30,7 @@ class EnterpriseControllerTest &lt; Test::Unit::TestCase @@ -30,6 +30,7 @@ class EnterpriseControllerTest &lt; Test::Unit::TestCase
30 30
31 def test_my_enterprises 31 def test_my_enterprises
32 login_as 'ze' 32 login_as 'ze'
  33 + get :index
33 assert_not_nil assigns(:my_enterprises) 34 assert_not_nil assigns(:my_enterprises)
34 assert_kind_of Array, assigns(:my_enterprises) 35 assert_kind_of Array, assigns(:my_enterprises)
35 end 36 end
@@ -42,7 +43,7 @@ class EnterpriseControllerTest &lt; Test::Unit::TestCase @@ -42,7 +43,7 @@ class EnterpriseControllerTest &lt; Test::Unit::TestCase
42 43
43 def test_register 44 def test_register
44 login_as 'ze' 45 login_as 'ze'
45 - post :register, :enterprise => {:name => 'register_test'} 46 + post :register, :enterprise => {:name => 'register_test', :identifier => 'register_test'}
46 assert_not_nil assigns(:enterprise) 47 assert_not_nil assigns(:enterprise)
47 48
48 assert_response :redirect 49 assert_response :redirect
@@ -53,7 +54,8 @@ class EnterpriseControllerTest &lt; Test::Unit::TestCase @@ -53,7 +54,8 @@ class EnterpriseControllerTest &lt; Test::Unit::TestCase
53 def test_fail_register 54 def test_fail_register
54 login_as 'ze' 55 login_as 'ze'
55 post :register, :enterprise => {:name => ''} 56 post :register, :enterprise => {:name => ''}
56 - assert_nil assigns(:enterprise) 57 + assert_response :success
  58 + assert !assigns(:enterprise).valid?
57 59
58 end 60 end
59 61