ramaze 2012.12.08 → 2023.01.06

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +1 -1
  3. data/examples/app/whywiki/spec/whywiki.rb +22 -24
  4. data/examples/app/whywiki/start.rb +10 -9
  5. data/examples/app/whywiki/{template → view}/edit.xhtml +2 -2
  6. data/examples/app/whywiki/view/show.xhtml +20 -0
  7. data/examples/app/wikore/spec/wikore.rb +1 -1
  8. data/guide/AUTHORS +11 -3
  9. data/guide/CHANGELOG +3761 -3599
  10. data/guide/general/sessions.md +42 -0
  11. data/lib/proto/Gemfile +2 -2
  12. data/lib/ramaze/cache/memcache.rb +3 -3
  13. data/lib/ramaze/cache/moneta.rb +143 -0
  14. data/lib/ramaze/cache/redis.rb +8 -11
  15. data/lib/ramaze/cache/sequel.rb +2 -2
  16. data/lib/ramaze/cache.rb +1 -0
  17. data/lib/ramaze/files.rb +1 -1
  18. data/lib/ramaze/helper/paginate.rb +5 -0
  19. data/lib/ramaze/helper/request_accessor.rb +3 -1
  20. data/lib/ramaze/helper/stack.rb +1 -1
  21. data/lib/ramaze/helper/upload.rb +1 -1
  22. data/lib/ramaze/log/syslog.rb +1 -1
  23. data/lib/ramaze/request.rb +2 -2
  24. data/lib/ramaze/snippets.rb +0 -1
  25. data/lib/ramaze/version.rb +3 -1
  26. data/lib/ramaze/view/nagoro/render_partial.rb +1 -1
  27. data/lib/ramaze.rb +1 -1
  28. data/ramaze.gemspec +11 -12
  29. data/spec/ramaze/cache/moneta.rb +53 -0
  30. data/spec/ramaze/cache/redis.rb +1 -1
  31. data/spec/ramaze/dispatcher/directory.rb +14 -7
  32. data/spec/ramaze/dispatcher/file.rb +0 -5
  33. data/spec/ramaze/error.rb +13 -17
  34. data/spec/ramaze/helper/paginate.rb +25 -0
  35. data/spec/ramaze/log/syslog.rb +11 -2
  36. data/spec/ramaze/session/redis.rb +2 -2
  37. data/spec/ramaze/view/haml.rb +3 -3
  38. data/spec/ramaze/view/slim.rb +1 -1
  39. metadata +88 -158
  40. data/.gems +0 -28
  41. data/.gitignore +0 -14
  42. data/.mailmap +0 -34
  43. data/.rvmrc +0 -2
  44. data/.travis.yml +0 -16
  45. data/.yardopts +0 -14
  46. data/examples/app/blog/public/.htaccess +0 -24
  47. data/examples/app/whywiki/template/show.xhtml +0 -18
  48. data/lib/ramaze/cache/localmemcache.rb +0 -53
  49. data/lib/ramaze/snippets/ramaze/lru_hash.rb +0 -247
  50. data/spec/ramaze/cache/localmemcache.rb +0 -50
  51. data/spec/ramaze/session/localmemcache.rb +0 -60
data/spec/ramaze/error.rb CHANGED
@@ -2,8 +2,7 @@
2
2
  # All files in this distribution are subject to the terms of the MIT license.
3
3
 
4
4
  require File.expand_path('../../../spec/helper', __FILE__)
5
- require 'rexml/document'
6
- require 'rexml/xpath'
5
+ require 'nokogiri'
7
6
 
8
7
  class SpecError < Ramaze::Controller
9
8
  map '/'
@@ -40,15 +39,14 @@ describe 'Error handling' do
40
39
  Ramaze.options.mode = :dev
41
40
 
42
41
  it 'uses Rack::ShowException to display errors' do
43
- got = get('/raises')
44
- [got.status, got['Content-Type']].should == [500, 'text/html']
45
-
46
- # we use this xpath notation because otherwise rexml is really slow...
47
- doc = REXML::Document.new(got.body)
48
- REXML::XPath.first(doc, "/html/body/div[1]/h1").text.
49
- should == "NameError at /raises"
50
- REXML::XPath.first(doc, "/html/body/div[4]/p/code").text.
51
- should == "Rack::ShowExceptions"
42
+ got = get('/raises', {}, {'HTTP_ACCEPT' => 'text/html'})
43
+ got.status.should == 500
44
+ got['Content-Type'].should == 'text/html'
45
+
46
+ doc = Nokogiri::HTML(got.body)
47
+ doc.at("#summary").text.should.match(/NameError at \/raises/)
48
+ doc.at("#explanation").text.strip.should ==
49
+ "You're seeing this error because you use Rack::ShowExceptions."
52
50
  end
53
51
 
54
52
  it 'uses original action_missing when no action was found' do
@@ -78,11 +76,9 @@ describe 'Error handling' do
78
76
  got = get('/empty')
