Commit Graph

2382 Commits

Author SHA1 Message Date
Hector Bustillos 92fea7a574 number_to_currency negative zero fix 2019-12-02 23:18:26 -07:00
Michael MacDonald 2863619b94
Fix minor typo in pattern example for number_to_phone [ci skip]
There is an extra closing parenthesis on the last example for `number_to_phone` which causes it to be invalid
2019-11-28 22:08:39 +11:00
Ryuta Kamizono d558febe32 Auto-correct rubocop offences 2019-11-24 09:54:47 +09:00
Ryuta Kamizono 214f439343 Fixup CHANGELOGs [ci skip] 2019-11-24 09:20:00 +09:00
BelenRemedi 4bf9e49ec4 show consitency in cache key and avoid getting into implementation details 2019-11-22 10:12:00 -03:00
Tatsuya Hoshino 41f0fb8c6e Remove needless `require "pp"`
In Ruby 2.5 and later, `Kernel#pp` is automatically loaded.

https://bugs.ruby-lang.org/issues/14123

This changes remove the needless `require "pp"`.
2019-11-06 22:50:53 +09:00
Artin Boghosian ec737fb846
Use singular, `instance`, in deprecation warning. 2019-11-04 13:45:46 -08:00
Rafael Mendonça França 86dd7d1621
No need to break the line 2019-11-04 15:24:40 -05:00
utilum 2ca6830831 TypeError Regexp#match?(nil) in Ruby Head
Aa of ruby/ruby@2a22a6b2d8 calling
`Regexp#match?(nil)` raises an exception.

[utilum, eregon, eugeneius]
2019-11-03 09:26:46 +02:00
Kasper Timm Hansen d2e8b839d2
Merge pull request #37561 from SinanMujan/fix_docs_actionview
[ci skip] Small fixes in ActionView documentation.
2019-10-27 08:31:23 -05:00
John Hawthorn 82f9d7c8b6
Merge pull request #37445 from jhawthorn/optimize_content_tag
Make content_tag a bit faster
2019-10-25 13:13:03 -07:00
sinanmujan f66946b11a [ci skip] Small fixes in ActionView documentation. 2019-10-25 09:02:26 +02:00
Orien Madgwick 493edf044f Add bug tracker/documentation/mailing list URIs to the gemspecs 2019-10-11 20:47:19 -04:00
John Hawthorn 25ed6627dd Convert two hash lookups into one 2019-10-11 13:52:51 -07:00
John Hawthorn a2720dd053 Avoid extra allocations when don't need escaping 2019-10-11 13:35:11 -07:00
Takayuki Nakata 4871f1f8d1 Remove unused `require`s
`remove_method` were removed at 661fd98aad and 737b718ea0
2019-10-07 10:03:46 +09:00
Kasper Timm Hansen eca6c273fe
[ci skip] switch eg. to proper e.g. 2019-10-07 02:18:36 +02:00
Xavier Noria 9f2c74eda0
Merge pull request #37350 from xuanxu/https
Update URLs in docs [ci skip]
2019-10-03 11:09:45 +02:00
Juanjo Bazán b24190807d update https urls [ci skip] 2019-10-03 11:01:32 +02:00
Juanjo Bazán e4b5a3eb77 update package.json files to use https homepage value 2019-10-02 12:00:11 +02:00
George Claghorn 8f37e2555a Avoid Element.closest() for IE 9 compatibility
Fixes #37234.
2019-09-29 09:07:11 -04:00
Akira Matsuda d1d1a2dee7 template_exists? takes keyword arguments 2019-09-24 13:48:14 +09:00
Rafael França 9c6bdb54a3
Merge pull request #34809 from bogdanvlviv/fix-select-with-nil
`ActionView::Helpers::FormOptionsHelper#select` should mark option for `nil` as selected
2019-09-19 15:45:40 -04:00
Akira Matsuda 9bce8c3c02 form_authenticity_token takes keyword arguments 2019-09-15 03:05:52 +09:00
Akira Matsuda fb6d5e0473 Passing in a Hash instance as kwargs parameters requires the "double splat" prefix 2019-09-14 08:53:04 +09:00
glacials c2cadd2f6d
Fix a button_to documentation example
Fixes an example in `button_to`'s documentation; the description states
`button_to` only takes a symbol for the `method` argument, but an
example just below uses a string.

Passing an all-lowercase string incidentally works, so the example is
technically functional despite being undefined behavior. But passing an
all-uppercase string fails, and this is a pretty common practice when
specifying HTTP methods (e.g. `DELETE`), so I think it's best this
example is put in line with the documentation and converted to use
symbols.

I fell for it myself and tried to pass an all-uppercase string after
seeing the example without reading the options descriptions.

Reproduction steps:

```sh
rails new buttonto
cd buttonto
rails c
> def protect_against_forgery?
>   false
> end
=> :protect_against_forgery?
>  button_to('Destroy', 'http://www.example.com', method: "delete", remote: true, data: { confirm: 'Are you sure?', disable_with: 'loading...' })
=> "<form class=\"button_to\" method=\"post\" action=\"http://www.example.com\" data-remote=\"true\"><input type=\"hidden\" name=\"_method\" value=\"delete\" /><input data-confirm=\"Are you sure?\" data-disable-with=\"loading...\" type=\"submit\" value=\"Destroy\" /></form>"
>  button_to('Destroy', 'http://www.example.com', method: "DELETE", remote: true, data: { confirm: 'Are you sure?', disable_with: 'loading...' })
=> "<form class=\"button_to\" method=\"post\" action=\"http://www.example.com\" data-remote=\"true\"><input data-confirm=\"Are you sure?\" data-disable-with=\"loading...\" type=\"submit\" value=\"Destroy\" /></form>"
```
2019-09-12 18:46:40 -07:00
John Hawthorn 2f44c3b00b
Merge pull request #37119 from jonathanhefner/fix-escaping-in-view-path-resolver
Fix escaping in OptimizedFileSystemResolver
2019-09-10 17:36:22 -07:00
Jonathan Hefner 897cdc721e Fix escaping in OptimizedFileSystemResolver
`OptimizedFileSystemResolver` builds a regular expression to match view
template paths.  Prior to this patch, only file globbing special
characters were escaped when building this regular expression, leaving
other regular expression special characters unescaped.

This patch properly escapes all regular expression special characters,
and adds test coverage for paths that include these characters.

Fixes #37107.
2019-09-09 12:20:02 -05:00
Akira Matsuda 7a563f749d Fix Class#new + keyword arguments warnings 2019-09-09 02:35:59 +09:00
bogdanvlviv cd2cbdcb48
`ActionView::Helpers::FormOptionsHelper#select` should mark option for `nil` as selected
```ruby
 @post = Post.new
 @post.category = nil

 # Before
 select("post", "category", none: nil, programming: 1, economics: 2)
 # =>
 # <select name="post[category]" id="post_category">
 #   <option value="">none</option>
 #  <option value="1">programming</option>
 #  <option value="2">economics</option>
 # </select>

 # After
 select("post", "category", none: nil, programming: 1, economics: 2)
 # =>
 # <select name="post[category]" id="post_category">
 #   <option selected="selected" value="">none</option>
 #  <option value="1">programming</option>
 #  <option value="2">economics</option>
 # </select>
 ```

To get the same result without these changes we can set `:selected` as `@post.category.to_s`:
 ```ruby
 select("post", "category", {none: nil, programming: 1, economics: 2}, {selected: @post.category.to_s}
 ```
2019-09-05 21:41:34 +03:00
George Claghorn 3437691708
Merge pull request #37040 from rails/reduce-info-level-logging
Logging at info level should be reserved for top-level concerns
2019-09-05 09:44:20 -04:00
Ryuta Kamizono 0cf609661e Auto-correct rubocop offences 2019-09-05 15:46:58 +09:00
Akira Matsuda d2f4541f12 Passing in a Hash instance as non-kwargs parameters has to be curly braced now 2019-09-05 13:26:58 +09:00
Akira Matsuda 4071115ddd Passing in a Hash instance as kwargs parameters requires the "double splat" prefix 2019-09-05 13:26:58 +09:00
sinsoku 7b157f1409
Add doc about I18n support for :placeholder option [ci skip]
The :placeholder option accepts true, so it should be mentioned in the documentation.

Ref: https://github.com/rails/rails/pull/16438
2019-08-28 02:25:41 +09:00
David Heinemeier Hansson 6315a11b90 Logging at info level should be reserved for top-level concerns
Information about partials and cable connection notices are too low level.
2019-08-26 16:43:45 -04:00
Akira Matsuda cade89e034 Reduce Hash creation in FormHelper 2019-08-27 04:07:22 +09:00
Akihito Tsukamoto 0a77c05308 Prevent TagBuilder modify options 2019-08-20 00:13:02 +09:00
Akira Matsuda 88fe8d9e7c Stop reopening ClassMethods and merge definitions 2019-08-19 00:35:23 +09:00
Akira Matsuda 2f71297919 :action is just a string 2019-08-19 00:34:28 +09:00
Akira Matsuda 07c50800fb Reduce Array allocations while finding templates 2019-08-19 00:22:42 +09:00
Will Jessop fdb6a90794
Remove misleading documentation
The docs for ActionView partial renderer state:

