##// END OF EJS Templates
Do not run Mercurial functional tests if the test repository is not set up....
Jean-Philippe Lang -
r1006:3d5381b24bb4
parent child
Show More
@@ -1,117 +1,122
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 RepositoriesMercurialControllerTest < Test::Unit::TestCase
24 class RepositoriesMercurialControllerTest < Test::Unit::TestCase
25 fixtures :projects, :users, :roles, :members, :repositories, :enabled_modules
25 fixtures :projects, :users, :roles, :members, :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/mercurial_repository'
28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/mercurial_repository'
29
29
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::Mercurial.create(:project => Project.find(3), :url => REPOSITORY_PATH)
36 end
36 end
37
37
38 if File.directory?(REPOSITORY_PATH)
38 def test_show
39 def test_show
39 get :show, :id => 3
40 get :show, :id => 3
40 assert_response :success
41 assert_response :success
41 assert_template 'show'
42 assert_template 'show'
42 assert_not_nil assigns(:entries)
43 assert_not_nil assigns(:entries)
43 assert_not_nil assigns(:changesets)
44 assert_not_nil assigns(:changesets)
44 end
45 end
45
46
46 def test_browse_root
47 def test_browse_root
47 get :browse, :id => 3
48 get :browse, :id => 3
48 assert_response :success
49 assert_response :success
49 assert_template 'browse'
50 assert_template 'browse'
50 assert_not_nil assigns(:entries)
51 assert_not_nil assigns(:entries)
51 assert_equal 3, assigns(:entries).size
52 assert_equal 3, assigns(:entries).size
52 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
53 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
53 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
54 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
54 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
55 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
55 end
56 end
56
57
57 def test_browse_directory
58 def test_browse_directory
58 get :browse, :id => 3, :path => ['images']
59 get :browse, :id => 3, :path => ['images']
59 assert_response :success
60 assert_response :success
60 assert_template 'browse'
61 assert_template 'browse'
61 assert_not_nil assigns(:entries)
62 assert_not_nil assigns(:entries)
62 assert_equal 2, assigns(:entries).size
63 assert_equal 2, assigns(:entries).size
63 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
64 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
64 assert_not_nil entry
65 assert_not_nil entry
65 assert_equal 'file', entry.kind
66 assert_equal 'file', entry.kind
66 assert_equal 'images/edit.png', entry.path
67 assert_equal 'images/edit.png', entry.path
67 end
68 end
68
69
69 def test_changes
70 def test_changes
70 get :changes, :id => 3, :path => ['images', 'edit.png']
71 get :changes, :id => 3, :path => ['images', 'edit.png']
71 assert_response :success
72 assert_response :success
72 assert_template 'changes'
73 assert_template 'changes'
73 assert_tag :tag => 'h2', :content => 'edit.png'
74 assert_tag :tag => 'h2', :content => 'edit.png'
74 end
75 end
75
76
76 def test_entry_show
77 def test_entry_show
77 get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb']
78 get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb']
78 assert_response :success
79 assert_response :success
79 assert_template 'entry'
80 assert_template 'entry'
80 # Line 19
81 # Line 19
81 assert_tag :tag => 'th',
82 assert_tag :tag => 'th',
82 :content => /10/,
83 :content => /10/,
83 :attributes => { :class => /line-num/ },
84 :attributes => { :class => /line-num/ },
84 :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
85 :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
85 end
86 end
86
87
87 def test_entry_download
88 def test_entry_download
88 get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
89 get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
89 assert_response :success
90 assert_response :success
90 # File content
91 # File content
91 assert @response.body.include?('WITHOUT ANY WARRANTY')
92 assert @response.body.include?('WITHOUT ANY WARRANTY')
92 end
93 end
93
94
94 def test_diff
95 def test_diff
95 # Full diff of changeset 4
96 # Full diff of changeset 4
96 get :diff, :id => 3, :rev => 4
97 get :diff, :id => 3, :rev => 4
97 assert_response :success
98 assert_response :success
98 assert_template 'diff'
99 assert_template 'diff'
99 # Line 22 removed
100 # Line 22 removed
100 assert_tag :tag => 'th',
101 assert_tag :tag => 'th',
101 :content => /22/,
102 :content => /22/,
102 :sibling => { :tag => 'td',
103 :sibling => { :tag => 'td',
103 :attributes => { :class => /diff_out/ },
104 :attributes => { :class => /diff_out/ },
104 :content => /def remove/ }
105 :content => /def remove/ }
105 end
106 end
106
107
107 def test_annotate
108 def test_annotate
108 get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb']
109 get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb']
109 assert_response :success
110 assert_response :success
110 assert_template 'annotate'
111 assert_template 'annotate'
111 # Line 23, revision 4
112 # Line 23, revision 4
112 assert_tag :tag => 'th', :content => /23/,
113 assert_tag :tag => 'th', :content => /23/,
113 :sibling => { :tag => 'td', :child => { :tag => 'a', :content => /4/ } },
114 :sibling => { :tag => 'td', :child => { :tag => 'a', :content => /4/ } },
114 :sibling => { :tag => 'td', :content => /jsmith/ },
115 :sibling => { :tag => 'td', :content => /jsmith/ },
115 :sibling => { :tag => 'td', :content => /watcher =/ }
116 :sibling => { :tag => 'td', :content => /watcher =/ }
116 end
117 end
118 else
119 puts "Mercurial test repository NOT FOUND. Skipping functional tests !!!"
120 def test_fake; assert true end
121 end
117 end
122 end
General Comments 0
You need to be logged in to leave comments. Login now