Commit Graph

289 Commits

Author SHA1 Message Date
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
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
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
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
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
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
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
Edward Rudd
c5efbbbccb Fix checking for template variants when using the ActionView::FixtureResolver 2019-04-03 18:09:34 -04:00
Kasper Timm Hansen
beb0bc9907
[ci skip] Follow up c8bf334104 2019-04-01 21:26:13 +02:00
John Hawthorn
c8bf334104 Only clear template caches in dev after changes (#35629) 2019-04-01 21:22:57 +02:00
Ryuta Kamizono
b89a3e7e63 Tweaks CHANGELOGs and docs [ci skip]
* add leading `#` before `=>` since hash rocket is valid Ruby code
* add backticks
* remove trailing spaces
* and more
2019-03-31 08:38:37 +09:00
Shailesh Kalamkar
839328c700 [ci skip] Fixed typo 2019-03-23 07:22:52 +05:30
John Hawthorn
5c2d695993 Update CHANGELOGs for 6.0.0.beta3 release 2019-03-22 13:13:01 -07:00
eileencodes
7c87fd5635 Prep release
* Update RAILS_VERSION
* Bundle
* rake update_versions
* rake changelog:header
2019-03-11 11:58:15 -04:00
Rafael Mendonça França
5e6e505083
Preparing for 6.0.0.beta2 release 2019-02-25 17:45:04 -05:00
Aaron Patterson
cf0dd4a71d
Fix some typos! 2019-02-06 16:57:34 -08:00
Aaron Patterson
7761ddbebb
Deprecate finalizer configuration (it doesn't do anything)
Revert "Remove finalizer and configuration"

This reverts commit 9e7b4a3173788ea43b11e74a4d2f69a5f1565daa.
2019-02-06 16:57:34 -08:00
Gannon McGibbon
7caea98e18 Merge branch 'float_dom_ids'
Closes #34975.
2019-02-05 13:48:25 -05:00
Javan Makhmali
e3d43333db Add CHANGELOG entries for npm package renames [ci skip] 2019-01-28 06:29:26 -05:00
Mark Edmondson
f8696b888e Fix unique DOM IDs for collection inputs 2019-01-25 10:04:23 -08:00
Ryuta Kamizono
9f203c3f81 Single new line is not rendered as new line in the CHANGELOG.md
https://github.com/rails/rails/blob/v6.0.0.beta1/actionview/CHANGELOG.md

[ci skip]
2019-01-19 18:18:05 +09:00
Rafael Mendonça França
5a0230c67f
Preparing for 6.0.0.beta1 release 2019-01-18 15:42:12 -05:00
Rafael Mendonça França
60c8a03c8d
Remove deprecated image_alt helper 2019-01-17 16:08:31 -05:00
Genadi Samokovarov
a58db74c4f Don't expect defined protect_against_forgery? in {token,csrf_meta}_tag
The `#csrf_meta_tags` and `#token_tag` Action View helper methods are
expecting the class in which are included to explicitly define the
method `#protect_against_forgery?` or else they will fail with
`NoMethodError`.

This is a problem if you want to use Action View outside of Rails
applications. For example, in #34788 I used the `#button_to` helper
inside of the error pages templates that have a custom
`ActionView::Base` subclass, which did not defined
`#protect_against_forgery?` and trying to call the button failed.

I had to dig inside of Action View to find-out what's was going on. I
think we should either set a default method implementation in the
helpers or check for the method definition, but don't explicitly require
the presence of `#protect_against_forgery?` in every `ActionViews::Base`
subclass as the errors are hard to figure out.
2018-12-27 11:33:54 +02:00
Kasper Timm Hansen
1b7c3222e8
Require Ruby 2.5 for Rails 6.
Generally followed the pattern for https://github.com/rails/rails/pull/32034

* Removes needless CI configs for 2.4
* Targets 2.5 in rubocop
* Updates existing CHANGELOG entries for fewer merge conflicts
* Removes Hash#slice extension as that's inlined on Ruby 2.5.
* Removes the need for send on define_method in MethodCallAssertions.
2018-12-19 21:47:50 +01:00
WoH
257a1a6373
Do not disable previously disabled elements 2018-12-06 09:02:07 +01:00
WoH
a2612622e8
Prevent unintended mouse keys from firing click events
Firefox fires click events on left-, right-
and scroll-wheel (any non-primary mouse key) clicks while other browsers don't.
2018-12-05 15:08:14 +01:00
Lyle Mullican
4fdc6269b6 Prevent TextHelper#word_wrap from stripping white space on the left
side of long lines; Fixes #34487
2018-11-19 17:16:34 -05:00
Ryuta Kamizono
5df4efd2fd Fix broken CHANGELOG markup [ci skip]
And remove trailing spaces.
2018-11-08 09:28:42 +09:00
Eileen Uchitelle
e8c1be4ae7 Add allocations to template renderer subscription
This PR adds the allocations to the instrumentation for template and
partial rendering.

Before:

```
  Rendering posts/new.html.erb within layouts/application
  Rendered posts/_form.html.erb (9.7ms)
  Rendered posts/new.html.erb within layouts/application (10.9ms)
Completed 200 OK in 902ms (Views: 890.8ms | ActiveRecord: 0.8ms)
```

After:

```
  Rendering posts/new.html.erb within layouts/application
  Rendered posts/_form.html.erb (Duration: 7.1ms | Allocations: 6004)
  Rendered posts/new.html.erb within layouts/application (Duration: 8.3ms | Allocations: 6654)
Completed 200 OK in 858ms (Views: 848.4ms | ActiveRecord: 0.4ms | Allocations: 1539564)
```
2018-10-10 08:07:12 -04:00
Joel Ambass
b48c2ade09 respect path_only option when an array is passed into url_for
The url_for method is now extracting the path_only option in order to determine if polymorphic_path or polymorphic_url should be called.

If the path_only option is not set it will be set to true unless the host option is set. This behaviour is the same as when a Hash or Params object is passed.

To support this unifying the code responsible for setting this default value has been extracted into a private method
2018-10-01 19:31:08 +02:00
Ryuta Kamizono
736edb9828 Formatting CHANGELOGs [ci skip]
Fixing code block rendering, indentation, backticks, etc.
2018-09-07 07:59:19 +09: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
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
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
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
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
Ryuta Kamizono
8f6c85f036 Merge pull request #32190 from liwii/use_year_names
Add `use_year_names` option to date_select tag
2018-06-21 17:01:35 +09:00
Koki Ryu
8f46a23d37 Add year_format option to date_select tag. This option makes it possible to customize year
names. Lambda should be passed to use this option. Example:

    date_select('user_birthday', '', start_year: 1998, end_year: 2000, year_format: ->year { "Heisei #{year - 1988}" })

The HTML produced:

    <select id="user_birthday__1i" name="user_birthday[(1i)]">
    <option value="1998">Heisei 10</option>
    <option value="1999">Heisei 11</option>
    <option value="2000">Heisei 12</option>
    </select>
    /* The rest is omitted */
2018-06-10 21:07:59 +09:00
yuuji.yaginuma
1694b02909 Make JS views rendered work with content security policy
As of now,  `HTMLElement.nonce` seems to work only in Chrome.
So, it should not be used now.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/nonce#Browser_compatibility

Fixes #32577.
2018-04-20 15:41:56 +09:00
Yaroslav Markin
47013a7126 Add the nonce: true option for javascript_include_tag helper. 2018-04-17 22:50:33 +03:00
bogdanvlviv
f0bde0167c
Fix actionview/CHANGELOG.md
- Add missing dots at the end of sentences.
- Wrap RecordTagHelper into `.
- `RecordTagHelper` => `ActionView::Helpers::RecordTagHelper`.

[ci skip]
2018-04-07 11:28:26 +03:00
Yoshiyuki Hirano
5c5ddd69b1 Remove RecordTagHelper
* Since #18411, we started to inform about extracted gem (record_tag_helper)
  to developers who use `ActionView::Helpers::RecordTagHelper` 's methods.

* Currently, it seems no problem that we don't have to support no longer.
2018-04-07 09:28:01 +09:00
Simon Coffey
eede8d8130 Add action_view.finalize_compiled_template_methods config option
ActionView::Template instances compile their source to methods on the
ActionView::CompiledTemplates module. To prevent leaks in development
mode, where templates can frequently change, a finalizer is added that
undefines these methods[1] when the templates are garbage-collected.

This is undesirable in the test environment, however, as templates don't
change during the life of the test. Moreover, the cost of undefining a
method is proportional to the number of descendants a class or module
has, since the method cache must be cleared for all descendant classes.

As ActionView::CompiledTemplates is mixed into every
ActionView::TestCase (or in RSpec suites, every view spec example
group), it can end up with a very large number of descendants, and
undefining its methods can become very expensive.

In large test suites, this results in a long delay at the end of the
test suite as all template finalizers are run, only for the process to
then exit.

To avoid this unnecessary cost, this change adds a config option,
`action_view.finalize_compiled_template_methods`, defaulting to true,
and sets it to false in the test environment only.

[1] 09b2348f7f/actionview/lib/action_view/template.rb (L118-L126)
2018-04-02 20:50:33 +01:00
Mathieu
e9aa7ecdee Extract the confirm call in its own, overridable method in rails_ujs 2018-04-01 19:15:36 +07:00
Rafael Mendonça França
ba0ae542ca
Remove changelog header for unreleased version
We only add the header when releasing to avoid some conflicts.

[ci skip]
2018-03-13 15:20:57 -04:00