From f1d56ceacb1da7d8d0cf9f293b2c25995e2bed68 Mon Sep 17 00:00:00 2001 From: Mason Ballengee Date: Mon, 26 Feb 2024 15:10:16 -0500 Subject: [PATCH] Add collection_id to media_object JSON response --- app/models/concerns/media_object_behavior.rb | 1 + spec/controllers/media_objects_controller_spec.rb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/models/concerns/media_object_behavior.rb b/app/models/concerns/media_object_behavior.rb index 26d03f907f..498522fbae 100644 --- a/app/models/concerns/media_object_behavior.rb +++ b/app/models/concerns/media_object_behavior.rb @@ -19,6 +19,7 @@ def as_json(options={}) id: id, title: title, collection: collection.name, + collection_id: collection.id, unit: collection.unit, main_contributors: creator, publication_date: date_created, diff --git a/spec/controllers/media_objects_controller_spec.rb b/spec/controllers/media_objects_controller_spec.rb index 92d03f4069..74ee109890 100644 --- a/spec/controllers/media_objects_controller_spec.rb +++ b/spec/controllers/media_objects_controller_spec.rb @@ -1193,6 +1193,7 @@ expect(json['id']).to eq(media_object.id) expect(json['title']).to eq(media_object.title) expect(json['collection']).to eq(media_object.collection.name) + expect(json['collection_id']).to eq(media_object.collection.id) expect(json['main_contributors']).to eq(media_object.creator) expect(json['publication_date']).to eq(media_object.date_created) expect(json['published_by']).to eq(media_object.avalon_publisher)