Commit Graph

74339 Commits

Author SHA1 Message Date
eileencodes 793b092f53 Fix Gemfile.lock
The PR #36860 changed ActionView's required version of
rails-html-sanitizer, but I missed that we needed to run bundle,
otherwise we end up with changes every time.
2019-08-06 13:15:50 -04:00
Eileen M. Uchitelle eb4faa13e8
Merge pull request #36864 from seejohnrun/activejob-test-helper-set-wait
Add at option to perform_enqueued_jobs test helper
2019-08-06 13:08:32 -04:00
eileencodes ff70c1764d Fix thread safety of prevent_writes
As demonstrated in the test added and in #36830 the code that prevents
writes wasn't thread safe. If one thread does a read, then another does
a write, and then another does a read the second read will cause the
first write to be unwriteable.

This change removes the instance variable and instead uses a
getter/setter on Thread.current[:prevent_writes] for the connection
handler to set whether writes are allowed.

Fixes #36830
2019-08-06 13:07:19 -04:00
John Crepezzi 647317d17e Add at option to perform_enqueued_jobs test helper
Currently, the `perform_enqueued_jobs` helpers will also immediately
perform jobs that are scheduled via `set(wait:)` to run in the future.
This commit adds a new argument to `perform_enqueued_jobs` to make it
only run jobs scheduled at or before the passed in `Time`. This allows
testing the side effects of immediate job execution separate of jobs
delayed in the future.
2019-08-06 16:31:48 +02:00
Ryuta Kamizono 7cd4148973
Merge pull request #36863 from okuramasafumi/add-explanation-of-context-to-activerecord-save-docs
[ci skip] Mention `context` option of save in documentation
2019-08-06 20:25:59 +09:00
OKURA Masafumi e7ce8d2653 [ci skip] Mention `context` option of save in documentation
`ActiveRecord::Validations#save` takes `context` option
which can change validation context.
This fact should be mentioned in the documentation.
2019-08-06 20:10:11 +09:00
Eileen M. Uchitelle 3d83fff3bb
Merge pull request #36860 from cpruitt/update-gemspec-rails-html-sanitizer-version
Update rails-html-sanitizer to 1.1.0 in actionview.gemspec
2019-08-05 14:54:26 -04:00
Cliff Pruitt 265f97f1c1 Update rails-html-sanitizer to 1.1.0 in actionview.gemspec
Commit 52f0b050e2 replaces `white_list_sanitizer` with `safe_list_sanitizer`. This is a breaking change unless the installed version of `rails-html-sanitizer` is `>= 1.1.0`.

This commit updates the minimum version in `actionview/actionview.gemspec` to `1.1.0`.
2019-08-05 13:20:53 -04:00
Eileen M. Uchitelle 170f5113d7
Merge pull request #36823 from abhaynikam/add-multiple-database-guide-entry-to-release-notes
Added multiple database Active Record guide entry to the release notes
2019-08-05 08:42:15 -04:00
Vipul A M 9f7461c6eb
Merge pull request #36857 from akshaymohite/correct-config-option-in-release-notes
Corrected config option path in release notes for deprecation release notes of Rails 6 [ci skip]
2019-08-05 11:36:47 +05:30
Akshay Mohite d15a72aba6
Corrected deperecation config option path for active_record.sqlite3.represent_boolean_as_integer option in release notes. [ci skip] 2019-08-05 11:26:43 +05:30
Kasper Timm Hansen 064b7f6082
Remove unused require 2019-08-05 04:10:54 +02:00
Kasper Timm Hansen 4f235e9a86
Merge pull request #36537 from quadule/fix-cookie-rotation-hash-pollution
Fix cookie modification during rotation
2019-08-05 03:57:08 +02:00
Kasper Timm Hansen 3d1f6feda2
Use newly released rails-html-sanitizer 2019-08-05 03:55:12 +02:00
Juanito Fatas 52f0b050e2
Update sanitizer in ActionView::Helpers::SanitizeHelper
- The sanitizer has been changed to safe_list_sanitizer.
- deprecate white_list_sanitizer
2019-08-05 03:35:35 +02:00
Lachlan Sylvester 1af44e4aee
handle passing in primary key to unique_by, and handle primary keys missing indexes 2019-08-05 02:39:52 +02:00
Guilherme Mansur 6c6d852854
Use Thread.pass instead of Kernel.sleep to trigger race condition 2019-08-05 02:31:53 +02:00
Guilherme Mansur 2bd2d853da
Able to initalize default value for thread_mattr_*
Added the ability to initialize `thread_mattr_*` methods with default
values like so:

