strelka 0.0.1.pre.199 → 0.0.1.pre.200

Sign up to get free protection for your applications and to get access to all the features.
@@ -148,6 +148,7 @@ module Strelka::App::Errors
148
148
  # If the app or any plugins threw a finish, look for a handler for the status code
149
149
  # and call it if one is found.
150
150
  if status_response
151
+ request.notes[:status_info] = status_response
151
152
  response = request.response
152
153
  status = status_response[:status]
153
154
  self.log.info "[:errors] Handling a status response: %d" % [ status ]
data/lib/strelka/app.rb CHANGED
@@ -331,6 +331,7 @@ class Strelka::App < Mongrel2::Handler
331
331
  status_code, message = status_info.values_at( :status, :message )
332
332
  self.log.info "Non-OK response: %d (%s)" % [ status_code, message ]
333
333
 
334
+ request.notes[:status_info] = status_info
334
335
  response = request.response
335
336
  response.reset
336
337
  response.status = status_code
@@ -50,7 +50,7 @@ describe Strelka::App::Errors do
50
50
  end
51
51
  end
52
52
 
53
- it "has its auth config inherited by subclasses" do
53
+ it "has its status handlers inherited by subclasses" do
54
54
  @app.on_status HTTP::OK do
55
55
  'blap'
56
56
  end
@@ -157,6 +157,25 @@ describe Strelka::App::Errors do
157
157
  res.body.should == 'Error: JAMBA'
158
158
  end
159
159
 
160
+ it "sets the error status info in the transaction notes when the response is handled by a status-handler" do
161
+ @app.class_eval do
162
+ on_status do |res, info|
163
+ res.body = '(%d) Filthy banana' % [ info[:status] ]
164
+ return res
165
+ end
166
+
167
+ get do |req|
168
+ finish_with HTTP::BAD_REQUEST, "Your sandwich is missing something."
169
+ end
170
+ end
171
+
172
+ req = @request_factory.get( '/foom' )
173
+ res = @app.new.handle( req )
174
+
175
+ res.notes[:status_info].should include( :status, :message, :headers )
176
+ res.notes[:status_info][:status].should == HTTP::BAD_REQUEST
177
+ res.notes[:status_info][:message].should == "Your sandwich is missing something."
178
+ end
160
179
 
161
180
  context "template-style handlers" do
162
181
 
@@ -236,6 +236,25 @@ describe Strelka::App do
236
236
  res.body.should == "You aren't allowed to look at that.\n"
237
237
  end
238
238
 
239
+ it "sets the error status info in the transaction notes for error responses" do
240
+ forbidden_plugin = Module.new do
241
+ def self::name; "Strelka::App::Forbidden"; end
242
+ extend Strelka::Plugin
243
+ def handle_request( r )
244
+ finish_with( HTTP::FORBIDDEN, "You aren't allowed to look at that." )
245
+ fail "Shouldn't be reached."
246
+ end
247
+ end
248
+ @app.plugin( forbidden_plugin )
249
+
250
+ res = @app.new.handle( @req )
251
+
252
+ res.notes.should include( :status_info )
253
+ res.notes[:status_info].should include( :status, :message, :headers )
254
+ res.notes[:status_info][:status].should == HTTP::FORBIDDEN
255
+ res.notes[:status_info][:message].should == "You aren't allowed to look at that."
256
+ end
257
+
239
258
 
240
259
  it "provides a declarative for setting the default content type of responses" do
241
260
  @app.class_eval do
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strelka
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre.199
4
+ version: 0.0.1.pre.200
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -40,7 +40,7 @@ date: 2012-04-20 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: trollop
43
- requirement: &70346770348920 !ruby/object:Gem::Requirement
43
+ requirement: &70139550821000 !ruby/object:Gem::Requirement
44
44
  none: false
45
45
  requirements:
46
46
  - - ~>
@@ -48,10 +48,10 @@ dependencies:
48
48
  version: '1.16'
49
49
  type: :runtime
50
50
  prerelease: false
51
- version_requirements: *70346770348920
51
+ version_requirements: *70139550821000
52
52
  - !ruby/object:Gem::Dependency
