comparison test/functional/.svn/text-base/repositories_mercurial_controller_test.rb.svn-base @ 120:cd2282d2aa55 cannam

Merge from the default branch. Note that this is not a valid SVN repository any more (use default, redmine-1.1 etc for SVN updates).
author Chris Cannam
date Thu, 13 Jan 2011 14:33:08 +0000
parents af80e5618e9b 8661b858af72
children 5e974759e8b2
comparison
equal deleted inserted replaced
118:b859cc0c4fa1 120:cd2282d2aa55
30 def setup 30 def setup
31 @controller = RepositoriesController.new 31 @controller = RepositoriesController.new
32 @request = ActionController::TestRequest.new 32 @request = ActionController::TestRequest.new
33 @response = ActionController::TestResponse.new 33 @response = ActionController::TestResponse.new
34 User.current = nil 34 User.current = nil
35 Repository::Mercurial.create(:project => Project.find(3), :url => REPOSITORY_PATH) 35 @repository = Repository::Mercurial.create(:project => Project.find(3), :url => REPOSITORY_PATH)
36 assert @repository
36 end 37 end
37 38
38 if File.directory?(REPOSITORY_PATH) 39 if File.directory?(REPOSITORY_PATH)
39 def test_show 40 def test_show
40 get :show, :id => 3 41 get :show, :id => 3
41 assert_response :success 42 assert_response :success
42 assert_template 'show' 43 assert_template 'show'
64 entry = assigns(:entries).detect {|e| e.name == 'edit.png'} 65 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
65 assert_not_nil entry 66 assert_not_nil entry
66 assert_equal 'file', entry.kind 67 assert_equal 'file', entry.kind
67 assert_equal 'images/edit.png', entry.path 68 assert_equal 'images/edit.png', entry.path
68 end 69 end
69 70
70 def test_show_at_given_revision 71 def test_show_at_given_revision
71 get :show, :id => 3, :path => ['images'], :rev => 0 72 [0, '0', '0885933ad4f6'].each do |r1|
72 assert_response :success 73 get :show, :id => 3, :path => ['images'], :rev => r1
73 assert_template 'show' 74 assert_response :success
74 assert_not_nil assigns(:entries) 75 assert_template 'show'
75 assert_equal ['delete.png'], assigns(:entries).collect(&:name) 76 assert_not_nil assigns(:entries)
77 assert_equal ['delete.png'], assigns(:entries).collect(&:name)
78 end
76 end 79 end
77 80
78 def test_show_directory_sql_escape_percent 81 def test_show_directory_sql_escape_percent
79 get :show, :id => 3, :path => ['sql_escape', 'percent%dir'], :rev => 13 82 [13, '13', '3a330eb32958'].each do |r1|
80 assert_response :success 83 get :show, :id => 3, :path => ['sql_escape', 'percent%dir'], :rev => r1
81 assert_template 'show' 84 assert_response :success
82 85 assert_template 'show'
83 assert_not_nil assigns(:entries) 86
84 assert_equal ['percent%file1.txt', 'percentfile1.txt'], assigns(:entries).collect(&:name) 87 assert_not_nil assigns(:entries)
85 changesets = assigns(:changesets) 88 assert_equal ['percent%file1.txt', 'percentfile1.txt'], assigns(:entries).collect(&:name)
86 89 changesets = assigns(:changesets)
87 ## This is not yet implemented. 90
88 # assert_not_nil changesets 91 ## This is not yet implemented.
89 # assert_equal %w(13 11 10 9), changesets.collect(&:revision) 92 # assert_not_nil changesets
93 # assert_equal %w(13 11 10 9), changesets.collect(&:revision)
94 end
90 end 95 end
91 96
92 def test_changes 97 def test_changes
93 get :changes, :id => 3, :path => ['images', 'edit.png'] 98 get :changes, :id => 3, :path => ['images', 'edit.png']
94 assert_response :success 99 assert_response :success
121 assert_not_nil assigns(:entry) 126 assert_not_nil assigns(:entry)
122 assert_equal 'sources', assigns(:entry).name 127 assert_equal 'sources', assigns(:entry).name
123 end 128 end
124 129
125 def test_diff 130 def test_diff
126 # Full diff of changeset 4 131 @repository.fetch_changesets
127 get :diff, :id => 3, :rev => 4 132 @repository.reload
128 assert_response :success 133
129 assert_template 'diff' 134 [4, '4', 'def6d2f1254a'].each do |r1|
130 # Line 22 removed 135 # Full diff of changeset 4
131 assert_tag :tag => 'th', 136 get :diff, :id => 3, :rev => 4
132 :content => '22', 137 assert_response :success
133 :sibling => { :tag => 'td', 138 assert_template 'diff'
134 :attributes => { :class => /diff_out/ }, 139
135 :content => /def remove/ } 140 if @repository.scm.class.client_version_above?([1, 2])
136 end 141 # Line 22 removed
137 142 assert_tag :tag => 'th',
143 :content => '22',
144 :sibling => { :tag => 'td',
145 :attributes => { :class => /diff_out/ },
146 :content => /def remove/ }
147 assert_tag :tag => 'h2', :content => /4:def6d2f1254a/
148 end
149 end
150 end
151
152 def test_diff_two_revs
153 @repository.fetch_changesets
154 @repository.reload
155
156 [2, '400bb8672109', '400', 400].each do |r1|
157 [4, 'def6d2f1254a'].each do |r2|
158 get :diff, :id => 3, :rev => r1,
159 :rev_to => r2
160 assert_response :success
161 assert_template 'diff'
162
163 diff = assigns(:diff)
164 assert_not_nil diff
165 assert_tag :tag => 'h2', :content => /4:def6d2f1254a 2:400bb8672109/
166 end
167 end
168 end
169
138 def test_annotate 170 def test_annotate
139 get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb'] 171 get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb']
140 assert_response :success 172 assert_response :success
141 assert_template 'annotate' 173 assert_template 'annotate'
142 # Line 23, revision 4:def6d2f1254a 174 # Line 23, revision 4:def6d2f1254a
145 :attributes => { :class => 'line-num' }, 177 :attributes => { :class => 'line-num' },
146 :sibling => 178 :sibling =>
147 { 179 {
148 :tag => 'td', 180 :tag => 'td',
149 :attributes => { :class => 'revision' }, 181 :attributes => { :class => 'revision' },
150 :child => { :tag => 'a', :content => '4' } 182 :child => { :tag => 'a', :content => '4:def6d2f1254a' }
151 # :child => { :tag => 'a', :content => /4:def6d2f1/ }
152 } 183 }
153 assert_tag :tag => 'th', 184 assert_tag :tag => 'th',
154 :content => '23', 185 :content => '23',
155 :attributes => { :class => 'line-num' }, 186 :attributes => { :class => 'line-num' },
156 :sibling => 187 :sibling =>
162 assert_tag :tag => 'th', 193 assert_tag :tag => 'th',
163 :content => '23', 194 :content => '23',
164 :attributes => { :class => 'line-num' }, 195 :attributes => { :class => 'line-num' },
165 :sibling => { :tag => 'td', :content => /watcher =/ } 196 :sibling => { :tag => 'td', :content => /watcher =/ }
166 end 197 end
198
199 def test_empty_revision
200 @repository.fetch_changesets
201 @repository.reload
202 ['', ' ', nil].each do |r|
203 get :revision, :id => 1, :rev => r
204 assert_response 500
205 assert_error_tag :content => /was not found/
206 end
207 end
167 else 208 else
168 puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!" 209 puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!"
169 def test_fake; assert true end 210 def test_fake; assert true end
170 end 211 end
171 end 212 end