Skip to content

Commit 4b15530

Browse files
committed
headers ending in "id" are displayed correctly
1 parent 93c88c5 commit 4b15530

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/rspec_api_documentation/headers.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ def env_to_headers(env)
88
# HTTP_ACCEPT_CHARSET => Accept-Charset
99
if key =~ /^(HTTP_|CONTENT_TYPE)/
1010
header = key.gsub(/^HTTP_/, '').titleize.split.join("-")
11+
header.concat('-Id') if key.scan(/_ID\Z/).any?
1112
headers[header] = value
1213
end
1314
end

spec/http_test_client_spec.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,14 @@
6262

6363
describe "#request_headers" do
6464
before do
65-
test_client.get "/", {}, { "Accept" => "application/json", "Content-Type" => "application/json" }
65+
test_client.get "/", {}, { "Accept" => "application/json", "Content-Type" => "application/json", "User-Id" => "1" }
6666
end
6767

6868
it "should contain all the headers" do
6969
expect(test_client.request_headers).to eq({
7070
"Accept" => "application/json",
71-
"Content-Type" => "application/json"
71+
"Content-Type" => "application/json",
72+
"User-Id" => "1"
7273
})
7374
end
7475
end

0 commit comments

Comments
 (0)