53
53
  name: highline
54
- requirement: &70346770348380 !ruby/object:Gem::Requirement
54
+ requirement: &70139550820480 !ruby/object:Gem::Requirement
55
55
  none: false
56
56
  requirements:
57
57
  - - ~>
@@ -59,10 +59,10 @@ dependencies:
59
59
  version: '1.6'
60
60
  type: :runtime
61
61
  prerelease: false
62
- version_requirements: *70346770348380
62
+ version_requirements: *70139550820480
63
63
  - !ruby/object:Gem::Dependency
64
64
  name: sysexits
65
- requirement: &70346770347880 !ruby/object:Gem::Requirement
65
+ requirement: &70139550819940 !ruby/object:Gem::Requirement
66
66
  none: false
67
67
  requirements:
68
68
  - - ~>
@@ -70,10 +70,10 @@ dependencies:
70
70
  version: '1.0'
71
71
  type: :runtime
72
72
  prerelease: false
73
- version_requirements: *70346770347880
73
+ version_requirements: *70139550819940
74
74
  - !ruby/object:Gem::Dependency
75
75
  name: formvalidator
76
- requirement: &70346770347340 !ruby/object:Gem::Requirement
76
+ requirement: &70139550819420 !ruby/object:Gem::Requirement
77
77
  none: false
78
78
  requirements:
79
79
  - - ~>
@@ -81,10 +81,10 @@ dependencies:
81
81
  version: '0.1'
82
82
  type: :runtime
83
83
  prerelease: false
84
- version_requirements: *70346770347340
84
+ version_requirements: *70139550819420
85
85
  - !ruby/object:Gem::Dependency
86
86
  name: inversion
87
- requirement: &70346770346760 !ruby/object:Gem::Requirement
87
+ requirement: &70139550818880 !ruby/object:Gem::Requirement
88
88
  none: false
89
89
  requirements:
90
90
  - - ~>
@@ -92,10 +92,10 @@ dependencies:
92
92
  version: '0.8'
93
93
  type: :runtime
94
94
  prerelease: false
95
- version_requirements: *70346770346760
95
+ version_requirements: *70139550818880
96
96
  - !ruby/object:Gem::Dependency
97
97
  name: mongrel2
98
- requirement: &70346770346280 !ruby/object:Gem::Requirement
98
+ requirement: &70139550818380 !ruby/object:Gem::Requirement
99
99
  none: false
100
100
  requirements:
101
101
  - - ~>
@@ -103,10 +103,10 @@ dependencies:
103
103
  version: '0.20'
104
104
  type: :runtime
105
105
  prerelease: false
106
- version_requirements: *70346770346280
106
+ version_requirements: *70139550818380
107
107
  - !ruby/object:Gem::Dependency
108
108
  name: uuidtools
109
- requirement: &70346770345820 !ruby/object:Gem::Requirement
109
+ requirement: &70139550817900 !ruby/object:Gem::Requirement
110
110
  none: false
111
111
  requirements:
112
112
  - - ~>
@@ -114,10 +114,10 @@ dependencies:
114
114
  version: '2.1'
115
115
  type: :runtime
116
116
  prerelease: false
117
- version_requirements: *70346770345820
117
+ version_requirements: *70139550817900
118
118
  - !ruby/object:Gem::Dependency
119
119
  name: configurability
120
- requirement: &70346899262780 !ruby/object:Gem::Requirement
120
+ requirement: &70139550877520 !ruby/object:Gem::Requirement
121
121
  none: false
122
122
  requirements:
123
123
  - - ~>
@@ -125,10 +125,10 @@ dependencies:
125
125
  version: '1.0'
126
126
  type: :runtime
127
127
  prerelease: false
128
- version_requirements: *70346899262780
128
+ version_requirements: *70139550877520
129
129
  - !ruby/object:Gem::Dependency
130
130
  name: pluginfactory
131
- requirement: &70346899262200 !ruby/object:Gem::Requirement
131
+ requirement: &70139550876960 !ruby/object:Gem::Requirement
132
132
  none: false
133
133
  requirements:
134
134
  - - ~>
