File tree Expand file tree Collapse file tree 2 files changed +27
-2
lines changed
lib/rspec_api_documentation Expand file tree Collapse file tree 2 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,7 @@ def env_to_headers(env)
77 env . each do |key , value |
88 # HTTP_ACCEPT_CHARSET => Accept-Charset
99 if key =~ /^(HTTP_|CONTENT_TYPE)/
10- header = key . gsub ( /^HTTP_/ , '' ) . titleize . split . join ( "-" )
11- header . concat ( '-Id' ) if key . scan ( /_ID\Z / ) . any?
10+ header = key . gsub ( /^HTTP_/ , '' ) . split ( '_' ) . map { |s | s . titleize } . join ( "-" )
1211 headers [ header ] = value
1312 end
1413 end
Original file line number Diff line number Diff line change 1+ require 'spec_helper'
2+
3+ class FakeHeaderable
4+ include RspecApiDocumentation ::Headers
5+
6+ def public_env_to_headers ( env )
7+ env_to_headers ( env )
8+ end
9+ end
10+
11+ describe RspecApiDocumentation ::Headers do
12+ let ( :example ) { FakeHeaderable . new }
13+
14+ describe '#env_to_headers' do
15+ subject { example . public_env_to_headers ( env ) }
16+
17+ context 'When the env contains "CONTENT_TYPE"' do
18+ let ( :env ) { { "CONTENT_TYPE" => 'multipart/form-data' } }
19+
20+ it 'converts the header to "Content-Type"' do
21+ expect ( subject [ 'Content-Type' ] ) . to eq 'multipart/form-data'
22+ end
23+ end
24+ end
25+
26+ end
You can’t perform that action at this time.
0 commit comments