sinatra 1.4.4 → 1.4.5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of sinatra might be problematic. Click here for more details.

@@ -1,3 +1,3 @@
1
1
  module Sinatra
2
- VERSION = '1.4.4'
2
+ VERSION = '1.4.5'
3
3
  end
@@ -7,6 +7,7 @@ Gem::Specification.new 'sinatra', Sinatra::VERSION do |s|
7
7
  s.authors = ["Blake Mizerany", "Ryan Tomayko", "Simon Rozet", "Konstantin Haase"]
8
8
  s.email = "sinatrarb@googlegroups.com"
9
9
  s.homepage = "http://www.sinatrarb.com/"
10
+ s.license = 'MIT'
10
11
  s.files = `git ls-files`.split("\n") - %w[.gitignore .travis.yml]
11
12
  s.test_files = s.files.select { |p| p =~ /^test\/.*_test.rb/ }
12
13
  s.extra_rdoc_files = s.files.select { |p| p =~ /^README/ } << 'LICENSE'
@@ -0,0 +1,72 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ begin
4
+ require 'asciidoctor'
5
+
6
+ class AsciidoctorTest < Test::Unit::TestCase
7
+ def asciidoc_app(&block)
8
+ mock_app do
9
+ set :views, File.dirname(__FILE__) + '/views'
10
+ get('/', &block)
11
+ end
12
+ get '/'
13
+ end
14
+
15
+ it 'renders inline AsciiDoc strings' do
16
+ asciidoc_app { asciidoc '== Hiya' }
17
+ assert ok?
18
+ assert_match %r{<h2.*?>Hiya</h2>}, body
19
+ end
20
+
21
+ it 'uses the correct engine' do
22
+ engine = Tilt::AsciidoctorTemplate
23
+ assert_equal engine, Tilt[:ad]
24
+ assert_equal engine, Tilt[:adoc]
25
+ assert_equal engine, Tilt[:asciidoc]
26
+ end
27
+
28
+ it 'renders .asciidoc files in views path' do
29
+ asciidoc_app { asciidoc :hello }
30
+ assert ok?
31
+ assert_match %r{<h2.*?>Hello from AsciiDoc</h2>}, body
32
+ end
33
+
34
+ it 'raises error if template not found' do
35
+ mock_app { get('/') { asciidoc :no_such_template } }
36
+ assert_raise(Errno::ENOENT) { get('/') }
37
+ end
38
+
39
+ it 'renders with inline layouts' do
40
+ mock_app do
41
+ layout { 'THIS. IS. #{yield.upcase}!' }
42
+ get('/') { asciidoc 'Sparta', :layout_engine => :str }
43
+ end
44
+ get '/'
45
+ assert ok?
46
+ assert_include body, 'THIS. IS.'
47
+ assert_include body, '<P>SPARTA</P>'
48
+ end
49
+
50
+ it 'renders with file layouts' do
51
+ asciidoc_app do
52
+ asciidoc 'Hello World', :layout => :layout2, :layout_engine => :erb
53
+ end
54
+ assert ok?
55
+ assert_include body, 'ERB Layout!'
56
+ assert_include body, '<p>Hello World</p>'
57
+ end
58
+
59
+ it 'can be used in a nested fashion for partials and whatnot' do
60
+ mock_app do
61
+ template(:inner) { 'hi' }
62
+ template(:outer) { '<outer><%= asciidoc :inner %></outer>' }
63
+ get('/') { erb :outer }
64
+ end
65
+ get '/'
66
+ assert ok?
67
+ assert_match %r{<outer>.*<p.*?>hi</p>.*</outer>}m, body
68
+ end
69
+ end
70
+ rescue LoadError
71
+ warn "#{$!.to_s}: skipping asciidoc tests"
72
+ end
@@ -334,13 +334,13 @@ class HelpersTest < Test::Unit::TestCase
334
334
  it 'should not reset the content-type to html for error handlers' do
335
335
  mock_app do
336
336
  disable :raise_errors
337
- before { content_type "application/json;charset=utf-8" }
337
+ before { content_type "application/json" }
338
338
  not_found { JSON.dump("error" => "Not Found") }
339
339
  end
340
340
 
341
341
  get '/'
342
342
  assert_equal 404, status
343
- assert_equal 'application/json;charset=utf-8', response.content_type
343
+ assert_equal 'application/json', response.content_type
344
344
  end
