File tree 2 files changed +35
-0
lines changed
2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1
1
module Api
2
2
class PicturesController < BaseController
3
+ before_action :set_additional_attributes , :only => [ :index , :show ]
4
+
3
5
def create_resource ( _type , _id , data )
4
6
Picture . create_from_base64 ( data )
5
7
rescue => err
6
8
raise BadRequestError , "Failed to create Picture - #{ err } "
7
9
end
10
+
11
+ private
12
+
13
+ def set_additional_attributes
14
+ @additional_attributes = %w( image_href extension )
15
+ end
8
16
end
9
17
end
Original file line number Diff line number Diff line change @@ -62,6 +62,33 @@ def expect_result_to_include_picture_href(source_id)
62
62
end
63
63
end
64
64
65
+ describe 'GET /api/pictures' do
66
+ it 'returns image_href, extension when resources are expanded' do
67
+ api_basic_authorize
68
+
69
+ expected = {
70
+ 'resources' => [
71
+ a_hash_including ( 'image_href' => a_string_including ( picture . image_href ) , 'extension' => picture . extension )
72
+ ]
73
+ }
74
+ get ( api_pictures_url , :params => { :expand => 'resources' } )
75
+
76
+ expect ( response ) . to have_http_status ( :ok )
77
+ expect ( response . parsed_body ) . to include ( expected )
78
+ end
79
+ end
80
+
81
+ describe 'GET /api/pictures/:id' do
82
+ it 'returns image_href, extension by default' do
83
+ api_basic_authorize
84
+
85
+ get ( api_picture_url ( nil , picture ) )
86
+
87
+ expect ( response ) . to have_http_status ( :ok )
88
+ expect ( response . parsed_body ) . to include ( 'image_href' => a_string_including ( picture . image_href ) , 'extension' => picture . extension )
89
+ end
90
+ end
91
+
65
92
describe 'POST /api/pictures' do
66
93
# Valid base64 image
67
94
let ( :content ) do
You can’t perform that action at this time.
0 commit comments