1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #34387 from yhirano55/rails_info_properties_json

Respond /rails/info/properties.json
This commit is contained in:
Ryuta Kamizono 2018-11-07 19:23:54 +09:00 committed by GitHub
commit 8eaffe7e89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 2 deletions

View file

@ -1,3 +1,9 @@
* Add JSON support to rails properties route (`/rails/info/properties`).
Now, `Rails::Info` properties may be accessed in JSON format at `/rails/info/properties.json`.
*Yoshiyuki Hirano*
* Use Ids instead of memory addresses when displaying references in scaffold views. * Use Ids instead of memory addresses when displaying references in scaffold views.
Fixes #29200. Fixes #29200.

View file

@ -54,6 +54,10 @@ module Rails
table << "</table>" table << "</table>"
end end
end end
def to_json
Hash[properties].to_json
end
end end
# The Rails version. # The Rails version.

View file

@ -14,8 +14,16 @@ class Rails::InfoController < Rails::ApplicationController # :nodoc:
end end
def properties def properties
@info = Rails::Info.to_html respond_to do |format|
@page_title = "Properties" format.html do
@info = Rails::Info.to_html
@page_title = "Properties"
end
format.json do
render json: Rails::Info.to_json
end
end
end end
def routes def routes

View file

@ -50,6 +50,11 @@ class InfoControllerTest < ActionController::TestCase
assert_select "table" assert_select "table"
end end
test "info controller renders json with properties" do
get :properties, format: :json
assert_equal Rails::Info.to_json, response.body
end
test "info controller renders with routes" do test "info controller renders with routes" do
get :routes get :routes
assert_response :success assert_response :success

View file

@ -43,6 +43,18 @@ class InfoTest < ActiveSupport::TestCase
end end
end end
def test_json_includes_middleware
Rails::Info.module_eval do
property "Middleware", ["Rack::Lock", "Rack::Static"]
end
hash = JSON.parse(Rails::Info.to_json)
assert_includes hash.keys, "Middleware"
properties.value_for("Middleware").each do |value|
assert_includes hash["Middleware"], value
end
end
private private
def properties def properties
Rails::Info.properties Rails::Info.properties