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:
commit
8eaffe7e89
5 changed files with 37 additions and 2 deletions
|
@ -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.
|
||||||
|
|
|
@ -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.
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue