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