345
345
 
346
346
  it 'should not invoke error handler when halting with 500 inside an error handler' do
@@ -665,7 +665,7 @@ class HelpersTest < Test::Unit::TestCase
665
665
  assert_equal content_type(:xml), 'application/xml;charset=utf-8'
666
666
  assert_equal content_type(:xhtml), 'application/xhtml+xml;charset=utf-8'
667
667
  assert_equal content_type(:js), 'application/javascript;charset=utf-8'
668
- assert_equal content_type(:json), 'application/json;charset=utf-8'
668
+ assert_equal content_type(:json), 'application/json'
669
669
  assert_equal content_type(:bar), 'application/bar'
670
670
  assert_equal content_type(:png), 'image/png'
671
671
  assert_equal content_type(:baz), 'application/baz;charset=utf-8'
@@ -0,0 +1,68 @@
1
+ require File.expand_path('../helper', __FILE__)
2
+
3
+ begin
4
+ require 'wikicloth'
5
+
6
+ class MediaWikiTest < Test::Unit::TestCase
7
+ def mediawiki_app(&block)
8
+ mock_app do
9
+ set :views, File.dirname(__FILE__) + '/views'
10
+ get('/', &block)
11
+ end
12
+ get '/'
13
+ end
14
+
15
+ it 'supports both .mw and .mediawiki extensions' do
16
+ assert_equal Tilt[:mw], Tilt[:mediawiki]
17
+ end
18
+
19
+ it 'renders inline mediawiki strings' do
20
+ mediawiki_app { mediawiki "''Hiya''" }
21
+ assert ok?
22
+ assert_include body, '<i>Hiya</i>'
23
+ end
24
+
25
+ it 'renders .mediawiki files in views path' do
26
+ mediawiki_app { mediawiki :hello }
27
+ assert ok?
28
+ assert_include body, "<i>Hello from MediaWiki</i>"
29
+ end
30
+
31
+ it 'raises error if template not found' do
32
+ mock_app { get('/') { mediawiki :no_such_template } }
33
+ assert_raise(Errno::ENOENT) { get('/') }
34
+ end
35
+
36
+ it 'renders with inline layouts' do
37
+ mock_app do
38
+ layout { 'THIS. IS. #{yield.upcase}!' }
39
+ get('/') { mediawiki 'Sparta', :layout_engine => :str }
40
+ end
41
+ get '/'
42
+ assert ok?
43
+ assert_like 'THIS. IS. <P>SPARTA</P>!', body
44
+ end
45
+
46
+ it 'renders with file layouts' do
47
+ mediawiki_app do
48
+ mediawiki 'Hello World', :layout => :layout2, :layout_engine => :erb
49
+ end
50
+ assert ok?
51
+ assert_body "ERB Layout!\n<p>Hello World</p>"
52
+ end
53
+
54
+ it 'can be used in a nested fashion for partials and whatnot' do
55
+ mock_app do
56
+ template(:inner) { "hi" }
57
+ template(:outer) { "<outer><%= mediawiki :inner %></outer>" }
58
+ get('/') { erb :outer }
59
+ end
60
+
61
+ get '/'
62
+ assert ok?
63
+ assert_like '<outer><p>hi</p></outer>', body
64
+ end
65
+ end
66
+ rescue LoadError
67
+ warn "#{$!.to_s}: skipping mediawiki tests"
68
+ end
@@ -89,4 +89,9 @@ class RequestTest < Test::Unit::TestCase
89
89
  assert request.accept?('text/html')
90
90
  assert_equal '*/*', request.preferred_type.to_s
91
91
  end
92
+
93
+ it 'will not accept types not specified in HTTP_ACCEPT when HTTP_ACCEPT is provided' do
94
+ request = Sinatra::Request.new 'HTTP_ACCEPT' => 'application/json'
95
+ assert !request.accept?('text/html')
96
+ end
92
97
  end
@@ -90,7 +90,10 @@ class RoutingTest < Test::Unit::TestCase
90
90
  end
91
91
 
92
92
  it "it handles encoded slashes correctly" do
93
- mock_app { get("/:a") { |a| a } }
93
+ mock_app {
94
+ set :protection, :except => :path_traversal
95
+ get("/:a") { |a| a }
96
+ }
94
97
  get '/foo%2Fbar'
