Commit Graph

77976 Commits

Author SHA1 Message Date
Sam Bostock
f50be302de
Add tests for :mem_cache_store initialization
This documents existing behavior ahead of changes.
2020-10-20 22:53:57 -04:00
Sam Bostock
944574872f
Refactor MemCacheStoreTest
- Remove unused instance variable
- Add client test helper
2020-10-20 22:53:26 -04:00
Eugene Kenny
0a608bd987
Merge pull request #36481 from guillaumebriday/master
Add values_at attribute method for active_record
2020-10-19 17:31:59 +01:00
Guillaume Briday
458fff60ce Add values_at attribute method for active_record 2020-10-19 17:15:02 +01:00
Eugene Kenny
871073c4a9
Merge pull request #40395 from marcelolx/fix_read_attribute_before_type_cast_for_aliased_attributes
Fix `read_attribute_before_type_cast` to consider attribute aliases
2020-10-19 01:06:18 +01:00
Marcelo Lauxen
5fdc7d385f Fix read_attribute_before_type_cast to consider attribute aliases
Numericality validations for aliased attributes are not able
to get the value of the attribute before type cast because
activerecord was trying to get the value of the attribute based
on attribute alias name and not the original attribute name.

Example of validation which would pass even if a invalid value
would be provided

    class MyModel < ActiveRecord::Base
      validates :aliased_balance, numericality: { greater_than_or_equal_to: 0 }
    end

If we instantiate MyModel like bellow it will be valid because
when numericality validation runs it will not be able to get the
value before type cast, so it uses the type casted value
which will be `0.0` and the validation will match.

    subject = MyModel.new(aliased_balance: "abcd")
    subject.valid?

But if we declare MyModel like this

    class MyModel < ActiveRecord::Base
      validates :balance, numericality: { greater_than_or_equal_to: 0 }
    end

and assign "abcd" value to `balance` when the validations
run the model will be invalid because activerecord will be able
to get the value before type cast.

With this change `read_attribute_before_type_cast` will be able to
get the value before type cast even when the attr_name is an
attribute_alias.
2020-10-18 20:32:47 -03:00
Eugene Kenny
28a4d97331
Merge pull request #40371 from shouichi/document-transform-event
Document transform.active_storage event [ci skip]
2020-10-18 19:52:18 +01:00
Gannon McGibbon
bd90ed1630
Merge pull request #40379 from dmitry/40378-adds-same-record-on-build
Prevent adding the same record twice on build when using source record in attribute when using has_many_inversing  #40378
2020-10-16 18:10:02 -04:00
Kasper Timm Hansen
d83ee61dc6
Merge pull request #40396 from p8/docs-without-frames-with-turbolinks
Replace frames-based api docs with css implementation and Turbolinks
2020-10-16 17:24:36 +02:00
Petrik
edff55987a Replace frames-based api docs with css implementation and Turbolinks
The current Rails documentation has a frames based implementation. This
prevents deep linking to documentation and removes navigation if the page
is opened without frames.

We can keep the same layout with a css based implementation.

Turbolinks is used to persisted the navigation/search bar across
requests.
2020-10-16 12:24:09 +02:00
Ryuta Kamizono
4194565ddf Remove .DS_Store 2020-10-16 15:23:45 +09:00
Eugene Kenny
7cf8e30902 Work around getaddrinfo deadlock in forked process
See https://bugs.ruby-lang.org/issues/17220.

This will prevent every CI run from getting stuck and eventually timing
out after 30 minutes.
2020-10-16 01:00:12 +01:00
John Hawthorn
64b1c81532
Merge pull request #40387 from jhawthorn/exists_on_contradiction
Avoid query from exists? on contradictory relation
2020-10-15 11:06:54 -07:00
Rafael França
e28090be2b
Merge pull request #40383 from Shopify/changed-in-place-encoding
Handle binary strings in Active Record serialized columns
2020-10-15 13:55:31 -04:00
Jonathan Hefner
2df6d44ddd
Merge pull request #40393 from SUMAR7/patch-1
Update active_record_querying.md [ci-skip]
2020-10-15 09:30:45 -05:00
Sajjad Umar
fc0280669c
Update active_record_querying.md
Fixed a typo in enums comment
2020-10-15 18:55:03 +05:00
Eileen M. Uchitelle
b5b078cd99
Merge pull request #39869 from joelhawksley/render_in-layout
Include layout when rendering objects from controllers
2020-10-14 16:03:55 -04:00
John Hawthorn
3b622bc0d6 Avoid query from exists? on contradictory relation
Co-authored-by: Adam Hess <HParker@github.com>
2020-10-14 12:30:10 -07:00
Joel Hawksley
136b814144 Include layout when rendering objects from controllers
In https://github.com/rails/rails/pull/37919, support
for rendering objects that respond_to render_in in
controllers was added. However, the implementation
did not support layouts.

