Skip to content

Commit c788a47

Browse files
committed
Merge pull request #1222 from stjhimy/strict_spec
Add spec for strict request with multiple accept headers
2 parents 9873491 + 27b0f56 commit c788a47

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

spec/grape/middleware/versioner/header_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,16 @@
224224
end
225225
end
226226

227+
it 'fails with 406 Not Acceptable if header contains a single invalid accept' do
228+
expect { subject.call('HTTP_ACCEPT' => 'application/json;application/vnd.vendor-v1+json').first }
229+
.to raise_exception do |exception|
230+
expect(exception).to be_a(Grape::Exceptions::InvalidAcceptHeader)
231+
expect(exception.headers).to eql({})
232+
expect(exception.status).to eql 406
233+
expect(exception.message).to include('API vendor or version not found.')
234+
end
235+
end
236+
227237
it 'succeeds if proper header is set' do
228238
expect(subject.call('HTTP_ACCEPT' => 'application/vnd.vendor-v1+json').first).to eq(200)
229239
end

0 commit comments

Comments
 (0)