Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

594 bulk upload issue/replace rest client with httparty #1616

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ group :test do
gem "govuk_test"
gem "webmock"
end

gem "httparty", "~> 0.21.0"
4 changes: 4 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ GEM
http-accept (1.7.0)
http-cookie (1.0.5)
domain_name (~> 0.5)
httparty (0.21.0)
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
io-console (0.6.0)
Expand Down Expand Up @@ -703,6 +706,7 @@ DEPENDENCIES
govuk_sidekiq
govuk_test
hashdiff
httparty (~> 0.21.0)
jquery-ui-rails
kaminari
pg
Expand Down
2 changes: 1 addition & 1 deletion app/lib/remote_csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ def sheet_data
end

def response
RestClient.get @csv_url
HTTParty.get @csv_url
end
end
9 changes: 7 additions & 2 deletions app/services/bulk_tagging/fetch_remote_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def call
response
process_spreadsheet
errors
rescue RestClient::Exception => e
rescue StandardError => e
GovukError.notify(e)
[spreadsheet_download_error]
end
Expand Down Expand Up @@ -57,7 +57,12 @@ def spreadsheet_download_error
end

def response
@response ||= RestClient.get tagging_spreadsheet.url
@response = HTTParty.get tagging_spreadsheet.url
if @response.code == 200
@response
else
raise StandardError, "error code from httparty"
end
end

def sheet_data
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/remote_csv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@

it "raises an error when the URI is invalid" do
expect { described_class.new("not a URL").rows_with_headers }
.to raise_error RemoteCsv::ParsingError, 'URI::InvalidURIError: bad URI(is not URI?): "http://not a URL"'
.to raise_error RemoteCsv::ParsingError, 'URI::InvalidURIError: bad URI(is not URI?): "not a URL"'
end

it "raises an error when the connection failed" do
stub_request(:get, csv_url).to_timeout

expect { described_class.new(csv_url).rows_with_headers }
.to raise_error RemoteCsv::ParsingError, "RestClient::Exceptions::OpenTimeout: Timed out connecting to server"
.to raise_error RemoteCsv::ParsingError, "Net::OpenTimeout: execution expired"
end

it "raises an error when the CSV is malformed" do
Expand Down
Loading