Commit Graph

26 Commits

Author SHA1 Message Date
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
Joel Hawksley
136b814144 Include layout when rendering objects from controllers
In https://github.com/rails/rails/pull/37919, support
for rendering objects that respond_to render_in in
controllers was added. However, the implementation
did not support layouts.

This change updates the implementation from #37919
to more closely match the rest of the
ActionView::Template classes, enabling the use of layouts.

Co-authored-by: Felipe Sateler <fsateler@gmail.com>
2020-10-14 11:49:45 -06:00
Joel Hawksley
c82a9193df
Document view components support (#38656) 2020-03-13 23:52:49 +01:00
Joel Hawksley
05a2a939f0 Remove validations from example components
We're moving away from using validations in our
component framework, and feel that it's better
to avoid prescribing their usage in these
example classes, which exist to serve as example
objects that are compatible with the render_in
API.
2020-02-20 09:48:25 -07:00
Ryuta Kamizono
c0af72bf86 Fix rubocop violations 2019-06-14 23:32:15 +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
Kir Shatrov
424117281e Use frozen string literal in actionview/ 2017-07-24 11:53:43 +03:00
Matthew Draper
87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
2017-07-02 02:15:17 +09:30
Kir Shatrov
cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
Akira Matsuda
0157608508 DRY fake models for testing 2017-02-02 16:43:29 +09:00
Akira Matsuda
9360b6be63 class Foo < Struct.new(:x) creates an extra unneeded anonymous class
because Struct.new returns a Class, we just can give it a name and use it directly without inheriting from it
2017-01-13 15:13:47 +09:00
Rafael Mendonça França
530e5ff910
Generate indexed names in input even when objects are not persisted
When you ask to generate multiple nested inputs using:

    field_for('comments[]', Comment.new) do |c|
      c.text_field :body

Rails should generated the names like `post[comments][][body]`.

To make sure we don't have regression the fake models now use the same
implementation of `#to_param` as `ActiveRecord::Base`

Fixes #26942
2017-01-03 16:47:13 -05:00
Rafael Mendonça França
fe1f4b2ad5
Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
Xavier Noria
b326e82dc0 applies remaining conventions across the project 2016-08-06 20:20:22 +02:00
Xavier Noria
4b6c68dfb8 applies new string literal convention in actionview/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 18:50:17 +02:00
Rafael Mendonça França
ddf4c953ae Revert "Merge pull request #22764 from stevenspiel/titleize_model_name_for_default_submit_button_value"
This reverts commit 4158974c60d817c9bc1e2aecb342161295f2ac0d, reversing
changes made to 3d590add45b7ff1de972d99b076cb504d5208935.

Reason: This break i18n in some languages. See
https://github.com/rails/rails/issues/791#issuecomment-192724640
2016-03-05 17:26:04 -03:00
yui-knk
54aaf85e4f Suppress warning (instance variable @persisted not initialized) 2016-01-07 10:24:54 +09:00
Steven Spiel
c74f9cc0e8 downcase default submit button value's model name 2016-01-01 19:59:11 -05:00
Rafael Mendonça França
0caac9bf9b Add tests to make sure label and placeholder respect to_model 2015-02-05 16:19:29 -02:00
claudiob
b26338e83b Better tests for AV::RecordIdentifier
This commit intends to clarify the scope of ActionView::RecordIdentifier
methods `dom_id` and `dom_class`.

Most of the current documentation comes from da257eb8 (7 years ago) when
the decoupling of ActionView, ActiveRecord and ActiveModel was not a concern.

Since then, steps have been taken to reach such decoupling.
Therefore I think it's important to show that ActionView::RecordIdentifier
**does not strictly depend on the ActiveRecord API**:
any class `Post` implementing `post.to_key` and `post.model_name.param_key`
will work.

This commit adds a test to prove that ActionView::RecordIdentifier methods
can also be used on objects that do not subclass ActiveRecord::Base.
2014-12-23 01:59:25 +01:00
claudiob
7375c17114 Remove unused Sheep fixture from AV
The `Sheep` fixture was added in eb23754e when moving template tests
from actionpack to actionview, but it's not actually used in ActionView tests.

The `Sheep` fixture is only used to test `uncountable` in ActiveModel tests,
and is already defined in activemodel/test/models/sheep.rb
2014-12-22 04:02:35 +01:00
Arun Agrawal
64eb39a5b9 Moved viewpathstest into actionview/test/actionpack/controller
These test were not running at all,
Now it will run as a tests part.
2013-10-09 20:09:33 +02:00
Arun Agrawal
32b42e2620 FakeController is not required in AV 2013-10-09 19:30:44 +02:00
Łukasz Strzałkowski
1b446d06dd Move view_paths from AP to AV 2013-08-25 11:39:07 +02:00
Piotr Sarnacki
5e5bf31b4a Remove unneeded files 2013-06-20 17:23:16 +02:00
Piotr Sarnacki
eb23754ebb Move template tests from actionpack to actionview 2013-06-20 17:23:16 +02:00