actionpack 1.12.3 → 1.12.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of actionpack might be problematic. Click here for more details.
- data/CHANGELOG +35 -0
- data/README +4 -0
- data/Rakefile +8 -4
- data/filler +53 -0
- data/lib/action_controller/base.rb +102 -71
- data/lib/action_controller/caching.rb +3 -3
- data/lib/action_controller/cgi_process.rb +6 -5
- data/lib/action_controller/integration.rb +10 -6
- data/lib/action_controller/layout.rb +7 -5
- data/lib/action_controller/mime_responds.rb +7 -1
- data/lib/action_controller/pagination.rb +2 -2
- data/lib/action_controller/request.rb +11 -3
- data/lib/action_controller/routing.rb +7 -2
- data/lib/action_controller/streaming.rb +11 -6
- data/lib/action_controller/templates/scaffolds/layout.rhtml +1 -1
- data/lib/action_controller/verification.rb +1 -1
- data/lib/action_pack/version.rb +1 -1
- data/lib/action_view/base.rb +7 -4
- data/lib/action_view/helpers/capture_helper.rb +18 -16
- data/lib/action_view/helpers/java_script_macros_helper.rb +5 -4
- data/lib/action_view/helpers/prototype_helper.rb +4 -3
- data/lib/action_view/helpers/text_helper.rb +22 -22
- data/test/controller/filter_params_test.rb +42 -0
- data/test/controller/send_file_test.rb +15 -1
- data/test/template/compiled_templates_test.rb +134 -0
- metadata +7 -4
- data/test/template/compiled_templates_tests.rb +0 -63
@@ -0,0 +1,42 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../abstract_unit'
|
2
|
+
|
3
|
+
class FilterParamController < ActionController::Base
|
4
|
+
end
|
5
|
+
|
6
|
+
class FilterParamTest < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@controller = FilterParamController.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_filter_parameters
|
12
|
+
assert FilterParamController.respond_to?(:filter_parameter_logging)
|
13
|
+
assert !@controller.respond_to?(:filter_parameters)
|
14
|
+
|
15
|
+
FilterParamController.filter_parameter_logging
|
16
|
+
assert @controller.respond_to?(:filter_parameters)
|
17
|
+
|
18
|
+
test_hashes = [[{},{},[]],
|
19
|
+
[{'foo'=>'bar'},{'foo'=>'bar'},[]],
|
20
|
+
[{'foo'=>'bar'},{'foo'=>'bar'},%w'food'],
|
21
|
+
[{'foo'=>'bar'},{'foo'=>'[FILTERED]'},%w'foo'],
|
22
|
+
[{'foo'=>'bar', 'bar'=>'foo'},{'foo'=>'[FILTERED]', 'bar'=>'foo'},%w'foo baz'],
|
23
|
+
[{'foo'=>'bar', 'baz'=>'foo'},{'foo'=>'[FILTERED]', 'baz'=>'[FILTERED]'},%w'foo baz'],
|
24
|
+
[{'bar'=>{'foo'=>'bar','bar'=>'foo'}},{'bar'=>{'foo'=>'[FILTERED]','bar'=>'foo'}},%w'fo'],
|
25
|
+
[{'foo'=>{'foo'=>'bar','bar'=>'foo'}},{'foo'=>'[FILTERED]'},%w'f banana']]
|
26
|
+
|
27
|
+
test_hashes.each do |before_filter, after_filter, filter_words|
|
28
|
+
FilterParamController.filter_parameter_logging(*filter_words)
|
29
|
+
assert_equal after_filter, @controller.filter_parameters(before_filter)
|
30
|
+
|
31
|
+
filter_words.push('blah')
|
32
|
+
FilterParamController.filter_parameter_logging(*filter_words) do |key, value|
|
33
|
+
value.reverse! if key =~ /bargain/
|
34
|
+
end
|
35
|
+
|
36
|
+
before_filter['barg'] = {'bargain'=>'gain', 'blah'=>'bar', 'bar'=>{'bargain'=>{'blah'=>'foo'}}}
|
37
|
+
after_filter['barg'] = {'bargain'=>'niag', 'blah'=>'[FILTERED]', 'bar'=>{'bargain'=>{'blah'=>'[FILTERED]'}}}
|
38
|
+
|
39
|
+
assert_equal after_filter, @controller.filter_parameters(before_filter)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -85,11 +85,25 @@ class SendFileTest < Test::Unit::TestCase
|
|
85
85
|
assert_equal 'type', h['Content-Type']
|
86
86
|
assert_equal 'disposition; filename="filename"', h['Content-Disposition']
|
87
87
|
assert_equal 'binary', h['Content-Transfer-Encoding']
|
88
|
-
|
88
|
+
|
89
89
|
# test overriding Cache-Control: no-cache header to fix IE open/save dialog
|
90
90
|
@controller.headers = { 'Cache-Control' => 'no-cache' }
|
91
91
|
@controller.send(:send_file_headers!, options)
|
92
92
|
h = @controller.headers
|
93
93
|
assert_equal 'private', h['Cache-Control']
|
94
94
|
end
|
95
|
+
|
96
|
+
%w(file data).each do |method|
|
97
|
+
define_method "test_send_#{method}_status" do
|
98
|
+
@controller.options = { :stream => false, :status => 500 }
|
99
|
+
assert_nothing_raised { assert_not_nil process(method) }
|
100
|
+
assert_equal '500', @controller.headers['Status']
|
101
|
+
end
|
102
|
+
|
103
|
+
define_method "test_default_send_#{method}_status" do
|
104
|
+
@controller.options = { :stream => false }
|
105
|
+
assert_nothing_raised { assert_not_nil process(method) }
|
106
|
+
assert_equal ActionController::Base::DEFAULT_RENDER_STATUS_CODE, @controller.headers['Status']
|
107
|
+
end
|
108
|
+
end
|
95
109
|
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require File.dirname(__FILE__) + '/../../lib/action_view/helpers/date_helper'
|
3
|
+
require File.dirname(__FILE__) + "/../abstract_unit"
|
4
|
+
|
5
|
+
class CompiledTemplateTests < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
@ct = ActionView::CompiledTemplates.new
|
9
|
+
@v = Class.new
|
10
|
+
@v.send :include, @ct
|
11
|
+
@a = './test_compile_template_a.rhtml'
|
12
|
+
@b = './test_compile_template_b.rhtml'
|
13
|
+
@s = './test_compile_template_link.rhtml'
|
14
|
+
end
|
15
|
+
def teardown
|
16
|
+
[@a, @b, @s].each do |f|
|
17
|
+
`rm #{f}` if File.exist?(f) || File.symlink?(f)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
attr_reader :ct, :v
|
21
|
+
|
22
|
+
def test_name_allocation
|
23
|
+
hi_world = ct.method_names['hi world']
|
24
|
+
hi_sexy = ct.method_names['hi sexy']
|
25
|
+
wish_upon_a_star = ct.method_names['I love seeing decent error messages']
|
26
|
+
|
27
|
+
assert_equal hi_world, ct.method_names['hi world']
|
28
|
+
assert_equal hi_sexy, ct.method_names['hi sexy']
|
29
|
+
assert_equal wish_upon_a_star, ct.method_names['I love seeing decent error messages']
|
30
|
+
assert_equal 3, [hi_world, hi_sexy, wish_upon_a_star].uniq.length
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_wrap_source
|
34
|
+
assert_equal(
|
35
|
+
"def aliased_assignment(value)\nself.value = value\nend",
|
36
|
+
@ct.wrap_source(:aliased_assignment, [:value], 'self.value = value')
|
37
|
+
)
|
38
|
+
|
39
|
+
assert_equal(
|
40
|
+
"def simple()\nnil\nend",
|
41
|
+
@ct.wrap_source(:simple, [], 'nil')
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_compile_source_single_method
|
46
|
+
selector = ct.compile_source('doubling method', [:a], 'a + a')
|
47
|
+
assert_equal 2, @v.new.send(selector, 1)
|
48
|
+
assert_equal 4, @v.new.send(selector, 2)
|
49
|
+
assert_equal -4, @v.new.send(selector, -2)
|
50
|
+
assert_equal 0, @v.new.send(selector, 0)
|
51
|
+
selector
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_compile_source_two_method
|
55
|
+
sel1 = test_compile_source_single_method # compile the method in the other test
|
56
|
+
sel2 = ct.compile_source('doubling method', [:a, :b], 'a + b + a + b')
|
57
|
+
assert_not_equal sel1, sel2
|
58
|
+
|
59
|
+
assert_equal 2, @v.new.send(sel1, 1)
|
60
|
+
assert_equal 4, @v.new.send(sel1, 2)
|
61
|
+
|
62
|
+
assert_equal 6, @v.new.send(sel2, 1, 2)
|
63
|
+
assert_equal 32, @v.new.send(sel2, 15, 1)
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_mtime
|
67
|
+
t1 = Time.now
|
68
|
+
test_compile_source_single_method
|
69
|
+
assert (t1..Time.now).include?(ct.mtime('doubling method', [:a]))
|
70
|
+
end
|
71
|
+
|
72
|
+
def test_compile_time
|
73
|
+
`echo '#{@a}' > #{@a}; echo '#{@b}' > #{@b}; ln -s #{@a} #{@s}`
|
74
|
+
|
75
|
+
v = ActionView::Base.new
|
76
|
+
v.base_path = '.'
|
77
|
+
v.cache_template_loading = false;
|
78
|
+
|
79
|
+
sleep 1
|
80
|
+
t = Time.now
|
81
|
+
v.compile_and_render_template(:rhtml, '', @a)
|
82
|
+
v.compile_and_render_template(:rhtml, '', @b)
|
83
|
+
v.compile_and_render_template(:rhtml, '', @s)
|
84
|
+
a_n = v.method_names[@a]
|
85
|
+
b_n = v.method_names[@b]
|
86
|
+
s_n = v.method_names[@s]
|
87
|
+
# all of the files have changed since last compile
|
88
|
+
assert v.compile_time[a_n] > t
|
89
|
+
assert v.compile_time[b_n] > t
|
90
|
+
assert v.compile_time[s_n] > t
|
91
|
+
|
92
|
+
sleep 1
|
93
|
+
t = Time.now
|
94
|
+
v.compile_and_render_template(:rhtml, '', @a)
|
95
|
+
v.compile_and_render_template(:rhtml, '', @b)
|
96
|
+
v.compile_and_render_template(:rhtml, '', @s)
|
97
|
+
# none of the files have changed since last compile
|
98
|
+
assert v.compile_time[a_n] < t
|
99
|
+
assert v.compile_time[b_n] < t
|
100
|
+
assert v.compile_time[s_n] < t
|
101
|
+
|
102
|
+
`rm #{@s}; ln -s #{@b} #{@s}`
|
103
|
+
v.compile_and_render_template(:rhtml, '', @a)
|
104
|
+
v.compile_and_render_template(:rhtml, '', @b)
|
105
|
+
v.compile_and_render_template(:rhtml, '', @s)
|
106
|
+
# the symlink has changed since last compile
|
107
|
+
assert v.compile_time[a_n] < t
|
108
|
+
assert v.compile_time[b_n] < t
|
109
|
+
assert v.compile_time[s_n] > t
|
110
|
+
|
111
|
+
sleep 1
|
112
|
+
`touch #{@b}`
|
113
|
+
t = Time.now
|
114
|
+
v.compile_and_render_template(:rhtml, '', @a)
|
115
|
+
v.compile_and_render_template(:rhtml, '', @b)
|
116
|
+
v.compile_and_render_template(:rhtml, '', @s)
|
117
|
+
# the file at the end of the symlink has changed since last compile
|
118
|
+
# both the symlink and the file at the end of it should be recompiled
|
119
|
+
assert v.compile_time[a_n] < t
|
120
|
+
assert v.compile_time[b_n] > t
|
121
|
+
assert v.compile_time[s_n] > t
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
module ActionView
|
126
|
+
class Base
|
127
|
+
def compile_time
|
128
|
+
@@compile_time
|
129
|
+
end
|
130
|
+
def method_names
|
131
|
+
@@method_names
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.0
|
3
3
|
specification_version: 1
|
4
4
|
name: actionpack
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.12.
|
7
|
-
date: 2006-
|
6
|
+
version: 1.12.4
|
7
|
+
date: 2006-08-09 00:00:00 -06:00
|
8
8
|
summary: Web-flow and rendering framework putting the VC in MVC.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -25,9 +25,11 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
25
25
|
platform: ruby
|
26
26
|
signing_key:
|
27
27
|
cert_chain:
|
28
|
+
post_install_message:
|
28
29
|
authors:
|
29
30
|
- David Heinemeier Hansson
|
30
31
|
files:
|
32
|
+
- filler
|
31
33
|
- Rakefile
|
32
34
|
- install.rb
|
33
35
|
- README
|
@@ -160,6 +162,7 @@ files:
|
|
160
162
|
- test/controller/cookie_test.rb
|
161
163
|
- test/controller/custom_handler_test.rb
|
162
164
|
- test/controller/fake_controllers.rb
|
165
|
+
- test/controller/filter_params_test.rb
|
163
166
|
- test/controller/filters_test.rb
|
164
167
|
- test/controller/flash_test.rb
|
165
168
|
- test/controller/fragment_store_setting_test.rb
|
@@ -281,7 +284,7 @@ files:
|
|
281
284
|
- test/template/active_record_helper_test.rb
|
282
285
|
- test/template/asset_tag_helper_test.rb
|
283
286
|
- test/template/benchmark_helper_test.rb
|
284
|
-
- test/template/
|
287
|
+
- test/template/compiled_templates_test.rb
|
285
288
|
- test/template/date_helper_test.rb
|
286
289
|
- test/template/form_helper_test.rb
|
287
290
|
- test/template/form_options_helper_test.rb
|
@@ -1,63 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require File.dirname(__FILE__) + '/../../lib/action_view/helpers/date_helper'
|
3
|
-
require File.dirname(__FILE__) + "/../abstract_unit"
|
4
|
-
|
5
|
-
class CompiledTemplateTests < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def setup
|
8
|
-
@ct = ActionView::CompiledTemplates.new
|
9
|
-
@v = Class.new
|
10
|
-
@v.send :include, @ct
|
11
|
-
end
|
12
|
-
attr_reader :ct, :v
|
13
|
-
|
14
|
-
def test_name_allocation
|
15
|
-
hi_world = ct.method_names['hi world']
|
16
|
-
hi_sexy = ct.method_names['hi sexy']
|
17
|
-
wish_upon_a_star = ct.method_names['I love seeing decent error messages']
|
18
|
-
|
19
|
-
assert_equal hi_world, ct.method_names['hi world']
|
20
|
-
assert_equal hi_sexy, ct.method_names['hi sexy']
|
21
|
-
assert_equal wish_upon_a_star, ct.method_names['I love seeing decent error messages']
|
22
|
-
assert_equal 3, [hi_world, hi_sexy, wish_upon_a_star].uniq.length
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_wrap_source
|
26
|
-
assert_equal(
|
27
|
-
"def aliased_assignment(value)\nself.value = value\nend",
|
28
|
-
@ct.wrap_source(:aliased_assignment, [:value], 'self.value = value')
|
29
|
-
)
|
30
|
-
|
31
|
-
assert_equal(
|
32
|
-
"def simple()\nnil\nend",
|
33
|
-
@ct.wrap_source(:simple, [], 'nil')
|
34
|
-
)
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_compile_source_single_method
|
38
|
-
selector = ct.compile_source('doubling method', [:a], 'a + a')
|
39
|
-
assert_equal 2, @v.new.send(selector, 1)
|
40
|
-
assert_equal 4, @v.new.send(selector, 2)
|
41
|
-
assert_equal -4, @v.new.send(selector, -2)
|
42
|
-
assert_equal 0, @v.new.send(selector, 0)
|
43
|
-
selector
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_compile_source_two_method
|
47
|
-
sel1 = test_compile_source_single_method # compile the method in the other test
|
48
|
-
sel2 = ct.compile_source('doubling method', [:a, :b], 'a + b + a + b')
|
49
|
-
assert_not_equal sel1, sel2
|
50
|
-
|
51
|
-
assert_equal 2, @v.new.send(sel1, 1)
|
52
|
-
assert_equal 4, @v.new.send(sel1, 2)
|
53
|
-
|
54
|
-
assert_equal 6, @v.new.send(sel2, 1, 2)
|
55
|
-
assert_equal 32, @v.new.send(sel2, 15, 1)
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_mtime
|
59
|
-
t1 = Time.now
|
60
|
-
test_compile_source_single_method
|
61
|
-
assert (t1..Time.now).include?(ct.mtime('doubling method', [:a]))
|
62
|
-
end
|
63
|
-
end
|