File tree 2 files changed +33
-9
lines changed
2 files changed +33
-9
lines changed Original file line number Diff line number Diff line change @@ -19,4 +19,13 @@ export default class DocumentSerializer extends LocalizedSerializer {
19
19
20
20
return formData ;
21
21
}
22
+
23
+ serialize ( ...args ) {
24
+ const json = super . serialize ( ...args ) ;
25
+
26
+ // delete content attribute, as it is only needed for POST
27
+ delete json . data . attributes . content ;
28
+
29
+ return json ;
30
+ }
22
31
}
Original file line number Diff line number Diff line change @@ -4,19 +4,34 @@ import { module, test } from "qunit";
4
4
module ( "Unit | Serializer | document" , function ( hooks ) {
5
5
setupTest ( hooks ) ;
6
6
7
- test ( "it exists" , function ( assert ) {
8
- const store = this . owner . lookup ( "service:store" ) ;
9
- const serializer = store . serializerFor ( "document" ) ;
10
-
11
- assert . ok ( serializer ) ;
12
- } ) ;
13
-
14
7
test ( "it serializes records" , function ( assert ) {
15
8
const store = this . owner . lookup ( "service:store" ) ;
16
- const record = store . createRecord ( "document" , { } ) ;
9
+ const record = store . createRecord ( "document" , {
10
+ title : { en : "Foo" } ,
11
+ content : "test" ,
12
+ } ) ;
17
13
18
14
const serializedRecord = record . serialize ( ) ;
19
15
20
- assert . ok ( serializedRecord ) ;
16
+ // content attribute should be removed
17
+ assert . deepEqual ( serializedRecord , {
18
+ data : {
19
+ attributes : {
20
+ "created-at" : undefined ,
21
+ "created-by-group" : undefined ,
22
+ "created-by-user" : undefined ,
23
+ date : undefined ,
24
+ description : { } ,
25
+ metainfo : undefined ,
26
+ "modified-at" : undefined ,
27
+ "modified-by-group" : undefined ,
28
+ "modified-by-user" : undefined ,
29
+ title : {
30
+ en : "Foo" ,
31
+ } ,
32
+ } ,
33
+ type : "documents" ,
34
+ } ,
35
+ } ) ;
21
36
} ) ;
22
37
} ) ;
You can’t perform that action at this time.
0 commit comments