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