Commit cb61792db973ce1bf3562eda7176a7f20ac5f69a

Authored by DanielaFeitosa
1 parent eb38a9dc

ActionItem6: enterprise's functional test


git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@289 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/models/enterprise.rb
1   -#A enterprise is a kind of profile. According to the system concept, only enterprises can offer priducts/services
  1 +#A enterprise is a kind of profile. According to the system concept, only enterprises can offer products/services
2 2 class Enterprise < Profile
3 3  
4 4 validates_numericality_of :foundation_year, :only_integer => true, :allow_nil => true
... ...
test/functional/enterprise_controller_test.rb
... ... @@ -11,17 +11,50 @@ class EnterpriseControllerTest &lt; Test::Unit::TestCase
11 11 @controller = EnterpriseController.new
12 12 @request = ActionController::TestRequest.new
13 13 @response = ActionController::TestResponse.new
14   - login_as('ze')
15 14 end
16 15  
17   - def test_index
  16 + def test_logged_index
  17 + login_as 'ze'
18 18 get :index
19 19 assert_response :success
20 20  
21   - assert_kind_of Array, assigns(:my_enterprises)
22   -
23 21 assert_kind_of Array, assigns(:pending_enterprises)
24 22 end
25 23  
  24 + def test_not_logged_index
  25 + get :index
  26 + assert_response :redirect
  27 +
  28 + assert_redirected_to :controller => 'account'
  29 + end
  30 +
  31 + def test_my_enterprises
  32 + login_as 'ze'
  33 + assert_not_nil assigns(:my_enterprises)
  34 + assert_kind_of Array, assigns(:my_enterprises)
  35 + end
  36 +
  37 + def test_register_form
  38 + login_as 'ze'
  39 + get :register_form
  40 + assert_response :success
  41 + end
  42 +
  43 + def test_register
  44 + login_as 'ze'
  45 + post :register, :enterprise => {:name => 'register_test'}
  46 + assert_not_nil assigns(:enterprise)
  47 +
  48 + assert_response :redirect
  49 +
  50 + assert_redirected_to :action => 'index'
  51 + end
  52 +
  53 + def test_fail_register
  54 + login_as 'ze'
  55 + post :register, :enterprise => {:name => ''}
  56 + assert_nil assigns(:enterprise)
  57 +
  58 + end
26 59  
27 60 end
... ...