79
77
  [got.status, got['Content-Type']].should == [404, 'text/html']
80
78
 
81
- # we use this xpath notation because otherwise rexml is really slow...
82
- doc = REXML::Document.new(got.body)
83
- REXML::XPath.first(doc, "/html/body/div[1]/h1").text.strip.
84
- should == "Not Found"
85
- REXML::XPath.first(doc, "/html/body/div[3]/p/code").text.
86
- should == "Rack::ShowStatus"
79
+ doc = Nokogiri::HTML(got.body)
80
+ doc.at("#info").text.strip.should == "Not Found"
81
+ doc.at("#explanation").text.strip.should ==
82
+ "You're seeing this error because you use Rack::ShowStatus."
87
83
  end
88
84
  end
@@ -32,6 +32,13 @@ class SpecHelperPaginateArray < Ramaze::Controller
32
32
  pager.each{|item| out << item }
33
33
  out.inspect
34
34
  end
35
+
36
+ def preserve_params
37
+ request.params['single'] = 'zero'
38
+ request.params['multiple'] = %w[ one two three ]
39
+ pager = paginate(ALPHA)
40
+ pager.navigation
41
+ end
35
42
  end
36
43
 
37
44
  describe Ramaze::Helper::Paginate do
@@ -275,5 +282,23 @@ describe Ramaze::Helper::Paginate do
275
282
 
276
283
  end
277
284
 
285
+ it 'preserves single value params' do
286
+ doc = Nokogiri::HTML(get("/array/preserve_params").body)
287
+ params = doc.search("//a").first[:href].split('?').last.split('&')
288
+ params.should.include 'single=zero'
289
+ params.should.not.include 'single[]'.escape(:cgi) + '=zero'
290
+ end
291
+
292
+ it 'preserves multi value params' do
293
+ doc = Nokogiri::HTML(get("/array/preserve_params").body)
294
+ params = doc.search("//a").first[:href].split('?').last.split('&')
295
+ params.should.not.include 'multiple=one'
296
+ params.should.not.include 'multiple=two'
297
+ params.should.not.include 'multiple=three'
298
+ params.should.include 'multiple[]'.escape(:cgi) + '=one'
299
+ params.should.include 'multiple[]'.escape(:cgi) + '=two'
300
+ params.should.include 'multiple[]'.escape(:cgi) + '=three'
301
+ end
302
+
278
303
  end
279
304
  end
@@ -56,8 +56,17 @@ describe 'Syslog' do
56
56
  }
57
57
  logpipe[1].close
58
58
  Process.waitpid(child)
59
-
60
- logpipe[0].gets.should == "ramaze_syslog_test[#{child}]: #{msg}\n"
59
+ label = case priority
60
+ # when 'debug', 'info', 'error'
61
+ # priority
62
+ when :dev
63
+ 'debug'
64
+ when :warn
65
+ 'warning'
66
+ else
67
+ priority.to_s
68
+ end
69
+ logpipe[0].gets.slice(/ramaze.*/).should == "ramaze_syslog_test[#{child}] <#{label.capitalize}>: #{msg}"
61
70
  end
62
71
 
63
72
  it 'should handle debug' do
@@ -2,8 +2,8 @@ require File.expand_path('../../../../spec/helper', __FILE__)
2
2
  spec_require 'redis'
3
3
 
4
4
  spec_precondition 'Redis is running' do
5
- cache = Redis.new
6
- cache['active'] = true
5
+ cache = Redis.new
6
+ "OK" == cache.set('testkey', 'testval')
7
7
  end
8
8
 
9
9
  class SpecSession < Ramaze::Controller
@@ -72,7 +72,7 @@ describe Ramaze::View::Haml do
72
72
  <li>
73
73
  <a href='/external'>External template</a>
74
74
  </li>
75
- </ul>"
75
+ </ul>".gsub(/\n\s+/, "\n")
76
76
  end
77
77
 
78
78
  should 'render external template' do
@@ -87,7 +87,7 @@ describe Ramaze::View::Haml do
87
87
  <body>
88
88
  <h1>Haml Template</h1>
89
89
  </body>
90
- </html>"
90
+ </html>".gsub(/\n\s+/, "\n")
91
91
  end
92
92
 
93
93
  should 'render external template with instance variables' do
@@ -97,7 +97,7 @@ describe Ramaze::View::Haml do
97
97
  got.body.strip.should ==
98
98
  "<div>
99
99
  3
100
- </div>"
100
+ </div>".gsub(/\n\s+/, "\n")
101
101
  end
102
102
 
103
103
  should 'render the wrapped view twice even with caching' do
@@ -39,7 +39,7 @@ describe 'Ramaze::View::Slim' do
39
39
  end
40
40
 
41
41
  should 'render an external template with variables' do
42
- got = get('/external')
42
+ got = get('/external_vars')
43
43
 
44
44
  got.status.should == 200
45
45
  got['Content-Type'].should == 'text/html'