rack-screen-door 0.0.2 → 0.0.3
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.
- data/README.md +7 -1
- data/lib/rack/screen_door/version.rb +1 -1
- data/lib/rack/screen_door.rb +1 -1
- data/spec/screen_door_spec.rb +5 -3
- metadata +4 -4
data/README.md
CHANGED
@@ -13,10 +13,16 @@ semi-private, e.g., during the development stages.
|
|
13
13
|
|
14
14
|
## Usage
|
15
15
|
|
16
|
-
|
16
|
+
For a Rack-based environment like Sinatra:
|
17
17
|
|
18
|
+
require 'rack/screen_door'
|
18
19
|
use Rack::ScreenDoor 'secret answer'
|
19
20
|
|
21
|
+
For Rails 3.x:
|
22
|
+
|
23
|
+
require 'rack/screen_door'
|
24
|
+
config.middleware.use Rack::ScreenDoor 'secret answer'
|
25
|
+
|
20
26
|
Additional options can be supplied:
|
21
27
|
|
22
28
|
use Rack::ScreenDoor 'secret answer',
|
data/lib/rack/screen_door.rb
CHANGED
@@ -9,7 +9,7 @@ module Rack
|
|
9
9
|
class ScreenDoor
|
10
10
|
|
11
11
|
DEFAULT_COOKIE_KEY = '_rack_screen_door'
|
12
|
-
DEFAULT_COOKIE_HASH = { :httponly => true }
|
12
|
+
DEFAULT_COOKIE_HASH = { :path => '/', :httponly => true }
|
13
13
|
DEFAULT_EXPIRES = 60 * 60 * 24 * 30 # 1 month
|
14
14
|
DEFAULT_TEMPLATE_PATH = ::File.expand_path('../../../default_template.html.erb', __FILE__)
|
15
15
|
DEFAULT_SALT = 'SaltySalt'
|
data/spec/screen_door_spec.rb
CHANGED
@@ -25,7 +25,7 @@ describe Rack::ScreenDoor do
|
|
25
25
|
|
26
26
|
its(:salt) { should == default_salt }
|
27
27
|
its(:cookie_key) { should == default_cookie_key }
|
28
|
-
its(:cookie_hash) { should == { :httponly => true } }
|
28
|
+
its(:cookie_hash) { should == { :path => '/', :httponly => true } }
|
29
29
|
its(:expires) { should == 60 * 60 * 24 * 30 }
|
30
30
|
its(:answer) { should == penguin_answer }
|
31
31
|
its(:hashed_answer) { should == penguin_hash }
|
@@ -73,17 +73,19 @@ describe Rack::ScreenDoor do
|
|
73
73
|
|
74
74
|
end
|
75
75
|
|
76
|
-
context 'POST / with correct answer' do
|
76
|
+
context 'POST /blah with correct answer' do
|
77
77
|
|
78
78
|
before do
|
79
79
|
Time.stub(:now) { Time.at(946684800).utc } # 2000-1-1
|
80
|
-
post '/', :answer => 'penguin', :redirect => 'http://example.org/stuff'
|
80
|
+
post '/blah', :answer => 'penguin', :redirect => 'http://example.org/stuff'
|
81
81
|
end
|
82
82
|
|
83
83
|
it { should be_redirect }
|
84
84
|
specify { headers['Location'].should == 'http://example.org/stuff' }
|
85
85
|
specify { headers['Set-Cookie'].should include("#{default_cookie_key}=#{penguin_hash}") }
|
86
86
|
specify { headers['Set-Cookie'].should include('expires=Mon, 31-Jan-2000 00:00:00 GMT') }
|
87
|
+
specify { headers['Set-Cookie'].should include('path=/;') }
|
88
|
+
specify { headers['Set-Cookie'].should_not include('path=/blah;') }
|
87
89
|
|
88
90
|
context 'after following the redirect' do
|
89
91
|
before { follow_redirect! }
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-screen-door
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- John Nishinaga
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-01-
|
18
|
+
date: 2012-01-13 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|