|
| 1 | +require 'spec_helper' |
| 2 | + |
| 3 | +RSpec.describe CatalogController, type: :controller do |
| 4 | + describe "bad params" do |
| 5 | + let (:facet_field) { "pub_date_si" } |
| 6 | + |
| 7 | + it "BadRequest without start param present" do |
| 8 | + expect { |
| 9 | + get :range_limit, params: { |
| 10 | + "range_field"=> facet_field, |
| 11 | + "range_start"=>"1931" |
| 12 | + } |
| 13 | + }.to raise_error(ActionController::BadRequest) |
| 14 | + end |
| 15 | + |
| 16 | + it "BadRequest without end param" do |
| 17 | + expect { |
| 18 | + get :range_limit, params: { |
| 19 | + "range_field"=> facet_field, |
| 20 | + "range_start"=>"1931" |
| 21 | + } |
| 22 | + }.to raise_error(ActionController::BadRequest) |
| 23 | + end |
| 24 | + |
| 25 | + it "BadRequest without either boundary" do |
| 26 | + expect { |
| 27 | + get :range_limit, params: { |
| 28 | + "range_field"=> facet_field, |
| 29 | + } |
| 30 | + }.to raise_error(ActionController::BadRequest) |
| 31 | + end |
| 32 | + |
| 33 | + it "NotFound without a range_field" do |
| 34 | + expect { |
| 35 | + get :range_limit, params: {} |
| 36 | + }.to raise_error(ActionController::RoutingError) |
| 37 | + end |
| 38 | + |
| 39 | + it "BadRequest if params out of order" do |
| 40 | + expect { |
| 41 | + get :range_limit, params: { |
| 42 | + "range_field"=> facet_field, |
| 43 | + "range_start"=>"1940", |
| 44 | + "range_end"=>"1930" |
| 45 | + } |
| 46 | + }.to raise_error(ActionController::BadRequest) |
| 47 | + end |
| 48 | + |
| 49 | + it "BadRequest if one of the params is an array" do |
| 50 | + expect { |
| 51 | + get :range_limit, params: { |
| 52 | + "range_field"=> facet_field, |
| 53 | + "range_start"=>"1931", |
| 54 | + "range_end"=>["1940"] |
| 55 | + } |
| 56 | + }.to raise_error(ActionController::BadRequest) |
| 57 | + end |
| 58 | + end |
| 59 | +end |
0 commit comments