diff options
Diffstat (limited to 'actionpack/test/controller/api')
9 files changed, 31 insertions, 43 deletions
diff --git a/actionpack/test/controller/api/conditional_get_test.rb b/actionpack/test/controller/api/conditional_get_test.rb index b4f1673be0..7b70829101 100644 --- a/actionpack/test/controller/api/conditional_get_test.rb +++ b/actionpack/test/controller/api/conditional_get_test.rb @@ -1,6 +1,6 @@ -require 'abstract_unit' -require 'active_support/core_ext/integer/time' -require 'active_support/core_ext/numeric/time' +require "abstract_unit" +require "active_support/core_ext/integer/time" +require "active_support/core_ext/numeric/time" class ConditionalGetApiController < ActionController::API before_action :handle_last_modified_and_etags, only: :two @@ -17,9 +17,9 @@ class ConditionalGetApiController < ActionController::API private - def handle_last_modified_and_etags - fresh_when(last_modified: Time.now.utc.beginning_of_day, etag: [ :foo, 123 ]) - end + def handle_last_modified_and_etags + fresh_when(last_modified: Time.now.utc.beginning_of_day, etag: [ :foo, 123 ]) + end end class ConditionalGetApiTest < ActionController::TestCase @@ -31,7 +31,7 @@ class ConditionalGetApiTest < ActionController::TestCase def test_request_gets_last_modified get :two - assert_equal @last_modified, @response.headers['Last-Modified'] + assert_equal @last_modified, @response.headers["Last-Modified"] assert_response :success end @@ -52,6 +52,6 @@ class ConditionalGetApiTest < ActionController::TestCase get :one assert_equal 304, @response.status.to_i assert @response.body.blank? - assert_equal @last_modified, @response.headers['Last-Modified'] + assert_equal @last_modified, @response.headers["Last-Modified"] end end diff --git a/actionpack/test/controller/api/data_streaming_test.rb b/actionpack/test/controller/api/data_streaming_test.rb index 0e7d97d1f4..f15b78d102 100644 --- a/actionpack/test/controller/api/data_streaming_test.rb +++ b/actionpack/test/controller/api/data_streaming_test.rb @@ -1,8 +1,8 @@ -require 'abstract_unit' +require "abstract_unit" module TestApiFileUtils def file_path() File.expand_path(__FILE__) end - def file_data() @data ||= File.open(file_path, 'rb') { |f| f.read } end + def file_data() @data ||= File.open(file_path, "rb") { |f| f.read } end end class DataStreamingApiController < ActionController::API @@ -19,7 +19,7 @@ class DataStreamingApiTest < ActionController::TestCase tests DataStreamingApiController def test_data - response = process('two') + response = process("two") assert_kind_of String, response.body assert_equal file_data, response.body end diff --git a/actionpack/test/controller/api/force_ssl_test.rb b/actionpack/test/controller/api/force_ssl_test.rb index 8578340d82..d239964e4a 100644 --- a/actionpack/test/controller/api/force_ssl_test.rb +++ b/actionpack/test/controller/api/force_ssl_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class ForceSSLApiController < ActionController::API force_ssl diff --git a/actionpack/test/controller/api/implicit_render_test.rb b/actionpack/test/controller/api/implicit_render_test.rb index 26f9cd8f78..b51ee0cf42 100644 --- a/actionpack/test/controller/api/implicit_render_test.rb +++ b/actionpack/test/controller/api/implicit_render_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class ImplicitRenderAPITestController < ActionController::API def empty_action diff --git a/actionpack/test/controller/api/params_wrapper_test.rb b/actionpack/test/controller/api/params_wrapper_test.rb index 53b3a0c3cc..a1da852040 100644 --- a/actionpack/test/controller/api/params_wrapper_test.rb +++ b/actionpack/test/controller/api/params_wrapper_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class ParamsWrapperForApiTest < ActionController::TestCase class UsersController < ActionController::API @@ -17,10 +17,10 @@ class ParamsWrapperForApiTest < ActionController::TestCase tests UsersController def test_specify_wrapper_name - @request.env['CONTENT_TYPE'] = 'application/json' - post :test, params: { 'username' => 'sikachu' } + @request.env["CONTENT_TYPE"] = "application/json" + post :test, params: { "username" => "sikachu" } - expected = { 'username' => 'sikachu', 'person' => { 'username' => 'sikachu' }} + expected = { "username" => "sikachu", "person" => { "username" => "sikachu" } } assert_equal expected, @controller.last_parameters end end diff --git a/actionpack/test/controller/api/redirect_to_test.rb b/actionpack/test/controller/api/redirect_to_test.rb index 18877c4b3a..ab14409f40 100644 --- a/actionpack/test/controller/api/redirect_to_test.rb +++ b/actionpack/test/controller/api/redirect_to_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class RedirectToApiController < ActionController::API def one diff --git a/actionpack/test/controller/api/renderers_test.rb b/actionpack/test/controller/api/renderers_test.rb index 911a8144b2..04e34a1f8f 100644 --- a/actionpack/test/controller/api/renderers_test.rb +++ b/actionpack/test/controller/api/renderers_test.rb @@ -1,14 +1,14 @@ -require 'abstract_unit' -require 'active_support/core_ext/hash/conversions' +require "abstract_unit" +require "active_support/core_ext/hash/conversions" class RenderersApiController < ActionController::API class Model def to_json(options = {}) - { a: 'b' }.to_json(options) + { a: "b" }.to_json(options) end def to_xml(options = {}) - { a: 'b' }.to_xml(options) + { a: "b" }.to_xml(options) end end @@ -21,11 +21,7 @@ class RenderersApiController < ActionController::API end def plain - render plain: 'Hi from plain', status: 500 - end - - def text - render text: 'Hi from text', status: 500 + render plain: "Hi from plain", status: 500 end end @@ -35,26 +31,18 @@ class RenderersApiTest < ActionController::TestCase def test_render_json get :one assert_response :success - assert_equal({ a: 'b' }.to_json, @response.body) + assert_equal({ a: "b" }.to_json, @response.body) end def test_render_xml get :two assert_response :success - assert_equal({ a: 'b' }.to_xml, @response.body) + assert_equal({ a: "b" }.to_xml, @response.body) end def test_render_plain get :plain assert_response :internal_server_error - assert_equal('Hi from plain', @response.body) - end - - def test_render_text - assert_deprecated do - get :text - end - assert_response :internal_server_error - assert_equal('Hi from text', @response.body) + assert_equal("Hi from plain", @response.body) end end diff --git a/actionpack/test/controller/api/url_for_test.rb b/actionpack/test/controller/api/url_for_test.rb index 0d8691a091..cb4ae7a88a 100644 --- a/actionpack/test/controller/api/url_for_test.rb +++ b/actionpack/test/controller/api/url_for_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class UrlForApiController < ActionController::API def one; end @@ -10,7 +10,7 @@ class UrlForApiTest < ActionController::TestCase def setup super - @request.host = 'www.example.com' + @request.host = "www.example.com" end def test_url_for diff --git a/actionpack/test/controller/api/with_cookies_test.rb b/actionpack/test/controller/api/with_cookies_test.rb index 4491dc9002..8928237dfd 100644 --- a/actionpack/test/controller/api/with_cookies_test.rb +++ b/actionpack/test/controller/api/with_cookies_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class WithCookiesController < ActionController::API include ActionController::Cookies @@ -12,10 +12,10 @@ class WithCookiesTest < ActionController::TestCase tests WithCookiesController def test_with_cookies - request.cookies[:foobar] = 'bazbang' + request.cookies[:foobar] = "bazbang" get :with_cookies - assert_equal 'bazbang', response.body + assert_equal "bazbang", response.body end end |