aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/actionpack/controller/render_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Enable `Layout/EmptyLinesAroundAccessModifier` copRyuta Kamizono2019-06-131-1/+0
| | | | | | | | | | | 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.
* Change `ActionDispatch::Response#content_type` returning Content-Type header ↵yuuji.yaginuma2019-06-011-12/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | 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. https://github.com/rails/rails/blob/39de7fac0507070e3c5f8b33fbad6fced84d97ed/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 ]
* Introduce Template::File as new render file:John Hawthorn2019-03-271-10/+34
| | | | | | | | | | | | | | | | | | | | | | | The previous behaviour of render file: was essentially the same as render template:, except that templates can be specified as an absolute path on the filesystem. This makes sense for historic reasons, but now render file: is almost exclusively used to render raw files (not .erb) like public/404.html. In addition to complicating the code in template/resolver.rb, I think the current behaviour is surprising to developers. This commit deprecates the existing "lookup a template from anywhere" behaviour and replaces it with "render this file exactly as it is on disk". Handlers will no longer be used (it will render the same as if the :raw handler was used), but formats (.html, .xml, etc) will still be detected (and will default to :plain). The existing render file: behaviour was the path through which Rails apps were vulnerable in the recent CVE-2019-5418. Although the vulnerability has been patched in a fully backwards-compatible way, I think it's a strong hint that we should drop the existing previously-vulnerable behaviour if it isn't a benefit to developers.
* Move inline rendering content-type test to a controller testAaron Patterson2019-02-191-0/+11
| | | | | | This commit is to remove direct access to the "rendered_format" attribute on the lookup context. "rendered_format" is an implementation detail that we shouldn't test directly.
* Add test for Hash-like object being passed to partial `locals`Ufuk Kayserilioglu2019-01-241-0/+10
| | | | | | | | | | The test passes an instance of `ActionController::Parameters` that acts like a Hash but does not respond to some Hash methods like `symbolize_keys`. Moreover, if someone were to call `to_h` on the value it would fail since the parameter is not permitted. So this is a great way to ensure that the partial rendering pipeline does not mess with `locals`.
* Revert "Allow usage of strings as locals for partial renderer"Ufuk Kayserilioglu2019-01-241-10/+0
|
* Remove deprecated catch-all route in the AV testsAaron Patterson2018-09-241-0/+118
| | | | | | | | 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
* Merge pull request #30647 from droptheplot/render-partials-string-localsRafael França2018-04-271-0/+9
|\ | | | | Allow usage of strings as locals for partial renderer
| * Allow usage of strings as locals for partial rendererSergey Novikov2017-09-181-0/+9
| |
* | Fix actionview tests executionbogdanvlviv2018-03-041-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On my local environment execution of `cd actionview/ && bin/test` raises error: ``` (snip) rails/actionview/test/template/render_test.rb:6:in `<top (required)>': superclass mismatch for class TestController (TypeError) ``` In some test files `TestController` inherited from `ActionController::Base`, but in `test/actionpack/controller/render_test.rb` file `TestController` inherited from `ApplicationController`. This produces error `superclass mismatch for class TestController (TypeError)` Step to reproduce this on any environment: `cd actionview/ && bin/test test/template/streaming_render_test.rb test/actionpack/controller/render_test.rb`
* | Enable `Layout/LeadingCommentSpace` to not allow cosmetic changes in the futureRyuta Kamizono2017-12-141-1/+1
|/ | | | Follow up of #31432.
* Use frozen string literal in actionview/Kir Shatrov2017-07-241-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* Define path with __dir__bogdanvlviv2017-05-231-6/+6
| | | | | | ".. with __dir__ we can restore order in the Universe." - by @fxn Related to 5b8738c2df003a96f0e490c43559747618d10f5f
* DRY fake models for testingAkira Matsuda2017-02-021-35/+1
|
* class Foo < Struct.new(:x) creates an extra unneeded anonymous classAkira Matsuda2017-01-131-2/+2
| | | | because Struct.new returns a Class, we just can give it a name and use it directly without inheriting from it
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-2/+2
|
* Add three new rubocop rulesRafael Mendonça França2016-08-161-6/+6
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* applies remaining conventions across the projectXavier Noria2016-08-061-6/+6
|
* modernizes hash syntax in actionviewXavier Noria2016-08-061-96/+96
|
* applies new string literal convention in actionview/testXavier Noria2016-08-061-42/+42
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Delete bad testSean Griffin2016-06-071-5/+0
| | | | | | | | | | | | This test was broken by f650e0324207e46ed5240380e60bdf1e2a5023a6. It was added by https://github.com/rails/rails/pull/17978, and is adequately tested elsewhere. The reason that this breaks is that `Controller#process` is not going to set a new response object, and we now terminate in callbacks if the response has been sent. The only reason that this test was calling `get` in the first place was because the controller under test blows up if `request` was `nil`. The point being that the failure is invalid, and I don't think we need to fix the test in this location.
* Use `Mime[:foo]` instead of `Mime::Type[:FOO]` for back compatJeremy Daer2015-10-061-1/+1
| | | | | | | | | | | | | | | | | Rails 4.x and earlier didn't support `Mime::Type[:FOO]`, so libraries that support multiple Rails versions would've had to feature-detect whether to use `Mime::Type[:FOO]` or `Mime::FOO`. `Mime[:foo]` has been around for ages to look up registered MIME types by symbol / extension, though, so libraries and plugins can safely switch to that without breaking backward- or forward-compatibility. Note: `Mime::ALL` isn't a real MIME type and isn't registered for lookup by type or extension, so it's not available as `Mime[:all]`. We use it internally as a wildcard for `respond_to` negotiation. If you use this internal constant, continue to reference it with `Mime::ALL`. Ref. efc6dd550ee49e7e443f9d72785caa0f240def53
* render should return a stringAaron Patterson2015-10-051-1/+1
|
* :hocho: TyposAkira Matsuda2015-09-211-1/+1
|
* Stop using deprecated `render :text` in testPrem Sichanugrist2015-07-171-19/+19
| | | | | | | | | This will silence deprecation warnings. Most of the test can be changed from `render :text` to render `:plain` or `render :body` right away. However, there are some tests that needed to be fixed by hand as they actually assert the default Content-Type returned from `render :body`.
* Revert "revises a test to account for case-insensitive file systems"Matthew Draper2015-06-141-18/+2
| | | | This reverts commit d345ce9630ce4c01bc81a09fb015e7bd935600ad.
* Remove `assigns` and `assert_template`.Guo Xiang Tan2015-05-301-46/+20
|
* Deprecate `:nothing` option for render methodMehmet Emin İNAÇ2015-05-281-1/+1
| | | | `head` method works similar to `render` method with `:nothing` option
* Remove deprecation warning.Guo Xiang Tan2015-05-221-1/+1
| | | | https://travis-ci.org/rails/rails/jobs/63594316#L1982
* revises a test to account for case-insensitive file systemsXavier Noria2015-05-211-3/+19
| | | | | | | | | | | | The patched test assumed the file system is case-sensitive, but that is not necessarily the case. In particular, this test did not pass in the recommended setup for the dev box, because the /vagrant shared folder is case-insensitive. After looking at some gems that provide access to file system metadata I have chosen to go with the check you can see in the patch because, albeit it's a bit dirty creating a file, it is super easy to understand and clearly portable. References https://github.com/rails/rails-dev-box/issues/102.
* Merge pull request #18948 from kaspth/automatic-collection-cachingRafael Mendonça França2015-02-251-0/+4
|\ | | | | Merge multi_fetch_fragments.
| * Merge multi_fetch_fragments.Kasper Timm Hansen2015-02-201-0/+4
| | | | | | | | | | | | | | | | Makes caching a collection of template partials faster using `read_multi` on the Rails cache store. Some caching implementations have optimized `read_multi` so we don't have to check in the cache store for every template.
* | Error message testing fixFranky W2015-02-201-2/+2
|/ | | | | | | | | The testing of error messages have been implemented wrongly a few times. This is an attempt to fix it. For example, some of these test should have failed with the new code. The reason they are not failling with the new string is the fact they were not being tested beforehand.
* use kwargs instead of xhr method. refs #18771.yuuji.yaginuma2015-02-071-2/+2
|
* Fixed test for deprecation warning in actionview, renaming from ↵Vipul A M2015-01-311-3/+3
| | | | https://github.com/rails/rails/commit/baf14ae513337cb185acf865e93dfc48f3aabf6a
* Support `:assigns` option when rendering with controllers/mailers.brainopia2015-01-221-0/+9
|
* Revert "Revert "Merge pull request #16888 from jejacks0n/render_template""Godfrey Chan2014-09-261-18/+5
| | | | This reverts commit 585e75696b31395aee895e5366e331c07c3f5ee1.
* Revert "Merge pull request #16888 from jejacks0n/render_template"Godfrey Chan2014-09-231-5/+18
| | | | | | | This reverts commit 07635a74b5ee08dcba3f6617def6230d8f114fe5, reversing changes made to 1b5f61a025b6ce1ee52b7148e3ed2a9acbde28b9. Reason: it's not ready :bomb:, see https://github.com/rails/rails/pull/16888#issuecomment-56400816
* Changes default render behavior from file to template.jejacks0n2014-09-111-18/+5
|
* Added PartialIteration class used when rendering collectionsJoel Junström2014-07-161-0/+18
| | | | | | | | | | | | The iteration object is available as the local variable "template_name_iteration" when rendering partials with collections. It gives access to the +size+ of the collection beeing iterated over, the current +index+ and two convinicence methods +first?+ and +last?+ "template_name_counter" variable is kept but is deprecated. [Joel Junström + Lucas Uyezu]
* Fixed borken tests in AV caused by 013c74dGodfrey Chan2014-07-101-2/+2
|
* Ensure that .process return the method returnArthur Neves2014-05-061-1/+5
|
* Unused class in AV testAkira Matsuda2013-12-251-2/+0
|
* Prefer assert_raise instead of flunk + rescue to test for exceptionsCarlos Antonio da Silva2013-12-191-3/+3
| | | | | | Change most tests to make use of assert_raise returning the raised exception rather than relying on a combination of flunk + rescue to check for exception types/messages.
* Fix integration test to pass same-origin verificationJeremy Kemper2013-12-171-1/+1
|
* Minor typo fixesAkira Matsuda2013-11-271-1/+1
|
* Move actionpack's controller testsŁukasz Strzałkowski2013-08-251-0/+1337