##// 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 1 # redMine - project management software
2 2 # Copyright (C) 2006-2008 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../test_helper', __FILE__)
19 19 require 'repositories_controller'
20 20
21 21 # Re-raise errors caught by the controller.
22 22 class RepositoriesController; def rescue_action(e) raise e end; end
23 23
24 24 class RepositoriesCvsControllerTest < ActionController::TestCase
25 25 fixtures :projects, :users, :roles, :members, :member_roles, :repositories, :enabled_modules
26 26
27 27 # No '..' in the repository path
28 28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository'
29 29 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
30 30 # CVS module
31 31 MODULE_NAME = 'test'
32
32 PRJ_ID = 3
33
33 34 def setup
34 35 @controller = RepositoriesController.new
35 36 @request = ActionController::TestRequest.new
36 37 @response = ActionController::TestResponse.new
37 38 Setting.default_language = 'en'
38 39 User.current = nil
39 40
40 @project = Project.find(1)
41 @project.repository = Repository::Cvs.create(:root_url => REPOSITORY_PATH,
42 :url => MODULE_NAME)
41 @project = Project.find(PRJ_ID)
42 @repository = Repository::Cvs.create(:project => Project.find(PRJ_ID),
43 :root_url => REPOSITORY_PATH,
44 :url => MODULE_NAME)
45 assert @repository
43 46 end
44 47
45 48 if File.directory?(REPOSITORY_PATH)
46 49 def test_show
47 get :show, :id => 1
50 @repository.fetch_changesets
51 @repository.reload
52 get :show, :id => PRJ_ID
48 53 assert_response :success
49 54 assert_template 'show'
50 55 assert_not_nil assigns(:entries)
51 56 assert_not_nil assigns(:changesets)
52 57 end
53 58
54 59 def test_browse_root
55 get :show, :id => 1
60 @repository.fetch_changesets
61 @repository.reload
62 get :show, :id => PRJ_ID
56 63 assert_response :success
57 64 assert_template 'show'
58 65 assert_not_nil assigns(:entries)
59 66 assert_equal 3, assigns(:entries).size
60 67
61 68 entry = assigns(:entries).detect {|e| e.name == 'images'}
62 69 assert_equal 'dir', entry.kind
63 70
64 71 entry = assigns(:entries).detect {|e| e.name == 'README'}
65 72 assert_equal 'file', entry.kind
66 73 end
67 74
68 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 79 assert_response :success
71 80 assert_template 'show'
72 81 assert_not_nil assigns(:entries)
73 82 assert_equal ['add.png', 'delete.png', 'edit.png'], assigns(:entries).collect(&:name)
74 83 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
75 84 assert_not_nil entry
76 85 assert_equal 'file', entry.kind
77 86 assert_equal 'images/edit.png', entry.path
78 87 end
79 88
80 89 def test_browse_at_given_revision
81 Project.find(1).repository.fetch_changesets
82 get :show, :id => 1, :path => ['images'], :rev => 1
90 @repository.fetch_changesets
91 @repository.reload
92 get :show, :id => PRJ_ID, :path => ['images'], :rev => 1
83 93 assert_response :success
84 94 assert_template 'show'
85 95 assert_not_nil assigns(:entries)
86 96 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
87 97 end
88 98
89 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 103 assert_response :success
92 104 assert_template 'entry'
93 105 assert_no_tag :tag => 'td', :attributes => { :class => /line-code/},
94 106 :content => /before_filter/
95 107 end
96 108
97 109 def test_entry_at_given_revision
98 110 # changesets must be loaded
99 Project.find(1).repository.fetch_changesets
100 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :rev => 2
111 @repository.fetch_changesets
112 @repository.reload
113 get :entry, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb'], :rev => 2
101 114 assert_response :success
102 115 assert_template 'entry'
103 116 # this line was removed in r3
104 117 assert_tag :tag => 'td', :attributes => { :class => /line-code/},
105 118 :content => /before_filter/
106 119 end
107 120
108 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 125 assert_tag :tag => 'p', :attributes => { :id => /errorExplanation/ },
111 126 :content => /The entry or revision was not found in the repository/
112 127 end
113 128
114 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 133 assert_response :success
117 134 end
118 135
119 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 140 assert_response :success
122 141 assert_template 'show'
123 142 assert_not_nil assigns(:entry)
124 143 assert_equal 'sources', assigns(:entry).name
125 144 end
126 145
127 146 def test_diff
128 Project.find(1).repository.fetch_changesets
129 get :diff, :id => 1, :rev => 3, :type => 'inline'
147 @repository.fetch_changesets
148 @repository.reload
149 get :diff, :id => PRJ_ID, :rev => 3, :type => 'inline'
130 150 assert_response :success
131 151 assert_template 'diff'
132 152 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' },
133 153 :content => /watched.remove_watcher/
134 154 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' },
135 155 :content => /watched.remove_all_watcher/
136 156 end
137 157
138 158 def test_annotate
139 Project.find(1).repository.fetch_changesets
140 get :annotate, :id => 1, :path => ['sources', 'watchers_controller.rb']
159 @repository.fetch_changesets
160 @repository.reload
161 get :annotate, :id => PRJ_ID, :path => ['sources', 'watchers_controller.rb']
141 162 assert_response :success
142 163 assert_template 'annotate'
143 164 # 1.1 line
144 165 assert_tag :tag => 'th', :attributes => { :class => 'line-num' },
145 166 :content => '18',
146 167 :sibling => { :tag => 'td', :attributes => { :class => 'revision' },
147 168 :content => /1.1/,
148 169 :sibling => { :tag => 'td', :attributes => { :class => 'author' },
149 170 :content => /LANG/
150 171 }
151 172 }
152 173 # 1.2 line
153 174 assert_tag :tag => 'th', :attributes => { :class => 'line-num' },
154 175 :content => '32',
155 176 :sibling => { :tag => 'td', :attributes => { :class => 'revision' },
156 177 :content => /1.2/,
157 178 :sibling => { :tag => 'td', :attributes => { :class => 'author' },
158 179 :content => /LANG/
159 180 }
160 181 }
161 182 end
162 183 else
163 184 puts "CVS test repository NOT FOUND. Skipping functional tests !!!"
164 185 def test_fake; assert true end
165 186 end
166 187 end
General Comments 0
You need to be logged in to leave comments. Login now