aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/render_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Run `file.close` before unlinking for traviseileencodes2016-01-281-1/+2
| | | | | | | | | | | This works on OSX but for some reason travis is throwing a ``` 1) Error: ExpiresInRenderTest#test_dynamic_render_with_absolute_path: NoMethodError: undefined method `unlink' for nil:NilClass ``` Looking at other tests in Railties the file has a name and we close it before unlinking, so I'm going to try that.
* Regression test for rendering file from absolute patheileencodes2016-01-281-0/+11
| | | | | | Test that we are not allowing you to grab a file with an absolute path outside of your application directory. This is dangerous because it could be used to retrieve files from the server like `/etc/passwd`.
* doc typoAkira Matsuda2016-01-271-2/+2
| | | | [ci skip]
* add a skip for failing testAaron Patterson2016-01-261-1/+2
|
* fix permitted? conditional for `render` callsAaron Patterson2016-01-261-0/+11
|
* clear view path cache between testsAaron Patterson2016-01-261-0/+5
| | | | | | | | The cache for `render file:` seems to also be used in the case of `render(string)`. If one is supposed to be a hit and the other is supposed to be a miss, and they both reference the same file, then the cache could return incorrect values. This commit clears the cache between runs so that we get non-cached behavior.
* Merge branch '5-0-beta-sec'Aaron Patterson2016-01-251-0/+31
|\ | | | | | | | | | | | | | | | | | | | | * 5-0-beta-sec: bumping version fix version update task to deal with .beta1.1 Eliminate instance level writers for class accessors allow :file to be outside rails root, but anything else must be inside the rails view directory Don't short-circuit reject_if proc stop caching mime types globally use secure string comparisons for basic auth username / password
| * allow :file to be outside rails root, but anything else must be inside the ↵Aaron Patterson2016-01-221-0/+31
| | | | | | | | | | | | rails view directory CVE-2016-0752
* | Response etags to always be weak: Prefixed W/ to value returned by ↵abhishek2016-01-201-1/+1
|/ | | | ActionDispatch::Http::Cache::Response#etag= such that etags set in fresh_when and stale? are weak. For #17556.
* Change Integer#year to return a Fixnum instead of a Float to improve consistencyKonstantinos Rousis2015-10-221-2/+2
|
* remove RackDelegation moduleAaron Patterson2015-08-261-2/+0
| | | | | | Since all controller instances are required to have a request and response object, RackDelegation is no longer needed (we always have to delegate to the response)
* Get rid of mocha tests - part 1Marcin Olichwirowicz2015-08-241-4/+4
|
* Stop using deprecated `render :text` in testPrem Sichanugrist2015-07-171-4/+4
| | | | | | | | | 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`.
* Deprecate passing hash as first parameter into ActionController::HeadMehmet Emin İNAÇ2015-06-151-7/+28
|
* Add test coverage for implicit render in empty actionsJorge Bejar2015-06-111-0/+14
|
* Deprecate `:nothing` option for render methodMehmet Emin İNAÇ2015-05-281-0/+10
| | | | `head` method works similar to `render` method with `:nothing` option
* Return true from head methodJoel Hayhurst2015-03-121-0/+11
| | | | | | It was returning false in normal circumstances. This broke the `head :ok and return if` construct. Add appropriate test.
* Implement http_cache_forever to ActionControllerArthur Neves2015-02-151-0/+53
| | | | | | | | | Add http_cache_forever to ActionController, so we can cache results forever. Things like static pages are a good candidate for this type of caching. This cache only controls caching headers, so it is up to the browser to cache those requests.
* Accept a collection in fresh_when and stale?claudiob2015-02-101-1/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The methods `fresh_when` and `stale?` from ActionController::ConditionalGet accept a single record as a short form for a hash. For instance ```ruby def show @article = Article.find(params[:id]) fresh_when(@article) end ``` is just a short form for: ```ruby def show @article = Article.find(params[:id]) fresh_when(etag: @article, last_modified: @article.created_at) end ``` This commit extends `fresh_when` and `stale?` to also accept a collection of records, so that a short form similar to the one above can be used in an `index` action. After this commit, the following code: ```ruby def index @article = Article.all fresh_when(etag: @articles, last_modified: @articles.maximum(:created_at)) end ``` can be simply written as: ```ruby def index @article = Article.all fresh_when(@articles) end ```
* Fix wrong kwarg "record" from #18872claudiob2015-02-101-0/+1
| | | | | | | | | | | | PR #18772 changed the parameters of `stale?` to use `kwargs`. [As for this comment](https://github.com/rails/rails/pull/18872/files#r24456288) the default value for the `etag` parameter should be `record`, not `nil`. This commit fixes the code and introduces a test that: - passed before #18872 - fails on the current master (after #18772) - passes again after setting the default value of `etag` to `record`.
* Switch to kwargs in ActionController::TestCase and ActionDispatch::IntegrationKir Shatrov2015-01-291-6/+6
| | | | | | | | Non-kwargs requests are deprecated now. Guides are updated as well. `post url, nil, nil, { a: 'b' }` doesn't make sense. `post url, params: { y: x }, session: { a: 'b' }` would be an explicit way to do the same
* Remove unused AV fixtures from AP testsclaudiob2015-01-111-65/+0
| | | | | | | | | When `render` was moved from ActionPack to ActionView in acc8e259, some fixtures required by the tests were duplicated, but they are actually only required by ActionView tests. To give one example, `double_render` is already defined [in the AV tests](https://github.com/rails/rails/blob/72139d8d310d896db78eaec98582c7a638135102/actionview/test/actionpack/controller/render_test.rb#L407) and is never used in the ActionPack tests.
* Correctly use the response's status code calling headRobin Dupret2014-12-311-0/+17
| | | | | | | | | | | | | | | | Commit 20fece1 introduced the `_status_code` method to fix calls to `head :ok`. This method has been added on both ActionController::Metal and ActionDispatch::Response. As for the latter, this method is just equivalent to the `response_code` one so commit aefec3c removed it from the `Reponse` object so call to the `_status_code` method on an ActionController::Base instance would be handled by the `Metal` class (which `Base` inherits from) but the status code is not updated according to the response at this level. The fix is to actually rely on `response_code` for ActionController::Base instances but this method doesn't exist for bare Metal controllers so we need to define it.
* When your templates change, browser caches bust automatically.Jeremy Kemper2014-08-171-2/+34
| | | | | | | | | | | | | | | | New default: the template digest is automatically included in your ETags. When you call `fresh_when @post`, the digest for `posts/show.html.erb` is mixed in so future changes to the HTML will blow HTTP caches for you. This makes it easy to HTTP-cache many more of your actions. If you render a different template, you can now pass the `:template` option to include its digest instead: fresh_when @post, template: 'widgets/show' Pass `template: false` to skip the lookup. To turn this off entirely, set: config.action_controller.etag_with_template_digest = false
* Remove redundant code.Guo Xiang Tan2014-06-051-4/+0
|
* Prevent state leak.Guo Xiang Tan2014-06-051-0/+2
|
* Remove missing integration points of AV extractionCarlos Antonio da Silva2013-12-051-1/+1
|
* Move render_test to AVŁukasz Strzałkowski2013-08-251-1298/+106
|
* Create AbstractController::Rendering interfaceŁukasz Strzałkowski2013-08-251-0/+2
| | | | This interface should be use when implementing renderers.
* Revert "Merge branch 'master' of github.com:rails/docrails"Vijay Dev2013-08-171-4/+0
| | | | | | | This reverts commit 70d6e16fbad75b89dd1798ed697e7732b8606fa3, reversing changes made to ea4db3bc078fb3093ecdddffdf4f2f4ff3e1e8f9. Seems to be a code merge done by mistake.
* Fix order dependent testsAkira Matsuda2013-07-261-0/+4
| | | | Reset ActionView::Base.logger after tests
* Fix undefined method `ref' for nil:NilClass for bad accept headersStephen Becker IV2013-06-191-0/+6
|
* Test that #fresh_when accepts an arrayBrandon Keepers2013-05-071-2/+19
| | | | https://github.com/rails/etagger/pull/3
* Remove unnecessary begin..rescue..end, use only rescueAkira Matsuda2013-01-061-9/+7
|
* deprecate `assert_blank` and `assert_present`.Yves Senn2013-01-051-11/+11
| | | | | They don't add any benefits over `assert object.blank?` and `assert object.present?`
* Merge pull request #8662 from ↵Santiago Pastorino2012-12-311-1/+12
|\ | | | | | | | | senny/8661_should_not_append_charset_if_already_present Charset should not be appended to image/* type
| * charset should not be appended for `head` responsesYves Senn2012-12-311-1/+12
| | | | | | | | | | | | | | 1) Failure: test_head_created_with_image_png_content_type(RenderTest) [test/controller/render_test.rb:1238]: Expected: "image/png" Actual: "image/png; charset=utf-8"
* | change spy of after invoked controller action. because ruby-2.0.0 waned ↵SHIBATA Hiroshi2012-12-201-1/+2
|/ | | | unused variables
* update documentation and code to use _action callbacksFrancesco Rodriguez2012-12-071-3/+3
|
* render every partial with a new `PartialRenderer`.Yves Senn2012-11-191-0/+10
| | | | | | | | This resolves issues when rendering nested partials. Previously the `PartialRenderer` was reused which led to situations where the state of the renderer was reset. Closes #8197
* can't pass :locals to #assert_template without a view test case. Closes #3415Yves Senn2012-10-061-0/+11
| | | | | | | | | | | the documentation on #assert_template states that the :locals option is only available in view test cases: # In a view test case, you can also assert that specific locals are passed # to partials: I added a warning when it's passed in an inapropriate context to prevent a NoMethodError.
* Added controller-level etag additions that will be part of the action etag ↵David Heinemeier Hansson2012-08-291-0/+32
| | | | computation *Jeremy Kemper/DHH*
* html_escape should escape single quotesSantiago Pastorino2012-07-311-2/+2
| | | | | https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content Closes #7215
* Removed warnings.Arun Agrawal2012-06-211-3/+3
| | | | | 1. Change in test name as already defined. 2. ambiguous first argument; put parentheses or even spaces
* Merge pull request #6777 from route/logger_in_metal_testsCarlos Antonio da Silva2012-06-191-0/+17
|\ | | | | | | Added test for case when view doesn't have logger method when using ActionController::Metal controller.
| * Added test for case when view doesn't have logger method when using ↵Dmitry Vorotilin2012-06-191-0/+17
| | | | | | | | ActionController::Metal controller.
* | Ensure that cache-control headers are mergedJames Tucker2012-06-181-0/+12
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | There are several aspects to this commit, that don't well fit into broken down commits, so they are detailed here: * When a user uses response.headers['Cache-Control'] = some_value, then the documented convention in ConditionalGet is not adhered to, in this case, response.cache_control is ignored due to `return if self[CACHE_CONTROL].present?` * When a middleware sets cache-control headers that would clobber, they're converted to symbols directly, without underscores. This would lead to bugs. * Items that would live in :extras if set through expires_in, are placed directly in the @cache_control hash, and not respected in many cases (somewhat adhering to the aforementioned documentation). * Although quite useless, any directive named 'extras' would be ignored. The general convention applied is that expires_* take precedence, but no longer overwrite everything and expires_* are ALWAYS applied, even if the header is set. I am still unhappy about the contents of this commit, and the code in general. Ideally it should be refactored to no longer use :extras. I'd likely recommend expanding @cache_control into a class, and giving it the power to handle the merge in a more efficient fashion. Such a commit would be a larger change that could have additional semantic changes for other libraries unless they utilize expires_in in very standard ways.
* Add failing test re #3436 which demonstrates content_type is not respected ↵Kunal Shah2012-05-081-0/+21
| | | | when using the :head method/shortcut
* Merge pull request #5368 from andhapp/remove-max-staleJosé Valim2012-05-071-4/+4
|\ | | | | Minor test improvement
| * Removed max-stale from the tests since it's a request cache-control ↵Anuj Dutta2012-03-101-4/+4
| | | | | | | | directive, just for clarity sake.