Commit Graph

71894 Commits

Author SHA1 Message Date
alkesh26
38472af70e ActiveSupport typo fixes. 2019-02-01 22:17:10 +05:30
Eileen M. Uchitelle
300c62f75c
Merge pull request #35043 from simoleone/activestorage/s3/content-type
include the content type when uploading to S3
2019-02-01 09:37:08 -05:00
Eileen M. Uchitelle
79bc9e81c3
Merge pull request #35126 from alkesh26/railities-typo-fix
Railties typo fixes.
2019-02-01 08:40:48 -05:00
alkesh26
79c3cef444 Railities typo fixes. 2019-02-01 16:42:40 +05:30
yuuji.yaginuma
eb1fc14d15 Fix doc of ActionDispatch::SystemTestCase [ci skip]
* Fix broken format.
* Need to specify driver to the first argument of `driven_by`.
* `add_emulation` doesn't have `device` keyword. Ref: https://github.com/SeleniumHQ/selenium/blob/master/rb/lib/selenium/webdriver/chrome/options.rb#L142-L162
2019-02-01 16:07:41 +09:00
Ryuta Kamizono
7ebfb319ff Enable Lint/ErbNewArguments cop to avoid the deprecated arguments warning
Related 5754a29a974d31cab2b4392716b9825a3d910a69.

And follows Ruby standard library style https://github.com/ruby/ruby/commit/3406c5d.
2019-02-01 14:20:11 +09:00
Ryuta Kamizono
6127b8d920
Merge pull request #35116 from kamipo/fix_through_association_creation
Fix has_many through association creation
2019-02-01 09:13:43 +09:00
Ryuta Kamizono
1d48a2025d
Merge pull request #35117 from kamipo/remove_unused_attr_writer
Remove unused attr_writers `visitor` and `indexes`
2019-02-01 09:07:55 +09:00
Yuji Yaginuma
d929b95bc8
Merge pull request #31253 from knu/backquote_returns_string
Make the backquote operator always return a string
2019-02-01 08:53:04 +09:00
Aaron Patterson
eda0f574f1
add tests to make sure deprecated API is still supported 2019-01-31 13:47:13 -08:00
Ryuta Kamizono
0413501691 Remove unused attr_writers visitor and indexes
I deprecated two unused attr_writers `visitor` and `indexes` at 8056fe0
and f4bc364 conservatively, since those are accidentaly exposed in the
docs.

https://api.rubyonrails.org/v5.2/classes/ActiveRecord/ConnectionAdapters/AbstractAdapter.html
https://api.rubyonrails.org/v5.2/classes/ActiveRecord/ConnectionAdapters/TableDefinition.html

But I've found that `view_renderer` attr_writer is removed without
deprecation at #35093, that is also exposed in the doc.

https://api.rubyonrails.org/v5.2/classes/ActionView/Base.html

I'd like to also remove the deprecated attr_writers since I think that
removing `visitor` and `indexes` attr_writers is as safe as removing
`view_renderer` attr_writer.
2019-02-01 02:32:01 +09:00
Vipul A M
315b9def91
Merge pull request #35112 from alkesh26/activerecord-typo-fixes
ActiveRecord typo fixes. [ci skip]
2019-01-31 22:25:49 +05:30
Ryuta Kamizono
341d86b490
Merge pull request #35115 from alkesh26/activestorage-typo-fix
ActiveStorage typo fix.

[ci skip]
2019-02-01 01:54:31 +09:00
Ryuta Kamizono
42d20e8de5 Revert "Merge pull request #33729 from kddeisz/plural-automatic-inverse"
This reverts commit ed1eda271c7ac82ecb7bd94b6fa1b0093e648a3e, reversing
changes made to 3d2caab7dc92a13d4dd369678d5b4ce659df8e52.

Reason: 7c3da6e0030aa080fcb89af58b094ed50d861a44
2019-02-01 01:34:49 +09:00
Ryuta Kamizono
7c3da6e003 Add regression test for has_many through record creation
#33729 affected the behavior of the has_many through record creation.

Since #33729, the intermediate reflection of simple has_many through
association has `inverse_of` to the association, it causes extra through
record creation, the extra through record required valid before the
association record is saved.

2312537867/activerecord/lib/active_record/associations/has_many_through_association.rb (L95-L102)

