Commit Graph

2817 Commits

Author SHA1 Message Date
Sean Doyle
9c86593caa Execute field_error_proc within view
Instead of treating it as an anonymous block, execute the
`ActionView::Base.field_error_proc` within the context of the
`ActionView::Base` instance.

This enables consumer applications to continue to override the proc as
they see fit, but frees them from declaring templating logic within a
`config/initializers/*.rb`, `config/environments/*.rb` or
`config/application.rb` file.

This makes it possible to replace something like:

```ruby
config.action_view.field_error_proc = proc do |html_tag, instance|
  <<~HTML.html_safe
    #{html_tag}
    <span class="errors">#{instance.error_message.to_sentence}</span>
  HTML
end
```

With inline calls to Action View helpers like:

```ruby
config.action_view.field_error_proc = proc do |html_tag, instance|
  safe_join [ html_tag, tag.span(instance.error_message.to_sentence, class: "errors") ]
end
```

Or with a view partial rendering, like:

```ruby
config.action_view.field_error_proc = proc do |html_tag, instance|
  render partial: "application/field_with_errors", locals: { html_tag: html_tag, instance: instance }
end
```

Then, elsewhere in `app/views/application/field_with_errors.html.erb`:

```erb
<%= html_tag %>
<span class="errors"><%= instance.error_message.to_sentence %></span>
```
2021-10-29 10:07:04 -04:00
Sean Doyle
71fb8eb833 button_to: Support authenticity_token: option
Match support for passing `authenticity_token:` in `form_with` and
`form_for` calls.

```ruby
button_to "Create", Post.new, authenticity_token: false
  # => <form class="button_to" method="post" action="/posts"><button type="submit">Create</button></form>

button_to "Create", Post.new, authenticity_token: true
  # => <form class="button_to" method="post" action="/posts"><button type="submit">Create</button><input type="hidden" name="form_token" value="abc123..." autocomplete="off" /></form>

button_to "Create", Post.new, authenticity_token: "secret"
  # => <form class="button_to" method="post" action="/posts"><button type="submit">Create</button><input type="hidden" name="form_token" value="secret" autocomplete="off" /></form>
```
2021-10-29 10:02:22 -04:00
Sean Doyle
46175a036a Action View: Support fields model: [...]
Support `fields model: [@nested, @model]` the same way as `form_with
model: [@nested, @model]`.

After this change, the `fields` helper matches the precedent established
by [fields_for][], [form_for][], and [form_with][].

[fields_for]: 5e1a039a1d/actionview/lib/action_view/helpers/form_helper.rb (L2235)
[form_with]: 5e1a039a1d/actionview/lib/action_view/helpers/form_helper.rb (L749)
[form_for]: 5e1a039a1d/actionview/lib/action_view/helpers/form_helper.rb (L436)
2021-10-29 10:01:51 -04:00
Sean Doyle
7d2be2e011 Make button_to more model-aware
Infer HTTP verb `[method]` from a model or Array with model as the first
argument to `button_to` when combined with a block:

```ruby
button_to(Workshop.find(1)){ "Update" }
  #=> <form method="post" action="/workshops/1" class="button_to">
  #=>   <input type="hidden" name="_method" value="patch" autocomplete="off" />
  #=>   <button type="submit">Update</button>
  #=> </form>

button_to([ Workshop.find(1), Session.find(1) ]) { "Update" }
  #=> <form method="post" action="/workshops/1/sessions/1" class="button_to">
  #=>   <input type="hidden" name="_method" value="patch" autocomplete="off" />
  #=>   <button type="submit">Update</button>
  #=> </form>
```

Prior to this change, the constructed `<form>` was always submitted with
a `[method="post"]` and _always_ omitted the `<input type="hidden"
name="_method" value="...">` field, regardless of the return value of
the "model" argument's `#persisted?` predicate.
2021-10-29 10:01:20 -04:00
Sean Doyle
37081bf507 Introduce field_name view helper
The `field_name` helper and corresponding `FormBuilder#field_name`
method provide an Action View-compliant way of overriding a form field
element's `[name]` attribute (similar to `field_id` and
`FormBuilder#field_id` introduced in rails/rails#40127[][]).

