@@ -24,6 +24,7 | |||
|
24 | 24 | </td> |
|
25 | 25 | <td align="center" style="width:10%;"> |
|
26 | 26 | <%= button_to(l(:button_delete), { :action => 'destroy', :id => role }, :confirm => l(:text_are_you_sure), :class => "button-small", :disabled => role.builtin? ) %> |
|
27 | </td> | |
|
27 | 28 | </tr> |
|
28 | 29 | <% end %> |
|
29 | 30 | </tbody> |
@@ -1,49 +1,4 | |||
|
1 | 1 | --- |
|
2 | roles_004: | |
|
3 | name: Non member | |
|
4 | id: 4 | |
|
5 | builtin: 1 | |
|
6 | permissions: | | |
|
7 | --- | |
|
8 | - :add_issues | |
|
9 | - :edit_issues | |
|
10 | - :manage_issue_relations | |
|
11 | - :add_issue_notes | |
|
12 | - :move_issues | |
|
13 | - :save_queries | |
|
14 | - :view_gantt | |
|
15 | - :view_calendar | |
|
16 | - :log_time | |
|
17 | - :view_time_entries | |
|
18 | - :comment_news | |
|
19 | - :view_documents | |
|
20 | - :manage_documents | |
|
21 | - :view_wiki_pages | |
|
22 | - :edit_wiki_pages | |
|
23 | - :add_messages | |
|
24 | - :view_files | |
|
25 | - :manage_files | |
|
26 | - :browse_repository | |
|
27 | - :view_changesets | |
|
28 | ||
|
29 | position: 5 | |
|
30 | roles_005: | |
|
31 | name: Anonymous | |
|
32 | id: 5 | |
|
33 | builtin: 2 | |
|
34 | permissions: | | |
|
35 | --- | |
|
36 | - :add_issue_notes | |
|
37 | - :view_gantt | |
|
38 | - :view_calendar | |
|
39 | - :view_time_entries | |
|
40 | - :view_documents | |
|
41 | - :view_wiki_pages | |
|
42 | - :view_files | |
|
43 | - :browse_repository | |
|
44 | - :view_changesets | |
|
45 | ||
|
46 | position: 6 | |
|
47 | 2 | roles_001: |
|
48 | 3 | name: Manager |
|
49 | 4 | id: 1 |
@@ -85,7 +40,7 roles_001: | |||
|
85 | 40 | - :browse_repository |
|
86 | 41 | - :view_changesets |
|
87 | 42 | |
|
88 |
position: |
|
|
43 | position: 1 | |
|
89 | 44 | roles_002: |
|
90 | 45 | name: Developer |
|
91 | 46 | id: 2 |
@@ -123,7 +78,7 roles_002: | |||
|
123 | 78 | - :browse_repository |
|
124 | 79 | - :view_changesets |
|
125 | 80 | |
|
126 |
position: |
|
|
81 | position: 2 | |
|
127 | 82 | roles_003: |
|
128 | 83 | name: Reporter |
|
129 | 84 | id: 3 |
@@ -139,7 +94,6 roles_003: | |||
|
139 | 94 | - :manage_issue_relations |
|
140 | 95 | - :add_issue_notes |
|
141 | 96 | - :move_issues |
|
142 | - :delete_issues | |
|
143 | 97 | - :manage_public_queries |
|
144 | 98 | - :save_queries |
|
145 | 99 | - :view_gantt |
@@ -160,4 +114,50 roles_003: | |||
|
160 | 114 | - :browse_repository |
|
161 | 115 | - :view_changesets |
|
162 | 116 | |
|
117 | position: 3 | |
|
118 | roles_004: | |
|
119 | name: Non member | |
|
120 | id: 4 | |
|
121 | builtin: 1 | |
|
122 | permissions: | | |
|
123 | --- | |
|
124 | - :add_issues | |
|
125 | - :edit_issues | |
|
126 | - :manage_issue_relations | |
|
127 | - :add_issue_notes | |
|
128 | - :move_issues | |
|
129 | - :save_queries | |
|
130 | - :view_gantt | |
|
131 | - :view_calendar | |
|
132 | - :log_time | |
|
133 | - :view_time_entries | |
|
134 | - :comment_news | |
|
135 | - :view_documents | |
|
136 | - :manage_documents | |
|
137 | - :view_wiki_pages | |
|
138 | - :edit_wiki_pages | |
|
139 | - :add_messages | |
|
140 | - :view_files | |
|
141 | - :manage_files | |
|
142 | - :browse_repository | |
|
143 | - :view_changesets | |
|
144 | ||
|
163 | 145 | position: 4 |
|
146 | roles_005: | |
|
147 | name: Anonymous | |
|
148 | id: 5 | |
|
149 | builtin: 2 | |
|
150 | permissions: | | |
|
151 | --- | |
|
152 | - :add_issue_notes | |
|
153 | - :view_gantt | |
|
154 | - :view_calendar | |
|
155 | - :view_time_entries | |
|
156 | - :view_documents | |
|
157 | - :view_wiki_pages | |
|
158 | - :view_files | |
|
159 | - :browse_repository | |
|
160 | - :view_changesets | |
|
161 | ||
|
162 | position: 5 | |
|
163 | No newline at end of file |
@@ -245,12 +245,6 workflows_225: | |||
|
245 | 245 | old_status_id: 3 |
|
246 | 246 | id: 225 |
|
247 | 247 | tracker_id: 3 |
|
248 | workflows_037: | |
|
249 | new_status_id: 3 | |
|
250 | role_id: 2 | |
|
251 | old_status_id: 2 | |
|
252 | id: 37 | |
|
253 | tracker_id: 1 | |
|
254 | 248 | workflows_063: |
|
255 | 249 | new_status_id: 4 |
|
256 | 250 | role_id: 3 |
@@ -32,6 +32,18 class RolesControllerTest < Test::Unit::TestCase | |||
|
32 | 32 | @request.session[:user_id] = 1 # admin |
|
33 | 33 | end |
|
34 | 34 | |
|
35 | def test_get_index | |
|
36 | get :index | |
|
37 | assert_response :success | |
|
38 | assert_template 'list' | |
|
39 | ||
|
40 | assert_not_nil assigns(:roles) | |
|
41 | assert_equal Role.find(:all, :order => 'builtin, position'), assigns(:roles) | |
|
42 | ||
|
43 | assert_tag :tag => 'a', :attributes => { :href => '/roles/edit/1' }, | |
|
44 | :content => 'Manager' | |
|
45 | end | |
|
46 | ||
|
35 | 47 | def test_get_new |
|
36 | 48 | get :new |
|
37 | 49 | assert_response :success |
@@ -89,4 +101,120 class RolesControllerTest < Test::Unit::TestCase | |||
|
89 | 101 | role = Role.find(1) |
|
90 | 102 | assert_equal [:edit_project], role.permissions |
|
91 | 103 | end |
|
104 | ||
|
105 | def test_destroy | |
|
106 | r = Role.new(:name => 'ToBeDestroyed', :permissions => [:view_wiki_pages]) | |
|
107 | assert r.save | |
|
108 | ||
|
109 | post :destroy, :id => r | |
|
110 | assert_redirected_to 'roles/list' | |
|
111 | assert_nil Role.find_by_id(r.id) | |
|
112 | end | |
|
113 | ||
|
114 | def test_destroy_role_in_use | |
|
115 | post :destroy, :id => 1 | |
|
116 | assert_redirected_to 'roles' | |
|
117 | assert flash[:error] == 'This role is in use and can not be deleted.' | |
|
118 | assert_not_nil Role.find_by_id(1) | |
|
119 | end | |
|
120 | ||
|
121 | def test_get_workflow | |
|
122 | get :workflow | |
|
123 | assert_response :success | |
|
124 | assert_template 'workflow' | |
|
125 | assert_not_nil assigns(:roles) | |
|
126 | assert_not_nil assigns(:trackers) | |
|
127 | end | |
|
128 | ||
|
129 | def test_get_workflow_with_role_and_tracker | |
|
130 | get :workflow, :role_id => 2, :tracker_id => 1 | |
|
131 | assert_response :success | |
|
132 | assert_template 'workflow' | |
|
133 | # allowed transitions | |
|
134 | assert_tag :tag => 'input', :attributes => { :type => 'checkbox', | |
|
135 | :name => 'issue_status[2][]', | |
|
136 | :value => '1', | |
|
137 | :checked => 'checked' } | |
|
138 | # not allowed | |
|
139 | assert_tag :tag => 'input', :attributes => { :type => 'checkbox', | |
|
140 | :name => 'issue_status[2][]', | |
|
141 | :value => '3', | |
|
142 | :checked => nil } | |
|
143 | end | |
|
144 | ||
|
145 | def test_post_workflow | |
|
146 | post :workflow, :role_id => 2, :tracker_id => 1, :issue_status => {'4' => ['5'], '3' => ['1', '2']} | |
|
147 | assert_redirected_to 'roles/workflow' | |
|
148 | ||
|
149 | assert_equal 3, Workflow.count(:conditions => {:tracker_id => 1, :role_id => 2}) | |
|
150 | assert_not_nil Workflow.find(:first, :conditions => {:role_id => 2, :tracker_id => 1, :old_status_id => 3, :new_status_id => 2}) | |
|
151 | assert_nil Workflow.find(:first, :conditions => {:role_id => 2, :tracker_id => 1, :old_status_id => 5, :new_status_id => 4}) | |
|
152 | end | |
|
153 | ||
|
154 | def test_clear_workflow | |
|
155 | assert Workflow.count(:conditions => {:tracker_id => 1, :role_id => 2}) > 0 | |
|
156 | ||
|
157 | post :workflow, :role_id => 2, :tracker_id => 1 | |
|
158 | assert_equal 0, Workflow.count(:conditions => {:tracker_id => 1, :role_id => 2}) | |
|
159 | end | |
|
160 | ||
|
161 | def test_get_report | |
|
162 | get :report | |
|
163 | assert_response :success | |
|
164 | assert_template 'report' | |
|
165 | ||
|
166 | assert_not_nil assigns(:roles) | |
|
167 | assert_equal Role.find(:all, :order => 'builtin, position'), assigns(:roles) | |
|
168 | ||
|
169 | assert_tag :tag => 'input', :attributes => { :type => 'checkbox', | |
|
170 | :name => 'permissions[3][]', | |
|
171 | :value => 'add_issues', | |
|
172 | :checked => 'checked' } | |
|
173 | ||
|
174 | assert_tag :tag => 'input', :attributes => { :type => 'checkbox', | |
|
175 | :name => 'permissions[3][]', | |
|
176 | :value => 'delete_issues', | |
|
177 | :checked => nil } | |
|
178 | end | |
|
179 | ||
|
180 | def test_post_report | |
|
181 | post :report, :permissions => { '0' => '', '1' => ['edit_issues'], '3' => ['add_issues', 'delete_issues']} | |
|
182 | assert_redirected_to 'roles/list' | |
|
183 | ||
|
184 | assert_equal [:edit_issues], Role.find(1).permissions | |
|
185 | assert_equal [:add_issues, :delete_issues], Role.find(3).permissions | |
|
186 | assert Role.find(2).permissions.empty? | |
|
187 | end | |
|
188 | ||
|
189 | def test_clear_all_permissions | |
|
190 | post :report, :permissions => { '0' => '' } | |
|
191 | assert_redirected_to 'roles/list' | |
|
192 | assert Role.find(1).permissions.empty? | |
|
193 | end | |
|
194 | ||
|
195 | def test_move_highest | |
|
196 | post :move, :id => 3, :position => 'highest' | |
|
197 | assert_redirected_to 'roles/list' | |
|
198 | assert_equal 1, Role.find(3).position | |
|
199 | end | |
|
200 | ||
|
201 | def test_move_higher | |
|
202 | position = Role.find(3).position | |
|
203 | post :move, :id => 3, :position => 'higher' | |
|
204 | assert_redirected_to 'roles/list' | |
|
205 | assert_equal position - 1, Role.find(3).position | |
|
206 | end | |
|
207 | ||
|
208 | def test_move_lower | |
|
209 | position = Role.find(2).position | |
|
210 | post :move, :id => 2, :position => 'lower' | |
|
211 | assert_redirected_to 'roles/list' | |
|
212 | assert_equal position + 1, Role.find(2).position | |
|
213 | end | |
|
214 | ||
|
215 | def test_move_lowest | |
|
216 | post :move, :id => 2, :position => 'lowest' | |
|
217 | assert_redirected_to 'roles/list' | |
|
218 | assert_equal Role.count, Role.find(2).position | |
|
219 | end | |
|
92 | 220 | end |
@@ -22,12 +22,12 class TrackerTest < Test::Unit::TestCase | |||
|
22 | 22 | |
|
23 | 23 | def test_copy_workflows |
|
24 | 24 | source = Tracker.find(1) |
|
25 |
assert_equal 9 |
|
|
25 | assert_equal 89, source.workflows.size | |
|
26 | 26 | |
|
27 | 27 | target = Tracker.new(:name => 'Target') |
|
28 | 28 | assert target.save |
|
29 | 29 | assert target.workflows.copy(source) |
|
30 | 30 | target.reload |
|
31 |
assert_equal 9 |
|
|
31 | assert_equal 89, target.workflows.size | |
|
32 | 32 | end |
|
33 | 33 | end |
General Comments 0
You need to be logged in to leave comments.
Login now