Feature #43484 » 0001-Improve-Redmine-MockFile-to-better-mimic-File-behavi.patch
| test/test_helper.rb | ||
|---|---|---|
| 299 | 299 |
end |
| 300 | 300 | |
| 301 | 301 |
module Redmine |
| 302 |
class MockFile |
|
| 303 |
attr_reader :size, :original_filename, :content_type
|
|
| 302 |
class MockFile < StringIO
|
|
| 303 |
attr_reader :original_filename, :content_type |
|
| 304 | 304 | |
| 305 | 305 |
def initialize(options={})
|
| 306 |
@size = options[:size] || 32 |
|
| 307 | 306 |
@original_filename = options[:original_filename] || options[:filename] |
| 308 | 307 |
@content_type = options[:content_type] |
| 309 |
@content = options[:content] || 'x'*size |
|
| 310 |
end |
|
| 311 | ||
| 312 |
def read(*args) |
|
| 313 |
if @eof |
|
| 314 |
false |
|
| 315 |
else |
|
| 316 |
@eof = true |
|
| 317 |
@content |
|
| 318 |
end |
|
| 308 |
size = options[:size] || 32 |
|
| 309 |
content = options[:content] || 'x' * size |
|
| 310 |
super(content) |
|
| 319 | 311 |
end |
| 320 | 312 |
end |
| 321 | 313 | |