@@ -136,10 +136,10 @@ dependencies:
136
136
  version: '1.0'
137
137
  type: :runtime
138
138
  prerelease: false
139
- version_requirements: *70346899262200
139
+ version_requirements: *70139550876960
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: hoe-mercurial
142
- requirement: &70346899261640 !ruby/object:Gem::Requirement
142
+ requirement: &70139550876400 !ruby/object:Gem::Requirement
143
143
  none: false
144
144
  requirements:
145
145
  - - ~>
@@ -147,10 +147,10 @@ dependencies:
147
147
  version: 1.4.0
148
148
  type: :development
149
149
  prerelease: false
150
- version_requirements: *70346899261640
150
+ version_requirements: *70139550876400
151
151
  - !ruby/object:Gem::Dependency
152
152
  name: hoe-manualgen
153
- requirement: &70346899261120 !ruby/object:Gem::Requirement
153
+ requirement: &70139550875880 !ruby/object:Gem::Requirement
154
154
  none: false
155
155
  requirements:
156
156
  - - ~>
@@ -158,10 +158,10 @@ dependencies:
158
158
  version: 0.3.0
159
159
  type: :development
160
160
  prerelease: false
161
- version_requirements: *70346899261120
161
+ version_requirements: *70139550875880
162
162
  - !ruby/object:Gem::Dependency
163
163
  name: hoe-highline
164
- requirement: &70346899260640 !ruby/object:Gem::Requirement
164
+ requirement: &70139550875380 !ruby/object:Gem::Requirement
165
165
  none: false
166
166
  requirements:
167
167
  - - ~>
@@ -169,10 +169,10 @@ dependencies:
169
169
  version: 0.1.0
170
170
  type: :development
171
171
  prerelease: false
172
- version_requirements: *70346899260640
172
+ version_requirements: *70139550875380
173
173
  - !ruby/object:Gem::Dependency
174
174
  name: rdoc
175
- requirement: &70346899260100 !ruby/object:Gem::Requirement
175
+ requirement: &70139550874860 !ruby/object:Gem::Requirement
176
176
  none: false
177
177
  requirements:
178
178
  - - ~>
@@ -180,10 +180,10 @@ dependencies:
180
180
  version: '3.10'
181
181
  type: :development
182
182
  prerelease: false
183
- version_requirements: *70346899260100
183
+ version_requirements: *70139550874860
184
184
  - !ruby/object:Gem::Dependency
185
185
  name: hoe-deveiate
186
- requirement: &70346899259600 !ruby/object:Gem::Requirement
186
+ requirement: &70139550874320 !ruby/object:Gem::Requirement
187
187
  none: false
188
188
  requirements:
189
189
  - - ~>
@@ -191,10 +191,10 @@ dependencies:
191
191
  version: '0.1'
192
192
  type: :development
193
193
  prerelease: false
194
- version_requirements: *70346899259600
194
+ version_requirements: *70139550874320
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: simplecov
197
- requirement: &70346899259040 !ruby/object:Gem::Requirement
197
+ requirement: &70139550873780 !ruby/object:Gem::Requirement
198
198
  none: false
199
199
  requirements:
200
200
  - - ~>
@@ -202,10 +202,10 @@ dependencies:
202
202
  version: '0.6'
203
203
  type: :development
204
204
  prerelease: false
205
- version_requirements: *70346899259040
205
+ version_requirements: *70139550873780
206
206
  - !ruby/object:Gem::Dependency
207
207
  name: hoe
208
- requirement: &70346899258540 !ruby/object:Gem::Requirement
208
+ requirement: &70139550873300 !ruby/object:Gem::Requirement
209
209
  none: false
210
210
  requirements:
211
211
  - - ~>
@@ -213,7 +213,7 @@ dependencies:
213
213
  version: '3.0'
214
214
  type: :development
215
215
  prerelease: false
216
- version_requirements: *70346899258540
216
+ version_requirements: *70139550873300
217
217
  description: ! 'Strelka is a framework for creating and deploying Mongrel2 web applications
218
218
 
219
219
  in Ruby, and for managing a Mongrel2 cluster.
metadata.gz.sig CHANGED
Binary file