Feature #43484 » 0001-Improve-Redmine-MockFile-to-better-mimic-File-behavi.patch
| test/test_helper.rb | ||
|---|---|---|
| 324 | 324 |
end |
| 325 | 325 | |
| 326 | 326 |
module Redmine |
| 327 |
class MockFile |
|
| 328 |
attr_reader :size, :original_filename, :content_type
|
|
| 327 |
class MockFile < StringIO
|
|
| 328 |
attr_reader :original_filename, :content_type |
|
| 329 | 329 | |
| 330 | 330 |
def initialize(options={})
|
| 331 |
@size = options[:size] || 32 |
|
| 332 | 331 |
@original_filename = options[:original_filename] || options[:filename] |
| 333 | 332 |
@content_type = options[:content_type] |
| 334 |
@content = options[:content] || 'x'*size |
|
| 335 |
end |
|
| 336 | ||
| 337 |
def read(*args) |
|
| 338 |
if @eof |
|
| 339 |
false |
|
| 340 |
else |
|
| 341 |
@eof = true |
|
| 342 |
@content |
|
| 343 |
end |
|
| 333 |
size = options[:size] || 32 |
|
| 334 |
content = options[:content] || 'x' * size |
|
| 335 |
super(content) |
|
| 344 | 336 |
end |
| 345 | 337 |
end |
| 346 | 338 | |