From 170a55474772c56998da29c0bc12b72d86f2c2db Mon Sep 17 00:00:00 2001 From: Alberto Aguirre Date: Sat, 17 Jun 2017 12:17:40 -0500 Subject: [PATCH 1/2] FIX: version check api.discourse.org server apparently does not like GET requests that have a port number in the headers Host entry Additionally fix the actual GET query; it should use query parameters not a body. --- lib/discourse_hub.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/discourse_hub.rb b/lib/discourse_hub.rb index a10f3a1b65b..73935e1acf3 100644 --- a/lib/discourse_hub.rb +++ b/lib/discourse_hub.rb @@ -42,8 +42,9 @@ module DiscourseHub def self.singular_action(action, rel_url, params={}) JSON.parse(Excon.send(action, "#{hub_base_url}#{rel_url}", - body: params.to_query, - headers: { 'Referer' => referer, 'Accept' => accepts.join(', ') } + headers: { 'Referer' => referer, 'Accept' => accepts.join(', ') }, + :query => params, + :omit_default_port => true ).body) end From b24bdc5b2095e450f254097aecc6e6ba90370851 Mon Sep 17 00:00:00 2001 From: Alberto Aguirre Date: Sun, 18 Jun 2017 14:40:28 -0500 Subject: [PATCH 2/2] FIX: discourse_hub_spec stub_request should include query params --- spec/components/discourse_hub_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/components/discourse_hub_spec.rb b/spec/components/discourse_hub_spec.rb index 22d9bfa5d25..a08b0856a18 100644 --- a/spec/components/discourse_hub_spec.rb +++ b/spec/components/discourse_hub_spec.rb @@ -7,6 +7,7 @@ describe DiscourseHub do hub_response = {'success' => 'OK', 'latest_version' => '0.8.1', 'critical_updates' => false} stub_request(:get, (ENV['HUB_BASE_URL'] || "http://local.hub:3000/api") + "/version_check"). + with(query: DiscourseHub.version_check_payload). to_return(status: 200, body: hub_response.to_json) expect(DiscourseHub.discourse_version_check).to eq(hub_response)