Skip to content

Commit 690e39b

Browse files
committed
fix: correct all content types that were application/json to application/hal+json
1 parent a4ce4c2 commit 690e39b

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

lib/pact_broker/api/resources/base_resource.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ def pact_params
9696
end
9797

9898
def set_json_error_message message
99-
response.headers['Content-Type'] = 'application/json;charset=utf-8'
99+
response.headers['Content-Type'] = 'application/hal+json;charset=utf-8'
100100
response.body = {error: message}.to_json
101101
end
102102

103103
def set_json_validation_error_messages errors
104-
response.headers['Content-Type'] = 'application/json;charset=utf-8'
104+
response.headers['Content-Type'] = 'application/hal+json;charset=utf-8'
105105
response.body = {errors: errors}.to_json
106106
end
107107

@@ -128,7 +128,7 @@ def invalid_json?
128128
rescue StandardError => e
129129
logger.error "Error parsing JSON #{e} - #{request_body}"
130130
set_json_error_message "Error parsing JSON - #{e.message}"
131-
response.headers['Content-Type'] = 'application/json;charset=utf-8'
131+
response.headers['Content-Type'] = 'application/hal+json;charset=utf-8'
132132
true
133133
end
134134
end

lib/pact_broker/api/resources/pact_webhooks.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def validation_errors? webhook
3838
errors = webhook_service.errors(webhook)
3939

4040
unless errors.empty?
41-
response.headers['Content-Type'] = 'application/json;charset=utf-8'
41+
response.headers['Content-Type'] = 'application/hal+json;charset=utf-8'
4242
response.body = { errors: errors.messages }.to_json
4343
end
4444

spec/features/create_webhook_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
it "returns a JSON content type" do
2626
subject
27-
expect(last_response.headers['Content-Type']).to eq 'application/json;charset=utf-8'
27+
expect(last_response.headers['Content-Type']).to eq 'application/hal+json;charset=utf-8'
2828
end
2929

3030
it "returns the validation errors" do

spec/lib/pact_broker/api/resources/pact_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ module Resources
7676
end
7777

7878
it "returns a JSON content type" do
79-
expect(response.headers['Content-Type']).to eq "application/json;charset=utf-8"
79+
expect(response.headers['Content-Type']).to eq "application/hal+json;charset=utf-8"
8080
end
8181

8282
it "returns an error message" do

spec/lib/pact_broker/api/resources/pact_webhooks_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ module Resources
9393

9494
it "returns a JSON content type" do
9595
subject
96-
expect(last_response.headers['Content-Type']).to eq 'application/json;charset=utf-8'
96+
expect(last_response.headers['Content-Type']).to eq 'application/hal+json;charset=utf-8'
9797
end
9898

9999
it "returns an error message" do
@@ -111,7 +111,7 @@ module Resources
111111

112112
it "returns a JSON content type" do
113113
subject
114-
expect(last_response.headers['Content-Type']).to eq 'application/json;charset=utf-8'
114+
expect(last_response.headers['Content-Type']).to eq 'application/hal+json;charset=utf-8'
115115
end
116116

117117
it "returns an error message" do
@@ -132,7 +132,7 @@ module Resources
132132

133133
it "returns a JSON content type" do
134134
subject
135-
expect(last_response.headers['Content-Type']).to eq 'application/json;charset=utf-8'
135+
expect(last_response.headers['Content-Type']).to eq 'application/hal+json;charset=utf-8'
136136
end
137137

138138
it "returns the validation errors" do

spec/support/shared_examples_for_responses.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@
2424

2525
RSpec::Matchers.define :be_a_json_response do
2626
match do | actual |
27-
expect(actual.headers['Content-Type']).to eq 'application/json;charset=utf-8'
27+
expect(actual.headers['Content-Type']).to eq 'application/hal+json;charset=utf-8'
2828
end
2929
end
3030

3131
RSpec::Matchers.define :be_a_json_error_response do | message |
3232
match do | actual |
3333
expect(actual.status).to be 400
34-
expect(actual.headers['Content-Type']).to eq 'application/json;charset=utf-8'
34+
expect(actual.headers['Content-Type']).to eq 'application/hal+json;charset=utf-8'
3535
expect(actual.body).to include message
3636
end
3737
end

0 commit comments

Comments
 (0)