Commit Graph

70943 Commits

Author SHA1 Message Date
Sam Bostock
d45b74e897
Add advanced test helpers docs to guides
[ci skip]
2018-12-04 18:29:52 -05:00
Rafael França
1decfedb2b
Merge pull request #34612 from utilum/bigdecimal_raises_on_comma_in_string_argument
Another Ruby 2.6 BigDecimal compatibility issue
2018-12-04 16:50:44 -05:00
Rafael França
bd62389307
Merge pull request #34560 from gmcgibbon/fix_decorate_leak_on_serial_attr_test
Fix attribute decoration leak on serialized attribute test
2018-12-04 14:05:36 -05:00
Rafael França
ec66c6a2fa
Merge pull request #34616 from gmcgibbon/route_symbol_note
Add note about symbols vs strings
2018-12-04 14:04:04 -05:00
Gannon McGibbon
7973170893 Add note about symbols vs strings 2018-12-04 13:46:02 -05:00
Rafael Mendonça França
0421eecf13
Fix announcement draft formatting [ci skip] 2018-12-04 13:41:49 -05:00
Rafael Mendonça França
b2465a0cc9
Add release link to the announcement [ci skip] 2018-12-04 13:41:43 -05:00
Rafael Mendonça França
e91bf5966e
Improve the task to generate the release summary
Now it accepts the base release to be compared with.

