提交 a0580e97 编写于 作者: R Rafael Mendonça França

Merge pull request #19055 from ianks/model_name.to_json

activemodel: make .model_name json encodable
......@@ -130,7 +130,7 @@ class Name
#
# Equivalent to +to_s+.
delegate :==, :===, :<=>, :=~, :"!~", :eql?, :to_s,
:to_str, to: :name
:to_str, :as_json, to: :name
# Returns a new ActiveModel::Name instance. By default, the +namespace+
# and +name+ option will take the namespace and name of the given class
......
......@@ -195,4 +195,8 @@ def @contact.as_json(options = {}); super(options.merge(only: [:name])); end
assert_no_match %r{"awesome":}, json
assert_no_match %r{"preferences":}, json
end
test "Class.model_name should be json encodable" do
assert_match %r{"Contact"}, Contact.model_name.to_json
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册