##// END OF EJS Templates
scm: cvs: change project id of functional test from 1 to 3....
Toshi MARUYAMA -
r4669:2b79e05e6c52
parent child
Show More
@@ -1,166 +1,187
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
2 # Copyright (C) 2006-2008 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'
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 RepositoriesCvsControllerTest < ActionController::TestCase
24 class RepositoriesCvsControllerTest < ActionController::TestCase
25 fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :enabled_modules
25 fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :enabled_modules
26
26
27 # No '..' in the repository path
27 # No '..' in the repository path
28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository'
28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository'
29 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
29 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
30 # CVS module
30 # CVS module
31 MODULE_NAME = 'test'
31 MODULE_NAME = 'test'
32
32 PRJ_ID = 3
33
33 def setup
34 def setup
34 @controller = RepositoriesController.new
35 @controller = RepositoriesController.new
35 @request = ActionController::TestRequest.new
36 @request = ActionController::TestRequest.new
36 @response = ActionController::TestResponse.new
37 @response = ActionController::TestResponse.new
37 Setting.default_language = 'en'
38 Setting.default_language = 'en'
38 User.current = nil
39 User.current = nil
39
40
40 @project = Project.find(1)
41 @project = Project.find(PRJ_ID)
41 @project.repository = Repository::Cvs.create(:root_url => REPOSITORY_PATH,
42 @repository = Repository::Cvs.create(:project => Project.find(PRJ_ID),
42 :url => MODULE_NAME)
43 :root_url => REPOSITORY_PATH,
44 :url => MODULE_NAME)
45 assert @repository
43 end
46 end
44
47
45 if File.directory?(REPOSITORY_PATH)
48 if File.directory?(REPOSITORY_PATH)
46 def test_show
49 def test_show
47 get :show, :id => 1
50 @repository.fetch_changesets
51 @repository.reload
52 get :show, :id => PRJ_ID
48 assert_response :success
53 assert_response :success
49 assert_template 'show'
54 assert_template 'show'
50 assert_not_nil assigns(:entries)
55 assert_not_nil assigns(:entries)
51 assert_not_nil assigns(:changesets)
56 assert_not_nil assigns(:changesets)
52 end
57 end
53
58
54 def test_browse_root
59 def test_browse_root
55 get :show, :id => 1
60 @repository.fetch_changesets
61 @repository.reload
62 get :show, :id => PRJ_ID
56 assert_response :success
63 assert_response :success
57 assert_template 'show'
64 assert_template 'show'
58 assert_not_nil assigns(:entries)
65 assert_not_nil assigns(:entries)
59 assert_equal 3, assigns(:entries).size
66 assert_equal 3, assigns(:entries).size
60
67
61 entry = assigns(:entries).detect {|e| e.name == 'images'}
68 entry = assigns(:entries).detect {|e| e.name == 'images'}
62 assert_equal 'dir', entry.kind
69 assert_equal 'dir', entry.kind
63
70
64 entry = assigns(:entries).detect {|e| e.name == 'README'}
71 entry = assigns(:entries).detect {|e| e.name == 'README'}
65 assert_equal 'file', entry.kind
72 assert_equal 'file', entry.kind
66 end
73 end
67
74
68 def test_browse_directory
75 def test_browse_directory
69 get :show, :id => 1, :path => ['images']
76 @repository.fetch_changesets
77 @repository.reload
78 get :show, :id => PRJ_ID, :path => ['images']
70 assert_response :success
79 assert_response :success
71 assert_template 'show'
80 assert_template 'show'
72 assert_not_nil assigns(:entries)
81 assert_not_nil assigns(:entries)
73 assert_equal ['add.png', 'delete.png', 'edit.png'], assigns(:entries).collect(&:name)
82 assert_equal ['add.png', 'delete.png', 'edit.png'], assigns(:entries).collect(&:name)
74 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
83 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
75 assert_not_nil entry
84 assert_not_nil entry
76 assert_equal 'file', entry.kind
85 assert_equal 'file', entry.kind
77 assert_equal 'images/edit.png', entry.path
86 assert_equal 'images/edit.png', entry.path
78 end
87 end
79
88
80 def test_browse_at_given_revision
89 def test_browse_at_given_revision
81 Project.find(1).repository.fetch_changesets
90 @repository.fetch_changesets
82 get :show, :id => 1, :path => ['images'], :rev => 1
91 @repository.reload
92 get :show, :id => PRJ_ID, :path => ['images'], :rev => 1
83 assert_response :success
93 assert_response :success
84 assert_template 'show'
94 assert_template 'show'
85 assert_not_nil assigns(:entries)
95 assert_not_nil assigns(:entries)
86 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
96 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
87 end
97 end
88
98
89 def test_entry
99 def test_entry
90 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb']
100 @repository.fetch_changesets
101 @repository.reload
102 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
91 assert_response :success
103 assert_response :success
92 assert_template 'entry'
104 assert_template 'entry'
93 assert_no_tag :tag => 'td', :attributes => { :class => /line-code/},
105 assert_no_tag :tag => 'td', :attributes => { :class => /line-code/},
94 :content => /before_filter/
106 :content => /before_filter/
95 end
107 end
96
108
97 def test_entry_at_given_revision
109 def test_entry_at_given_revision
98 # changesets must be loaded
110 # changesets must be loaded
99 Project.find(1).repository.fetch_changesets
111 @repository.fetch_changesets
100 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :rev => 2
112 @repository.reload
113 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :rev => 2
101 assert_response :success
114 assert_response :success
102 assert_template 'entry'
115 assert_template 'entry'
103 # this line was removed in r3
116 # this line was removed in r3
104 assert_tag :tag => 'td', :attributes => { :class => /line-code/},
117 assert_tag :tag => 'td', :attributes => { :class => /line-code/},
105 :content => /before_filter/
118 :content => /before_filter/
106 end
119 end
107
120
108 def test_entry_not_found
121 def test_entry_not_found
109 get :entry, :id => 1, :path => ['sources', 'zzz.c']
122 @repository.fetch_changesets
123 @repository.reload
124 get :entry, :id => PRJ_ID, :path => ['sources', 'zzz.c']
110 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
125 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
111 :content => /The entry or revision was not found in the repository/
126 :content => /The entry or revision was not found in the repository/
112 end
127 end
113
128
114 def test_entry_download
129 def test_entry_download
115 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
130 @repository.fetch_changesets
131 @repository.reload
132 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
116 assert_response :success
133 assert_response :success
117 end
134 end
118
135
119 def test_directory_entry
136 def test_directory_entry
120 get :entry, :id => 1, :path => ['sources']
137 @repository.fetch_changesets
138 @repository.reload
139 get :entry, :id => PRJ_ID, :path => ['sources']
121 assert_response :success
140 assert_response :success
122 assert_template 'show'
141 assert_template 'show'
123 assert_not_nil assigns(:entry)
142 assert_not_nil assigns(:entry)
124 assert_equal 'sources', assigns(:entry).name
143 assert_equal 'sources', assigns(:entry).name
125 end
144 end
126
145
127 def test_diff
146 def test_diff
128 Project.find(1).repository.fetch_changesets
147 @repository.fetch_changesets
129 get :diff, :id => 1, :rev => 3, :type => 'inline'
148 @repository.reload
149 get :diff, :id => PRJ_ID, :rev => 3, :type => 'inline'
130 assert_response :success
150 assert_response :success
131 assert_template 'diff'
151 assert_template 'diff'
132 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' },
152 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' },
133 :content => /watched.remove_watcher/
153 :content => /watched.remove_watcher/
134 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' },
154 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' },
135 :content => /watched.remove_all_watcher/
155 :content => /watched.remove_all_watcher/
136 end
156 end
137
157
138 def test_annotate
158 def test_annotate
139 Project.find(1).repository.fetch_changesets
159 @repository.fetch_changesets
140 get :annotate, :id => 1, :path => ['sources', 'watchers_controller.rb']
160 @repository.reload
161 get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
141 assert_response :success
162 assert_response :success
142 assert_template 'annotate'
163 assert_template 'annotate'
143 # 1.1 line
164 # 1.1 line
144 assert_tag :tag => 'th', :attributes => { :class => 'line-num' },
165 assert_tag :tag => 'th', :attributes => { :class => 'line-num' },
145 :content => '18',
166 :content => '18',
146 :sibling => { :tag => 'td', :attributes => { :class => 'revision' },
167 :sibling => { :tag => 'td', :attributes => { :class => 'revision' },
147 :content => /1.1/,
168 :content => /1.1/,
148 :sibling => { :tag => 'td', :attributes => { :class => 'author' },
169 :sibling => { :tag => 'td', :attributes => { :class => 'author' },
149 :content => /LANG/
170 :content => /LANG/
150 }
171 }
151 }
172 }
152 # 1.2 line
173 # 1.2 line
153 assert_tag :tag => 'th', :attributes => { :class => 'line-num' },
174 assert_tag :tag => 'th', :attributes => { :class => 'line-num' },
154 :content => '32',
175 :content => '32',
155 :sibling => { :tag => 'td', :attributes => { :class => 'revision' },
176 :sibling => { :tag => 'td', :attributes => { :class => 'revision' },
156 :content => /1.2/,
177 :content => /1.2/,
157 :sibling => { :tag => 'td', :attributes => { :class => 'author' },
178 :sibling => { :tag => 'td', :attributes => { :class => 'author' },
158 :content => /LANG/
179 :content => /LANG/
159 }
180 }
160 }
181 }
161 end
182 end
162 else
183 else
163 puts "CVS test repository NOT FOUND. Skipping functional tests !!!"
184 puts "CVS test repository NOT FOUND. Skipping functional tests !!!"
164 def test_fake; assert true end
185 def test_fake; assert true end
165 end
186 end
166 end
187 end
General Comments 0
You need to be logged in to leave comments. Login now