File tree Expand file tree Collapse file tree 2 files changed +23
-3
lines changed
Expand file tree Collapse file tree 2 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,7 @@ def after
8484 encode_txt ( body )
8585 end
8686 end
87- headers [ 'Content-Type' ] = 'application/json'
87+ headers [ 'Content-Type' ] = content_types [ env [ 'api.format' ] ]
8888 Rack ::Response . new ( bodymap , status , headers ) . to_a
8989 end
9090
@@ -103,4 +103,4 @@ def encode_txt(object)
103103 end
104104 end
105105 end
106- end
106+ end
Original file line number Diff line number Diff line change @@ -84,4 +84,24 @@ def serializable_hash
8484 subject . env [ 'api.format' ] . should == :json
8585 end
8686 end
87- end
87+
88+ context 'Content-type' do
89+ it 'should be set for json' do
90+ _ , headers , _ = subject . call ( { 'PATH_INFO' => '/info.json' } )
91+ headers [ 'Content-type' ] . should == 'application/json'
92+ end
93+ it 'should be set for xml' do
94+ _ , headers , _ = subject . call ( { 'PATH_INFO' => '/info.xml' } )
95+ headers [ 'Content-type' ] . should == 'application/xml'
96+ end
97+ it 'should be set for txt' do
98+ _ , headers , _ = subject . call ( { 'PATH_INFO' => '/info.txt' } )
99+ headers [ 'Content-type' ] . should == 'text/plain'
100+ end
101+ it 'should be set for custom' do
102+ subject . options [ :content_types ] [ :custom ] = 'application/x-custom'
103+ _ , headers , _ = subject . call ( { 'PATH_INFO' => '/info.custom' } )
104+ headers [ 'Content-type' ] . should == 'application/x-custom'
105+ end
106+ end
107+ end
You can’t perform that action at this time.
0 commit comments