Merge pull request #3025 from evazion/fix-xml-attrs

Fix #3024: strip '?' from API attributes
This commit is contained in:
Albert Yi
2017-05-08 12:59:57 -07:00
committed by GitHub
2 changed files with 13 additions and 0 deletions

View File

@@ -26,6 +26,11 @@ module Danbooru
super(options, &block)
end
def serializable_hash(*args)
hash = super(*args)
hash.transform_keys { |key| key.delete("?") }
end
protected
def hidden_attributes
[:uploader_ip_addr, :updater_ip_addr, :creator_ip_addr, :ip_addr]

View File

@@ -64,6 +64,14 @@ class UsersControllerTest < ActionController::TestCase
assert_response :success
assert_nil(json["last_logged_in_at"])
end
should "strip '?' from attributes" do
get :show, {id: @user.id, format: :xml}, {user_id: @user.id}
xml = Hash.from_xml(response.body)
assert_response :success
assert_equal(false, xml["user"]["can_upload"])
end
end
context "new action" do