Commit Graph

71518 Commits

Author SHA1 Message Date
George Claghorn
a4c0157312
Merge pull request #34878 from bogdanvlviv/action_text-guides-docs
Add Action Text to guides [ci skip]
2019-01-05 11:04:21 -05:00
George Claghorn
20f1f22a78
Merge pull request #34879 from bogdanvlviv/add-skip-action-text-option-to-rails-new-cmd
Add `--skip-action-text` option to `rails new`
2019-01-05 10:42:47 -05:00
George Claghorn
9035000241
Merge pull request #34877 from bogdanvlviv/document-action_text_content-hook
Add `action_text_content` hook to the guide [ci skip]
2019-01-05 10:42:01 -05:00
George Claghorn
7a88f649da
Merge pull request #34875 from bogdanvlviv/test-actiontext-on-rails-6.0
Test actiontext on Rails 6.0
2019-01-05 10:41:41 -05:00
George Claghorn
35ed21bc16
Merge pull request #34876 from bogdanvlviv/remove-needless-comment-actiontext.gemspec
Remove comment from `actiontext/actiontext.gemspec`
2019-01-05 10:41:08 -05:00
George Claghorn
a13612b070
Merge pull request #34874 from bogdanvlviv/fix-RichText-api-docs
Fix API docs of `ActionText::RichText` [ci skip]
2019-01-05 10:40:37 -05:00
Javan Makhmali
2832ca131d
Merge pull request #34709 from gmcgibbon/action_cable_guides_es6
Use ES6 and Webpacker in ActionCable guide.
2019-01-05 06:18:15 -08:00
bogdanvlviv
67a9a86b1d
Test actiontext on Rails 6.0
- config.load_defaults 6.0 in the dummy app and
  fix the test since by default rails 6.0 configured
  does not generate "utf8" hidden input, see #32125
- Use `ActiveRecord::Migration[6.0]` in the dummy app
  since actiontext will be since Rails 6.0
- Fix `CreateActiveStorageTables` migration in the dummy app.
  Add `t.foreign_key :active_storage_blobs, column: :blob_id`
  It was added in 2ae3a29508e.
- `rails/actiontext$ yarn install`
2019-01-05 15:24:27 +02:00
bogdanvlviv
6b8048173d
Add --skip-action-text option to rails new
Since PR#34816 was merged in c6ef670aee186a2880b7be59c4c6892b5c983e58,
we should add this option for flexibility, and consistency.
2019-01-05 13:54:35 +02:00
bogdanvlviv
0fb6c9011f
Add Action Text to guides [ci skip]
- Move some actiontext/README.md content to Action Text Overview guide
- I added WIP label to that guide since we definitely want to complement it.
- Add Action Text to Major Features of Rails 6.0

Similar approach was used in #34812
2019-01-05 13:30:37 +02:00
bogdanvlviv
3bf3286ba0
Add action_text_content hook to the guide [ci skip]
See actiontext/lib/action_text/content.rb:132
2019-01-05 12:17:26 +02:00
bogdanvlviv
b04b008b3d
Remove comment from actiontext/actiontext.gemspec
This comment was autogenerated, see
`railties/lib/rails/generators/rails/plugin/templates/%name%.gemspec.tt`
Since actiontext is well described in this file, I think we shouldn't
keep this comment. Note that this commit is more like cosmetic change,
so it is OK if we don't merge this.
2019-01-05 11:57:26 +02:00
bogdanvlviv
78ed534f30
Fix API docs of ActionText::RichText [ci skip]
This text should appear on the page
https://api.rubyonrails.org/v6.0/classes/ActionText/RichText.html

