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