Commit Graph

69071 Commits

Author SHA1 Message Date
utilum
acca10d8ef Update et-orbi to latest version
avoids `warning: assigned but unused variable - tu`.
2018-05-28 09:37:20 +02:00
yuuji.yaginuma
36390b6bdc Remove unnecessary with_default_enforce_utf8 method
Because the same method is defined in `FormWithTest` of the parent class.
fe9547b6fb/actionview/test/template/form_helper/form_with_test.rb (L19..L26)
2018-05-28 11:08:09 +09:00
Ryuta Kamizono
fe9547b6fb Parse raw value only when a value came from user in numericality validator
Since `parse_raw_value_as_a_number` may not always parse raw value from
database as a number without type casting (e.g. "$150.55" as money
format).

Fixes #32531.
2018-05-28 10:12:15 +09:00
Ryuta Kamizono
17bf62033e Fix that association's after_touch is not called with counter cache
Since #31405, using `#increment!` with touch option instead of `#touch`
to touch belongs_to association if counter cache is enabled. It caused
the regression since `#increment!` won't invoke after_touch callbacks
even if touch option is given.
To fix the regression, make `#increment!` invokes after_touch callbacks
if touch option is given.

Fixes #31559.
Fixes #32408.
2018-05-27 12:06:58 +09:00
Ryuta Kamizono
ced783fe74 Fix inconsistent touching behavior between assigning and unassigning
On belongs_to with `touch: true` association, unassigned object is
caused touching, but assigned object is not touched.

And also, if primary key is customized, it will touch against the wrong
target looked up by the customized key as primary key.

This change ensures correctly touching consistently between assigning
and unassigning.
2018-05-27 09:28:27 +09:00
Ryuta Kamizono
6349ad300f Fix belongs_to_counter_cache_after_update to respect polymorphic type change 2018-05-27 02:33:47 +09:00
Ryuta Kamizono
cbab69c278 Avoid a subquery in updating counter cache
Since UPDATE with a subquery doesn't work on MySQL.
2018-05-26 16:21:03 +09:00
Ryuta Kamizono
7ac5b9e848 Fix belongs_to_counter_cache_after_update to respect custom primary key counter
If belongs_to primary key is customized, the callback will update
counters against the wrong target looked up by the customized key as
primary key.
We need to convert the customized key into an object that can be
referred to as primary key.
2018-05-26 15:04:41 +09:00
Ryuta Kamizono
e34c2050e9 Fix different_target? to respect custom primary key counter 2018-05-26 11:56:32 +09:00
Ryuta Kamizono
6edf354b65 Eager loading won't mutate owner record
Since #31575, `BelongsToAssociation#target=` replaces owner record's
foreign key to fix an inverse association bug.

