aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/test
Commit message (Collapse)AuthorAgeFilesLines
...
* Generate a new key for each service testGeorge Claghorn2018-06-256-20/+20
| | | | Sidestep Google Cloud Storage's restrictive per-object rate limit.
* Permit configuring the default service URL expiryGeorge Claghorn2018-06-211-3/+3
|
* Fix "warning: Net::HTTPResponse#header is obsolete"yuuji.yaginuma2018-06-171-1/+1
| | | | Ref: https://github.com/ruby/ruby/blob/cc77a811298bd7ab1c422f7f999b93c858327da9/lib/net/http/response.rb#L138-L155
* Refactor activestorage/test/models/attached_test.rbbogdanvlviv2018-06-071-19/+21
| | | | | | | | | | | Don't include `ActiveJob::TestHelper` since there is no test that uses it. Ensure removing of overridden User's methods. Related to https://github.com/rails/rails/pull/33085#issuecomment-395548563 Module#remove_method is private in Ruby 2.4. Related to fd0bd1bf682622f064ac437ceee4e1b2a6b6d3b9
* Merge pull request #33018 from kddeisz/defined-attachmentsRafael França2018-06-011-0/+29
|\ | | | | ActiveStorage reflection
| * Move ActiveStorage reflection logic entirely into ActiveStorageKevin Deisz2018-05-311-2/+2
| |
| * Reflection for attachmentsKevin Deisz2018-05-301-0/+29
| | | | | | | | Add the ability to reflect on the attachments that have been defined using ActiveRecord::Reflection.
* | Remove errant debugger callGeorge Claghorn2018-05-301-1/+0
| |
* | Include blob ID in tempfile name for debugging convenienceGeorge Claghorn2018-05-301-5/+9
|/
* Verify integrity after chunked downloadGeorge Claghorn2018-05-281-1/+11
|
* Change video preview format from PNG to JPGJavan Makhmali2018-05-232-4/+5
|
* Merge pull request #32144 from kazu9su/masterGeorge Claghorn2018-05-221-0/+4
|\ | | | | Add ActiveStorage::Service::DiskService#url_for_direct_upload test
| * Add ActiveStorage::Service::DiskService#url_for_direct_upload testtommy2018-03-011-0/+4
| |
* | Disable variant options when false or nil presentJacob Smith2018-05-211-0/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In response to https://github.com/rails/rails/issues/32917 In the current implementation, ActiveStorage passes all options to the underlying processor, including when a key has a value of false. For example, passing: ``` avatar.variant(resize: "100x100", monochrome: false, flip: "-90") ``` will return a monochrome image (or an error, pending on ImageMagick configuration) because it passes `-monochrome false` to the command (but the command line does not allow disabling flags this way, as usually a user would omit the flag entirely to disable that feature). This fix only passes those keys forward to the underlying processor if the value responds to `present?`. In practice, this means that `false` or `nil` will be filtered out before going to the processor. One possible use case would be for a user to be able to apply different filters to an avatar. The code might look something like: ``` variant_options = { monochrome: params[:monochrome], resize: params[:resize] } avatar.variant(*variant_options) ``` Obviously some sanitization may be beneficial in a real-world scenario, but this type of configuration object could be used in many other places as well. - Add removing falsy values from varaints to changelog - The entirety of #image_processing_transformation inject block was wrapped in `list.tap` to guard against the default `nil` being returned if no conditional was called. - add test for explicitly true variant options
* | Permit opening a blob in a custom tempdirGeorge Claghorn2018-05-171-0/+12
| |
* | Generate getter and setter methods in mixinJosh Susser2018-05-171-0/+54
| | | | | | | | | | | | | | | | | | | | | | Generated attachment getter and setter methods are created within the model's `GeneratedAssociationMethods` module to allow overriding and composition using `super`. Includes tests for new functionality. Co-authored-by: Josh Susser <josh@hasmanythrough.com> Co-authored-by: Jamon Douglas <terrildouglas@gmail.com>
* | Add ActiveStorage::Blob#openGeorge Claghorn2018-05-161-0/+9
| | | | | | | | [David Robertson & George Claghorn]
* | Add option to ActiveStorage::Blob to set extract_content_type_from_ioRyan Davidson2018-05-082-2/+12
| | | | | | | | | | | | | | This adds a boolean argument called identify to ActiveStorage::Blob methods #create_after_upload, #build_after_upload and #upload. It allows a user to bypass the automatic content_type inference from the io.
* | Assert correct response bodyGeorge Claghorn2018-05-031-4/+6
| |
* | Support streaming downloads from Google Cloud StorageGeorge Claghorn2018-05-011-5/+13
| |
* | Stream blobs from disk in 5 MB chunksGeorge Claghorn2018-04-291-3/+3
| | | | | | | | Match other services, which all use a 5 MB chunk size.
* | Merge pull request #31956 from fatkodima/has_attached-presence-validationEileen M. Uchitelle2018-04-271-0/+30
|\ \ | | | | | | has_(one/many)_attached presence validation
| * | has_(one/many)_attached presence validationfatkodima2018-02-111-0/+30
| | |
* | | Move #extract_metadata_from to ActiveStorage's TestHelperRicardo Díaz2018-04-253-10/+4
| | | | | | | | | | | | | | | | | | ImageAnalyzerTest and VideoAnalyzerTest are defining the same helper, since both use `#create_file_blob` that is defined in TestHelper, it makes sense to move `#extract_metadata_from` to that side.
* | | Show ImageProcessing macros in a dedicated exampleJanko Marohnić2018-04-231-3/+13
| | |
* | | Rename ActiveStorage.processor to .variant_processorJanko Marohnić2018-04-221-4/+4
| | |
* | | Use ImageProcessing gem for ActiveStorage variantsJanko Marohnić2018-04-182-13/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ImageProcessing gem is a wrapper around MiniMagick and ruby-vips, and implements an interface for common image resizing and processing. This is the canonical image processing gem recommended in [Shrine], and that's where it developed from. The initial implementation was extracted from Refile, which also implements on-the-fly transformations. Some features that ImageProcessing gem adds on top of MiniMagick: * resizing macros - #resize_to_limit - #resize_to_fit - #resize_to_fill - #resize_and_pad * automatic orientation * automatic thumbnail sharpening * avoids the complex and inefficient MiniMagick::Image class * will use "magick" instead of "convert" on ImageMagick 7 However, the biggest feature of the ImageProcessing gem is that it has an alternative implementation that uses libvips. Libvips is an alternative to ImageMagick that can process images very rapidly (we've seen up 10x faster than ImageMagick). What's great is that the ImageProcessing gem provides the same interface for both implementations. The macros are named the same, and the libvips implementation does auto orientation and thumbnail sharpening as well; only the operations/options specific to ImageMagick/libvips differ. The integration provided by this PR should work for both implementations. The plan is to introduce the ImageProcessing backend in Rails 6.0 as the default backend and deprecate the MiniMagick backend, then in Rails 6.1 remove the MiniMagick backend.
* | | Always exclude JSON root from direct_uploads#create responseJavan Makhmali2018-04-101-0/+23
| | | | | | | | | | | | | | | | | | The JavaScript component expects a bare response. Fixes #32365
* | | Use a current model to provide the host for service urlsAndrew White2018-04-063-2/+10
| | | | | | | | | | | | | | | | | | | | | Trying to pass the current request down to the service so that it can create full urls instead of paths makes the API messy so use a model based on ActiveSupport::CurrentAttributes to provide the current host to services that need it (primarily the disk service).
* | | Flip the order of the after_create callbacksDwight Watson2018-03-272-3/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Addresses rails/rails#32247 Add test that checks identify and analyze work in correct order Break out direct upload test helper Review changes for direct-upload test helper
* | | Allow full use of the AWS S3 SDK authentication options (#32270)Brian Knight2018-03-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | If an explicit AWS key pair and/or region is not provided in config/storage.yml, attempt to use environment variables, shared credentials, or IAM role credentials. Order of precedence is determined by the AWS SDK[1]. [1]: https://docs.aws.amazon.com/sdk-for-ruby/v3/developer-guide/setup-config.html
* | | Update ASt test services configGeorge Claghorn2018-03-121-0/+0
| | |
* | | Remove path config option from Azure serviceAndrew White2018-03-121-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Active Storage service for Azure Storage has an option called `path` that is ambiguous in meaning. It needs to be set to the primary blob storage endpoint but that can be determined from the blobs client anyway. To simplify the configuration this commit removes the `path` option and gets the endpoint from the blobs client instead. Closes #32225.
* | | Provide an alternative PDF previewer based on PopplerTerence Lee2018-03-062-3/+26
| | | | | | | | | | | | | | | | | | mutool is licensed under the Affero GPL, which has strict distribution requirements. Poppler is licensed under the more liberal GPL, making it a good alternative for those who can't use mutool.
* | | Update test to reflect GCS direct upload header changeGeorge Claghorn2018-03-061-1/+1
| | |
* | | Allow selectively purging attached blobsNicholas Shirley2018-03-061-0/+28
| | |
* | | Fix purging dependent blobs when attachments aren't loadedGeorge Claghorn2018-03-052-2/+18
| | |
* | | Delete dependent attachments with recordGeorge Claghorn2018-03-052-0/+15
| | | | | | | | | | | | [Matt Jones & George Claghorn]
* | | Generate root-relative paths in Active Storage disk service URL methodsGeorge Claghorn2018-03-055-7/+6
| | | | | | | | | | | | Fixes #32129.
* | | Handle another case where a blob might be erroneously purgedGeorge Claghorn2018-03-041-0/+12
| | |
* | | Avoid purging attached blob when replacing it with itselfGeorge Claghorn2018-03-041-0/+12
| | |
* | | Merge Previews/Variants controller into one Representations controller.Kasper Timm Hansen2018-03-033-65/+61
| |/ |/| | | | | | | | | | | | | | | Since ActiveStorage::Blob::Representable unifies the idea of previews and variants under one roof as representation, we may as well have the controllers follow suit. Thus ActiveStorage::RepresenationsController enters the fray. I've copied the old tests for both previews and variants and unified those as well.
* | Update test to reflect direct upload header changesGeorge Claghorn2018-02-261-1/+1
| |
* | Avoid specifying content types for direct uploads to Google Cloud StorageGeorge Claghorn2018-02-261-1/+1
| | | | | | | | Fix customizing the download Content-Type for a directly-uploaded blob via a signed URL. See e8286ee.
* | Support varying ICO filesGeorge Claghorn2018-02-242-0/+11
| | | | | | | | Closes #32096.
* | Allow S3 tests against buckets in other regionsAndrew White2018-02-212-2/+2
| | | | | | | | | | Only us-east-1 gives URLs like bucket.s3.amazonaws.com whereas other regions have URLs like s3-eu-west-1.amazonaws.com/ubxd-rails
* | Add ActiveStorage::Blob.unattached scopefatkodima2018-02-121-0/+17
|/
* Fix `blob.service_url` for supports string or nil `:filename` option.Jason Lee2018-02-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | - Make sure `blob.service_url` present a `ActiveStorage::Filename` type to `serivce.url`. - Add `ActiveStorage::Filename.wrap` method. before: ```rb blob.service_url(filename: ActiveStorage::Filename.new("new.txt")) blob.service_url(filename: "new.txt") => NoMethodError: undefined method `parameters' for "new.txt":String params = {} blob.service_url(filename: params[:filename]) => NoMethodError: undefined method `parameters' for nil:NilClass ``` after: ```rb blob.service_url(filename: "new.txt") blob.service_url(filename: nil) ```
* Allow `ActiveStorage::Blob#service_url` to pass addition options to ↵Jason Lee2018-02-011-0/+20
| | | | | | | | | | | | | | | | | | | | | | | `service.url`. Because there have some service needs more parameters for file URL: https://www.alibabacloud.com/help/doc-detail/44687.htm ```rb class AliyunService < Service def url(key, options = {}) image_process = options[:oss_process] || "image/resize,w_800" "http://image-demo.oss-cn-hangzhou.aliyuncs.com/example.jpg?x-oss-process=#{image_process}" end end ``` Use case: ```erb <%= image_tag @user.avatar.service_url(oss_process: "image/resize,m_fill,h_100,w_100" %> ```
* Correct orientation detectionGeorge Claghorn2018-01-311-2/+2
|