Commit Graph

74209 Commits

Author SHA1 Message Date
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 dd779c9686f49f5ed6dda8ad5a1cb3b0788e1dd4.
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 98d0f7ebd34b858f12a12dcf37ae54fdbb5cab64.
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 8d2866bb80fbe81acb04f5b0c44f152f571fb29f.
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
Akira Matsuda
dd779c9686 No such class since 8d2866bb80fbe81acb04f5b0c44f152f571fb29f 2019-08-02 06:21:14 +09:00
Ryuta Kamizono
89399ed88c
Merge pull request #36821 from rails/virtual-attribute-type
Add tests for selecting aggregrates
2019-08-02 05:54:01 +09:00
Akira Matsuda
0168ac3dfc Missing require AS/core_ext/string/inflections 2019-08-02 05:36:38 +09:00
Akira Matsuda
3d561aab75 Let's try not to depend too much on other core extensions in a core extension test 2019-08-02 05:36:38 +09:00
Akira Matsuda
2ec1bad4ad Missing require AS/core_ext/object/blank 2019-08-02 05:36:38 +09:00
Akira Matsuda
f22a11edc7 require only what each test concerns 2019-08-02 05:36:38 +09:00
Akira Matsuda
8d2866bb80 You give jruby_skip & rubinius_skip a good name
This hack prevails everywhere in the codebase by being copy & pasted, and it's actually not a negative thing but a necessary thing for framework implementors,
so it should better have a name and be a thing.

And with this commit, activesupport/test/abstract_unit.rb now doesn't silently autoload AS::TestCase,
so we're ready to establish clearner environment for running AS tests (probably in later commits)
2019-08-02 05:36:38 +09:00
Akira Matsuda
98d0f7ebd3 MethodCallAssertions is a regular player of the team ActiveSupport::TestCase now
It's used everywhere, clean and mature enough
2019-08-02 05:36:15 +09:00
eileencodes
dde03a9234 Introduce InvalidConfigurationError
In our app at work we had a faked config like this:

```
{ "foo" => :bar, "bar" => { "adapter" => "memory" } }
```

This config is invalid. You can't say for foo env just have a symbol,
nor would this work if you had fa foo env with just a string. A
configuration must be a url or an adapter or a database. Otherwise it's
invalid and we can't parse it.

When this was just yaml turned into hashes you could get away with
passing whatever. It wouldn't work but it wouldn't blow up either.

Now that we're using objects we were returning `nil` for these but that
just means we either blow up on `for_current_env` or compact the
`nil`'s.

I think it's a better user experience to not build the configs and raise
an appropriate error.

This is also an invalid config because if you do pass a string here it
should be a URL.

```
{ "foo" => "bar", "bar" => { "adapter" => "memory" } }
```
2019-08-01 16:33:58 -04:00
Ryuta Kamizono
4f1bd290f0
Merge pull request #36834 from kamipo/deduplicate_joins
Deduplicate joins values
2019-08-02 04:02:01 +09:00
Ryuta Kamizono
e6f953fc39 Deduplicate joins values
#36805 have one possible regression that failing deduplication if
`joins_values` have complex order (e.g. `joins_values = [join_node_a,
:comments, :tags, join_node_a]`).

This fixes the deduplication to take it in the first phase before
grouping.
2019-08-02 03:35:44 +09:00
Godfrey Chan
05300be635 Add tests for selecting aggregates
These tests verifies that aggregates like `AVG` can be selected as
"virtual attributes" on Active Record models and have the correct
column type.
2019-08-01 10:56:10 -07:00
Ryuta Kamizono
ad957273f5 Fix _write_layout_method 2019-08-02 01:55:47 +09:00
Rafael Mendonça França
d40c88ae05
No private def 2019-08-01 11:18:42 -04:00
Abhay Nikam
0db87b9908 Added multiple database Active Record guide entry to the release notes [ci skip] 2019-08-01 19:59:41 +05:30
Carlos Antonio da Silva
11cb8c48ee
Merge pull request #36831 from akshaymohite/fix-form-helpers-documentation-comment
Added missing comment notation for the example of form_with in form_helpers.md documentation. [ci skip]
2019-08-01 10:37:18 -03:00
Akshay Mohite
c27be3bf21
Added missing comment notation for the example of form_with in form_helpers.md documentation. [ci skip] 2019-08-01 18:09:35 +05:30
Akira Matsuda
b3b3ff5dfd Missing require "AS/core_ext/date_time/conversions"
This causes
  "NameError: undefined local variable or method `nsec' for #<DateTime:0x0000559163cdd878>"
2019-08-01 21:09:57 +09:00
Akira Matsuda
2b222a89ec Another missing require "AS/core_ext/object/try" 2019-08-01 21:09:44 +09:00
Akira Matsuda
530f7805ed It may be better to explicitly require 'object/try' where we call try
In most cases it works now without explicit require because it's accidentally required through
active_support/core_ext/date_and_time/calculations.rb where we still call `try`,
but that would stop working if we changed the Calculations implementation and remove the require call there.
2019-08-01 18:51:51 +09:00
Akira Matsuda
03018cb79b Don't require 'active_support/all' in an individual test case!!!
and Git taught me that this crap was added via this commit... 68db6bc431
2019-08-01 18:27:24 +09:00
Akira Matsuda
d21e5fbc70 These methods doesn't have to be protected 2019-08-01 17:58:00 +09:00
Akira Matsuda
af2129b4c7 Use try only when we're unsure if the receiver would respond_to the method 2019-08-01 17:58:00 +09:00
Vipul A M
dbf3e4882f
Merge pull request #36827 from akshaymohite/fix-documentation-typo-in-example
Fixed a typo in documentation example of activerecord database configuration. [ci skip]
2019-08-01 10:05:04 +08:00
Akshay Mohite
b5950b8ee8
Fixed a typo in documentation example of activerecord database configuration. [ci skip]
- The example has sqlite3 adpater in database.yml, whereas configuration object had incorrectly specified mysql2 in documentation.
2019-08-01 07:23:51 +05:30
yuuji.yaginuma
6b3d9f8f86 Do not use the same test class in different tests
This fixes the following warnings.

```
actionmailer/test/base_test.rb:272: warning: method redefined; discarding old welcome
actionmailer/test/base_test.rb:260: warning: previous definition of welcome was here
```
2019-08-01 10:26:59 +09:00
Gannon McGibbon
388e011b08
Merge pull request #36792 from peterzhu2118/azure-content-disposition
Upload filename and disposition for Azure
2019-07-31 18:44:58 -04:00
Peter Zhu
24ae11daae Upload file with filename and disposition for Azure 2019-07-31 15:44:40 -04:00
Eileen M. Uchitelle
f66bfdb284
Merge pull request #36825 from cpruitt/transliterate-frozen-us-ascii-strings
Prevent error on transliterate with frozen strings
2019-07-31 13:04:58 -04:00