@@ -1,193 +1,199 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2011 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.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
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 |
|
19 | |||
24 | class RepositoriesBazaarControllerTest < ActionController::TestCase |
|
20 | class RepositoriesBazaarControllerTest < ActionController::TestCase | |
|
21 | tests RepositoriesController | |||
|
22 | ||||
25 | fixtures :projects, :users, :roles, :members, :member_roles, |
|
23 | fixtures :projects, :users, :roles, :members, :member_roles, | |
26 | :repositories, :enabled_modules |
|
24 | :repositories, :enabled_modules | |
27 |
|
25 | |||
28 | REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository/trunk').to_s |
|
26 | REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository/trunk').to_s | |
29 | PRJ_ID = 3 |
|
27 | PRJ_ID = 3 | |
30 |
|
28 | |||
31 | def setup |
|
29 | def setup | |
32 | @controller = RepositoriesController.new |
|
|||
33 | @request = ActionController::TestRequest.new |
|
|||
34 | @response = ActionController::TestResponse.new |
|
|||
35 | User.current = nil |
|
30 | User.current = nil | |
36 | @project = Project.find(PRJ_ID) |
|
31 | @project = Project.find(PRJ_ID) | |
37 | @repository = Repository::Bazaar.create( |
|
32 | @repository = Repository::Bazaar.create( | |
38 | :project => @project, |
|
33 | :project => @project, | |
39 | :url => REPOSITORY_PATH, |
|
34 | :url => REPOSITORY_PATH, | |
40 | :log_encoding => 'UTF-8') |
|
35 | :log_encoding => 'UTF-8') | |
41 | assert @repository |
|
36 | assert @repository | |
42 | end |
|
37 | end | |
43 |
|
38 | |||
44 | if File.directory?(REPOSITORY_PATH) |
|
39 | if File.directory?(REPOSITORY_PATH) | |
|
40 | def test_get_edit | |||
|
41 | @request.session[:user_id] = 1 | |||
|
42 | @project.repository.destroy | |||
|
43 | xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Bazaar' | |||
|
44 | assert_response :success | |||
|
45 | assert_equal 'text/javascript', @response.content_type | |||
|
46 | assert_kind_of Repository::Bazaar, assigns(:repository) | |||
|
47 | assert assigns(:repository).new_record? | |||
|
48 | assert_select_rjs :replace_html, 'tab-content-repository' | |||
|
49 | end | |||
|
50 | ||||
45 | def test_browse_root |
|
51 | def test_browse_root | |
46 | get :show, :id => PRJ_ID |
|
52 | get :show, :id => PRJ_ID | |
47 | assert_response :success |
|
53 | assert_response :success | |
48 | assert_template 'show' |
|
54 | assert_template 'show' | |
49 | assert_not_nil assigns(:entries) |
|
55 | assert_not_nil assigns(:entries) | |
50 | assert_equal 2, assigns(:entries).size |
|
56 | assert_equal 2, assigns(:entries).size | |
51 | assert assigns(:entries).detect {|e| e.name == 'directory' && e.kind == 'dir'} |
|
57 | assert assigns(:entries).detect {|e| e.name == 'directory' && e.kind == 'dir'} | |
52 | assert assigns(:entries).detect {|e| e.name == 'doc-mkdir.txt' && e.kind == 'file'} |
|
58 | assert assigns(:entries).detect {|e| e.name == 'doc-mkdir.txt' && e.kind == 'file'} | |
53 | end |
|
59 | end | |
54 |
|
60 | |||
55 | def test_browse_directory |
|
61 | def test_browse_directory | |
56 | get :show, :id => PRJ_ID, :path => ['directory'] |
|
62 | get :show, :id => PRJ_ID, :path => ['directory'] | |
57 | assert_response :success |
|
63 | assert_response :success | |
58 | assert_template 'show' |
|
64 | assert_template 'show' | |
59 | assert_not_nil assigns(:entries) |
|
65 | assert_not_nil assigns(:entries) | |
60 | assert_equal ['doc-ls.txt', 'document.txt', 'edit.png'], assigns(:entries).collect(&:name) |
|
66 | assert_equal ['doc-ls.txt', 'document.txt', 'edit.png'], assigns(:entries).collect(&:name) | |
61 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} |
|
67 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | |
62 | assert_not_nil entry |
|
68 | assert_not_nil entry | |
63 | assert_equal 'file', entry.kind |
|
69 | assert_equal 'file', entry.kind | |
64 | assert_equal 'directory/edit.png', entry.path |
|
70 | assert_equal 'directory/edit.png', entry.path | |
65 | end |
|
71 | end | |
66 |
|
72 | |||
67 | def test_browse_at_given_revision |
|
73 | def test_browse_at_given_revision | |
68 | get :show, :id => PRJ_ID, :path => [], :rev => 3 |
|
74 | get :show, :id => PRJ_ID, :path => [], :rev => 3 | |
69 | assert_response :success |
|
75 | assert_response :success | |
70 | assert_template 'show' |
|
76 | assert_template 'show' | |
71 | assert_not_nil assigns(:entries) |
|
77 | assert_not_nil assigns(:entries) | |
72 | assert_equal ['directory', 'doc-deleted.txt', 'doc-ls.txt', 'doc-mkdir.txt'], |
|
78 | assert_equal ['directory', 'doc-deleted.txt', 'doc-ls.txt', 'doc-mkdir.txt'], | |
73 | assigns(:entries).collect(&:name) |
|
79 | assigns(:entries).collect(&:name) | |
74 | end |
|
80 | end | |
75 |
|
81 | |||
76 | def test_changes |
|
82 | def test_changes | |
77 | get :changes, :id => PRJ_ID, :path => ['doc-mkdir.txt'] |
|
83 | get :changes, :id => PRJ_ID, :path => ['doc-mkdir.txt'] | |
78 | assert_response :success |
|
84 | assert_response :success | |
79 | assert_template 'changes' |
|
85 | assert_template 'changes' | |
80 | assert_tag :tag => 'h2', :content => 'doc-mkdir.txt' |
|
86 | assert_tag :tag => 'h2', :content => 'doc-mkdir.txt' | |
81 | end |
|
87 | end | |
82 |
|
88 | |||
83 | def test_entry_show |
|
89 | def test_entry_show | |
84 | get :entry, :id => PRJ_ID, :path => ['directory', 'doc-ls.txt'] |
|
90 | get :entry, :id => PRJ_ID, :path => ['directory', 'doc-ls.txt'] | |
85 | assert_response :success |
|
91 | assert_response :success | |
86 | assert_template 'entry' |
|
92 | assert_template 'entry' | |
87 | # Line 19 |
|
93 | # Line 19 | |
88 | assert_tag :tag => 'th', |
|
94 | assert_tag :tag => 'th', | |
89 | :content => /29/, |
|
95 | :content => /29/, | |
90 | :attributes => { :class => /line-num/ }, |
|
96 | :attributes => { :class => /line-num/ }, | |
91 | :sibling => { :tag => 'td', :content => /Show help message/ } |
|
97 | :sibling => { :tag => 'td', :content => /Show help message/ } | |
92 | end |
|
98 | end | |
93 |
|
99 | |||
94 | def test_entry_download |
|
100 | def test_entry_download | |
95 | get :entry, :id => PRJ_ID, :path => ['directory', 'doc-ls.txt'], :format => 'raw' |
|
101 | get :entry, :id => PRJ_ID, :path => ['directory', 'doc-ls.txt'], :format => 'raw' | |
96 | assert_response :success |
|
102 | assert_response :success | |
97 | # File content |
|
103 | # File content | |
98 | assert @response.body.include?('Show help message') |
|
104 | assert @response.body.include?('Show help message') | |
99 | end |
|
105 | end | |
100 |
|
106 | |||
101 | def test_directory_entry |
|
107 | def test_directory_entry | |
102 | get :entry, :id => PRJ_ID, :path => ['directory'] |
|
108 | get :entry, :id => PRJ_ID, :path => ['directory'] | |
103 | assert_response :success |
|
109 | assert_response :success | |
104 | assert_template 'show' |
|
110 | assert_template 'show' | |
105 | assert_not_nil assigns(:entry) |
|
111 | assert_not_nil assigns(:entry) | |
106 | assert_equal 'directory', assigns(:entry).name |
|
112 | assert_equal 'directory', assigns(:entry).name | |
107 | end |
|
113 | end | |
108 |
|
114 | |||
109 | def test_diff |
|
115 | def test_diff | |
110 | # Full diff of changeset 3 |
|
116 | # Full diff of changeset 3 | |
111 | ['inline', 'sbs'].each do |dt| |
|
117 | ['inline', 'sbs'].each do |dt| | |
112 | get :diff, :id => PRJ_ID, :rev => 3, :type => dt |
|
118 | get :diff, :id => PRJ_ID, :rev => 3, :type => dt | |
113 | assert_response :success |
|
119 | assert_response :success | |
114 | assert_template 'diff' |
|
120 | assert_template 'diff' | |
115 | # Line 11 removed |
|
121 | # Line 11 removed | |
116 | assert_tag :tag => 'th', |
|
122 | assert_tag :tag => 'th', | |
117 | :content => '11', |
|
123 | :content => '11', | |
118 | :sibling => { :tag => 'td', |
|
124 | :sibling => { :tag => 'td', | |
119 | :attributes => { :class => /diff_out/ }, |
|
125 | :attributes => { :class => /diff_out/ }, | |
120 | :content => /Display more information/ } |
|
126 | :content => /Display more information/ } | |
121 | end |
|
127 | end | |
122 | end |
|
128 | end | |
123 |
|
129 | |||
124 | def test_annotate |
|
130 | def test_annotate | |
125 | get :annotate, :id => PRJ_ID, :path => ['doc-mkdir.txt'] |
|
131 | get :annotate, :id => PRJ_ID, :path => ['doc-mkdir.txt'] | |
126 | assert_response :success |
|
132 | assert_response :success | |
127 | assert_template 'annotate' |
|
133 | assert_template 'annotate' | |
128 | assert_tag :tag => 'th', :content => '2', |
|
134 | assert_tag :tag => 'th', :content => '2', | |
129 | :sibling => { |
|
135 | :sibling => { | |
130 | :tag => 'td', |
|
136 | :tag => 'td', | |
131 | :child => { |
|
137 | :child => { | |
132 | :tag => 'a', |
|
138 | :tag => 'a', | |
133 | :content => '3' |
|
139 | :content => '3' | |
134 | } |
|
140 | } | |
135 | } |
|
141 | } | |
136 | assert_tag :tag => 'th', :content => '2', |
|
142 | assert_tag :tag => 'th', :content => '2', | |
137 | :sibling => { :tag => 'td', :content => /jsmith/ } |
|
143 | :sibling => { :tag => 'td', :content => /jsmith/ } | |
138 | assert_tag :tag => 'th', :content => '2', |
|
144 | assert_tag :tag => 'th', :content => '2', | |
139 | :sibling => { |
|
145 | :sibling => { | |
140 | :tag => 'td', |
|
146 | :tag => 'td', | |
141 | :child => { |
|
147 | :child => { | |
142 | :tag => 'a', |
|
148 | :tag => 'a', | |
143 | :content => '3' |
|
149 | :content => '3' | |
144 | } |
|
150 | } | |
145 | } |
|
151 | } | |
146 | assert_tag :tag => 'th', :content => '2', |
|
152 | assert_tag :tag => 'th', :content => '2', | |
147 | :sibling => { :tag => 'td', :content => /Main purpose/ } |
|
153 | :sibling => { :tag => 'td', :content => /Main purpose/ } | |
148 | end |
|
154 | end | |
149 |
|
155 | |||
150 | def test_destroy_valid_repository |
|
156 | def test_destroy_valid_repository | |
151 | @request.session[:user_id] = 1 # admin |
|
157 | @request.session[:user_id] = 1 # admin | |
152 | assert_equal 0, @repository.changesets.count |
|
158 | assert_equal 0, @repository.changesets.count | |
153 | @repository.fetch_changesets |
|
159 | @repository.fetch_changesets | |
154 | @project.reload |
|
160 | @project.reload | |
155 | assert @repository.changesets.count > 0 |
|
161 | assert @repository.changesets.count > 0 | |
156 |
|
162 | |||
157 | get :destroy, :id => PRJ_ID |
|
163 | get :destroy, :id => PRJ_ID | |
158 | assert_response 302 |
|
164 | assert_response 302 | |
159 | @project.reload |
|
165 | @project.reload | |
160 | assert_nil @project.repository |
|
166 | assert_nil @project.repository | |
161 | end |
|
167 | end | |
162 |
|
168 | |||
163 | def test_destroy_invalid_repository |
|
169 | def test_destroy_invalid_repository | |
164 | @request.session[:user_id] = 1 # admin |
|
170 | @request.session[:user_id] = 1 # admin | |
165 | assert_equal 0, @repository.changesets.count |
|
171 | assert_equal 0, @repository.changesets.count | |
166 | @repository.fetch_changesets |
|
172 | @repository.fetch_changesets | |
167 | @project.reload |
|
173 | @project.reload | |
168 | assert @repository.changesets.count > 0 |
|
174 | assert @repository.changesets.count > 0 | |
169 |
|
175 | |||
170 | get :destroy, :id => PRJ_ID |
|
176 | get :destroy, :id => PRJ_ID | |
171 | assert_response 302 |
|
177 | assert_response 302 | |
172 | @project.reload |
|
178 | @project.reload | |
173 | assert_nil @project.repository |
|
179 | assert_nil @project.repository | |
174 |
|
180 | |||
175 | @repository = Repository::Bazaar.create( |
|
181 | @repository = Repository::Bazaar.create( | |
176 | :project => @project, |
|
182 | :project => @project, | |
177 | :url => "/invalid", |
|
183 | :url => "/invalid", | |
178 | :log_encoding => 'UTF-8') |
|
184 | :log_encoding => 'UTF-8') | |
179 | assert @repository |
|
185 | assert @repository | |
180 | @repository.fetch_changesets |
|
186 | @repository.fetch_changesets | |
181 | @repository.reload |
|
187 | @repository.reload | |
182 | assert_equal 0, @repository.changesets.count |
|
188 | assert_equal 0, @repository.changesets.count | |
183 |
|
189 | |||
184 | get :destroy, :id => PRJ_ID |
|
190 | get :destroy, :id => PRJ_ID | |
185 | assert_response 302 |
|
191 | assert_response 302 | |
186 | @project.reload |
|
192 | @project.reload | |
187 | assert_nil @project.repository |
|
193 | assert_nil @project.repository | |
188 | end |
|
194 | end | |
189 | else |
|
195 | else | |
190 | puts "Bazaar test repository NOT FOUND. Skipping functional tests !!!" |
|
196 | puts "Bazaar test repository NOT FOUND. Skipping functional tests !!!" | |
191 | def test_fake; assert true end |
|
197 | def test_fake; assert true end | |
192 | end |
|
198 | end | |
193 | end |
|
199 | end |
@@ -1,282 +1,288 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2011 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.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
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 |
|
19 | |||
24 | class RepositoriesCvsControllerTest < ActionController::TestCase |
|
20 | class RepositoriesCvsControllerTest < ActionController::TestCase | |
|
21 | tests RepositoriesController | |||
|
22 | ||||
25 | fixtures :projects, :users, :roles, :members, :member_roles, |
|
23 | fixtures :projects, :users, :roles, :members, :member_roles, | |
26 | :repositories, :enabled_modules |
|
24 | :repositories, :enabled_modules | |
27 |
|
25 | |||
28 | REPOSITORY_PATH = Rails.root.join('tmp/test/cvs_repository').to_s |
|
26 | REPOSITORY_PATH = Rails.root.join('tmp/test/cvs_repository').to_s | |
29 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? |
|
27 | REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin? | |
30 | # CVS module |
|
28 | # CVS module | |
31 | MODULE_NAME = 'test' |
|
29 | MODULE_NAME = 'test' | |
32 | PRJ_ID = 3 |
|
30 | PRJ_ID = 3 | |
33 | NUM_REV = 7 |
|
31 | NUM_REV = 7 | |
34 |
|
32 | |||
35 | def setup |
|
33 | def setup | |
36 | @controller = RepositoriesController.new |
|
|||
37 | @request = ActionController::TestRequest.new |
|
|||
38 | @response = ActionController::TestResponse.new |
|
|||
39 | Setting.default_language = 'en' |
|
34 | Setting.default_language = 'en' | |
40 | User.current = nil |
|
35 | User.current = nil | |
41 |
|
36 | |||
42 | @project = Project.find(PRJ_ID) |
|
37 | @project = Project.find(PRJ_ID) | |
43 | @repository = Repository::Cvs.create(:project => Project.find(PRJ_ID), |
|
38 | @repository = Repository::Cvs.create(:project => Project.find(PRJ_ID), | |
44 | :root_url => REPOSITORY_PATH, |
|
39 | :root_url => REPOSITORY_PATH, | |
45 | :url => MODULE_NAME, |
|
40 | :url => MODULE_NAME, | |
46 | :log_encoding => 'UTF-8') |
|
41 | :log_encoding => 'UTF-8') | |
47 | assert @repository |
|
42 | assert @repository | |
48 | end |
|
43 | end | |
49 |
|
44 | |||
50 | if File.directory?(REPOSITORY_PATH) |
|
45 | if File.directory?(REPOSITORY_PATH) | |
|
46 | def test_get_edit | |||
|
47 | @request.session[:user_id] = 1 | |||
|
48 | @project.repository.destroy | |||
|
49 | xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Cvs' | |||
|
50 | assert_response :success | |||
|
51 | assert_equal 'text/javascript', @response.content_type | |||
|
52 | assert_kind_of Repository::Cvs, assigns(:repository) | |||
|
53 | assert assigns(:repository).new_record? | |||
|
54 | assert_select_rjs :replace_html, 'tab-content-repository' | |||
|
55 | end | |||
|
56 | ||||
51 | def test_browse_root |
|
57 | def test_browse_root | |
52 | assert_equal 0, @repository.changesets.count |
|
58 | assert_equal 0, @repository.changesets.count | |
53 | @repository.fetch_changesets |
|
59 | @repository.fetch_changesets | |
54 | @project.reload |
|
60 | @project.reload | |
55 | assert_equal NUM_REV, @repository.changesets.count |
|
61 | assert_equal NUM_REV, @repository.changesets.count | |
56 | get :show, :id => PRJ_ID |
|
62 | get :show, :id => PRJ_ID | |
57 | assert_response :success |
|
63 | assert_response :success | |
58 | assert_template 'show' |
|
64 | assert_template 'show' | |
59 | assert_not_nil assigns(:entries) |
|
65 | assert_not_nil assigns(:entries) | |
60 | assert_equal 3, assigns(:entries).size |
|
66 | assert_equal 3, assigns(:entries).size | |
61 |
|
67 | |||
62 | entry = assigns(:entries).detect {|e| e.name == 'images'} |
|
68 | entry = assigns(:entries).detect {|e| e.name == 'images'} | |
63 | assert_equal 'dir', entry.kind |
|
69 | assert_equal 'dir', entry.kind | |
64 |
|
70 | |||
65 | entry = assigns(:entries).detect {|e| e.name == 'README'} |
|
71 | entry = assigns(:entries).detect {|e| e.name == 'README'} | |
66 | assert_equal 'file', entry.kind |
|
72 | assert_equal 'file', entry.kind | |
67 |
|
73 | |||
68 | assert_not_nil assigns(:changesets) |
|
74 | assert_not_nil assigns(:changesets) | |
69 | assert assigns(:changesets).size > 0 |
|
75 | assert assigns(:changesets).size > 0 | |
70 | end |
|
76 | end | |
71 |
|
77 | |||
72 | def test_browse_directory |
|
78 | def test_browse_directory | |
73 | assert_equal 0, @repository.changesets.count |
|
79 | assert_equal 0, @repository.changesets.count | |
74 | @repository.fetch_changesets |
|
80 | @repository.fetch_changesets | |
75 | @project.reload |
|
81 | @project.reload | |
76 | assert_equal NUM_REV, @repository.changesets.count |
|
82 | assert_equal NUM_REV, @repository.changesets.count | |
77 | get :show, :id => PRJ_ID, :path => ['images'] |
|
83 | get :show, :id => PRJ_ID, :path => ['images'] | |
78 | assert_response :success |
|
84 | assert_response :success | |
79 | assert_template 'show' |
|
85 | assert_template 'show' | |
80 | assert_not_nil assigns(:entries) |
|
86 | assert_not_nil assigns(:entries) | |
81 | assert_equal ['add.png', 'delete.png', 'edit.png'], assigns(:entries).collect(&:name) |
|
87 | assert_equal ['add.png', 'delete.png', 'edit.png'], assigns(:entries).collect(&:name) | |
82 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} |
|
88 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | |
83 | assert_not_nil entry |
|
89 | assert_not_nil entry | |
84 | assert_equal 'file', entry.kind |
|
90 | assert_equal 'file', entry.kind | |
85 | assert_equal 'images/edit.png', entry.path |
|
91 | assert_equal 'images/edit.png', entry.path | |
86 | end |
|
92 | end | |
87 |
|
93 | |||
88 | def test_browse_at_given_revision |
|
94 | def test_browse_at_given_revision | |
89 | assert_equal 0, @repository.changesets.count |
|
95 | assert_equal 0, @repository.changesets.count | |
90 | @repository.fetch_changesets |
|
96 | @repository.fetch_changesets | |
91 | @project.reload |
|
97 | @project.reload | |
92 | assert_equal NUM_REV, @repository.changesets.count |
|
98 | assert_equal NUM_REV, @repository.changesets.count | |
93 | get :show, :id => PRJ_ID, :path => ['images'], :rev => 1 |
|
99 | get :show, :id => PRJ_ID, :path => ['images'], :rev => 1 | |
94 | assert_response :success |
|
100 | assert_response :success | |
95 | assert_template 'show' |
|
101 | assert_template 'show' | |
96 | assert_not_nil assigns(:entries) |
|
102 | assert_not_nil assigns(:entries) | |
97 | assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) |
|
103 | assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) | |
98 | end |
|
104 | end | |
99 |
|
105 | |||
100 | def test_entry |
|
106 | def test_entry | |
101 | assert_equal 0, @repository.changesets.count |
|
107 | assert_equal 0, @repository.changesets.count | |
102 | @repository.fetch_changesets |
|
108 | @repository.fetch_changesets | |
103 | @project.reload |
|
109 | @project.reload | |
104 | assert_equal NUM_REV, @repository.changesets.count |
|
110 | assert_equal NUM_REV, @repository.changesets.count | |
105 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] |
|
111 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] | |
106 | assert_response :success |
|
112 | assert_response :success | |
107 | assert_template 'entry' |
|
113 | assert_template 'entry' | |
108 | assert_no_tag :tag => 'td', |
|
114 | assert_no_tag :tag => 'td', | |
109 | :attributes => { :class => /line-code/}, |
|
115 | :attributes => { :class => /line-code/}, | |
110 | :content => /before_filter/ |
|
116 | :content => /before_filter/ | |
111 | end |
|
117 | end | |
112 |
|
118 | |||
113 | def test_entry_at_given_revision |
|
119 | def test_entry_at_given_revision | |
114 | # changesets must be loaded |
|
120 | # changesets must be loaded | |
115 | assert_equal 0, @repository.changesets.count |
|
121 | assert_equal 0, @repository.changesets.count | |
116 | @repository.fetch_changesets |
|
122 | @repository.fetch_changesets | |
117 | @project.reload |
|
123 | @project.reload | |
118 | assert_equal NUM_REV, @repository.changesets.count |
|
124 | assert_equal NUM_REV, @repository.changesets.count | |
119 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :rev => 2 |
|
125 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :rev => 2 | |
120 | assert_response :success |
|
126 | assert_response :success | |
121 | assert_template 'entry' |
|
127 | assert_template 'entry' | |
122 | # this line was removed in r3 |
|
128 | # this line was removed in r3 | |
123 | assert_tag :tag => 'td', |
|
129 | assert_tag :tag => 'td', | |
124 | :attributes => { :class => /line-code/}, |
|
130 | :attributes => { :class => /line-code/}, | |
125 | :content => /before_filter/ |
|
131 | :content => /before_filter/ | |
126 | end |
|
132 | end | |
127 |
|
133 | |||
128 | def test_entry_not_found |
|
134 | def test_entry_not_found | |
129 | assert_equal 0, @repository.changesets.count |
|
135 | assert_equal 0, @repository.changesets.count | |
130 | @repository.fetch_changesets |
|
136 | @repository.fetch_changesets | |
131 | @project.reload |
|
137 | @project.reload | |
132 | assert_equal NUM_REV, @repository.changesets.count |
|
138 | assert_equal NUM_REV, @repository.changesets.count | |
133 | get :entry, :id => PRJ_ID, :path => ['sources', 'zzz.c'] |
|
139 | get :entry, :id => PRJ_ID, :path => ['sources', 'zzz.c'] | |
134 | assert_tag :tag => 'p', |
|
140 | assert_tag :tag => 'p', | |
135 | :attributes => { :id => /errorExplanation/ }, |
|
141 | :attributes => { :id => /errorExplanation/ }, | |
136 | :content => /The entry or revision was not found in the repository/ |
|
142 | :content => /The entry or revision was not found in the repository/ | |
137 | end |
|
143 | end | |
138 |
|
144 | |||
139 | def test_entry_download |
|
145 | def test_entry_download | |
140 | assert_equal 0, @repository.changesets.count |
|
146 | assert_equal 0, @repository.changesets.count | |
141 | @repository.fetch_changesets |
|
147 | @repository.fetch_changesets | |
142 | @project.reload |
|
148 | @project.reload | |
143 | assert_equal NUM_REV, @repository.changesets.count |
|
149 | assert_equal NUM_REV, @repository.changesets.count | |
144 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], |
|
150 | get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], | |
145 | :format => 'raw' |
|
151 | :format => 'raw' | |
146 | assert_response :success |
|
152 | assert_response :success | |
147 | end |
|
153 | end | |
148 |
|
154 | |||
149 | def test_directory_entry |
|
155 | def test_directory_entry | |
150 | assert_equal 0, @repository.changesets.count |
|
156 | assert_equal 0, @repository.changesets.count | |
151 | @repository.fetch_changesets |
|
157 | @repository.fetch_changesets | |
152 | @project.reload |
|
158 | @project.reload | |
153 | assert_equal NUM_REV, @repository.changesets.count |
|
159 | assert_equal NUM_REV, @repository.changesets.count | |
154 | get :entry, :id => PRJ_ID, :path => ['sources'] |
|
160 | get :entry, :id => PRJ_ID, :path => ['sources'] | |
155 | assert_response :success |
|
161 | assert_response :success | |
156 | assert_template 'show' |
|
162 | assert_template 'show' | |
157 | assert_not_nil assigns(:entry) |
|
163 | assert_not_nil assigns(:entry) | |
158 | assert_equal 'sources', assigns(:entry).name |
|
164 | assert_equal 'sources', assigns(:entry).name | |
159 | end |
|
165 | end | |
160 |
|
166 | |||
161 | def test_diff |
|
167 | def test_diff | |
162 | assert_equal 0, @repository.changesets.count |
|
168 | assert_equal 0, @repository.changesets.count | |
163 | @repository.fetch_changesets |
|
169 | @repository.fetch_changesets | |
164 | @project.reload |
|
170 | @project.reload | |
165 | assert_equal NUM_REV, @repository.changesets.count |
|
171 | assert_equal NUM_REV, @repository.changesets.count | |
166 | ['inline', 'sbs'].each do |dt| |
|
172 | ['inline', 'sbs'].each do |dt| | |
167 | get :diff, :id => PRJ_ID, :rev => 3, :type => dt |
|
173 | get :diff, :id => PRJ_ID, :rev => 3, :type => dt | |
168 | assert_response :success |
|
174 | assert_response :success | |
169 | assert_template 'diff' |
|
175 | assert_template 'diff' | |
170 | assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' }, |
|
176 | assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' }, | |
171 | :content => /before_filter :require_login/ |
|
177 | :content => /before_filter :require_login/ | |
172 | assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' }, |
|
178 | assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' }, | |
173 | :content => /with one change/ |
|
179 | :content => /with one change/ | |
174 | end |
|
180 | end | |
175 | end |
|
181 | end | |
176 |
|
182 | |||
177 | def test_diff_new_files |
|
183 | def test_diff_new_files | |
178 | assert_equal 0, @repository.changesets.count |
|
184 | assert_equal 0, @repository.changesets.count | |
179 | @repository.fetch_changesets |
|
185 | @repository.fetch_changesets | |
180 | @project.reload |
|
186 | @project.reload | |
181 | assert_equal NUM_REV, @repository.changesets.count |
|
187 | assert_equal NUM_REV, @repository.changesets.count | |
182 | ['inline', 'sbs'].each do |dt| |
|
188 | ['inline', 'sbs'].each do |dt| | |
183 | get :diff, :id => PRJ_ID, :rev => 1, :type => dt |
|
189 | get :diff, :id => PRJ_ID, :rev => 1, :type => dt | |
184 | assert_response :success |
|
190 | assert_response :success | |
185 | assert_template 'diff' |
|
191 | assert_template 'diff' | |
186 | assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' }, |
|
192 | assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' }, | |
187 | :content => /watched.remove_watcher/ |
|
193 | :content => /watched.remove_watcher/ | |
188 | assert_tag :tag => 'th', :attributes => { :class => 'filename' }, |
|
194 | assert_tag :tag => 'th', :attributes => { :class => 'filename' }, | |
189 | :content => /test\/README/ |
|
195 | :content => /test\/README/ | |
190 | assert_tag :tag => 'th', :attributes => { :class => 'filename' }, |
|
196 | assert_tag :tag => 'th', :attributes => { :class => 'filename' }, | |
191 | :content => /test\/images\/delete.png / |
|
197 | :content => /test\/images\/delete.png / | |
192 | assert_tag :tag => 'th', :attributes => { :class => 'filename' }, |
|
198 | assert_tag :tag => 'th', :attributes => { :class => 'filename' }, | |
193 | :content => /test\/images\/edit.png/ |
|
199 | :content => /test\/images\/edit.png/ | |
194 | assert_tag :tag => 'th', :attributes => { :class => 'filename' }, |
|
200 | assert_tag :tag => 'th', :attributes => { :class => 'filename' }, | |
195 | :content => /test\/sources\/watchers_controller.rb/ |
|
201 | :content => /test\/sources\/watchers_controller.rb/ | |
196 | end |
|
202 | end | |
197 | end |
|
203 | end | |
198 |
|
204 | |||
199 | def test_annotate |
|
205 | def test_annotate | |
200 | assert_equal 0, @repository.changesets.count |
|
206 | assert_equal 0, @repository.changesets.count | |
201 | @repository.fetch_changesets |
|
207 | @repository.fetch_changesets | |
202 | @project.reload |
|
208 | @project.reload | |
203 | assert_equal NUM_REV, @repository.changesets.count |
|
209 | assert_equal NUM_REV, @repository.changesets.count | |
204 | get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] |
|
210 | get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'] | |
205 | assert_response :success |
|
211 | assert_response :success | |
206 | assert_template 'annotate' |
|
212 | assert_template 'annotate' | |
207 | # 1.1 line |
|
213 | # 1.1 line | |
208 | assert_tag :tag => 'th', |
|
214 | assert_tag :tag => 'th', | |
209 | :attributes => { :class => 'line-num' }, |
|
215 | :attributes => { :class => 'line-num' }, | |
210 | :content => '18', |
|
216 | :content => '18', | |
211 | :sibling => { |
|
217 | :sibling => { | |
212 | :tag => 'td', |
|
218 | :tag => 'td', | |
213 | :attributes => { :class => 'revision' }, |
|
219 | :attributes => { :class => 'revision' }, | |
214 | :content => /1.1/, |
|
220 | :content => /1.1/, | |
215 | :sibling => { |
|
221 | :sibling => { | |
216 | :tag => 'td', |
|
222 | :tag => 'td', | |
217 | :attributes => { :class => 'author' }, |
|
223 | :attributes => { :class => 'author' }, | |
218 | :content => /LANG/ |
|
224 | :content => /LANG/ | |
219 | } |
|
225 | } | |
220 | } |
|
226 | } | |
221 | # 1.2 line |
|
227 | # 1.2 line | |
222 | assert_tag :tag => 'th', |
|
228 | assert_tag :tag => 'th', | |
223 | :attributes => { :class => 'line-num' }, |
|
229 | :attributes => { :class => 'line-num' }, | |
224 | :content => '32', |
|
230 | :content => '32', | |
225 | :sibling => { |
|
231 | :sibling => { | |
226 | :tag => 'td', |
|
232 | :tag => 'td', | |
227 | :attributes => { :class => 'revision' }, |
|
233 | :attributes => { :class => 'revision' }, | |
228 | :content => /1.2/, |
|
234 | :content => /1.2/, | |
229 | :sibling => { |
|
235 | :sibling => { | |
230 | :tag => 'td', |
|
236 | :tag => 'td', | |
231 | :attributes => { :class => 'author' }, |
|
237 | :attributes => { :class => 'author' }, | |
232 | :content => /LANG/ |
|
238 | :content => /LANG/ | |
233 | } |
|
239 | } | |
234 | } |
|
240 | } | |
235 | end |
|
241 | end | |
236 |
|
242 | |||
237 | def test_destroy_valid_repository |
|
243 | def test_destroy_valid_repository | |
238 | @request.session[:user_id] = 1 # admin |
|
244 | @request.session[:user_id] = 1 # admin | |
239 | assert_equal 0, @repository.changesets.count |
|
245 | assert_equal 0, @repository.changesets.count | |
240 | @repository.fetch_changesets |
|
246 | @repository.fetch_changesets | |
241 | @project.reload |
|
247 | @project.reload | |
242 | assert_equal NUM_REV, @repository.changesets.count |
|
248 | assert_equal NUM_REV, @repository.changesets.count | |
243 |
|
249 | |||
244 | get :destroy, :id => PRJ_ID |
|
250 | get :destroy, :id => PRJ_ID | |
245 | assert_response 302 |
|
251 | assert_response 302 | |
246 | @project.reload |
|
252 | @project.reload | |
247 | assert_nil @project.repository |
|
253 | assert_nil @project.repository | |
248 | end |
|
254 | end | |
249 |
|
255 | |||
250 | def test_destroy_invalid_repository |
|
256 | def test_destroy_invalid_repository | |
251 | @request.session[:user_id] = 1 # admin |
|
257 | @request.session[:user_id] = 1 # admin | |
252 | assert_equal 0, @repository.changesets.count |
|
258 | assert_equal 0, @repository.changesets.count | |
253 | @repository.fetch_changesets |
|
259 | @repository.fetch_changesets | |
254 | @project.reload |
|
260 | @project.reload | |
255 | assert_equal NUM_REV, @repository.changesets.count |
|
261 | assert_equal NUM_REV, @repository.changesets.count | |
256 |
|
262 | |||
257 | get :destroy, :id => PRJ_ID |
|
263 | get :destroy, :id => PRJ_ID | |
258 | assert_response 302 |
|
264 | assert_response 302 | |
259 | @project.reload |
|
265 | @project.reload | |
260 | assert_nil @project.repository |
|
266 | assert_nil @project.repository | |
261 |
|
267 | |||
262 | @repository = Repository::Cvs.create( |
|
268 | @repository = Repository::Cvs.create( | |
263 | :project => Project.find(PRJ_ID), |
|
269 | :project => Project.find(PRJ_ID), | |
264 | :root_url => "/invalid", |
|
270 | :root_url => "/invalid", | |
265 | :url => MODULE_NAME, |
|
271 | :url => MODULE_NAME, | |
266 | :log_encoding => 'UTF-8' |
|
272 | :log_encoding => 'UTF-8' | |
267 | ) |
|
273 | ) | |
268 | assert @repository |
|
274 | assert @repository | |
269 | @repository.fetch_changesets |
|
275 | @repository.fetch_changesets | |
270 | @project.reload |
|
276 | @project.reload | |
271 | assert_equal 0, @repository.changesets.count |
|
277 | assert_equal 0, @repository.changesets.count | |
272 |
|
278 | |||
273 | get :destroy, :id => PRJ_ID |
|
279 | get :destroy, :id => PRJ_ID | |
274 | assert_response 302 |
|
280 | assert_response 302 | |
275 | @project.reload |
|
281 | @project.reload | |
276 | assert_nil @project.repository |
|
282 | assert_nil @project.repository | |
277 | end |
|
283 | end | |
278 | else |
|
284 | else | |
279 | puts "CVS test repository NOT FOUND. Skipping functional tests !!!" |
|
285 | puts "CVS test repository NOT FOUND. Skipping functional tests !!!" | |
280 | def test_fake; assert true end |
|
286 | def test_fake; assert true end | |
281 | end |
|
287 | end | |
282 | end |
|
288 | end |
@@ -1,164 +1,170 | |||||
1 | # Redmine - project management software |
|
1 | # Redmine - project management software | |
2 | # Copyright (C) 2006-2011 Jean-Philippe Lang |
|
2 | # Copyright (C) 2006-2011 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.expand_path('../../test_helper', __FILE__) |
|
18 | require File.expand_path('../../test_helper', __FILE__) | |
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 |
|
19 | |||
24 | class RepositoriesDarcsControllerTest < ActionController::TestCase |
|
20 | class RepositoriesDarcsControllerTest < ActionController::TestCase | |
|
21 | tests RepositoriesController | |||
|
22 | ||||
25 | fixtures :projects, :users, :roles, :members, :member_roles, |
|
23 | fixtures :projects, :users, :roles, :members, :member_roles, | |
26 | :repositories, :enabled_modules |
|
24 | :repositories, :enabled_modules | |
27 |
|
25 | |||
28 | REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s |
|
26 | REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s | |
29 | PRJ_ID = 3 |
|
27 | PRJ_ID = 3 | |
30 | NUM_REV = 6 |
|
28 | NUM_REV = 6 | |
31 |
|
29 | |||
32 | def setup |
|
30 | def setup | |
33 | @controller = RepositoriesController.new |
|
|||
34 | @request = ActionController::TestRequest.new |
|
|||
35 | @response = ActionController::TestResponse.new |
|
|||
36 | User.current = nil |
|
31 | User.current = nil | |
37 | @project = Project.find(PRJ_ID) |
|
32 | @project = Project.find(PRJ_ID) | |
38 | @repository = Repository::Darcs.create( |
|
33 | @repository = Repository::Darcs.create( | |
39 | :project => @project, |
|
34 | :project => @project, | |
40 | :url => REPOSITORY_PATH, |
|
35 | :url => REPOSITORY_PATH, | |
41 | :log_encoding => 'UTF-8' |
|
36 | :log_encoding => 'UTF-8' | |
42 | ) |
|
37 | ) | |
43 | assert @repository |
|
38 | assert @repository | |
44 | end |
|
39 | end | |
45 |
|
40 | |||
46 | if File.directory?(REPOSITORY_PATH) |
|
41 | if File.directory?(REPOSITORY_PATH) | |
|
42 | def test_get_edit | |||
|
43 | @request.session[:user_id] = 1 | |||
|
44 | @project.repository.destroy | |||
|
45 | xhr :get, :edit, :id => 'subproject1', :repository_scm => 'Darcs' | |||
|
46 | assert_response :success | |||
|
47 | assert_equal 'text/javascript', @response.content_type | |||
|
48 | assert_kind_of Repository::Darcs, assigns(:repository) | |||
|
49 | assert assigns(:repository).new_record? | |||
|
50 | assert_select_rjs :replace_html, 'tab-content-repository' | |||
|
51 | end | |||
|
52 | ||||
47 | def test_browse_root |
|
53 | def test_browse_root | |
48 | assert_equal 0, @repository.changesets.count |
|
54 | assert_equal 0, @repository.changesets.count | |
49 | @repository.fetch_changesets |
|
55 | @repository.fetch_changesets | |
50 | @project.reload |
|
56 | @project.reload | |
51 | assert_equal NUM_REV, @repository.changesets.count |
|
57 | assert_equal NUM_REV, @repository.changesets.count | |
52 | get :show, :id => PRJ_ID |
|
58 | get :show, :id => PRJ_ID | |
53 | assert_response :success |
|
59 | assert_response :success | |
54 | assert_template 'show' |
|
60 | assert_template 'show' | |
55 | assert_not_nil assigns(:entries) |
|
61 | assert_not_nil assigns(:entries) | |
56 | assert_equal 3, assigns(:entries).size |
|
62 | assert_equal 3, assigns(:entries).size | |
57 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} |
|
63 | assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'} | |
58 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} |
|
64 | assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'} | |
59 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} |
|
65 | assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'} | |
60 | end |
|
66 | end | |
61 |
|
67 | |||
62 | def test_browse_directory |
|
68 | def test_browse_directory | |
63 | assert_equal 0, @repository.changesets.count |
|
69 | assert_equal 0, @repository.changesets.count | |
64 | @repository.fetch_changesets |
|
70 | @repository.fetch_changesets | |
65 | @project.reload |
|
71 | @project.reload | |
66 | assert_equal NUM_REV, @repository.changesets.count |
|
72 | assert_equal NUM_REV, @repository.changesets.count | |
67 | get :show, :id => PRJ_ID, :path => ['images'] |
|
73 | get :show, :id => PRJ_ID, :path => ['images'] | |
68 | assert_response :success |
|
74 | assert_response :success | |
69 | assert_template 'show' |
|
75 | assert_template 'show' | |
70 | assert_not_nil assigns(:entries) |
|
76 | assert_not_nil assigns(:entries) | |
71 | assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) |
|
77 | assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name) | |
72 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} |
|
78 | entry = assigns(:entries).detect {|e| e.name == 'edit.png'} | |
73 | assert_not_nil entry |
|
79 | assert_not_nil entry | |
74 | assert_equal 'file', entry.kind |
|
80 | assert_equal 'file', entry.kind | |
75 | assert_equal 'images/edit.png', entry.path |
|
81 | assert_equal 'images/edit.png', entry.path | |
76 | end |
|
82 | end | |
77 |
|
83 | |||
78 | def test_browse_at_given_revision |
|
84 | def test_browse_at_given_revision | |
79 | assert_equal 0, @repository.changesets.count |
|
85 | assert_equal 0, @repository.changesets.count | |
80 | @repository.fetch_changesets |
|
86 | @repository.fetch_changesets | |
81 | @project.reload |
|
87 | @project.reload | |
82 | assert_equal NUM_REV, @repository.changesets.count |
|
88 | assert_equal NUM_REV, @repository.changesets.count | |
83 | get :show, :id => PRJ_ID, :path => ['images'], :rev => 1 |
|
89 | get :show, :id => PRJ_ID, :path => ['images'], :rev => 1 | |
84 | assert_response :success |
|
90 | assert_response :success | |
85 | assert_template 'show' |
|
91 | assert_template 'show' | |
86 | assert_not_nil assigns(:entries) |
|
92 | assert_not_nil assigns(:entries) | |
87 | assert_equal ['delete.png'], assigns(:entries).collect(&:name) |
|
93 | assert_equal ['delete.png'], assigns(:entries).collect(&:name) | |
88 | end |
|
94 | end | |
89 |
|
95 | |||
90 | def test_changes |
|
96 | def test_changes | |
91 | assert_equal 0, @repository.changesets.count |
|
97 | assert_equal 0, @repository.changesets.count | |
92 | @repository.fetch_changesets |
|
98 | @repository.fetch_changesets | |
93 | @project.reload |
|
99 | @project.reload | |
94 | assert_equal NUM_REV, @repository.changesets.count |
|
100 | assert_equal NUM_REV, @repository.changesets.count | |
95 | get :changes, :id => PRJ_ID, :path => ['images', 'edit.png'] |
|
101 | get :changes, :id => PRJ_ID, :path => ['images', 'edit.png'] | |
96 | assert_response :success |
|
102 | assert_response :success | |
97 | assert_template 'changes' |
|
103 | assert_template 'changes' | |
98 | assert_tag :tag => 'h2', :content => 'edit.png' |
|
104 | assert_tag :tag => 'h2', :content => 'edit.png' | |
99 | end |
|
105 | end | |
100 |
|
106 | |||
101 | def test_diff |
|
107 | def test_diff | |
102 | assert_equal 0, @repository.changesets.count |
|
108 | assert_equal 0, @repository.changesets.count | |
103 | @repository.fetch_changesets |
|
109 | @repository.fetch_changesets | |
104 | @project.reload |
|
110 | @project.reload | |
105 | assert_equal NUM_REV, @repository.changesets.count |
|
111 | assert_equal NUM_REV, @repository.changesets.count | |
106 | # Full diff of changeset 5 |
|
112 | # Full diff of changeset 5 | |
107 | ['inline', 'sbs'].each do |dt| |
|
113 | ['inline', 'sbs'].each do |dt| | |
108 | get :diff, :id => PRJ_ID, :rev => 5, :type => dt |
|
114 | get :diff, :id => PRJ_ID, :rev => 5, :type => dt | |
109 | assert_response :success |
|
115 | assert_response :success | |
110 | assert_template 'diff' |
|
116 | assert_template 'diff' | |
111 | # Line 22 removed |
|
117 | # Line 22 removed | |
112 | assert_tag :tag => 'th', |
|
118 | assert_tag :tag => 'th', | |
113 | :content => '22', |
|
119 | :content => '22', | |
114 | :sibling => { :tag => 'td', |
|
120 | :sibling => { :tag => 'td', | |
115 | :attributes => { :class => /diff_out/ }, |
|
121 | :attributes => { :class => /diff_out/ }, | |
116 | :content => /def remove/ } |
|
122 | :content => /def remove/ } | |
117 | end |
|
123 | end | |
118 | end |
|
124 | end | |
119 |
|
125 | |||
120 | def test_destroy_valid_repository |
|
126 | def test_destroy_valid_repository | |
121 | @request.session[:user_id] = 1 # admin |
|
127 | @request.session[:user_id] = 1 # admin | |
122 | assert_equal 0, @repository.changesets.count |
|
128 | assert_equal 0, @repository.changesets.count | |
123 | @repository.fetch_changesets |
|
129 | @repository.fetch_changesets | |
124 | @project.reload |
|
130 | @project.reload | |
125 | assert_equal NUM_REV, @repository.changesets.count |
|
131 | assert_equal NUM_REV, @repository.changesets.count | |
126 |
|
132 | |||
127 | get :destroy, :id => PRJ_ID |
|
133 | get :destroy, :id => PRJ_ID | |
128 | assert_response 302 |
|
134 | assert_response 302 | |
129 | @project.reload |
|
135 | @project.reload | |
130 | assert_nil @project.repository |
|
136 | assert_nil @project.repository | |
131 | end |
|
137 | end | |
132 |
|
138 | |||
133 | def test_destroy_invalid_repository |
|
139 | def test_destroy_invalid_repository | |
134 | @request.session[:user_id] = 1 # admin |
|
140 | @request.session[:user_id] = 1 # admin | |
135 | assert_equal 0, @repository.changesets.count |
|
141 | assert_equal 0, @repository.changesets.count | |
136 | @repository.fetch_changesets |
|
142 | @repository.fetch_changesets | |
137 | @project.reload |
|
143 | @project.reload | |
138 | assert_equal NUM_REV, @repository.changesets.count |
|
144 | assert_equal NUM_REV, @repository.changesets.count | |
139 |
|
145 | |||
140 | get :destroy, :id => PRJ_ID |
|
146 | get :destroy, :id => PRJ_ID | |
141 | assert_response 302 |
|
147 | assert_response 302 | |
142 | @project.reload |
|
148 | @project.reload | |
143 | assert_nil @project.repository |
|
149 | assert_nil @project.repository | |
144 |
|
150 | |||
145 | @repository = Repository::Darcs.create( |
|
151 | @repository = Repository::Darcs.create( | |
146 | :project => @project, |
|
152 | :project => @project, | |
147 | :url => "/invalid", |
|
153 | :url => "/invalid", | |
148 | :log_encoding => 'UTF-8' |
|
154 | :log_encoding => 'UTF-8' | |
149 | ) |
|
155 | ) | |
150 | assert @repository |
|
156 | assert @repository | |
151 | @repository.fetch_changesets |
|
157 | @repository.fetch_changesets | |
152 | @project.reload |
|
158 | @project.reload | |
153 | assert_equal 0, @repository.changesets.count |
|
159 | assert_equal 0, @repository.changesets.count | |
154 |
|
160 | |||
155 | get :destroy, :id => PRJ_ID |
|
161 | get :destroy, :id => PRJ_ID | |
156 | assert_response 302 |
|
162 | assert_response 302 | |
157 | @project.reload |
|
163 | @project.reload | |
158 | assert_nil @project.repository |
|
164 | assert_nil @project.repository | |
159 | end |
|
165 | end | |
160 | else |
|
166 | else | |
161 | puts "Darcs test repository NOT FOUND. Skipping functional tests !!!" |
|
167 | puts "Darcs test repository NOT FOUND. Skipping functional tests !!!" | |
162 | def test_fake; assert true end |
|
168 | def test_fake; assert true end | |
163 | end |
|
169 | end | |
164 | end |
|
170 | end |
General Comments 0
You need to be logged in to leave comments.
Login now