```ruby
text_field_tag :post, :title, name: field_name(:post, :title, :subtitle)
  # => <input type="text" name="post[title][subtitle]">

text_field_tag :post, :tag, name: field_name(:post, :tag, multiple: true)
  # => <input type="text" name="post[tag][]">

form_for @post do |f|
  f.field_tag :tag, name: f.field_name(:tag, multiple: true)
  # => <input type="text" name="post[tag][]">
end
```

[rails/rails#40127]: https://github.com/rails/rails/pull/40127
2021-10-29 10:00:15 -04:00
Ryuta Kamizono
394dbac0b3
Merge pull request #43567 from shunichi/date-select-day-format
Add :day_format option to date_select
2021-10-29 16:59:45 +09:00
Jean Boussier
7b5096947e Call Executor#wrap around each test
It's `Rails.application.executor.wrap` that is responsible for
clearing request/job local state such as `CurrentAttributes`.

Instead of including an ad hoc helper to clear `CurrentAttributes` it's
better to run the executor so we properly clear other states as well.

However it means all executor hooks now need to be re-entrant.
2021-10-28 15:18:29 +02:00
Shunichi Ikegami
e9fa24fca5 Add :day_format option to date_select
date_select("article", "written_on", day_format: ->(day) { day.ordinalize })

generates day options like

  <option value="1">1st</option>\n<option value="2">2nd</option>...
2021-10-28 13:51:20 +09:00
Rafael Mendonça França
fee61e3abc
Merge pull request #43415 from rails/rm-translate-on-controllers
Treat html suffix in controller translation
2021-10-12 14:19:21 -04:00
Rafael Mendonça França
28bc4f87fd
Extract common behavior of html safe translation to a module
This module will be a private module in Active Support, this way
if we need to change the behavior of translate in controllers or
views don't forget to change in the other one.
2021-10-12 18:03:46 +00:00
David Heinemeier Hansson
fb1ab3460a
Make Sprockets more optional, offer Propshaft as alternative (#43261)
* Make Sprockets more optional, offer Propshaft as alternative

* Whups, local reference

* No longer used

* Spacing

* Need explicit sprockets-rails inclusion now

* Manually require the sprockets railtie

* Don't need these changes right now

* Kick off another build

* Fix tests

* DRY up test

* Require railtie when using sprockets

* Introduce option to skip asset pipeline

* No longer relevant

* Always have to return

* Gone

* Add helper for skip_sprockets?

* Fix guard statement

* Use latest gems

* Include propshaft

* fix tests for #43261 (#43277)

* help fix tests for #43261

skip_sprockets? should not be called on options

:skip_sprockets is no longer a value in the option hash, so
skip_sprockets? should not be called on it

move --asset-pipeline to shared generator

skip_sprockets? is defined on app_base, and used in the plugin
generator to determine whether to add the engine's assets to the dummy
sprockets manifest, so I believe it makes sense to include in both
generators

Because of this change, I also changed the shared test back to testing
against non-sprockets

add skip_sprockets to Gemfile template vars

Mocking skip_sprockets? in app_base generator

fix more generator tests

* use skip_sprockets? everywhere

* Use latest propshaft

* Update `AssetUrlHelper` docs to list both asset pipeline gems (#43328)

* Update to latest Propshaft

* Bump Propshaft again

* Ask for latest

* Use latest propshaft

Co-authored-by: Hartley McGuire <skipkayhil@gmail.com>
Co-authored-by: Richard Macklin <1863540+rmacklin@users.noreply.github.com>
2021-10-09 17:03:05 +02:00
Daniel Colson
ccb3cb573b
Replace ableist language
The word "Crazy" has long been associated with mental illness. While
there may be other dictionary definitions, it's difficult for some of us
to separate the word from the stigmatization, gaslighting, and bullying
that often comes along with it.

This commit replaces instances of the word with various alternatives. I
find most of these more focused and descriptive than what we had before.
2021-10-05 22:27:09 -04:00
Liuri Loami
d3e5833459 Replaces the "hash rocket" operator in favor of the newer Ruby syntax when rendering on render 2021-10-03 23:33:56 -03:00
Jonathan Hefner
03bb5c1dc2
Merge pull request #43323 from muraken-ken/hotfix
Fix wrong API document for form_with helper method [ci-skip]
2021-09-28 10:08:22 -05:00
muraken-ken
0a3b1ebf6a Fix wrong RDoc 2021-09-28 20:33:35 +09:00
Eike S
9b36864595 Improves ActionView FormHelper check_box documentation
The ActionView::Helpers::Tags::CheckBox class accepts the `checked` and `include_hidden` options. The documentation for these options is added to the `check_box` methods in the ActionView::Helpers::FormHelper class where they are exposed.

Co-authored-by: Jonathan Hefner <jonathan@hefner.pro>
2021-09-28 10:16:04 +02:00
Rafael França
aa449a89df
Merge pull request #43280 from ryanfb/hidden_autocomplete_off
Add autocomplete="off" to all generated hidden fields (fixes #42610)
2021-09-22 18:20:52 -04:00
Rafael Mendonça França
8e86e87219
Merge PR #42234 2021-09-21 18:54:48 -04:00
Ryan Baumann
168170ff14 Add autocomplete="off" to all generated hidden fields (fixes #42610) 2021-09-21 15:57:56 -04:00
Rafael Mendonça França
040e22b104
Fix CHANGELOG [ci skip] 2021-09-20 17:35:12 -04:00
Rafael França
6e2247e976
Merge pull request #43232 from le0pard/fix_use_tag
Support svg unpaired tags in tag helper
2021-09-20 17:34:28 -04:00
Drew Bragg
451c55e312 Add beginning_of_week option to weekday_options_for_select
Change `begin_on_monday` to `beginning_of_week`

Change `begin_on_monday` to `beginning_of_week`

Better handle ignored day

Remove inaccurate tests

Improve docs and use DAYS_INTO_WEEK to calc rotation

Remove inaccurate docs
2021-09-17 19:39:07 -04:00
Alexey Vasiliev
6b7ff4f933
Support svg unpaired tags in tag helper 2021-09-16 21:50:54 +03:00
Rafael Mendonça França
d177551c30
Preparing for 7.0.0.alpha2 release 2021-09-15 18:22:51 -04:00
Rafael Mendonça França
9b7be48212
Preparing for 7.0.0.alpha1 release 2021-09-15 17:55:08 -04:00
Jean Boussier
c91c266872 Enable Style/ExplicitBlockArgument cop
This reduce the stack size which is beneficial for
exceptions performance.

See: https://gist.github.com/byroot/cb3bcadcc3701c2518d002fb8d3a4e7a

However the cop is unsafe because it might change the block arity,
so it can run into some false positives.
2021-09-05 17:06:19 +02:00
Jean Boussier
4d3a2c09c8
Merge pull request #43106 from flavorjones/flavorjones-activesupport-number-converter-valid-float
Avoid use of exceptions to detect invalid floats
2021-08-26 15:41:10 +02:00
David Heinemeier Hansson
4214a8d229
Document that @rails/ujs is deprecated (#43112)
Recommended replacements: Turbo + Stimulus.
2021-08-26 14:25:30 +02:00
Mike Dalessio
900ce92c9d
Avoid use of exceptions to detect invalid floats
Use Kernel::Float(..., exceptions:false) instead of a rescue block in
ActionView::Helpers::NumberHelper and
ActiveSupport::NumberHelper::NumberConverter to slightly improve
performance.

Also remove documentation that incorrectly states
ActiveSupport::NumberHelper supports the `raise:` option.
2021-08-25 21:44:45 -04:00
Kasper Timm Hansen
94e80269e3
[ci skip] Fully qualify attributes (we're in docs) and move them above the class so it's not confused with the belongs_to's 2021-08-25 16:59:02 +02:00
Kasper Timm Hansen
163466467e
[ci skip] Use more consistent spacing; trim some ending newlines 2021-08-25 16:58:17 +02:00
Kasper Timm Hansen
1ade156d3c
[ci skip] Use more modern tag.x call structure 2021-08-25 16:56:22 +02:00
Kasper Timm Hansen
ccad4b0886
[ci skip] Modernize example; make it consistent with the example at the top documentation 2021-08-25 16:55:47 +02:00
Kasper Timm Hansen
6faf60b158
[ci skip] Fix some links that didn't link but now should, you get me? 2021-08-25 16:55:00 +02:00
Kasper Timm Hansen
ea5397e708
[ci skip] Use symbols and double quoted strings more consistently in these docs 2021-08-25 16:54:22 +02:00
Kasper Timm Hansen
915b9cdbb7
Clear up resolve_link_as
Swaps to case/when to highlight the 3 branches better and uses `presence_in`
to cut down on the else branch noise.

`resolve_link_as` added in: eb90b8bc86e758045a707cae43d11dab538ca6db
Most recent other commit: 46bfd082b00a6c10f7263c769edb9c053bd03936

Made a decision to tweak this as core, don't send cosmetic PRs.
2021-08-24 22:38:40 +02:00
Nate Berkopec
46bfd082b0
Make preload_link_tag work with images 2021-08-24 13:49:02 -06:00
John Hawthorn
2daef106af
Merge pull request #42945 from jhawthorn/hash_match
Remove details_key-based Template cache
2021-08-23 10:47:58 -07:00
Olivier Lacan
1e9629e8a9 Allow url_for to infer the name of the link from Model#to_s 2021-08-17 12:17:04 -04:00
Koichi ITO
65af100ddd Tweak unreachable assertion tests in the block of assert_raises
I found an unexpected use of assertion in the block of `assert_raise`
when I implemented https://github.com/rubocop/rubocop-minitest/pull/137.
It is expected to be asserted after an exception is raised in
`assert_raise` block, but in actually it is not asserted after an
exception is raised. Therefore, this PR removes or updates assertions
that have not been asserted after an exception has raised.

This PR will add `rubocop-minitest` and enable
`Minitest/UnreachableAssertion` cop to able similar auto-detection,
but will remove `rubocop-minitest` from this PR if you don't like it.
2021-08-17 20:33:08 +09:00
Xavier Noria
2306a8e645 Setup the once autoloader on bootstrap 2021-08-17 05:23:51 +02:00
Xavier Noria
bbe74a8c97 Delete AS::Dependencies.unhook! 2021-08-17 05:18:22 +02:00
Drew Bragg
592570f1bf Add weekday_options_for_select method
Add `weekday_select` method

Create `Tags::WeekdaySelect` class

Add `weekday_select` to `FromBuilder`

Add Documentation

Allow `WeekdaySelect` to use selected option if value is nil

Doc fix

Add tests

Use kwrd args

Update CHANGELOG

Fix `Tags::WeekdaySelect` for updated kwrd args

Update CHANGELOG format

Condense `weekday_options_for_select` method

Update tests for kwargs
2021-08-16 13:04:33 -04:00
Kasper Timm Hansen
0965b67bf7
Merge pull request #42967 from p8/main
Clean up missing dots in changelogs
2021-08-13 02:24:40 +02:00
John Hawthorn
bb5208692a Avoid building full path objects when cached 2021-08-09 14:52:11 -07:00
John Hawthorn
4db7ae52f8 Remove cache from Template::Resolver 2021-08-09 14:52:11 -07:00
John Hawthorn
76561430e5 Normalize locals in unbound templates 2021-08-09 12:56:57 -07:00
John Hawthorn
da81403665 Use TemplateDetails::Requested as details_key 2021-08-09 12:56:57 -07:00
John Hawthorn
6b49f33054
Merge pull request #42969 from Matt-Yorkley/tracker-tests
Create shared examples for dependency tracker tests
2021-08-08 12:36:01 -07:00
Matt-Yorkley
73b3772e49 Move dependency tracker tests shared examples
The bulk of these tests should be run using both the ERBTracker and the RipperTracker until ERBTracker is eventually removed.
2021-08-08 15:01:15 +01:00
Petrik de Heus
6828334555
Add missing dots to changelogs 2021-08-07 18:53:10 +02:00
Ryuta Kamizono
c3518b4a9c Fix markup in RDoc [ci skip] 2021-08-07 17:52:33 +09:00
Rafael Mendonça França
d4d14a34a1
Remove duplicated test
We have a test with the same name in this file, so this test doesn't
run.
2021-08-05 11:02:09 -04:00
Carlos Antonio da Silva
65bbfa9519 Fix typo in Action View changelog [ci skip] 2021-08-05 11:03:08 -03:00
HParker
41c0681fb7 Default to ERB Tracker
This leaves Ripper tracker as an optional view dependency tracker, but uses the current ERBTracker by default.

Eventually the default can change to the Ripper tracker, but this makes it an optional update for now
2021-08-04 15:34:07 -07:00
John Hawthorn
c44d702a08
Merge pull request #42458 from HParker/use-ripper-dependency-tracker
Replace dependency tracker with ripper based tracker
2021-08-04 11:10:13 -07:00
Joel Hawksley
fd5792f0fc
Add caching? helper method
Caching something that shouldn't be cached is a potential source of
bugs and security vulnerabilities. For example, one could write a
form helper that outputs a request-specific auth token, only for
the helper to be used inside of a `cache` block.

In the GitHub application, we implemented a caching? method and used
it to raise an error if a specific code path is being cached that
we don't want to be cached.

I've credited its original author, @btoews.

Co-authored-by: Ben Toews <mastahyeti@gmail.com>
Co-authored-by: John Hawthorn <jhawthorn@github.com>
Co-authored-by: Kasper Timm Hansen <kaspth@gmail.com>
2021-08-03 15:49:48 -06:00
Rafael Mendonça França
18707ab17f
Standardize nodoc comments 2021-07-29 21:18:07 +00:00
Rafael Mendonça França
6741222f65
Merge pull request #41728 2021-07-29 01:11:59 +00:00
Xander
d9fda55594
Update resolve_link_as to include SVG (#42892)
* Update resolve_link_as to include SVG

Preloading SVGs won't work without 'as: image' because of:

`Preload of /packs/media/images/81d035675e31079ea9da.svg was ignored due to unknown “as” or “type” values, or non-matching “media” attribute.`

Preloading SVGs can be useful, for instance when using sprites such as bootstrap-icons.

* Adds test case for asset_tag_helper

* Fix test case -- silly mistake

[xanderificnl + Rafael Mendonça França]
2021-07-28 16:26:55 -04:00
Jonathan Hefner
11c2c0ef2f Fix incomplete :nodoc: directives [ci-skip] 2021-07-28 10:30:06 -05:00
Jonathan Hefner
8ace007519 Fix current_page? when URL has trailing slash
This fixes the `current_page?` helper when the given URL has a trailing
slash, and is an absolute URL or also has query params.

Fixes #33956.

Co-authored-by: Rien Maertens <rien.maertens@posteo.be>
2021-07-23 17:03:45 -05:00
Ryuta Kamizono
e50b0e3ab3 Fixup CHANGELOGs [ci skip] 2021-07-21 10:08:08 +09:00
John Hawthorn
801980ab8a
Merge pull request #42777 from jhawthorn/requested_details_hash_match
Store requested detail indexes in hashes
2021-07-14 07:13:38 -07:00
John Hawthorn
e70b0a47a0
Merge pull request #42779 from jhawthorn/faster_template_lookups
Speed up template lookups by avoiding splats and ===
2021-07-14 07:05:55 -07:00
Eugene Kenny
c9cdf7410e Remove unnecessary dup from FormTagHelper#field_id
This was needed when `sanitized_method_name` was a memoised method, but
since 59ca21c0119fff803e75e78d800c0c98aee7fd4c it's a local variable.
2021-07-14 13:06:05 +01:00
John Hawthorn
d4ca317993 Avoid splats in LookupContext and PathSet
Though this ends up with a bit more repetition, I believe it's a little
clearer and is also a decent amount faster.
2021-07-13 17:49:15 -07:00
Sean Doyle
3b34cb9e39 Resolve bug in nested FormBuilder#field_id
As a follow-up to [#40127][], this commit adds a bug fix for nested form
builders (through either `fields_for` or `fields`) incorrectly
constructing a field's `[id]` attribute. To do so, treat the
`@object_name` with higher precedence than the `@object`, since that
will be provided as instance state during construction.

[#40127]: https://github.com/rails/rails/pull/40127
2021-07-13 18:16:36 -04:00
John Hawthorn
6c67e27bd2 Use Array() instead of Array === 2021-07-13 15:13:01 -07:00
John Hawthorn
eac19fea2b Store requested detail indexes in hashes
This improves the performance of matching and sorting TemplateDetails
based on Hash#[] being faster than Array#include? and Array#index.
2021-07-13 12:26:26 -07:00
HParker
897b9bf6e2 Replace dependency tracker with ripper based tracker
Instead of using the ERBTracker, we can use RipperTracker which is extracted from https://github.com/jhawthorn/actionview_precompiler.

Using a parser finds dependencies that would otherwise be difficult to find with the regular expressions. It should also theoretically work with other template systems since it operates on the compiled template instead of the contents of the file.

Co-authored-by: John Hawthorn <john@hawthorn.email>
2021-07-12 10:33:09 -07:00
Ted
0c528034cf
Update actionview/CHANGELOG.md
Co-authored-by: Petrik de Heus <petrik@deheus.net>
2021-07-12 09:16:25 -07:00
Ted
141a0859f8
Add CHANGELOG message for PR #41283 2021-07-11 19:04:52 -07:00
Rafael França
37fb99e2c5
Merge pull request #41283 from tywhang/more_accurate_error_for_missing_file
Handle error when file does not exist at filepath
2021-07-07 18:36:34 -04:00
Ryuta Kamizono
5f45aeaaae :nodoc: for corrections
Like all others for corrections already does.
2021-07-05 17:59:22 +09:00
Ryuta Kamizono
2f078aafad Migrate DidYouMean.correct_error to DidYouMean::Correctable for MissingTemplate
Follow up to #42333.
2021-07-05 15:47:07 +09:00
Petrik
0409ed57ac Clean up checks to see if DidYouMean is defined
As of Ruby 2.7 DidYouMean is included as a default gem, so there is no
need to check if DidYouMean is defined in the test suite. We still need
to check if the DidYouMean modules are defined in the actual code, as
someone might run Rails with DidYouMean disabled by using the
`--disable-did_you_mean` flag. This is ussually done for performance
reasons.

This commit also includes some of the changes made by Yuki in:
https://github.com/rails/rails/pull/39555
These changes include replacing Jaro with the more accurate
SpellChecker, and using DidYouMean::Correctable for simplere
corrections.

The DidYouMean::SpellChecker does have a treshold for corrections.
If there is not enough similarity it might not return a suggestion.
To stop the tests from failing some test data had to be changed.

For example, `non_existent` does not meet the treshold for `hello`, but
`ello` does:

DidYouMean::SpellChecker.new(dictionary: %w[hello]).correct('non_existent')
=> []
DidYouMean::SpellChecker.new(dictionary: %w[hello]).correct('ello')
=> ["hello"]

The treshold makes sense for spelling errors. But maybe we should add a
different SpellChecker that helps to get a suggestion even if there is
little overlap. For example for when a model only has 2 attributes
(title and body), it's helpful to get a suggestion for `name`

Co-Authored-By: Yuki Nishijima <yk.nishijima@gmail.com>
2021-07-04 13:43:50 +02:00
Ryuta Kamizono
91593af849 Merge pull request #41559 from jonathanhefner/sms_to-country_code
Add :country_code option to sms_to
2021-07-03 11:19:20 +09:00
Ryuta Kamizono
d7fce6c996 Fix odd closing parenthesis by enabling the Layout/ClosingParenthesisIndentation cop 2021-07-02 18:01:50 +09:00
Dirkjan Bussink
0523532a3c
Always use OpenSSL constants for Digest operations
As also previously discussed in
https://github.com/rails/rails/pull/40770#issuecomment-748347066, this
moves the usage of Digest constants to always use the OpenSSL version of
those Digest implementations.
2021-06-30 13:57:54 +02:00
John Hawthorn
eeea496d5f Remove cvar for registered details 2021-06-29 15:46:18 -07:00
Michael Bianco
9508b4b3c3 Adding docs link to ujs readme 2021-06-28 14:55:37 -06:00
Zachary Scott
70a0a766e3 Remove docs for render layout: with a block and args
This behavior was removed in 9f5cd01 but these docs were missed.

Fixes #42540
2021-06-27 21:31:31 +09:00
Vasiliy Ermolovich
c69f6b1bc7 Make AssetTagHelper#preload_link_tag to use path_to_asset method instead of asset_path.
To avoid conflicts with an asset_path named route.

Closes https://github.com/rails/rails/issues/42545
2021-06-23 18:55:14 +03:00
Rafael França
58ed26f616
Revert "Extract methods assert_queries and assert_no_queries" 2021-06-17 13:35:25 -04:00
Zachary Scott
f8e45f9c6b
Merge pull request #42485 from AdityaBhutani/correct-all-x-based-occurances
[ci skip] Fixing all <x> based occurances to <x>-based
2021-06-17 08:33:54 +09:00
Aditya Bhutani
32af6add67 [ci skip] Fixing all <x> based occurances to <x>-based 2021-06-16 19:15:12 +05:30
David Heinemeier Hansson
8de181dac6
Don't attach UJS form submission handlers to Turbo forms (#42476)
* Don't attach UJS form submission handlers to Turbo forms

Allows for easier migration of apps written for UJS, such that new work can be done with Turbo forms that are marked with data-turbo=true.

* Fix duplicate selectors

* Proper fix take 2
2021-06-15 17:31:33 +02:00
Ricardo Díaz
f644f7d35b Extract methods assert_queries and assert_no_queries
Both methods are defined in multiple parts of the framework. It would
be useful to put them in a proper place, so that repetition is
avoided.

I chose the implementation from `ActiveRecord` because it's a bit more
complete with the `SQLCounter` class, and also because other parts
depend on it.
2021-06-14 09:55:13 -05:00
Rafael Mendonça França
600ff9abfc
Fix all rubocop violations 2021-06-08 23:35:59 +00:00
Adam Hess
e8156a2788 Return "test" as the controller_name in ActionView tests
before https://github.com/rails/rails/pull/40125 test names would be
set to "test" after this change controller_name was nil when using
ActionView::TestCase.

This returns ActionView::TestCase to previous behavior returning "test"
2021-06-07 15:52:08 -07:00
Simon Fish
fe5ef4281f
Add option to strip trailing newlines from ERB templates
Add failing test for views with trailing newlines

Add and test config option

Move config option to config/application.rb

Move implementation to ERB template handler

Move config option to ActionView::Template::Handlers::ERB
2021-06-04 10:27:55 +01:00
John Hawthorn
f303eb2895 Add failing test for link_tags when streaming 2021-05-31 16:13:25 -07:00
John Hawthorn
0f3a895ee1 Dont send preload links headers if streaming
Co-authored-by: John Crepezzi <john.crepezzi@gmail.com>
2021-05-31 16:13:25 -07:00
John Hawthorn
13327e0bec
Merge pull request #42210 from jhawthorn/template_details_rebase
Encapsulate "details" into TemplateDetails
2021-05-12 15:53:04 -07:00
Keeran Raj Hawoldar
63c32e9eda ensure normalize_name is operating on a string 2021-05-12 18:26:03 +01:00
John Hawthorn
f8f9a085cc Encapsulate "details" into TemplateDetails
When dealing with the "details" for a template: locale, format,
variant, and handler, previously we would store these in an ad-hoc way
every place we did. Often as a hash or as separate instance variables on
a class.

This PR attempts to simplify this by encapsulating known details on a
template in a new ActionView::TemplateDetails class, and requested
details in ActionView::TemplateDetails::Requested.

This allowed extracting and simplifying filtering and sorting logic from
the Resolver class as well as extracting default format logic from
UnboundTemplate.

As well as reducing complexity, in the future this should make it
possible to provide suggestions on missing template errors due to
mismatched details, and might allow improved performance.

At least for now these new classes are private (:nodoc)

Co-authored-by: John Crepezzi <john.crepezzi@gmail.com>
2021-05-11 18:48:24 -07:00
Ryuta Kamizono
f55010a179 select! and reject! doesn't return self unless any elements are matched
https://docs.ruby-lang.org/en/3.0.0/Array.html#method-i-select-21
https://docs.ruby-lang.org/en/3.0.0/Array.html#method-i-reject-21
2021-05-12 06:49:49 +09:00
Ryuta Kamizono
b77ae45d29 Add missing slash to test_parse_root_partial_with_slash 2021-05-12 06:24:08 +09:00
Ryuta Kamizono
6c864fa725 Remove duplicated test_parse_partial
https://buildkite.com/rails/rails/builds/77358#27d13623-5ea6-4db8-a16c-2a2ceb6a0caa/977-979
2021-05-12 06:17:43 +09:00