##// END OF EJS Templates
scm: bazaar: fix functional annotate test....
Toshi MARUYAMA -
r5791:d4d75401b3a2
parent child
Show More
@@ -1,145 +1,158
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2011 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 RepositoriesBazaarControllerTest < ActionController::TestCase
25 25 fixtures :projects, :users, :roles, :members, :member_roles,
26 26 :repositories, :enabled_modules
27 27
28 28 # No '..' in the repository path
29 29 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/bazaar_repository'
30 30 PRJ_ID = 3
31 31
32 32 def setup
33 33 @controller = RepositoriesController.new
34 34 @request = ActionController::TestRequest.new
35 35 @response = ActionController::TestResponse.new
36 36 User.current = nil
37 37 @project = Project.find(PRJ_ID)
38 38 @repository = Repository::Bazaar.create(
39 39 :project => @project,
40 40 :url => REPOSITORY_PATH,
41 41 :log_encoding => 'UTF-8')
42 42 assert @repository
43 43 end
44 44
45 45 if File.directory?(REPOSITORY_PATH)
46 46 def test_show
47 47 get :show, :id => PRJ_ID
48 48 assert_response :success
49 49 assert_template 'show'
50 50 assert_not_nil assigns(:entries)
51 51 assert_not_nil assigns(:changesets)
52 52 end
53 53
54 54 def test_browse_root
55 55 get :show, :id => PRJ_ID
56 56 assert_response :success
57 57 assert_template 'show'
58 58 assert_not_nil assigns(:entries)
59 59 assert_equal 2, assigns(:entries).size
60 60 assert assigns(:entries).detect {|e| e.name == 'directory' && e.kind == 'dir'}
61 61 assert assigns(:entries).detect {|e| e.name == 'doc-mkdir.txt' && e.kind == 'file'}
62 62 end
63 63
64 64 def test_browse_directory
65 65 get :show, :id => PRJ_ID, :path => ['directory']
66 66 assert_response :success
67 67 assert_template 'show'
68 68 assert_not_nil assigns(:entries)
69 69 assert_equal ['doc-ls.txt', 'document.txt', 'edit.png'], assigns(:entries).collect(&:name)
70 70 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
71 71 assert_not_nil entry
72 72 assert_equal 'file', entry.kind
73 73 assert_equal 'directory/edit.png', entry.path
74 74 end
75 75
76 76 def test_browse_at_given_revision
77 77 get :show, :id => PRJ_ID, :path => [], :rev => 3
78 78 assert_response :success
79 79 assert_template 'show'
80 80 assert_not_nil assigns(:entries)
81 81 assert_equal ['directory', 'doc-deleted.txt', 'doc-ls.txt', 'doc-mkdir.txt'],
82 82 assigns(:entries).collect(&:name)
83 83 end
84 84
85 85 def test_changes
86 86 get :changes, :id => PRJ_ID, :path => ['doc-mkdir.txt']
87 87 assert_response :success
88 88 assert_template 'changes'
89 89 assert_tag :tag => 'h2', :content => 'doc-mkdir.txt'
90 90 end
91 91
92 92 def test_entry_show
93 93 get :entry, :id => PRJ_ID, :path => ['directory', 'doc-ls.txt']
94 94 assert_response :success
95 95 assert_template 'entry'
96 96 # Line 19
97 97 assert_tag :tag => 'th',
98 98 :content => /29/,
99 99 :attributes => { :class => /line-num/ },
100 100 :sibling => { :tag => 'td', :content => /Show help message/ }
101 101 end
102 102
103 103 def test_entry_download
104 104 get :entry, :id => PRJ_ID, :path => ['directory', 'doc-ls.txt'], :format => 'raw'
105 105 assert_response :success
106 106 # File content
107 107 assert @response.body.include?('Show help message')
108 108 end
109 109
110 110 def test_directory_entry
111 111 get :entry, :id => PRJ_ID, :path => ['directory']
112 112 assert_response :success
113 113 assert_template 'show'
114 114 assert_not_nil assigns(:entry)
115 115 assert_equal 'directory', assigns(:entry).name
116 116 end
117 117
118 118 def test_diff
119 119 # Full diff of changeset 3
120 120 get :diff, :id => PRJ_ID, :rev => 3
121 121 assert_response :success
122 122 assert_template 'diff'
123 123 # Line 11 removed
124 124 assert_tag :tag => 'th',
125 125 :content => /11/,
126 126 :sibling => { :tag => 'td',
127 127 :attributes => { :class => /diff_out/ },
128 128 :content => /Display more information/ }
129 129 end
130 130
131 131 def test_annotate
132 132 get :annotate, :id => PRJ_ID, :path => ['doc-mkdir.txt']
133 133 assert_response :success
134 134 assert_template 'annotate'
135 # Line 2, revision 3
136 assert_tag :tag => 'th', :content => /2/,
137 :sibling => { :tag => 'td', :child => { :tag => 'a', :content => /3/ } },
138 :sibling => { :tag => 'td', :content => /jsmith/ },
135 assert_tag :tag => 'th', :content => '2',
136 :sibling => {
137 :tag => 'td',
138 :child => {
139 :tag => 'a',
140 :content => /3/
141 }
142 },
143 :sibling => { :tag => 'td', :content => /jsmith/ }
144 assert_tag :tag => 'th', :content => '2',
145 :sibling => {
146 :tag => 'td',
147 :child => {
148 :tag => 'a',
149 :content => /3/
150 }
151 },
139 152 :sibling => { :tag => 'td', :content => /Main purpose/ }
140 153 end
141 154 else
142 155 puts "Bazaar test repository NOT FOUND. Skipping functional tests !!!"
143 156 def test_fake; assert true end
144 157 end
145 158 end
General Comments 0
You need to be logged in to leave comments. Login now