This repository was archived by the owner on Jul 8, 2020. It is now read-only.
File tree 3 files changed +21
-1
lines changed
3 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ module.exports = function (bookshelf) {
28
28
29
29
organization : function ( ) {
30
30
return this . belongsTo ( 'Organization' ) ;
31
+ } ,
32
+
33
+ domain : function ( ) {
34
+ return this . belongsTo ( 'Domain' ) ;
31
35
}
32
36
33
37
} ) ) ;
Original file line number Diff line number Diff line change @@ -21,14 +21,20 @@ module.exports = function (server) {
21
21
handler : function ( request , reply ) {
22
22
Campaign
23
23
. where ( { id : request . params . id } )
24
- . fetch ( { require : true } )
24
+ . fetch ( {
25
+ require : true ,
26
+ withRelated : request . query . expand
27
+ } )
25
28
. then ( reply )
26
29
. catch ( reply ) ;
27
30
} ,
28
31
config : {
29
32
validate : {
30
33
params : {
31
34
id : Joi . string ( ) . guid ( )
35
+ } ,
36
+ query : {
37
+ expand : Joi . array ( ) . includes ( Joi . string ( ) )
32
38
}
33
39
} ,
34
40
cache : {
Original file line number Diff line number Diff line change @@ -34,6 +34,16 @@ module.exports = function (server) {
34
34
} ) ;
35
35
} ) ;
36
36
37
+ it ( 'can get the campaign with the domain' , function ( ) {
38
+ return server . injectThen ( '/campaigns/' + campaign . id + '?expand[]=domain' )
39
+ . then ( function ( response ) {
40
+ expect ( response . statusCode ) . to . equal ( 200 ) ;
41
+ expect ( JSON . parse ( response . payload ) )
42
+ . to . have . deep . property ( 'domain.id' )
43
+ . with . length ( 36 ) ;
44
+ } ) ;
45
+ } ) ;
46
+
37
47
it ( 'responds with a 400 for non-uuid' , function ( ) {
38
48
return server . injectThen ( '/campaigns/1' )
39
49
. then ( function ( response ) {
You can’t perform that action at this time.
0 commit comments