[15-minute fix] Add created_at to listings API response (#14437)
* Add created_at to listings API response * Add created_at listing attribute to org controller
This commit is contained in:
parent
940241ac03
commit
231ce5d3cb
4 changed files with 10 additions and 2 deletions
|
|
@ -18,7 +18,7 @@ module Api
|
|||
# actual column name for the listing category, prefixed with classified_.
|
||||
ATTRIBUTES_FOR_SERIALIZATION = %i[
|
||||
id user_id organization_id title slug body_markdown cached_tag_list
|
||||
classified_listing_category_id processed_html published
|
||||
classified_listing_category_id processed_html published created_at
|
||||
].freeze
|
||||
private_constant :ATTRIBUTES_FOR_SERIALIZATION
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ module Api
|
|||
|
||||
LISTINGS_FOR_SERIALIZATION = %i[
|
||||
id user_id organization_id title slug body_markdown cached_tag_list
|
||||
classified_listing_category_id processed_html published
|
||||
classified_listing_category_id processed_html published created_at
|
||||
].freeze
|
||||
private_constant :LISTINGS_FOR_SERIALIZATION
|
||||
|
||||
|
|
|
|||
|
|
@ -14,3 +14,4 @@ json.extract!(
|
|||
json.listing_category_id listing.classified_listing_category_id
|
||||
json.tag_list listing.cached_tag_list
|
||||
json.tags listing.tag_list
|
||||
json.created_at utc_iso_timestamp(listing.created_at)
|
||||
|
|
|
|||
|
|
@ -106,6 +106,13 @@ RSpec.describe "Api::V0::Listings", type: :request do
|
|||
get api_listings_path
|
||||
expect(response.parsed_body.detect { |l| l["published"] == false }).to be_nil
|
||||
end
|
||||
|
||||
# Regression test for https://github.com/forem/forem/issues/14436
|
||||
it "includes the created at timestamp for listings" do
|
||||
get api_listings_path
|
||||
listing = response.parsed_body.first
|
||||
expect(listing["created_at"]).to match(/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /api/listings/category/:category" do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue