##// END OF EJS Templates
Fixes platform determination under JRuby (#1804)....
Jean-Philippe Lang -
r1752:116091a1d2ea
parent child
Show More
@@ -0,0 +1,26
1 # Redmine - project management software
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
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
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 module Redmine
19 module Platform
20 class << self
21 def mswin?
22 (RUBY_PLATFORM =~ /(:?mswin|mingw)/) || (RUBY_PLATFORM == 'java' && (ENV['OS'] || ENV['os']) =~ /windows/i)
23 end
24 end
25 end
26 end
@@ -1,296 +1,296
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 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 'cgi'
18 require 'cgi'
19
19
20 module Redmine
20 module Redmine
21 module Scm
21 module Scm
22 module Adapters
22 module Adapters
23 class CommandFailed < StandardError #:nodoc:
23 class CommandFailed < StandardError #:nodoc:
24 end
24 end
25
25
26 class AbstractAdapter #:nodoc:
26 class AbstractAdapter #:nodoc:
27 class << self
27 class << self
28 # Returns the version of the scm client
28 # Returns the version of the scm client
29 # Eg: [1, 5, 0] or [] if unknown
29 # Eg: [1, 5, 0] or [] if unknown
30 def client_version
30 def client_version
31 []
31 []
32 end
32 end
33
33
34 # Returns the version string of the scm client
34 # Returns the version string of the scm client
35 # Eg: '1.5.0' or 'Unknown version' if unknown
35 # Eg: '1.5.0' or 'Unknown version' if unknown
36 def client_version_string
36 def client_version_string
37 v = client_version || 'Unknown version'
37 v = client_version || 'Unknown version'
38 v.is_a?(Array) ? v.join('.') : v.to_s
38 v.is_a?(Array) ? v.join('.') : v.to_s
39 end
39 end
40
40
41 # Returns true if the current client version is above
41 # Returns true if the current client version is above
42 # or equals the given one
42 # or equals the given one
43 # If option is :unknown is set to true, it will return
43 # If option is :unknown is set to true, it will return
44 # true if the client version is unknown
44 # true if the client version is unknown
45 def client_version_above?(v, options={})
45 def client_version_above?(v, options={})
46 ((client_version <=> v) >= 0) || (client_version.empty? && options[:unknown])
46 ((client_version <=> v) >= 0) || (client_version.empty? && options[:unknown])
47 end
47 end
48 end
48 end
49
49
50 def initialize(url, root_url=nil, login=nil, password=nil)
50 def initialize(url, root_url=nil, login=nil, password=nil)
51 @url = url
51 @url = url
52 @login = login if login && !login.empty?
52 @login = login if login && !login.empty?
53 @password = (password || "") if @login
53 @password = (password || "") if @login
54 @root_url = root_url.blank? ? retrieve_root_url : root_url
54 @root_url = root_url.blank? ? retrieve_root_url : root_url
55 end
55 end
56
56
57 def adapter_name
57 def adapter_name
58 'Abstract'
58 'Abstract'
59 end
59 end
60
60
61 def supports_cat?
61 def supports_cat?
62 true
62 true
63 end
63 end
64
64
65 def supports_annotate?
65 def supports_annotate?
66 respond_to?('annotate')
66 respond_to?('annotate')
67 end
67 end
68
68
69 def root_url
69 def root_url
70 @root_url
70 @root_url
71 end
71 end
72
72
73 def url
73 def url
74 @url
74 @url
75 end
75 end
76
76
77 # get info about the svn repository
77 # get info about the svn repository
78 def info
78 def info
79 return nil
79 return nil
80 end
80 end
81
81
82 # Returns the entry identified by path and revision identifier
82 # Returns the entry identified by path and revision identifier
83 # or nil if entry doesn't exist in the repository
83 # or nil if entry doesn't exist in the repository
84 def entry(path=nil, identifier=nil)
84 def entry(path=nil, identifier=nil)
85 parts = path.to_s.split(%r{[\/\\]}).select {|n| !n.blank?}
85 parts = path.to_s.split(%r{[\/\\]}).select {|n| !n.blank?}
86 search_path = parts[0..-2].join('/')
86 search_path = parts[0..-2].join('/')
87 search_name = parts[-1]
87 search_name = parts[-1]
88 if search_path.blank? && search_name.blank?
88 if search_path.blank? && search_name.blank?
89 # Root entry
89 # Root entry
90 Entry.new(:path => '', :kind => 'dir')
90 Entry.new(:path => '', :kind => 'dir')
91 else
91 else
92 # Search for the entry in the parent directory
92 # Search for the entry in the parent directory
93 es = entries(search_path, identifier)
93 es = entries(search_path, identifier)
94 es ? es.detect {|e| e.name == search_name} : nil
94 es ? es.detect {|e| e.name == search_name} : nil
95 end
95 end
96 end
96 end
97
97
98 # Returns an Entries collection
98 # Returns an Entries collection
99 # or nil if the given path doesn't exist in the repository
99 # or nil if the given path doesn't exist in the repository
100 def entries(path=nil, identifier=nil)
100 def entries(path=nil, identifier=nil)
101 return nil
101 return nil
102 end
102 end
103
103
104 def properties(path, identifier=nil)
104 def properties(path, identifier=nil)
105 return nil
105 return nil
106 end
106 end
107
107
108 def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
108 def revisions(path=nil, identifier_from=nil, identifier_to=nil, options={})
109 return nil
109 return nil
110 end
110 end
111
111
112 def diff(path, identifier_from, identifier_to=nil)
112 def diff(path, identifier_from, identifier_to=nil)
113 return nil
113 return nil
114 end
114 end
115
115
116 def cat(path, identifier=nil)
116 def cat(path, identifier=nil)
117 return nil
117 return nil
118 end
118 end
119
119
120 def with_leading_slash(path)
120 def with_leading_slash(path)
121 path ||= ''
121 path ||= ''
122 (path[0,1]!="/") ? "/#{path}" : path
122 (path[0,1]!="/") ? "/#{path}" : path
123 end
123 end
124
124
125 def with_trailling_slash(path)
125 def with_trailling_slash(path)
126 path ||= ''
126 path ||= ''
127 (path[-1,1] == "/") ? path : "#{path}/"
127 (path[-1,1] == "/") ? path : "#{path}/"
128 end
128 end
129
129
130 def without_leading_slash(path)
130 def without_leading_slash(path)
131 path ||= ''
131 path ||= ''
132 path.gsub(%r{^/+}, '')
132 path.gsub(%r{^/+}, '')
133 end
133 end
134
134
135 def without_trailling_slash(path)
135 def without_trailling_slash(path)
136 path ||= ''
136 path ||= ''
137 (path[-1,1] == "/") ? path[0..-2] : path
137 (path[-1,1] == "/") ? path[0..-2] : path
138 end
138 end
139
139
140 def shell_quote(str)
140 def shell_quote(str)
141 if RUBY_PLATFORM =~ /mswin/
141 if Redmine::Platform.mswin?
142 '"' + str.gsub(/"/, '\\"') + '"'
142 '"' + str.gsub(/"/, '\\"') + '"'
143 else
143 else
144 "'" + str.gsub(/'/, "'\"'\"'") + "'"
144 "'" + str.gsub(/'/, "'\"'\"'") + "'"
145 end
145 end
146 end
146 end
147
147
148 private
148 private
149 def retrieve_root_url
149 def retrieve_root_url
150 info = self.info
150 info = self.info
151 info ? info.root_url : nil
151 info ? info.root_url : nil
152 end
152 end
153
153
154 def target(path)
154 def target(path)
155 path ||= ''
155 path ||= ''
156 base = path.match(/^\//) ? root_url : url
156 base = path.match(/^\//) ? root_url : url
157 shell_quote("#{base}/#{path}".gsub(/[?<>\*]/, ''))
157 shell_quote("#{base}/#{path}".gsub(/[?<>\*]/, ''))
158 end
158 end
159
159
160 def logger
160 def logger
161 self.class.logger
161 self.class.logger
162 end
162 end
163
163
164 def shellout(cmd, &block)
164 def shellout(cmd, &block)
165 self.class.shellout(cmd, &block)
165 self.class.shellout(cmd, &block)
166 end
166 end
167
167
168 def self.logger
168 def self.logger
169 RAILS_DEFAULT_LOGGER
169 RAILS_DEFAULT_LOGGER
170 end
170 end
171
171
172 def self.shellout(cmd, &block)
172 def self.shellout(cmd, &block)
173 logger.debug "Shelling out: #{cmd}" if logger && logger.debug?
173 logger.debug "Shelling out: #{cmd}" if logger && logger.debug?
174 begin
174 begin
175 IO.popen(cmd, "r+") do |io|
175 IO.popen(cmd, "r+") do |io|
176 io.close_write
176 io.close_write
177 block.call(io) if block_given?
177 block.call(io) if block_given?
178 end
178 end
179 rescue Errno::ENOENT => e
179 rescue Errno::ENOENT => e
180 msg = strip_credential(e.message)
180 msg = strip_credential(e.message)
181 # The command failed, log it and re-raise
181 # The command failed, log it and re-raise
182 logger.error("SCM command failed: #{strip_credential(cmd)}\n with: #{msg}")
182 logger.error("SCM command failed: #{strip_credential(cmd)}\n with: #{msg}")
183 raise CommandFailed.new(msg)
183 raise CommandFailed.new(msg)
184 end
184 end
185 end
185 end
186
186
187 # Hides username/password in a given command
187 # Hides username/password in a given command
188 def self.hide_credential(cmd)
188 def self.hide_credential(cmd)
189 q = (RUBY_PLATFORM =~ /mswin/ ? '"' : "'")
189 q = (Redmine::Platform.mswin? ? '"' : "'")
190 cmd.to_s.gsub(/(\-\-(password|username))\s+(#{q}[^#{q}]+#{q}|[^#{q}]\S+)/, '\\1 xxxx')
190 cmd.to_s.gsub(/(\-\-(password|username))\s+(#{q}[^#{q}]+#{q}|[^#{q}]\S+)/, '\\1 xxxx')
191 end
191 end
192
192
193 def strip_credential(cmd)
193 def strip_credential(cmd)
194 self.class.hide_credential(cmd)
194 self.class.hide_credential(cmd)
195 end
195 end
196 end
196 end
197
197
198 class Entries < Array
198 class Entries < Array
199 def sort_by_name
199 def sort_by_name
200 sort {|x,y|
200 sort {|x,y|
201 if x.kind == y.kind
201 if x.kind == y.kind
202 x.name <=> y.name
202 x.name <=> y.name
203 else
203 else
204 x.kind <=> y.kind
204 x.kind <=> y.kind
205 end
205 end
206 }
206 }
207 end
207 end
208
208
209 def revisions
209 def revisions
210 revisions ||= Revisions.new(collect{|entry| entry.lastrev}.compact)
210 revisions ||= Revisions.new(collect{|entry| entry.lastrev}.compact)
211 end
211 end
212 end
212 end
213
213
214 class Info
214 class Info
215 attr_accessor :root_url, :lastrev
215 attr_accessor :root_url, :lastrev
216 def initialize(attributes={})
216 def initialize(attributes={})
217 self.root_url = attributes[:root_url] if attributes[:root_url]
217 self.root_url = attributes[:root_url] if attributes[:root_url]
218 self.lastrev = attributes[:lastrev]
218 self.lastrev = attributes[:lastrev]
219 end
219 end
220 end
220 end
221
221
222 class Entry
222 class Entry
223 attr_accessor :name, :path, :kind, :size, :lastrev
223 attr_accessor :name, :path, :kind, :size, :lastrev
224 def initialize(attributes={})
224 def initialize(attributes={})
225 self.name = attributes[:name] if attributes[:name]
225 self.name = attributes[:name] if attributes[:name]
226 self.path = attributes[:path] if attributes[:path]
226 self.path = attributes[:path] if attributes[:path]
227 self.kind = attributes[:kind] if attributes[:kind]
227 self.kind = attributes[:kind] if attributes[:kind]
228 self.size = attributes[:size].to_i if attributes[:size]
228 self.size = attributes[:size].to_i if attributes[:size]
229 self.lastrev = attributes[:lastrev]
229 self.lastrev = attributes[:lastrev]
230 end
230 end
231
231
232 def is_file?
232 def is_file?
233 'file' == self.kind
233 'file' == self.kind
234 end
234 end
235
235
236 def is_dir?
236 def is_dir?
237 'dir' == self.kind
237 'dir' == self.kind
238 end
238 end
239
239
240 def is_text?
240 def is_text?
241 Redmine::MimeType.is_type?('text', name)
241 Redmine::MimeType.is_type?('text', name)
242 end
242 end
243 end
243 end
244
244
245 class Revisions < Array
245 class Revisions < Array
246 def latest
246 def latest
247 sort {|x,y|
247 sort {|x,y|
248 unless x.time.nil? or y.time.nil?
248 unless x.time.nil? or y.time.nil?
249 x.time <=> y.time
249 x.time <=> y.time
250 else
250 else
251 0
251 0
252 end
252 end
253 }.last
253 }.last
254 end
254 end
255 end
255 end
256
256
257 class Revision
257 class Revision
258 attr_accessor :identifier, :scmid, :name, :author, :time, :message, :paths, :revision, :branch
258 attr_accessor :identifier, :scmid, :name, :author, :time, :message, :paths, :revision, :branch
259 def initialize(attributes={})
259 def initialize(attributes={})
260 self.identifier = attributes[:identifier]
260 self.identifier = attributes[:identifier]
261 self.scmid = attributes[:scmid]
261 self.scmid = attributes[:scmid]
262 self.name = attributes[:name] || self.identifier
262 self.name = attributes[:name] || self.identifier
263 self.author = attributes[:author]
263 self.author = attributes[:author]
264 self.time = attributes[:time]
264 self.time = attributes[:time]
265 self.message = attributes[:message] || ""
265 self.message = attributes[:message] || ""
266 self.paths = attributes[:paths]
266 self.paths = attributes[:paths]
267 self.revision = attributes[:revision]
267 self.revision = attributes[:revision]
268 self.branch = attributes[:branch]
268 self.branch = attributes[:branch]
269 end
269 end
270
270
271 end
271 end
272
272
273 class Annotate
273 class Annotate
274 attr_reader :lines, :revisions
274 attr_reader :lines, :revisions
275
275
276 def initialize
276 def initialize
277 @lines = []
277 @lines = []
278 @revisions = []
278 @revisions = []
279 end
279 end
280
280
281 def add_line(line, revision)
281 def add_line(line, revision)
282 @lines << line
282 @lines << line
283 @revisions << revision
283 @revisions << revision
284 end
284 end
285
285
286 def content
286 def content
287 content = lines.join("\n")
287 content = lines.join("\n")
288 end
288 end
289
289
290 def empty?
290 def empty?
291 lines.empty?
291 lines.empty?
292 end
292 end
293 end
293 end
294 end
294 end
295 end
295 end
296 end
296 end
@@ -1,165 +1,165
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
2 # Copyright (C) 2006-2008 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.dirname(__FILE__) + '/../test_helper'
18 require File.dirname(__FILE__) + '/../test_helper'
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 RepositoriesCvsControllerTest < Test::Unit::TestCase
24 class RepositoriesCvsControllerTest < Test::Unit::TestCase
25
25
26 # No '..' in the repository path
26 # No '..' in the repository path
27 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository'
27 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository'
28 REPOSITORY_PATH.gsub!(/\//, "\\") if RUBY_PLATFORM =~ /mswin/
28 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
29 # CVS module
29 # CVS module
30 MODULE_NAME = 'test'
30 MODULE_NAME = 'test'
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 Setting.default_language = 'en'
36 Setting.default_language = 'en'
37 User.current = nil
37 User.current = nil
38
38
39 @project = Project.find(1)
39 @project = Project.find(1)
40 @project.repository = Repository::Cvs.create(:root_url => REPOSITORY_PATH,
40 @project.repository = Repository::Cvs.create(:root_url => REPOSITORY_PATH,
41 :url => MODULE_NAME)
41 :url => MODULE_NAME)
42 end
42 end
43
43
44 if File.directory?(REPOSITORY_PATH)
44 if File.directory?(REPOSITORY_PATH)
45 def test_show
45 def test_show
46 get :show, :id => 1
46 get :show, :id => 1
47 assert_response :success
47 assert_response :success
48 assert_template 'show'
48 assert_template 'show'
49 assert_not_nil assigns(:entries)
49 assert_not_nil assigns(:entries)
50 assert_not_nil assigns(:changesets)
50 assert_not_nil assigns(:changesets)
51 end
51 end
52
52
53 def test_browse_root
53 def test_browse_root
54 get :browse, :id => 1
54 get :browse, :id => 1
55 assert_response :success
55 assert_response :success
56 assert_template 'browse'
56 assert_template 'browse'
57 assert_not_nil assigns(:entries)
57 assert_not_nil assigns(:entries)
58 assert_equal 3, assigns(:entries).size
58 assert_equal 3, assigns(:entries).size
59
59
60 entry = assigns(:entries).detect {|e| e.name == 'images'}
60 entry = assigns(:entries).detect {|e| e.name == 'images'}
61 assert_equal 'dir', entry.kind
61 assert_equal 'dir', entry.kind
62
62
63 entry = assigns(:entries).detect {|e| e.name == 'README'}
63 entry = assigns(:entries).detect {|e| e.name == 'README'}
64 assert_equal 'file', entry.kind
64 assert_equal 'file', entry.kind
65 end
65 end
66
66
67 def test_browse_directory
67 def test_browse_directory
68 get :browse, :id => 1, :path => ['images']
68 get :browse, :id => 1, :path => ['images']
69 assert_response :success
69 assert_response :success
70 assert_template 'browse'
70 assert_template 'browse'
71 assert_not_nil assigns(:entries)
71 assert_not_nil assigns(:entries)
72 assert_equal ['add.png', 'delete.png', 'edit.png'], assigns(:entries).collect(&:name)
72 assert_equal ['add.png', 'delete.png', 'edit.png'], assigns(:entries).collect(&:name)
73 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
73 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
74 assert_not_nil entry
74 assert_not_nil entry
75 assert_equal 'file', entry.kind
75 assert_equal 'file', entry.kind
76 assert_equal 'images/edit.png', entry.path
76 assert_equal 'images/edit.png', entry.path
77 end
77 end
78
78
79 def test_browse_at_given_revision
79 def test_browse_at_given_revision
80 Project.find(1).repository.fetch_changesets
80 Project.find(1).repository.fetch_changesets
81 get :browse, :id => 1, :path => ['images'], :rev => 1
81 get :browse, :id => 1, :path => ['images'], :rev => 1
82 assert_response :success
82 assert_response :success
83 assert_template 'browse'
83 assert_template 'browse'
84 assert_not_nil assigns(:entries)
84 assert_not_nil assigns(:entries)
85 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
85 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
86 end
86 end
87
87
88 def test_entry
88 def test_entry
89 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb']
89 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb']
90 assert_response :success
90 assert_response :success
91 assert_template 'entry'
91 assert_template 'entry'
92 assert_no_tag :tag => 'td', :attributes => { :class => /line-code/},
92 assert_no_tag :tag => 'td', :attributes => { :class => /line-code/},
93 :content => /before_filter/
93 :content => /before_filter/
94 end
94 end
95
95
96 def test_entry_at_given_revision
96 def test_entry_at_given_revision
97 # changesets must be loaded
97 # changesets must be loaded
98 Project.find(1).repository.fetch_changesets
98 Project.find(1).repository.fetch_changesets
99 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :rev => 2
99 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :rev => 2
100 assert_response :success
100 assert_response :success
101 assert_template 'entry'
101 assert_template 'entry'
102 # this line was removed in r3
102 # this line was removed in r3
103 assert_tag :tag => 'td', :attributes => { :class => /line-code/},
103 assert_tag :tag => 'td', :attributes => { :class => /line-code/},
104 :content => /before_filter/
104 :content => /before_filter/
105 end
105 end
106
106
107 def test_entry_not_found
107 def test_entry_not_found
108 get :entry, :id => 1, :path => ['sources', 'zzz.c']
108 get :entry, :id => 1, :path => ['sources', 'zzz.c']
109 assert_tag :tag => 'div', :attributes => { :class => /error/ },
109 assert_tag :tag => 'div', :attributes => { :class => /error/ },
110 :content => /The entry or revision was not found in the repository/
110 :content => /The entry or revision was not found in the repository/
111 end
111 end
112
112
113 def test_entry_download
113 def test_entry_download
114 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
114 get :entry, :id => 1, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
115 assert_response :success
115 assert_response :success
116 end
116 end
117
117
118 def test_directory_entry
118 def test_directory_entry
119 get :entry, :id => 1, :path => ['sources']
119 get :entry, :id => 1, :path => ['sources']
120 assert_response :success
120 assert_response :success
121 assert_template 'browse'
121 assert_template 'browse'
122 assert_not_nil assigns(:entry)
122 assert_not_nil assigns(:entry)
123 assert_equal 'sources', assigns(:entry).name
123 assert_equal 'sources', assigns(:entry).name
124 end
124 end
125
125
126 def test_diff
126 def test_diff
127 Project.find(1).repository.fetch_changesets
127 Project.find(1).repository.fetch_changesets
128 get :diff, :id => 1, :rev => 3, :type => 'inline'
128 get :diff, :id => 1, :rev => 3, :type => 'inline'
129 assert_response :success
129 assert_response :success
130 assert_template 'diff'
130 assert_template 'diff'
131 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' },
131 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_out' },
132 :content => /watched.remove_watcher/
132 :content => /watched.remove_watcher/
133 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' },
133 assert_tag :tag => 'td', :attributes => { :class => 'line-code diff_in' },
134 :content => /watched.remove_all_watcher/
134 :content => /watched.remove_all_watcher/
135 end
135 end
136
136
137 def test_annotate
137 def test_annotate
138 Project.find(1).repository.fetch_changesets
138 Project.find(1).repository.fetch_changesets
139 get :annotate, :id => 1, :path => ['sources', 'watchers_controller.rb']
139 get :annotate, :id => 1, :path => ['sources', 'watchers_controller.rb']
140 assert_response :success
140 assert_response :success
141 assert_template 'annotate'
141 assert_template 'annotate'
142 # 1.1 line
142 # 1.1 line
143 assert_tag :tag => 'th', :attributes => { :class => 'line-num' },
143 assert_tag :tag => 'th', :attributes => { :class => 'line-num' },
144 :content => '18',
144 :content => '18',
145 :sibling => { :tag => 'td', :attributes => { :class => 'revision' },
145 :sibling => { :tag => 'td', :attributes => { :class => 'revision' },
146 :content => /1.1/,
146 :content => /1.1/,
147 :sibling => { :tag => 'td', :attributes => { :class => 'author' },
147 :sibling => { :tag => 'td', :attributes => { :class => 'author' },
148 :content => /LANG/
148 :content => /LANG/
149 }
149 }
150 }
150 }
151 # 1.2 line
151 # 1.2 line
152 assert_tag :tag => 'th', :attributes => { :class => 'line-num' },
152 assert_tag :tag => 'th', :attributes => { :class => 'line-num' },
153 :content => '32',
153 :content => '32',
154 :sibling => { :tag => 'td', :attributes => { :class => 'revision' },
154 :sibling => { :tag => 'td', :attributes => { :class => 'revision' },
155 :content => /1.2/,
155 :content => /1.2/,
156 :sibling => { :tag => 'td', :attributes => { :class => 'author' },
156 :sibling => { :tag => 'td', :attributes => { :class => 'author' },
157 :content => /LANG/
157 :content => /LANG/
158 }
158 }
159 }
159 }
160 end
160 end
161 else
161 else
162 puts "CVS test repository NOT FOUND. Skipping functional tests !!!"
162 puts "CVS test repository NOT FOUND. Skipping functional tests !!!"
163 def test_fake; assert true end
163 def test_fake; assert true end
164 end
164 end
165 end
165 end
@@ -1,146 +1,146
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2008 Jean-Philippe Lang
2 # Copyright (C) 2006-2008 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.dirname(__FILE__) + '/../test_helper'
18 require File.dirname(__FILE__) + '/../test_helper'
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 RepositoriesGitControllerTest < Test::Unit::TestCase
24 class RepositoriesGitControllerTest < Test::Unit::TestCase
25 fixtures :projects, :users, :roles, :members, :repositories, :enabled_modules
25 fixtures :projects, :users, :roles, :members, :repositories, :enabled_modules
26
26
27 # No '..' in the repository path
27 # No '..' in the repository path
28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
28 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
29 REPOSITORY_PATH.gsub!(/\//, "\\") if RUBY_PLATFORM =~ /mswin/
29 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
30
30
31 def setup
31 def setup
32 @controller = RepositoriesController.new
32 @controller = RepositoriesController.new
33 @request = ActionController::TestRequest.new
33 @request = ActionController::TestRequest.new
34 @response = ActionController::TestResponse.new
34 @response = ActionController::TestResponse.new
35 User.current = nil
35 User.current = nil
36 Repository::Git.create(:project => Project.find(3), :url => REPOSITORY_PATH)
36 Repository::Git.create(:project => Project.find(3), :url => REPOSITORY_PATH)
37 end
37 end
38
38
39 if File.directory?(REPOSITORY_PATH)
39 if File.directory?(REPOSITORY_PATH)
40 def test_show
40 def test_show
41 get :show, :id => 3
41 get :show, :id => 3
42 assert_response :success
42 assert_response :success
43 assert_template 'show'
43 assert_template 'show'
44 assert_not_nil assigns(:entries)
44 assert_not_nil assigns(:entries)
45 assert_not_nil assigns(:changesets)
45 assert_not_nil assigns(:changesets)
46 end
46 end
47
47
48 def test_browse_root
48 def test_browse_root
49 get :browse, :id => 3
49 get :browse, :id => 3
50 assert_response :success
50 assert_response :success
51 assert_template 'browse'
51 assert_template 'browse'
52 assert_not_nil assigns(:entries)
52 assert_not_nil assigns(:entries)
53 assert_equal 3, assigns(:entries).size
53 assert_equal 3, assigns(:entries).size
54 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
54 assert assigns(:entries).detect {|e| e.name == 'images' && e.kind == 'dir'}
55 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
55 assert assigns(:entries).detect {|e| e.name == 'sources' && e.kind == 'dir'}
56 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
56 assert assigns(:entries).detect {|e| e.name == 'README' && e.kind == 'file'}
57 end
57 end
58
58
59 def test_browse_directory
59 def test_browse_directory
60 get :browse, :id => 3, :path => ['images']
60 get :browse, :id => 3, :path => ['images']
61 assert_response :success
61 assert_response :success
62 assert_template 'browse'
62 assert_template 'browse'
63 assert_not_nil assigns(:entries)
63 assert_not_nil assigns(:entries)
64 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
64 assert_equal ['delete.png', 'edit.png'], assigns(:entries).collect(&:name)
65 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
65 entry = assigns(:entries).detect {|e| e.name == 'edit.png'}
66 assert_not_nil entry
66 assert_not_nil entry
67 assert_equal 'file', entry.kind
67 assert_equal 'file', entry.kind
68 assert_equal 'images/edit.png', entry.path
68 assert_equal 'images/edit.png', entry.path
69 end
69 end
70
70
71 def test_browse_at_given_revision
71 def test_browse_at_given_revision
72 get :browse, :id => 3, :path => ['images'], :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518'
72 get :browse, :id => 3, :path => ['images'], :rev => '7234cb2750b63f47bff735edc50a1c0a433c2518'
73 assert_response :success
73 assert_response :success
74 assert_template 'browse'
74 assert_template 'browse'
75 assert_not_nil assigns(:entries)
75 assert_not_nil assigns(:entries)
76 assert_equal ['delete.png'], assigns(:entries).collect(&:name)
76 assert_equal ['delete.png'], assigns(:entries).collect(&:name)
77 end
77 end
78
78
79 def test_changes
79 def test_changes
80 get :changes, :id => 3, :path => ['images', 'edit.png']
80 get :changes, :id => 3, :path => ['images', 'edit.png']
81 assert_response :success
81 assert_response :success
82 assert_template 'changes'
82 assert_template 'changes'
83 assert_tag :tag => 'h2', :content => 'edit.png'
83 assert_tag :tag => 'h2', :content => 'edit.png'
84 end
84 end
85
85
86 def test_entry_show
86 def test_entry_show
87 get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb']
87 get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb']
88 assert_response :success
88 assert_response :success
89 assert_template 'entry'
89 assert_template 'entry'
90 # Line 19
90 # Line 19
91 assert_tag :tag => 'th',
91 assert_tag :tag => 'th',
92 :content => /10/,
92 :content => /10/,
93 :attributes => { :class => /line-num/ },
93 :attributes => { :class => /line-num/ },
94 :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
94 :sibling => { :tag => 'td', :content => /WITHOUT ANY WARRANTY/ }
95 end
95 end
96
96
97 def test_entry_download
97 def test_entry_download
98 get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
98 get :entry, :id => 3, :path => ['sources', 'watchers_controller.rb'], :format => 'raw'
99 assert_response :success
99 assert_response :success
100 # File content
100 # File content
101 assert @response.body.include?('WITHOUT ANY WARRANTY')
101 assert @response.body.include?('WITHOUT ANY WARRANTY')
102 end
102 end
103
103
104 def test_directory_entry
104 def test_directory_entry
105 get :entry, :id => 3, :path => ['sources']
105 get :entry, :id => 3, :path => ['sources']
106 assert_response :success
106 assert_response :success
107 assert_template 'browse'
107 assert_template 'browse'
108 assert_not_nil assigns(:entry)
108 assert_not_nil assigns(:entry)
109 assert_equal 'sources', assigns(:entry).name
109 assert_equal 'sources', assigns(:entry).name
110 end
110 end
111
111
112 def test_diff
112 def test_diff
113 # Full diff of changeset 2f9c0091
113 # Full diff of changeset 2f9c0091
114 get :diff, :id => 3, :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
114 get :diff, :id => 3, :rev => '2f9c0091c754a91af7a9c478e36556b4bde8dcf7'
115 assert_response :success
115 assert_response :success
116 assert_template 'diff'
116 assert_template 'diff'
117 # Line 22 removed
117 # Line 22 removed
118 assert_tag :tag => 'th',
118 assert_tag :tag => 'th',
119 :content => /22/,
119 :content => /22/,
120 :sibling => { :tag => 'td',
120 :sibling => { :tag => 'td',
121 :attributes => { :class => /diff_out/ },
121 :attributes => { :class => /diff_out/ },
122 :content => /def remove/ }
122 :content => /def remove/ }
123 end
123 end
124
124
125 def test_annotate
125 def test_annotate
126 get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb']
126 get :annotate, :id => 3, :path => ['sources', 'watchers_controller.rb']
127 assert_response :success
127 assert_response :success
128 assert_template 'annotate'
128 assert_template 'annotate'
129 # Line 23, changeset 2f9c0091
129 # Line 23, changeset 2f9c0091
130 assert_tag :tag => 'th', :content => /23/,
130 assert_tag :tag => 'th', :content => /23/,
131 :sibling => { :tag => 'td', :child => { :tag => 'a', :content => /2f9c0091/ } },
131 :sibling => { :tag => 'td', :child => { :tag => 'a', :content => /2f9c0091/ } },
132 :sibling => { :tag => 'td', :content => /jsmith/ },
132 :sibling => { :tag => 'td', :content => /jsmith/ },
133 :sibling => { :tag => 'td', :content => /watcher =/ }
133 :sibling => { :tag => 'td', :content => /watcher =/ }
134 end
134 end
135
135
136 def test_annotate_binary_file
136 def test_annotate_binary_file
137 get :annotate, :id => 3, :path => ['images', 'delete.png']
137 get :annotate, :id => 3, :path => ['images', 'delete.png']
138 assert_response 500
138 assert_response 500
139 assert_tag :tag => 'div', :attributes => { :class => /error/ },
139 assert_tag :tag => 'div', :attributes => { :class => /error/ },
140 :content => /can not be annotated/
140 :content => /can not be annotated/
141 end
141 end
142 else
142 else
143 puts "Git test repository NOT FOUND. Skipping functional tests !!!"
143 puts "Git test repository NOT FOUND. Skipping functional tests !!!"
144 def test_fake; assert true end
144 def test_fake; assert true end
145 end
145 end
146 end
146 end
@@ -1,60 +1,60
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 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.dirname(__FILE__) + '/../test_helper'
18 require File.dirname(__FILE__) + '/../test_helper'
19 require 'pp'
19 require 'pp'
20 class RepositoryCvsTest < Test::Unit::TestCase
20 class RepositoryCvsTest < Test::Unit::TestCase
21 fixtures :projects
21 fixtures :projects
22
22
23 # No '..' in the repository path
23 # No '..' in the repository path
24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository'
24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/cvs_repository'
25 REPOSITORY_PATH.gsub!(/\//, "\\") if RUBY_PLATFORM =~ /mswin/
25 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
26 # CVS module
26 # CVS module
27 MODULE_NAME = 'test'
27 MODULE_NAME = 'test'
28
28
29 def setup
29 def setup
30 @project = Project.find(1)
30 @project = Project.find(1)
31 assert @repository = Repository::Cvs.create(:project => @project,
31 assert @repository = Repository::Cvs.create(:project => @project,
32 :root_url => REPOSITORY_PATH,
32 :root_url => REPOSITORY_PATH,
33 :url => MODULE_NAME)
33 :url => MODULE_NAME)
34 end
34 end
35
35
36 if File.directory?(REPOSITORY_PATH)
36 if File.directory?(REPOSITORY_PATH)
37 def test_fetch_changesets_from_scratch
37 def test_fetch_changesets_from_scratch
38 @repository.fetch_changesets
38 @repository.fetch_changesets
39 @repository.reload
39 @repository.reload
40
40
41 assert_equal 5, @repository.changesets.count
41 assert_equal 5, @repository.changesets.count
42 assert_equal 14, @repository.changes.count
42 assert_equal 14, @repository.changes.count
43 assert_not_nil @repository.changesets.find_by_comments('Two files changed')
43 assert_not_nil @repository.changesets.find_by_comments('Two files changed')
44 end
44 end
45
45
46 def test_fetch_changesets_incremental
46 def test_fetch_changesets_incremental
47 @repository.fetch_changesets
47 @repository.fetch_changesets
48 # Remove the 3 latest changesets
48 # Remove the 3 latest changesets
49 @repository.changesets.find(:all, :order => 'committed_on DESC', :limit => 3).each(&:destroy)
49 @repository.changesets.find(:all, :order => 'committed_on DESC', :limit => 3).each(&:destroy)
50 @repository.reload
50 @repository.reload
51 assert_equal 2, @repository.changesets.count
51 assert_equal 2, @repository.changesets.count
52
52
53 @repository.fetch_changesets
53 @repository.fetch_changesets
54 assert_equal 5, @repository.changesets.count
54 assert_equal 5, @repository.changesets.count
55 end
55 end
56 else
56 else
57 puts "CVS test repository NOT FOUND. Skipping unit tests !!!"
57 puts "CVS test repository NOT FOUND. Skipping unit tests !!!"
58 def test_fake; assert true end
58 def test_fake; assert true end
59 end
59 end
60 end
60 end
@@ -1,56 +1,56
1 # redMine - project management software
1 # redMine - project management software
2 # Copyright (C) 2006-2007 Jean-Philippe Lang
2 # Copyright (C) 2006-2007 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.dirname(__FILE__) + '/../test_helper'
18 require File.dirname(__FILE__) + '/../test_helper'
19
19
20 class RepositoryGitTest < Test::Unit::TestCase
20 class RepositoryGitTest < Test::Unit::TestCase
21 fixtures :projects
21 fixtures :projects
22
22
23 # No '..' in the repository path
23 # No '..' in the repository path
24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
24 REPOSITORY_PATH = RAILS_ROOT.gsub(%r{config\/\.\.}, '') + '/tmp/test/git_repository'
25 REPOSITORY_PATH.gsub!(/\//, "\\") if RUBY_PLATFORM =~ /mswin/
25 REPOSITORY_PATH.gsub!(/\//, "\\") if Redmine::Platform.mswin?
26
26
27 def setup
27 def setup
28 @project = Project.find(1)
28 @project = Project.find(1)
29 assert @repository = Repository::Git.create(:project => @project, :url => REPOSITORY_PATH)
29 assert @repository = Repository::Git.create(:project => @project, :url => REPOSITORY_PATH)
30 end
30 end
31
31
32 if File.directory?(REPOSITORY_PATH)
32 if File.directory?(REPOSITORY_PATH)
33 def test_fetch_changesets_from_scratch
33 def test_fetch_changesets_from_scratch
34 @repository.fetch_changesets
34 @repository.fetch_changesets
35 @repository.reload
35 @repository.reload
36
36
37 assert_equal 6, @repository.changesets.count
37 assert_equal 6, @repository.changesets.count
38 assert_equal 11, @repository.changes.count
38 assert_equal 11, @repository.changes.count
39 assert_equal "Initial import.\nThe repository contains 3 files.", @repository.changesets.find(:first, :order => 'id ASC').comments
39 assert_equal "Initial import.\nThe repository contains 3 files.", @repository.changesets.find(:first, :order => 'id ASC').comments
40 end
40 end
41
41
42 def test_fetch_changesets_incremental
42 def test_fetch_changesets_incremental
43 @repository.fetch_changesets
43 @repository.fetch_changesets
44 # Remove the 3 latest changesets
44 # Remove the 3 latest changesets
45 @repository.changesets.find(:all, :order => 'id DESC', :limit => 3).each(&:destroy)
45 @repository.changesets.find(:all, :order => 'id DESC', :limit => 3).each(&:destroy)
46 @repository.reload
46 @repository.reload
47 assert_equal 3, @repository.changesets.count
47 assert_equal 3, @repository.changesets.count
48
48
49 @repository.fetch_changesets
49 @repository.fetch_changesets
50 assert_equal 6, @repository.changesets.count
50 assert_equal 6, @repository.changesets.count
51 end
51 end
52 else
52 else
53 puts "Git test repository NOT FOUND. Skipping unit tests !!!"
53 puts "Git test repository NOT FOUND. Skipping unit tests !!!"
54 def test_fake; assert true end
54 def test_fake; assert true end
55 end
55 end
56 end
56 end
General Comments 0
You need to be logged in to leave comments. Login now