committee 0.4.12 → 0.4.13

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.
@@ -17,7 +17,15 @@ module Committee::Middleware
17
17
  end
18
18
  if @call
19
19
  env["committee.response"] = data
20
- _, call_headers, _ = @app.call(env)
20
+ call_status, call_headers, call_body = @app.call(env)
21
+
22
+ # a committee.suppress signal initiates a direct pass through
23
+ if env["committee.suppress"] == true
24
+ return call_status, call_headers, call_body
25
+ end
26
+
27
+ # otherwise keep the headers and whatever data manipulations were
28
+ # made, and stub normally
21
29
  headers.merge!(call_headers)
22
30
  end
23
31
  status = link_schema["rel"] == "create" ? 201 : 200
@@ -29,6 +29,15 @@ describe Committee::Middleware::Stub do
29
29
  MultiJson.decode(last_response.headers["Committee-Response"])
30
30
  end
31
31
 
32
+ it "optionally returns the application's response" do
33
+ @app = new_rack_app(call: true, suppress: true)
34
+ get "/apps/heroku-api"
35
+ assert_equal 429, last_response.status
36
+ assert_equal ValidApp,
37
+ MultiJson.decode(last_response.headers["Committee-Response"])
38
+ assert_equal "", last_response.body
39
+ end
40
+
32
41
  it "takes a prefix" do
33
42
  @app = new_rack_app(prefix: "/v1")
34
43
  get "/v1/apps/heroku-api"
@@ -40,6 +49,7 @@ describe Committee::Middleware::Stub do
40
49
  private
41
50
 
42
51
  def new_rack_app(options = {})
52
+ suppress = options.delete(:suppress)
43
53
  options = {
44
54
  schema: File.read("./test/data/schema.json")
45
55
  }.merge(options)
@@ -47,7 +57,8 @@ describe Committee::Middleware::Stub do
47
57
  use Committee::Middleware::Stub, options
48
58
  run lambda { |env|
49
59
  headers = { "Committee-Response" => MultiJson.encode(env["committee.response"]) }
50
- [200, headers, []]
60
+ env["committee.suppress"] = suppress
61
+ [429, headers, []]
51
62
  }
52
63
  }
53
64
  end
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: 0.4.12
4
+ version: 0.4.13
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-04-29 00:00:00.000000000 Z
13
+ date: 2014-04-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json