##// END OF EJS Templates
scm: bazaar: split REPOSITORY_PATH to trunk in functional test (#14931)...
Toshi MARUYAMA -
r11916:23c56501de37
parent child
Show More
@@ -1,187 +1,188
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2013 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
20 20 class RepositoriesBazaarControllerTest < ActionController::TestCase
21 21 tests RepositoriesController
22 22
23 23 fixtures :projects, :users, :roles, :members, :member_roles,
24 24 :repositories, :enabled_modules
25 25
26 REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository/trunk').to_s
26 REPOSITORY_PATH = Rails.root.join('tmp/test/bazaar_repository').to_s
27 REPOSITORY_PATH_TRUNK = File.join(REPOSITORY_PATH, "trunk")
27 28 PRJ_ID = 3
28 29
29 30 def setup
30 31 User.current = nil
31 32 @project = Project.find(PRJ_ID)
32 33 @repository = Repository::Bazaar.create(
33 34 :project => @project,
34 :url => REPOSITORY_PATH,
35 :url => REPOSITORY_PATH_TRUNK,
35 36 :log_encoding => 'UTF-8')
36 37 assert @repository
37 38 end
38 39
39 40 if File.directory?(REPOSITORY_PATH)
40 41 def test_get_new
41 42 @request.session[:user_id] = 1
42 43 @project.repository.destroy
43 44 get :new, :project_id => 'subproject1', :repository_scm => 'Bazaar'
44 45 assert_response :success
45 46 assert_template 'new'
46 47 assert_kind_of Repository::Bazaar, assigns(:repository)
47 48 assert assigns(:repository).new_record?
48 49 end
49 50
50 51 def test_browse_root
51 52 get :show, :id => PRJ_ID
52 53 assert_response :success
53 54 assert_template 'show'
54 55 assert_not_nil assigns(:entries)
55 56 assert_equal 2, assigns(:entries).size
56 57 assert assigns(:entries).detect {|e| e.name == 'directory' && e.kind == 'dir'}
57 58 assert assigns(:entries).detect {|e| e.name == 'doc-mkdir.txt' && e.kind == 'file'}
58 59 end
59 60
60 61 def test_browse_directory
61 62 get :show, :id => PRJ_ID, :path => repository_path_hash(['directory'])[:param]
62 63 assert_response :success
63 64 assert_template 'show'
64 65 assert_not_nil assigns(:entries)
65 66 assert_equal ['doc-ls.txt', 'document.txt', 'edit.png'], assigns(:entries).collect(&:name)
66 67 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
67 68 assert_not_nil entry
68 69 assert_equal 'file', entry.kind
69 70 assert_equal 'directory/edit.png', entry.path
70 71 end
71 72
72 73 def test_browse_at_given_revision
73 74 get :show, :id => PRJ_ID, :path => repository_path_hash([])[:param],
74 75 :rev => 3
75 76 assert_response :success
76 77 assert_template 'show'
77 78 assert_not_nil assigns(:entries)
78 79 assert_equal ['directory', 'doc-deleted.txt', 'doc-ls.txt', 'doc-mkdir.txt'],
79 80 assigns(:entries).collect(&:name)
80 81 end
81 82
82 83 def test_changes
83 84 get :changes, :id => PRJ_ID,
84 85 :path => repository_path_hash(['doc-mkdir.txt'])[:param]
85 86 assert_response :success
86 87 assert_template 'changes'
87 88 assert_tag :tag => 'h2', :content => 'doc-mkdir.txt'
88 89 end
89 90
90 91 def test_entry_show
91 92 get :entry, :id => PRJ_ID,
92 93 :path => repository_path_hash(['directory', 'doc-ls.txt'])[:param]
93 94 assert_response :success
94 95 assert_template 'entry'
95 96 # Line 19
96 97 assert_tag :tag => 'th',
97 98 :content => /29/,
98 99 :attributes => { :class => /line-num/ },
99 100 :sibling => { :tag => 'td', :content => /Show help message/ }
100 101 end
101 102
102 103 def test_entry_download
103 104 get :entry, :id => PRJ_ID,
104 105 :path => repository_path_hash(['directory', 'doc-ls.txt'])[:param],
105 106 :format => 'raw'
106 107 assert_response :success
107 108 # File content
108 109 assert @response.body.include?('Show help message')
109 110 end
110 111
111 112 def test_directory_entry
112 113 get :entry, :id => PRJ_ID,
113 114 :path => repository_path_hash(['directory'])[:param]
114 115 assert_response :success
115 116 assert_template 'show'
116 117 assert_not_nil assigns(:entry)
117 118 assert_equal 'directory', assigns(:entry).name
118 119 end
119 120
120 121 def test_diff
121 122 # Full diff of changeset 3
122 123 ['inline', 'sbs'].each do |dt|
123 124 get :diff, :id => PRJ_ID, :rev => 3, :type => dt
124 125 assert_response :success
125 126 assert_template 'diff'
126 127 # Line 11 removed
127 128 assert_tag :tag => 'th',
128 129 :content => '11',
129 130 :sibling => { :tag => 'td',
130 131 :attributes => { :class => /diff_out/ },
131 132 :content => /Display more information/ }
132 133 end
133 134 end
134 135
135 136 def test_annotate
136 137 get :annotate, :id => PRJ_ID,
137 138 :path => repository_path_hash(['doc-mkdir.txt'])[:param]
138 139 assert_response :success
139 140 assert_template 'annotate'
140 141 assert_select "th.line-num", :text => '2' do
141 142 assert_select "+ td.revision" do
142 143 assert_select "a", :text => '3'
143 144 assert_select "+ td.author", :text => "jsmith@" do
144 145 assert_select "+ td",
145 146 :text => "Main purpose:"
146 147 end
147 148 end
148 149 end
149 150 end
150 151
151 152 def test_destroy_valid_repository
152 153 @request.session[:user_id] = 1 # admin
153 154 assert_equal 0, @repository.changesets.count
154 155 @repository.fetch_changesets
155 156 assert @repository.changesets.count > 0
156 157
157 158 assert_difference 'Repository.count', -1 do
158 159 delete :destroy, :id => @repository.id
159 160 end
160 161 assert_response 302
161 162 @project.reload
162 163 assert_nil @project.repository
163 164 end
164 165
165 166 def test_destroy_invalid_repository
166 167 @request.session[:user_id] = 1 # admin
167 168 @project.repository.destroy
168 169 @repository = Repository::Bazaar.create!(
169 170 :project => @project,
170 171 :url => "/invalid",
171 172 :log_encoding => 'UTF-8')
172 173 @repository.fetch_changesets
173 174 @repository.reload
174 175 assert_equal 0, @repository.changesets.count
175 176
176 177 assert_difference 'Repository.count', -1 do
177 178 delete :destroy, :id => @repository.id
178 179 end
179 180 assert_response 302
180 181 @project.reload
181 182 assert_nil @project.repository
182 183 end
183 184 else
184 185 puts "Bazaar test repository NOT FOUND. Skipping functional tests !!!"
185 186 def test_fake; assert true end
186 187 end
187 188 end
General Comments 0
You need to be logged in to leave comments. Login now