This change updates the implementation from #37919
to more closely match the rest of the
ActionView::Template classes, enabling the use of layouts.

Co-authored-by: Felipe Sateler <fsateler@gmail.com>
2020-10-14 11:49:45 -06:00
Eugene Kenny
c9357cd3e3
Merge pull request #39770 from Shopify/as-cache-coder
Make AS::Cache coder configurable
2020-10-14 11:34:09 +01:00
Jean Boussier
c4845aa779 Make AS::Cache coder configurable 2020-10-14 12:12:36 +02:00
Jean Boussier
d6929e5a09 Handle binary strings in Active Record serialized columns
Serialized attributes stored in BLOB columns will be loaded
with the `ASCII-8BIT` (AKA BINARY) encoding.

So unless the serialized payload is pure ASCII, they need
to have the same internal encoding to be properly compared.

Since the serializer have no way to know how the string will
be stored, it's up to the column type to properly set the
encoding.
2020-10-14 11:57:34 +02:00
Shouichi Kamiya
d394d7f99f Document transform.active_storage event [ci skip] 2020-10-14 16:27:52 +09:00
Eugene Kenny
55badbba3b Skip PostgreSQL interval tests on other adapters
Also remove an unnecessary magic encoding comment.
2020-10-13 21:08:40 +01:00
Eugene Kenny
5f17d2dd66
Merge pull request #40380 from cgriego/patch-2
Add missing ActiveSupport require in ActiveModel::Serialization
2020-10-13 20:52:57 +01:00
Chris Griego
5fe517563e
Add missing ActiveSupport require in ActiveModel::Serialization
serializable_attributes is using index_with from active_support/core_ext/enumerable
2020-10-13 14:30:24 -05:00
Jonathan Hefner
162f96917c
Merge pull request #40312 from p8/guides/fix-small-typos
Fix small typos in the guides [skip ci]
2020-10-13 11:58:11 -05:00
Jonathan Hefner
5c3a59fded
Merge pull request #39753 from p8/guides/remove-form-helpers-from-av-helpers
Remove duplicate FormHelpers from ActionView Helpers guide [ci skip]
2020-10-13 11:55:34 -05:00
Jonathan Hefner
3d82ed1b5a
Merge pull request #40377 from jonathanhefner/guide-form_helpers-_tag-helpers
Mention _tag helpers in Form Helpers guide [ci-skip]
2020-10-13 11:53:21 -05:00
Jonathan Hefner
93391a7468
Merge pull request #40339 from jonathanhefner/guide-form_helpers-grouped-options
Add Option Groups section to Form Helpers guide [ci-skip]
2020-10-13 11:52:33 -05:00
dmitry
50e4aaaf25
Prevent adding the same record twice on build when using source record in attribute when using has_many_inversing #40378
Record should be replaced via add_to_target, not added as a separate record to an array.
2020-10-13 19:24:02 +03:00
Jonathan Hefner
140cf5c9fe Mention _tag helpers in Form Helpers guide [ci-skip]
This adds mention of the `*_tag` helpers provided by `FormTagHelper`,
and directs the reader to the API documentation for more information.
2020-10-13 10:47:31 -05:00
Eileen M. Uchitelle
2e8ca04906
Merge pull request #40366 from tgxworld/fix_flaky_advisory_lock_test
Fix flaky advisory lock test.
2020-10-13 09:09:22 -04:00
Eileen M. Uchitelle
9660f2a986
Merge pull request #40372 from alexrs/patch-1
Stable sorting for DatabaseConfigurations#find_db_config
2020-10-13 08:51:11 -04:00
Alejandro Rodríguez Salamanca
fae2df5f54 Update database_configurations.rb 2020-10-13 09:43:12 +01:00
Guo Xiang Tan
d2215580d8
Fix flaky advisory lock test.
Random failures due to active connection checking within the
assert_no_changes block.