95
98
  assert_equal 200, status
96
99
  assert_body "foo/bar"
@@ -1,7 +1,6 @@
1
1
  require File.expand_path('../helper', __FILE__)
2
2
 
3
3
  begin
4
- raise LoadError, 'sass not supported on Ruby 2.0' if RUBY_VERSION >= '2.0'
5
4
  require 'sass'
6
5
 
7
6
  class SassTest < Test::Unit::TestCase
@@ -1,7 +1,6 @@
1
1
  require File.expand_path('../helper', __FILE__)
2
2
 
3
3
  begin
4
- raise LoadError, 'sass not supported on Ruby 2.0' if RUBY_VERSION >= '2.0'
5
4
  require 'sass'
6
5
 
7
6
  class ScssTest < Test::Unit::TestCase
@@ -18,7 +18,7 @@ class StaticTest < Test::Unit::TestCase
18
18
 
19
19
  it 'produces a body that can be iterated over multiple times' do
20
20
  env = Rack::MockRequest.env_for("/#{File.basename(__FILE__)}")
21
- status, headers, body = @app.call(env)
21
+ _, _, body = @app.call(env)
22
22
  buf1, buf2 = [], []
23
23
  body.each { |part| buf1 << part }
24
24
  body.each { |part| buf2 << part }
@@ -28,7 +28,7 @@ class StaticTest < Test::Unit::TestCase
28
28
 
29
29
  it 'sets the sinatra.static_file env variable if served' do
30
30
  env = Rack::MockRequest.env_for("/#{File.basename(__FILE__)}")
31
- status, headers, body = @app.call(env)
31
+ @app.call(env)
32
32
  assert_equal File.expand_path(__FILE__), env['sinatra.static_file']
33
33
  end
34
34
 
@@ -192,7 +192,7 @@ class StaticTest < Test::Unit::TestCase
192
192
 
193
193
  it 'does not include static cache control headers by default' do
194
194
  env = Rack::MockRequest.env_for("/#{File.basename(__FILE__)}")
195
- status, headers, body = @app.call(env)
195
+ _, headers, _ = @app.call(env)
196
196
  assert !headers.has_key?('Cache-Control')
197
197
  end
198
198
 
@@ -216,4 +216,21 @@ class StaticTest < Test::Unit::TestCase
216
216
  )
217
217
  end
218
218
 
219
- end
219
+ it 'renders static assets with custom status via options' do
220
+ mock_app do
221
+ set :static, true
222
+ set :public_folder, File.dirname(__FILE__)
223
+
224
+ post '/*' do
225
+ static!(:status => params[:status])
226
+ end
227
+ end
228
+
229
+ post "/#{File.basename(__FILE__)}?status=422"
230
+ assert_equal response.status, 422
231
+ assert_equal File.read(__FILE__), body
232
+ assert_equal File.size(__FILE__).to_s, response['Content-Length']
233
+ assert response.headers.include?('Last-Modified')
234
+ end
235
+
236
+ end
@@ -0,0 +1 @@
1
+ == Hello from AsciiDoc
@@ -0,0 +1 @@
1
+ ''Hello from MediaWiki''
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.4
4
+ version: 1.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Mizerany
@@ -11,54 +11,54 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-10-21 00:00:00.000000000 Z
14
+ date: 2014-04-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rack
18
18
  requirement: !ruby/object:Gem::Requirement
19
19
  requirements:
20
- - - ~>
20
+ - - "~>"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '1.4'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ~>
27
+ - - "~>"
28
28
  - !ruby/object:Gem::Version
29
29
  version: '1.4'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: tilt
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  requirements:
34
- - - ~>
34
+ - - "~>"
35
35
  - !ruby/object:Gem::Version
36
36
  version: '1.3'
37
- - - '>='
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: 1.3.4
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
- - - ~>
44
+ - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '1.3'
47
- - - '>='
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: 1.3.4
50
50
  - !ruby/object:Gem::Dependency
51
51
  name: rack-protection
52
52
  requirement: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - ~>
54
+ - - "~>"
55
55
  - !ruby/object:Gem::Version
56
56
  version: '1.4'
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ~>
61
+ - - "~>"
62
62
  - !ruby/object:Gem::Version
63
63
  version: '1.4'
64
64
  description: Sinatra is a DSL for quickly creating web applications in Ruby with minimal
