diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index bdf162b..a8657bb 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -1,4 +1,4 @@ -#A enterprise is a kind of profile. According to the system concept, only enterprises can offer priducts/services +#A enterprise is a kind of profile. According to the system concept, only enterprises can offer products/services class Enterprise < Profile validates_numericality_of :foundation_year, :only_integer => true, :allow_nil => true diff --git a/test/functional/enterprise_controller_test.rb b/test/functional/enterprise_controller_test.rb index d7a3116..a79e57f 100644 --- a/test/functional/enterprise_controller_test.rb +++ b/test/functional/enterprise_controller_test.rb @@ -11,17 +11,50 @@ class EnterpriseControllerTest < Test::Unit::TestCase @controller = EnterpriseController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new - login_as('ze') end - def test_index + def test_logged_index + login_as 'ze' get :index assert_response :success - assert_kind_of Array, assigns(:my_enterprises) - assert_kind_of Array, assigns(:pending_enterprises) end + def test_not_logged_index + get :index + assert_response :redirect + + assert_redirected_to :controller => 'account' + end + + def test_my_enterprises + login_as 'ze' + assert_not_nil assigns(:my_enterprises) + assert_kind_of Array, assigns(:my_enterprises) + end + + def test_register_form + login_as 'ze' + get :register_form + assert_response :success + end + + def test_register + login_as 'ze' + post :register, :enterprise => {:name => 'register_test'} + assert_not_nil assigns(:enterprise) + + assert_response :redirect + + assert_redirected_to :action => 'index' + end + + def test_fail_register + login_as 'ze' + post :register, :enterprise => {:name => ''} + assert_nil assigns(:enterprise) + + end end -- libgit2 0.21.2