From 35bfbc9c828d3a2de65e308623ad3252f394c6bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Fri, 24 Jan 2020 16:58:32 +0100 Subject: [PATCH] Return missing created_at field on reshares endpoint --- app/controllers/api/v1/reshares_controller.rb | 1 + lib/schemas/api_v1.json | 14 ++++++++++++++ spec/integration/api/reshares_controller_spec.rb | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/v1/reshares_controller.rb b/app/controllers/api/v1/reshares_controller.rb index 48f9edf81..8caca9e7e 100644 --- a/app/controllers/api/v1/reshares_controller.rb +++ b/app/controllers/api/v1/reshares_controller.rb @@ -25,6 +25,7 @@ module Api reshares_page[:data] = reshares_page[:data].map do |r| { guid: r.guid, + created_at: r.created_at, author: PersonPresenter.new(r.author).as_api_json } end diff --git a/lib/schemas/api_v1.json b/lib/schemas/api_v1.json index 30006d6ef..6faa4c04f 100644 --- a/lib/schemas/api_v1.json +++ b/lib/schemas/api_v1.json @@ -337,6 +337,20 @@ ] }, + "reshares": { + "type": "array", + "items": { + "type": "object", + "properties": { + "guid": { "$ref": "#/definitions/guid" }, + "created_at": { "$ref": "#/definitions/timestamp" }, + "author": { "$ref": "#/definitions/short_profile" } + }, + "required": ["guid", "created_at", "author"], + "additionalProperties": false + } + }, + "posts": { "type": "array", "items": { "$ref": "#/definitions/post" } diff --git a/spec/integration/api/reshares_controller_spec.rb b/spec/integration/api/reshares_controller_spec.rb index 5f3cd7c79..328426238 100644 --- a/spec/integration/api/reshares_controller_spec.rb +++ b/spec/integration/api/reshares_controller_spec.rb @@ -55,7 +55,7 @@ describe Api::V1::ResharesController do expect(reshare["guid"]).not_to be_nil confirm_person_format(reshare["author"], alice) - expect(reshares.to_json).to match_json_schema(:api_v1_schema) + expect(reshares.to_json).to match_json_schema(:api_v1_schema, fragment: "#/definitions/reshares") end it "succeeds but empty with private post it can see" do