From 7a7ba8e02a66cfce5f185c4f7588c823d2c938e6 Mon Sep 17 00:00:00 2001 From: Martha Thompson <437455+MothOnMars@users.noreply.github.com> Date: Mon, 12 Aug 2019 10:12:31 -0400 Subject: [PATCH] SRCH-75 upgrade to ruby 2.5.5 (#332) - bump scrypt - add missing spec for RejectInvalidRequestUri - remove redundant Dockerize installation for CircleCi --- .circleci/config.yml | 2 +- .circleci/images/primary/Dockerfile | 9 +-------- .ruby-version | 2 +- README.markdown | 8 +++++--- app/controllers/sites/query_downloads_controller.rb | 2 +- .../middlewares/reject_invalid_request_uri_spec.rb | 13 +++++++++++-- 6 files changed, 20 insertions(+), 16 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 0370a3ad5e..21d0f4b428 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -10,7 +10,7 @@ executors: docker: # using custom image, see .circleci/images/primary/Dockerfile - - image: searchgov/circleci:20190320 + - image: searchgov/circleci:20190417 environment: RAILS_ENV: test diff --git a/.circleci/images/primary/Dockerfile b/.circleci/images/primary/Dockerfile index 9cdc8b3986..f2b9020ec0 100644 --- a/.circleci/images/primary/Dockerfile +++ b/.circleci/images/primary/Dockerfile @@ -1,5 +1,5 @@ # using legacy image for phantomjs -FROM circleci/ruby:2.3.8-browsers-legacy +FROM circleci/ruby:2.5.5-browsers-legacy USER root @@ -8,11 +8,4 @@ RUN apt-get update && apt-get install -y \ libprotobuf-dev \ protobuf-compiler -# Install Dockerize to ensure services are started before test runs -# https://support.circleci.com/hc/en-us/articles/360006773953-Race-Conditions-Wait-For-Database -ENV DOCKERIZE_VERSION v0.6.1 -RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ - && tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \ - && rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz - USER circleci diff --git a/.ruby-version b/.ruby-version index a9eea9a34b..80d02f910b 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -ruby-2.3.8 +ruby-2.5.5 diff --git a/README.markdown b/README.markdown index b5eccf2f2c..52e09a4864 100644 --- a/README.markdown +++ b/README.markdown @@ -12,11 +12,13 @@ working development environment for Rails up and running, including the database ## Ruby -You will need Ruby 2.3.8 Verify that your path points to the correct version of Ruby: +You will need the version of Ruby specified in `.ruby-version`. Verify that your path points to the correct version of Ruby: - devbox:usasearch $ ruby -v - ruby 2.3.8p459 (2018-10-18 revision 65136) [x86_64-darwin16] + +You should see output similar to the following: + + ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-darwin18] ## Packages diff --git a/app/controllers/sites/query_downloads_controller.rb b/app/controllers/sites/query_downloads_controller.rb index 525d601765..d43b3838b5 100644 --- a/app/controllers/sites/query_downloads_controller.rb +++ b/app/controllers/sites/query_downloads_controller.rb @@ -48,7 +48,7 @@ def top_queries def ctr(click_count, query_count) return '--' if click_count == 0 || query_count == 0 - sprintf("%.1f%", click_count.to_f * 100 / query_count) + sprintf('%.1f%%', click_count.to_f * 100 / query_count) end def date_range_top_n_query diff --git a/spec/lib/middlewares/reject_invalid_request_uri_spec.rb b/spec/lib/middlewares/reject_invalid_request_uri_spec.rb index 6cb8fb47a9..894a478607 100644 --- a/spec/lib/middlewares/reject_invalid_request_uri_spec.rb +++ b/spec/lib/middlewares/reject_invalid_request_uri_spec.rb @@ -6,10 +6,19 @@ let(:app) { double('app') } let(:middleware) { RejectInvalidRequestUri.new(app) } let(:env) { { 'REQUEST_URI' => "/search?query=\xC0" } } + let(:response) { middleware.call(env) } + let(:status) { response.first } - it 'should return with status 400' do - status, header, body = middleware.call env + it 'returns a 400 status' do expect(status).to eq(400) end + + context 'when invalid arguments are passed' do + before { allow(CGI).to receive(:unescape).and_raise(ArgumentError) } + + it 'returns a 400 status' do + expect(status).to eq(400) + end + end end end