sinatra_warden 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +3 -2
- data/VERSION +1 -1
- data/lib/sinatra_warden/sinatra.rb +1 -1
- data/sinatra_warden.gemspec +38 -3
- data/spec/fixtures/testing_login.rb +11 -0
- data/spec/sinatra_warden_spec.rb +21 -9
- metadata +124 -19
data/Rakefile
CHANGED
@@ -15,10 +15,11 @@ begin
|
|
15
15
|
|
16
16
|
manifest = Bundler::Environment.load(File.dirname(__FILE__) + '/Gemfile')
|
17
17
|
manifest.dependencies.each do |d|
|
18
|
-
next if d.only && d.only.include?(
|
18
|
+
next if d.only && d.only.include?(:testing)
|
19
19
|
gem.add_dependency(d.name, d.version)
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
|
+
gem.executables = nil
|
22
23
|
end
|
23
24
|
Jeweler::GemcutterTasks.new
|
24
25
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/sinatra_warden.gemspec
CHANGED
@@ -5,14 +5,13 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sinatra_warden}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Justin Smestad", "Daniel Neighman"]
|
12
|
-
s.date = %q{2009-11-
|
12
|
+
s.date = %q{2009-11-04}
|
13
13
|
s.description = %q{basic helpers and authentication methods for using warden with sinatra also providing some hooks into Rack::Flash}
|
14
14
|
s.email = %q{justin.smestad@gmail.com}
|
15
|
-
s.executables = ["autospec", "css2sass", "edit_json.rb", "haml", "html2haml", "jeweler", "prettify_json.rb", "rackup", "rake", "rcov", "rubyforge", "sass", "spec", "yard-graph", "yardoc", "yri"]
|
16
15
|
s.extra_rdoc_files = [
|
17
16
|
"LICENSE",
|
18
17
|
"README.rdoc"
|
@@ -56,13 +55,49 @@ Gem::Specification.new do |s|
|
|
56
55
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
57
56
|
s.add_runtime_dependency(%q<sinatra>, [">= 0.9.4"])
|
58
57
|
s.add_runtime_dependency(%q<warden>, ["~> 0.5.0"])
|
58
|
+
s.add_runtime_dependency(%q<rake>, [">= 0"])
|
59
|
+
s.add_runtime_dependency(%q<jeweler>, [">= 0"])
|
60
|
+
s.add_runtime_dependency(%q<bundler>, [">= 0"])
|
61
|
+
s.add_runtime_dependency(%q<rspec>, ["~> 1.2.9"])
|
62
|
+
s.add_runtime_dependency(%q<yard>, [">= 0"])
|
63
|
+
s.add_runtime_dependency(%q<rack-test>, ["~> 0.5.0"])
|
64
|
+
s.add_runtime_dependency(%q<rcov>, [">= 0"])
|
65
|
+
s.add_runtime_dependency(%q<do_sqlite3>, ["~> 0.10.0"])
|
66
|
+
s.add_runtime_dependency(%q<dm-core>, ["~> 0.10.1"])
|
67
|
+
s.add_runtime_dependency(%q<bcrypt-ruby>, [">= 0"])
|
68
|
+
s.add_runtime_dependency(%q<haml>, [">= 0"])
|
69
|
+
s.add_runtime_dependency(%q<rack-flash>, [">= 0"])
|
59
70
|
else
|
60
71
|
s.add_dependency(%q<sinatra>, [">= 0.9.4"])
|
61
72
|
s.add_dependency(%q<warden>, ["~> 0.5.0"])
|
73
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
74
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
75
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
76
|
+
s.add_dependency(%q<rspec>, ["~> 1.2.9"])
|
77
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
78
|
+
s.add_dependency(%q<rack-test>, ["~> 0.5.0"])
|
79
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
80
|
+
s.add_dependency(%q<do_sqlite3>, ["~> 0.10.0"])
|
81
|
+
s.add_dependency(%q<dm-core>, ["~> 0.10.1"])
|
82
|
+
s.add_dependency(%q<bcrypt-ruby>, [">= 0"])
|
83
|
+
s.add_dependency(%q<haml>, [">= 0"])
|
84
|
+
s.add_dependency(%q<rack-flash>, [">= 0"])
|
62
85
|
end
|
63
86
|
else
|
64
87
|
s.add_dependency(%q<sinatra>, [">= 0.9.4"])
|
65
88
|
s.add_dependency(%q<warden>, ["~> 0.5.0"])
|
89
|
+
s.add_dependency(%q<rake>, [">= 0"])
|
90
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
91
|
+
s.add_dependency(%q<bundler>, [">= 0"])
|
92
|
+
s.add_dependency(%q<rspec>, ["~> 1.2.9"])
|
93
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
94
|
+
s.add_dependency(%q<rack-test>, ["~> 0.5.0"])
|
95
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
96
|
+
s.add_dependency(%q<do_sqlite3>, ["~> 0.10.0"])
|
97
|
+
s.add_dependency(%q<dm-core>, ["~> 0.10.1"])
|
98
|
+
s.add_dependency(%q<bcrypt-ruby>, [">= 0"])
|
99
|
+
s.add_dependency(%q<haml>, [">= 0"])
|
100
|
+
s.add_dependency(%q<rack-flash>, [">= 0"])
|
66
101
|
end
|
67
102
|
end
|
68
103
|
|
@@ -11,8 +11,19 @@ class TestingLogin < Sinatra::Base
|
|
11
11
|
"My Dashboard"
|
12
12
|
end
|
13
13
|
|
14
|
+
get '/account' do
|
15
|
+
authorize!
|
16
|
+
"#{user.email}'s account page"
|
17
|
+
end
|
18
|
+
|
19
|
+
post '/login_as/?' do
|
20
|
+
authorize!
|
21
|
+
user = User.authenticate(params['email'], params['password'])
|
22
|
+
end
|
23
|
+
|
14
24
|
get '/admin' do
|
15
25
|
authorize!
|
26
|
+
"Welcome #{current_user.email}"
|
16
27
|
end
|
17
28
|
|
18
29
|
end
|
data/spec/sinatra_warden_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
|
-
describe "
|
3
|
+
describe "Sinatra::Warden" do
|
4
4
|
before(:each) do
|
5
5
|
@user = User.create(:email => 'justin.smestad@gmail.com', :password => 'thedude')
|
6
6
|
end
|
@@ -15,7 +15,6 @@ describe "SinatraWarden" do
|
|
15
15
|
end
|
16
16
|
|
17
17
|
context "the authentication system" do
|
18
|
-
|
19
18
|
it "should allow us to login as that user" do
|
20
19
|
post '/login', 'email' => 'justin.smestad@gmail.com', 'password' => 'thedude'
|
21
20
|
last_request.env['warden'].authenticated?.should == true
|
@@ -24,15 +23,14 @@ describe "SinatraWarden" do
|
|
24
23
|
it "should allow us to logout after logging in" do
|
25
24
|
post '/login', 'email' => 'justin.smestad@gmail.com', 'password' => 'thedude'
|
26
25
|
last_request.env['warden'].authenticated?.should == true
|
27
|
-
|
26
|
+
get '/logout'
|
27
|
+
last_request.env['warden'].authenticated?.should == false
|
28
28
|
end
|
29
|
-
|
30
29
|
end
|
31
30
|
|
32
31
|
context "the helpers" do
|
33
32
|
|
34
33
|
context "the authorize! helper" do
|
35
|
-
|
36
34
|
it "should redirect to root (default) if not logged in" do
|
37
35
|
get '/admin'
|
38
36
|
follow_redirect!
|
@@ -51,16 +49,30 @@ describe "SinatraWarden" do
|
|
51
49
|
get '/dashboard'
|
52
50
|
last_response.body.should == "My Dashboard"
|
53
51
|
end
|
54
|
-
|
55
52
|
end
|
56
53
|
|
57
54
|
context "the user helper" do
|
55
|
+
before(:each) do
|
56
|
+
post '/login', 'email' => 'justin.smestad@gmail.com', 'password' => 'thedude'
|
57
|
+
last_request.env['warden'].authenticated?.should == true
|
58
|
+
end
|
58
59
|
|
59
|
-
it "should be aliased to current_user"
|
60
|
+
it "should be aliased to current_user" do
|
61
|
+
get '/admin'
|
62
|
+
last_response.body.should == "Welcome #{@user.email}"
|
63
|
+
end
|
60
64
|
|
61
|
-
it "should allow assignment of the user (user=)"
|
65
|
+
it "should allow assignment of the user (user=)" do
|
66
|
+
john = User.create(:email => 'john.doe@hotmail.com', :password => 'secret')
|
67
|
+
last_request.env['warden'].user.should == @user
|
68
|
+
post '/login_as', 'email' => 'john.doe@hotmail.com', 'password' => 'secret'
|
69
|
+
last_request.env['warden'].user.should == john
|
70
|
+
end
|
62
71
|
|
63
|
-
it "should return the current logged in user"
|
72
|
+
it "should return the current logged in user" do
|
73
|
+
get '/account'
|
74
|
+
last_response.body.should == "#{@user.email}'s account page"
|
75
|
+
end
|
64
76
|
|
65
77
|
end
|
66
78
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra_warden
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Smestad
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-11-
|
13
|
+
date: 2009-11-04 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -33,25 +33,130 @@ dependencies:
|
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: 0.5.0
|
35
35
|
version:
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
type: :runtime
|
39
|
+
version_requirement:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: "0"
|
45
|
+
version:
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: jeweler
|
48
|
+
type: :runtime
|
49
|
+
version_requirement:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
version:
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: bundler
|
58
|
+
type: :runtime
|
59
|
+
version_requirement:
|
60
|
+
version_requirements: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: "0"
|
65
|
+
version:
|
66
|
+
- !ruby/object:Gem::Dependency
|
67
|
+
name: rspec
|
68
|
+
type: :runtime
|
69
|
+
version_requirement:
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 1.2.9
|
75
|
+
version:
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: yard
|
78
|
+
type: :runtime
|
79
|
+
version_requirement:
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: "0"
|
85
|
+
version:
|
86
|
+
- !ruby/object:Gem::Dependency
|
87
|
+
name: rack-test
|
88
|
+
type: :runtime
|
89
|
+
version_requirement:
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ~>
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 0.5.0
|
95
|
+
version:
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: rcov
|
98
|
+
type: :runtime
|
99
|
+
version_requirement:
|
100
|
+
version_requirements: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: "0"
|
105
|
+
version:
|
106
|
+
- !ruby/object:Gem::Dependency
|
107
|
+
name: do_sqlite3
|
108
|
+
type: :runtime
|
109
|
+
version_requirement:
|
110
|
+
version_requirements: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ~>
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 0.10.0
|
115
|
+
version:
|
116
|
+
- !ruby/object:Gem::Dependency
|
117
|
+
name: dm-core
|
118
|
+
type: :runtime
|
119
|
+
version_requirement:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.10.1
|
125
|
+
version:
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: bcrypt-ruby
|
128
|
+
type: :runtime
|
129
|
+
version_requirement:
|
130
|
+
version_requirements: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: "0"
|
135
|
+
version:
|
136
|
+
- !ruby/object:Gem::Dependency
|
137
|
+
name: haml
|
138
|
+
type: :runtime
|
139
|
+
version_requirement:
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: "0"
|
145
|
+
version:
|
146
|
+
- !ruby/object:Gem::Dependency
|
147
|
+
name: rack-flash
|
148
|
+
type: :runtime
|
149
|
+
version_requirement:
|
150
|
+
version_requirements: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: "0"
|
155
|
+
version:
|
36
156
|
description: basic helpers and authentication methods for using warden with sinatra also providing some hooks into Rack::Flash
|
37
157
|
email: justin.smestad@gmail.com
|
38
|
-
executables:
|
39
|
-
|
40
|
-
- css2sass
|
41
|
-
- edit_json.rb
|
42
|
-
- haml
|
43
|
-
- html2haml
|
44
|
-
- jeweler
|
45
|
-
- prettify_json.rb
|
46
|
-
- rackup
|
47
|
-
- rake
|
48
|
-
- rcov
|
49
|
-
- rubyforge
|
50
|
-
- sass
|
51
|
-
- spec
|
52
|
-
- yard-graph
|
53
|
-
- yardoc
|
54
|
-
- yri
|
158
|
+
executables: []
|
159
|
+
|
55
160
|
extensions: []
|
56
161
|
|
57
162
|
extra_rdoc_files:
|