But the method is not only used for inverse association but also used
for eager loading/preloading, it caused some public behavior changes
(#32338, #32375).

To avoid any side-effect in loading associations, I reverted the
overriding `#target=`, then introduced `#inversed_from` to replace
foreign key in `set_inverse_instance`.

Closes #32375.
2018-05-25 23:57:09 +09:00
Ryuta Kamizono
8a60018355 Make force equality checking more strictly not to allow serialized attribute
Since #26074, introduced force equality checking to build a predicate
consistently for both `find` and `create` (fixes #27313).

But the assumption that only array/range attribute have subtype was
wrong. We need to make force equality checking more strictly not to
allow serialized attribute.

Fixes #32761.
2018-05-25 23:55:38 +09:00
George Claghorn
cd4a88123d
Merge pull request #32982 from ruralocity/update-dateandtime-calculations-docs
Improve grammar for DateAndTime before? and after? calculations [ci skip]
2018-05-24 19:00:09 -04:00
Aaron Sumner
a2a3fa8d7d Improve grammar for DateAndTime before? and after? calculations [ci skip] 2018-05-24 15:42:08 -07:00
Ryuta Kamizono
f6ae74ca95
Merge pull request #32979 from eugeneius/stale_comment
Update stale issue comment to mention 5-2-stable
2018-05-25 07:29:58 +09:00
Eugene Kenny
472f24e22f Update stale issue comment to mention 5-2-stable
5-2-stable is the release series that currently receives bug fixes.
2018-05-24 23:23:30 +01:00
Guillermo Iguaran
c31317bd16
Merge pull request #32976 from oamado/fix_doc_broken_link
update README link: md instead rdoc
2018-05-24 10:55:22 -05:00
Oscar Amado
ef90adfd27 update README link: md instead rdoc [ci skip] 2018-05-24 17:49:35 +02:00
Guillermo Iguaran
3f2afd4d23
Merge pull request #32975 from oamado/fix_activejob_doc
correct link to activejob readme [ci skip]
2018-05-24 09:46:45 -05:00
Oscar Amado
d795e94c45 correct link to activejob readme [ci skip] 2018-05-24 16:39:38 +02:00
George Claghorn
097650c194
Merge pull request #32968 from utilum/shadowing_outer_variable
Avoid 2.6 warning: shadowing outer local variable - list
2018-05-23 21:56:33 -04:00
utilum
f6f8fc2ca0 Avoid 2.6 warning: shadowing outer local variable - list 2018-05-23 23:48:32 +02:00
Rafael Mendonça França
49df9043c6
Merge pull request #30406 from eliotsykes/reduce-spring-watch-calls
Minimize Spring.watch calls
2018-05-23 17:26:09 -04:00
Rafael França
2e6e8142a2
Merge pull request #32969 from utilum/enable_warnings
Enable warnings in all test tasks
2018-05-23 17:15:02 -04:00
utilum
a48f6a5d9f Enable warnings in all test tasks
Also normalize AJ task use t, like all other Rails test tasks.
2018-05-23 23:05:03 +02:00
Samuel Cochran
4d43b05881 Eager autoload mail gem when eager load is true (#32808)
* Eager autoload mail gem when eager load is true

We had a production issue where our Sidekiq worker threads all became
deadlocked while autoloading a file within the mail gem, required via
ActionMailer, despite setting our Rails applicaiton to eager load.
`Mail.eager_autoload!` exists and works great, ActionMailer just doesn't
call it during eager loading. Adding it to the ActionMailer Railtie's
eager_load_namespaces takes care of calling `Mail.eager_autoload!`
during the `eager_load!` initializer.

* 'Mail' isn't defined yet, use before_eager_load instead

* Make sure mail is loaded

* Move eager load of Mail into ActionMailer.eager_load!

[Samuel Cochran + Rafael Mendonça França]
2018-05-23 16:50:36 -04:00
Javan Makhmali
78a9de52dd
Merge pull request #32967 from javan/ast/jpg-video-previews
Change Active Storage’s video preview format from PNG to JPG
2018-05-23 16:24:08 -04:00
Javan Makhmali
b60ee86d94 Change video preview format from PNG to JPG 2018-05-23 14:32:34 -04:00
Eileen M. Uchitelle
70bd858af0
Merge pull request #32882 from utilum/unnecessary_mocking
remove unnecessary mocking in ActionCable tests
2018-05-23 08:45:06 -07:00
yuuji.yaginuma
2f76256127 Fix RDoc formatting: + doesn't work with space [ci skip]
Follow up of #32958.
2018-05-23 08:12:20 +09:00
Rafael França
be43b1f6de
Merge pull request #32822 from lxxxvi/improved_error_message_in_assert_changes
Clearer error message in assert_changes
2018-05-22 18:17:11 -04:00
Rafael França
9480618f06
Merge pull request #32699 from printercu/patch-3
Respect NODE_ENV when running `rails yarn:install`
2018-05-22 17:48:57 -04:00
Rafael França
2b2bf2c73b
Merge pull request #32851 from yskkin/doc_require_dependency
Document require_dependency [ci skip]
2018-05-22 17:47:06 -04:00
George Claghorn
bdd8b6843c
Merge pull request #32144 from kazu9su/master
Add ActiveStorage::Service::DiskService#url_for_direct_upload test
2018-05-22 17:34:19 -04:00
Rafael França
96c02b58f3
Merge pull request #32958 from frewsxcv/patch-1
Indicate `true` in a doc comment is code-like.
2018-05-22 17:32:24 -04:00
Corey Farwell
0077462be0
Indicate true in a doc comment is code-like. 2018-05-22 17:24:33 -04:00
Guillermo Iguaran
e10fd57e98 Bump minimum version of Thor to 0.19.0
Thor 0.18 is causing failures in all the generator tests.
2018-05-22 15:58:35 -05:00
Rafael França
e6519f95da
Merge pull request #32825 from utilum/fewer_tt.eclosure_calls
FIX: tt.eclosure is not needed for the GTG
2018-05-22 16:53:40 -04:00
Guillaume Malette
976ef40aef Rollback parent transaction when children fails to update (#32796)
* 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]
2018-05-22 15:58:22 -04:00
utilum
0428ed8067 Remove 7 years old note-to-self by tenderlove
Introduced in rails/journey@a806beb

[ci skip]
2018-05-22 21:55:41 +02:00
Rafael França
9385a5b585
Merge pull request #32934 from aki77/fix-locale-selector
Fix locale selector to email preview
2018-05-22 15:13:29 -04:00
Rafael França
09f26ed9da
Merge pull request #32865 from yahonda/another_31988
Disable foreign keys during `alter_table` for sqlite3 adapter
2018-05-22 14:23:38 -04:00
Rafael França
fa9d01d7dd
Merge pull request #32938 from utilum/range_case_equality
Allow Range#=== and Range#cover? on Range
2018-05-22 14:14:56 -04:00
Rafael França
7ee898ca18
Merge pull request #32931 from jeremyevans/fast-xor
Speed up xor_byte_strings by 70%
2018-05-22 13:14:27 -04:00
utilum
e04a79e772 add CHANGELOG/Doc 2018-05-22 15:56:36 +02:00
utilum
0fcb921a65 Allow Range#=== and Range#cover? on Range
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*
2018-05-22 14:38:19 +02:00
Yasuo Honda
45881b0a64 Disable foreign keys during alter_table for sqlite3 adapter
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.
```
2018-05-22 02:08:08 +00:00
utilum
78288f75e1 remove unnecessary mocking in ActionCable tests 2018-05-22 02:29:18 +02:00
George Claghorn
6c574ac589
Merge pull request #32936 from jacobsmith/image-variant-allow-disabling-options
[ActiveStorage] Disable variant options when false or nil present
2018-05-21 11:49:22 -04:00
Kasper Timm Hansen
41147e3ef8
Merge pull request #32523 from kaspth/enumerable-index-with-extension
Add Enumerable#index_with.
2018-05-21 17:46:48 +02:00
Kasper Timm Hansen
429f15ff7f
[ci skip] Add documentation/changelog entry. 2018-05-21 17:46:05 +02:00