Failure:
MigrationTest#test_with_advisory_lock_closes_connection [/rails/activerecord/test/cases/migration_test.rb:947]:
--- expected
+++ actual
@@ -1 +1 @@
-["SELECT 1", "SELECT 1"]
+["SELECT 1", "SELECT 1", "SELECT 1"]

This commit scopes the query down further to ensure that the advisory
unlock query is not left in pg_stat_activity which is an indication that
the connection pool was not disconnected.
2020-10-13 09:02:09 +08:00
Akira Matsuda
5699122abf Revert "*Store implements delete_session as a public method"
This reverts commit d41939a678290c773f9a5275a4aed772b4707f06.

Reason: activerecord-session_store implements `delete_session` as a private method
https://github.com/rails/activerecord-session_store/blob/f188efb/lib/action_dispatch/session/active_record_store.rb#L94

Thank you @al for pointing this out!
https://github.com/rails/rails/commit/d41939a6#commitcomment-43152220

Co-authored-by: Alan Larkin <alan.larkin@gmail.com>
2020-10-12 09:16:39 +09:00
Petrik
e278b21ff5 Fix small typos in the guides [skip ci] 2020-10-11 10:33:23 +02:00
Eileen M. Uchitelle
83912c88bf
Merge pull request #40296 from kylerdmoore/patch-1
Add resource to Naming Routes override example
2020-10-10 12:43:43 -04:00
Rafael França
2b1a400656
Merge pull request #39784 from marcrohloff/remove-magic-parameter-from-where
Remove the magic `:chain` parameter from `Relation#where`
2020-10-09 17:50:58 -04:00
Rafael França
f88df82a87
Merge pull request #40359 from weiserma/patch-1
Update action_text_overview.md
2020-10-09 16:30:44 -04:00
Xavier Noria
18de2ec9fa edits in the constants guide [skip ci] 2020-10-09 20:18:45 +02:00
Xavier Noria
08c1f4da0b documents differences zeitwerk vs classic mode [skip ci] 2020-10-09 20:06:39 +02:00
Xavier Noria
ff80d7708d Fixes case in guides title [skip ci] 2020-10-09 19:03:53 +02:00
weiserma
2cfdf71872
Update action_text_overview.md
Added additional overview in n+1 queries that the scope is named with the rich text field name.
2020-10-09 11:23:06 -04:00
Rafael França
9492339979
Merge pull request #38443 from jonathanhefner/plugin-fix-stack-traces
Fix stack traces when testing plugins
2020-10-08 19:06:40 -04:00
Rafael França
b4524f44dd
Merge pull request #40357 from jonathanhefner/guide-form_helpers-date-time
Rework Date and Time Form Helpers section [ci-skip]
2020-10-08 18:51:32 -04:00
Jonathan Hefner
a6c426d986 Rework Date and Time Form Helpers section [ci-skip]
This shifts the primary focus from the bare `select_*` helpers to the
equivalent `FormBuilder#*_select` helpers.  It also links all covered
helpers to their API documentation.
2020-10-08 16:33:14 -05:00
Eugene Kenny
e44b3419d4 Prefix keys in Active Storage service test
Otherwise this test fails when run concurrently.

https://buildkite.com/rails/rails/builds/71999#77923632-f943-4fa0-b478-0af38001c22b/1032-1098
https://buildkite.com/rails/rails/builds/71999#01fdec79-dc1f-4a6a-b730-ac0df134a2e7/970-1062
2020-10-07 21:47:59 +01:00
Jonathan Hefner
33fdae0584 Fix backtraces for generated plugin tests
`Minitest.plugin_rails_init` sets `Minitest.backtrace_filter` to
`Rails.backtrace_cleaner` right before tests are run, overwriting the
value set in test_helper.rb.

`Rails.backtrace_cleaner` silences backtrace lines that do not start
with `Rails.root` followed by e.g. "lib/" or "test/".  Thus when
`Rails.root` is a subdirectory of the project directory -- for example,
when testing a plugin that has a dummy app -- all lines of the backtrace
are silenced.

This commit adds a fallback such that when all backtrace lines are
silenced, the original `Minitest.backtrace_filter` is used instead.

Additionally, this commit refactors and expands existing test coverage.
2020-10-07 15:40:56 -05:00