##// END OF EJS Templates
scm: darcs: define NUM_REV as the number of test repository revisions at functional test...
Toshi MARUYAMA -
r7027:9114df75de35
parent child
Show More
@@ -1,151 +1,152
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 RepositoriesDarcsControllerTest < ActionController::TestCase
25 25 fixtures :projects, :users, :roles, :members, :member_roles,
26 26 :repositories, :enabled_modules
27 27
28 28 REPOSITORY_PATH = Rails.root.join('tmp/test/darcs_repository').to_s
29 29 PRJ_ID = 3
30 NUM_REV = 6
30 31
31 32 def setup
32 33 @controller = RepositoriesController.new
33 34 @request = ActionController::TestRequest.new
34 35 @response = ActionController::TestResponse.new
35 36 User.current = nil
36 37 @project = Project.find(PRJ_ID)
37 38 @repository = Repository::Darcs.create(
38 39 :project => @project,
39 40 :url => REPOSITORY_PATH,
40 41 :log_encoding => 'UTF-8'
41 42 )
42 43 assert @repository
43 44 end
44 45
45 46 if File.directory?(REPOSITORY_PATH)
46 47 def test_browse_root
47 48 @repository.fetch_changesets
48 49 @repository.reload
49 50 get :show, :id => PRJ_ID
50 51 assert_response :success
51 52 assert_template 'show'
52 53 assert_not_nil assigns(:entries)
53 54 assert_equal 3, assigns(:entries).size
54 55 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
55 56 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
56 57 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
57 58 end
58 59
59 60 def test_browse_directory
60 61 @repository.fetch_changesets
61 62 @repository.reload
62 63 get :show, :id => PRJ_ID, :path => ['images']
63 64 assert_response :success
64 65 assert_template 'show'
65 66 assert_not_nil assigns(:entries)
66 67 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
67 68 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
68 69 assert_not_nil entry
69 70 assert_equal 'file', entry.kind
70 71 assert_equal 'images/edit.png', entry.path
71 72 end
72 73
73 74 def test_browse_at_given_revision
74 75 @repository.fetch_changesets
75 76 @repository.reload
76 77 get :show, :id => PRJ_ID, :path => ['images'], :rev => 1
77 78 assert_response :success
78 79 assert_template 'show'
79 80 assert_not_nil assigns(:entries)
80 81 assert_equal ['delete.png'], assigns(:entries).collect(&:name)
81 82 end
82 83
83 84 def test_changes
84 85 @repository.fetch_changesets
85 86 @repository.reload
86 87 get :changes, :id => PRJ_ID, :path => ['images', 'edit.png']
87 88 assert_response :success
88 89 assert_template 'changes'
89 90 assert_tag :tag => 'h2', :content => 'edit.png'
90 91 end
91 92
92 93 def test_diff
93 94 @repository.fetch_changesets
94 95 @repository.reload
95 96 # Full diff of changeset 5
96 97 ['inline', 'sbs'].each do |dt|
97 98 get :diff, :id => PRJ_ID, :rev => 5, :type => dt
98 99 assert_response :success
99 100 assert_template 'diff'
100 101 # Line 22 removed
101 102 assert_tag :tag => 'th',
102 103 :content => '22',
103 104 :sibling => { :tag => 'td',
104 105 :attributes => { :class => /diff_out/ },
105 106 :content => /def remove/ }
106 107 end
107 108 end
108 109
109 110 def test_destroy_valid_repository
110 111 @request.session[:user_id] = 1 # admin
111 112 @repository.fetch_changesets
112 113 @repository.reload
113 114 assert @repository.changesets.count > 0
114 115
115 116 get :destroy, :id => PRJ_ID
116 117 assert_response 302
117 118 @project.reload
118 119 assert_nil @project.repository
119 120 end
120 121
121 122 def test_destroy_invalid_repository
122 123 @request.session[:user_id] = 1 # admin
123 124 @repository.fetch_changesets
124 125 @repository.reload
125 126 assert @repository.changesets.count > 0
126 127
127 128 get :destroy, :id => PRJ_ID
128 129 assert_response 302
129 130 @project.reload
130 131 assert_nil @project.repository
131 132
132 133 @repository = Repository::Darcs.create(
133 134 :project => @project,
134 135 :url => "/invalid",
135 136 :log_encoding => 'UTF-8'
136 137 )
137 138 assert @repository
138 139 @repository.fetch_changesets
139 140 @repository.reload
140 141 assert_equal 0, @repository.changesets.count
141 142
142 143 get :destroy, :id => PRJ_ID
143 144 assert_response 302
144 145 @project.reload
145 146 assert_nil @project.repository
146 147 end
147 148 else
148 149 puts "Darcs test repository NOT FOUND. Skipping functional tests !!!"
149 150 def test_fake; assert true end
150 151 end
151 152 end
General Comments 0
You need to be logged in to leave comments. Login now