Skip to content

Commit d273d2c

Browse files
committed
fix(personality insights): Fix bug with content type to be accepted
1 parent af6b45b commit d273d2c

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

lib/ibm_watson/watson_service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def request(args)
123123
args[:json] = args[:data].merge(args[:json]) if args[:data].respond_to?(:merge)
124124
args[:json] = args[:data] if args[:json].empty? || (args[:data].instance_of?(String) && !args[:data].empty?)
125125
args[:json].delete_if { |_k, v| v.nil? } if args[:json].instance_of?(Hash)
126-
args[:headers]["Accept"] = "application/json" if args[:accept_json]
126+
args[:headers]["Accept"] = "application/json" if args[:accept_json] && args[:headers]["Accept"].nil?
127127
args[:headers]["Content-Type"] = "application/json" unless args[:headers].key?("Content-Type")
128128
args[:json] = args[:json].to_json if args[:json].instance_of?(Hash)
129129
args[:headers].delete_if { |_k, v| v.nil? } if args[:headers].instance_of?(Hash)

test/test_helper.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
File.basename(src_file.filename) == "version.rb"
1313
end
1414

15+
lib_proc = proc { |file| !file.filename.include?("service_extensions") }
16+
add_group "Services", "/lib/", &lib_proc
17+
add_group "Patches", "/lib/ibm_watson/service_extensions/"
1518
command_name "Minitest"
1619
end
1720
end

test/unit/test_personality_insights_v3.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def test_json_to_csv
105105
.with(
106106
body: personality_text,
107107
headers: {
108-
"Accept" => "application/json",
108+
"Accept" => "text/csv",
109109
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
110110
"Content-Type" => "application/json",
111111
"Host" => "gateway.watsonplatform.net"

test/unit/test_vcap_using_personality_insights.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def test_json_to_csv
8787
.with(
8888
body: personality_text,
8989
headers: {
90-
"Accept" => "application/json",
90+
"Accept" => "text/csv",
9191
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
9292
"Content-Type" => "application/json",
9393
"Host" => "gateway.watsonplatform.net"

0 commit comments

Comments
 (0)