> NOTE: Due to backwards compatibility concerns, the collection can't be one of hashes. Normally you'd also just keep domain objects, like Active Records, in there.

The reporter stated:

> I can render a collection of hashes without problems:
>
> = render :partial => "info_row", :collection => my_collection, :as => :d

I tested this in a Rails 6.0 rc2 app and hashes were passed as described. Fixes #36897. [ci skip]
2019-08-10 02:52:15 +01:00
Kasper Timm Hansen 12001611d6
Require and support rails-html-sanitzer 1.2.0
Rails now requires 1.2.0 because it relies on the safe_list_sanitizer
API exclusively.

Also raise `sanitizer_vendor` API from the dead for
rails-deprecated_sanitizer.

Fixes https://github.com/rails/rails-deprecated_sanitizer/pull/6
2019-08-09 00:07:45 +02:00
Cliff Pruitt 265f97f1c1 Update rails-html-sanitizer to 1.1.0 in actionview.gemspec
Commit 52f0b050e2 replaces `white_list_sanitizer` with `safe_list_sanitizer`. This is a breaking change unless the installed version of `rails-html-sanitizer` is `>= 1.1.0`.

This commit updates the minimum version in `actionview/actionview.gemspec` to `1.1.0`.
2019-08-05 13:20:53 -04:00
Kasper Timm Hansen 064b7f6082
Remove unused require 2019-08-05 04:10:54 +02:00
Juanito Fatas 52f0b050e2
Update sanitizer in ActionView::Helpers::SanitizeHelper
- The sanitizer has been changed to safe_list_sanitizer.
- deprecate white_list_sanitizer
2019-08-05 03:35:35 +02:00
Rafael Mendonça França 92cb55ce19
This test needs integer core ext for time 2019-08-02 01:16:50 -04:00
Rafael Mendonça França 4b4bed83e2
Require integer conversion for this test 2019-08-02 00:49:47 -04:00
Rafael Mendonça França 967beb7229
Revert "MethodCallAssertions is a regular player of the team ActiveSupport::TestCase now"
This reverts commit 98d0f7ebd3.
2019-08-02 00:24:21 -04:00
Rafael Mendonça França 6384933994
Revert "You give jruby_skip & rubinius_skip a good name"
This reverts commit 8d2866bb80.
2019-08-02 00:24:11 -04:00
Akira Matsuda 8d2866bb80 You give jruby_skip & rubinius_skip a good name
This hack prevails everywhere in the codebase by being copy & pasted, and it's actually not a negative thing but a necessary thing for framework implementors,
so it should better have a name and be a thing.

And with this commit, activesupport/test/abstract_unit.rb now doesn't silently autoload AS::TestCase,
so we're ready to establish clearner environment for running AS tests (probably in later commits)
2019-08-02 05:36:38 +09:00
Akira Matsuda 98d0f7ebd3 MethodCallAssertions is a regular player of the team ActiveSupport::TestCase now
It's used everywhere, clean and mature enough
2019-08-02 05:36:15 +09:00
Ryuta Kamizono ad957273f5 Fix `_write_layout_method` 2019-08-02 01:55:47 +09:00
Rafael Mendonça França d40c88ae05
No private def 2019-08-01 11:18:42 -04:00
Akira Matsuda d21e5fbc70 These methods doesn't have to be `protected` 2019-08-01 17:58:00 +09:00
Akira Matsuda af2129b4c7 Use `try` only when we're unsure if the receiver would respond_to the method 2019-08-01 17:58:00 +09:00
Ryuta Kamizono f40eb4a408
Merge pull request #36818 from hc0208/fix_typo_in_data_remote_js
Fix typo submited → submitted
2019-07-31 12:39:08 +09:00
hc0208 6a409f7341 Fix typo submited → submitted [ci skip] 2019-07-31 12:22:21 +09:00
Akira Matsuda 46d207fde4 Avoid creating new Array when looking up already registered detail 2019-07-31 12:18:42 +09:00
Prem Sichanugrist 004f223f33
Merge pull request #36813 from haruyuki97/haruyuki97/fix-comment-in-url-helper
Fix a/an usage on `phone_to` documentation.

