padrino-core 0.16.0.pre3 → 0.16.0
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.
- checksums.yaml +4 -4
- data/README.rdoc +8 -8
- data/Rakefile +1 -1
- data/bin/padrino +1 -1
- data/lib/padrino-core/application/application_setup.rb +28 -26
- data/lib/padrino-core/application/authenticity_token.rb +3 -2
- data/lib/padrino-core/application/flash.rb +4 -5
- data/lib/padrino-core/application/params_protection.rb +34 -37
- data/lib/padrino-core/application/routing.rb +165 -164
- data/lib/padrino-core/application/show_exceptions.rb +5 -7
- data/lib/padrino-core/application.rb +4 -4
- data/lib/padrino-core/caller.rb +28 -30
- data/lib/padrino-core/cli/adapter.rb +4 -4
- data/lib/padrino-core/cli/base.rb +31 -32
- data/lib/padrino-core/cli/binstub.rb +9 -8
- data/lib/padrino-core/cli/console.rb +1 -1
- data/lib/padrino-core/cli/launcher.rb +45 -42
- data/lib/padrino-core/cli/rake.rb +16 -14
- data/lib/padrino-core/cli/rake_tasks.rb +18 -20
- data/lib/padrino-core/command.rb +1 -1
- data/lib/padrino-core/ext/sinatra.rb +3 -2
- data/lib/padrino-core/filter.rb +3 -3
- data/lib/padrino-core/loader.rb +10 -12
- data/lib/padrino-core/logger.rb +87 -78
- data/lib/padrino-core/mounter/application_extension.rb +2 -2
- data/lib/padrino-core/mounter.rb +33 -34
- data/lib/padrino-core/path_router/compiler.rb +8 -8
- data/lib/padrino-core/path_router/matcher.rb +11 -11
- data/lib/padrino-core/path_router/route.rb +15 -15
- data/lib/padrino-core/path_router.rb +4 -3
- data/lib/padrino-core/reloader/rack.rb +1 -1
- data/lib/padrino-core/reloader/storage.rb +12 -11
- data/lib/padrino-core/reloader.rb +18 -19
- data/lib/padrino-core/router.rb +14 -14
- data/lib/padrino-core/server.rb +20 -24
- data/lib/padrino-core/tasks.rb +0 -1
- data/lib/padrino-core/version.rb +1 -1
- data/lib/padrino-core.rb +9 -10
- data/padrino-core.gemspec +18 -17
- data/test/fixtures/app_gem/app_gem.gemspec +8 -7
- data/test/fixtures/app_gem/lib/app_gem/version.rb +1 -1
- data/test/fixtures/apps/complex.rb +6 -6
- data/test/fixtures/apps/concerned/app.rb +1 -1
- data/test/fixtures/apps/custom_dependencies/custom_dependencies.rb +3 -3
- data/test/fixtures/apps/demo_app.rb +1 -1
- data/test/fixtures/apps/demo_demo.rb +1 -1
- data/test/fixtures/apps/demo_project/api/app.rb +1 -1
- data/test/fixtures/apps/demo_project/app.rb +1 -1
- data/test/fixtures/apps/helpers/class_methods_helpers.rb +1 -0
- data/test/fixtures/apps/helpers/instance_methods_helpers.rb +1 -0
- data/test/fixtures/apps/helpers/system_helpers.rb +0 -1
- data/test/fixtures/apps/lib/myklass/mysubklass.rb +2 -2
- data/test/fixtures/apps/mountable_apps/rack_apps.rb +7 -7
- data/test/fixtures/apps/precompiled_app.rb +6 -5
- data/test/fixtures/apps/simple.rb +5 -5
- data/test/fixtures/apps/static.rb +2 -2
- data/test/fixtures/apps/stealthy/app.rb +1 -1
- data/test/fixtures/apps/stealthy/helpers/stealthy_class_helpers.rb +1 -1
- data/test/fixtures/apps/system.rb +1 -1
- data/test/fixtures/apps/system_class_methods_demo.rb +1 -1
- data/test/fixtures/apps/system_instance_methods_demo.rb +1 -1
- data/test/fixtures/dependencies/a.rb +1 -1
- data/test/fixtures/dependencies/b.rb +1 -1
- data/test/fixtures/dependencies/c.rb +1 -1
- data/test/fixtures/dependencies/circular/e.rb +2 -1
- data/test/fixtures/dependencies/d.rb +1 -1
- data/test/fixtures/dependencies/linear/i.rb +1 -1
- data/test/fixtures/dependencies/nested/l.rb +2 -2
- data/test/fixtures/dependencies/nested/m.rb +1 -1
- data/test/fixtures/dependencies/nested/qqq.rb +2 -2
- data/test/fixtures/dependencies/nested/rrr.rb +1 -1
- data/test/fixtures/dependencies/nested/sss.rb +1 -1
- data/test/fixtures/reloadable_apps/external/app/app.rb +0 -1
- data/test/fixtures/reloadable_apps/external/app/controllers/base.rb +1 -2
- data/test/fixtures/reloadable_apps/main/app.rb +2 -2
- data/test/helper.rb +2 -2
- data/test/test_application.rb +59 -60
- data/test/test_configuration.rb +2 -2
- data/test/test_core.rb +13 -13
- data/test/test_csrf_protection.rb +67 -63
- data/test/test_dependencies.rb +33 -34
- data/test/test_filters.rb +52 -53
- data/test/test_flash.rb +18 -18
- data/test/test_locale.rb +2 -2
- data/test/test_logger.rb +65 -65
- data/test/test_mounter.rb +133 -123
- data/test/test_params_protection.rb +40 -40
- data/test/test_reloader_complex.rb +24 -24
- data/test/test_reloader_external.rb +10 -10
- data/test/test_reloader_simple.rb +26 -23
- data/test/test_reloader_storage.rb +9 -12
- data/test/test_reloader_system.rb +29 -29
- data/test/test_restful_routing.rb +19 -19
- data/test/test_router.rb +126 -145
- data/test/test_routing.rb +897 -909
- metadata +7 -7
data/test/test_dependencies.rb
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative 'helper'
|
|
2
2
|
|
|
3
|
-
describe
|
|
3
|
+
describe 'Dependencies' do
|
|
4
4
|
describe 'when we require a dependency that have another dependency' do
|
|
5
5
|
before do
|
|
6
6
|
@log_level = Padrino::Logger::Config[:test]
|
|
7
7
|
@io = StringIO.new
|
|
8
|
-
Padrino::Logger::Config[:test] = { :
|
|
8
|
+
Padrino::Logger::Config[:test] = { log_level: :error, stream: @io }
|
|
9
9
|
Padrino::Logger.setup!
|
|
10
10
|
end
|
|
11
11
|
|
|
@@ -18,10 +18,10 @@ describe "Dependencies" do
|
|
|
18
18
|
capture_io do
|
|
19
19
|
assert_raises(RuntimeError) do
|
|
20
20
|
Padrino.require_dependencies(
|
|
21
|
-
Padrino.root(
|
|
22
|
-
Padrino.root(
|
|
23
|
-
Padrino.root(
|
|
24
|
-
Padrino.root(
|
|
21
|
+
Padrino.root('fixtures/dependencies/a.rb'),
|
|
22
|
+
Padrino.root('fixtures/dependencies/b.rb'),
|
|
23
|
+
Padrino.root('fixtures/dependencies/c.rb'),
|
|
24
|
+
Padrino.root('fixtures/dependencies/d.rb')
|
|
25
25
|
)
|
|
26
26
|
end
|
|
27
27
|
end
|
|
@@ -32,35 +32,35 @@ describe "Dependencies" do
|
|
|
32
32
|
it 'should resolve dependency problems' do
|
|
33
33
|
capture_io do
|
|
34
34
|
Padrino.require_dependencies(
|
|
35
|
-
Padrino.root(
|
|
36
|
-
Padrino.root(
|
|
37
|
-
Padrino.root(
|
|
35
|
+
Padrino.root('fixtures/dependencies/a.rb'),
|
|
36
|
+
Padrino.root('fixtures/dependencies/b.rb'),
|
|
37
|
+
Padrino.root('fixtures/dependencies/c.rb')
|
|
38
38
|
)
|
|
39
39
|
end
|
|
40
|
-
assert_equal [
|
|
41
|
-
assert_equal
|
|
42
|
-
assert_equal
|
|
40
|
+
assert_equal %w[B C], A_result
|
|
41
|
+
assert_equal 'C', B_result
|
|
42
|
+
assert_equal '', @io.string
|
|
43
43
|
end
|
|
44
44
|
|
|
45
45
|
it 'should remove partially loaded constants' do
|
|
46
46
|
capture_io do
|
|
47
47
|
Padrino.require_dependencies(
|
|
48
|
-
Padrino.root(
|
|
49
|
-
Padrino.root(
|
|
50
|
-
Padrino.root(
|
|
48
|
+
Padrino.root('fixtures/dependencies/circular/e.rb'),
|
|
49
|
+
Padrino.root('fixtures/dependencies/circular/f.rb'),
|
|
50
|
+
Padrino.root('fixtures/dependencies/circular/g.rb')
|
|
51
51
|
)
|
|
52
52
|
end
|
|
53
|
-
assert_equal [
|
|
54
|
-
assert_equal
|
|
53
|
+
assert_equal ['name'], F.fields
|
|
54
|
+
assert_equal '', @io.string
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it 'should not silence LoadError raised in dependencies excluded from reloading' do
|
|
58
58
|
capture_io do
|
|
59
59
|
assert_raises(LoadError) do
|
|
60
|
-
Padrino::Reloader.exclude << Padrino.root(
|
|
60
|
+
Padrino::Reloader.exclude << Padrino.root('fixtures/dependencies/linear/h.rb')
|
|
61
61
|
Padrino.require_dependencies(
|
|
62
|
-
Padrino.root(
|
|
63
|
-
Padrino.root(
|
|
62
|
+
Padrino.root('fixtures/dependencies/linear/h.rb'),
|
|
63
|
+
Padrino.root('fixtures/dependencies/linear/i.rb')
|
|
64
64
|
)
|
|
65
65
|
end
|
|
66
66
|
end
|
|
@@ -69,20 +69,19 @@ describe "Dependencies" do
|
|
|
69
69
|
it 'should not remove constants that are newly commited in nested require_dependencies' do
|
|
70
70
|
capture_io do
|
|
71
71
|
Padrino.require_dependencies(
|
|
72
|
-
Padrino.root(
|
|
73
|
-
Padrino.root(
|
|
74
|
-
Padrino.root(
|
|
72
|
+
Padrino.root('fixtures/dependencies/nested/j.rb'),
|
|
73
|
+
Padrino.root('fixtures/dependencies/nested/k.rb'),
|
|
74
|
+
Padrino.root('fixtures/dependencies/nested/l.rb')
|
|
75
75
|
)
|
|
76
76
|
end
|
|
77
|
-
assert_equal
|
|
77
|
+
assert_equal 'hello', M.hello
|
|
78
78
|
end
|
|
79
79
|
|
|
80
|
-
|
|
81
|
-
describe "change log level for :devel" do
|
|
80
|
+
describe 'change log level for :devel' do
|
|
82
81
|
before do
|
|
83
82
|
@log_level_devel = Padrino::Logger::Config[:test]
|
|
84
83
|
@io = StringIO.new
|
|
85
|
-
Padrino::Logger::Config[:test] = { :
|
|
84
|
+
Padrino::Logger::Config[:test] = { log_level: :devel, stream: @io }
|
|
86
85
|
Padrino::Logger.setup!
|
|
87
86
|
end
|
|
88
87
|
|
|
@@ -94,14 +93,14 @@ describe "Dependencies" do
|
|
|
94
93
|
it 'should resolve interdependence by out/in side nested require_dependencies' do
|
|
95
94
|
capture_io do
|
|
96
95
|
Padrino.require_dependencies(
|
|
97
|
-
Padrino.root(
|
|
98
|
-
Padrino.root(
|
|
99
|
-
Padrino.root(
|
|
96
|
+
Padrino.root('fixtures/dependencies/nested/ooo.rb'),
|
|
97
|
+
Padrino.root('fixtures/dependencies/nested/ppp.rb'),
|
|
98
|
+
Padrino.root('fixtures/dependencies/nested/qqq.rb')
|
|
100
99
|
)
|
|
101
100
|
end
|
|
102
|
-
assert_equal
|
|
103
|
-
assert_equal
|
|
104
|
-
assert_equal
|
|
101
|
+
assert_equal 'hello', RRR.hello
|
|
102
|
+
assert_equal 'hello', OOO.hello
|
|
103
|
+
assert_equal 'hello', RollbackTarget.hello
|
|
105
104
|
assert_match(/Removed constant RollbackTarget from Object/, @io.string)
|
|
106
105
|
end
|
|
107
106
|
end
|
data/test/test_filters.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative 'helper'
|
|
2
2
|
|
|
3
|
-
describe
|
|
3
|
+
describe 'Filters' do
|
|
4
4
|
it 'should filters by accept header' do
|
|
5
5
|
mock_app do
|
|
6
|
-
get '/foo', :
|
|
6
|
+
get '/foo', provides: %i[xml js] do
|
|
7
7
|
request.env['HTTP_ACCEPT']
|
|
8
8
|
end
|
|
9
9
|
end
|
|
@@ -17,16 +17,16 @@ describe "Filters" do
|
|
|
17
17
|
assert ok?
|
|
18
18
|
assert_equal 'application/xml;charset=utf-8', response.headers['Content-Type']
|
|
19
19
|
|
|
20
|
-
get '/foo', {}, { 'HTTP_ACCEPT' => '
|
|
20
|
+
get '/foo', {}, { 'HTTP_ACCEPT' => 'text/javascript' }
|
|
21
21
|
assert ok?
|
|
22
|
-
assert_equal '
|
|
23
|
-
assert_equal '
|
|
22
|
+
assert_equal 'text/javascript', body
|
|
23
|
+
assert_equal 'text/javascript;charset=utf-8', response.headers['Content-Type']
|
|
24
24
|
|
|
25
25
|
get '/foo.js'
|
|
26
26
|
assert ok?
|
|
27
|
-
assert_equal '
|
|
27
|
+
assert_equal 'text/javascript;charset=utf-8', response.headers['Content-Type']
|
|
28
28
|
|
|
29
|
-
get '/foo', {}, {
|
|
29
|
+
get '/foo', {}, { 'HTTP_ACCEPT' => 'text/html' }
|
|
30
30
|
assert_equal 406, status
|
|
31
31
|
end
|
|
32
32
|
|
|
@@ -35,27 +35,27 @@ describe "Filters" do
|
|
|
35
35
|
controller do
|
|
36
36
|
before { env['QUERY_STRING'] == 'secret' or pass }
|
|
37
37
|
get :index do
|
|
38
|
-
|
|
38
|
+
'secret index'
|
|
39
39
|
end
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
controller do
|
|
43
43
|
before { env['QUERY_STRING'] == 'halt' and halt 401, 'go away!' }
|
|
44
44
|
get :index do
|
|
45
|
-
|
|
45
|
+
'index'
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
get
|
|
51
|
-
assert_equal
|
|
50
|
+
get '/?secret'
|
|
51
|
+
assert_equal 'secret index', body
|
|
52
52
|
|
|
53
|
-
get
|
|
54
|
-
assert_equal
|
|
53
|
+
get '/?halt'
|
|
54
|
+
assert_equal 'go away!', body
|
|
55
55
|
assert_equal 401, status
|
|
56
56
|
|
|
57
|
-
get
|
|
58
|
-
assert_equal
|
|
57
|
+
get '/'
|
|
58
|
+
assert_equal 'index', body
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
it 'should scope filters in the given controller' do
|
|
@@ -66,26 +66,26 @@ describe "Filters" do
|
|
|
66
66
|
controller :foo do
|
|
67
67
|
before { @foo = :foo }
|
|
68
68
|
after { @foo = nil }
|
|
69
|
-
get(
|
|
69
|
+
get('/') { [@foo, @bar, @global].compact.join(' ') }
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
-
get(
|
|
72
|
+
get('/') { [@foo, @bar, @global].compact.join(' ') }
|
|
73
73
|
|
|
74
74
|
controller :bar do
|
|
75
75
|
before { @bar = :bar }
|
|
76
76
|
after { @bar = nil }
|
|
77
|
-
get(
|
|
77
|
+
get('/') { [@foo, @bar, @global].compact.join(' ') }
|
|
78
78
|
end
|
|
79
79
|
end
|
|
80
80
|
|
|
81
|
-
get
|
|
82
|
-
assert_equal
|
|
81
|
+
get '/bar'
|
|
82
|
+
assert_equal 'bar global', body
|
|
83
83
|
|
|
84
|
-
get
|
|
85
|
-
assert_equal
|
|
84
|
+
get '/foo'
|
|
85
|
+
assert_equal 'foo global', body
|
|
86
86
|
|
|
87
|
-
get
|
|
88
|
-
assert_equal
|
|
87
|
+
get '/'
|
|
88
|
+
assert_equal 'global', body
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
it 'should be able to access params in a before filter' do
|
|
@@ -96,7 +96,7 @@ describe "Filters" do
|
|
|
96
96
|
username_from_before_filter = params[:username]
|
|
97
97
|
end
|
|
98
98
|
|
|
99
|
-
get :users, :
|
|
99
|
+
get :users, with: :username do
|
|
100
100
|
end
|
|
101
101
|
end
|
|
102
102
|
get '/users/josh'
|
|
@@ -105,18 +105,18 @@ describe "Filters" do
|
|
|
105
105
|
|
|
106
106
|
it 'should be able to access params normally when a before filter is specified' do
|
|
107
107
|
mock_app do
|
|
108
|
-
before {
|
|
108
|
+
before {}
|
|
109
109
|
get :index do
|
|
110
|
-
params.
|
|
110
|
+
params.to_json
|
|
111
111
|
end
|
|
112
112
|
end
|
|
113
113
|
get '/?test=what'
|
|
114
|
-
assert_equal '{"test"
|
|
114
|
+
assert_equal '{"test":"what"}', body
|
|
115
115
|
end
|
|
116
116
|
|
|
117
117
|
it 'should be able to filter based on a path' do
|
|
118
118
|
mock_app do
|
|
119
|
-
before('/') { @test = "#{@test}before"}
|
|
119
|
+
before('/') { @test = "#{@test}before" }
|
|
120
120
|
get :index do
|
|
121
121
|
@test
|
|
122
122
|
end
|
|
@@ -132,7 +132,7 @@ describe "Filters" do
|
|
|
132
132
|
|
|
133
133
|
it 'should be able to filter based on a symbol' do
|
|
134
134
|
mock_app do
|
|
135
|
-
before(:index) { @test = 'before'}
|
|
135
|
+
before(:index) { @test = 'before' }
|
|
136
136
|
get :index do
|
|
137
137
|
@test
|
|
138
138
|
end
|
|
@@ -149,27 +149,26 @@ describe "Filters" do
|
|
|
149
149
|
it 'should be able to filter based on a symbol for a controller' do
|
|
150
150
|
mock_app do
|
|
151
151
|
controller :foo do
|
|
152
|
-
before(:test) { @test = 'foo'}
|
|
153
|
-
get
|
|
154
|
-
@test.to_s + " response"
|
|
155
|
-
end
|
|
152
|
+
before(:test) { @test = 'foo' }
|
|
153
|
+
get(:test) { "#{@test} response" }
|
|
156
154
|
end
|
|
155
|
+
|
|
157
156
|
controller :bar do
|
|
158
|
-
before(:test) { @test = 'bar'}
|
|
159
|
-
get
|
|
160
|
-
@test.to_s + " response"
|
|
161
|
-
end
|
|
157
|
+
before(:test) { @test = 'bar' }
|
|
158
|
+
get(:test) { "#{@test} response" }
|
|
162
159
|
end
|
|
163
160
|
end
|
|
161
|
+
|
|
164
162
|
get '/foo/test'
|
|
165
163
|
assert_equal 'foo response', body
|
|
164
|
+
|
|
166
165
|
get '/bar/test'
|
|
167
166
|
assert_equal 'bar response', body
|
|
168
167
|
end
|
|
169
168
|
|
|
170
169
|
it 'should be able to filter based on a symbol or path' do
|
|
171
170
|
mock_app do
|
|
172
|
-
before(:index, '/main') { @test = 'before'}
|
|
171
|
+
before(:index, '/main') { @test = 'before' }
|
|
173
172
|
get :index do
|
|
174
173
|
@test
|
|
175
174
|
end
|
|
@@ -185,7 +184,7 @@ describe "Filters" do
|
|
|
185
184
|
|
|
186
185
|
it 'should be able to filter based on a symbol or regexp' do
|
|
187
186
|
mock_app do
|
|
188
|
-
before(:index, /main/) { @test = 'before'}
|
|
187
|
+
before(:index, /main/) { @test = 'before' }
|
|
189
188
|
get :index do
|
|
190
189
|
@test
|
|
191
190
|
end
|
|
@@ -206,7 +205,7 @@ describe "Filters" do
|
|
|
206
205
|
|
|
207
206
|
it 'should be able to filter excluding based on a symbol' do
|
|
208
207
|
mock_app do
|
|
209
|
-
before(:
|
|
208
|
+
before(except: :index) { @test = 'before' }
|
|
210
209
|
get :index do
|
|
211
210
|
@test
|
|
212
211
|
end
|
|
@@ -223,8 +222,8 @@ describe "Filters" do
|
|
|
223
222
|
it 'should be able to filter excluding based on a symbol when specify the multiple routes and use nested controller' do
|
|
224
223
|
mock_app do
|
|
225
224
|
controller :test, :nested do
|
|
226
|
-
before(:
|
|
227
|
-
before(:
|
|
225
|
+
before(except: %i[test1 test2]) { @long = 'long' }
|
|
226
|
+
before(except: [:test1]) { @short = 'short' }
|
|
228
227
|
get :test1 do
|
|
229
228
|
"#{@long} #{@short} normal"
|
|
230
229
|
end
|
|
@@ -246,14 +245,14 @@ describe "Filters" do
|
|
|
246
245
|
|
|
247
246
|
it 'should be able to filter based on a request param' do
|
|
248
247
|
mock_app do
|
|
249
|
-
before(:
|
|
248
|
+
before(agent: /IE/) { @test = 'before' }
|
|
250
249
|
get :index do
|
|
251
250
|
@test
|
|
252
251
|
end
|
|
253
252
|
end
|
|
254
253
|
get '/'
|
|
255
254
|
assert_equal '', body
|
|
256
|
-
get
|
|
255
|
+
get '/', {}, { 'HTTP_USER_AGENT' => 'This is IE' }
|
|
257
256
|
assert_equal 'before', body
|
|
258
257
|
end
|
|
259
258
|
|
|
@@ -343,7 +342,7 @@ describe "Filters" do
|
|
|
343
342
|
doodle = 'Been after'
|
|
344
343
|
end
|
|
345
344
|
before do
|
|
346
|
-
raise StandardError,
|
|
345
|
+
raise StandardError, 'before'
|
|
347
346
|
end
|
|
348
347
|
get :index do
|
|
349
348
|
doodle = 'Been now'
|
|
@@ -363,11 +362,11 @@ describe "Filters" do
|
|
|
363
362
|
mock_app do
|
|
364
363
|
after do
|
|
365
364
|
doodle += ' and after'
|
|
366
|
-
raise StandardError,
|
|
365
|
+
raise StandardError, 'after'
|
|
367
366
|
end
|
|
368
367
|
get :foo do
|
|
369
368
|
doodle = 'Been now'
|
|
370
|
-
raise StandardError,
|
|
369
|
+
raise StandardError, 'now'
|
|
371
370
|
end
|
|
372
371
|
get :index do
|
|
373
372
|
doodle = 'Been now'
|
|
@@ -389,12 +388,12 @@ describe "Filters" do
|
|
|
389
388
|
|
|
390
389
|
it 'should trigger filters if superclass responds to :filters' do
|
|
391
390
|
class FilterApp < Padrino::Application
|
|
392
|
-
before { @foo =
|
|
391
|
+
before { @foo = 'foo' }
|
|
393
392
|
end
|
|
394
393
|
mock_app FilterApp do
|
|
395
|
-
get(
|
|
394
|
+
get('/') { @foo }
|
|
396
395
|
end
|
|
397
|
-
get
|
|
398
|
-
assert_equal
|
|
396
|
+
get '/'
|
|
397
|
+
assert_equal 'foo', body
|
|
399
398
|
end
|
|
400
399
|
end
|
data/test/test_flash.rb
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative 'helper'
|
|
2
2
|
|
|
3
3
|
describe Padrino::Flash do
|
|
4
4
|
describe 'storage' do
|
|
5
5
|
before do
|
|
6
6
|
@storage = Padrino::Flash::Storage.new(
|
|
7
|
-
:
|
|
8
|
-
:
|
|
9
|
-
:
|
|
10
|
-
:
|
|
7
|
+
success: 'Success msg',
|
|
8
|
+
error: 'Error msg',
|
|
9
|
+
notice: 'Notice msg',
|
|
10
|
+
custom: 'Custom msg'
|
|
11
11
|
)
|
|
12
12
|
@storage[:one] = 'One msg'
|
|
13
13
|
@storage[:two] = 'Two msg'
|
|
@@ -68,12 +68,12 @@ describe Padrino::Flash do
|
|
|
68
68
|
|
|
69
69
|
routes = proc do
|
|
70
70
|
get :index do
|
|
71
|
-
params[:key] ? flash[params[:key].to_sym].to_s : flash.now.
|
|
71
|
+
params[:key] ? flash[params[:key].to_sym].to_s : flash.now.to_json
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
post :index do
|
|
75
|
-
params.each { |k,v| flash[k.to_sym] = v.to_s }
|
|
76
|
-
flash.next.
|
|
75
|
+
params.each { |k, v| flash[k.to_sym] = v.to_s }
|
|
76
|
+
flash.next.to_json
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
get :session do
|
|
@@ -81,7 +81,7 @@ describe Padrino::Flash do
|
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
get :redirect do
|
|
84
|
-
redirect url(:index, :
|
|
84
|
+
redirect url(:index, key: :foo), 301, foo: 'redirected!'
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
get :success do
|
|
@@ -106,8 +106,8 @@ describe Padrino::Flash do
|
|
|
106
106
|
end
|
|
107
107
|
|
|
108
108
|
it 'should set a flash' do
|
|
109
|
-
post '/', :
|
|
110
|
-
assert_equal '{
|
|
109
|
+
post '/', foo: :bar
|
|
110
|
+
assert_equal '{"foo":"bar"}', body
|
|
111
111
|
end
|
|
112
112
|
end
|
|
113
113
|
|
|
@@ -128,13 +128,13 @@ describe Padrino::Flash do
|
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
it 'should set a flash' do
|
|
131
|
-
post '/', :
|
|
132
|
-
assert_equal '{
|
|
131
|
+
post '/', foo: :bar
|
|
132
|
+
assert_equal '{"foo":"bar"}', body
|
|
133
133
|
end
|
|
134
134
|
|
|
135
135
|
it 'should get a flash' do
|
|
136
|
-
post '/', :
|
|
137
|
-
get '/', :
|
|
136
|
+
post '/', foo: :bar
|
|
137
|
+
get '/', key: :foo
|
|
138
138
|
assert_equal 'bar', body
|
|
139
139
|
post '/'
|
|
140
140
|
assert_equal '{}', body
|
|
@@ -149,19 +149,19 @@ describe Padrino::Flash do
|
|
|
149
149
|
|
|
150
150
|
it 'should set success' do
|
|
151
151
|
get '/success'
|
|
152
|
-
get '/', :
|
|
152
|
+
get '/', key: :success
|
|
153
153
|
assert_equal 'Yup', body
|
|
154
154
|
end
|
|
155
155
|
|
|
156
156
|
it 'should set error' do
|
|
157
157
|
get '/error'
|
|
158
|
-
get '/', :
|
|
158
|
+
get '/', key: :error
|
|
159
159
|
assert_equal 'Arg', body
|
|
160
160
|
end
|
|
161
161
|
|
|
162
162
|
it 'should set notice' do
|
|
163
163
|
get '/notice'
|
|
164
|
-
get '/', :
|
|
164
|
+
get '/', key: :notice
|
|
165
165
|
assert_equal 'Mmm', body
|
|
166
166
|
end
|
|
167
167
|
end
|
data/test/test_locale.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
require_relative 'helper'
|
|
2
2
|
|
|
3
|
-
describe
|
|
3
|
+
describe 'Locales' do
|
|
4
4
|
Dir[File.expand_path('../lib/padrino-core/locale/*.yml', __dir__)].each do |file|
|
|
5
5
|
base_original = YAML.load_file(file)
|
|
6
6
|
name = File.basename(file, '.yml')
|