Commit Graph

1937 Commits

Author SHA1 Message Date
Patrik Bóna
8e07711d65 Do not enable disabled elements for XHR redirects
Fixes #29473.
2018-09-27 10:59:56 +02:00
Rafael França
05a66686f1
Merge pull request #33975 from JuanitoFatas/jf.fix-test-name
[CaptureHelperTest] Fix a content_for test description
2018-09-25 17:54:30 -04:00
Rafael Mendonça França
49f9dff9b6
Fix more offences 2018-09-25 13:21:40 -04:00
Rafael Mendonça França
f679933daa
Change the empty block style to have space inside of the block 2018-09-25 13:19:35 -04:00
Aaron Patterson
6d698fdb07
Merge pull request #33973 from rails/remove-catch-all
Remove deprecated catch-all route in the AV tests
2018-09-25 09:27:37 -07:00
Juanito Fatas
6f36168eca Fix a content_for test description 2018-09-25 15:15:35 +09:00
Aaron Patterson
3301804ff6
make bot happy 2018-09-24 16:01:34 -07:00
Aaron Patterson
4f96e739c2
Remove deprecated catch-all route in the AV tests
This commit removes a deprecated catch-all route in the AV tests.  It
defines and includes the necessary routes for each test such that we
don't need the catch-all anymore.

This also helps push us toward #33970
2018-09-24 15:39:15 -07:00
Kasper Timm Hansen
22dc2b3db8
Merge pull request #33949 from sjain1107/no-private-def
Remove private def
2018-09-23 19:39:15 +02:00
Sakshi Jain
0fe2bb816f Remove private def 2018-09-23 21:27:44 +05:30
yuuji.yaginuma
1b86d90136 Enable Performance/UnfreezeString cop
In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`.

```ruby
# frozen_string_literal: true

require "bundler/inline"

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

  gem "benchmark-ips"
end

Benchmark.ips do |x|
  x.report('+@') { +"" }
  x.report('dup') { "".dup }
  x.compare!
end
```

```
$ ruby -v benchmark.rb
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
Warming up --------------------------------------
                  +@   282.289k i/100ms
                 dup   187.638k i/100ms
Calculating -------------------------------------
                  +@      6.775M (± 3.6%) i/s -     33.875M in   5.006253s
                 dup      3.320M (± 2.2%) i/s -     16.700M in   5.032125s

Comparison:
                  +@:  6775299.3 i/s
                 dup:  3320400.7 i/s - 2.04x  slower