@@ -71,7 +71,7 @@ extra_rdoc_files:
71
71
  - README.es.md
72
72
  - README.fr.md
73
73
  - README.hu.md
74
- - README.jp.md
74
+ - README.ja.md
75
75
  - README.ko.md
76
76
  - README.md
77
77
  - README.pt-br.md
@@ -80,7 +80,7 @@ extra_rdoc_files:
80
80
  - README.zh.md
81
81
  - LICENSE
82
82
  files:
83
- - .yardopts
83
+ - ".yardopts"
84
84
  - AUTHORS
85
85
  - CHANGES
86
86
  - Gemfile
@@ -89,7 +89,7 @@ files:
89
89
  - README.es.md
90
90
  - README.fr.md
91
91
  - README.hu.md
92
- - README.jp.md
92
+ - README.ja.md
93
93
  - README.ko.md
94
94
  - README.md
95
95
  - README.pt-br.md
@@ -108,6 +108,7 @@ files:
108
108
  - lib/sinatra/show_exceptions.rb
109
109
  - lib/sinatra/version.rb
110
110
  - sinatra.gemspec
111
+ - test/asciidoctor_test.rb
111
112
  - test/base_test.rb
112
113
  - test/builder_test.rb
113
114
  - test/coffee_test.rb
@@ -130,6 +131,7 @@ files:
130
131
  - test/mapped_error_test.rb
131
132
  - test/markaby_test.rb
132
133
  - test/markdown_test.rb
134
+ - test/mediawiki_test.rb
133
135
  - test/middleware_test.rb
134
136
  - test/nokogiri_test.rb
135
137
  - test/public/favicon.ico
@@ -164,6 +166,7 @@ files:
164
166
  - test/views/error.sass
165
167
  - test/views/explicitly_nested.str
166
168
  - test/views/foo/hello.test
169
+ - test/views/hello.asciidoc
167
170
  - test/views/hello.builder
168
171
  - test/views/hello.coffee
169
172
  - test/views/hello.creole
@@ -173,6 +176,7 @@ files:
173
176
  - test/views/hello.liquid
174
177
  - test/views/hello.mab
175
178
  - test/views/hello.md
179
+ - test/views/hello.mediawiki
176
180
  - test/views/hello.nokogiri
177
181
  - test/views/hello.rabl
178
182
  - test/views/hello.radius
@@ -203,36 +207,38 @@ files:
203
207
  - test/wlang_test.rb
204
208
  - test/yajl_test.rb
205
209
  homepage: http://www.sinatrarb.com/
206
- licenses: []
210
+ licenses:
211
+ - MIT
207
212
  metadata: {}
208
213
  post_install_message:
209
214
  rdoc_options:
210
- - --line-numbers
211
- - --inline-source
212
- - --title
215
+ - "--line-numbers"
216
+ - "--inline-source"
217
+ - "--title"
213
218
  - Sinatra
214
- - --main
219
+ - "--main"
215
220
  - README.rdoc
216
- - --encoding=UTF-8
221
+ - "--encoding=UTF-8"
217
222
  require_paths:
218
223
  - lib
219
224
  required_ruby_version: !ruby/object:Gem::Requirement
220
225
  requirements:
221
- - - '>='
226
+ - - ">="
222
227
  - !ruby/object:Gem::Version
223
228
  version: '0'
224
229
  required_rubygems_version: !ruby/object:Gem::Requirement
225
230
  requirements:
226
- - - '>='
231
+ - - ">="
227
232
  - !ruby/object:Gem::Version
228
233
  version: '0'
229
234
  requirements: []
230
235
  rubyforge_project:
231
- rubygems_version: 2.0.7
236
+ rubygems_version: 2.0.14
232
237
  signing_key:
233
238
  specification_version: 4
234
239
  summary: Classy web-development dressed in a DSL
235
240
  test_files:
241
+ - test/asciidoctor_test.rb
236
242
  - test/base_test.rb
237
243
  - test/builder_test.rb
238
244
  - test/coffee_test.rb
@@ -251,6 +257,7 @@ test_files:
251
257
  - test/mapped_error_test.rb
252
258
  - test/markaby_test.rb
253
259
  - test/markdown_test.rb
260
+ - test/mediawiki_test.rb
254
261
  - test/middleware_test.rb
255
262
  - test/nokogiri_test.rb
256
263
  - test/rabl_test.rb