[ci skip]
2018-12-04 13:41:36 -05:00
Rafael França
e5172265bf
Merge pull request #34605 from alfie-max/disable_enum_scopes
option to disable all scopes that `ActiveRecord.enum` generates
2018-12-04 11:48:40 -05:00
Gannon McGibbon
f5050d998d Add MailDeliveryJob for unified mail delivery
Add `MailDeliveryJob` for delivering both regular and parameterized mail.
Deprecate using `DeliveryJob` and `Parameterized::DeliveryJob`.
2018-12-04 11:00:34 -05:00
utilum
ab631b363e Another Ruby 2.6 BigDecimal compatibility issue
This patch modifies XmlMini::Parsing["decimal"] to handle a string that
contains an invalid number. Since [ruby/ruby@a0e438c#diff-6b866d482baf2bdfd8433893fb1f6d36R144](a0e438cd3c (diff-6b866d482baf2bdfd8433893fb1f6d36R144)) this case raises an `ArgumentError`. `String.to_f` returns 0.0 if there is not a valid number at the start of the argument, so current behavior is conserved.

See https://travis-ci.org/rails/rails/jobs/463180341#L6264

Related: #34600, #34601
2018-12-04 13:50:45 +01:00
Alfred Dominic
c4d157aafe option to disable scopes that ActiveRecord.enum generates by default 2018-12-04 15:56:31 +05:30
Ryuta Kamizono
609c58bfa6 Merge pull request #34609 from kamipo/delete_all_on_collection_proxy
Ensure that `delete_all` on collection proxy returns affected count
2018-12-04 15:48:22 +09:00
Ryuta Kamizono
53d5a682c9
Merge pull request #34607 from gmcgibbon/clear_scope_on_delete
Reset scope after collection delete
2018-12-04 15:47:00 +09:00
Ryuta Kamizono
4d7354aa35 Ensure that delete_all on collection proxy returns affected count
Unlike the `Relation#delete_all`, `delete_all` on collection proxy
doesn't return affected count. Since the `CollectionProxy` is a subclass
of the `Relation`, this inconsistency is probably not intended, so it
should return the count consistently.
2018-12-04 14:33:31 +09:00
Gannon McGibbon
67bca35a64 Reset scope after collection delete
Reset scope after delete on collection association to clear stale
offsets of removed records.
2018-12-04 00:16:42 -05:00
blahed
8e25e9e315 colorize the unpermitted params log message 2018-12-03 19:40:46 -05:00
Gannon McGibbon
6ca6478a67
Merge pull request #34596 from bogdanvlviv/imporve-parallel-testing-guide
Improve parallel testing guide [ci skip]
2018-12-03 11:02:18 -05:00
Rafael França
e167818687
Merge pull request #34602 from guizmaii/master
Pass the `connection` to the `@instrumenter.instrument` method call
2018-12-03 10:47:50 -05:00
Ryuta Kamizono
41e468a051
Merge pull request #34601 from evexoio/34600-test_should_return_nil_as_average
Fix NumericData.average test on 2.6.0-dev
2018-12-03 20:41:13 +09:00
Abdallah Samman
89b4612ffc Fix NumericData.average test on ruby 2.6 2018-12-03 12:59:38 +02:00
Ryuta Kamizono
df76eaa4f1 Address "warning: shadowing outer local variable - parts"
And hide the `READ_QUERY` internal constant.
2018-12-03 19:57:27 +09:00
bogdanvlviv
4973a7643b
Improve parallel testing guide [ci skip]
- Fix formatting
- Don't repeat "Active Record automatically handles creating and migrating a new
  database for each worker to use."
- Tell that AR loads the schema to a database for each process(Related to #33479)
- Clarify that `parallelize_teardown` is executed for each process
2018-12-03 11:17:58 +02:00
jules Ivanic
6d1c9a9b23 Pass the connection to the @instrumenter.instrument method call 2018-12-03 10:12:14 +01:00
Yuji Yaginuma
e7717ec7a0
Merge pull request #34597 from utilum/assigned_but_unused_variable_bird
Assigned but unused variable - bird
2018-12-03 11:39:54 +09:00
Rafael França
5bf6986293
Merge pull request #34598 from rmacklin/add-missing-authorship-to-changelog-entry
Add missing authorship to ActionCable changelog entry
2018-12-02 21:13:39 -05:00
Richard Macklin
fced64062f Add missing authorship to ActionCable changelog entry
I accidentally forgot to add the author line to my changelog entry from
2bb4fdef5efc70327c018e982ff809a29ac6708b
2018-12-02 17:16:02 -08:00
utilum
d1c2f4d0d9 Assigned but unused variable - bird
See: https://travis-ci.org/rails/rails/jobs/462233144#L1384
2018-12-03 01:36:01 +01:00
Yuji Yaginuma
222757618e
Merge pull request #34585 from marceloperini/marceloperini/33795
add require 'database/setup' in activestorage/test/service/s3_service_test.rb
2018-12-03 08:29:57 +09:00
Ryuta Kamizono
01d3899695
Merge pull request #34595 from albertoalmagro/remove-unnecessary-variable
Remove unnecessary variable route
2018-12-03 05:01:28 +09:00
Javan Makhmali
985557b533
Merge pull request #34590 from rmacklin/use-websocket-adapter-in-getState
Replace reference to WebSocket global with ActionCable.adapters.WebSocket
2018-12-02 14:50:05 -05:00
Javan Makhmali
730ead9b09
Merge pull request #34588 from rmacklin/fix-yarn-lockfiles
Remove obsolete yarn.lock files and check in root yarn.lock file
2018-12-02 14:47:36 -05:00
Richard Macklin
fb0c81d349 Remove obsolete yarn.lock files and check in root yarn.lock file 2018-12-02 10:02:14 -08:00
Alberto Almagro
c93bad2070 Remove unnecessary variable route
The variable `route` was only allocated to hold an object that was
immediately returned. This patch removes that variable.
2018-12-02 18:10:03 +01:00
Richard Macklin
2bb4fdef5e Replace reference to WebSocket global with ActionCable.adapters.WebSocket
The WebSocket dependency of ActionCable.Connection was made configurable
in 66901c1849efae74c8a58fe0cb36afd487c067cc

However, the reference here in Connection#getState was not updated to
use the configurable property. This change remedies that and adds a test
to verify it. Additionally, it backfills a test to ensure that
Connection#open uses the configurable property.
2018-12-01 14:49:43 -08:00
rmacklin
aa1ba9cb24 Remove circular dependency warnings in ActionCable javascript and publish source modules with fine-grained exports (#34370)
* Replace several ActionCable.* references with finer-grained imports

This reduces the number of circular dependencies among the module
imports from 4:

```
(!) Circular dependency: app/javascript/action_cable/index.js -> app/javascript/action_cable/connection.js -> app/javascript/action_cable/index.js
(!) Circular dependency: app/javascript/action_cable/index.js -> app/javascript/action_cable/connection_monitor.js -> app/javascript/action_cable/index.js
(!) Circular dependency: app/javascript/action_cable/index.js -> app/javascript/action_cable/consumer.js -> app/javascript/action_cable/index.js
(!) Circular dependency: app/javascript/action_cable/index.js -> app/javascript/action_cable/subscriptions.js -> app/javascript/action_cable/index.js
```

to 2:

```
(!) Circular dependency: app/javascript/action_cable/index.js -> app/javascript/action_cable/connection.js -> app/javascript/action_cable/index.js
(!) Circular dependency: app/javascript/action_cable/index.js -> app/javascript/action_cable/connection.js -> app/javascript/action_cable/connection_monitor.js -> app/javascript/action_cable/index.js
```

* Remove tests that only test javascript object property assignment

These tests really only assert that you can assign a property to
the ActionCable global object. That's true for pretty much any object
in javascript (it would only be false if the object has been frozen, or
has explicitly set some properties to be nonconfigurable).

* Refactor ActionCable to provide individual named exports

By providing individual named exports rather than a default export which
is an object with all of those properties, we enable applications to
only import the functions they need: any unused functions will be
removed via tree shaking.

Additionally, this restructuring removes the remaining circular
dependencies by extracting the separate adapters and logger modules, so
there are now no warnings when compiling the ActionCable bundle.

Note: This produces two small breaking API changes:

- The `ActionCable.WebSocket` getter and setter would be moved to
  `ActionCable.adapters.WebSocket`. If a user is currently configuring
  this, when upgrading they'd need to either add a delegated
  getter/setter themselves, or change it like this:
   ```diff
   -    ActionCable.WebSocket = MyWebSocket
   +    ActionCable.adapters.WebSocket = MyWebSocket
    ```
   Applications which don't change the WebSocket adapter would not need
   any changes for this when upgrading.

- Similarly, the `ActionCable.logger` getter and setter would be moved
  to `ActionCable.adapters.logger`. If a user is currently configuring
  this, when upgrading they'd need to either add a delegated
  getter/setter themselves, or change it like this:
   ```diff
   -    ActionCable.logger = myLogger
   +    ActionCable.adapters.logger = myLogger
    ```
   Applications which don't change the logger would not need any changes
   for this when upgrading.

These two aspects of the public API have to change because there's no
way to export a property setter for `WebSocket` (or `logger`) such that
this:
```js
import ActionCable from "actioncable"

ActionCable.WebSocket = MyWebSocket
```
would actually update `adapters.WebSocket`. (We can only offer that if
we have two separate source files like if `index.js` uses
`import * as ActionCable from "./action_cable" and then exports a
wrapper which has delegated getters and setters for those properties.)

This API change is very minor - it should be easy for applications to
add the `adapters.` prefix in their assignments or to patch in delegated
setters. And especially because most applications in the wild are not
ever changing the default value of `ActionCable.WebSocket` or
`ActionCable.logger` (because the default values are perfect), this API
breakage is worth the tree-shaking benefits we gain.

* Include source code in published actioncable npm package

This allows actioncable users to ship smaller javascript bundles to
visitors using modern browsers, as demonstrated in this repository:
https://github.com/rmacklin/actioncable-es2015-build-example

In that example, the bundle shrinks by 2.8K (25.2%) when you simply
change the actioncable import to point to the untranspiled src.

If you go a step further, like this:
```
diff --git a/app/scripts/main.js b/app/scripts/main.js
index 17bc031..1a2b2e0 100644
--- a/app/scripts/main.js
+++ b/app/scripts/main.js
@@ -1,6 +1,6 @@
-import ActionCable from 'actioncable';
+import * as ActionCable from 'actioncable';

 let cable = ActionCable.createConsumer('wss://cable.example.com');

 cable.subscriptions.create('AppearanceChannel', {
```

then the bundle shrinks by 3.6K (31.7%)!

In addition to allowing smaller bundles for those who ship untranspiled
code to modern browsers, including the source code in the published
package can be useful in other ways:

1. Users can import individual modules rather than the whole library
2. As a result of (1), users can also monkey patch parts of actioncable
   by importing the relevant module, modifying the exported object, and
   then importing the rest of actioncable (which would then use the
   patched object).

Note: This is the same enhancement that we made to activestorage in
c0368ad090b79c19300a4aa133bb188b2d9ab611

* Remove unused commonjs & resolve plugins from ActionCable rollup config

These were added when we copied the rollup config from ActiveStorage,
but ActionCable does not have any commonjs dependencies (it doesn't have
any external dependencies at all), so these plugins are unnecessary here

* Change ActionCable.startDebugging() -> ActionCable.logger.enabled=true

and ActionCable.stopDebugging() -> ActionCable.logger.enabled=false

This API is simpler and more clearly describes what it does

* Change Travis configuration to run yarn install at the root for ActionCable builds

This is necessary now that the repository is using Yarn Workspaces
2018-12-01 16:25:02 -05:00
Marcelo Perini Veloso
ce40e85194
add require 'database/setup' in activestorage/test/service/s3_service_test.rb 2018-12-01 15:47:54 -02:00
Ryuta Kamizono
a429b29425
Merge pull request #34583 from gregmolnar/guides_fix
fix example code syntax [ci skip]
2018-12-01 18:06:52 +09:00
Greg Molnar
e06e53e285 fix example code syntax [ci skip] 2018-12-01 09:48:08 +01:00
Ryuta Kamizono
d8b86c236c
Merge pull request #34579 from gmcgibbon/yield_in_with_delivery_job
Add yield to with_delivery_job test helper
2018-12-01 15:18:32 +09:00
yuuji.yaginuma
6ca2f2acb2 metadata is not passed to service
Ref: 604fac6d71/activestorage/app/models/active_storage/blob.rb (L256-L264)

This fixes broken `GCSServiceTest`.
https://travis-ci.org/rails/rails/jobs/461868394#L6624-L6626

Follow up to  #34576.
2018-12-01 09:12:55 +09:00
Gannon McGibbon
ebf484a640 Add yield to with_delivery_job test helper
Adds yield to parameterized mail test helper so assertions
passed into with_delivery_job are actually ran.
2018-11-30 17:38:26 -05:00
Ryuta Kamizono
604fac6d71
Merge pull request #34577 from gmcgibbon/id_as_non_pk_docs
Clarify no support for non PK id columns

[ci skip]
2018-12-01 03:40:27 +09:00
Gannon McGibbon
220494185c Clarify no support for non PK id columns
[ci skip]
2018-11-30 13:25:42 -05:00
Rafael França
25c076117c
Merge pull request #33882 from mberlanda/mberlanda/as-inheritable-options-intialization
[Realties] config_for as ActiveSupport::OrderedOptions
2018-11-30 11:42:44 -05:00
Rafael França
b37f06c814
Merge pull request #34576 from ys/test-upload-extra-keys
Add a test with extra keys to active_storage Service#upload
2018-11-30 11:39:12 -05:00
Eileen M. Uchitelle
f6e1061c91
Merge pull request #34505 from eileencodes/add-readonly-mode
Add ability to block writes to a database
2018-11-30 10:06:02 -05:00
Yannick Schutz
7bd21e8575
Add a test with extra keys to active_storage Service#upload 2018-11-30 15:54:38 +01:00
Eileen Uchitelle
f39d72d526 Add ability to prevent writes to a database
This PR adds the ability to prevent writes to a database even if the
database user is able to write (ie the database is a primary and not a
replica).

This is useful for a few reasons: 1) when converting your database from
a single db to a primary/replica setup - you can fix all the writes on
reads early on, 2) when we implement automatic database switching or
when an app is manually switching connections this feature can be used
to ensure reads are reading and writes are writing. We want to make sure
we raise if we ever try to write in read mode, regardless of database
type and 3) for local development if you don't want to set up multiple
databases but do want to support rw/ro queries.

This should be used in conjunction with `connected_to` in write mode.
For example:

```
ActiveRecord::Base.connected_to(role: :writing) do
  Dog.connection.while_preventing_writes do
    Dog.create! # will raise because we're preventing writes
  end
end

ActiveRecord::Base.connected_to(role: :reading) do
  Dog.connection.while_preventing_writes do
    Dog.first # will not raise because we're not writing
  end
end
```
2018-11-30 09:28:04 -05:00
Ryuta Kamizono
5c6316dbb8
Merge pull request #34572 from kamipo/fix_scoping_with_query_method
Fix the scoping with query methods in the scope block
2018-11-30 21:41:12 +09:00