aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/test
Commit message (Collapse)AuthorAgeFilesLines
* Revert "MethodCallAssertions is a regular player of the team ↵Rafael Mendonça França2019-08-021-0/+3
| | | | | | ActiveSupport::TestCase now" This reverts commit 98d0f7ebd34b858f12a12dcf37ae54fdbb5cab64.
* MethodCallAssertions is a regular player of the team ActiveSupport::TestCase nowAkira Matsuda2019-08-021-3/+0
| | | | It's used everywhere, clean and mature enough
* It may be better to explicitly require 'object/try' where we call `try`Akira Matsuda2019-08-011-0/+1
| | | | | | In most cases it works now without explicit require because it's accidentally required through active_support/core_ext/date_and_time/calculations.rb where we still call `try`, but that would stop working if we changed the Calculations implementation and remove the require call there.
* Merge pull request #36792 from peterzhu2118/azure-content-dispositionGannon McGibbon2019-07-311-0/+15
|\ | | | | Upload filename and disposition for Azure
| * Upload file with filename and disposition for AzurePeter Zhu2019-07-311-0/+15
| |
* | Merge pull request #36791 from peterzhu2118/s3-upload-dispositionGannon McGibbon2019-07-311-0/+17
|\ \ | | | | | | Upload with filename and disposition for S3
| * | Upload file with filename and disposition for S3Peter Zhu2019-07-311-0/+17
| |/
* | Let the generated initializers/backtrace_silencers.rb code use Regexp#match?Akira Matsuda2019-07-291-1/+1
| |
* | Use a smaller TIFF file as fixtureErshad Kunnakkadan2019-07-271-0/+0
|/
* Merge pull request #36715 from peterzhu2118/azure-content-typeEileen M. Uchitelle2019-07-241-0/+14
|\ | | | | Add content_type to upload method for Azure
| * Add content_type to upload in AzurePeter Zhu2019-07-241-0/+14
| |
* | Merge pull request #36642 from wagenet/fix-disk-service-hostRafael França2019-07-231-2/+8
|\ \ | | | | | | Fix host for ActiveStorage DiskService
| * | Fix host for ActiveStorage DiskServicePeter Wagenet2019-07-091-2/+8
| | | | | | | | | | | | | | | Previous behavior would only set host, which didn't work correctly if the default_url_options contained the protocol or the port.
* | | Preserve existing attachment assignment behavior for upgraded appsGeorge Claghorn2019-07-201-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | Assigning to a collection of attachments appends rather than replacing, as in 5.2. Existing 5.2 apps that rely on this behavior will no longer break when they're upgraded to 6.0. For apps generated on 6.0 or newer, assigning replaces the existing attachments in the collection. #attach should be used to add new attachments to the collection without removing existing ones. I expect that we'll deprecate the old behavior in 6.1. Closes #36374.
* | | Revert "Merge pull request #36676 from ↵Ryuta Kamizono2019-07-171-1/+1
| |/ |/| | | | | | | | | | | | | | | | | | | | | wjessop/change_activestorage_metadata_duration_to_bound" This reverts commit a307c697b28e3c8b2860d2274c23e4d95dc164ae, reversing changes made to f30f76af747858826d3618866676cd5a4979e64a. Reason: This assertion is not failed even without this PR since both ffprobe versions (3.2.14 and 4.1.3) return the same duration 5.166648 for `video.mp4`. So there is no need to touch this assertion at this point.
* | Different versions of ffprobe can return subtly different video lengthsWill Jessop2019-07-141-1/+1
| | | | | | | | Specify a range so we can take this into account, but not get caught out by 0, nil or way too large values.
* | Fix activestorage CI failure due to ffprove version differeceRyuta Kamizono2019-07-141-1/+0
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Our CI environment is upgraded from stretch to buster then ffprove version is also upgraded from 3.2.14 to 4.1.3. https://packages.debian.org/stretch/ffmpeg https://packages.debian.org/buster/ffmpeg Somehow those ffprove returns different metadata for `rotated_video.mp4`. ``` $ ffprobe -print_format json -show_streams -v error rotated_video.mp4 > ffprobe41.json $ diff -ub ffprobe32.json ffprobe41.json --- ffprobe32.json 2019-07-14 20:02:13.000000000 +0900 +++ ffprobe41.json 2019-07-14 19:59:08.000000000 +0900 @@ -27,8 +27,8 @@ "time_base": "1/17594", "start_pts": 3976, "start_time": "0.225986", - "duration_ts": 91981, - "duration": "5.227975", + "duration_ts": 88000, + "duration": "5.001705", "bit_rate": "321546", "bits_per_raw_sample": "8", "nb_frames": "44", @@ -78,8 +78,8 @@ "time_base": "1/44100", "start_pts": 0, "start_time": "0.000000", - "duration_ts": 227865, - "duration": "5.167007", + "duration_ts": 227850, + "duration": "5.166667", "bit_rate": "109732", "max_bit_rate": "109732", "nb_frames": "223", ``` In the case on the `test "analyzing a rotated video"`, most important part is `assert_equal 90, metadata[:angle]`, the accidental difference of duration for ffprove version is out of scope for the test.
* Mirror direct uploadsGeorge Claghorn2019-05-224-59/+70
|
* S3: permit uploading files larger than 5 GBGeorge Claghorn2019-05-161-2/+20
| | | Use multipart uploads for files larger than 100 MB. Dynamically calculate part size based on total object size and maximum part count.
* Remove outdated cross-origin redirection testsGeorge Claghorn2019-05-152-55/+0
|
* Don't fail ImageAnalyzer on unsupported typesGuilherme Mansur2019-04-241-0/+8
| | | | | | | | | | Fix: #36065 The IamgeAnalyzer passes a image to ImageMagick without checking if the image is supported by ImageMagick. This patch checks that image is supported and if not logs an error and returns an empty hash instead of raising an error. This is the same error handling we do when we encounter a LoadError when mini_magick is not installed.
* Merge pull request #36045 from yfxie/fix-normalize-the-hash-of-transformationsGeorge Claghorn2019-04-211-0/+8
|\ | | | | ActiveStorage - normalize the hash of transformations
| * normalize the hash of transformationsYi Feng2019-04-201-0/+8
| |
* | Allow ActiveStorage to generate variants of BMP imagesYounes SERRAJ2019-04-212-0/+11
|/
* Output junit format test reportFumiaki MATSUSHIMA2019-04-041-0/+2
|
* url -> URL where apt except inside actionpack/Sharang Dashputre2019-04-013-7/+7
|
* Add ActiveStorage::Service#openGeorge Claghorn2019-03-281-5/+3
|
* [ActiveStorage] Ensure that the `_blob` association is properly loaded when ↵Abhishek Chandrasekhar2019-02-262-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | attaching `::One` Consider a model with `One` and `Many` attachments configured: class User < ActiveRecord::Base has_one_attached :avatar has_many_attached :highlights end === One Attachment After attaching `One` attachment (`:avatar`), we can see that the associated `_blob` record (`:avatar_blob`) still returns as `nil`. user.avatar.attach(blob) user.avatar_attachment.present? => true user.avatar_blob.present? => false # Incorrect! This is a false negative. It happens because after the attachment and blob are built: 1. The record already has its `_blob` association loaded, as `nil` 2. the `::Attachment` is associated with the record but the `::Blob` only gets associated with the `::Attachment`, not the record itself In reality, the blob does in fact exist. We can verify this as follows: user.avatar.attach(blob) user.avatar_attachment.blob.present? => true # Blob does exist! The fix in this change is to simply assign the `::Blob` when assigning the `::Attachment`. After this fix is applied, we correctly observe: user.avatar.attach(blob) user.avatar_attachment.present? => true user.avatar_blob.present? => true # Woohoo! === Many Attachments We don't see this issue with `Many` attachments because the `_blob` association is already loaded as part of attaching more/newer blobs. user.highlights.attach(blob) user.highlights_attachments.any? => true user.highlights_blobs.any? => true
* Delegated path_for to primary in the MirrorServiceAbhay Nikam2019-02-141-0/+4
|
* include the content type when uploading to S3Simo Leone2019-01-241-0/+18
|
* Fix ArgumentError: Unsafe redirectYuichi Takeuchi2019-01-212-0/+55
|
* Merge pull request #34132 from ConfusedVorlon/enable_fragment_cache_log_in_devRafael França2019-01-081-0/+1
|\ | | | | enable_fragment_cache_logging in dev by default
| * enable_fragment_cache_loggingRob Jonson2018-10-091-0/+1
| | | | | | | | | | | | | | | | fragment caching was refactored in (I think 5.2) and by default doesn't log cache info this is confusing in development where rails dev:cache now turns on caching, but doesn't show any different logging output better to enable debugging by default for dev - and let people turn it off if preferred
* | Permit generating variants of TIFF imagesLuciano Sousa2018-12-302-0/+11
| |
* | Make Active Storage blob keys lowercaseJulik Tarkhanov2018-12-302-1/+5
| | | | | | Accommodate case-insensitive filesystems and database collations.
* | Use 6.0 default configs in Active Storage test dummy appbogdanvlviv2018-12-301-1/+1
| |
* | Enable `Style/RedundantBegin` cop to avoid newly adding redundant begin blockRyuta Kamizono2018-12-217-212/+180
| | | | | | | | | | | | | | | | | | | | Currently we sometimes find a redundant begin block in code review (e.g. https://github.com/rails/rails/pull/33604#discussion_r209784205). I'd like to enable `Style/RedundantBegin` cop to avoid that, since rescue/else/ensure are allowed inside do/end blocks in Ruby 2.5 (https://bugs.ruby-lang.org/issues/12906), so we'd probably meets with that situation than before.
* | Module#{define_method,alias_method,undef_method,remove_method} become public ↵Ryuta Kamizono2018-12-212-2/+2
| | | | | | | | | | | | since Ruby 2.5 https://bugs.ruby-lang.org/issues/14133
* | add require 'database/setup' in activestorage/test/service/s3_service_test.rbMarcelo Perini Veloso2018-12-011-0/+1
| |
* | `metadata` is not passed to serviceyuuji.yaginuma2018-12-011-2/+1
| | | | | | | | | | | | | | | | | | Ref: https://github.com/rails/rails/blob/604fac6d7191fca102380b1a5f5eb9c619fb407f/activestorage/app/models/active_storage/blob.rb#L256-L264 This fixes broken `GCSServiceTest`. https://travis-ci.org/rails/rails/jobs/461868394#L6624-L6626 Follow up to #34576.
* | Add a test with extra keys to active_storage Service#uploadYannick Schutz2018-11-301-0/+19
| |
* | Fix "warning: ambiguous first argument; put parentheses or a space even ↵yuuji.yaginuma2018-11-281-3/+3
| | | | | | | | after `/' operator"
* | text is treated as `attachment`yuuji.yaginuma2018-11-281-2/+2
| |
* | Fix broken `ActiveStorage::BlobTest`yuuji.yaginuma2018-11-281-1/+1
| | | | | | | | `ActiveStorage::Filename#parameters` was removed by #33829.
* | Remove duplicated testyuuji.yaginuma2018-11-281-14/+0
| | | | | | | | | | | | | | | | | | | | | | | | Since 06ab7b27ea1c1ab357085439abacdb464f6742bf, `GCSServiceTest#test_signed_URL_response_headers` is broken. https://travis-ci.org/rails/rails/jobs/460454477#L7084-L7087 This seems to be due to lack of `content_type` at upload. This is solved by specifying `conten_type`. However, since the same content is also tested with `test_upload_with_content_type`, it will be duplicated content, so I think that can remove `test_signed_URL_response_headers`.
* | Prevent content type and disposition bypass in storage service URLsRosa Gutierrez2018-11-274-11/+78
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Force content-type to binary on service urls for relevant content types We have a list of content types that must be forcibly served as binary, but in practice this only means to serve them as attachment always. We should also set the Content-Type to the configured binary type. As a bonus: add text/cache-manifest to the list of content types to be served as binary by default. * Store content-disposition and content-type in GCS Forcing these in the service_url when serving the file works fine for S3 and Azure, since these services include params in the signature. However, GCS specifically excludes response-content-disposition and response-content-type from the signature, which means an attacker can modify these and have files that should be served as text/plain attachments served as inline HTML for example. This makes our attempt to force specific files to be served as binary and as attachment can be easily bypassed. The only way this can be forced in GCS is by storing content-disposition and content-type in the object metadata. * Update GCS object metadata after identifying blob In some cases we create the blob and upload the data before identifying the content-type, which means we can't store that in GCS right when uploading. In these, after creating the attachment, we enqueue a job to identify the blob, and set the content-type. In other cases, files are uploaded to the storage service via direct upload link. We create the blob before the direct upload, which happens independently from the blob creation itself. We then mark the blob as identified, but we have already the content-type we need without having put it in the service. In these two cases, then, we need to update the metadata in the GCS service. * Include content-type and disposition in the verified key for disk service This prevents an attacker from modifying these params in the service signed URL, which is particularly important when we want to force them to have specific values for security reasons. * Allow only a list of specific content types to be served inline This is different from the content types that must be served as binary in the sense that any content type not in this list will be always served as attachment but with its original content type. Only types in this list are allowed to be served either inline or as attachment. Apart from forcing this in the service URL, for GCS we need to store the disposition in the metadata. Fix CVE-2018-16477.
* Fix issue ActiveStorage direct upload diskGraham Conzett2018-10-071-0/+10
| | | | | | Fix an issue in ActiveStorage where a direct upload to disk storage would fail due to a content type mismatch if the file was uploaded using a mime-type synonym.
* Make Webpacker the default JavaScript compiler for Rails 6 (#33079)David Heinemeier Hansson2018-09-303-4/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Use Webpacker by default on new apps * Stop including coffee-rails by default * Drop using a js_compressor by default * Drop extra test for coffeescript inclusion by default * Stick with skip_javascript to signify skipping webpack * Don't install a JS runtime by default any more * app/javascript will be the new default directory for JS * Make it clear that this is just for configuring the default Webpack framework setup now * Start using the Webpack tag in the default layout * Irrelevant test * jQuery is long gone * Stop having asset pipeline compile default application.js * Add rails-ujs by default to the Webpack setup * Add Active Storage JavaScript to application.js pack by default * Consistent quoting * Add Turbolinks to default pack * Add Action Cable to default pack Need some work on how to set the global consumer that channels will work with. @javan? * Require all channels by default and use a separate consumer stub * Channel generator now targets Webpack style * Update task docs to match new generator style * Use uniform import style * Drop the JS assets generator It was barely helpful as it was. It’s no longer helpful in a Webpacked world. Sayonara! * Add app/javascript to the stats directories * Simpler import style Which match the other imports. * Address test failures from dropping JS compilation (and compression) * webpacker-default: Modify `AssetsGeneratorTest` Before: ``` $ bin/test test/generators/assets_generator_test.rb Run options: --seed 46201 F Failure: AssetsGeneratorTest#test_assets [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/assets_generator_test.rb:12]: Expected file "app/assets/javascripts/posts.js" to exist, but does not bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/assets_generator_test.rb:10 . Finished in 0.031343s, 63.8101 runs/s, 95.7152 assertions/s. 2 runs, 3 assertions, 1 failures, 0 errors, 0 skips ``` After: ``` $ bin/test test/generators/assets_generator_test.rb Run options: --seed 43571 .. Finished in 0.030370s, 65.8545 runs/s, 65.8545 assertions/s. 2 runs, 2 assertions, 0 failures, 0 errors, 0 skips ``` * webpacker-default: Modify `ChannelGeneratorTest` Before: ``` $ bin/test test/generators/channel_generator_test.rb Run options: --seed 8986 .F Failure: ChannelGeneratorTest#test_channel_with_multiple_actions_is_created [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:43]: Expected file "app/assets/javascripts/channels/chat.js" to exist, but does not bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:34 .F Failure: ChannelGeneratorTest#test_channel_is_created [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:29]: Expected file "app/assets/javascripts/channels/chat.js" to exist, but does not bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:22 E Error: ChannelGeneratorTest#test_cable_js_is_created_if_not_present_already: Errno::ENOENT: No such file or directory @ apply2files - /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/fixtures/tmp/app/assets/javascripts/cable.js bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:60 F Failure: ChannelGeneratorTest#test_channel_suffix_is_not_duplicated [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:87]: Expected file "app/assets/javascripts/channels/chat.js" to exist, but does not bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:80 F Failure: ChannelGeneratorTest#test_channel_on_revoke [/Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:77]: Expected file "app/assets/javascripts/cable.js" to exist, but does not bin/test /Users/ttanimichi/ghq/github.com/ttanimichi/rails/railties/test/generators/channel_generator_test.rb:68 Finished in 0.064384s, 108.7227 runs/s, 481.4861 assertions/s. 7 runs, 31 assertions, 4 failures, 1 errors, 0 skips ``` After: ``` $ bin/test test/generators/channel_generator_test.rb Run options: --seed 44857 ....... Finished in 0.060243s, 116.1961 runs/s, 697.1764 assertions/s. 7 runs, 42 assertions, 0 failures, 0 errors, 0 skips ``` * Fix shared generator tests. * webpacker-default: Modify `ControllerGeneratorTest` The JS assets generator was dropped. ref. https://github.com/rails/rails/commit/46215b179483d3e4d264555f5a4952f43eb8142a * Revert "Simpler import style". It's currently failing with an error of "TypeError: undefined is not an object (evaluating '__WEBPACK_IMPORTED_MODULE_2_activestorage___default.a.start')". Waiting for @javan to have a look. This reverts commit 5d3ebb71059f635d3756cbda4ab9752027e09256. * require webpacker in test app * Add webpacker without making the build hang/timeout. (#33640) * use yarn workspaces to allow for installing unreleased packages and only generate js/bootsnap when required * no longer need to have webpacker in env templates as webpacker moved this config to yml file * Fix rubocop violation * Got the test passing for the running scaffold * update expected lines of code * update middleware tests to account for webpacker * disable js in plugins be default to get the tests passing (#34009) * clear codeclimate report issues * Anything newer than currently released is good * Use Webpacker development version during development of Rails * Edge should get development webpacker as well * Add changelog entry for Webpacker change
* Change the empty block style to have space inside of the blockRafael Mendonça França2018-09-251-1/+1
|
* Merge pull request #33829 from mtsmfm/encode-filenameKasper Timm Hansen2018-09-232-33/+1
|\ | | | | Encode Content-Disposition filenames on send_data and send_file