aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/controller/mime/respond_to_test.rb
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2016-08-06 18:54:50 +0200
committerXavier Noria <fxn@hashref.com>2016-08-06 18:54:50 +0200
commit35b3de8021e68649cac963bd82a74cc75d1f60f0 (patch)
treed37f9096be6ee54a13d3c04cc8e1c5a9ba0d99ec /actionpack/test/controller/mime/respond_to_test.rb
parent628e51ff109334223094e30ad1365188bbd7f9c6 (diff)
downloadrails-35b3de8021e68649cac963bd82a74cc75d1f60f0.tar.gz
rails-35b3de8021e68649cac963bd82a74cc75d1f60f0.tar.bz2
rails-35b3de8021e68649cac963bd82a74cc75d1f60f0.zip
applies new string literal convention in actionpack/test
The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
Diffstat (limited to 'actionpack/test/controller/mime/respond_to_test.rb')
-rw-r--r--actionpack/test/controller/mime/respond_to_test.rb104
1 files changed, 52 insertions, 52 deletions
diff --git a/actionpack/test/controller/mime/respond_to_test.rb b/actionpack/test/controller/mime/respond_to_test.rb
index 993f4001de..ef2d89e1c0 100644
--- a/actionpack/test/controller/mime/respond_to_test.rb
+++ b/actionpack/test/controller/mime/respond_to_test.rb
@@ -1,4 +1,4 @@
-require 'abstract_unit'
+require "abstract_unit"
require "active_support/log_subscriber/test_helper"
class RespondToController < ActionController::Base
@@ -45,9 +45,9 @@ class RespondToController < ActionController::Base
def json_xml_or_html
respond_to do |type|
- type.json { render body: 'JSON' }
- type.xml { render :xml => 'XML' }
- type.html { render body: 'HTML' }
+ type.json { render body: "JSON" }
+ type.xml { render :xml => "XML" }
+ type.html { render body: "HTML" }
end
end
@@ -133,8 +133,8 @@ class RespondToController < ActionController::Base
def handle_any_any
respond_to do |type|
- type.html { render body: 'HTML' }
- type.any { render body: 'Whatever you ask for, I got it' }
+ type.html { render body: "HTML" }
+ type.any { render body: "Whatever you ask for, I got it" }
end
end
@@ -146,7 +146,7 @@ class RespondToController < ActionController::Base
def json_with_callback
respond_to do |type|
- type.json { render :json => 'JS', :callback => 'alert' }
+ type.json { render :json => "JS", :callback => "alert" }
end
end
@@ -305,10 +305,10 @@ class RespondToControllerTest < ActionController::TestCase
def test_html
@request.accept = "text/html"
get :js_or_html
- assert_equal 'HTML', @response.body
+ assert_equal "HTML", @response.body
get :html_or_xml
- assert_equal 'HTML', @response.body
+ assert_equal "HTML", @response.body
assert_raises(ActionController::UnknownFormat) do
get :just_xml
@@ -318,29 +318,29 @@ class RespondToControllerTest < ActionController::TestCase
def test_all
@request.accept = "*/*"
get :js_or_html
- assert_equal 'HTML', @response.body # js is not part of all
+ assert_equal "HTML", @response.body # js is not part of all
get :html_or_xml
- assert_equal 'HTML', @response.body
+ assert_equal "HTML", @response.body
get :just_xml
- assert_equal 'XML', @response.body
+ assert_equal "XML", @response.body
end
def test_xml
@request.accept = "application/xml"
get :html_xml_or_rss
- assert_equal 'XML', @response.body
+ assert_equal "XML", @response.body
end
def test_js_or_html
@request.accept = "text/javascript, text/html"
get :js_or_html, xhr: true
- assert_equal 'JS', @response.body
+ assert_equal "JS", @response.body
@request.accept = "text/javascript, text/html"
get :html_or_xml, xhr: true
- assert_equal 'HTML', @response.body
+ assert_equal "HTML", @response.body
@request.accept = "text/javascript, text/html"
@@ -352,25 +352,25 @@ class RespondToControllerTest < ActionController::TestCase
def test_json_or_yaml_with_leading_star_star
@request.accept = "*/*, application/json"
get :json_xml_or_html
- assert_equal 'HTML', @response.body
+ assert_equal "HTML", @response.body
@request.accept = "*/* , application/json"
get :json_xml_or_html
- assert_equal 'HTML', @response.body
+ assert_equal "HTML", @response.body
end
def test_json_or_yaml
get :json_or_yaml, xhr: true
- assert_equal 'JSON', @response.body
+ assert_equal "JSON", @response.body
- get :json_or_yaml, format: 'json'
- assert_equal 'JSON', @response.body
+ get :json_or_yaml, format: "json"
+ assert_equal "JSON", @response.body
- get :json_or_yaml, format: 'yaml'
- assert_equal 'YAML', @response.body
+ get :json_or_yaml, format: "yaml"
+ assert_equal "YAML", @response.body
- { 'YAML' => %w(text/yaml),
- 'JSON' => %w(application/json text/x-json)
+ { "YAML" => %w(text/yaml),
+ "JSON" => %w(application/json text/x-json)
}.each do |body, content_types|
content_types.each do |content_type|
@request.accept = content_type
@@ -383,20 +383,20 @@ class RespondToControllerTest < ActionController::TestCase
def test_js_or_anything
@request.accept = "text/javascript, */*"
get :js_or_html, xhr: true
- assert_equal 'JS', @response.body
+ assert_equal "JS", @response.body
get :html_or_xml, xhr: true
- assert_equal 'HTML', @response.body
+ assert_equal "HTML", @response.body
get :just_xml, xhr: true
- assert_equal 'XML', @response.body
+ assert_equal "XML", @response.body
end
def test_using_defaults
@request.accept = "*/*"
get :using_defaults
assert_equal "text/html", @response.content_type
- assert_equal 'Hello world!', @response.body
+ assert_equal "Hello world!", @response.body
@request.accept = "application/xml"
get :using_defaults
@@ -422,7 +422,7 @@ class RespondToControllerTest < ActionController::TestCase
@request.accept = "*/*"
get :using_defaults_with_type_list
assert_equal "text/html", @response.content_type
- assert_equal 'Hello world!', @response.body
+ assert_equal "Hello world!", @response.body
@request.accept = "application/xml"
get :using_defaults_with_type_list
@@ -447,7 +447,7 @@ class RespondToControllerTest < ActionController::TestCase
def test_synonyms
@request.accept = "application/javascript"
get :js_or_html
- assert_equal 'JS', @response.body
+ assert_equal "JS", @response.body
@request.accept = "application/x-xml"
get :html_xml_or_rss
@@ -458,82 +458,82 @@ class RespondToControllerTest < ActionController::TestCase
@request.accept = "application/crazy-xml"
get :custom_type_handling
assert_equal "application/crazy-xml", @response.content_type
- assert_equal 'Crazy XML', @response.body
+ assert_equal "Crazy XML", @response.body
@request.accept = "text/html"
get :custom_type_handling
assert_equal "text/html", @response.content_type
- assert_equal 'HTML', @response.body
+ assert_equal "HTML", @response.body
end
def test_xhtml_alias
@request.accept = "application/xhtml+xml,application/xml"
get :html_or_xml
- assert_equal 'HTML', @response.body
+ assert_equal "HTML", @response.body
end
def test_firefox_simulation
@request.accept = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
get :html_or_xml
- assert_equal 'HTML', @response.body
+ assert_equal "HTML", @response.body
end
def test_handle_any
@request.accept = "*/*"
get :handle_any
- assert_equal 'HTML', @response.body
+ assert_equal "HTML", @response.body
@request.accept = "text/javascript"
get :handle_any
- assert_equal 'Either JS or XML', @response.body
+ assert_equal "Either JS or XML", @response.body
@request.accept = "text/xml"
get :handle_any
- assert_equal 'Either JS or XML', @response.body
+ assert_equal "Either JS or XML", @response.body
end
def test_handle_any_any
@request.accept = "*/*"
get :handle_any_any
- assert_equal 'HTML', @response.body
+ assert_equal "HTML", @response.body
end
def test_handle_any_any_parameter_format
- get :handle_any_any, format: 'html'
- assert_equal 'HTML', @response.body
+ get :handle_any_any, format: "html"
+ assert_equal "HTML", @response.body
end
def test_handle_any_any_explicit_html
@request.accept = "text/html"
get :handle_any_any
- assert_equal 'HTML', @response.body
+ assert_equal "HTML", @response.body
end
def test_handle_any_any_javascript
@request.accept = "text/javascript"
get :handle_any_any
- assert_equal 'Whatever you ask for, I got it', @response.body
+ assert_equal "Whatever you ask for, I got it", @response.body
end
def test_handle_any_any_xml
@request.accept = "text/xml"
get :handle_any_any
- assert_equal 'Whatever you ask for, I got it', @response.body
+ assert_equal "Whatever you ask for, I got it", @response.body
end
def test_handle_any_any_unkown_format
- get :handle_any_any, format: 'php'
- assert_equal 'Whatever you ask for, I got it', @response.body
+ get :handle_any_any, format: "php"
+ assert_equal "Whatever you ask for, I got it", @response.body
end
def test_browser_check_with_any_any
@request.accept = "application/json, application/xml"
get :json_xml_or_html
- assert_equal 'JSON', @response.body
+ assert_equal "JSON", @response.body
@request.accept = "application/json, application/xml, */*"
get :json_xml_or_html
- assert_equal 'HTML', @response.body
+ assert_equal "HTML", @response.body
end
def test_html_type_with_layout
@@ -543,15 +543,15 @@ class RespondToControllerTest < ActionController::TestCase
end
def test_json_with_callback_sets_javascript_content_type
- @request.accept = 'application/json'
+ @request.accept = "application/json"
get :json_with_callback
- assert_equal '/**/alert(JS)', @response.body
- assert_equal 'text/javascript', @response.content_type
+ assert_equal "/**/alert(JS)", @response.body
+ assert_equal "text/javascript", @response.content_type
end
def test_xhr
get :js_or_html, xhr: true
- assert_equal 'JS', @response.body
+ assert_equal "JS", @response.body
end
def test_custom_constant
@@ -685,7 +685,7 @@ class RespondToControllerTest < ActionController::TestCase
logger = ActiveSupport::LogSubscriber::TestHelper::MockLogger.new
old_logger, ActionController::Base.logger = ActionController::Base.logger, logger
- get :variant_without_implicit_template_rendering, format: 'json', params: { v: :does_not_matter }
+ get :variant_without_implicit_template_rendering, format: "json", params: { v: :does_not_matter }
assert_response :no_content
assert_equal 1, logger.logged(:info).select{ |s| s == NO_CONTENT_WARNING }.size, "Implicit head :no_content not logged"