Commit Graph

73680 Commits

Author SHA1 Message Date
John Hawthorn cd4541a1aa Fix Browser#preload for older Selenium
Older versions of selenium had driver_path on
::Selenium::WebDriver::Chrome directly, not on Service. This avoids
errors on those old versions and will preload properly if webdrivers is
installed.
2019-07-04 15:00:07 -07:00
John Hawthorn a59b230579
Merge pull request #36592 from jhawthorn/system_testing_preload
Preload browser driver_path to fix system testing under parallelism
2019-07-04 13:20:30 -07:00
jacobherrington 6fd43bd071 Fix a typo by removing extra article [ci skip] 2019-07-04 11:00:14 -05:00
Prem Sichanugrist 05ce1769dc
Merge pull request #36594 from jacobherrington/doc/rephrase-ski-ci-instructions
Update docs regarding skipping CI tests [ci skip]
2019-07-04 12:45:37 +09:00
jacobherrington 8a0d1dfc0a Update docs regarding skipping CI tests [ci skip]
The phrasing of this struck we as odd, "To help our CI servers..." So I
feel it would be more useful if we explain more explicitly that ci skip
cuts down on usage by not running CI.
2019-07-03 18:45:26 -05:00
John Hawthorn b21ef26661 Preload browser driver_path for system testing
The webdrivers gem configures Selenium::WebDriver::Service.driver_path
as a proc which updates the web drivers and returns their path.

This commit introduces SystemTesting::Browser#preload, which runs this
proc early. This ensures that webdrivers update is run before forking
for parallel testing, but doesn't explicitly tie us to that gem (and I
think anything configured as driver_path probably makes sense to
eager-load).
2019-07-03 13:56:50 -07:00
Eileen M. Uchitelle 182d475197
Merge pull request #36585 from tr4b4nt/patch-1
Fix swapped replica/primary in multi-db docs [ci skip]
2019-07-03 14:42:45 -04:00
Yuji Yaginuma 141b30630c
Merge pull request #36534 from y-yagi/fixes_35137
Add the ability to set the CSP nonce only to the specified directives
2019-07-03 08:23:48 +09:00
tr4b4nt d71d3f4326
Replace replica with primary in automatic connection switching after write in multi-db docs [ci skip]
Reads after write should be from the primary database.
2019-07-02 16:47:00 +02:00
Ryuta Kamizono 41503f3d08 Revert "Merge pull request #36582 from f1337/master"
This reverts commit 60e19c6d6c, reversing
changes made to 72e257b4c9.

The method signature is different between `create_file` and `template`.

https://www.rubydoc.info/github/erikhuda/thor/master/Thor/Actions#create_file-instance_method
https://www.rubydoc.info/github/erikhuda/thor/master/Thor/Actions#template-instance_method
2019-07-02 11:24:43 +09:00
Ryuta Kamizono 60e19c6d6c
Merge pull request #36582 from f1337/master
[skip ci] use 'template' instead of 'create_file' for erb templates in generators guide
2019-07-02 03:25:48 +09:00
Michael R Fleet 63a863476a use 'template' instead of 'create_file' for erb templates in generators guide [skip ci] 2019-07-01 13:47:53 -04:00
Xavier Noria 72e257b4c9 bumps Zeitwerk
This version makes eager loading and autoloading consistent,
as documented in the upgrading guide.
2019-06-30 23:57:19 +02:00
Xavier Noria 49073faa92 adds two sections to the upgrading notes for autoloading [skip ci] 2019-06-30 23:50:38 +02:00
yuuji.yaginuma 4b621df384 Make `bin/setup` test pass even if the database does not exist 2019-06-30 10:15:26 +09:00
yuuji.yaginuma 89afd816bd Link to top of PR as well as other links [ci skip] 2019-06-29 08:35:23 +09:00
Ryuta Kamizono 1eb5cc13a2 Add "SCHEMA" to the query in `configure_connection` like as other adapters
This makes to be able to ignore the query in `assert_queries` even if
accidentally reconnected a connection.

