@@ -0,0 +1,91 | |||||
|
1 | # redMine - project management software | |||
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |||
|
3 | # | |||
|
4 | # This program is free software; you can redistribute it and/or | |||
|
5 | # modify it under the terms of the GNU General Public License | |||
|
6 | # as published by the Free Software Foundation; either version 2 | |||
|
7 | # of the License, or (at your option) any later version. | |||
|
8 | # | |||
|
9 | # This program is distributed in the hope that it will be useful, | |||
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
12 | # GNU General Public License for more details. | |||
|
13 | # | |||
|
14 | # You should have received a copy of the GNU General Public License | |||
|
15 | # along with this program; if not, write to the Free Software | |||
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
|
17 | ||||
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |||
|
19 | require 'repositories_controller' | |||
|
20 | ||||
|
21 | # Re-raise errors caught by the controller. | |||
|
22 | class RepositoriesController; def rescue_action(e) raise e end; end | |||
|
23 | ||||
|
24 | class RepositoriesControllerTest < Test::Unit::TestCase | |||
|
25 | fixtures :projects, :users, :roles, :members, :repositories, :issues, :issue_statuses, :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers | |||
|
26 | ||||
|
27 | # No '..' in the repository path for svn | |||
|
28 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/subversion_repository' | |||
|
29 | ||||
|
30 | def setup | |||
|
31 | @controller = RepositoriesController.new | |||
|
32 | @request = ActionController::TestRequest.new | |||
|
33 | @response = ActionController::TestResponse.new | |||
|
34 | User.current = nil | |||
|
35 | end | |||
|
36 | ||||
|
37 | if File.directory?(REPOSITORY_PATH) | |||
|
38 | def test_show | |||
|
39 | get :show, :id => 1 | |||
|
40 | assert_response :success | |||
|
41 | assert_template 'show' | |||
|
42 | assert_not_nil assigns(:entries) | |||
|
43 | assert_not_nil assigns(:changesets) | |||
|
44 | end | |||
|
45 | ||||
|
46 | def test_browse_root | |||
|
47 | get :browse, :id => 1 | |||
|
48 | assert_response :success | |||
|
49 | assert_template 'browse' | |||
|
50 | assert_not_nil assigns(:entries) | |||
|
51 | entry = assigns(:entries).detect {|e| e.name == 'subversion_test'} | |||
|
52 | assert_equal 'dir', entry.kind | |||
|
53 | end | |||
|
54 | ||||
|
55 | def test_browse_directory | |||
|
56 | get :browse, :id => 1, :path => ['subversion_test'] | |||
|
57 | assert_response :success | |||
|
58 | assert_template 'browse' | |||
|
59 | assert_not_nil assigns(:entries) | |||
|
60 | entry = assigns(:entries).detect {|e| e.name == 'helloworld.c'} | |||
|
61 | assert_equal 'file', entry.kind | |||
|
62 | assert_equal 'subversion_test/helloworld.c', entry.path | |||
|
63 | end | |||
|
64 | ||||
|
65 | def test_entry | |||
|
66 | get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c'] | |||
|
67 | assert_response :success | |||
|
68 | assert_template 'entry' | |||
|
69 | end | |||
|
70 | ||||
|
71 | def test_entry_download | |||
|
72 | get :entry, :id => 1, :path => ['subversion_test', 'helloworld.c'], :format => 'raw' | |||
|
73 | assert_response :success | |||
|
74 | end | |||
|
75 | ||||
|
76 | def test_diff | |||
|
77 | get :diff, :id => 1, :rev => 3 | |||
|
78 | assert_response :success | |||
|
79 | assert_template 'diff' | |||
|
80 | end | |||
|
81 | ||||
|
82 | def test_annotate | |||
|
83 | get :annotate, :id => 1, :path => ['subversion_test', 'helloworld.c'] | |||
|
84 | assert_response :success | |||
|
85 | assert_template 'annotate' | |||
|
86 | end | |||
|
87 | else | |||
|
88 | puts "Subversion test repository NOT FOUND. Skipping functional tests !!!" | |||
|
89 | def test_fake; assert true end | |||
|
90 | end | |||
|
91 | end |
@@ -1,15 +1,17 | |||||
1 | --- |
|
1 | --- | |
2 | repositories_001: |
|
2 | repositories_001: | |
3 | project_id: 1 |
|
3 | project_id: 1 | |
4 | url: svn://localhost/test |
|
4 | url: file:///<%= RAILS_ROOT.gsub(%r{config\/\.\.}, '') %>/tmp/test/subversion_repository | |
5 | id: 10 |
|
5 | id: 10 | |
6 | root_url: svn://localhost |
|
6 | root_url: file:///<%= RAILS_ROOT.gsub(%r{config\/\.\.}, '') %>/tmp/test/subversion_repository | |
7 | password: "" |
|
7 | password: "" | |
8 | login: "" |
|
8 | login: "" | |
|
9 | type: Subversion | |||
9 | repositories_002: |
|
10 | repositories_002: | |
10 | project_id: 2 |
|
11 | project_id: 2 | |
11 | url: svn://localhost/test |
|
12 | url: svn://localhost/test | |
12 | id: 11 |
|
13 | id: 11 | |
13 | root_url: svn://localhost |
|
14 | root_url: svn://localhost | |
14 | password: "" |
|
15 | password: "" | |
15 | login: "" |
|
16 | login: "" | |
|
17 | type: Subversion |
@@ -1,156 +1,211 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.dirname(__FILE__) + '/../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
19 | require 'projects_controller' |
|
19 | require 'projects_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class ProjectsController; def rescue_action(e) raise e end; end |
|
22 | class ProjectsController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 | class ProjectsControllerTest < Test::Unit::TestCase |
|
24 | class ProjectsControllerTest < Test::Unit::TestCase | |
25 | fixtures :projects, :users, :roles, :members, :issues, :journals, :journal_details, :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations |
|
25 | fixtures :projects, :versions, :users, :roles, :members, :issues, :journals, :journal_details, :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations | |
26 |
|
26 | |||
27 | def setup |
|
27 | def setup | |
28 | @controller = ProjectsController.new |
|
28 | @controller = ProjectsController.new | |
29 | @request = ActionController::TestRequest.new |
|
29 | @request = ActionController::TestRequest.new | |
30 | @response = ActionController::TestResponse.new |
|
30 | @response = ActionController::TestResponse.new | |
31 | end |
|
31 | end | |
32 |
|
32 | |||
33 | def test_index |
|
33 | def test_index | |
34 | get :index |
|
34 | get :index | |
35 | assert_response :success |
|
35 | assert_response :success | |
36 | assert_template 'list' |
|
36 | assert_template 'list' | |
37 | end |
|
37 | end | |
38 |
|
38 | |||
39 | def test_list |
|
39 | def test_list | |
40 | get :list |
|
40 | get :list | |
41 | assert_response :success |
|
41 | assert_response :success | |
42 | assert_template 'list' |
|
42 | assert_template 'list' | |
43 | assert_not_nil assigns(:project_tree) |
|
43 | assert_not_nil assigns(:project_tree) | |
|
44 | # Root project as hash key | |||
|
45 | assert assigns(:project_tree).has_key?(Project.find(1)) | |||
|
46 | # Subproject in corresponding value | |||
|
47 | assert assigns(:project_tree)[Project.find(1)].include?(Project.find(3)) | |||
44 | end |
|
48 | end | |
45 |
|
49 | |||
46 | def test_show |
|
50 | def test_show | |
47 | get :show, :id => 1 |
|
51 | get :show, :id => 1 | |
48 | assert_response :success |
|
52 | assert_response :success | |
49 | assert_template 'show' |
|
53 | assert_template 'show' | |
50 | assert_not_nil assigns(:project) |
|
54 | assert_not_nil assigns(:project) | |
51 | end |
|
55 | end | |
52 |
|
56 | |||
53 | def test_list_documents |
|
57 | def test_list_documents | |
54 | get :list_documents, :id => 1 |
|
58 | get :list_documents, :id => 1 | |
55 | assert_response :success |
|
59 | assert_response :success | |
56 | assert_template 'list_documents' |
|
60 | assert_template 'list_documents' | |
57 | assert_not_nil assigns(:grouped) |
|
61 | assert_not_nil assigns(:grouped) | |
58 | end |
|
62 | end | |
59 |
|
63 | |||
60 | def test_bulk_edit_issues |
|
64 | def test_bulk_edit_issues | |
61 | @request.session[:user_id] = 2 |
|
65 | @request.session[:user_id] = 2 | |
62 | # update issues priority |
|
66 | # update issues priority | |
63 | post :bulk_edit_issues, :id => 1, :issue_ids => [1, 2], :priority_id => 7, :notes => 'Bulk editing', :assigned_to_id => '' |
|
67 | post :bulk_edit_issues, :id => 1, :issue_ids => [1, 2], :priority_id => 7, :notes => 'Bulk editing', :assigned_to_id => '' | |
64 | assert_response 302 |
|
68 | assert_response 302 | |
65 | # check that the issues were updated |
|
69 | # check that the issues were updated | |
66 | assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id} |
|
70 | assert_equal [7, 7], Issue.find_all_by_id([1, 2]).collect {|i| i.priority.id} | |
67 | assert_equal 'Bulk editing', Issue.find(1).journals.find(:first, :order => 'created_on DESC').notes |
|
71 | assert_equal 'Bulk editing', Issue.find(1).journals.find(:first, :order => 'created_on DESC').notes | |
68 | end |
|
72 | end | |
69 |
|
73 | |||
70 | def test_list_files |
|
74 | def test_list_files | |
71 | get :list_files, :id => 1 |
|
75 | get :list_files, :id => 1 | |
72 | assert_response :success |
|
76 | assert_response :success | |
73 | assert_template 'list_files' |
|
77 | assert_template 'list_files' | |
74 | assert_not_nil assigns(:versions) |
|
78 | assert_not_nil assigns(:versions) | |
75 | end |
|
79 | end | |
76 |
|
80 | |||
77 | def test_changelog |
|
81 | def test_changelog | |
78 | get :changelog, :id => 1 |
|
82 | get :changelog, :id => 1 | |
79 | assert_response :success |
|
83 | assert_response :success | |
80 | assert_template 'changelog' |
|
84 | assert_template 'changelog' | |
81 | assert_not_nil assigns(:versions) |
|
85 | assert_not_nil assigns(:versions) | |
82 | end |
|
86 | end | |
83 |
|
87 | |||
84 | def test_roadmap |
|
88 | def test_roadmap | |
85 | get :roadmap, :id => 1 |
|
89 | get :roadmap, :id => 1 | |
86 | assert_response :success |
|
90 | assert_response :success | |
87 | assert_template 'roadmap' |
|
91 | assert_template 'roadmap' | |
88 | assert_not_nil assigns(:versions) |
|
92 | assert_not_nil assigns(:versions) | |
|
93 | # Version with no date set appears | |||
|
94 | assert assigns(:versions).include?(Version.find(3)) | |||
|
95 | # Completed version doesn't appear | |||
|
96 | assert !assigns(:versions).include?(Version.find(1)) | |||
|
97 | end | |||
|
98 | ||||
|
99 | def test_roadmap_with_completed_versions | |||
|
100 | get :roadmap, :id => 1, :completed => 1 | |||
|
101 | assert_response :success | |||
|
102 | assert_template 'roadmap' | |||
|
103 | assert_not_nil assigns(:versions) | |||
|
104 | # Version with no date set appears | |||
|
105 | assert assigns(:versions).include?(Version.find(3)) | |||
|
106 | # Completed version appears | |||
|
107 | assert assigns(:versions).include?(Version.find(1)) | |||
89 | end |
|
108 | end | |
90 |
|
109 | |||
91 | def test_activity |
|
110 | def test_activity | |
92 | get :activity, :id => 1, :year => 2.days.ago.to_date.year, :month => 2.days.ago.to_date.month |
|
111 | get :activity, :id => 1, :year => 2.days.ago.to_date.year, :month => 2.days.ago.to_date.month | |
93 | assert_response :success |
|
112 | assert_response :success | |
94 | assert_template 'activity' |
|
113 | assert_template 'activity' | |
95 | assert_not_nil assigns(:events_by_day) |
|
114 | assert_not_nil assigns(:events_by_day) | |
96 |
|
115 | |||
97 | assert_tag :tag => "h3", |
|
116 | assert_tag :tag => "h3", | |
98 | :content => /#{2.days.ago.to_date.day}/, |
|
117 | :content => /#{2.days.ago.to_date.day}/, | |
99 | :sibling => { :tag => "ul", |
|
118 | :sibling => { :tag => "ul", | |
100 | :child => { :tag => "li", |
|
119 | :child => { :tag => "li", | |
101 | :child => { :tag => "p", |
|
120 | :child => { :tag => "p", | |
102 | :content => /(#{IssueStatus.find(2).name})/, |
|
121 | :content => /(#{IssueStatus.find(2).name})/, | |
103 | } |
|
122 | } | |
104 | } |
|
123 | } | |
105 | } |
|
124 | } | |
106 |
|
125 | |||
107 | get :activity, :id => 1, :year => 3.days.ago.to_date.year, :month => 3.days.ago.to_date.month |
|
126 | get :activity, :id => 1, :year => 3.days.ago.to_date.year, :month => 3.days.ago.to_date.month | |
108 | assert_response :success |
|
127 | assert_response :success | |
109 | assert_template 'activity' |
|
128 | assert_template 'activity' | |
110 | assert_not_nil assigns(:events_by_day) |
|
129 | assert_not_nil assigns(:events_by_day) | |
111 |
|
130 | |||
112 | assert_tag :tag => "h3", |
|
131 | assert_tag :tag => "h3", | |
113 | :content => /#{3.day.ago.to_date.day}/, |
|
132 | :content => /#{3.day.ago.to_date.day}/, | |
114 | :sibling => { :tag => "ul", |
|
133 | :sibling => { :tag => "ul", | |
115 | :child => { :tag => "li", |
|
134 | :child => { :tag => "li", | |
116 | :child => { :tag => "p", |
|
135 | :child => { :tag => "p", | |
117 | :content => /#{Issue.find(1).subject}/, |
|
136 | :content => /#{Issue.find(1).subject}/, | |
118 | } |
|
137 | } | |
119 | } |
|
138 | } | |
120 | } |
|
139 | } | |
121 | end |
|
140 | end | |
122 |
|
141 | |||
|
142 | def test_calendar | |||
|
143 | get :calendar, :id => 1 | |||
|
144 | assert_response :success | |||
|
145 | assert_template 'calendar' | |||
|
146 | assert_not_nil assigns(:calendar) | |||
|
147 | end | |||
|
148 | ||||
|
149 | def test_calendar_with_subprojects | |||
|
150 | get :calendar, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2] | |||
|
151 | assert_response :success | |||
|
152 | assert_template 'calendar' | |||
|
153 | assert_not_nil assigns(:calendar) | |||
|
154 | end | |||
|
155 | ||||
|
156 | def test_gantt | |||
|
157 | get :gantt, :id => 1 | |||
|
158 | assert_response :success | |||
|
159 | assert_template 'gantt.rhtml' | |||
|
160 | assert_not_nil assigns(:events) | |||
|
161 | end | |||
|
162 | ||||
|
163 | def test_gantt_with_subprojects | |||
|
164 | get :gantt, :id => 1, :with_subprojects => 1, :tracker_ids => [1, 2] | |||
|
165 | assert_response :success | |||
|
166 | assert_template 'gantt.rhtml' | |||
|
167 | assert_not_nil assigns(:events) | |||
|
168 | end | |||
|
169 | ||||
|
170 | def test_gantt_export_to_pdf | |||
|
171 | get :gantt, :id => 1, :format => 'pdf' | |||
|
172 | assert_response :success | |||
|
173 | assert_template 'gantt.rfpdf' | |||
|
174 | assert_equal 'application/pdf', @response.content_type | |||
|
175 | assert_not_nil assigns(:events) | |||
|
176 | end | |||
|
177 | ||||
123 | def test_archive |
|
178 | def test_archive | |
124 | @request.session[:user_id] = 1 # admin |
|
179 | @request.session[:user_id] = 1 # admin | |
125 | post :archive, :id => 1 |
|
180 | post :archive, :id => 1 | |
126 | assert_redirected_to 'admin/projects' |
|
181 | assert_redirected_to 'admin/projects' | |
127 | assert !Project.find(1).active? |
|
182 | assert !Project.find(1).active? | |
128 | end |
|
183 | end | |
129 |
|
184 | |||
130 | def test_unarchive |
|
185 | def test_unarchive | |
131 | @request.session[:user_id] = 1 # admin |
|
186 | @request.session[:user_id] = 1 # admin | |
132 | Project.find(1).archive |
|
187 | Project.find(1).archive | |
133 | post :unarchive, :id => 1 |
|
188 | post :unarchive, :id => 1 | |
134 | assert_redirected_to 'admin/projects' |
|
189 | assert_redirected_to 'admin/projects' | |
135 | assert Project.find(1).active? |
|
190 | assert Project.find(1).active? | |
136 | end |
|
191 | end | |
137 |
|
192 | |||
138 | def test_add_issue |
|
193 | def test_add_issue | |
139 | @request.session[:user_id] = 2 |
|
194 | @request.session[:user_id] = 2 | |
140 | get :add_issue, :id => 1, :tracker_id => 1 |
|
195 | get :add_issue, :id => 1, :tracker_id => 1 | |
141 | assert_response :success |
|
196 | assert_response :success | |
142 | assert_template 'add_issue' |
|
197 | assert_template 'add_issue' | |
143 | post :add_issue, :id => 1, :issue => {:tracker_id => 1, :subject => 'This is the test_add_issue issue', :description => 'This is the description', :priority_id => 5} |
|
198 | post :add_issue, :id => 1, :issue => {:tracker_id => 1, :subject => 'This is the test_add_issue issue', :description => 'This is the description', :priority_id => 5} | |
144 | assert_redirected_to 'projects/1/issues' |
|
199 | assert_redirected_to 'projects/1/issues' | |
145 | assert Issue.find_by_subject('This is the test_add_issue issue') |
|
200 | assert Issue.find_by_subject('This is the test_add_issue issue') | |
146 | end |
|
201 | end | |
147 |
|
202 | |||
148 | def test_copy_issue |
|
203 | def test_copy_issue | |
149 | @request.session[:user_id] = 2 |
|
204 | @request.session[:user_id] = 2 | |
150 | get :add_issue, :id => 1, :copy_from => 1 |
|
205 | get :add_issue, :id => 1, :copy_from => 1 | |
151 | assert_template 'add_issue' |
|
206 | assert_template 'add_issue' | |
152 | assert_not_nil assigns(:issue) |
|
207 | assert_not_nil assigns(:issue) | |
153 | orig = Issue.find(1) |
|
208 | orig = Issue.find(1) | |
154 | assert_equal orig.subject, assigns(:issue).subject |
|
209 | assert_equal orig.subject, assigns(:issue).subject | |
155 | end |
|
210 | end | |
156 | end |
|
211 | end |
@@ -1,46 +1,64 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.dirname(__FILE__) + '/../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
19 | require 'repositories_controller' |
|
19 | require 'repositories_controller' | |
20 |
|
20 | |||
21 | # Re-raise errors caught by the controller. |
|
21 | # Re-raise errors caught by the controller. | |
22 | class RepositoriesController; def rescue_action(e) raise e end; end |
|
22 | class RepositoriesController; def rescue_action(e) raise e end; end | |
23 |
|
23 | |||
24 | class RepositoriesControllerTest < Test::Unit::TestCase |
|
24 | class RepositoriesControllerTest < Test::Unit::TestCase | |
25 | fixtures :projects, :users, :roles, :members, :repositories, :issues, :issue_statuses, :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers |
|
25 | fixtures :projects, :users, :roles, :members, :repositories, :issues, :issue_statuses, :changesets, :changes, :issue_categories, :enumerations, :custom_fields, :custom_values, :trackers | |
26 |
|
26 | |||
27 | def setup |
|
27 | def setup | |
28 | @controller = RepositoriesController.new |
|
28 | @controller = RepositoriesController.new | |
29 | @request = ActionController::TestRequest.new |
|
29 | @request = ActionController::TestRequest.new | |
30 | @response = ActionController::TestResponse.new |
|
30 | @response = ActionController::TestResponse.new | |
31 | User.current = nil |
|
31 | User.current = nil | |
32 | end |
|
32 | end | |
33 |
|
33 | |||
|
34 | def test_revisions | |||
|
35 | get :revisions, :id => 1 | |||
|
36 | assert_response :success | |||
|
37 | assert_template 'revisions' | |||
|
38 | assert_not_nil assigns(:changesets) | |||
|
39 | end | |||
|
40 | ||||
34 | def test_revision_with_before_nil_and_afer_normal |
|
41 | def test_revision_with_before_nil_and_afer_normal | |
35 | get :revision, {:id => 1, :rev => 1} |
|
42 | get :revision, {:id => 1, :rev => 1} | |
36 | assert_response :success |
|
43 | assert_response :success | |
37 | assert_template 'revision' |
|
44 | assert_template 'revision' | |
38 | assert_no_tag :tag => "div", :attributes => { :class => "contextual" }, |
|
45 | assert_no_tag :tag => "div", :attributes => { :class => "contextual" }, | |
39 | :child => { :tag => "a", :attributes => { :href => '/repositories/revision/1?rev=0'} |
|
46 | :child => { :tag => "a", :attributes => { :href => '/repositories/revision/1?rev=0'} | |
40 | } |
|
47 | } | |
41 | assert_tag :tag => "div", :attributes => { :class => "contextual" }, |
|
48 | assert_tag :tag => "div", :attributes => { :class => "contextual" }, | |
42 | :child => { :tag => "a", :attributes => { :href => '/repositories/revision/1?rev=2'} |
|
49 | :child => { :tag => "a", :attributes => { :href => '/repositories/revision/1?rev=2'} | |
43 | } |
|
50 | } | |
44 | end |
|
51 | end | |
45 |
|
52 | |||
|
53 | def test_graph_commits_per_month | |||
|
54 | get :graph, :id => 1, :graph => 'commits_per_month' | |||
|
55 | assert_response :success | |||
|
56 | assert_equal 'image/svg+xml', @response.content_type | |||
|
57 | end | |||
|
58 | ||||
|
59 | def test_graph_commits_per_author | |||
|
60 | get :graph, :id => 1, :graph => 'commits_per_author' | |||
|
61 | assert_response :success | |||
|
62 | assert_equal 'image/svg+xml', @response.content_type | |||
|
63 | end | |||
46 | end |
|
64 | end |
@@ -1,87 +1,87 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.dirname(__FILE__) + '/../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
19 |
|
19 | |||
20 | class RepositoryBazaarTest < Test::Unit::TestCase |
|
20 | class RepositoryBazaarTest < Test::Unit::TestCase | |
21 | fixtures :projects |
|
21 | fixtures :projects | |
22 |
|
22 | |||
23 | # No '..' in the repository path |
|
23 | # No '..' in the repository path | |
24 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + 'tmp/test/bazaar_repository' |
|
24 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + 'tmp/test/bazaar_repository' | |
25 |
|
25 | |||
26 | def setup |
|
26 | def setup | |
27 | @project = Project.find(1) |
|
27 | @project = Project.find(1) | |
28 | assert @repository = Repository::Bazaar.create(:project => @project, :url => "file:///#{REPOSITORY_PATH}") |
|
28 | assert @repository = Repository::Bazaar.create(:project => @project, :url => "file:///#{REPOSITORY_PATH}") | |
29 | end |
|
29 | end | |
30 |
|
30 | |||
31 | if File.directory?(REPOSITORY_PATH) |
|
31 | if File.directory?(REPOSITORY_PATH) | |
32 | def test_fetch_changesets_from_scratch |
|
32 | def test_fetch_changesets_from_scratch | |
33 | @repository.fetch_changesets |
|
33 | @repository.fetch_changesets | |
34 | @repository.reload |
|
34 | @repository.reload | |
35 |
|
35 | |||
36 | assert_equal 4, @repository.changesets.count |
|
36 | assert_equal 4, @repository.changesets.count | |
37 | assert_equal 9, @repository.changes.count |
|
37 | assert_equal 9, @repository.changes.count | |
38 | assert_equal 'Initial import', @repository.changesets.find_by_revision(1).comments |
|
38 | assert_equal 'Initial import', @repository.changesets.find_by_revision(1).comments | |
39 | end |
|
39 | end | |
40 |
|
40 | |||
41 | def test_fetch_changesets_incremental |
|
41 | def test_fetch_changesets_incremental | |
42 | @repository.fetch_changesets |
|
42 | @repository.fetch_changesets | |
43 | # Remove changesets with revision > 5 |
|
43 | # Remove changesets with revision > 5 | |
44 | @repository.changesets.find(:all, :conditions => 'revision > 2').each(&:destroy) |
|
44 | @repository.changesets.find(:all, :conditions => 'revision > 2').each(&:destroy) | |
45 | @repository.reload |
|
45 | @repository.reload | |
46 | assert_equal 2, @repository.changesets.count |
|
46 | assert_equal 2, @repository.changesets.count | |
47 |
|
47 | |||
48 | @repository.fetch_changesets |
|
48 | @repository.fetch_changesets | |
49 | assert_equal 4, @repository.changesets.count |
|
49 | assert_equal 4, @repository.changesets.count | |
50 | end |
|
50 | end | |
51 |
|
51 | |||
52 | def test_entries |
|
52 | def test_entries | |
53 | entries = @repository.entries |
|
53 | entries = @repository.entries | |
54 | assert_equal 2, entries.size |
|
54 | assert_equal 2, entries.size | |
55 |
|
55 | |||
56 | assert_equal 'dir', entries[0].kind |
|
56 | assert_equal 'dir', entries[0].kind | |
57 | assert_equal 'directory', entries[0].name |
|
57 | assert_equal 'directory', entries[0].name | |
58 |
|
58 | |||
59 | assert_equal 'file', entries[1].kind |
|
59 | assert_equal 'file', entries[1].kind | |
60 | assert_equal 'doc-mkdir.txt', entries[1].name |
|
60 | assert_equal 'doc-mkdir.txt', entries[1].name | |
61 | end |
|
61 | end | |
62 |
|
62 | |||
63 | def test_entries_in_subdirectory |
|
63 | def test_entries_in_subdirectory | |
64 | entries = @repository.entries('directory') |
|
64 | entries = @repository.entries('directory') | |
65 | assert_equal 3, entries.size |
|
65 | assert_equal 3, entries.size | |
66 |
|
66 | |||
67 | assert_equal 'file', entries.last.kind |
|
67 | assert_equal 'file', entries.last.kind | |
68 | assert_equal 'edit.png', entries.last.name |
|
68 | assert_equal 'edit.png', entries.last.name | |
69 | end |
|
69 | end | |
70 |
|
70 | |||
71 | def test_cat |
|
71 | def test_cat | |
72 | cat = @repository.scm.cat('directory/document.txt') |
|
72 | cat = @repository.scm.cat('directory/document.txt') | |
73 | assert cat =~ /Write the contents of a file as of a given revision to standard output/ |
|
73 | assert cat =~ /Write the contents of a file as of a given revision to standard output/ | |
74 | end |
|
74 | end | |
75 |
|
75 | |||
76 | def test_annotate |
|
76 | def test_annotate | |
77 | annotate = @repository.scm.annotate('doc-mkdir.txt') |
|
77 | annotate = @repository.scm.annotate('doc-mkdir.txt') | |
78 | assert_equal 17, annotate.lines.size |
|
78 | assert_equal 17, annotate.lines.size | |
79 | assert_equal 1, annotate.revisions[0].identifier |
|
79 | assert_equal 1, annotate.revisions[0].identifier | |
80 | assert_equal 'jsmith@', annotate.revisions[0].author |
|
80 | assert_equal 'jsmith@', annotate.revisions[0].author | |
81 | assert_equal 'mkdir', annotate.lines[0] |
|
81 | assert_equal 'mkdir', annotate.lines[0] | |
82 | end |
|
82 | end | |
83 | else |
|
83 | else | |
84 | puts "Bazaar test repository NOT FOUND. Skipping tests !!!" |
|
84 | puts "Bazaar test repository NOT FOUND. Skipping unit tests !!!" | |
85 | def test_fake; assert true end |
|
85 | def test_fake; assert true end | |
86 | end |
|
86 | end | |
87 | end |
|
87 | end |
@@ -1,55 +1,55 | |||||
1 | # redMine - project management software |
|
1 | # redMine - project management software | |
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2007 Jean-Philippe Lang | |
3 | # |
|
3 | # | |
4 | # This program is free software; you can redistribute it and/or |
|
4 | # This program is free software; you can redistribute it and/or | |
5 | # modify it under the terms of the GNU General Public License |
|
5 | # modify it under the terms of the GNU General Public License | |
6 | # as published by the Free Software Foundation; either version 2 |
|
6 | # as published by the Free Software Foundation; either version 2 | |
7 | # of the License, or (at your option) any later version. |
|
7 | # of the License, or (at your option) any later version. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU General Public License |
|
14 | # You should have received a copy of the GNU General Public License | |
15 | # along with this program; if not, write to the Free Software |
|
15 | # along with this program; if not, write to the Free Software | |
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 |
|
17 | |||
18 | require File.dirname(__FILE__) + '/../test_helper' |
|
18 | require File.dirname(__FILE__) + '/../test_helper' | |
19 |
|
19 | |||
20 | class RepositorySubversionTest < Test::Unit::TestCase |
|
20 | class RepositorySubversionTest < Test::Unit::TestCase | |
21 | fixtures :projects |
|
21 | fixtures :projects | |
22 |
|
22 | |||
23 | # No '..' in the repository path for svn |
|
23 | # No '..' in the repository path for svn | |
24 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/subversion_repository' |
|
24 | REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/subversion_repository' | |
25 |
|
25 | |||
26 | def setup |
|
26 | def setup | |
27 | @project = Project.find(1) |
|
27 | @project = Project.find(1) | |
28 | assert @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{REPOSITORY_PATH}") |
|
28 | assert @repository = Repository::Subversion.create(:project => @project, :url => "file:///#{REPOSITORY_PATH}") | |
29 | end |
|
29 | end | |
30 |
|
30 | |||
31 | if File.directory?(REPOSITORY_PATH) |
|
31 | if File.directory?(REPOSITORY_PATH) | |
32 | def test_fetch_changesets_from_scratch |
|
32 | def test_fetch_changesets_from_scratch | |
33 | @repository.fetch_changesets |
|
33 | @repository.fetch_changesets | |
34 | @repository.reload |
|
34 | @repository.reload | |
35 |
|
35 | |||
36 | assert_equal 8, @repository.changesets.count |
|
36 | assert_equal 8, @repository.changesets.count | |
37 | assert_equal 16, @repository.changes.count |
|
37 | assert_equal 16, @repository.changes.count | |
38 | assert_equal 'Initial import.', @repository.changesets.find_by_revision(1).comments |
|
38 | assert_equal 'Initial import.', @repository.changesets.find_by_revision(1).comments | |
39 | end |
|
39 | end | |
40 |
|
40 | |||
41 | def test_fetch_changesets_incremental |
|
41 | def test_fetch_changesets_incremental | |
42 | @repository.fetch_changesets |
|
42 | @repository.fetch_changesets | |
43 | # Remove changesets with revision > 5 |
|
43 | # Remove changesets with revision > 5 | |
44 | @repository.changesets.find(:all, :conditions => 'revision > 5').each(&:destroy) |
|
44 | @repository.changesets.find(:all, :conditions => 'revision > 5').each(&:destroy) | |
45 | @repository.reload |
|
45 | @repository.reload | |
46 | assert_equal 5, @repository.changesets.count |
|
46 | assert_equal 5, @repository.changesets.count | |
47 |
|
47 | |||
48 | @repository.fetch_changesets |
|
48 | @repository.fetch_changesets | |
49 | assert_equal 8, @repository.changesets.count |
|
49 | assert_equal 8, @repository.changesets.count | |
50 | end |
|
50 | end | |
51 | else |
|
51 | else | |
52 | puts "Subversion test repository NOT FOUND. Skipping tests !!!" |
|
52 | puts "Subversion test repository NOT FOUND. Skipping unit tests !!!" | |
53 | def test_fake; assert true end |
|
53 | def test_fake; assert true end | |
54 | end |
|
54 | end | |
55 | end |
|
55 | end |
General Comments 0
You need to be logged in to leave comments.
Login now