Compare commits

..

2 Commits

Author SHA1 Message Date
Bilal
b03026f19c rebase 2020-09-01 21:56:08 +03:00
Bilal
3cbff1b0f1 structure 2020-09-01 21:56:08 +03:00
4 changed files with 8 additions and 26 deletions

View File

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

View File

@@ -7,7 +7,7 @@ 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
@@ -17,14 +17,4 @@ class SerializableAcquiredMediaRelease < JSONAPI::Serializable::Resource
{ count: @object.file_infos.size }
end
end
has_many :files do
data do
@object.files
end
meta do
{ count: @object.files.size }
end
end
end

View File

@@ -542,9 +542,9 @@ CREATE TABLE public.broadcast_recordings (
updated_at timestamp(6) without time zone NOT NULL,
duration double precision,
hidden boolean DEFAULT false,
starred boolean DEFAULT false,
name character varying,
description text
description text,
starred boolean DEFAULT false
);
@@ -1492,6 +1492,7 @@ CREATE TABLE public.settings (
--
CREATE SEQUENCE public.settings_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1527,6 +1528,7 @@ CREATE TABLE public.taggings (
--
CREATE SEQUENCE public.taggings_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1557,6 +1559,7 @@ CREATE TABLE public.tags (
--
CREATE SEQUENCE public.tags_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE

View File

@@ -30,16 +30,6 @@ RSpec.describe Api::AcquiredMediaReleasesController, type: :controller do
expect(response).to be_successful
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).to match /file_infos/
expect(response.body).to match /files/
end
end
describe '#create' do