Commit Graph

81624 Commits

Author SHA1 Message Date
Rafael França
ddaf3b2cb3
Merge pull request #42574 from leastbad/connection_identifier
add connection_identifier to ConnectionStub
2021-09-23 19:19:07 -04:00
Rafael França
78e7a7f6b7
Merge pull request #43224 from jmileham/with_lock_accepts_transaction_opts
Accept optional transaction args to #with_lock
2021-09-23 19:08:10 -04:00
John Mileham
b5e670a9dd Accept optional transaction args to #with_lock
Make #with_lock as expressive as calling #transaction and #lock!
individually to enable behavior like so:

    person.with_lock("FOR UPDATE NOWAIT", requires_new: true) do
      ...
    end

Helps teams who prefer #with_lock over #lock! to ensure the lock is
taken out within a transaction, even when advanced transaction control
is required without requiring redundant transaction blocks.
2021-09-23 09:43:00 -04:00
Rafael Mendonça França
6d42731ded
Merge PR #41487 2021-09-22 18:43:16 -04:00
Rafael França
aa449a89df
Merge pull request #43280 from ryanfb/hidden_autocomplete_off
Add autocomplete="off" to all generated hidden fields (fixes #42610)
2021-09-22 18:20:52 -04:00
Rafael Mendonça França
b2db4c78a4
Merge PR #42840 2021-09-22 18:11:40 -04:00
Rafael França
6aeeb0c6ba
Merge pull request #42227 from ghiculescu/as-invalid-defaults
Active Storage: deprecate invalid default content types
2021-09-22 18:04:03 -04:00
Rafael França
31b4824744
Merge pull request #41469 from ghiculescu/postgres-enum
PostgreSQL: support custom enum types
2021-09-22 17:48:17 -04:00
Alex Ghiculescu
550d728bd1 Active Storage: incorrect defaults
https://github.com/rails/rails/pull/42225 identified that some of the content types used as defaults by Active Storage aren't recognized by `mini_mime`. This means that in practice code like [this](https://github.com/rails/rails/pull/42225/files#diff-7a3ec24c556b138abdbd67066ab5125b73528e45891d83142e417d3944194128R116) will crash or not function correctly. In [this](https://github.com/rails/rails/pull/42225/files#diff-c2010824d2d2e8d841ff4fc058c264c12d870e893025b153e6de571fba6b6c6cR194) example, a file with content_type `image/jpg` is treated as a PNG by the representer, since `image/jpg` isn't a valid content type according to `mini_mime`.

I don't think the default content_types should include formats that have never actually worked, so I'm proposing we remove them from the defaults.
2021-09-22 16:38:52 -05:00
Alex Ghiculescu
4eef348584 PostgreSQL: support custom enum types
Something I've seen on many Rails + PostgreSQL apps is that the only reason `structure.sql` is used instead of `schema.rb` is to support custom [enum types](https://www.postgresql.org/docs/current/datatype-enum.html). Enum types are great for type integrity and they work well with [`ActiveRecord::Enum`](https://api.rubyonrails.org/classes/ActiveRecord/Enum.html). And schema.rb is much easier to use than structure.sql. It would be great if more PostgreSQL projects could use schema.rb. To enable that, this PR adds native support for PostgreSQL enums in schema.rb.

In migrations, you can now use `create_enum` to add a new enum type, and `t.enum` to add a column:

```ruby
def up
  # note that enums cannot be dropped
  create_enum :mood, ["happy", "sad"]

  change_table :cats do |t|
    t.enum :current_mood, enum_type: "mood", default: "happy", null: false
  end
end
```

The enum definitions and enum columns will be presented in schema.rb, so you can load them into a test database and they'll work correctly.

-------------------------------

It's worth noting again that this is *not* compatible with other database engines. So this will not work with `rails db:system:change` (or the equivalent manual process). My assumption is that this is a fairly unlikely thing to happen midway through a project - as opposed to when the app is first spun up - so it's safe to assume that once you've dug into using enums you probably aren't going to switch databases on a whim.

For what it's worth, the MySQL adapter also supports enums (https://github.com/rails/rails/blob/main/activerecord/test/cases/adapters/mysql2/enum_test.rb) but the syntax doesn't look easy to translate (I also don't have much MySQL experience so don't really want to wade into this).
2021-09-22 16:34:10 -05:00
Rafael França
581b9fca69
Merge pull request #43290 from michaelkirk/mkirk/password-hashing-docs
docs: passwords are *hashed*, not "encrypted"
2021-09-22 16:08:35 -04:00
Rafael Mendonça França
db94a22b08
Fix codespaces precache action 2021-09-22 13:34:27 -04:00
Rafael Mendonça França
0cfee597e4
Setup codespaces prebuild tasks 2021-09-22 13:31:58 -04:00
Michael Kirk
e6e052d2db docs: passwords are *hashed*, not "encrypted"
"encrypted" implies *symmetrically (reversibly)* encrypted, using something like AES.

e.g. see the other usages of "encrypt" in this security doc:

    > unencrypted wireless LAN
    > Rails encrypts cookies by default
    > For more details on key rotation with encrypted and signed messages
    > Rails stores secrets in `config/credentials.yml.enc`, which is
      encrypted and hence cannot be edited directly

All of these usages are referring to symmetric encryption.

Additionally, all three of the referenced implementations (devise,
authlogic, and rails' own has_secure_password), use password _hashing_
not a symmetric encryption.

[Authlogic notes this](0cdd582ba5/lib/authlogic/acts_as_authentic/password.rb (L105))

> Reversible functions like AES256 are the worst choice, and we no longer support them.

Alternatively, I'd be fine with doubling down on the term "digest" if
there's a strong preference for that instead of "hash". From my
perspective they're synonyms, and equally distinct from "encrypt".

Internally the [Rails has_secure_password
implementation](83217025a1/activemodel/lib/active_model/secure_password.rb (L7))
refers to both "hash" and "digest".
2021-09-22 17:24:14 +01:00
Jonathan Hefner
4e35354917
Merge pull request #43286 from soartec-lab/task/fix-document-for-activerecord-uniqueness-validate
Fixed guide to `case_sensitive` option for Activerecord uniqueness validator [skip ci]
2021-09-22 10:31:24 -05:00
soartec-lab
613b9ae855 Fixed guide to case_sensitive option for Activerecord uniqueness validator [skip ci] 2021-09-23 00:20:39 +09:00
Xavier Noria
e44ce53f78 Depend on Zeitwerk 2.5.0.beta4 2021-09-22 08:47:21 +02:00
Ryan Baumann
58127ec6d5 Fix tests for actiontext with hidden inputs defaulting to autocomplete="off" 2021-09-21 21:16:01 -04:00
Rafael Mendonça França
860f59b5e1
Merge PR #42872 2021-09-21 18:59:40 -04:00
Rafael Mendonça França
8e86e87219
Merge PR #42234 2021-09-21 18:54:48 -04:00
Rafael França
1cc7e699f4
Merge pull request #43276 from camilamaia/43275
Add missing migrate command to Getting Started Guide section 8.3
2021-09-21 18:49:44 -04:00
Rafael França
1eab3324f0
Merge pull request #43278 from jjb/patch-2
specify how to enable zeitwerk by itself
2021-09-21 18:49:35 -04:00
Rafael França
8f9f7e7ca4
Merge pull request #42864 from hahmed/ha/new-rails-api-app-errors-on-welcome-controller
Fixes DisabledSessionError with new rails api app
2021-09-21 18:46:49 -04:00
Rafael França
02537722f3
Merge pull request #42970 from thutterer/email_address_with_blank_name
Return just the address if name is blank
2021-09-21 18:41:19 -04:00
Rafael Mendonça França
eed30a0c33
Fix test in isolation
The test was calling `auth_param` that then called `second` in an array,
but that method was not being required.
2021-09-21 18:40:18 -04:00
John Bachir
1a54c1871d specify how to configure zeitwerk by itself
there's also related docs further down in the doc

https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#how-to-use-the-classic-autoloader-in-rails-6
2021-09-21 23:35:19 +01:00
Rafael França
30e54b8622
Merge pull request #43104 from ghiculescu/http-406-crash
Fix crash in `ActionController::Instrumentation` with invalid HTTP formats
2021-09-21 17:59:49 -04:00
Rafael França
ce72a8a5a7
Merge pull request #43273 from p8/actionpack/add-fallback-host-for-rack-system-tests
Add fallback host for SystemTestCase driven by RackTest
2021-09-21 17:56:05 -04:00
Rafael Mendonça França
eb04c7f61c Start the mariadb service in the dev container
Signed-off-by: GitHub <noreply@github.com>
2021-09-21 21:04:43 +00:00
Ryan Baumann
168170ff14 Add autocomplete="off" to all generated hidden fields (fixes #42610) 2021-09-21 15:57:56 -04:00
Petrik
4b78325a12 Add fallback host for SystemTestCase driven by RackTest
For links to work in SystemTestCases, it requires the `host` to be added
to the `default_url_options`. Since
78c734386cddf5ee533ad1915d3769b9cc1be3a2 this is done by looking at
`Capybara.app_host` or `Capybara.current_session.server_url`.

This works correctly when using the Selenium webdriver, as Capybara sets
either the `Capybara.app_host` or the `Capybara.current_session.server_url`.
However the Capybara RackTest driver uses paths instead of URL's, so it doesn't
set Capybara.app_host or Capybara.current_session.server_url.

For SystemTestCase to work for the RackTest driver a host has to be
available for url options. We can fallback to "http://127.0.0.1" which
was the default before 78c734386cddf5ee533ad1915d3769b9cc1be3a2.
2021-09-21 20:09:16 +02:00
Rafael França
7df466c384
Fix name of the development package 2021-09-21 14:08:26 -04:00
Rafael França
9fb53e0673
Merge pull request #43061 from edwinv/devcontainer
Github Codespaces configuration
2021-09-21 12:01:55 -04:00
Camila Maia
edc5ee1fa2 Add missing migrate command to Getting Started section 8.3 2021-09-21 12:01:25 -03:00
Rafael França
1a240cf83e
Merge pull request #43131 from yahonda/bin_test_handles_adaptes
Active Record `bin/test` to execute its own adapter specific tests
2021-09-21 01:17:21 -04:00
Rafael França
badf915283
Merge pull request #42501 from HParker/allow-specifying-numeric-strong_params
Allow permitting numeric params
2021-09-21 01:14:39 -04:00
Yasuo Honda
6d10aafce6 Rename adapter_short to adapter_name 2021-09-21 08:26:04 +09:00
Rafael França
20db0845cd
Merge pull request #43209 from mpestov/check-basic-auth-credentials
Check basic auth credentials before authenticate
2021-09-20 18:13:14 -04:00
Rafael Mendonça França
a76344ffc5
Merge PR #42475 2021-09-20 18:03:57 -04:00
Rafael França
7e738a5587
Merge pull request #43267 from the-spectator/big_int_generator_fix
Fixes #43266 Add `bigint` to `NATIVE_DATABASE_TYPES` in mysql & postgres adapter
2021-09-20 17:59:56 -04:00
Rafael Mendonça França
49bc29a8fb
Fix CHANGELOG [ci skip] 2021-09-20 17:56:06 -04:00
Rafael Mendonça França
040e22b104
Fix CHANGELOG [ci skip] 2021-09-20 17:35:12 -04:00
Rafael França
6e2247e976
Merge pull request #43232 from le0pard/fix_use_tag
Support svg unpaired tags in tag helper
2021-09-20 17:34:28 -04:00
Rafael França
98fda3d317
Merge pull request #43253 from geoffreyp7/patch-5
Minor grammatical improvements
2021-09-20 17:31:03 -04:00
Rafael França
6d3aedbbf2
Merge pull request #43263 from bnjamin/filter-virtual-columns
Filter virtual columns from the attribute names
2021-09-20 17:28:45 -04:00
Rafael Mendonça França
50d60e4f7c
Allow Marcel to be released following semver 2021-09-20 17:19:57 -04:00
Rafael França
1d986fda85
Merge pull request #43270 from ceritium/selenium-webdriver-4
Requires selenium-webdriver 4.0.0 on ruby >= 3.0.0
2021-09-20 17:05:36 -04:00
Jose Galisteo
23ea5b0f2c Requires selenium-webdriver 4.0.0
`selenium-webdriver` added support for Ruby 3.0, but there is only an RC version available right now.

Related to https://github.com/rails/rails/issues/43248
2021-09-20 22:32:04 +02:00
Rafael França
b3efb35aa3
Merge pull request #42989 from jharrilim/patch-2
Change diff highlighting background for dark mode
2021-09-20 16:28:14 -04:00
Rafael França
9289935a1e
Merge pull request #43093 from issei-m/patch-1
Stop ignoring tmp/storage/.keep
2021-09-20 16:21:54 -04:00