You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
851 B

  1. require 'rails_helper'
  2. RSpec.describe HandleBadEncodingMiddleware do
  3. let(:app) { double() }
  4. let(:middleware) { HandleBadEncodingMiddleware.new(app) }
  5. it "request with query string is unchanged" do
  6. expect(app).to receive(:call).with("PATH" => "/some/path", "QUERY_STRING" => "name=fred")
  7. middleware.call("PATH" => "/some/path", "QUERY_STRING" => "name=fred")
  8. end
  9. it "request with no query string is unchanged" do
  10. expect(app).to receive(:call).with("PATH" => "/some/path")
  11. middleware.call("PATH" => "/some/path")
  12. end
  13. it "request with invalid encoding in query string drops query string" do
  14. expect(app).to receive(:call).with("QUERY_STRING" => "", "PATH" => "/some/path")
  15. middleware.call("QUERY_STRING" => "q=%2Fsearch%2Fall%Forder%3Ddescending%26page%3D5%26sort%3Dcreated_at", "PATH" => "/some/path")
  16. end
  17. end