I think that #33729 need to more work to care about has_many through
association, that PR should be reverted to not break existing apps.
2019-02-01 01:34:32 +09:00
Akinori MUSHA
545b6e5820 Remove the Kernel#` override that turns ENOENT into nil
ActiveSupport overrides `` Kernel#` `` so that it would not raise
`Errno::ENOENT` but return `nil` instead (due to the last statement
`STDERR.puts` returning nil) if a given command were not found.
Because of this, you cannot safely say somthing like
`` `command`.chomp `` when ActiveSupport is loaded.

It turns out that this is an outdated monkey patch for Windows
platforms to emulate Unix behavior on an ancient version of Ruby, and
it should be removed by now.
2019-01-31 23:42:03 +09:00
alkesh26
a57f4defa7 ActiveStorage typo fix. 2019-01-31 19:42:32 +05:30
alkesh26
379354572f ActiveRecord typo fixe. 2019-01-31 16:31:51 +05:30
Yuji Yaginuma
2312537867
Merge pull request #35109 from abhaynikam/35073-fix-automatic-database-switching-doc-typo
Fix typo: inherts -> inherits [ci skip]
2019-01-31 11:38:34 +09:00
Abhay Nikam
15db608f3e Fixed typo for DatabaseSelector::Resolver documentation 2019-01-31 07:57:38 +05:30
Ryuta Kamizono
1f5e21bcbc Remove redundant begin block
We enabled `Style/RedundantBegin` cop at #34764, but it is hard to
detect an offence if returning value put after the block.
2019-01-31 10:18:34 +09:00
yuuji.yaginuma
5754a29a97 Fix ERB.new argument deprecated warning
This fixes following warning.

```
warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments.
```
2019-01-31 10:08:24 +09:00
Eileen M. Uchitelle
0a9bb48f83
Merge pull request #35108 from jhawthorn/db-selection-timestamp-after
Write update_last_write_timestamp after request
2019-01-30 18:21:16 -05:00
Kasper Timm Hansen
e01e64628d
Merge pull request #35104 from alkesh26/activemodel-typo-fixes
ActiveModel typo fixes.
2019-01-30 23:49:24 +01:00
Yuji Yaginuma
6729cef751
Merge pull request #34980 from y-yagi/fixes_34979
Don't add `RAILS_ENV` in generate action
2019-01-31 07:19:22 +09:00
John Hawthorn
ab952b1949 Write update_last_write_timestamp after request
We need to update using the timestamp from the end of the request, not
the start. For example, if a request spends 5+ seconds writing, we still
want to wait another 5 seconds for replication lag.

Since we now run the update after we yield, we need to use ensure to
make sure we update the timestamp even if there is an exception.
2019-01-30 13:25:09 -08:00
alkesh26
8b66ea5d2c activemodel typo fixes. 2019-01-31 02:43:44 +05:30
Aaron Patterson
535a8b9957
Merge pull request #35093 from rails/av-base-constructor
Tighten up the AV::Base constructor
2019-01-30 11:57:47 -08:00
Eileen M. Uchitelle
8ca6bd2e94
Merge pull request #35073 from eileencodes/db-selection
Part 8: Multi db improvements, Adds basic automatic database switching to Rails
2019-01-30 14:03:45 -05:00
Eileen Uchitelle
0abcec416b Adds basic automatic database switching to Rails
The following PR adds behavior to Rails to allow an application to
automatically switch it's connection from the primary to the replica.

A request will be sent to the replica if:

* The request is a read request (`GET` or `HEAD`)
* AND It's been 2 seconds since the last write to the database (because
we don't want to send a user to a replica if the write hasn't made it
to the replica yet)

A request will be sent to the primary if:

* It's not a GET/HEAD request (ie is a POST, PATCH, etc)
* Has been less than 2 seconds since the last write to the database

The implementation that decides when to switch reads (the 2 seconds) is
"safe" to use in production but not recommended without adequate testing
with your infrastructure. At GitHub in addition to the a 5 second delay
we have a curcuit breaker that checks the replication delay
and will send the query to a replica before the 5 seconds has passed.
This is specific to our application and therefore not something Rails
should be doing for you. You'll need to test and implement more robust
handling of when to switch based on your infrastructure. The auto
switcher in Rails is meant to be a basic implementation / API that acts
as a guide for how to implement autoswitching.

