hobbit-contrib 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: af3ee7b967c82d5892915486da7919cb9989d337
4
- data.tar.gz: 401797602c10a6b729d03c62e36f1ddf9e69cd5f
3
+ metadata.gz: 38cbd1cc4eec48457c5c880ef48dd29617c40c7c
4
+ data.tar.gz: 590f088b6fad3a60d927c12d7274c1b3c332a959
5
5
  SHA512:
6
- metadata.gz: e18eb6ea6859527421bb092d1da4c37f110d3306848cbf91c967ec8e723356a93f97f73750fe1636268abf945212e4197e8198b46c996f7766cca5119f027e2d
7
- data.tar.gz: 9ff85ff4a2f82ea0e65b53563ffe2d40127a831776b694d03ea0a3a02868285832395d689dccc056311a64386caa72627f13be09ff5d1471805b0bdf858657e6
6
+ metadata.gz: b394910413b48d9b4525ccb4d5cd63244b65209bfddb81e1e7f5a1fad218ee95e52d5894e14ec678be72eadd5129ac45d0b0e5073dafd0e7499132355697de5e
7
+ data.tar.gz: 8e6217e2811ea0772730a19e5fa03aa7a1af871201ae97a5bdd7751f81a2dcad5ce1b7807ae6d1491e781fe47d2c2852da95b2e83ecac06b17eaa76b3026ecbe
@@ -1,5 +1,5 @@
1
1
  module Hobbit
2
2
  module Contrib
3
- VERSION = '0.2.2'
3
+ VERSION = '0.2.3'
4
4
  end
5
5
  end
data/lib/hobbit/filter.rb CHANGED
@@ -30,8 +30,10 @@ module Hobbit
30
30
  @request = Rack::Request.new(@env)
31
31
  @response = Hobbit::Response.new
32
32
  filter :before
33
- super
34
- filter :after
33
+ unless @response.redirection?
34
+ super
35
+ filter :after
36
+ end
35
37
  @response.finish
36
38
  end
37
39
 
data/spec/filter_spec.rb CHANGED
@@ -142,4 +142,32 @@ EOS
142
142
  last_request.env['hobbit.after'].must_equal 'this will match'
143
143
  end
144
144
  end
145
+
146
+ describe 'when a before filter redirects the response' do
147
+ let :app do
148
+ mock_app do
149
+ include Hobbit::Filter
150
+
151
+ before do
152
+ response.redirect '/goodbye' unless request.path_info == '/goodbye'
153
+ end
154
+
155
+ get '/' do
156
+ 'hello world'
157
+ end
158
+
159
+ get '/goodbye' do
160
+ 'goodbye world'
161
+ end
162
+ end
163
+ end
164
+
165
+ it 'must redirect on before filters' do
166
+ get '/'
167
+ last_response.must_be :redirection?
168
+ follow_redirect!
169
+ last_response.must_be :ok?
170
+ last_response.body.must_match /goodbye world/
171
+ end
172
+ end
145
173
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobbit-contrib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patricio Mac Adden