``` ruby
  class MyClass
    thread_attr_reader :foo, default: :foo
    thread_attr_writer :bar, default: :bar
    thread_attr_accessor: baz do
      "baz"
    end
  end
```

This is consistent with the api exposed by `mattr_accessor`.
2019-08-05 02:31:36 +02:00
Prathamesh Sonpatki cebbf6c6cf
Mention how to use webpacker in updated Rails apps [ci skip] 2019-08-04 22:20:59 +02:00
Eileen M. Uchitelle 2c0b67c281
Merge pull request #36845 from eileencodes/fix-pg-closed-connection
Fix `PG::ConnectionBad` error when running fixtures
2019-08-04 15:25:05 -04:00
Kasper Timm Hansen 5f3848a979
Merge pull request #36854 from eugeneius/media_type_instead_of_content_type
Use media_type instead of content_type internally
2019-08-04 02:53:01 +02:00
Kasper Timm Hansen f1f5024b91
Revise flow to what was described in 03e44f9 2019-08-04 02:19:55 +02:00
Eugene Kenny 7cf445d3bd Use media_type instead of content_type internally
These calls to `content_type` were triggering the deprecation from
c631e8d011 in upgraded applications.

We can use `media_type` in all of these cases to avoid the deprecation.
2019-08-04 00:35:49 +01:00
Kasper Timm Hansen 03e44f9300
Revise credentials diffing flow to use a separate diff command
Didn't like the complicated stuff that happened on credentials:edit. It
would append to .gitattributes multiple times. Though I see why it was
written that way.

I'm cutting off for now, but since this new flow would require each developer
to run --enable perhaps this should really be:

1. Developer enrolls Rails app by running `credentials:diff --enable`
2. credentials:edit checks .gitattributes for `diff=rails_credentials` and
   if the current file is covered by that.
3. If so, set up the "rails_credentials" driver automatically.
2019-08-04 01:32:41 +02:00
Kasper Timm Hansen 6db2c426c0
Extract diffing to separate credentials:diff command 2019-08-04 00:00:16 +02:00
Kasper Timm Hansen b4112f45b3
Commands already make fileutils available. 2019-08-03 23:19:14 +02:00
Kasper Timm Hansen af2880bdda
Rename to Diffing and move module into credentials command
Helpers is more for sharing between commands. Since `Diffing` is only
for credentials we should just keep it only for credentials.

Replaces "pretty" with diffing since the former is ambiguous, while
diffing captures what it does. `opt_in` seemed clunky so it's swapped
for the one-word enable.
2019-08-03 23:06:47 +02:00
y-yagi 99650550e8
Merge pull request #36849 from yahonda/use_assert_nil
Address `DEPRECATED: Use assert_nil if expecting nil`
2019-08-03 11:50:17 +09:00
Yasuo Honda 20772f6c53 Address `DEPRECATED: Use assert_nil if expecting nil`
```ruby
$ cd activerecord
$ bin/test test/cases/dirty_test.rb:494
... snip ...
DEPRECATED: Use assert_nil if expecting nil from /home/yahonda/git/rails/activerecord/test/cases/dirty_test.rb:494. This will fail in Minitest 6.
DEPRECATED: Use assert_nil if expecting nil from /home/yahonda/git/rails/activerecord/test/cases/dirty_test.rb:511. This will fail in Minitest 6.
.

Finished in 0.061593s, 16.2356 runs/s, 795.5428 assertions/s.
1 runs, 49 assertions, 0 failures, 0 errors, 0 skips
$
```

Refer seattlerb/minitest#666 rails/rails#27712
2019-08-03 02:27:56 +00:00
John Hawthorn d0e95f45f3 Raise TypeError instead of infinite looping 2019-08-02 15:58:42 -07:00
Vipul A M 5944a31292
Merge pull request #36846 from SGourshete/master
typo in word compatibily -> compatibility [ci skip]
2019-08-03 04:17:04 +08:00
Swapnil Gourshete 303f415573
typo in word compatibily - autoloading and reloading constants guide 2019-08-03 01:29:35 +05:30
eileencodes bfec23aecb Fix `PG::ConnectionBad` error when running fixtures
At first this appeared to be a multi-db bug but after some invesitgation
it was clear that this can occur just by calling `establish_connection`
from ApplicationRecord.

After some investigation we found that this only occurred when using
fixtures. The console boots fine, the server runs fine, and the tests
even run fine if we used paralellization or eager loading in the tests.

