From 213265a5d00c9b48f005b0bca9fee232421c58af Mon Sep 17 00:00:00 2001 From: Adam Townsend Date: Thu, 12 Oct 2023 23:30:47 -0700 Subject: [PATCH] added test for submitting with the wrong content type header --- spec/create_spec.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/spec/create_spec.rb b/spec/create_spec.rb index 0c2afd3..4ef0610 100644 --- a/spec/create_spec.rb +++ b/spec/create_spec.rb @@ -88,4 +88,14 @@ describe "Submit API request to create new link" do response_json = JSON.parse(last_response.body) expect(response_json['message']).to eq('url does not resolve') end + + it "should return with a 400 status and 'not a valid json request' message when a request is made with the wrong content type header" do + data = { + url: 'http://google.com' + } + post('/links', data.to_json) + expect(last_response.status).to eq(400) + response_json = JSON.parse(last_response.body) + expect(response_json['message']).to eq('not a valid json request') + end end