From 3eec4c1ad8f65f27c8ee2df306596f1696d0be6a Mon Sep 17 00:00:00 2001 From: MoisesMachado Date: Wed, 8 Aug 2007 15:24:58 +0000 Subject: [PATCH] ActionItem6: functional tests of enterprise controller now passes --- app/controllers/enterprise_controller.rb | 4 ++++ app/models/profile.rb | 2 ++ app/views/enterprise/_form.rhtml | 3 +++ app/views/enterprise/show.rhtml | 1 + test/functional/enterprise_controller_test.rb | 12 +++++++----- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/app/controllers/enterprise_controller.rb b/app/controllers/enterprise_controller.rb index f28c303..14ebb16 100644 --- a/app/controllers/enterprise_controller.rb +++ b/app/controllers/enterprise_controller.rb @@ -34,6 +34,8 @@ class EnterpriseController < ApplicationController redirect_to :action => 'index' else flash[:notice] = _('Enterprise was not created') + @vitual_communities = VirtualCommunity.find(:all) + @validation_entities = Organization.find(:all) render :action => 'register_form' end end @@ -49,6 +51,7 @@ class EnterpriseController < ApplicationController redirect_to :action => 'index' else flash[:notice] = _('Could not update the enterprise') + @validation_entities = Organization.find(:all) - [@enterprise] render :action => 'edit' end end @@ -65,6 +68,7 @@ class EnterpriseController < ApplicationController redirect_to :action => 'index' end + protected def logon diff --git a/app/models/profile.rb b/app/models/profile.rb index d1621f1..358011b 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -23,6 +23,8 @@ class Profile < ActiveRecord::Base community ] + acts_as_taggable + has_many :domains, :as => :owner belongs_to :virtual_community has_many :affiliations diff --git a/app/views/enterprise/_form.rhtml b/app/views/enterprise/_form.rhtml index 4d0b659..2a90dda 100644 --- a/app/views/enterprise/_form.rhtml +++ b/app/views/enterprise/_form.rhtml @@ -27,3 +27,6 @@


<%= select 'validation_entity', 'id', @validation_entities.map{|v| [v.name, v.id] } %>

+ +


+<%= text_field 'enterprise', 'tag_list', 'size' => 20 %>

diff --git a/app/views/enterprise/show.rhtml b/app/views/enterprise/show.rhtml index fa20d01..a45bff6 100644 --- a/app/views/enterprise/show.rhtml +++ b/app/views/enterprise/show.rhtml @@ -9,6 +9,7 @@

<%= _('Legal Form: ') %> <%= @enterprise.organization_info.legal_form %>

<%= _('Economic activity: ') %> <%= @enterprise.organization_info.economic_activity %>

<%= _('Management infomation: ') %> <%= @enterprise.organization_info.management_information %>

+

<%= _('Tags:') %> <%= @enterprise.tag_list %>

<%= link_to _('Edit enterprise'), :action => 'edit', :id => @enterprise %> <%= link_to _('Delete enterprise'), :action => 'destroy', :id => @enterprise %> diff --git a/test/functional/enterprise_controller_test.rb b/test/functional/enterprise_controller_test.rb index a79e57f..b471a2f 100644 --- a/test/functional/enterprise_controller_test.rb +++ b/test/functional/enterprise_controller_test.rb @@ -5,7 +5,7 @@ require 'enterprise_controller' class EnterpriseController; def rescue_action(e) raise e end; end class EnterpriseControllerTest < Test::Unit::TestCase - fixtures :users + all_fixtures def setup @controller = EnterpriseController.new @@ -16,9 +16,9 @@ class EnterpriseControllerTest < Test::Unit::TestCase def test_logged_index login_as 'ze' get :index - assert_response :success + assert_response :redirect - assert_kind_of Array, assigns(:pending_enterprises) + assert_kind_of Array, assigns(:my_pending_enterprises) end def test_not_logged_index @@ -30,6 +30,7 @@ class EnterpriseControllerTest < Test::Unit::TestCase def test_my_enterprises login_as 'ze' + get :index assert_not_nil assigns(:my_enterprises) assert_kind_of Array, assigns(:my_enterprises) end @@ -42,7 +43,7 @@ class EnterpriseControllerTest < Test::Unit::TestCase def test_register login_as 'ze' - post :register, :enterprise => {:name => 'register_test'} + post :register, :enterprise => {:name => 'register_test', :identifier => 'register_test'} assert_not_nil assigns(:enterprise) assert_response :redirect @@ -53,7 +54,8 @@ class EnterpriseControllerTest < Test::Unit::TestCase def test_fail_register login_as 'ze' post :register, :enterprise => {:name => ''} - assert_nil assigns(:enterprise) + assert_response :success + assert !assigns(:enterprise).valid? end -- libgit2 0.21.2