[ci skip]
2019-07-30 18:59:31 +09:00
haruyuki97 96e8a817fa fix a typo [ci skip] 2019-07-30 18:49:25 +09:00
Akira Matsuda 0196551e60 Use match? where we don't need MatchData 2019-07-29 14:23:10 +09:00
Akira Matsuda 8f90ac7827 Add AS::TimeZone#match? 2019-07-29 14:17:36 +09:00
Akira Matsuda 62d089a4ad Suppress Ruby warning: ⚠️ non-nil $, will be deprecated 2019-07-29 12:55:28 +09:00
st0012 e289c8d775 Assert query counts in cache relation test
This is to guard the change in #35982
2019-07-28 14:24:47 +08:00
Akira Matsuda d1ffe59ab5 Use match? where we don't need MatchData
We're already running Performance/RegexpMatch cop, but it seems like the cop is not always =~ justice
2019-07-27 13:06:49 +09:00
Pietro Moro c285c15820 Change test description with the correct URL name 2019-07-26 21:25:23 +00:00
Rafael França a0e58e687d
Merge pull request #36178 from sshaw/fix_time_zone_options_priority
Update time_zone_options_for_select docs
2019-07-26 16:03:37 -04:00
Abhay Nikam b34d7692c1 Change the test description to say the URL helper name in test. 2019-07-27 00:41:28 +05:30
Pietro Moro 0eff6956a5 Added a phone_to helper method, on the style of mail_to and sms_to. (#36775)
* Added a phone_to helper method, on the style of mail_to and sms_to.

It creates an anchor tag with the href set to tel: *here your number*
which, when clicked on a mobile phone, or on a desktop with a supported
application, lets the phone app kick in, and it prepopulates it with the
phone number specified.

[Pietro Moro + Rafael Mendonça França]
2019-07-26 14:54:57 -04:00
Rafael França 1760fe919f
Merge pull request #36764 from willianveiga/feature/inputs-inside-disabled-fieldset-are-not-submited-on-remote-true-forms
Inputs inside disabled fieldset are not submited on remote: true forms
2019-07-26 13:48:18 -04:00
Willian Gustavo Veiga 64631d83c5 Add test for submitted fields within disabled fieldsets 2019-07-26 12:59:23 -03:00
Sharang Dashputre b00a183aa1 Add a default value for arg `format` in `ActionView::Digestor.digest()` 2019-07-26 15:22:43 +05:30
Rafael França a11a7b2c7b
Merge pull request #35334 from sharang-d/digest-doc-update
Update comment for ActionView::Digestor.digest [ci skip]
2019-07-26 00:01:08 -04:00
Rafael Mendonça França 64f4d7fcb0
Merge pull request #36576 from mtsmfm/mtsmfm/fix-fixture-resolver
Support :any variants for ActionView::FixtureResolver
2019-07-25 22:24:31 -04:00
Rafael Mendonça França c9b7b9ff8a
Merge pull request #36412 from robotdana/compact_blank
Add compact_blank shortcut for reject(&:blank?)
2019-07-25 16:18:18 -04:00
Willian Gustavo Veiga c3e786fc48 Issue #36728 - Inputs inside disabled fieldset are not submited on remote: true forms 2019-07-25 16:07:11 -03:00
Rafael França 89ba95b69a
Merge pull request #36467 from spk/add-doc-host-protocol-asset_path
Add documentation on actionview asset_path with host and protocol
2019-07-24 14:14:08 -04:00
Ryuta Kamizono 0e149abbd5 Fix broken rdoc for UrlHelper [ci skip]
* Fix unintentionally linked String, Symbol, Hash, and ERB.
* Fix unintentionally code block.
2019-07-24 12:55:28 +09:00
Carlos Antonio da Silva 876548a7e7 Fix argument in doc sample of new `sms_to` helper [ci skip] 2019-07-19 18:10:47 -03:00
Guillermo Iguaran ea91f9bc1c
Merge pull request #36511 from aantix/sms_link_helper
Helper method to create an sms link
2019-07-19 15:36:58 -05:00
Jean Boussier bd78d3eecf Fix a minor typo in ActionView::UnboundTemplate 2019-07-19 15:18:57 +02:00
Guilherme Mansur 526a5eb10c Empty array instead of nil for source_extract
The source_extract method will return nil when it can't find the file name in
the backtrace, methods that consume this method expect an array and the nil ends
up causing type errors down the road like it happened here: #36341. This
patch refactors the source_extract method so that it returns an empty
array instead of nil when it can't find the source code.

Co-authored-by: Kasper Timm Hansen <kaspth@gmail.com>
2019-07-14 15:04:25 -04:00
Akira Matsuda 356857a122 active_support/deprecation has to be already required via active_support/rails.rb 2019-07-12 18:34:07 +09:00
Akira Matsuda b2b897217d A type class or nil has to respond_to :to_s 2019-07-12 18:33:31 +09:00
Akira Matsuda 00c3f3fca2 No Woman, No try 2019-07-12 18:32:45 +09:00
Fumiaki MATSUSHIMA 92af4aba25 Support :any variants for FixtureResolver 2019-06-30 02:23:08 +09:00
Guilherme Mansur 99e52ae7b1 Autoload SyntaxErrorInTemplate
When a SyntaxError is detected in a template we raise this exception. On
a first request to the server the exception we get a NameError since the
exception is not required from `active_view/template/error.rb` yet.
However later on it gets required and a second request will succeed.
On the first request we see the rails "Something Wen Wrong" page and not
the expected syntax error in template error page with the webconsole and
stacktrace. By autoloading the constant we fix this issue.

Co-authored-by: Gannon McGibbon <gannon.mcgibbon@gmail.com>
2019-06-19 14:53:24 -04:00
Jim Jones d2d15ad8a5 Doc changes. 2019-06-18 14:01:43 -05:00
Jim Jones 3115b735ea Helper method to create an sms link - when clicked it opens the phone/desktop's messaging client with the phone number and optional body value prepopulated. 2019-06-18 12:10:16 -05:00
Rafael França c65acad0df
Merge pull request #36482 from Shopify/fix-translation-helper-default-hash
Fix TranslationHelper#translate handling of Hash defaults
2019-06-17 13:38:39 -04:00
Akira Matsuda c8a84603e2 2019-06-15 15:19:13 +09:00
Ryuta Kamizono c0af72bf86 Fix rubocop violations 2019-06-14 23:32:15 +09:00
Jean Boussier 5d4a77d324 Fix TranslationHelper#translate handling of Hash defaults
It is sometimes expected of the `translate` methods to return a Hash,
for instance it's the case of the `number.format` key.

As such users might need to specify a Hash default, e.g.

`translate(:'some.format', default: { separator: '.', delimiter: ',' })`.

This works as expected with the `I18n.translate` methods,
however `TranslationHelper#translate` apply `Array()` on the default value.

As a result the default value end up as `[:separator, '.', :delimiter, ',']`.
2019-06-14 14:07:28 +02:00
Rafael França 95d038f020
Merge pull request #36477 from albertoalmagro/alberto/button-to-default-path
[ci skip] Use default path in button_to documentation
2019-06-13 17:45:59 -04:00
Gannon McGibbon c9e52d028c
Merge pull request #36437 from sudara/fix_programmatic_clicks_with_data_remote
Fix programmatic clicks with data-remote
2019-06-13 17:30:38 -04:00
Alberto Almagro 4f4fd0a625 [ci skip] Use default path in button_to documentation
This is really a nit pick, but as this is the framework's documentation
I think it should follow standards as many times as possible to avoid
confusion in new users.

If we were using `resources :articles` in routes. which is what scaffold
adds, the generated helper would be `new_article_path` instead of
`new_articles_path`.
2019-06-13 23:20:31 +02:00
Sudara ab4ed8c786 Ensure non-mouse/programmatic clicks work with data-remote 2019-06-13 19:59:17 +02:00
Aaron Patterson 3683a828dc
Merge pull request #36388 from joelhawksley/actionview-component
Introduce ActionView::Component
2019-06-13 09:37:49 -07:00
Ryuta Kamizono c81af6ae72 Enable `Layout/EmptyLinesAroundAccessModifier` cop
We sometimes say "✂️ newline after `private`" in a code review (e.g.
https://github.com/rails/rails/pull/18546#discussion_r23188776,
https://github.com/rails/rails/pull/34832#discussion_r244847195).

Now `Layout/EmptyLinesAroundAccessModifier` cop have new enforced style
`EnforcedStyle: only_before` (https://github.com/rubocop-hq/rubocop/pull/7059).

That cop and enforced style will reduce the our code review cost.
2019-06-13 12:00:45 +09:00
Joel Hawksley c221b5b448
`RenderingHelper` supports rendering objects that `respond_to?` `:render_in`
Co-authored-by: Natasha Umer <natashau@github.com>
Co-authored-by: Aaron Patterson <tenderlove@github.com>
Co-authored-by: Shawn Allen <shawnbot@github.com>
Co-authored-by: Emily Plummer <emplums@github.com>
Co-authored-by: Diana Mounter <broccolini@github.com>
Co-authored-by: John Hawthorn <jhawthorn@github.com>
Co-authored-by: Nathan Herald <myobie@github.com>
Co-authored-by: Zaid Zawaideh <zawaideh@github.com>
Co-authored-by: Zach Ahn <engineering@zachahn.com>
2019-06-12 16:31:01 -06:00
Laurent Arnoud 6b651d9904
Add documentation on actionview asset_path with host and protocol 2019-06-12 13:57:48 +02:00
John Hawthorn 1126d14c14
Merge pull request #36422 from jhawthorn/parallelize_actionview
Run actionview tests in parallel
2019-06-06 11:23:31 -07:00
Abhay Nikam 00b3b68602 Bump rubocop to 0.71 2019-06-06 15:34:50 +05:30
John Hawthorn df4ab6e103 Run actionview tests in parallel 2019-06-05 18:40:08 -07:00
John Hawthorn d130ea2ff2 Remove actionview tests which modify fixtures
We shouldn't modify fixtures (or any files which are checked-in). It
prevents us from parallelizing, and probably has other issues.

We could fix these tests by copying the file to a tmpdir and modifying
it there, but I don't think they are testing anything useful anymore.
Re-initializing a resolver isn't representative of "uncached" rendering
(either in dev-mode or using lookup_context.disable_cache).
2019-06-05 18:40:06 -07:00
Dana Sherson 459657a9f8 Use compact_blank throughout rails 2019-06-05 18:26:19 +10:00
yuuji.yaginuma a72f19a6c3 Only clear cache when view paths are specified
Currently, `clear_cache_if_necessary` is executed even if view paths are
not set like `rails console`.
If the watcher class is `EventedFileUpdateChecker` and the watch
directories are empty, the application root directory will watch. This
is because listen uses the current directory as the default watch directory.
8d85b4cd57/lib/listen/adapter/config.rb (L13)

As a result, `node_modules` also watch. This cause a warning of `listen`.
Ref: https://github.com/rails/rails/pull/36377#issuecomment-498399576
2019-06-04 08:44:28 +09:00
yuuji.yaginuma ea5f509643 Change `ActionDispatch::Response#content_type` returning Content-Type header as it is
Since #35709, `Response#conten_type` returns only MIME type correctly.
It is a documented behavior that this method only returns MIME type, so
this change seems appropriate.
39de7fac05/actionpack/lib/action_dispatch/http/response.rb (L245-L249)

But unfortunately, some users expect this method to return all
Content-Type that does not contain charset. This seems to be breaking
changes.

We can change this behavior with the deprecate cycle.
But, in that case, a method needs that include Content-Type with
additional parameters. And that method name is probably the
`content_type` seems to properly.

So I changed the new behavior to more appropriate `media_type` method.
And `Response#content_type` changed (as the method name) to return Content-Type
header as it is.

Fixes #35709.

[Rafael Mendonça França & Yuuji Yaginuma ]
2019-06-01 09:20:13 +09:00
Eileen M. Uchitelle 350ae29635
Merge pull request #36324 from yoones/fix-unexpected-select-tag-delete-behavior
Fix unexpected select_tag delete behavior when include_blank is present
2019-05-28 08:20:21 -07:00
Younes SERRAJ a4229a534f Fix select_tag so that is doesn't change options when include_blank is set 2019-05-22 10:21:59 +02:00
John Hawthorn be34af0c53 Wrap actionview cache expiry in a mutex 2019-05-21 19:46:42 -07:00
Alexander Graul 2256f0bdb0
Correct human file size examples [ci skip]
The `number_to_human_size` helpers in Action View and Active Support
calculate the "human size" with a base of 1024. The examples should
reflect that so they don't confuse the reader.

The updated documentations use the values from:

    helper.number_to_human_size(1500)
2019-05-20 18:25:11 +02:00
Xavier Noria 65f9e0c4bb NPM -> npm [ci skip]
According to https://www.npmjs.com/.
2019-05-12 12:00:03 +02:00
st0012 405b4c7f1e Remove useless find_partial method 2019-05-07 01:21:07 +08:00
Ryuta Kamizono 020856c328 Remove useless `GC.start` in `test/template/render_test.rb`
The `GC.start` was added at b29e893, but the finalizer has been removed
at 7d0ce78 in #35036.
2019-05-06 23:30:07 +09:00
st0012 34a33f8b0c Clear Resolvers' cache after running RenderTestCases' test cases
The templates rendered in RenderTestCases tests will be cached by the
resolvers unexpectedly. And this will break other tests when executed in
certain order. (See https://github.com/rails/rails/issues/36154 for more
detail)

So to fix this issue, we just need to clear the caches on all resolvers.
2019-05-06 22:08:48 +08:00
sshaw 5ee4a57a26 Update time_zone_options_for_select docs 2019-05-04 20:17:35 -04:00
Rafael França a0434ce37f
Merge pull request #35337 from abhaynikam/35265-remove-unused-argument-layout-from-rendered-template
Removed unused layout attribute from RenderedTemplate
2019-05-01 15:45:06 -05:00
Akira Matsuda fef174f5c5 `@controller` may not be defined here, and if so, it causes a Ruby warning
e.g. via test-unit-rails' `run_setup`
2019-05-01 13:33:38 +09:00
Michael Bock 74d74496ba
Fixes grammar in comments on tag_name and tag_id 2019-04-25 11:56:56 -07:00
Rafael França d4d145a679
Merge pull request #32313 from lulalala/model_error_as_object
Model error as object
2019-04-24 16:16:00 -04:00
Rafael Mendonça França 9834be6565
Start Rails 6.1 development 2019-04-24 15:57:14 -04:00
Ryuta Kamizono 3a4aa49256 Fix markup in CHANGELOGs [ci skip]
Need to new line to break line in the markdown.
2019-04-25 03:19:15 +09:00
st0012 88c195bf81 Update the changelog to explain the fix 2019-04-20 01:34:53 +09:00
Koichi ITO c6379fd27f Bump RuboCop to 0.67.2
Performance cops will be extracted from RuboCop to RuboCop Performance
when next RuboCop 0.68 will be released.
https://github.com/rubocop-hq/rubocop/issues/5977

RuboCop 0.67 is its transition period.

Since rails/rails repository uses Performance cops, This PR added
rubocop-performance gem to Gemfile.

And this PR fixes some offenses using the following auto-correct.

```console
% bundle exec rubocop -a

Offenses:

activerecord/test/cases/connection_adapters/connection_handlers_multi_db_test.rb:212:26:
C: [Corrected] Layout/SpaceAroundOperators: Operator =
> should be surrounded by a single space.
              "primary"  => { adapter: "sqlite3", database: "db/primary.sqlite3" }
                         ^^
activerecord/test/cases/connection_adapters/connection_handlers_multi_db_test.rb:239:26:
C: [Corrected] Layout/SpaceAroundOperators: Operator => should be
surrounded by a single space.
              "primary"  => { adapter: "sqlite3", database: "db/primary.sqlite3" }
                         ^^
actionview/test/template/resolver_shared_tests.rb:1:1: C: [Corrected]
Style/FrozenStringLiteralComment: Missing magic comment #
frozen_string_literal: true.
module ResolverSharedTests
^
actionview/test/template/resolver_shared_tests.rb:10:33: C: [Corrected]
Layout/SpaceAroundEqualsInParameterDefault: Surrounding space missing in
default value assignment.
  def with_file(filename, source="File at #{filename}")
                                ^
actionview/test/template/resolver_shared_tests.rb:106:5: C: [Corrected]
Rails/RefuteMethods: Prefer assert_not_same over refute_same.
    refute_same a, b
    ^^^^^^^^^^^

2760 files inspected, 5 offenses detected, 5 offenses corrected
```
2019-04-16 17:58:24 +09:00
Sharang Dashputre f22441ff6e Update comment for ActionView::Digestor.digest [ci skip] 2019-04-16 14:18:41 +05:30
Rafael França ddf471a163
Merge pull request #35959 from jhawthorn/unbound_templates
De-duplicate templates, introduce UnboundTemplate
2019-04-15 17:57:39 -04:00
John Hawthorn 2455d16a5a Add additional test for sharing templates 2019-04-12 16:08:30 -07:00
John Hawthorn 0b26cc41db Avoid duplication using _find_all 2019-04-12 15:40:33 -07:00
John Hawthorn 53e4055a75 Support disabling cache for Digestor
This adds a bit of complexity, but is necessary for now to avoid holding
extra copies of templates which are resolved from ActionView::Digestor
after disabling cache on the lookup context.
2019-04-12 12:30:26 -07:00
John Hawthorn 1fc735e5f5 De-dup Templates, introduce UnboundTemplate
Previously it's possible to have multiple copies of the "same" Template.
For example, if index.html.erb is found both the :en and :fr locale, it
will return a different Template object for each. The same can happen
with formats, variants, and handlers.

This commit de-duplicates templates, there will now only be one template
per file/virtual_path/locals tuple.

We need to consider virtual_path because both `render "index"`, and
`render "index.html"` can both find the same file but will have
different virtual_paths. IMO this is rare and should be
deprecated/removed, but it exists now so we need to consider it in order
to cache correctly.

This commit introduces a new UnboundTemplate class, which represents a
template with unknown locals. Template objects can be built from it by
using `#with_locals`. Currently, this is just a convenience around
caching templates, but I hope it's a helpful concept that could have
more utility in the future.
2019-04-12 12:30:26 -07:00
utilum f999210c98 Squash `warning: instance variable @filename not initialized` 2019-04-12 15:25:30 +02:00
John Hawthorn 80e2aaa80a Add tests against resolver
We didn't previously have many tests directly against the
OptimizedFileSystemResolver or FileSystemResolver, though usually
failures would be exposed through other tests.

It's easier to test some specifics of the behaviour with unit tests.
This also lets us test FileSystemResolver (non-optimized) which I don't
think previously had much testing (other than from classses inheriting
it).
2019-04-11 17:09:00 -07:00
John Hawthorn 6e85c5c634 Remove FileTemplate
This is unnecessary now that we can just provide a file source
2019-04-04 16:21:12 -07:00
John Hawthorn 151cac65f1 Deprecate Template#refresh 2019-04-04 15:07:14 -07:00
John Hawthorn db1830a7ec Add ActionView::Template::Sources::File 2019-04-04 15:07:14 -07:00
John Hawthorn b8e6594181 Don't call Template#refresh
Now that Template#source will always return a source, this is
unnecessary.
2019-04-04 14:28:10 -07:00
John Hawthorn b8c90c3644 Don't discard source after rendering
Previously, we would discard the template source after rendering, if we
had a virtual path, in hopes that the virtual path would let us find our
same template again going through the Resolver.

Previously we discarded the source as an optimization, to avoid keeping
it around in memory. By instead just reading the file every time source
is called, as FileTemplate does, this is unnecessary.
2019-04-04 14:25:31 -07:00
localhostdotdev b2b2f70f1f Fix arity warning for template handlers
Mainly to help with knowning which template is reponsible for the
warning.

handler.class # => Class

handler.to_s # => Coffee::Rails::TemplateHandler

Before:

Change:
  >> Class#call(template)
To:
  >> Class#call(template, source)

After:

Change:
  >> Coffee::Rails::TemplateHandler.call(template)
To:
  >> Coffee::Rails::TemplateHandler.call(template, source)
2019-04-04 19:13:46 +02:00
Prathamesh Sonpatki 6a4bf486c3
Fix deprecation warning about variants and formats
- After https://github.com/rails/rails/pull/35408 and
  https://github.com/rails/rails/pull/35406, the `formats` and
  `variants` methods are deprecated in favor of `format` and `variant`.
2019-04-04 19:29:27 +05:30
Fumiaki MATSUSHIMA 61c4be4777 Output junit format test report 2019-04-04 14:34:46 +09:00
Rafael França eda2d7d7b9
Merge pull request #35145 from st0012/fix-35114
Fix partial caching ignore repeated items issue
2019-04-03 23:03:30 -04:00
st0012 e8688ddb33 Fix partial caching ignore repeated items issue
This is because we only use hash to maintain the result. So when the key
are the same, the result would be skipped. The solution is to maintain
an array for tracking every item's position to restructure the result.
2019-04-04 09:59:06 +08:00
Edward Rudd c5efbbbccb Fix checking for template variants when using the ActionView::FixtureResolver 2019-04-03 18:09:34 -04:00
Eileen M. Uchitelle d39b2b684e
Merge pull request #35825 from jhawthorn/always_filter_view_paths
Make Resolver#find_all_anywhere equivalent to #find_all
2019-04-03 13:21:51 -04:00
John Hawthorn eb52904eb5 Always reject files external to app
Previously, when using `render file:`, it was possible to render files
not only at an absolute path or relative to the current directory, but
relative to ANY view paths. This was probably done for absolutely
maximum compatibility when addressing CVE-2016-0752, but I think is
unlikely to be used in practice.

Tihs commit removes the ability to `render file:` with a path relative
to a non-fallback view path.

Make FallbackResolver.new private

To ensure nobody is making FallbackResolvers other than "/" and "".

Make reject_files_external_... no-op for fallbacks

Because there are only two values used for path: "" and "/", and
File.join("", "") == File.join("/", "") == "/", this method was only
testing that the absolute paths started at "/" (which of course all do).

This commit doesn't change any behaviour, but it makes it explicit that
the FallbackFileSystemResolver works this way.

Remove outside_app_allowed argument

Deprecate find_all_anywhere

This is now equivalent to find_all

Remove outside_app argument

Deprecate find_file for find

Both LookupContext#find_file and PathSet#find_file are now equivalent to
their respective #find methods.
2019-04-03 09:02:28 -07:00
Abhay Nikam b04656ecb2 [ci skip] Updated the doc after renaming Template::File -> Template::RawFile in #35826 2019-04-02 14:03:43 +05:30
Cliff Pruitt 90196398a1 Rename File to RawFile 2019-04-01 19:29:03 -04:00
Kasper Timm Hansen beb0bc9907
[ci skip] Follow up c8bf334104 2019-04-01 21:26:13 +02:00