Patch #38146 » 0005-Fix-RuboCop-offense-Performance-FixedSize.patch
| .rubocop_todo.yml | ||
|---|---|---|
| 486 | 486 |
- 'test/unit/lib/redmine/scm/adapters/mercurial_adapter_test.rb' |
| 487 | 487 |
- 'test/unit/project_test.rb' |
| 488 | 488 | |
| 489 |
Performance/FixedSize: |
|
| 490 |
Exclude: |
|
| 491 |
- 'test/integration/api_test/issues_test.rb' |
|
| 492 |
- 'test/integration/attachments_test.rb' |
|
| 493 | ||
| 494 | 489 |
# This cop supports unsafe autocorrection (--autocorrect-all). |
| 495 | 490 |
Performance/RedundantEqualityComparisonBlock: |
| 496 | 491 |
Exclude: |
| test/integration/api_test/issues_test.rb | ||
|---|---|---|
| 969 | 969 |
end |
| 970 | 970 | |
| 971 | 971 |
def test_create_issue_with_uploaded_file |
| 972 |
token = xml_upload('test_create_with_upload', credentials('jsmith'))
|
|
| 972 |
file_content = 'test_create_with_upload' |
|
| 973 |
token = xml_upload(file_content, credentials('jsmith'))
|
|
| 973 | 974 |
attachment = Attachment.find_by_token(token) |
| 974 | 975 | |
| 975 | 976 |
# create the issue with the upload's token |
| ... | ... | |
| 991 | 992 |
attachment.reload |
| 992 | 993 |
assert_equal 'test.txt', attachment.filename |
| 993 | 994 |
assert_equal 'text/plain', attachment.content_type |
| 994 |
assert_equal 'test_create_with_upload'.size, attachment.filesize
|
|
| 995 |
assert_equal file_content.size, attachment.filesize
|
|
| 995 | 996 |
assert_equal 2, attachment.author_id |
| 996 | 997 | |
| 997 | 998 |
# get the issue with its attachments |
| test/integration/attachments_test.rb | ||
|---|---|---|
| 58 | 58 |
def test_upload_as_js_and_attach_to_an_issue |
| 59 | 59 |
log_user('jsmith', 'jsmith')
|
| 60 | 60 | |
| 61 |
token = ajax_upload('myupload.txt', 'File content')
|
|
| 61 |
file_content = 'File content' |
|
| 62 |
token = ajax_upload('myupload.txt', file_content)
|
|
| 62 | 63 | |
| 63 | 64 |
assert_difference 'Issue.count' do |
| 64 | 65 |
post( |
| ... | ... | |
| 84 | 85 |
attachment = issue.attachments.first |
| 85 | 86 |
assert_equal 'myupload.txt', attachment.filename |
| 86 | 87 |
assert_equal 'My uploaded file', attachment.description |
| 87 |
assert_equal 'File content'.length, attachment.filesize
|
|
| 88 |
assert_equal file_content.length, attachment.filesize
|
|
| 88 | 89 |
end |
| 89 | 90 | |
| 90 | 91 |
def test_upload_as_js_and_preview_as_inline_attachment |
| ... | ... | |
| 121 | 122 |
def test_upload_and_resubmit_after_validation_failure |
| 122 | 123 |
log_user('jsmith', 'jsmith')
|
| 123 | 124 | |
| 124 |
token = ajax_upload('myupload.txt', 'File content')
|
|
| 125 |
file_content = 'File content' |
|
| 126 |
token = ajax_upload('myupload.txt', file_content)
|
|
| 125 | 127 | |
| 126 | 128 |
assert_no_difference 'Issue.count' do |
| 127 | 129 |
post( |
| ... | ... | |
| 167 | 169 |
attachment = issue.attachments.first |
| 168 | 170 |
assert_equal 'myupload.txt', attachment.filename |
| 169 | 171 |
assert_equal 'My uploaded file', attachment.description |
| 170 |
assert_equal 'File content'.length, attachment.filesize
|
|
| 172 |
assert_equal file_content.length, attachment.filesize
|
|
| 171 | 173 |
end |
| 172 | 174 | |
| 173 | 175 |
def test_upload_filename_with_plus |
| 174 | 176 |
log_user('jsmith', 'jsmith')
|
| 175 | 177 |
filename = 'a+b.txt' |
| 176 |
token = ajax_upload(filename, 'File content') |
|
| 178 |
file_content = 'File content' |
|
| 179 |
token = ajax_upload(filename, file_content) |
|
| 177 | 180 |
assert_difference 'Issue.count' do |
| 178 | 181 |
post( |
| 179 | 182 |
'/projects/ecookbook/issues', |
| ... | ... | |
| 191 | 194 |
attachment = issue.attachments.first |
| 192 | 195 |
assert_equal filename, attachment.filename |
| 193 | 196 |
assert_equal '', attachment.description |
| 194 |
assert_equal 'File content'.length, attachment.filesize
|
|
| 197 |
assert_equal file_content.length, attachment.filesize
|
|
| 195 | 198 |
end |
| 196 | 199 | |
| 197 | 200 |
def test_upload_as_js_and_destroy |