Commit 26bb1072f03658489d6bfe0a9450d24021b33296
1 parent
b4fadbd8
Exists in
master
and in
29 other branches
ActionItem5: enterprise controller refactored into the profile_members and membe…
…rship_editor controller git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@550 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
1 changed file
with
0 additions
and
177 deletions
Show diff stats
test/functional/enterprise_controller_test.rb
... | ... | @@ -1,177 +0,0 @@ |
1 | -require File.dirname(__FILE__) + '/../test_helper' | |
2 | -require 'enterprise_controller' | |
3 | - | |
4 | -# Re-raise errors caught by the controller. | |
5 | -class EnterpriseController; def rescue_action(e) raise e end; end | |
6 | - | |
7 | -class EnterpriseControllerTest < Test::Unit::TestCase | |
8 | - all_fixtures | |
9 | - | |
10 | - def setup | |
11 | - @controller = EnterpriseController.new | |
12 | - @request = ActionController::TestRequest.new | |
13 | - @response = ActionController::TestResponse.new | |
14 | - end | |
15 | - | |
16 | - # FIXME: this should be generic | |
17 | - def get(action, params = {}) | |
18 | - super(action, {:profile => 'ze'}.merge(params)) | |
19 | - end | |
20 | - | |
21 | - # FIXME: this should be generic | |
22 | - def post(action, params = {}) | |
23 | - super(action, {:profile => 'ze'}.merge(params)) | |
24 | - end | |
25 | - | |
26 | - def test_logged_with_one_enterprise_index | |
27 | - login_as 'ze' | |
28 | - get :index, :profile => 'ze' | |
29 | - assert_response :redirect | |
30 | - assert_redirected_to :action => 'show' | |
31 | - | |
32 | - assert_kind_of Array, assigns(:my_pending_enterprises) | |
33 | - end | |
34 | - | |
35 | - def test_logged_with_two_enterprises_index | |
36 | - login_as 'johndoe' | |
37 | - get :index | |
38 | - assert_response :redirect | |
39 | - assert_redirected_to :action => 'list' | |
40 | - | |
41 | - assert_kind_of Array, assigns(:my_pending_enterprises) | |
42 | - end | |
43 | - | |
44 | - def test_not_logged_index | |
45 | - get :index | |
46 | - assert_response :redirect | |
47 | - assert_redirected_to :controller => 'account' | |
48 | - end | |
49 | - | |
50 | - def test_my_enterprises | |
51 | - login_as 'ze' | |
52 | - get :index | |
53 | - assert_not_nil assigns(:my_enterprises) | |
54 | - assert_kind_of Array, assigns(:my_enterprises) | |
55 | - end | |
56 | - | |
57 | - def test_enterprise_listing | |
58 | - login_as 'ze' | |
59 | - get :list | |
60 | - assert_not_nil assigns(:enterprises) | |
61 | - assert Array, assigns(:enterprises) | |
62 | - end | |
63 | - | |
64 | - def test_enterprise_showing | |
65 | - login_as 'ze' | |
66 | - get :show, :id => 5 | |
67 | - assert_not_nil assigns(:enterprise) | |
68 | - assert_kind_of Enterprise, assigns(:enterprise) | |
69 | - end | |
70 | - | |
71 | - def test_register_form | |
72 | - login_as 'ze' | |
73 | - get :register_form | |
74 | - assert_response :success | |
75 | - end | |
76 | - | |
77 | - def test_register | |
78 | - login_as 'ze' | |
79 | - post :register, :enterprise => {:name => 'register_test', :identifier => 'register_test'} | |
80 | - assert_not_nil assigns(:enterprise) | |
81 | - assert_response :redirect | |
82 | - assert_redirected_to :action => 'index' | |
83 | - end | |
84 | - | |
85 | - def test_fail_register | |
86 | - login_as 'ze' | |
87 | - post :register, :enterprise => {:name => ''} | |
88 | - assert_response :success | |
89 | - assert !assigns(:enterprise).valid? | |
90 | - end | |
91 | - | |
92 | - def test_enterprise_editing | |
93 | - login_as 'ze' | |
94 | - e = create_enterprise | |
95 | - get :edit, :id => e | |
96 | - assert_not_nil assigns(:enterprise) | |
97 | - assert_kind_of Enterprise, assigns(:enterprise) | |
98 | - end | |
99 | - | |
100 | - def test_enterprise_updating | |
101 | - login_as 'ze' | |
102 | - e = create_enterprise | |
103 | - post :update, :id => e, :enterprise => {:name => 'colivre'} | |
104 | - assert_not_nil assigns(:enterprise) | |
105 | - assert_kind_of Enterprise, assigns(:enterprise) | |
106 | - assert_response :redirect | |
107 | - assert_redirected_to :action => 'index' | |
108 | - end | |
109 | - | |
110 | - def test_enterprise_updating_wrong | |
111 | - login_as 'ze' | |
112 | - e = create_enterprise | |
113 | - post :update, :id => e, :enterprise => {:name => ''} # name can't be blank | |
114 | - assert_not_nil assigns(:enterprise) | |
115 | - assert_kind_of Enterprise, assigns(:enterprise) | |
116 | - assert_response :success | |
117 | - assert_template 'edit' | |
118 | - end | |
119 | - | |
120 | - def test_affiliate | |
121 | - login_as 'ze' | |
122 | - e = create_enterprise(:owner => 'johndoe', :user => 'ze') | |
123 | - post :affiliate, :id => e | |
124 | - assert assigns(:enterprise) | |
125 | - assert assigns(:enterprise).people.include?(assigns(:person)) | |
126 | - assert assigns(:person).enterprises.include?(assigns(:enterprise)) | |
127 | - end | |
128 | - | |
129 | - def test_destroy | |
130 | - login_as 'ze' | |
131 | - e = create_enterprise | |
132 | - c = Enterprise.count | |
133 | - assert_nothing_raised { Enterprise.find(e) } | |
134 | - post :destroy, :id => e | |
135 | - assert assigns(:enterprise) | |
136 | - assert_raise ActiveRecord::RecordNotFound do | |
137 | - Enterprise.find(e) | |
138 | - end | |
139 | - assert_equal c - 1, Enterprise.count | |
140 | - end | |
141 | - | |
142 | - def test_search | |
143 | - login_as 'ze' | |
144 | - e = create_enterprise(:tag_list => 'bla') | |
145 | - get :search, :query => 'bla' | |
146 | - assert assigns(:tagged_enterprises) | |
147 | - assert_kind_of Array, assigns(:tagged_enterprises) | |
148 | - end | |
149 | - | |
150 | - def test_activate | |
151 | - login_as 'ze' | |
152 | - e = create_enterprise | |
153 | - post :activate, :id => e | |
154 | - assert assigns(:enterprise) | |
155 | - assert_kind_of Enterprise, assigns(:enterprise) | |
156 | - assert assigns(:enterprise).active | |
157 | - end | |
158 | - | |
159 | - def test_approve | |
160 | - login_as 'ze' | |
161 | - e = create_enterprise | |
162 | - post :approve, :id => e | |
163 | - assert assigns(:enterprise) | |
164 | - end | |
165 | - | |
166 | - protected | |
167 | - | |
168 | - def create_enterprise(options = {}) | |
169 | - owner = options.delete(:owner) | |
170 | - user = options.delete(:user) | |
171 | - login_as owner if owner | |
172 | - post :register, :enterprise => {:identifier => 'enterprise_a', :name => 'Enterprise A'}.merge(options) | |
173 | - id = assigns(:enterprise).id | |
174 | - login_as user if user | |
175 | - id | |
176 | - end | |
177 | -end |