diff --git a/Gemfile.lock b/Gemfile.lock index e7366a614d..51e57e246d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -258,17 +258,15 @@ GEM rspec (>= 2.99.0, < 4.0) hashdiff (1.0.1) hashie (4.1.0) - http (4.4.1) - addressable (~> 2.3) + http (5.0.4) + addressable (~> 2.8) http-cookie (~> 1.0) http-form_data (~> 2.2) - http-parser (~> 1.2.0) + llhttp-ffi (~> 0.4.0) http-accept (1.7.0) - http-cookie (1.0.3) + http-cookie (1.0.4) domain_name (~> 0.5) http-form_data (2.3.0) - http-parser (1.2.1) - ffi-compiler (>= 1.0, < 2.0) http_accept_language (2.1.1) i18n (1.8.10) concurrent-ruby (~> 1.0) @@ -301,6 +299,9 @@ GEM rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) ruby_dep (~> 1.2) + llhttp-ffi (0.4.0) + ffi-compiler (~> 1.0) + rake (~> 13.0) lodash-rails (4.17.15) railties (>= 3.1) lograge (0.11.2) @@ -593,7 +594,7 @@ GEM execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext - unf_ext (0.0.7.7) + unf_ext (0.0.8) unicode-display_width (2.0.0) uuidtools (2.1.5) view_component (2.24.0) diff --git a/app/services/exotel_api_service.rb b/app/services/exotel_api_service.rb index 2715f00510..3e1ee26c54 100644 --- a/app/services/exotel_api_service.rb +++ b/app/services/exotel_api_service.rb @@ -78,7 +78,7 @@ def execute_post(url, data) def parse_response(response) return unless response.status.ok? - JSON.parse(response, symbolize_names: true) + response.parse(:json).deep_symbolize_keys end def base_uri diff --git a/spec/jobs/automatic_phone_number_whitelisting_worker_spec.rb b/spec/jobs/automatic_phone_number_whitelisting_worker_spec.rb index 38fac4c686..7ca4c17bb2 100644 --- a/spec/jobs/automatic_phone_number_whitelisting_worker_spec.rb +++ b/spec/jobs/automatic_phone_number_whitelisting_worker_spec.rb @@ -21,7 +21,7 @@ "Connection" => "close", "Host" => "api.exotel.com", "Content-Type" => "application/x-www-form-urlencoded", - "User-Agent" => "http.rb/4.4.1" + "User-Agent" => "http.rb/#{HTTP::VERSION}" } end let!(:stub) do diff --git a/spec/jobs/update_phone_number_details_worker_spec.rb b/spec/jobs/update_phone_number_details_worker_spec.rb index d1bb579211..8d1c3daac4 100644 --- a/spec/jobs/update_phone_number_details_worker_spec.rb +++ b/spec/jobs/update_phone_number_details_worker_spec.rb @@ -16,7 +16,7 @@ "Authorization" => "Basic #{auth_token}", "Connection" => "close", "Host" => "api.exotel.com", - "User-Agent" => "http.rb/4.4.1" + "User-Agent" => "http.rb/#{HTTP::VERSION}" } end diff --git a/spec/services/exotel_api_service_spec.rb b/spec/services/exotel_api_service_spec.rb index 18a272ea11..7280c2b1b4 100644 --- a/spec/services/exotel_api_service_spec.rb +++ b/spec/services/exotel_api_service_spec.rb @@ -10,10 +10,16 @@ "Authorization" => "Basic #{auth_token}", "Connection" => "close", "Host" => "api.exotel.com", - "User-Agent" => "http.rb/4.4.1" + "User-Agent" => "http.rb/#{HTTP::VERSION}" } end + around do |example| + WebMock.disallow_net_connect! + example.run + WebMock.allow_net_connect! + end + describe "#call_details" do let!(:call_details_200) { File.read("spec/support/fixtures/call_details_200.json") } let!(:call_details_400) { File.read("spec/support/fixtures/call_details_400.json") } @@ -27,7 +33,7 @@ "Authorization" => "Basic #{auth_token}", "Connection" => "close", "Host" => "api.exotel.com", - "User-Agent" => "http.rb/4.4.1" + "User-Agent" => "http.rb/#{HTTP::VERSION}" } end @@ -35,10 +41,11 @@ stub_request(:get, request_url).with(headers: request_headers).to_return(status: 200, body: call_details_200, headers: {}) + response = described_class.new(sid, token).call_details(call_sid) - expected_call_details_response = described_class.new(sid, token).call_details(call_sid) - - expect(expected_call_details_response[:Call].keys).to eq(%i[Sid + expect(response[:Call][:From]).to eq("09663127355") + expect(response[:Call][:To]).to eq("01930483621") + expect(response[:Call].keys).to eq(%i[Sid ParentCallSid DateCreated DateUpdated