```
2018-09-23 08:56:55 +09:00
Rafael França
013749ecff
Merge pull request #33564 from avit/escape_javascript_casting
Let escape_javascript handle conversion to string
2018-09-21 17:06:45 -04:00
Andrew Vit
dd0cfb03b2 Let escape_javascript handle conversion to string
This brings `escape_javascript` in line with the behavior of `json_escape` and
allows other value types to be output without needing explicit casting in the
view template.

Example:

    <%= javascript_tag do %>
      var locale = '<%== j I18n.locale %>'; // locale is a symbol
    <% end %>
2018-09-21 12:30:40 -07:00
schneems
e8283dabd2 [ci skip] document collection_caching.rb 2018-09-19 18:03:16 -05:00
John Hawthorn
a33776b0f5 Fix for variants: :any special case 2018-09-12 18:22:09 -07:00
John Hawthorn
cc9a0de660 Use wildcard glob for optimized template resolving 2018-09-12 17:54:23 -07:00
schneems
99d260298c Move digest path calculation out of loop
On every iteration of generating a cache for a collection a “digest path” is calculated even though it’s exactly the same for every element.

This PR exposes a method `digest_path_from_virtual` that returns back a “digest_path”. This can in turn be passed back into `cache_fragment_name`. This not only does less work, but it also (you guessed it) uses  less memory.

before: Total allocated: 762539 bytes (7035 objects)
after: Total allocated: 743590 bytes (6621 objects) 


(762539 - 743590)/ 762539.0 # => 2.4% faster 
2018-09-11 16:52:44 -05:00
schneems
1bd578ffe6 Don’t allocate array on no args
When no dependencies are present to be digested there is no reason to build an array just to turn around and turn it back into a string.

The dependencies array is not mutated in this method so we can use the same empty array across all invocations.

Total allocated: 791402 bytes (7294 objects)
Total allocated: 777442 bytes (7132 objects)

(791402 - 777442) / 791402.0 # => 1.76 % speed improvement
2018-09-07 17:33:10 -05:00
Ryuta Kamizono
736edb9828 Formatting CHANGELOGs [ci skip]
Fixing code block rendering, indentation, backticks, etc.
2018-09-07 07:59:19 +09:00
schneems
31cfd5e4fd [ci skip] Doc ActionView::OutputBuffer 2018-09-06 15:28:45 -05:00
schneems
a01f4d53b3 [ci skip] Clarify CaptureHelper#capture function 2018-09-06 11:12:55 -05:00
Matthew Draper
068fe7dc90
Merge pull request #33718 from kddeisz/permit-list
Finish converting whitelist and blacklist references
2018-08-29 14:07:37 +09:30
Kevin Deisz
7c9751d7fe
Permit list usage cleanup and clearer documentation 2018-08-27 09:51:46 -04:00
bogdanvlviv
3a598ae6d1
Add :namespace option to the api docs of form_with [ci skip] 2018-08-27 15:40:09 +03:00
Kevin Deisz
cac2bb7f44
Deprecate usage of ActionView::Template::Handlers::ERB::escape_whitelist 2018-08-24 16:13:57 -04:00
Kevin Deisz
c14859513a
Convert over the rest of the whitelist references 2018-08-24 16:10:17 -04:00
Matthew Draper
047a893da7 Merge pull request #33547 from Ana06/patch-1
Use public_send in value_for_collection
2018-08-23 00:08:35 +09:30
Ryuta Kamizono
103b02f152
Merge pull request #31132 from emaxi/feature/add-missing-documentation-option-to-number-to-currency
Add missing documentation option to number_to_currency

[ci skip]
2018-08-20 10:49:54 +09:00
Ryuta Kamizono
b2c1e29c14 Enable Style/ParenthesesAroundCondition cop
To prevent style check in review like https://github.com/rails/rails/pull/33608#discussion_r211087605.
2018-08-19 08:16:21 +09:00
yuuji.yaginuma
87d5415f0a Fix unclosed tags [ci skip] 2018-08-18 16:23:20 +09:00
Prem Sichanugrist
88c4ea1d2d Update coffeelint to 2.1.0
There was a warning when running `npm install` in Action View:

    coffee-script@1.11.1: CoffeeScript on NPM has moved to
    "coffeescript" (no hyphen)

We are not requiring `coffee-script` explicitly, but `coffeelint` does.
The latest version, 2.1.0, already fix the dependency package name, so
we should upgrade to it to suppress the warning.
2018-08-13 10:22:25 +09:00
Ana María Martínez Gómez
0853cdffa2 Add tests for privates methods in view's helpers
Test that using private methods in `options_from_collection_for_select`
is deprecated.

Make the unused `secret` paramether in the `Post` Struct private to use
it in the test.
2018-08-08 18:04:50 +02:00
Ana María Martínez Gómez
4ca9fa11f9 Deprecate use of private methods in view's helpers
Instead of dropping it completely in case someone is relying (probably
inadvertenly) on it.
2018-08-08 11:47:11 +02:00
Ana María Martínez Gómez
0c62e141a3 Add one more method affected in CHANGELOG 2018-08-08 10:47:19 +02:00
Ana María Martínez Gómez
a9764dcc07 Use public_send in extract_values_from_collection
Avoid exposing private methods in view's helpers. However, as
`extract_values_from_collection` is only called from
`options_from_collection_for_select` where `value_for_collection` is
previously called, this case was already covered. The change makes
anyway sense for consistency and in case the code changes in the
future.
2018-08-08 10:14:13 +02:00
Ana María Martínez Gómez
87b6e6aa43 Use public_send in value_for_collection
Avoid exposing private methods in view's helpers.

Fixes https://github.com/rails/rails/issues/33546
2018-08-07 17:45:12 +02:00
Alberto Almagro
67265a3ab0 [ci skip] Change references from Rake task to Rails command
This commit follows the path we started at commit #ea4f0e2
and continued at PR #33229.
2018-08-01 22:44:53 +02:00
Kazuhiro NISHIYAMA
9df747c9f0 Throw if ujs loaded twice
I saw two posts of problem about ajax requesting twice on qiita.
So I think detecting double loaded earlier make easy to find the problem.

https://qiita.com/hot_study_man/items/56dc87ad734cfda68bb6
https://qiita.com/hisas/items/8399aec3a5377bf75017
2018-07-31 22:16:02 +09:00
Bart de Water
eb5fea40a4 Enable Start/EndWith and RegexpMatch cops
In cases where the MatchData object is not used, this provides a speed-up:
https://github.com/JuanitoFatas/fast-ruby/#stringmatch-vs-stringmatch-vs-stringstart_withstringend_with-code-start-code-end
2018-07-28 17:37:17 -04:00
Dillon Welch
d108288c2f
Turn on performance based cops
Use attr_reader/attr_writer instead of methods

method is 12% slower

Use flat_map over map.flatten(1)

flatten is 66% slower

Use hash[]= instead of hash.merge! with single arguments

merge! is 166% slower

See https://github.com/rails/rails/pull/32337 for more conversation
2018-07-23 15:37:06 -07:00
Richard Schneeman
c11fc3b71c
Merge pull request #33268 from benpickles/remove-pubdate-from-docs
Keep time_tag docs up-to-date.
2018-07-21 13:39:37 -05:00
Yurii Cherniavskyi
d4a4a6f118 Fix leaking special form_with attributes into html attributes
Special form_with attributes `skip_default_ids` and `allow_method_names_outside_object`
attributes are leaking into html attributes of option select tag helpers.
2018-07-20 23:21:02 +03:00
Georgi Georgiev
113d8a2ba3 Fix issue with button_to's to_form_params
`button_to` was throwing exception when invoked with `params` hash that
contains symbol and string keys. The reason for the exception was that
`to_form_params` was comparing the given symbol and string keys.

The issue is fixed by turning all keys to strings inside
`to_form_params` before comparing them.
2018-07-16 09:44:22 +03:00
emaxi
6e1a536ad4 Add missing documentation options to number_to_currency [ci skip] 2018-07-11 20:59:51 -03:00
Tsukuru Tanimichi
4eb9c01e39
[ci skip] sanitizer_vendor will be removed in Rails 6
Related to https://github.com/rails/rails/pull/24386#issuecomment-403926683
2018-07-11 10:04:49 +09:00
Ryuta Kamizono
90e2739d86 Merge pull request #33286 from ph3t/add-changelog-entry-for-42c3537
Add changelog entry for 42c3537 [ci skip]
2018-07-04 09:43:56 +09:00
Juan Broullon
54c2c6de17 Add changelog entry for 42c3537 [ci skip] 2018-07-03 16:38:25 -04:00
Kasper Timm Hansen
a3a876f809
Merge pull request #32361 from ph3t/safe-html-translation-arrays
Add safe html support to arrays of translations
2018-07-03 18:27:29 +02:00
Juan Broullon
42c353705a Add safe html support to arrays of translations 2018-07-03 11:50:02 -04:00
Ben Pickles
46bb787c04 Keep time_tag docs up-to-date.
The pubdate attribute was removed from the spec, see
940eec417f20e53abd3e3114c7fa845dac0d3a62 for context.
2018-07-01 12:33:00 +01:00