aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #32967 from javan/ast/jpg-video-previewsJavan Makhmali2018-05-233-7/+7
|\ | | | | Change Active Storage’s video preview format from PNG to JPG
| * Change video preview format from PNG to JPGJavan Makhmali2018-05-233-7/+7
|/
* Merge pull request #32882 from utilum/unnecessary_mockingEileen M. Uchitelle2018-05-235-39/+24
|\ | | | | remove unnecessary mocking in ActionCable tests
| * remove unnecessary mocking in ActionCable testsutilum2018-05-225-39/+24
| |
* | Fix RDoc formatting: `+` doesn't work with space [ci skip]yuuji.yaginuma2018-05-231-1/+1
| | | | | | | | Follow up of #32958.
* | Merge pull request #32822 from lxxxvi/improved_error_message_in_assert_changesRafael França2018-05-222-2/+4
|\ \ | | | | | | Clearer error message in assert_changes
| * | Clearer error message in assert_changeslxxxvi2018-05-052-2/+4
| | | | | | | | | | | | When `to:` is passed to `assert_changes`, it now prints the well-known `"Expected: x\n Actual: y"` message. Before, the message only contained the actual value.
* | | Merge pull request #32699 from printercu/patch-3Rafael França2018-05-221-1/+7
|\ \ \ | | | | | | | | Respect NODE_ENV when running `rails yarn:install`
| * | | Respect NODE_ENV when running `rails yarn:install`printercu2018-04-231-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | `yarn install --prod` removes dev deps, so it's impossible to run `assets:precompile` with dev npm dependencies. This change makes rake task pass NODE_ENV to yarn when explicitly set.
* | | | Merge pull request #32851 from yskkin/doc_require_dependencyRafael França2018-05-221-0/+4
|\ \ \ \ | | | | | | | | | | Document require_dependency [ci skip]
| * | | | Document require_dependency [ci skip]Yoshiyuki Kinjo2018-05-091-0/+4
| | | | |
* | | | | 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
| | | | | |
* | | | | | Merge pull request #32958 from frewsxcv/patch-1Rafael França2018-05-221-1/+1
|\ \ \ \ \ \ | | | | | | | | | | | | | | Indicate `true` in a doc comment is code-like.
| * | | | | | Indicate `true` in a doc comment is code-like.Corey Farwell2018-05-221-1/+1
|/ / / / / /
* | | | | | Bump minimum version of Thor to 0.19.0Guillermo Iguaran2018-05-222-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Thor 0.18 is causing failures in all the generator tests.
* | | | | | Merge pull request #32825 from utilum/fewer_tt.eclosure_callsRafael França2018-05-221-2/+0
|\ \ \ \ \ \ | | | | | | | | | | | | | | FIX: tt.eclosure is not needed for the GTG
| * | | | | | Remove 7 years old note-to-self by tenderloveutilum2018-05-221-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduced in rails/journey@a806beb [ci skip]
* | | | | | | Rollback parent transaction when children fails to update (#32796)Guillaume Malette2018-05-223-2/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Rollback parent transaction when children fails to update Rails supports autosave associations on the owner of a `has_many` relationship. In certain situation, if the children of the association fail to save, the parent is not rolled back. ```ruby class Employee < ActiveRecord::Base end class Company < ActiveRecord::Base has_many(:employees) end company = Company.new employee = company.employees.new company.save ``` In the previous example, if the Employee failed to save, the Company will not be rolled back. It will remain in the database with no associated Employee. I expect the `company.save` call to be atomic, and either create all or none of the records. The persistance of the Company already starts a transaction that nests it's children. However, it didn't track the success or failure of it's children in this very situation, and the outermost transaction is not rolled back. This PR makes the change to track the success of the child insertion and rollback the parent if any of the children fail. * Change the test to reflect what we expect Once #32862 is merged, rolling back a record will rollback it's state to match the state before the database changes were applied * Use only the public API to express the tests * Refactor to avoid reassigning saved for nested reflections [Guillaume Malette + Rafael Mendonça França]
* | | | | | | Merge pull request #32934 from aki77/fix-locale-selectorRafael França2018-05-221-7/+10
|\ \ \ \ \ \ \ | |/ / / / / / |/| | | | | | Fix locale selector to email preview
| * | | | | | Fix locale selectoraki2018-05-191-7/+10
| | | | | | |
* | | | | | | Merge pull request #32865 from yahonda/another_31988Rafael França2018-05-222-5/+56
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Disable foreign keys during `alter_table` for sqlite3 adapter
| * | | | | | | Disable foreign keys during `alter_table` for sqlite3 adapterYasuo Honda2018-05-222-5/+56
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Unlike other databases, changing SQLite3 table definitions need to create a temporary table. While changing table operations, the original table needs dropped which caused `SQLite3::ConstraintException: FOREIGN KEY constraint failed` if the table is referenced by foreign keys. This pull request disables foreign keys by `disable_referential_integrity`. Also `disable_referential_integrity` method needs to execute `defer_foreign_keys = ON` to defer re-enabling foreign keys until the transaction is committed. https://www.sqlite.org/pragma.html#pragma_defer_foreign_keys Fixes #31988 - This `defer_foreign_keys = ON` has been supported since SQLite 3.8.0 https://www.sqlite.org/releaselog/3_8_0.html and Rails 6 requires SQLite 3.8 #32923 now - <Models>.reset_column_information added to address `ActiveModel::UnknownAttributeError` ``` Error: ActiveRecord::Migration::ForeignKeyChangeColumnTest#test_change_column_of_parent_table: ActiveModel::UnknownAttributeError: unknown attribute 'name' for ActiveRecord::Migration::ForeignKeyChangeColumnTest::Post. ```
* | | | | | | | Merge pull request #32938 from utilum/range_case_equalityRafael França2018-05-225-30/+91
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | Allow Range#=== and Range#cover? on Range
| * | | | | | | | add CHANGELOG/Docutilum2018-05-222-7/+23
| | | | | | | | |
| * | | | | | | | 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 #32931 from jeremyevans/fast-xorRafael França2018-05-221-3/+8
|\ \ \ \ \ \ \ \ | |/ / / / / / / |/| | | | | | | Speed up xor_byte_strings by 70%
| * | | | | | | Speed up xor_byte_strings by 70%Jeremy Evans2018-05-181-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Benchmark: ```ruby require 'benchmark' require 'benchmark/ips' require 'securerandom' def xor_byte_strings(s1, s2) # :doc: s2_bytes = s2.bytes s1.each_byte.with_index { |c1, i| s2_bytes[i] ^= c1 } s2_bytes.pack("C*") end def xor_byte_strings_new(s1, s2) # :doc: s2 = s2.dup size = s1.bytesize i = 0 while i < size s2.setbyte(i, s1.getbyte(i) ^ s2.getbyte(i)) i += 1 end s2 end s1 = SecureRandom.random_bytes(32) s2 = SecureRandom.random_bytes(32) Benchmark.ips do |x| x.report("current"){xor_byte_strings(s1, s2)} x.report("new"){xor_byte_strings_new(s1, s2)} x.compare! end 100000.times do |i| s3 = SecureRandom.random_bytes(32) s4 = SecureRandom.random_bytes(32) raise unless xor_byte_strings(s3, s4) == xor_byte_strings_new(s3, s4) end ``` Results on ruby 2.5.1: ``` Warming up -------------------------------------- current 6.519k i/100ms new 10.508k i/100ms Calculating ------------------------------------- current 84.723k (_ 0.4%) i/s - 423.735k in 5.001456s new 145.871k (_ 0.3%) i/s - 735.560k in 5.042606s Comparison: new: 145870.6 i/s current: 84723.4 i/s - 1.72x slower ```
* | | | | | | | 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
| | | | | |