aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/mime
Commit message (Collapse)AuthorAgeFilesLines
* pass variants in rather than mutating the request.Aaron Patterson2015-07-071-48/+31
| | | | | | Variants are typically set in the controller based on some attribute of the request that the browser sent. We should make our tests more in line with reality by doing the same and not mutating the request object.
* Override default_render's behavior with a blockDave Copeland2015-06-201-0/+21
| | | | | | | | | | In 0de4a23 the behavior when there is a missing template was changed to not raise an error, but instead head :no_content. This is a breaking change and some gems rely on this happening. To allow gems and other code to work around this, allow `default_render` to take a block which, if provided, will execute the contents of that block instead of doing the `head :no_content`.
* Fix ActionPack tests after changes to missing template loggereileencodes2015-04-061-0/+1
| | | | | | | | | After merging #19377 ActionPack tests were missing a require for `ActiveSupport::LogSubscriber::TestHelper` and change didn't take into account that logger could be nil. Added the require and only log to info if logger exists. This wasn't caught earlier because these tests only run after a merge.
* head no_content when there is no template or action performedStephen Bussey2015-04-051-6/+16
|
* Migrating xhr methods to keyword arguments syntaxKir Shatrov2015-02-011-10/+10
| | | | | | | | | | | | in `ActionController::TestCase` and `ActionDispatch::Integration` Old syntax: `xhr :get, :create, params: { id: 1 }` New syntax example: `get :create, params: { id: 1 }, xhr: true`
* Switch to kwargs in ActionController::TestCase and ActionDispatch::IntegrationKir Shatrov2015-01-292-16/+16
| | | | | | | | 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 respond_to/respond_with placeholder methodsCarlos Antonio da Silva2015-01-041-32/+0
| | | | This functionality has been extracted to the responders gem.
* Remove redundant `to_s` in interpolationclaudiob2014-10-301-2/+2
|
* `responders` 1.x won't do it. Told you to RTFM for details!Godfrey Chan2014-08-171-0/+2
|
* The gem is called 'responders'Godfrey Chan2014-08-171-2/+2
|
* Raise a more helpful error for people who are using these extracted featuresGodfrey Chan2014-08-171-0/+30
|
* Move respond_with to the responders gemJosé Valim2014-08-171-737/+0
| | | | | | | | respond_with (and consequently the class-level respond_to) are being removed from Rails. Instead of moving it to a 3rd library, the functionality will be moved to responders gem (at github.com/plataformatec/responders) which already provides some responders extensions.
* Address CVE-2014-4671 (JSONP Flash exploit)Greg Campbell2014-07-091-1/+1
| | | | | | Adds a comment before JSONP callbacks. See http://miki.it/blog/2014/7/8/abusing-jsonp-with-rosetta-flash/ for more details on the exploit in question.
* Change the JSON renderer to enforce the 'JS' Content TypeLucas Mazza2014-07-021-0/+13
| | | | | | | The controller can set the response format as 'JSON' before the renderer code be evaluated, so we must replace it when necessary. Fixes #15081
* Merge pull request #15182 from zuhao/refactor_actionpack_respond_with_test_2Yves Senn2014-05-201-4/+10
|\ | | | | Un-define :to_json for Customer class after stubbing.
| * Add using_resouce_with_json to controller.Zuhao Wan2014-05-201-4/+10
| |
* | Add ActionController::Renderers.remove.Zuhao Wan2014-05-201-0/+19
|/
* Remove tests method for test cases when controller can be inferred.Guo Xiang2014-05-033-6/+0
|
* Return null type format when format is not knowRafael Mendonça França2014-04-141-0/+5
| | | | | | | | | | | | | | | | | | | | | | When requesting a controller with the following code with a unknown format: def my_action respond_to do |format| format.json { head :ok } format.any { render text: 'Default response' } end end we should render the default response instead of raising ActionController::UnknownFormat Fixes #14462 Conflicts: actionpack/CHANGELOG.md actionpack/test/controller/mime/respond_with_test.rb Conflicts: actionpack/CHANGELOG.md
* No variant should also be picked up by variant.any if variant.none is not ↵David Heinemeier Hansson2014-02-131-0/+4
| | | | defined (just like any other variant)
* Variant negotiationLukasz Strzalkowski2014-02-131-0/+21
| | | | | | | | | | | | | | Allow setting `request.variant` as an array - an order in which they will be rendered. For example: request.variant = [:tablet, :phone] respond_to do |format| format.html.none format.html.phone # this gets rendered end
* Add any/all support for variantsŁukasz Strzałkowski2013-12-261-0/+143
| | | | | | | | | | | | | | | | | | | | Like `format.any`, you can do the same with variants. It works for both inline: respond_to do |format| format.html.any { render text: "any" } format.html.phone { render text: "phone" } end and block syntax: respond_to do |format| format.html do |variant| variant.any(:tablet, :phablet){ render text: "any" } variant.phone { render text: "phone" } end end
* Inline variants syntaxŁukasz Strzałkowski2013-12-101-1/+38
| | | | | | | | | | | | | | | | | | | | | | | In most cases, when setting variant specific code, you're not sharing any code within format. Inline syntax can vastly simplify defining variants in those situations: respond_to do |format| format.js { render "trash" } format.html do |variant| variant.phone { redirect_to progress_path } variant.none { render "trash" } end end Becomes: respond_to do |format| format.js { render "trash" } format.html.phone { redirect_to progress_path } format.html.none { render "trash" } end
* Revert "Merge pull request #13235 from strzalek/variants-inline" -- needs a ↵David Heinemeier Hansson2013-12-081-13/+1
| | | | | | | little more work! This reverts commit 186161148a189839a1e0924043f068a8d155ce69, reversing changes made to cad9eb178ea5eec0e27d74e93518f4ed34e2f997.
* Inline variants syntaxŁukasz Strzałkowski2013-12-081-1/+13
| | | | | | | | | | | | | | | | | | | | | | | In most cases, when setting variant specific code, you're not sharing any code within format. Inline syntax can vastly simplify defining variants in those sitiations: respond_to do |format| format.js { render "trash" } format.html do |variant| variant.phone { redirect_to progress_path } variant.none { render "trash" } end end ` Becomes: respond_to do |format| format.js { render "trash" } format.html.phone { redirect_to progress_path } format.html.none { render "trash" } end
* Variants can be declared without a block to signify their presence in the ↵David Heinemeier Hansson2013-12-071-1/+1
| | | | controller
* Allow code execution in case no variant has been set with variant.noneDavid Heinemeier Hansson2013-12-071-0/+16
|
* Action Pack VariantsŁukasz Strzałkowski2013-12-041-0/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | By default, variants in the templates will be picked up if a variant is set and there's a match. The format will be: app/views/projects/show.html.erb app/views/projects/show.html+tablet.erb app/views/projects/show.html+phone.erb If request.variant = :tablet is set, we'll automatically be rendering the html+tablet template. In the controller, we can also tailer to the variants with this syntax: class ProjectsController < ActionController::Base def show respond_to do |format| format.html do |html| @stars = @project.stars html.tablet { @notifications = @project.notifications } html.phone { @chat_heads = @project.chat_heads } end format.js format.atom end end end The variant itself is nil by default, but can be set in before filters, like so: class ApplicationController < ActionController::Base before_action do if request.user_agent =~ /iPad/ request.variant = :tablet end end end This is modeled loosely on custom mime types, but it's specifically not intended to be used together. If you're going to make a custom mime type, you don't need a variant. Variants are for variations on a single mime types.
* Fixing repond_with working directly on the options hashBlueHotDog2013-10-091-0/+15
| | | | | | | | This fixes an issue where the respond_with worked directly with the given options hash, so that if a user relied on it after calling respond_with, the hash wouldn't be the same. Fixes #12029
* Create AbstractController::Rendering interfaceŁukasz Strzałkowski2013-08-251-0/+1
| | | | This interface should be use when implementing renderers.
* Fail informatively in #respond_with when no appropriate #api_behavior ↵Ben Woosley2013-08-171-0/+31
| | | | | | | | | | | | renderer is available. Currently if a user calls #respond_with(csvable), but has not csv renderer available, Responder will just run through the default render behavior twice, raising ActionView::MissingTemplate both times. This changes ActionController::Metal::Responder#api_behavior to check in advance whether there is a renderer available, and raise ActionController::MissingRenderer if not.
* Split the 1200+ line mime_responds_test into 3 more focused and manageable ↵Ben Woosley2013-08-173-0/+1254
test files.