show both, files and file infos in acq.media API response

This commit is contained in:
Bilal
2020-09-01 05:23:32 +03:00
parent 9a1f49f0dc
commit 09f4e4d454
3 changed files with 14 additions and 3 deletions

View File

@@ -45,13 +45,14 @@ class Api::ReleasesController < Api::ApiController
if model_name == "acquired_media_release"
mapping = {
"#{model_name.camelize}": SerializableAcquiredMediaRelease,
FileInfo: SerializableFileInfo,
"ActiveStorage::Attachment".to_sym => ActiveStorage::SerializableAttachment,
}
render jsonapi: release,
status: status,
class: mapping,
include: [:files]
include: [:files, :file_infos]
else
mapping = {
"#{model_name.camelize}": show_serializable,

View File

@@ -7,7 +7,17 @@ class SerializableAcquiredMediaRelease < JSONAPI::Serializable::Resource
:person_title, :person_company, :created_at, :updated_at, :collection_uid, :territory_old, :term_old,
:applicable_medium_id, :applicable_medium_text, :territory_id, :territory_text, :term_id, :term_text,
:restriction_id, :restriction_text, :categories, :description, :tag_list
has_many :file_infos do
data do
@object.file_infos
end
meta do
{ count: @object.file_infos.size }
end
end
has_many :files do
data do
@object.files

View File

@@ -37,7 +37,7 @@ RSpec.describe Api::AcquiredMediaReleasesController, type: :controller do
sign_in_to_api(current_user)
get :show, params: { id: tested_release.id }
expect(response.body).not_to match /file_infos/
expect(response.body).to match /file_infos/
expect(response.body).to match /files/
end
end