The impementation here is meant to be strict enough that you know how to
implement your own resolver and operations classes but flexible enough
that we're not telling you how to do it.

The middleware is not included automatically and can be installed in
your application with the classes you want to use for the resolver and
operations passed in. If you don't pass any classes into the middleware
the Rails default Resolver and Session classes will be used.

The Resolver decides what parameters define when to
switch, Operations sets timestamps for the Resolver to read from. For
example you may want to use cookies instead of a session so you'd
implement a Resolver::Cookies class and pass that into the middleware
via configuration options.

```
config.active_record.database_selector = { delay: 2.seconds }
config.active_record.database_resolver = MyResolver
config.active_record.database_operations = MyResolver::MyCookies
```

Your classes can inherit from the existing classes and reimplment the
methods (or implement more methods) that you need to do the switching.
You only need to implement methods that you want to change. For example
if you wanted to set the session token for the last read from a replica
you would reimplement the `read_from_replica` method in your resolver
class and implement a method that updates a new timestamp in your
operations class.
2019-01-30 13:37:25 -05:00
Eileen M. Uchitelle
677b658d63
Merge pull request #35102 from eileencodes/fix-case-when-url-in-url-config-is-nil
Fix case when we want a UrlConfig but the URL is nil
2019-01-30 10:26:46 -05:00
Ryuta Kamizono
9f8438a99f
Merge pull request #35101 from bogdanvlviv/remove-unused-code
Remove unused code
2019-01-31 00:18:59 +09:00
Eileen Uchitelle
dedcc19506 Fix case when we want a UrlConfig but the URL is nil
Previously if the `url` key in a config hash was nil we'd ignore the
configuration as invalid. This can happen when you're relying on a
`DATABASE_URL` in the env and that is not set in the environment.

```
production:
  <<: *default
  url: ENV['DATABASE_URL']
```

This PR fixes that case by checking if there is a `url` key in the
config instead of checking if the `url` is not nil in the config.

In addition to changing the conditional we then need to build a url hash
to merge with the original hash in the `UrlConfig` object.

Fixes #35091
2019-01-30 09:31:35 -05:00
bogdanvlviv
b8231433d6
Remove unused code
- Remove `fragment_cache_key` helper declaration.
  It was removed in e70d3df7c9b05c129b0fdcca57f66eca316c5cfc

- Remove `by_private_lifo`.
  It is unused since a7becf147afc85c354e5cfa519911a948d25fc4d
2019-01-30 14:29:17 +00:00
Ryuta Kamizono
9bb07b79e4 Merge pull request #35080 from sos4nt/add_hash_assoc
Add HashWithIndifferentAccess#assoc
2019-01-30 18:05:55 +09:00
Ryuta Kamizono
1cfa913948 Relax version locking of the selenium-webdriver
3.5.2 (September 07, 2017) is a little older.
2019-01-30 17:27:37 +09:00
Ryuta Kamizono
76da7b9d14 Add require "selenium/webdriver" to all using DrivenBySeleniumWith* classes
https://travis-ci.org/rails/rails/jobs/486285170#L1349-L1366

