show files attachments instead of file infos in API for acq.media release
This commit is contained in:
@@ -45,13 +45,13 @@ class Api::ReleasesController < Api::ApiController
|
|||||||
if model_name == "acquired_media_release"
|
if model_name == "acquired_media_release"
|
||||||
mapping = {
|
mapping = {
|
||||||
"#{model_name.camelize}": SerializableAcquiredMediaRelease,
|
"#{model_name.camelize}": SerializableAcquiredMediaRelease,
|
||||||
FileInfo: SerializableFileInfo
|
"ActiveStorage::Attachment".to_sym => ActiveStorage::SerializableAttachment,
|
||||||
}
|
}
|
||||||
|
|
||||||
render jsonapi: release,
|
render jsonapi: release,
|
||||||
status: status,
|
status: status,
|
||||||
class: mapping,
|
class: mapping,
|
||||||
include: [:file_infos]
|
include: [:files]
|
||||||
else
|
else
|
||||||
mapping = {
|
mapping = {
|
||||||
"#{model_name.camelize}": show_serializable,
|
"#{model_name.camelize}": show_serializable,
|
||||||
|
|||||||
@@ -8,13 +8,13 @@ class SerializableAcquiredMediaRelease < JSONAPI::Serializable::Resource
|
|||||||
:applicable_medium_id, :applicable_medium_text, :territory_id, :territory_text, :term_id, :term_text,
|
:applicable_medium_id, :applicable_medium_text, :territory_id, :territory_text, :term_id, :term_text,
|
||||||
:restriction_id, :restriction_text, :categories, :description, :tag_list
|
:restriction_id, :restriction_text, :categories, :description, :tag_list
|
||||||
|
|
||||||
has_many :file_infos do
|
has_many :files do
|
||||||
data do
|
data do
|
||||||
@object.file_infos
|
@object.files
|
||||||
end
|
end
|
||||||
|
|
||||||
meta do
|
meta do
|
||||||
{ count: @object.file_infos.size }
|
{ count: @object.files.size }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -30,6 +30,16 @@ RSpec.describe Api::AcquiredMediaReleasesController, type: :controller do
|
|||||||
|
|
||||||
expect(response).to be_successful
|
expect(response).to be_successful
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'contains files attachment data' do
|
||||||
|
tested_release = create(:acquired_media_release, name: 'ct1', project_id: project.id)
|
||||||
|
|
||||||
|
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 /files/
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#create' do
|
describe '#create' do
|
||||||
|
|||||||
Reference in New Issue
Block a user