aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Allow Range#=== and Range#cover? on Rangeutilum2018-05-223-23/+68
| | | | | | | | | | | ruby/ruby@989e07c features switching `Range#===` to use internal `r_cover_p` instead of rubyland `include?`. This breaks expected behavior of `ActiveSupport::CoreExt::Range` documented since at least 8b67a02. This patch adds overrides on `Range#cover?` and `Range#===` and places all three in a single module, `CompareWithRange`. *Requiring core_ext/range/include_range now causes a deprecation warnning*
* Merge pull request #32936 from jacobsmith/image-variant-allow-disabling-optionsGeorge Claghorn2018-05-213-12/+81
|\ | | | | [ActiveStorage] Disable variant options when false or nil present
| * Disable variant options when false or nil presentJacob Smith2018-05-213-12/+81
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge pull request #32523 from kaspth/enumerable-index-with-extensionKasper Timm Hansen2018-05-214-1/+70
|\ \ | | | | | | Add Enumerable#index_with.
| * | [ci skip] Add documentation/changelog entry.Kasper Timm Hansen2018-05-212-0/+30
| | |
| * | Add Enumerable#index_with.Kasper Timm Hansen2018-05-212-1/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In the app I'm working on I've wished that index_by had a buddy that would assign the hash value instead of the key multiple times. Enter index_with. Useful when building a hash from a static list of symbols. Before you'd do: ```ruby POST_ATTRIBUTES.map { |attr_name| [ attr_name, public_send(attr_name) ] }.to_h ``` But now that's a little clearer and faster with: ````ruby POST_ATTRIBUTES.index_with { |attr_name| public_send(attr_name) } ``` It's also useful when you have an enumerable that should be converted to a hash, but you don't want to muddle the code up with the overhead that it takes to create that hash. So before, that's: ```ruby WEEKDAYS.each_with_object(Hash.new) do |day, intervals| intervals[day] = [ Interval.all_day ] end ``` And now it's just: ```ruby WEEKDAYS.index_with([ Interval.all_day ]) ``` It's also nice to quickly get a hash with either nil, [], or {} as the value.
* | | Merge pull request #32946 from coryjb/patch-1Kasper Timm Hansen2018-05-211-1/+1
|\ \ \ | |/ / |/| | Exception wording change
| * | Exception wording changeCory Becker2018-05-211-1/+1
| | |
* | | Rename exception variable to error.Kasper Timm Hansen2018-05-211-2/+2
|/ / | | | | | | Follows the change from 6fac9bd, so the naming is consistent.
* | Merge pull request #32923 from yahonda/bump_sqlite3_version_to_38Ryuta Kamizono2018-05-215-32/+17
|\ \ | | | | | | Bump minimum SQLite version to 3.8
| * | Bump minimum SQLite version to 3.8Yasuo Honda2018-05-215-32/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These OS versions have SQLite 3.8 or higher by default. - macOS 10.10 (Yosemite) or higher - Ubuntu 14.04 LTS or higher Raising the minimum version of SQLite 3.8 introduces these changes: - All of bundled adapters support `supports_multi_insert?` - SQLite 3.8 always satisifies `supports_foreign_keys_in_create?` and `supports_partial_index?` - sqlite adapter can support `alter_table` method for foreign key referenced tables by #32865 - Deprecated `supports_multi_insert?` method
* | | Enable `Lint/StringConversionInInterpolation` rubocop ruleRyuta Kamizono2018-05-214-4/+7
|/ / | | | | | | | | To prevent redundant `to_s` like https://github.com/rails/rails/pull/32923#discussion_r189460008 automatically in the future.
* / `SqlTypeMetadata` is :nodoc: class [ci skip]Ryuta Kamizono2018-05-211-0/+1
|/ | | | So do not expose `PostgreSQLTypeMetadata` in the doc too.
* Add test case that configure ↵yuuji.yaginuma2018-05-201-0/+17
| | | | | | `config.action_view.finalize_compiled_template_methods` Follow up of #32418.
* Rollback correctly restore initial record id after double saveRyuta Kamizono2018-05-192-1/+2
|
* Merge pull request #32911 from eugeneius/finalize_transaction_record_stateRyuta Kamizono2018-05-193-15/+54
|\ | | | | Finalize transaction record state after real transaction
| * Finalize transaction record state after real transactionEugene Kenny2018-05-193-15/+54
|/ | | | | | | | | | | | | | | | | | After a real (non-savepoint) transaction has committed or rolled back, the original persistence-related state for all records modified in that transaction is discarded or restored, respectively. When the model has transactional callbacks, this happens synchronously in the `committed!` or `rolled_back!` methods; otherwise, it happens lazily the next time the record's persistence-related state is accessed. The synchronous code path always finalizes the state of the record, but the lazy code path only pops one "level" from the transaction counter, assuming it will always reach zero immediately after a real transaction. As the test cases included here demonstrate, that isn't always the case. By using the same logic as the synchronous code path, we ensure that the record's state is always updated after a real transaction has finished.
* Merge pull request #32900 from ttanimichi/app-update-skip-yarnRafael França2018-05-184-3/+25
|\ | | | | Don't generate yarn's contents in `app:update` task if it's skipped
| * Don't generate yarn's contents in `app:update` task if it's skippedTsukuru Tanimichi2018-05-164-3/+25
| |
* | Merge pull request #32925 from Linuus/fix/actioncontroller-params-fetch-docsRafael França2018-05-181-1/+3
|\ \ | | | | | | Fix documentation for ActionController::Params#fetch
| * | Fix documentation for ActionController::Params#fetchLinus Marton2018-05-181-1/+3
| | | | | | | | | | | | | | | Make it clear that the return value is converted to an instance of ActionController::Parameters if possible
* | | Raise a better exception when a invalid depreation behavior is setRafael Mendonça França2018-05-182-0/+12
|/ / | | | | | | Fixes #32928.
* | Permit opening a blob in a custom tempdirGeorge Claghorn2018-05-175-9/+26
| |
* | Merge pull request #32921 from joshsusser/masterRafael França2018-05-173-2/+62
|\ \ | | | | | | Generate ActiveStorage attachment getter and setter methods in mixin
| * | Generate getter and setter methods in mixinJosh Susser2018-05-173-2/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | | Fix markdown [ci skip]Rafael Mendonça França2018-05-171-1/+1
|/ /
* | Merge pull request #32908 from anniecodes/fix-time-random-stringRafael França2018-05-174-0/+28
|\ \ | | | | | | Fix user_input_in_time_zone to coerce non valid string into nil
| * | Fix user_input_in_time_zone to coerce non valid string into nilAnnie-Claude Côté2018-05-163-0/+27
| | | | | | | | | | | | Before it was coercing an invalid string into "2000-01-01 00:00:00".
| * | Add missing require for string to timezone conversionAnnie-Claude Côté2018-05-161-0/+1
| | | | | | | | | | | | Inside user_input_in_time_zone we call in_time_zone on the value and value can be a String.
* | | Fix formatting of author credit [ci skip]Ryuta Kamizono2018-05-171-1/+1
| | |
* | | Merge pull request #32916 from lucfranken/patch-1Ryuta Kamizono2018-05-171-1/+1
|\ \ \ | | | | | | | | | | | | | | | | Active storage: Image variant options not correct in docs [ci skip]
| * | | Active storage: Image variant options not correctlucfranken2018-05-171-1/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Steps to reproduce Using Rails 5.2.0 When following this example: http://api.rubyonrails.org/classes/ActiveStorage/Variant.html `avatar.variant(resize: "100x100", monochrome: true, flip: "-90")` ### Expected behavior Image should be rendered as flipped. ### Actual behavior I get an error: > failed with error: gm mogrify: Unrecognized option (-90). ### Fix: According to: https://github.com/minimagick/minimagick the option should be called rotate: `avatar.variant(resize: "100x100", monochrome: true, rotate: "-90")` So **flip** changed to **rotate**. ### System configuration **Rails version**: 5.2.0 **Ruby version**: ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
* | | Remove unused `require "active_support/core_ext/string/filters"`Ryuta Kamizono2018-05-171-2/+0
| | |
* | | Add ActiveStorage::Previewer#tempdirGeorge Claghorn2018-05-161-1/+5
| | |
* | | Add missing block parametersGeorge Claghorn2018-05-162-2/+2
| | |
* | | Demonstrate ActiveStorage::Blob#open in the Active Storage guideGeorge Claghorn2018-05-161-42/+9
| | |
* | | Add ActiveStorage::Blob#openGeorge Claghorn2018-05-168-12/+81
| |/ |/| | | | | [David Robertson & George Claghorn]
* | Don't expose `SingularAssociation#replace` which is internal APIRyuta Kamizono2018-05-163-47/+44
|/ | | | | Originally `SingularAssociation#replace` abstract method is private, and doesn't intend to be called directly.
* Remove :nodoc: from the methods which is added the doc [ci skip]Ryuta Kamizono2018-05-151-4/+4
| | | | Follow up of #19171 and #26825.
* Merge pull request #32724 from nikolai-b/add_math_testRyuta Kamizono2018-05-152-9/+83
|\ | | | | Add math test
| * Add math testsNikolai B2018-05-142-9/+83
|/ | | | | | After #449 was merged math can be done on these nodes, adding a test file to unit test all the math operators.
* Merge pull request #32837 from ttanimichi/app-update-skip-springYuji Yaginuma2018-05-143-1/+17
|\ | | | | Don't generate `config/spring.rb` in `app:update` task when spring isn't loaded
| * Don't generate `config/spring.rb` in `app:update` task when spring isn't loadedTsukuru Tanimichi2018-05-133-1/+17
| |
* | Merge pull request #32876 from wata727/add_available_transformationsGeorge Claghorn2018-05-131-0/+3
|\ \ | | | | | | Add available transformations to docs
| * | Add available transformations to docs [ci skip]wata_mac2018-05-131-0/+3
| | | | | | | | | | | | `foreign_key`, `json` and `virtual` are also available.
* | | Fix `CustomCops/AssertNot` to allow it to have failure messageRyuta Kamizono2018-05-1345-143/+143
| | | | | | | | | | | | Follow up of #32605.
* | | Merge pull request #32878 from eugeneius/rm_rollback_active_record_stateRyuta Kamizono2018-05-131-14/+1
|\ \ \ | | | | | | | | Remove ActiveRecord::Transactions#rollback_active_record_state!
| * | | Remove ActiveRecord::Transactions#rollback_active_record_state!Eugene Kenny2018-05-131-14/+1
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `rollback_active_record_state!` was removed from `save!` but not `save` in da840d13da865331297d5287391231b1ed39721b. I believe that leaving it in `save` was a mistake, since that commit was intended to move the rollback logic from the `save`/`save!` call to the transaction stack. As of 67d8bb963d5d51fc644d6b1ca20164efb4cee6d7 the record's original state is lazily restored the first time it's accessed after the transaction, instead of when a rollback occurs. This means that the call to `restore_transaction_record_state` here has no effect: the record's transaction level is incremented twice (in rollback_active_record_state! and `with_transaction_returning_status`), isn't decremented again until the the `ensure` block runs, and won't hit zero until the next time `sync_with_transaction_state` is called.
* | | Merge pull request #32862 from eugeneius/callback_rollbackRyuta Kamizono2018-05-132-7/+13
|\ \ \ | |/ / |/| | Don't clear transaction state after manual rollback
| * | Don't clear transaction state after manual rollbackEugene Kenny2018-05-102-7/+13
| | | | | | | | | | | | | | | | | | | | | If an `ActiveRecord::Rollback` error was raised by a persistence method (e.g. in an `after_save` callback), this logic would potentially discard the original state of the record from before the transaction, preventing it from being restored later when the transaction was rolled back.