committee 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,12 +15,10 @@ module Committee::Middleware
15
15
  Committee::RequestValidator.new.call(link, env[@params_key])
16
16
  end
17
17
  @app.call(env)
18
- rescue Committee::BadRequest
18
+ rescue Committee::BadRequest, Committee::InvalidRequest
19
19
  render_error(400, :bad_request, $!.message)
20
- rescue Committee::Error
21
- render_error(422, :invalid_params, $!.message)
22
20
  rescue MultiJson::LoadError
23
- render_error(400, :invalid_params, "Request body wasn't valid JSON.")
21
+ render_error(400, :bad_request, "Request body wasn't valid JSON.")
24
22
  end
25
23
  end
26
24
  end
@@ -17,6 +17,17 @@ describe Committee::Middleware::RequestValidation do
17
17
  assert_equal 200, last_response.status
18
18
  end
19
19
 
20
+ it "detects an invalid request" do
21
+ @app = new_rack_app
22
+ header "Content-Type", "application/json"
23
+ params = {
24
+ "name" => 1
25
+ }
26
+ post "/apps", MultiJson.encode(params)
27
+ assert_equal 400, last_response.status
28
+ assert_match /invalid request/i, last_response.body
29
+ end
30
+
20
31
  it "detects an invalid Content-Type" do
21
32
  @app = new_rack_app
22
33
  header "Content-Type", "application/whats-this"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: committee
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-05-22 00:00:00.000000000 Z
13
+ date: 2014-05-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: json_schema