Pistos-ramaze 2009.04.08 → 2009.06.12
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/MANIFEST +37 -22
- data/{README.markdown → README.md} +5 -24
- data/Rakefile +33 -26
- data/benchmark/bench_templates/bench.rb +67 -0
- data/benchmark/bench_templates/view/large.erb +79 -0
- data/benchmark/bench_templates/view/large.haml +41 -0
- data/benchmark/bench_templates/view/large.xhtml +79 -0
- data/benchmark/bench_templates/view/small.erb +21 -0
- data/benchmark/bench_templates/view/small.haml +12 -0
- data/benchmark/bench_templates/view/small.xhtml +21 -0
- data/benchmark/run.rb +14 -21
- data/benchmark/suite/minimal.rb +3 -5
- data/benchmark/suite/no_informer.rb +0 -2
- data/benchmark/suite/no_sessions.rb +3 -4
- data/benchmark/suite/no_template.rb +1 -3
- data/benchmark/suite/simple.rb +1 -3
- data/benchmark/suite/template_erubis.rb +0 -2
- data/benchmark/suite/template_etanni.rb +8 -0
- data/benchmark/suite/template_ezamar.rb +1 -3
- data/benchmark/suite/template_haml.rb +0 -2
- data/benchmark/suite/template_liquid.rb +0 -2
- data/benchmark/suite/template_markaby.rb +0 -2
- data/benchmark/suite/template_nagoro.rb +1 -3
- data/benchmark/suite/template_redcloth.rb +0 -2
- data/benchmark/suite/template_tenjin.rb +0 -2
- data/bin/ramaze +11 -163
- data/doc/AUTHORS +15 -8
- data/doc/CHANGELOG +10094 -12262
- data/doc/meta/announcement.txt +93 -46
- data/doc/tutorial/todolist.html +22 -58
- data/doc/tutorial/todolist.txt +20 -39
- data/examples/app/auth/layout/{auth.nag → auth.xhtml} +0 -0
- data/examples/app/auth/view/{index.nag → index.xhtml} +0 -0
- data/examples/app/auth/view/{login.nag → login.xhtml} +0 -0
- data/examples/app/auth/view/{secret.nag → secret.xhtml} +0 -0
- data/examples/app/blog/app.rb +1 -1
- data/examples/app/blog/controller/comment.rb +1 -1
- data/examples/app/blog/controller/entry.rb +12 -3
- data/examples/app/blog/model/init.rb +5 -0
- data/examples/app/blog/model/tag.rb +2 -2
- data/examples/app/blog/view/entry/index.nag +3 -3
- data/examples/app/blog/view/feed.atom.nag +1 -1
- data/examples/app/blog/view/feed.rss.nag +1 -1
- data/examples/app/blog/view/index.nag +1 -1
- data/examples/app/blog/view/tag/index.nag +1 -1
- data/examples/app/chat/layout/{default.nag → default.xhtml} +0 -0
- data/examples/app/chat/view/{chat.nag → chat.xhtml} +0 -0
- data/examples/app/chat/view/{index.nag → index.xhtml} +0 -0
- data/examples/app/localization/locale/de.yaml +5 -0
- data/examples/app/localization/locale/en.yaml +5 -0
- data/examples/app/localization/locale/ja.yaml +5 -0
- data/examples/app/localization/start.rb +33 -20
- data/examples/app/wikore/spec/wikore.rb +4 -6
- data/examples/app/wikore/src/controller.rb +9 -11
- data/examples/app/wikore/src/model.rb +7 -10
- data/examples/app/wikore/start.rb +1 -1
- data/examples/app/wikore/{template → view}/index.xhtml +0 -0
- data/examples/helpers/cache.rb +6 -4
- data/examples/misc/css.rb +6 -12
- data/examples/misc/rapp.rb +28 -17
- data/lib/proto/app.rb +14 -0
- data/lib/proto/config.ru +8 -5
- data/lib/proto/controller/init.rb +3 -3
- data/lib/proto/spec/main.rb +9 -11
- data/lib/proto/start.rb +6 -10
- data/lib/ramaze.rb +8 -9
- data/lib/ramaze/app.rb +4 -3
- data/lib/ramaze/cache/localmemcache.rb +2 -2
- data/lib/ramaze/cache/memcache.rb +26 -1
- data/lib/ramaze/cache/sequel.rb +24 -9
- data/lib/ramaze/contrib/addressable_route.rb +56 -0
- data/lib/ramaze/contrib/email.rb +2 -0
- data/lib/ramaze/contrib/facebook/facebook.rb +4 -4
- data/lib/ramaze/contrib/sequel/create_join.rb +1 -0
- data/lib/ramaze/contrib/sequel/form_field.rb +4 -4
- data/lib/ramaze/contrib/sequel/image.rb +9 -11
- data/lib/ramaze/contrib/sequel/relation.rb +17 -3
- data/lib/ramaze/controller.rb +26 -18
- data/lib/ramaze/gestalt.rb +4 -1
- data/lib/ramaze/helper.rb +1 -0
- data/lib/ramaze/helper/auth.rb +0 -5
- data/lib/ramaze/helper/cache.rb +65 -25
- data/lib/ramaze/helper/form.rb +14 -2
- data/lib/ramaze/helper/formatting.rb +3 -1
- data/lib/ramaze/helper/gestalt.rb +32 -0
- data/lib/ramaze/helper/identity.rb +3 -3
- data/lib/ramaze/helper/layout.rb +97 -0
- data/lib/ramaze/helper/link.rb +6 -25
- data/lib/ramaze/helper/localize.rb +13 -3
- data/lib/ramaze/helper/paginate.rb +4 -2
- data/lib/ramaze/helper/ultraviolet.rb +2 -0
- data/lib/ramaze/helper/user.rb +3 -3
- data/lib/ramaze/log/rotatinginformer.rb +10 -10
- data/lib/ramaze/request.rb +3 -5
- data/lib/ramaze/setup.rb +22 -9
- data/lib/ramaze/spec.rb +8 -12
- data/lib/ramaze/spec/bacon.rb +34 -0
- data/lib/ramaze/spec/helper/template_examples.rb +15 -22
- data/lib/ramaze/tool/bin.rb +340 -0
- data/lib/ramaze/tool/project_creator.rb +1 -1
- data/lib/ramaze/version.rb +1 -1
- data/lib/ramaze/view.rb +6 -11
- data/lib/ramaze/view/erubis.rb +2 -2
- data/lib/ramaze/view/ezamar.rb +2 -2
- data/lib/ramaze/view/gestalt.rb +14 -0
- data/lib/ramaze/view/haml.rb +2 -1
- data/lib/ramaze/view/liquid.rb +45 -11
- data/lib/ramaze/view/maruku.rb +2 -1
- data/lib/ramaze/view/nagoro/render_partial.rb +9 -9
- data/lib/ramaze/view/sass.rb +1 -1
- data/lib/ramaze/view/tenjin.rb +7 -4
- data/lib/vendor/etag.rb +4 -2
- data/lib/vendor/route_exceptions.rb +9 -15
- data/ramaze.gemspec +56 -9
- data/spec/contrib/addressable_route.rb +30 -0
- data/spec/contrib/rest.rb +2 -2
- data/spec/examples/caching.rb +5 -7
- data/spec/examples/css.rb +3 -3
- data/spec/examples/element.rb +4 -3
- data/spec/examples/hello.rb +3 -3
- data/spec/examples/helpers/httpdigest.rb +44 -69
- data/spec/examples/linking.rb +3 -3
- data/spec/examples/simple.rb +3 -3
- data/spec/examples/templates/template_erubis.rb +8 -4
- data/spec/examples/templates/template_ezamar.rb +9 -4
- data/spec/examples/templates/template_haml.rb +8 -4
- data/spec/examples/templates/template_liquid.rb +8 -4
- data/spec/examples/templates/template_markaby.rb +9 -5
- data/spec/examples/templates/template_nagoro.rb +9 -5
- data/spec/examples/templates/template_redcloth.rb +8 -4
- data/spec/examples/templates/template_remarkably.rb +8 -4
- data/spec/examples/templates/template_tenjin.rb +8 -4
- data/spec/helper.rb +1 -2
- data/spec/ramaze/action/render.rb +4 -1
- data/spec/ramaze/app.rb +5 -2
- data/spec/ramaze/bin/ramaze.rb +96 -0
- data/spec/ramaze/cache/localmemcache.rb +1 -1
- data/spec/ramaze/cache/memcache.rb +7 -1
- data/spec/ramaze/cache/sequel.rb +1 -1
- data/spec/ramaze/controller/actionless_templates.rb +2 -2
- data/spec/ramaze/controller/lonely_mapping.rb +18 -0
- data/spec/ramaze/controller/mapping.rb +4 -15
- data/spec/ramaze/controller/provide_inheritance.rb +5 -2
- data/spec/ramaze/controller/resolve.rb +2 -2
- data/spec/ramaze/controller/subclass.rb +2 -2
- data/spec/ramaze/controller/template_resolving.rb +2 -2
- data/spec/ramaze/dispatcher/directory.rb +5 -2
- data/spec/ramaze/dispatcher/file.rb +28 -26
- data/spec/ramaze/error.rb +3 -3
- data/spec/ramaze/files.rb +5 -2
- data/spec/ramaze/gestalt.rb +26 -17
- data/spec/ramaze/helper/auth.rb +30 -41
- data/spec/ramaze/helper/bench.rb +6 -2
- data/spec/ramaze/helper/cache.rb +45 -5
- data/spec/ramaze/helper/flash.rb +11 -15
- data/spec/ramaze/helper/form.rb +6 -3
- data/spec/ramaze/helper/formatting.rb +4 -1
- data/spec/ramaze/helper/gestalt.rb +4 -1
- data/spec/ramaze/helper/gravatar.rb +4 -1
- data/spec/ramaze/helper/httpdigest.rb +51 -66
- data/spec/ramaze/helper/layout.rb +79 -0
- data/spec/ramaze/helper/layout/default.xhtml +5 -0
- data/spec/ramaze/helper/link.rb +33 -12
- data/spec/ramaze/helper/localize.rb +9 -4
- data/spec/ramaze/helper/maruku.rb +5 -2
- data/spec/ramaze/helper/pager.rb +2 -2
- data/spec/ramaze/helper/paginate.rb +5 -2
- data/spec/ramaze/helper/request_accessor.rb +5 -2
- data/spec/ramaze/helper/sequel_form.rb +7 -2
- data/spec/ramaze/helper/simple_captcha.rb +10 -14
- data/spec/ramaze/helper/stack.rb +32 -40
- data/spec/ramaze/helper/user.rb +19 -14
- data/spec/ramaze/helper/xhtml.rb +4 -1
- data/spec/ramaze/log/informer.rb +1 -1
- data/spec/ramaze/log/logging.rb +4 -1
- data/spec/ramaze/log/syslog.rb +6 -6
- data/spec/ramaze/params.rb +5 -6
- data/spec/ramaze/request.rb +16 -1
- data/spec/ramaze/session/memcache.rb +66 -0
- data/spec/ramaze/struct.rb +4 -1
- data/spec/ramaze/view.rb +2 -2
- data/spec/ramaze/view/erubis.rb +2 -2
- data/spec/ramaze/view/ezamar.rb +2 -2
- data/spec/ramaze/view/gestalt.rb +94 -0
- data/spec/ramaze/view/gestalt/external.ges +8 -0
- data/spec/ramaze/view/haml.rb +2 -2
- data/spec/ramaze/view/liquid.rb +2 -2
- data/spec/ramaze/view/nagoro.rb +2 -2
- data/spec/ramaze/view/redcloth.rb +2 -2
- data/spec/ramaze/view/remarkably.rb +2 -2
- data/spec/ramaze/view/sass.rb +2 -2
- data/spec/ramaze/view/tagz.rb +2 -2
- data/spec/ramaze/view/tenjin.rb +2 -2
- data/spec/snippets/array/put_within.rb +30 -25
- data/spec/snippets/binding/locals.rb +4 -1
- data/spec/snippets/numeric/filesize_format.rb +4 -1
- data/spec/snippets/numeric/time.rb +5 -2
- data/spec/snippets/object/__dir__.rb +4 -1
- data/spec/snippets/ordered_set.rb +4 -1
- data/spec/snippets/ramaze/acquire.rb +4 -1
- data/spec/snippets/ramaze/dictionary.rb +4 -1
- data/spec/snippets/ramaze/struct.rb +4 -1
- data/spec/snippets/string/camel_case.rb +4 -1
- data/spec/snippets/string/color.rb +4 -1
- data/spec/snippets/string/snake_case.rb +4 -1
- data/spec/snippets/string/unindent.rb +4 -1
- data/spec/snippets/thread/into.rb +4 -1
- data/tasks/bacon.rake +5 -3
- data/tasks/changelog.rake +3 -1
- data/tasks/{gem_installer.rake → gem_setup.rake} +45 -22
- data/tasks/release.rake +12 -27
- data/tasks/setup.rake +6 -0
- data/tasks/todo.rake +2 -4
- metadata +205 -31
- data/CHANGELOG +0 -16546
- data/benchmark/suite/template_builder.rb +0 -12
- data/doc/tutorial/todolist.mkd +0 -787
- data/examples/helpers/provide.rb +0 -23
- data/lib/proto/view/page.xhtml +0 -27
- data/lib/ramaze/snippets/divide.rb +0 -22
- data/lib/ramaze/snippets/kernel/constant.rb +0 -41
- data/lib/ramaze/snippets/object/acquire.rb +0 -37
- data/lib/ramaze/snippets/string/each.rb +0 -19
- data/spec/ramaze/helper/partial.rb +0 -40
- data/spec/snippets/kernel/constant.rb +0 -23
- data/tasks/install_dependencies.rake +0 -6
data/spec/ramaze/helper/auth.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
require 'spec/helper'
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
5
5
|
|
6
6
|
$password = Digest::SHA1.hexdigest('pass')
|
7
7
|
|
@@ -49,46 +49,35 @@ class SpecHelperAuthLambda < SpecHelperAuth
|
|
49
49
|
end
|
50
50
|
|
51
51
|
describe Ramaze::Helper::Auth do
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
52
|
+
%w[ hash lambda method ].each do |prefix|
|
53
|
+
describe "login" do
|
54
|
+
behaves_like :rack_test
|
55
|
+
|
56
|
+
it "uses a #{prefix}" do
|
57
|
+
get "/#{prefix}/secured"
|
58
|
+
follow_redirect!
|
59
|
+
last_response.status.should == 200
|
60
|
+
last_response.body.should =~ (/<form/)
|
61
|
+
|
62
|
+
post("/#{prefix}/login", 'username' => 'manveru', 'password' => 'pass')
|
63
|
+
follow_redirect!
|
64
|
+
last_response.status.should == 200
|
65
|
+
last_response.body.should == 'Secret content'
|
66
|
+
|
67
|
+
get "/#{prefix}/secured"
|
68
|
+
last_response.status.should == 200
|
69
|
+
last_response.body.should == 'Secret content'
|
70
|
+
|
71
|
+
get "/#{prefix}/logout"
|
72
|
+
follow_redirect!
|
73
|
+
last_response.status.should == 200
|
74
|
+
last_response.body.should == 'SpecHelperAuth'
|
75
|
+
|
76
|
+
get "/#{prefix}/secured"
|
77
|
+
follow_redirect!
|
78
|
+
last_response.status.should == 200
|
79
|
+
last_response.body.should =~ (/<form/)
|
80
|
+
end
|
80
81
|
end
|
81
82
|
end
|
82
|
-
|
83
|
-
it 'authenticates by looking into a hash' do
|
84
|
-
procedure('/hash')
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'authenticates by looking into a lambda' do
|
88
|
-
procedure('/lambda')
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'authenticates by looking into a method' do
|
92
|
-
procedure('/method')
|
93
|
-
end
|
94
83
|
end
|
data/spec/ramaze/helper/bench.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
2
5
|
require 'ramaze/helper/bench'
|
3
6
|
|
4
7
|
describe Ramaze::Helper::Bench do
|
@@ -12,6 +15,7 @@ describe Ramaze::Helper::Bench do
|
|
12
15
|
result = bench{ sleep 0.1; 'result' }
|
13
16
|
result.should == 'result'
|
14
17
|
log.size.should == 1
|
15
|
-
|
18
|
+
# output between ruby 1.8 and 1.9 differs...
|
19
|
+
log.pop.should =~ %r!^Bench #{__FILE__}:#{__LINE__ - 4}:.* \d\.\d+$!
|
16
20
|
end
|
17
21
|
end
|
data/spec/ramaze/helper/cache.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
require 'spec/helper'
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
5
5
|
|
6
6
|
class SpecHelperCache < Ramaze::Controller
|
7
7
|
map '/'
|
8
8
|
helper :cache
|
9
|
-
|
9
|
+
|
10
|
+
cache_action(:method => :cached_action)
|
11
|
+
cache_action(:method => :with_params)
|
12
|
+
cache_action(:method => :with_type)
|
10
13
|
|
11
14
|
def cached_value
|
12
15
|
cache_value[:time] ||= random
|
@@ -16,6 +19,15 @@ class SpecHelperCache < Ramaze::Controller
|
|
16
19
|
random.to_s
|
17
20
|
end
|
18
21
|
|
22
|
+
def with_params(foo, bar)
|
23
|
+
"foo: #{foo}, bar: #{bar}, random: #{random}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def with_type
|
27
|
+
response['Content-Type'] = 'text/plain'
|
28
|
+
random.to_s
|
29
|
+
end
|
30
|
+
|
19
31
|
private
|
20
32
|
|
21
33
|
def random
|
@@ -36,15 +48,15 @@ end
|
|
36
48
|
class SpecHelperCacheKey < Ramaze::Controller
|
37
49
|
map '/key'
|
38
50
|
helper :cache
|
39
|
-
cache_action(:method => :
|
51
|
+
cache_action(:method => :index){ request[:name] }
|
40
52
|
|
41
|
-
def
|
53
|
+
def index
|
42
54
|
"hi #{request['name']} #{rand}"
|
43
55
|
end
|
44
56
|
end
|
45
57
|
|
46
58
|
describe Ramaze::Helper::Cache do
|
47
|
-
behaves_like :
|
59
|
+
behaves_like :rack_test
|
48
60
|
|
49
61
|
it 'caches actions' do
|
50
62
|
got = get('/cached_action')
|
@@ -74,6 +86,22 @@ describe Ramaze::Helper::Cache do
|
|
74
86
|
got.body.should == cached_body
|
75
87
|
end
|
76
88
|
|
89
|
+
it 'caches actions with params' do
|
90
|
+
2.times do
|
91
|
+
lambda{ get('/with_params/foo/bar').body }.should.not.change{ get('/with_params/foo/bar').body }
|
92
|
+
end
|
93
|
+
|
94
|
+
get('/with_params/foo/bar').body.should.not == get('/with_params/baz/quux').body
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'preserves the Content-Type' do
|
98
|
+
2.times do
|
99
|
+
lambda{ get('/with_type').body }.should.not.change{ get('/with_type').body }
|
100
|
+
end
|
101
|
+
|
102
|
+
get('/with_type')['Content-Type'].should == 'text/plain'
|
103
|
+
end
|
104
|
+
|
77
105
|
it 'caches actions with ttl' do
|
78
106
|
2.times do
|
79
107
|
lambda{ get('/ttl').body }.should.not.change{ get('/ttl').body }
|
@@ -81,4 +109,16 @@ describe Ramaze::Helper::Cache do
|
|
81
109
|
|
82
110
|
lambda{ sleep 1; get('/ttl').body }.should.change{ get('/ttl').body }
|
83
111
|
end
|
112
|
+
|
113
|
+
it 'caches actions with block keys' do
|
114
|
+
2.times do
|
115
|
+
lambda{ get('/key?name=foo').body }.should.not.change{ get('/key?name=foo').body }
|
116
|
+
end
|
117
|
+
|
118
|
+
get('/key?name=foo').body.should.not == get('/key?name=bar').body
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'caches actions on a per-controller basis' do
|
122
|
+
get('/ttl').body.should.not == get('/key').body
|
123
|
+
end
|
84
124
|
end
|
data/spec/ramaze/helper/flash.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
2
|
# All files in this distribution are subject to the terms of the Ruby license.
|
3
3
|
|
4
|
-
require 'spec/helper'
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
5
5
|
|
6
6
|
class SpecHelperFlash < Ramaze::Controller
|
7
|
-
map
|
7
|
+
map '/'
|
8
8
|
helper :flash
|
9
9
|
trait :flashbox => "%key : %value"
|
10
10
|
|
@@ -23,23 +23,19 @@ class SpecHelperFlash < Ramaze::Controller
|
|
23
23
|
end
|
24
24
|
|
25
25
|
describe Ramaze::Helper::Flash do
|
26
|
-
behaves_like :
|
26
|
+
behaves_like :rack_test
|
27
27
|
|
28
28
|
it 'displays a flashbox with one item' do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
got.body.should == 'one : for starters'
|
34
|
-
end
|
29
|
+
get('/populate_one')
|
30
|
+
get('/box')
|
31
|
+
last_response.status.should == 200
|
32
|
+
last_response.body.should == 'one : for starters'
|
35
33
|
end
|
36
34
|
|
37
35
|
it 'displays a flashbox with two items' do
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
got.body.split("\n").sort.should == ['one : this one', 'two : and this']
|
43
|
-
end
|
36
|
+
get('/populate_two')
|
37
|
+
get('/box')
|
38
|
+
last_response.status.should == 200
|
39
|
+
last_response.body.split("\n").sort.should == ['one : this one', 'two : and this']
|
44
40
|
end
|
45
41
|
end
|
data/spec/ramaze/helper/form.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
2
5
|
|
3
6
|
spec_requires 'hpricot'
|
4
7
|
|
@@ -42,7 +45,7 @@ class SpecHelperForm < Ramaze::Controller
|
|
42
45
|
|
43
46
|
def select_array_multiple
|
44
47
|
languages = %w[ English German Japanese ]
|
45
|
-
form_select('Languages', :languages, languages, :multiple =>
|
48
|
+
form_select('Languages', :languages, languages, :multiple => 1)
|
46
49
|
end
|
47
50
|
|
48
51
|
def select_array_selected
|
@@ -57,7 +60,7 @@ class SpecHelperForm < Ramaze::Controller
|
|
57
60
|
end
|
58
61
|
|
59
62
|
describe Ramaze::Helper::Form do
|
60
|
-
behaves_like :
|
63
|
+
behaves_like :rack_test
|
61
64
|
|
62
65
|
it 'provides empty text input' do
|
63
66
|
got = get('/text')
|
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
2
5
|
require 'ramaze/helper/formatting'
|
3
6
|
|
4
7
|
describe 'Helper::Formatting' do
|
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
2
5
|
require 'ramaze/helper/gestalt'
|
3
6
|
|
4
7
|
describe Ramaze::Helper::Gestalt do
|
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
2
5
|
require 'ramaze/helper/gravatar'
|
3
6
|
|
4
7
|
describe Ramaze::Helper::Gravatar do
|
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
2
5
|
|
3
6
|
REALM = 'HttpDigestTestRealm'
|
4
7
|
|
@@ -26,7 +29,7 @@ class PlainTextController < Ramaze::Controller
|
|
26
29
|
|
27
30
|
protected
|
28
31
|
|
29
|
-
def httpdigest_lookup_plaintext_password
|
32
|
+
def httpdigest_lookup_plaintext_password(username)
|
30
33
|
username.reverse
|
31
34
|
end
|
32
35
|
end
|
@@ -48,85 +51,67 @@ class PasswordLookupController < Ramaze::Controller
|
|
48
51
|
end
|
49
52
|
|
50
53
|
describe Ramaze::Helper::HttpDigest do
|
51
|
-
|
52
|
-
|
53
|
-
def auth_for(got, uri, username, password, qop_type = "auth")
|
54
|
-
authorization = Rack::Auth::Digest::Params.parse(got.headers['WWW-Authenticate'])
|
55
|
-
|
56
|
-
cnonce = Digest::MD5.hexdigest(rand.to_s)
|
57
|
-
nc = 1
|
58
|
-
nonce = authorization['nonce']
|
59
|
-
|
60
|
-
authorization['cnonce'] = cnonce
|
61
|
-
authorization['nc'] = nc
|
62
|
-
authorization['uri'] = uri
|
63
|
-
authorization['username'] = username
|
64
|
-
authorization['qop'] = qop_type
|
65
|
-
|
66
|
-
ha1 = Digest::MD5.hexdigest([username, REALM, password].join(':'))
|
67
|
-
a2 = ['GET',uri]
|
68
|
-
a2 << Digest::MD5.hexdigest('') if qop_type == "auth-int"
|
69
|
-
ha2 = Digest::MD5.hexdigest( a2.join(':') )
|
54
|
+
describe 'headers' do
|
55
|
+
behaves_like :rack_test
|
70
56
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
def get_auth( uri, username, password, qop_type = "auth" )
|
77
|
-
got = nil
|
78
|
-
session do |mock|
|
79
|
-
got = mock.get( uri )
|
80
|
-
got.status.should == 401
|
81
|
-
got.body.should == 'Unauthorized'
|
82
|
-
got = mock.get( uri , 'HTTP_AUTHORIZATION' => auth_for(got, uri, username, password, qop_type ) )
|
83
|
-
end
|
84
|
-
got
|
85
|
-
end
|
86
|
-
|
87
|
-
it 'sends out all the required header information' do
|
88
|
-
session do |mock|
|
89
|
-
got = mock.get('/authenticate')
|
90
|
-
authorization = Rack::Auth::Digest::Params.parse(got.headers['WWW-Authenticate'])
|
57
|
+
it 'sends out all the required header information' do
|
58
|
+
get '/authenticate'
|
59
|
+
www_authenticate = last_response.headers['WWW-Authenticate']
|
60
|
+
authorization = Rack::Auth::Digest::Params.parse(www_authenticate)
|
91
61
|
authorization["opaque"].should.not.be.empty
|
92
62
|
authorization["nonce"].should.not.be.empty
|
93
63
|
authorization["realm"].should == REALM
|
94
64
|
authorization["qop"].should == "auth,auth-int"
|
95
|
-
|
96
|
-
|
65
|
+
|
66
|
+
digest_authorize 'foo', 'oof'
|
67
|
+
get '/authenticate'
|
68
|
+
last_response.headers.should.satisfy do |headers|
|
97
69
|
!headers.has_key?( "WWW-Authenticate" )
|
98
70
|
end
|
99
71
|
end
|
100
72
|
end
|
73
|
+
end
|
101
74
|
|
102
|
-
|
103
|
-
got = get_auth( '/authenticate', 'foo', 'oof' )
|
104
|
-
got.status.should == 200
|
105
|
-
got.body.should == "Hello foo"
|
106
|
-
end
|
75
|
+
__END__
|
107
76
|
|
108
|
-
|
109
|
-
|
110
|
-
got.status.should == 401
|
111
|
-
got.body.should == "Unauthorized"
|
112
|
-
end
|
77
|
+
describe 'Digest authentication' do
|
78
|
+
behaves_like :rack_test
|
113
79
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
80
|
+
it 'authenticates a user with a block' do
|
81
|
+
digest_authorize 'foo', 'oof'
|
82
|
+
get '/authenticate'
|
83
|
+
last_response.status.should == 200
|
84
|
+
last_response.body.should == "Hello foo"
|
85
|
+
end
|
119
86
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
87
|
+
it 'fails to authenticate an incorrect password with a block' do
|
88
|
+
digest_authorize 'foo', 'bar'
|
89
|
+
get '/authenticate'
|
90
|
+
last_response.status.should == 401
|
91
|
+
last_response.body.should == "Unauthorized"
|
92
|
+
end
|
124
93
|
end
|
125
94
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
95
|
+
describe 'Plaintext authentication' do
|
96
|
+
behaves_like :rack_test
|
97
|
+
|
98
|
+
it 'authenticates a user with the plaintext method' do
|
99
|
+
get '/plaintext/authenticate'
|
100
|
+
last_response.status.should == 401
|
101
|
+
last_response.body.should == 'Unauthorized'
|
102
|
+
|
103
|
+
authorize 'foo', 'oof'
|
104
|
+
get '/plaintext/authenticate'
|
105
|
+
last_response.status.should == 200
|
106
|
+
last_response.body.should == "Hello foo"
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'fails to authenticate an incorrect password with the plaintext method' do
|
110
|
+
authorize 'foo', 'bar'
|
111
|
+
get '/plaintext/authenticate'
|
112
|
+
last_response.status.should == 401
|
113
|
+
last_response.body.should == "Unauthorized"
|
114
|
+
end
|
130
115
|
end
|
131
116
|
|
132
117
|
it 'authenticates a user with the password lookup method' do
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# Copyright (c) 2009 Michael Fellinger m.fellinger@gmail.com
|
2
|
+
# All files in this distribution are subject to the terms of the Ruby license.
|
3
|
+
|
4
|
+
require File.expand_path('../../../../spec/helper', __FILE__)
|
5
|
+
|
6
|
+
class LayoutHelperOne < Ramaze::Controller
|
7
|
+
map '/one'
|
8
|
+
set_layout 'default'
|
9
|
+
|
10
|
+
def laid_out1; end
|
11
|
+
def laid_out2; end
|
12
|
+
def laid_out3; end
|
13
|
+
end
|
14
|
+
|
15
|
+
class LayoutHelperTwo < Ramaze::Controller
|
16
|
+
map '/two'
|
17
|
+
set_layout 'default' => [:laid_out1, :laid_out2]
|
18
|
+
|
19
|
+
def laid_out1; end
|
20
|
+
def laid_out2; end
|
21
|
+
|
22
|
+
def not_laid_out; end
|
23
|
+
end
|
24
|
+
|
25
|
+
class LayoutHelper < Ramaze::Controller
|
26
|
+
map '/three'
|
27
|
+
set_layout_except 'default' => [:not_laid_out1, :not_laid_out2]
|
28
|
+
|
29
|
+
def laid_out1; end
|
30
|
+
def laid_out2; end
|
31
|
+
|
32
|
+
def not_laid_out1; end
|
33
|
+
def not_laid_out2; end
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
describe Ramaze::Helper::Layout do
|
38
|
+
behaves_like :rack_test
|
39
|
+
|
40
|
+
it 'lays out all actions' do
|
41
|
+
get '/one/laid_out1'
|
42
|
+
last_response.status.should == 200
|
43
|
+
last_response.body.should.match /laid out/
|
44
|
+
get '/one/laid_out2'
|
45
|
+
last_response.status.should == 200
|
46
|
+
last_response.body.should.match /laid out/
|
47
|
+
get '/one/laid_out3'
|
48
|
+
last_response.status.should == 200
|
49
|
+
last_response.body.should.match /laid out/
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'lays out only a whitelist of actions' do
|
53
|
+
get '/two/laid_out1'
|
54
|
+
last_response.status.should == 200
|
55
|
+
last_response.body.should.match /laid out/
|
56
|
+
get '/two/laid_out2'
|
57
|
+
last_response.status.should == 200
|
58
|
+
last_response.body.should.match /laid out/
|
59
|
+
get '/two/not_laid_out'
|
60
|
+
last_response.status.should == 200
|
61
|
+
last_response.body.should.not.match /laid out/
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'lays out all actions except a blacklist' do
|
65
|
+
get '/three/laid_out1'
|
66
|
+
last_response.status.should == 200
|
67
|
+
last_response.body.should.match /laid out/
|
68
|
+
get '/three/laid_out2'
|
69
|
+
last_response.status.should == 200
|
70
|
+
last_response.body.should.match /laid out/
|
71
|
+
get '/three/not_laid_out1'
|
72
|
+
last_response.status.should == 200
|
73
|
+
last_response.body.should.not.match /laid out/
|
74
|
+
get '/three/not_laid_out2'
|
75
|
+
last_response.status.should == 200
|
76
|
+
last_response.body.should.not.match /laid out/
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|