https://buildkite.com/rails/rails/builds/61917#4c49187a-3173-4d5c-8a8d-d65768f5bfc9/1000-1799
2019-06-28 13:07:39 +09:00
utilum 12bc759325 warning: instance variable @serial not initialized (#36556)
Introduced in bba7c63a66

Before:

```
$ TESTOPTS="-n=/test_yaml_dump_and_load/" bundle exec rake
test:postgresql

:scisors: ... :scisors:

Using postgresql
Run options: -n=/test_yaml_dump_and_load/ --seed 36896

/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
/home/u/code/rails/activerecord/lib/active_record/connection_adapters/postgresql/column.rb:15:
warning: instance variable @serial not initialized
.

Finished in 0.195325s, 5.1197 runs/s, 35.8376 assertions/s.
1 runs, 7 assertions, 0 failures, 0 errors, 0 skips

```

Co-authored-by: Ryuta Kamizono <kamipo@gmail.com>
2019-06-28 07:02:38 +09:00
Eileen M. Uchitelle 04d2fda1f8
Merge pull request #36565 from rails/fix-url-configs
Fix broken url configs
2019-06-27 13:37:32 -04:00
eileencodes f2ad69fe7a Fix broken url configs
This PR is to fix #36559 but I also found other issues that haven't been
reported.

The check for `(config.size == 1 && config.values.all? { |v| v.is_a?
String })` was naive. The only reason this passed was because we had
tests that had single hash size configs, but that doesn't mean we don't
want to create a hash config in other cases. So this now checks for
`config["database"] || config["adapter"] || ENV["DATABASE_URL"]`. In the
end for url configs we still get a UrlConfig but we need to pass through
the HashConfig to create the right kind of UrlConfig. The UrlConfig's
are really complex and I don't necessarily understand everything that's
needed in order to act the same as Rails 5.2.

I edited the connection handler test to demonstrate how the previous
implementation was broken when checking config size. Now old and new
tests pass so I think this is closer to 5.2.

Fixes #36559
2019-06-27 13:07:23 -04:00
Ryuta Kamizono 7e08b6d2b2 Address to "DEPRECATION WARNING: Uniqueness validator will no longer enforce case sensitive comparison in Rails 6.1"
Caused by #36210.
2019-06-28 00:28:47 +09:00
Eileen M. Uchitelle 40246125b9
Merge pull request #36560 from eileencodes/warn-if-database-yml-cant-be-read
Warn if we can't read the yaml to create database tasks
2019-06-27 10:08:08 -04:00
eileencodes df6b0de7d9 Load initial database.yml once, and warn if we can't create tasks
For multiple databases we attempt to generate the tasks by reading the
database.yml before the Rails application is booted. This means that we
need to strip out ERB since it could be reading Rails configs.

In some cases like https://github.com/rails/rails/issues/36540 the ERB
is too complex and we can't overwrite with the DummyCompilier we used in
https://github.com/rails/rails/pull/35497. For the complex causes we
simply issue a warning that says we couldn't infer the database tasks
from the database.yml.

While working on this I decided to update the code to only load the
database.yml once initially so that we avoid having to issue the same
warning multiple times. Note that this had no performance impact in my
testing and is merely for not having to save the error off somewhere.
Also this feels cleaner.

Note that this will not break running tasks that exist, it will just
mean that tasks for multi-db like `db:create:other_db` will not be
generated. If the database.yml is actually unreadable it will blow up
during normal rake task calls.

Fixes #36540
2019-06-27 09:54:25 -04:00
Masayuki Morita 1518ce3dc8 [ci skip] Update free-programming-books link in getting started guide
https://github.com/vhf/free-programming-books seems to have moved to
https://github.com/EbookFoundation/free-programming-books
2019-06-26 22:02:42 -05:00
Ryuta Kamizono f6db8b8d82 `length(title)` is a safe SQL string since #36448 2019-06-26 08:56:00 +09:00
Rafael França e80cf005b6
Merge pull request #36555 from dineshpanda/update-initialization-guide
[ci skip] Refer actionmailbox and actiontext in the guide
2019-06-25 17:50:32 -04:00
dineshpanda c3a08f8844 [ci skip] Refer actionmailbox and actiontext in the guide 2019-06-26 03:07:50 +05:30
Ryuta Kamizono 7a5e2b51dc
Merge pull request #36553 from tatsuyafw/fix-robots-txt-url
Replace the www.robotstxt.org URL with https one [ci skip]
2019-06-25 23:42:48 +09:00
Tatsuya Hoshino 1466701fab Replace the www.robotstxt.org URL with https one [ci skip]
The robots.txt site is moved permanently to https URL.
2019-06-25 23:20:19 +09:00
Rafael França 1aa90ddc1c
Merge pull request #36530 from benoittgt/source_annotation_deprecation_issue
Rely on Kernel require instead of self require
2019-06-24 14:57:43 -04:00
Rafael França b65f88652f
Merge pull request #36210 from vishaltelangre/raise-record-invalid-when-associations-fail-to-save-due-to-uniqueness-failure
Fix: ActiveRecord::RecordInvalid is not raised when an associated record fails to #save! due to uniqueness validation failure
2019-06-24 13:59:15 -04:00
Aaron Suarez 58256db507 Update link to OWASP XSS cheat sheet [ci skip] 2019-06-23 21:13:11 -04:00
yuuji.yaginuma 74e38da810 Test against all sent attributes 2019-06-23 10:33:29 +09:00
Benoit Tigeot 968fcd6b80
Rely on Kernel require instead of self require
With this code (exctracted from derailed_benchmarks):

```ruby

require "bundler/inline"

gemfile(true) do
  source "https://rubygems.org"

  gem "rails", "~> 6.0.0.rc1", require: false
end

FILES = [
  "rails/engine/configuration",
  "rails/source_annotation_extractor",
  "active_support/deprecation"
]

module Kernel
  alias :original_require :require

  def require(file)
    Kernel.require(file)
  end

  class << self
    alias :original_require :require
  end
end

Kernel.define_singleton_method(:require) do |file|
  original_require(file)
end

FILES.each do |file|
  puts "requiring file: #{file}"
  require file
end
```

It fails with Rails 6 and the change introduced by 32065
```
requiring file: rails/engine/configuration
requiring file: rails/source_annotation_extractor
Traceback (most recent call last):
	11: from repro_derailed.rb:33:in `<main>'
	10: from repro_derailed.rb:33:in `each'
	 9: from repro_derailed.rb:35:in `block in <main>'
	 8: from repro_derailed.rb:21:in `require'
	 7: from repro_derailed.rb:30:in `block in <main>'
	 6: from repro_derailed.rb:30:in `require'
	 5: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/railties-6.0.0.rc1/lib/rails/source_annotation_extractor.rb:8:in `<top (required)>'
	 4: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:10:in `new'
	 3: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:10:in `new'
	 2: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:125:in `initialize'
	 1: from /Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:23:in `method_missing'
/Users/benoit.tigeot/.rvm/gems/ruby-2.5.1/gems/activesupport-6.0.0.rc1/lib/active_support/deprecation/proxy_wrappers.rb:148:in `warn': private method `warn' called for nil:NilClass (NoMethodError)
```

Related:
- https://github.com/schneems/derailed_benchmarks/pull/130
- https://github.com/rails/rails/pull/32065
2019-06-22 09:11:16 +02:00
yuuji.yaginuma 09d55b3022 Add the ability to set the CSP nonce only to the specified directives
I changed to set CSP nonce to `style-src` directive in #32932.
But this causes an issue when `unsafe-inline` is specified to `style-src`
(If a nonce is present, a nonce takes precedence over `unsafe-inline`).

So, I fixed to nonce directives configurable. By configure this, users
can make CSP as before.

Fixes #35137.
2019-06-22 12:44:37 +09:00
Akira Matsuda a2a515d9de Indentation >> 2019-06-22 05:22:07 +09:00
Kasper Timm Hansen ef1dbd8cc7
Schema Cache: extract deduplication commonality 2019-06-21 18:20:16 +02:00
Kasper Timm Hansen 75a0cf4f8b
Merge pull request #36529 from Shopify/schema-cache-deduplication-init-with
Also deduplicate schema cache data when using the init_with interface
2019-06-21 18:13:10 +02:00
Jean Boussier bba7c63a66 Also deduplicate schema cache data when using the init_with interface 2019-06-21 12:11:16 +02:00
Yuji Yaginuma c631e8d011
Merge pull request #36490 from y-yagi/revise_36034
Make `ActionDispatch::Response#content_type` behavior configurable
2019-06-21 09:04:30 +09:00
yuuji.yaginuma ddb6d788d6 Make `ActionDispatch::Response#content_type` behavior configurable
I changed return value of `ActionDispatch::Response#content_type` in #36034.
But this change seems to an obstacle to upgrading. https://github.com/rails/rails/pull/36034#issuecomment-498795893

Therefore, I restored the behavior of `ActionDispatch::Response#content_type`
to 5.2 and deprecated old behavior. Also, made it possible to control the
behavior with the config.
2019-06-21 07:17:14 +09:00
Ryuta Kamizono 3218459c28
Merge pull request #36526 from yahonda/test_statement_cache_with_in_clause_pg
Address test_statement_cache_with_in_clause failure
2019-06-21 06:40:02 +09:00
Rafael França 06c38ce5d5
Merge pull request #36525 from eileencodes/revert-integer-change-to-schema-migration
Revert schema dumper to use strings rather than integers
2019-06-20 14:28:41 -04:00
Yasuo Honda 688da62a4c Address test_statement_cache_with_in_clause failure due to nondeterministic sort order
This failure is occasional, does not always reproduce.

```ruby
$ cd activerecord
$ bundle exec rake test_postgresql
... snip ...

....F

Failure:
ActiveRecord::BindParameterTest#test_statement_cache_with_in_clause [/home/yahonda/git/rails/activerecord/test/cases/bind_parameter_test.rb:97]:
Expected: [1, 3]
  Actual: [3, 1]

rails test home/yahonda/git/rails/activerecord/test/cases/bind_parameter_test.rb:93

```
2019-06-20 15:07:58 +00:00
eileencodes 4feeee2abe Revert schema dumper to use strings rather than integers
I think we should change this, but not in 6-0-stable since that's
already in RC and I was trying to only make changes that won't require
any app changes.

This reverts a portion of https://github.com/rails/rails/pull/36439 that
made all schema migration version numbers get dumped as an integer.
While it doesn't _really_ matter it did change behavior. We should bring
this back in 6.1 with a deprecation.
2019-06-20 14:00:42 +02:00
Ryuta Kamizono e14f3f3c11
Merge pull request #36520 from kamipo/test_case_for_deterministic_order
Add test cases to ensure deterministic order for ordinal methods
2019-06-20 18:07:40 +09:00
Yuji Yaginuma defd6c411e
Merge pull request #36523 from y-yagi/include_bcc_in_mail_sent_from_development_page
Include BCC in the mail that sent from the development page
2019-06-20 17:32:53 +09:00
yuuji.yaginuma aab9f6734d Include BCC in the mail that sent from the development page
The BCC should be included as we show input field for BCC in view.
bf625f7fec/actionmailbox/app/views/rails/conductor/action_mailbox/inbound_emails/new.html.erb (L21-L24)
2019-06-20 14:09:01 +09:00
Yuji Yaginuma bf625f7fec
Merge pull request #36486 from benthorner/master
Allow using env var to specify pidfile
2019-06-20 11:52:21 +09:00
Kasper Timm Hansen 8a20a40fef
Merge pull request #36518 from Shopify/drop-schema-cache-column-hash
Stop serializing and parsing columns_hash in Active Record schema caches
2019-06-19 21:22:01 +02:00