```
% git grep -n DrivenBySeleniumWith
test/abstract_unit.rb:374:class DrivenBySeleniumWithChrome < ActionDispatch::SystemTestCase
test/abstract_unit.rb:378:class DrivenBySeleniumWithHeadlessChrome < ActionDispatch::SystemTestCase
test/abstract_unit.rb:382:class DrivenBySeleniumWithHeadlessFirefox < ActionDispatch::SystemTestCase
test/dispatch/system_testing/screenshot_helper_test.rb:10:    new_test = DrivenBySeleniumWithChrome.new("x")
test/dispatch/system_testing/screenshot_helper_test.rb:18:    new_test = DrivenBySeleniumWithChrome.new("x")
test/dispatch/system_testing/screenshot_helper_test.rb:28:    new_test = DrivenBySeleniumWithChrome.new("x")
test/dispatch/system_testing/screenshot_helper_test.rb:40:    new_test = DrivenBySeleniumWithChrome.new("x")
test/dispatch/system_testing/screenshot_helper_test.rb:48:    new_test = DrivenBySeleniumWithChrome.new("x")
test/dispatch/system_testing/screenshot_helper_test.rb:62:    new_test = DrivenBySeleniumWithChrome.new("x")
test/dispatch/system_testing/screenshot_helper_test.rb:76:class SeleniumScreenshotsTest < DrivenBySeleniumWithChrome
test/dispatch/system_testing/system_test_case_test.rb:11:class OverrideSeleniumSubclassToRackTestTest < DrivenBySeleniumWithChrome
test/dispatch/system_testing/system_test_case_test.rb:19:class SetDriverToSeleniumTest < DrivenBySeleniumWithChrome
test/dispatch/system_testing/system_test_case_test.rb:25:class SetDriverToSeleniumHeadlessChromeTest < DrivenBySeleniumWithHeadlessChrome
test/dispatch/system_testing/system_test_case_test.rb:31:class SetDriverToSeleniumHeadlessFirefoxTest < DrivenBySeleniumWithHeadlessFirefox
test/dispatch/system_testing/system_test_case_test.rb:49:class UndefMethodsTest < DrivenBySeleniumWithChrome
```
2019-01-30 17:15:44 +09:00
Ryuta Kamizono
68eed60eee selenium-webdriver is not always required for system testing
But `NameError: uninitialized constant ActionDispatch::SystemTesting::Browser::Selenium`
is pretty confused. I've little improved missing constant error to
`NameError: uninitialized constant Selenium`.
2019-01-30 16:40:01 +09:00
Stefan Schüßler
fc6a525341 Add HashWithIndifferentAccess#assoc 2019-01-30 08:31:37 +01:00
Ryuta Kamizono
deac9ec430 Fix system testing failure
https://travis-ci.org/rails/rails/jobs/486155626#L1317-L1335
2019-01-30 16:21:10 +09:00
Ryuta Kamizono
bf42e1506b
Merge pull request #35092 from utilum/update_sneakers_to_latest_version
Update Sneakers to the latest version
2019-01-30 14:19:05 +09:00
George Claghorn
370310bb1e
Merge pull request #35094 from palkan/feature/action-cable-load-hooks
Add ActionCable channel/connection load hooks
2019-01-29 22:57:00 -05:00
Vladimir Dementyev
8ed276b2f7
Add ActionCable channel/connection load hooks 2019-01-29 22:07:49 -05:00
Aaron Patterson
e17fe52e0e
Tighten up the AV::Base constructor
The AV::Base constructor was too complicated, and this commit tightens
up the parameters it will take.  At runtime, AV::Base is most commonly
constructed here:

  94d54fa4ab/actionview/lib/action_view/rendering.rb (L72-L74)

This provides an AV::Renderer instance, a hash of assignments, and a
controller instance.  Since this is the common case for construction, we
should remove logic from the constructor that handles other cases.  This
commit introduces special constructors for those other cases.
Interestingly, most code paths that construct AV::Base "strangely" are
tests.
2019-01-29 15:49:40 -08:00
Eileen M. Uchitelle
94d54fa4ab
Merge pull request #35081 from eileencodes/ec-driver-option-updated
[UPDATED] Implement a way to add browser capabilities
2019-01-29 17:54:16 -05:00
utilum
6f4fba43bd Update Sneakers to the latest version
Sneakers 2.11.0 has a more recent Bunny dependency which squashes some
Ruby 2.6 warnings tickled by ActiveJob tests.
2019-01-29 23:52:54 +01:00
Eileen Uchitelle
1a4f613072 Rename methods and update docs
This is a minor update to the named methods for the following:

- s/desired_capabilities/capabilities
- s/driver_options/capabilities

Since they are all the same thing we should keep the name the same
throughout the feature.

Updated docs to match / be a little bit clearer

Also updated the Gemfile for selenium-webdriver.
2019-01-29 11:55:30 -05:00
Ryuta Kamizono
3d22069c63
Merge pull request #35083 from alkesh26/activejob-typo-fixes
Activejob typo fixes.
2019-01-30 01:41:01 +09:00
alkesh26
e356200ca1 activejob typo fixes. 2019-01-29 21:15:12 +05:30
Edouard CHIN
5936bd9a20 driver_option -> driver_options 2019-01-29 08:50:29 -05:00