Related to 86517942e469193e8624d5078d718785552c1270
2019-01-05 11:01:47 +02:00
George Claghorn
86517942e4 Generate Action Text's API docs 2019-01-04 23:56:22 -05:00
George Claghorn
76c02013ad Label Action Text PRs [ci skip] 2019-01-04 23:48:30 -05:00
George Claghorn
df8ee09ce7
Merge pull request #34873 from georgeclaghorn/actiontext
Import Action Text
2019-01-04 23:09:12 -05:00
George Claghorn
0decd2ddc4 Import Action Text 2019-01-04 22:22:49 -05:00
Rosa Gutierrez
88349cee3c Support in-flight jobs stored before individual execution counters for retry_on (#34731)
Also, make tests and examples for individual execution counters
clearer, as it wasn't entierly clear what would happen in this case:

```
retry_on CustomException, OtherException, attempts: 3
```

The job would be retried at most 3 times in total, for both
CustomException and OtherException. To have the job retry 3 times at
most for each exception individually, the following retry_on
declarations are necessary:

```
retry_on CustomException, attempts: 3
retry_on OtherException, attempts: 3
```
2019-01-05 13:54:38 +13:00
Gannon McGibbon
195da08ef7 Use ES6 and Webpacker in ActionCable guide.
[ci skip]
2019-01-04 17:31:24 -05:00
Rikki Pitt
cfe4674d36 Update tag helper routes for use in engines (#49)
When using the `rich_text_area_tag` form helper from within a Rails
engine, the direct_upload_url and blob_url_template options would
default to non-existent routes.

By prefixing these routes with `main_app` we ensure the application
root is used rather than the engine.
2019-01-04 13:57:43 -08:00
George Claghorn
8a23a0e8c2
Merge pull request #34867 from bogdanvlviv/test-actionmailbox-configurations
Test Action Mailbox configurations
2019-01-04 16:17:51 -05:00
Kasper Timm Hansen
188ce3567f
Merge pull request #34870 from bogdanvlviv/fix-new_framework_defaults_6_0.rb-file
Fix `new_framework_defaults_6_0.rb` file
2019-01-04 22:05:18 +01:00
Rafael França
d3159cec60
Merge pull request #34866 from bogdanvlviv/add-activemodel_errors_of_kind
Add `ActiveModel::Errors#of_kind?`
2019-01-04 15:53:55 -05:00
Ryuta Kamizono
15383eea36
Merge pull request #34871 from bogdanvlviv/clarify-delegate_missing_to
Clarify `delegate_missing_to` [ci skip]
2019-01-05 05:29:41 +09:00
bogdanvlviv
ee79a842ff
Clarify delegate_missing_to [ci skip]
Since #34864 removed explicit receiver to clarify the
purpose of `delegate_missing_to`, I think it will be
better to do the same a few lines above to easier figure
out that `delegate_missing_to` defines `method_missing`,
`respond_to_missing?` when comparing these examples.
2019-01-04 22:18:00 +02:00
bogdanvlviv
9e1a567b07
Fix new_framework_defaults_6_0.rb file
`Rails.application.config.active_job.return_false_on_aborted_enqueue`
should be commented as well.
2019-01-04 21:58:18 +02:00
bogdanvlviv
1d53654a98
Test Action Mailbox configurations
Related to 0d40c62213
2019-01-04 21:32:07 +02:00
bogdanvlviv
d5c26c43c0
Add ActiveModel::Errors#of_kind?
Related to https://github.com/rails/rails/pull/34817#issuecomment-451508668
2019-01-04 20:47:31 +02:00
George Claghorn
663f6cc14f
Send Active Storage jobs to dedicated queues by default
Match Action Mailbox, which sets a default queue for each of its two jobs.
2019-01-04 12:43:51 -05:00
Rafael França
a86b64918b
Merge pull request #34864 from mikegee/patch-1
Clarify benefit of `delegate_missing_to`
2019-01-04 11:56:02 -05:00
Michael Gee
348f8e0c91
Clarify benefit of delegate_missing_to
Removing the explicit receiver clarifies the purpose of `delegate_missing_to`.
2019-01-04 11:50:30 -05:00
Eileen M. Uchitelle
9f0928322f
Merge pull request #34797 from gsamokovarov/views-without-defined-protect-against-forgery
Don't expect defined protect_against_forgery? in {token,csrf_meta}_tag
2019-01-04 09:18:36 -05:00
Vipul A M
de50002723
Merge pull request #34862 from bogdanvlviv/fix-i18n-guide
Fix example of I18n setting in the guide [ci skip]
2019-01-04 17:08:25 +03:00
bogdanvlviv
939b85af70
Fix example of I18n setting in the guide [ci skip]
Since #34356 logging `locale` value is more correct
2019-01-04 16:04:55 +02:00
Eileen M. Uchitelle
725c6422e7
Merge pull request #34773 from eileencodes/share-fixture-connections-with-multiple-handlers
For fixtures share the connection pool when there are multiple handlers
2019-01-04 08:49:17 -05:00
Ryuta Kamizono
a5a22c4ea1
Merge pull request #34858 from albertoalmagro/make-rails-compatible-accross-ruby-versions
Make average compatible across ruby versions
2019-01-04 10:32:37 +09:00
Alberto Almagro
d237c7c72c Make average compatible accross Ruby versions
Since Ruby 2.6.0 NilClass#to_d is returning `BigDecimal` 0.0, this
breaks `average` compatibility with prior Ruby versions. This patch
makes `average` return `nil` in all Ruby versions when there are no
rows.
2019-01-04 00:41:22 +01:00
Alberto Almagro
3f2c865731 Revert "Fix NumericData.average test on ruby 2.6"
This reverts commit 89b4612ffc97e6648f5cf807906ae210e05acdda.
2019-01-04 00:32:33 +01:00
Rafael França
912db8bd06
Merge pull request #34855 from bogdanvlviv/update-configuring-guide
Update the "Configuring Rails Applications" guide [ci skip]
2019-01-03 18:20:50 -05:00
bogdanvlviv
4348b4afa1
Update the "Configuring Rails Applications" guide [ci skip]
Add section "Results of `load_defaults`" to the guide.
2019-01-04 01:17:15 +02:00
Ryuta Kamizono
7a4e20e0cd Merge the redundant when Symbol case to the when String, ... 2019-01-04 08:05:17 +09:00
Ryuta Kamizono
e9aa0c5c72 2x faster connection.type_cast
`nil`, `Numeric`, and `String` are most basic objects which are passed
to `type_cast`. But now each `when *types_which_need_no_typecasting`
evaluation allocates extra two arrays, it makes `type_cast` slower.

The `types_which_need_no_typecasting` was introduced at #15351, but the
method isn't useful (never used any adapters) since all adapters
(sqlite3, mysql2, postgresql, oracle-enhanced, sqlserver) still
overrides the `_type_cast`.

Just expanding the method would make the `type_cast` 2x faster.

```ruby
module ActiveRecord
  module TypeCastFast
    def type_cast_fast(value, column = nil)
      value = id_value_for_database(value) if value.is_a?(Base)

      if column
        value = type_cast_from_column(column, value)
      end

      _type_cast_fast(value)
    rescue TypeError
      to_type = column ? " to #{column.type}" : ""
      raise TypeError, "can't cast #{value.class}#{to_type}"
    end

    private
      def _type_cast_fast(value)
        case value
        when Symbol, ActiveSupport::Multibyte::Chars, Type::Binary::Data
          value.to_s
        when true       then unquoted_true
        when false      then unquoted_false
        # BigDecimals need to be put in a non-normalized form and quoted.
        when BigDecimal then value.to_s("F")
        when nil, Numeric, String then value
        when Type::Time::Value then quoted_time(value)
        when Date, Time then quoted_date(value)
        else raise TypeError
        end
      end
  end
end

conn = ActiveRecord::Base.connection
conn.extend ActiveRecord::TypeCastFast

Benchmark.ips do |x|
  x.report("type_cast") { conn.type_cast("foo") }
  x.report("type_cast_fast") { conn.type_cast_fast("foo") }
  x.compare!
end
```

```
Warming up --------------------------------------
           type_cast    58.733k i/100ms
      type_cast_fast   101.364k i/100ms
Calculating -------------------------------------
           type_cast    708.066k (± 5.9%) i/s -      3.583M in   5.080866s
      type_cast_fast      1.424M (± 2.3%) i/s -      7.197M in   5.055860s

Comparison:
      type_cast_fast:  1424240.0 i/s
           type_cast:   708066.0 i/s - 2.01x  slower
```
2019-01-04 07:24:57 +09:00
Rafael Mendonça França
c6ef670aee
Merge pull request #34816 from bogdanvlviv/add-skip-action-mailbox-option-to-rails-new-cmd
Add `--skip-action-mailbox` option to `rails new`
2019-01-03 16:36:17 -05:00
Eileen Uchitelle
b24bfcce77 Share the connection pool when there are multiple handlers
In an application that has a primary and replica database the data
inserted on the primary connection will not be able to be read by the
replica connection.

In a test like this:

```
test "creating a home and then reading it" do
  home = Home.create!(owner: "eileencodes")

  ActiveRecord::Base.connected_to(role: :default) do
    assert_equal 3, Home.count
  end

  ActiveRecord::Base.connected_to(role: :readonly) do
    assert_equal 3, Home.count
  end
end
```

The home inserted in the beginning of the test can't be read by the
replica database because when the test is started a transasction is
opened byy `setup_fixtures`. That transaction remains open for the
remainder of the test until we are done and run `teardown_fixtures`.

Because the data isn't actually committed to the database the replica
database cannot see the data insertion.

I considered a couple ways to fix this. I could have written a database
cleaner like class that would allow the data to be committed and then
clean up that data afterwards. But database cleaners can make the
database slow and the point of the fixtures is to be fast.

In GitHub we solve this by sharing the connection pool for the replicas
with the primary (writing) connection. This is a bit hacky but it works.
Additionally since we define `replica? || preventing_writes?` as the
code that blocks writes to the database this will still prevent writing
on the replica / readonly connection. So we get all the behavior of
multiple connections for the same database without slowing down the
database.

In this PR the code loops through the handlers. If the handler doesn't
match the default handler then it retrieves the connection pool from the
default / writing handler and assigns the reading handler's connections
to that pool.

Then in enlist_fixture_connections it maps all the connections for the
default handler because all the connections are now available on that
handler so we don't need to loop through them again.

The test uses a temporary connection pool so we can test this with
sqlite3_mem. This adapter doesn't behave the same as the others and
after looking over how the query cache test works I think this is the
most correct. The issues comes when calling `connects_to` because that
establishes new connections and confuses the sqlite3_mem adapter. I'm
not entirely sure why but I wanted to make sure we tested all adapters
for this change and I checked that it wasn't the shared connection code
that was causing issues - it was the `connects_to` code.
2019-01-03 16:32:46 -05:00
Gannon McGibbon
cc3cc6b50f
Merge pull request #34706 from ChrisBr/instrumentation-guide
Add missing keys to ActiveSupport#instrumentation guide [skip ci]
2019-01-03 12:34:58 -05:00
Kasper Timm Hansen
6f0cda8f8e
Merge pull request #33985 from eugeneius/attribute_methods_schema_cache
Only define attribute methods from schema cache
2019-01-03 15:03:06 +01:00
David Heinemeier Hansson
2584762cd9 Capistrano is no longer a dominant force in the deployment strategy for new apps 2019-01-03 21:27:44 +11:00
yuuji.yaginuma
2191c537ad Use latest Bundler
Don't need to specify the version because Bundler 2.0 released.
Ref: https://bundler.io/blog/2019/01/03/announcing-bundler-2.html
2019-01-03 15:40:54 +09:00
Ryuta Kamizono
f04e04b45c
Merge pull request #34846 from palkan/fix/ar-reaper-test
fix activerecord reaper_test
2019-01-03 08:51:06 +09:00
Vladimir Dementyev
6ea356e978
fix activerecord reaper_test 2019-01-02 17:55:48 -05:00