I tracked the issue down to the line that calls
`self.connection_specification_name = name` in the SchemaMigration
changes for Rails 6.0. But how can this be? That is not that major of a
change? How could `connection_specification_name` be a problem?

First `connection_specification_name` caches the name of the connection
specificatio. Second, fixtures were incorrectly holding onto a reference
to that connection.

So when you went to run the tests the models wouldn't be connected and
when the fixtures tried to load the data it would choke on that
unconnected database.

The changes here move the connection into a lambda so we can call it
when we need it rather than blowing up before the model is connected.

Fixes #36743

Co-authored-by: Aaron Patterson <aaron.patterson@gmail.com>
2019-08-02 15:22:11 -04:00
Rafael Mendonça França 1c7207a22f
1.hour needs core_ext to work
Usually the application requires the entire active support at load time
but the configuration happens before it is loaded. For that reason we
need to require the core_ext that we want to use in this file.
2019-08-02 15:02:59 -04:00
Eileen M. Uchitelle ac7c9381f0
Merge pull request #36843 from eileencodes/add-ability-to-unset-preventing-writes
Add ability to unset preventing writes
2019-08-02 13:03:03 -04:00
eileencodes f2de448106 Add ability to unset preventing writes
Previously if an app attempts to do a write inside a read request it will be
impossilbe to switch back to writing to the primary. This PR adds an
argument to the `while_preventing_writes` so that we can make sure to
turn it off if we're doing a write on a primary.

Fixes #36830

Co-authored-by: John Crepezzi <john.crepezzi@gmail.com>
2019-08-02 12:10:32 -04:00
Eileen M. Uchitelle f3c68c59ed
Merge pull request #36814 from eileencodes/introduce-invalid-configuration-error
Introduce InvalidConfigurationError
2019-08-02 08:50:27 -04:00
Rafael Mendonça França 92cb55ce19
This test needs integer core ext for time 2019-08-02 01:16:50 -04:00
Rafael Mendonça França 847ad98e07
ConditionalGet needs time core_ext 2019-08-02 01:12:36 -04:00
Rafael Mendonça França dd16e208a6
Require time extensions in the job that depends on time 2019-08-02 00:52:02 -04:00
Rafael Mendonça França 4b4bed83e2
Require integer conversion for this test 2019-08-02 00:49:47 -04:00
Rafael Mendonça França 0e62667047
Revert "No such class since 8d2866bb80fbe81acb04f5b0c44f152f571fb29f"
This reverts commit dd779c9686.
2019-08-02 00:25:13 -04:00
Rafael Mendonça França 967beb7229
Revert "MethodCallAssertions is a regular player of the team ActiveSupport::TestCase now"
This reverts commit 98d0f7ebd3.
2019-08-02 00:24:21 -04:00
Rafael Mendonça França 6384933994
Revert "You give jruby_skip & rubinius_skip a good name"
This reverts commit 8d2866bb80.
2019-08-02 00:24:11 -04:00
Akira Matsuda a162fc22e8 Missing require AS/core_ext/date/conversions 2019-08-02 13:18:01 +09:00
Akira Matsuda 12959dee0f hash_conversion itself does not at all depend on time extensions 2019-08-02 13:17:53 +09:00
David Heinemeier Hansson a0bb19fbfa
Add *_previously_was attribute methods when dirty tracking (#36836) 2019-08-01 15:38:03 -07:00
Ryuta Kamizono 603cd18b0b
Merge pull request #36837 from composerinteralia/no-color
Remove duplicate method definition
2019-08-02 07:09:18 +09:00
Daniel Colson 159a121044
Remove duplicate method definition
no_color! is already defined in [`Rails::Command::Behavior`][behavior],
which gets [included into `Rails:Generators`][include]. This duplication
came about in 6813edc7d9 when we introduced the Thor command structure.

We have [test coverage][] to ensure this method still behaves correctly
on `Rails:Generators`.

[behavior]: f7e91c7224/railties/lib/rails/command/behavior.rb (L12-L14)
[include]: f7e91c7224/railties/lib/rails/generators.rb (L18)
[test coverage]: f7e91c7224/railties/test/generators_test.rb (L163-L168)
2019-08-01 17:42:44 -04:00
Akira Matsuda f7e91c7224 Lazily evaluate FileUpdateCheckerSharedTests when being included
To avoid "uninitialized constant ActiveSupport::Testing (NameError)"
2019-08-02 06:21:14 +09:00