mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fix word case. json
-> JSON
This commit is contained in:
parent
c5d8105e62
commit
3a32915bbc
17 changed files with 36 additions and 36 deletions
|
@ -1,4 +1,4 @@
|
|||
* Rescue `JSON::ParserError` in Cookies json deserializer to discards marshal dumps:
|
||||
* Rescue `JSON::ParserError` in Cookies JSON deserializer to discards marshal dumps:
|
||||
|
||||
Without this change, if `action_dispatch.cookies_serializer` is set to `:json` and
|
||||
the app tries to read a `:marshal` serialized cookie, it would error out which wouldn't
|
||||
|
|
|
@ -18,28 +18,28 @@ class JsonParamsParsingTest < ActionDispatch::IntegrationTest
|
|||
TestController.last_request_parameters = nil
|
||||
end
|
||||
|
||||
test "parses json params for application json" do
|
||||
test "parses JSON params for application JSON" do
|
||||
assert_parses(
|
||||
{ "person" => { "name" => "David" } },
|
||||
"{\"person\": {\"name\": \"David\"}}", "CONTENT_TYPE" => "application/json"
|
||||
)
|
||||
end
|
||||
|
||||
test "parses boolean and number json params for application json" do
|
||||
test "parses boolean and number JSON params for application JSON" do
|
||||
assert_parses(
|
||||
{ "item" => { "enabled" => false, "count" => 10 } },
|
||||
"{\"item\": {\"enabled\": false, \"count\": 10}}", "CONTENT_TYPE" => "application/json"
|
||||
)
|
||||
end
|
||||
|
||||
test "parses json params for application jsonrequest" do
|
||||
test "parses JSON params for application jsonrequest" do
|
||||
assert_parses(
|
||||
{ "person" => { "name" => "David" } },
|
||||
"{\"person\": {\"name\": \"David\"}}", "CONTENT_TYPE" => "application/jsonrequest"
|
||||
)
|
||||
end
|
||||
|
||||
test "parses json params for application problem+json" do
|
||||
test "parses JSON params for application problem+json" do
|
||||
assert_parses(
|
||||
{ "person" => { "name" => "David" } },
|
||||
"{\"person\": {\"name\": \"David\"}}", "CONTENT_TYPE" => "application/problem+json"
|
||||
|
@ -140,35 +140,35 @@ class RootLessJSONParamsParsingTest < ActionDispatch::IntegrationTest
|
|||
UsersController.last_request_parameters = nil
|
||||
end
|
||||
|
||||
test "parses json params for application json" do
|
||||
test "parses JSON params for application JSON" do
|
||||
assert_parses(
|
||||
{ "user" => { "username" => "sikachu" }, "username" => "sikachu" },
|
||||
"{\"username\": \"sikachu\"}", "CONTENT_TYPE" => "application/json"
|
||||
)
|
||||
end
|
||||
|
||||
test "parses json params for application jsonrequest" do
|
||||
test "parses JSON params for application jsonrequest" do
|
||||
assert_parses(
|
||||
{ "user" => { "username" => "sikachu" }, "username" => "sikachu" },
|
||||
"{\"username\": \"sikachu\"}", "CONTENT_TYPE" => "application/jsonrequest"
|
||||
)
|
||||
end
|
||||
|
||||
test "parses json params for application problem+json" do
|
||||
test "parses JSON params for application problem+json" do
|
||||
assert_parses(
|
||||
{ "user" => { "username" => "sikachu" }, "username" => "sikachu" },
|
||||
"{\"username\": \"sikachu\"}", "CONTENT_TYPE" => "application/problem+json"
|
||||
)
|
||||
end
|
||||
|
||||
test "parses json with non-object JSON content" do
|
||||
test "parses JSON with non-object JSON content" do
|
||||
assert_parses(
|
||||
{ "user" => { "_json" => "string content" }, "_json" => "string content" },
|
||||
"\"string content\"", "CONTENT_TYPE" => "application/json"
|
||||
)
|
||||
end
|
||||
|
||||
test "parses json params after custom json mime type registered" do
|
||||
test "parses JSON params after custom JSON mime type registered" do
|
||||
Mime::Type.unregister :json
|
||||
Mime::Type.register "application/json", :json, %w(application/vnd.rails+json)
|
||||
assert_parses(
|
||||
|
@ -180,7 +180,7 @@ class RootLessJSONParamsParsingTest < ActionDispatch::IntegrationTest
|
|||
Mime::Type.register "application/json", :json, %w( text/x-json application/jsonrequest application/problem+json )
|
||||
end
|
||||
|
||||
test "parses json params after custom json mime type registered with synonym" do
|
||||
test "parses JSON params after custom JSON mime type registered with synonym" do
|
||||
Mime::Type.unregister :json
|
||||
Mime::Type.register "application/json", :json, %w(application/vnd.rails+json)
|
||||
assert_parses(
|
||||
|
|
|
@ -8315,7 +8315,7 @@ jQuery.extend( {
|
|||
// Text to html (true = no transformation)
|
||||
"text html": true,
|
||||
|
||||
// Evaluate text as a json expression
|
||||
// Evaluate text as a JSON expression
|
||||
"text json": jQuery.parseJSON,
|
||||
|
||||
// Parse text as xml
|
||||
|
@ -9295,7 +9295,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
|||
s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
|
||||
}
|
||||
|
||||
// Use data converter to retrieve json after script execution
|
||||
// Use data converter to retrieve JSON after script execution
|
||||
s.converters[ "script json" ] = function() {
|
||||
if ( !responseContainer ) {
|
||||
jQuery.error( callbackName + " was not called" );
|
||||
|
@ -9303,7 +9303,7 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
|
|||
return responseContainer[ 0 ];
|
||||
};
|
||||
|
||||
// Force json dataType
|
||||
// Force JSON dataType
|
||||
s.dataTypes[ 0 ] = "json";
|
||||
|
||||
// Install callback
|
||||
|
|
|
@ -215,7 +215,7 @@ module ActiveModel
|
|||
|
||||
# Returns a Hash that can be used as the JSON representation for this
|
||||
# object. You can pass the <tt>:full_messages</tt> option. This determines
|
||||
# if the json object should contain full messages or not (false by default).
|
||||
# if the JSON object should contain full messages or not (false by default).
|
||||
#
|
||||
# person.errors.as_json # => {:name=>["cannot be nil"]}
|
||||
# person.errors.as_json(full_messages: true) # => {:name=>["name cannot be nil"]}
|
||||
|
|
|
@ -14,7 +14,7 @@ class JsonSerializationTest < ActiveModel::TestCase
|
|||
@contact.preferences = { "shows" => "anime" }
|
||||
end
|
||||
|
||||
test "should not include root in json (class method)" do
|
||||
test "should not include root in JSON (class method)" do
|
||||
json = @contact.to_json
|
||||
|
||||
assert_no_match %r{^\{"contact":\{}, json
|
||||
|
@ -25,7 +25,7 @@ class JsonSerializationTest < ActiveModel::TestCase
|
|||
assert_match %r{"preferences":\{"shows":"anime"\}}, json
|
||||
end
|
||||
|
||||
test "should include root in json if include_root_in_json is true" do
|
||||
test "should include root in JSON if include_root_in_json is true" do
|
||||
original_include_root_in_json = Contact.include_root_in_json
|
||||
Contact.include_root_in_json = true
|
||||
json = @contact.to_json
|
||||
|
@ -40,19 +40,19 @@ class JsonSerializationTest < ActiveModel::TestCase
|
|||
Contact.include_root_in_json = original_include_root_in_json
|
||||
end
|
||||
|
||||
test "should include root in json (option) even if the default is set to false" do
|
||||
test "should include root in JSON (option) even if the default is set to false" do
|
||||
json = @contact.to_json(root: true)
|
||||
|
||||
assert_match %r{^\{"contact":\{}, json
|
||||
end
|
||||
|
||||
test "should not include root in json (option)" do
|
||||
test "should not include root in JSON (option)" do
|
||||
json = @contact.to_json(root: false)
|
||||
|
||||
assert_no_match %r{^\{"contact":\{}, json
|
||||
end
|
||||
|
||||
test "should include custom root in json" do
|
||||
test "should include custom root in JSON" do
|
||||
json = @contact.to_json(root: "json_contact")
|
||||
|
||||
assert_match %r{^\{"json_contact":\{}, json
|
||||
|
@ -198,7 +198,7 @@ class JsonSerializationTest < ActiveModel::TestCase
|
|||
assert_no_match %r{"preferences":}, json
|
||||
end
|
||||
|
||||
test "Class.model_name should be json encodable" do
|
||||
test "Class.model_name should be JSON encodable" do
|
||||
assert_match %r{"Contact"}, Contact.model_name.to_json
|
||||
end
|
||||
end
|
||||
|
|
|
@ -450,7 +450,7 @@ module ActiveRecord
|
|||
false
|
||||
end
|
||||
|
||||
# Does this adapter support json data type?
|
||||
# Does this adapter support JSON data type?
|
||||
def supports_json?
|
||||
false
|
||||
end
|
||||
|
|
|
@ -530,7 +530,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase
|
|||
assert_predicate topic, :user_defined_time?
|
||||
end
|
||||
|
||||
test "user-defined json attribute predicate" do
|
||||
test "user-defined JSON attribute predicate" do
|
||||
klass = Class.new(ActiveRecord::Base) do
|
||||
self.table_name = Topic.table_name
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Hack to load json gem first so we can override its to_json.
|
||||
# Hack to load JSON gem first so we can override its to_json.
|
||||
require "json"
|
||||
require "bigdecimal"
|
||||
require "ipaddr"
|
||||
|
|
|
@ -5,7 +5,7 @@ require "active_support/core_ext/module/delegation"
|
|||
require "json"
|
||||
|
||||
module ActiveSupport
|
||||
# Look for and parse json strings that look like ISO 8601 times.
|
||||
# Look for and parse JSON strings that look like ISO 8601 times.
|
||||
mattr_accessor :parse_json_times
|
||||
|
||||
module JSON
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
require_relative "../../abstract_unit"
|
||||
|
||||
# These test cases were added to test that cherry-picking the json extensions
|
||||
# These test cases were added to test that cherry-picking the JSON extensions
|
||||
# works correctly, primarily for dependencies problems reported in #16131. They
|
||||
# need to be executed in isolation to reproduce the scenario correctly, because
|
||||
# other test cases might have already loaded additional dependencies.
|
||||
|
|
|
@ -4,7 +4,7 @@ require_relative "../../abstract_unit"
|
|||
require "json"
|
||||
require_relative "../../json/encoding_test_cases"
|
||||
|
||||
# These test cases were added to test that we do not interfere with json gem's
|
||||
# These test cases were added to test that we do not interfere with JSON gem's
|
||||
# output when the AS encoder is loaded, primarily for problems reported in
|
||||
# #20775. They need to be executed in isolation to reproduce the scenario
|
||||
# correctly, because other test cases might have already loaded additional
|
||||
|
|
|
@ -66,9 +66,9 @@ class TestJSONDecoding < ActiveSupport::TestCase
|
|||
%q({"a":"\n"}) => { "a" => "\n" },
|
||||
%q({"a":"\u000a"}) => { "a" => "\n" },
|
||||
%q({"a":"Line1\u000aLine2"}) => { "a" => "Line1\nLine2" },
|
||||
# prevent json unmarshalling
|
||||
# prevent JSON unmarshalling
|
||||
'{"json_class":"TestJSONDecoding::Foo"}' => { "json_class" => "TestJSONDecoding::Foo" },
|
||||
# json "fragments" - these are invalid JSON, but ActionPack relies on this
|
||||
# JSON "fragments" - these are invalid JSON, but ActionPack relies on this
|
||||
'"a string"' => "a string",
|
||||
"1.1" => 1.1,
|
||||
"1" => 1,
|
||||
|
@ -81,7 +81,7 @@ class TestJSONDecoding < ActiveSupport::TestCase
|
|||
TESTS.each_with_index do |(json, expected), index|
|
||||
fail_message = "JSON decoding failed for #{json}"
|
||||
|
||||
test "json decodes #{index}" do
|
||||
test "JSON decodes #{index}" do
|
||||
with_tz_default "Eastern Time (US & Canada)" do
|
||||
with_parse_json_times(true) do
|
||||
silence_warnings do
|
||||
|
@ -96,7 +96,7 @@ class TestJSONDecoding < ActiveSupport::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
test "json decodes time json with time parsing disabled" do
|
||||
test "JSON decodes time JSON with time parsing disabled" do
|
||||
with_parse_json_times(false) do
|
||||
expected = { "a" => "2007-01-01 01:12:34 Z" }
|
||||
assert_equal expected, ActiveSupport::JSON.decode(%({"a": "2007-01-01 01:12:34 Z"}))
|
||||
|
|
|
@ -496,7 +496,7 @@ for detailed changes.
|
|||
map to integers in the database, but can be queried by
|
||||
name. ([Commit](https://github.com/rails/rails/commit/db41eb8a6ea88b854bf5cd11070ea4245e1639c5))
|
||||
|
||||
* Type cast json values on write, so that the value is consistent with reading
|
||||
* Type cast JSON values on write, so that the value is consistent with reading
|
||||
from the database. ([Pull Request](https://github.com/rails/rails/pull/12643))
|
||||
|
||||
* Type cast hstore values on write, so that the value is consistent
|
||||
|
|
|
@ -1191,7 +1191,7 @@ The I18n API described in this guide is primarily intended for translating inter
|
|||
|
||||
Several gems can help with this:
|
||||
|
||||
* [Mobility](https://github.com/shioyama/mobility): Provides support for storing translations in many formats, including translation tables, json columns (PostgreSQL), etc.
|
||||
* [Mobility](https://github.com/shioyama/mobility): Provides support for storing translations in many formats, including translation tables, JSON columns (PostgreSQL), etc.
|
||||
* [Traco](https://github.com/barsoom/traco): Translatable columns stored in the model table itself
|
||||
|
||||
Conclusion
|
||||
|
|
|
@ -2245,7 +2245,7 @@ start using the more precise `:plain`, `:html`, and `:body` options instead.
|
|||
Using `render :text` may pose a security risk, as the content is sent as
|
||||
`text/html`.
|
||||
|
||||
### PostgreSQL json and hstore datatypes
|
||||
### PostgreSQL JSON and hstore datatypes
|
||||
|
||||
Rails 4.1 will map `json` and `hstore` columns to a string-keyed Ruby `Hash`.
|
||||
In earlier versions, a `HashWithIndifferentAccess` was used. This means that
|
||||
|
|
|
@ -121,7 +121,7 @@ module ApplicationTests
|
|||
assert_equal "signed cookie", verifier_sha512.verify(last_response.body, purpose: "cookie.signed_cookie")
|
||||
end
|
||||
|
||||
test "signed cookies with SHA512 digest and json serializer and rotated out SHA256 and SHA1 digests" do
|
||||
test "signed cookies with SHA512 digest and JSON serializer and rotated out SHA256 and SHA1 digests" do
|
||||
app_file "config/routes.rb", <<-RUBY
|
||||
Rails.application.routes.draw do
|
||||
get ':controller(/:action)'
|
||||
|
|
|
@ -136,7 +136,7 @@ module ApplicationTests
|
|||
assert_equal '"1"', last_response.body
|
||||
end
|
||||
|
||||
test "session using encrypted cookie store with json serializer" do
|
||||
test "session using encrypted cookie store with JSON serializer" do
|
||||
app_file "config/routes.rb", <<-RUBY
|
||||
Rails.application.routes.draw do
|
||||
get ':controller(/:action)'
|
||||
|
|
Loading…
Reference in a new issue