class RespondToController
Public Instance Methods
all_types_with_layout()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 141 def all_types_with_layout respond_to do |type| type.html end end
custom_constant_handling()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 113 def custom_constant_handling respond_to do |type| type.html { render body: "HTML" } type.mobile { render body: "Mobile" } end end
custom_constant_handling_without_block()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 120 def custom_constant_handling_without_block respond_to do |type| type.html { render body: "HTML" } type.mobile end end
custom_type_handling()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 105 def custom_type_handling respond_to do |type| type.html { render body: "HTML" } type.custom("application/crazy-xml") { render body: "Crazy XML" } type.all { render body: "Nothing" } end end
forced_xml()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 56 def forced_xml request.format = :xml respond_to do |type| type.html { render body: "HTML" } type.xml { render body: "XML" } end end
format_any_variant_any()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 268 def format_any_variant_any respond_to do |format| format.html { render body: "HTML" } format.any(:js, :xml) do |variant| variant.phone { render body: "phone" } variant.any(:tablet, :phablet) { render body: "tablet" } end end end
handle_any()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 127 def handle_any respond_to do |type| type.html { render body: "HTML" } type.any(:js, :xml) { render body: "Either JS or XML" } end end
handle_any_any()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 134 def handle_any_any respond_to do |type| type.html { render body: "HTML" } type.any { render body: "Whatever you ask for, I got it" } end end
html_or_xml()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 40 def html_or_xml respond_to do |type| type.html { render body: "HTML" } type.xml { render body: "XML" } type.all { render body: "Nothing" } end end
html_xml_or_rss()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 16 def html_xml_or_rss respond_to do |type| type.html { render body: "HTML" } type.xml { render body: "XML" } type.rss { render body: "RSS" } type.all { render body: "Nothing" } end end
iphone_with_html_response_type()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 153 def iphone_with_html_response_type request.format = :iphone if request.env["HTTP_ACCEPT"] == "text/iphone" respond_to do |type| type.html { @type = "Firefox" } type.iphone { @type = "iPhone" } end end
iphone_with_html_response_type_without_layout()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 162 def iphone_with_html_response_type_without_layout request.format = "iphone" if request.env["HTTP_ACCEPT"] == "text/iphone" respond_to do |type| type.html { @type = "Firefox"; render action: "iphone_with_html_response_type" } type.iphone { @type = "iPhone" ; render action: "iphone_with_html_response_type" } end end
js_or_html()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 25 def js_or_html respond_to do |type| type.html { render body: "HTML" } type.js { render body: "JS" } type.all { render body: "Nothing" } end end
json_or_yaml()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 33 def json_or_yaml respond_to do |type| type.json { render body: "JSON" } type.yaml { render body: "YAML" } end end
json_with_callback()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 147 def json_with_callback respond_to do |type| type.json { render json: "JS", callback: "alert" } end end
json_xml_or_html()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 48 def json_xml_or_html respond_to do |type| type.json { render body: "JSON" } type.xml { render xml: "XML" } type.html { render body: "HTML" } end end
just_xml()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 65 def just_xml respond_to do |type| type.xml { render body: "XML" } end end
made_for_content_type()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 97 def made_for_content_type respond_to do |type| type.rss { render body: "RSS" } type.atom { render body: "ATOM" } type.all { render body: "Nothing" } end end
missing_templates()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 78 def missing_templates respond_to do |type| # This test requires a block that is empty type.json {} type.xml end end
multiple_variants_for_format()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 189 def multiple_variants_for_format respond_to do |type| type.html do |html| html.tablet { render body: "tablet" } html.phone { render body: "phone" } end end end
using_defaults()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 71 def using_defaults respond_to do |type| type.html type.xml end end
using_defaults_with_all()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 90 def using_defaults_with_all respond_to do |type| type.html type.all { render body: "ALL" } end end
using_defaults_with_type_list()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 86 def using_defaults_with_type_list respond_to(:html, :xml) end
variant_any()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 223 def variant_any respond_to do |format| format.html do |variant| variant.any(:tablet, :phablet) { render body: "any" } variant.phone { render body: "phone" } end end end
variant_any_any()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 232 def variant_any_any respond_to do |format| format.html do |variant| variant.any { render body: "any" } variant.phone { render body: "phone" } end end end
variant_any_implicit_render()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 255 def variant_any_implicit_render respond_to do |format| format.html.phone format.html.any(:tablet, :phablet) end end
variant_any_with_none()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 262 def variant_any_with_none respond_to do |format| format.html.any(:none, :phone) { render body: "none or phone" } end end
variant_inline_any()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 241 def variant_inline_any respond_to do |format| format.html.any(:tablet, :phablet) { render body: "any" } format.html.phone { render body: "phone" } end end
variant_inline_any_any()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 248 def variant_inline_any_any respond_to do |format| format.html.phone { render body: "phone" } format.html.any { render body: "any" } end end
variant_inline_syntax()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 207 def variant_inline_syntax respond_to do |format| format.js { render body: "js" } format.html.none { render body: "none" } format.html.phone { render body: "phone" } end end
variant_inline_syntax_without_block()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 215 def variant_inline_syntax_without_block respond_to do |format| format.js format.html.none format.html.phone end end
variant_plus_none_for_format()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 198 def variant_plus_none_for_format respond_to do |format| format.html do |variant| variant.phone { render body: "phone" } variant.none end end end
variant_with_format_and_custom_render()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 181 def variant_with_format_and_custom_render request.variant = :mobile respond_to do |type| type.html { render body: "mobile" } end end
variant_with_implicit_template_rendering()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 171 def variant_with_implicit_template_rendering # This has exactly one variant template defined in the file system (+mobile.html.erb), # which raises the regular MissingTemplate error for other variants. end
variant_without_implicit_template_rendering()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 176 def variant_without_implicit_template_rendering # This differs from the above in that it does not have any templates defined in the file # system, which triggers the ImplicitRender (204 No Content) behavior. end
Private Instance Methods
set_layout()
click to toggle source
# File actionpack/test/controller/mime/respond_to_test.rb, line 279 def set_layout case action_name when "all_types_with_layout", "iphone_with_html_response_type" "respond_to/layouts/standard" when "iphone_with_html_response_type_without_layout" "respond_to/layouts/missing" end end