actionpack 1.11.0 → 1.11.1
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 +45 -0
- data/lib/action_controller/assertions.rb +1 -1
- data/lib/action_controller/base.rb +24 -12
- data/lib/action_controller/caching.rb +1 -0
- data/lib/action_controller/cgi_ext/raw_post_data_fix.rb +1 -0
- data/lib/action_controller/cgi_process.rb +44 -27
- data/lib/action_controller/components.rb +2 -2
- data/lib/action_controller/flash.rb +16 -7
- data/lib/action_controller/helpers.rb +12 -1
- data/lib/action_controller/layout.rb +3 -1
- data/lib/action_controller/macros/in_place_editing.rb +1 -1
- data/lib/action_controller/request.rb +20 -16
- data/lib/action_controller/session/active_record_store.rb +57 -51
- data/lib/action_controller/templates/rescues/_request_and_response.rhtml +0 -2
- data/lib/action_controller/vendor/html-scanner/html/node.rb +1 -1
- data/lib/action_controller/vendor/html-scanner/html/node.rb.rej +17 -0
- data/lib/action_pack/version.rb +2 -2
- data/lib/action_view/base.rb +4 -5
- data/lib/action_view/helpers/asset_tag_helper.rb +2 -2
- data/lib/action_view/helpers/form_options_helper.rb +1 -1
- data/lib/action_view/helpers/form_tag_helper.rb +1 -1
- data/lib/action_view/helpers/java_script_macros_helper.rb +11 -9
- data/lib/action_view/helpers/javascripts/controls.js +30 -1
- data/lib/action_view/helpers/javascripts/dragdrop.js +37 -17
- data/lib/action_view/helpers/javascripts/effects.js +3 -91
- data/lib/action_view/helpers/javascripts/prototype.js +109 -67
- data/lib/action_view/helpers/text_helper.rb +30 -9
- data/rakefile +2 -2
- data/test/controller/active_record_assertions_test.rb +1 -0
- data/test/controller/active_record_store_test.rb +12 -6
- data/test/controller/flash_test.rb +1 -1
- data/test/controller/helper_test.rb +21 -5
- data/test/controller/new_render_test.rb +31 -0
- data/test/controller/request_test.rb +5 -0
- data/test/fixtures/helpers/fun/pdf_helper.rb +3 -0
- data/test/fixtures/test/render_file_with_ivar.rhtml +1 -0
- data/test/fixtures/test/render_file_with_locals.rhtml +1 -0
- data/test/template/form_options_helper_test.rb +16 -6
- data/test/template/text_helper_test.rb +7 -0
- metadata +7 -3
@@ -135,11 +135,17 @@ module ActionView
|
|
135
135
|
# auto_link("Go to http://www.rubyonrails.com and say hello to david@loudthinking.com") =>
|
136
136
|
# Go to <a href="http://www.rubyonrails.com">http://www.rubyonrails.com</a> and
|
137
137
|
# say hello to <a href="mailto:david@loudthinking.com">david@loudthinking.com</a>
|
138
|
-
|
138
|
+
#
|
139
|
+
# If a block is given, each url and email address is yielded and the
|
140
|
+
# result is used as the link text. Example:
|
141
|
+
# auto_link(post.body, :all, :target => '_blank') do |text|
|
142
|
+
# truncate(text, 15)
|
143
|
+
# end
|
144
|
+
def auto_link(text, link = :all, href_options = {}, &block)
|
139
145
|
case link
|
140
|
-
when :all then auto_link_urls(auto_link_email_addresses(text), href_options)
|
141
|
-
when :email_addresses then auto_link_email_addresses(text)
|
142
|
-
when :urls then auto_link_urls(text, href_options)
|
146
|
+
when :all then auto_link_urls(auto_link_email_addresses(text, &block), href_options, &block)
|
147
|
+
when :email_addresses then auto_link_email_addresses(text, &block)
|
148
|
+
when :urls then auto_link_urls(text, href_options, &block)
|
143
149
|
end
|
144
150
|
end
|
145
151
|
|
@@ -325,22 +331,37 @@ module ActionView
|
|
325
331
|
([[:punct:]]|\s|<|$) # trailing text
|
326
332
|
/x unless const_defined?(:AUTO_LINK_RE)
|
327
333
|
|
328
|
-
# Turns all urls into clickable links.
|
334
|
+
# Turns all urls into clickable links. If a block is given, each url
|
335
|
+
# is yielded and the result is used as the link text. Example:
|
336
|
+
# auto_link_urls(post.body, :all, :target => '_blank') do |text|
|
337
|
+
# truncate(text, 15)
|
338
|
+
# end
|
329
339
|
def auto_link_urls(text, href_options = {})
|
340
|
+
extra_options = tag_options(href_options.stringify_keys) || ""
|
330
341
|
text.gsub(AUTO_LINK_RE) do
|
331
342
|
all, a, b, c, d = $&, $1, $2, $3, $5
|
332
343
|
if a =~ /<a\s/i # don't replace URL's that are already linked
|
333
344
|
all
|
334
345
|
else
|
335
|
-
|
336
|
-
|
346
|
+
text = b + c
|
347
|
+
text = yield(text) if block_given?
|
348
|
+
%(#{a}<a href="#{b=="www."?"http://www.":b}#{c}"#{extra_options}>#{text}</a>#{d})
|
337
349
|
end
|
338
350
|
end
|
339
351
|
end
|
340
352
|
|
341
|
-
# Turns all email addresses into clickable links.
|
353
|
+
# Turns all email addresses into clickable links. If a block is given,
|
354
|
+
# each email is yielded and the result is used as the link text.
|
355
|
+
# Example:
|
356
|
+
# auto_link_email_addresses(post.body) do |text|
|
357
|
+
# truncate(text, 15)
|
358
|
+
# end
|
342
359
|
def auto_link_email_addresses(text)
|
343
|
-
text.gsub(/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)
|
360
|
+
text.gsub(/([\w\.!#\$%\-+.]+@[A-Za-z0-9\-]+(\.[A-Za-z0-9\-]+)+)/) do
|
361
|
+
text = $1
|
362
|
+
text = yield(text) if block_given?
|
363
|
+
%{<a href="mailto:#{$1}">#{text}</a>}
|
364
|
+
end
|
344
365
|
end
|
345
366
|
end
|
346
367
|
end
|
data/rakefile
CHANGED
@@ -9,7 +9,7 @@ require File.join(File.dirname(__FILE__), 'lib', 'action_pack', 'version')
|
|
9
9
|
|
10
10
|
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
11
11
|
PKG_NAME = 'actionpack'
|
12
|
-
PKG_VERSION = ActionPack::
|
12
|
+
PKG_VERSION = ActionPack::VERSION::STRING + PKG_BUILD
|
13
13
|
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
|
14
14
|
|
15
15
|
RELEASE_NAME = "REL #{PKG_VERSION}"
|
@@ -62,7 +62,7 @@ spec = Gem::Specification.new do |s|
|
|
62
62
|
s.has_rdoc = true
|
63
63
|
s.requirements << 'none'
|
64
64
|
|
65
|
-
s.add_dependency('activesupport', '= 1.2.
|
65
|
+
s.add_dependency('activesupport', '= 1.2.4' + PKG_BUILD)
|
66
66
|
|
67
67
|
s.require_path = 'lib'
|
68
68
|
s.autorequire = 'action_controller'
|
@@ -23,6 +23,7 @@ end
|
|
23
23
|
|
24
24
|
# Set up company fixtures.
|
25
25
|
$LOAD_PATH << "#{path_to_ar}/test"
|
26
|
+
QUOTED_TYPE = ActiveRecord::Base.connection.quote_column_name('type') unless Object.const_defined?(:QUOTED_TYPE)
|
26
27
|
require 'fixtures/company'
|
27
28
|
File.read("#{path_to_ar}/test/fixtures/db_definitions/sqlite.sql").split(';').each do |sql|
|
28
29
|
ActiveRecord::Base.connection.execute(sql) unless sql.blank?
|
@@ -15,12 +15,12 @@ require 'action_controller/session/active_record_store'
|
|
15
15
|
|
16
16
|
#ActiveRecord::Base.logger = Logger.new($stdout)
|
17
17
|
begin
|
18
|
-
CGI::Session::ActiveRecordStore::Session.establish_connection(:adapter => 'sqlite3', :
|
18
|
+
CGI::Session::ActiveRecordStore::Session.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
|
19
19
|
CGI::Session::ActiveRecordStore::Session.connection
|
20
20
|
rescue Object
|
21
21
|
$stderr.puts 'SQLite 3 unavailable; falling back to SQLite 2.'
|
22
22
|
begin
|
23
|
-
CGI::Session::ActiveRecordStore::Session.establish_connection(:adapter => 'sqlite', :
|
23
|
+
CGI::Session::ActiveRecordStore::Session.establish_connection(:adapter => 'sqlite', :database => ':memory:')
|
24
24
|
CGI::Session::ActiveRecordStore::Session.connection
|
25
25
|
rescue Object
|
26
26
|
$stderr.puts 'SQLite 2 unavailable; skipping ActiveRecordStore test suite.'
|
@@ -68,13 +68,19 @@ class ActiveRecordStoreTest < Test::Unit::TestCase
|
|
68
68
|
ENV['REQUEST_METHOD'] = 'GET'
|
69
69
|
CGI::Session::ActiveRecordStore.session_class = session_class
|
70
70
|
|
71
|
-
@
|
71
|
+
@cgi = CGI.new
|
72
|
+
@new_session = CGI::Session.new(@cgi, 'database_manager' => CGI::Session::ActiveRecordStore, 'new_session' => true)
|
72
73
|
@new_session['foo'] = 'bar'
|
73
74
|
end
|
74
75
|
|
76
|
+
def test_another_instance
|
77
|
+
@another = CGI::Session.new(@cgi, 'session_id' => @new_session.session_id, 'database_manager' => CGI::Session::ActiveRecordStore)
|
78
|
+
assert_equal @new_session.session_id, @another.session_id
|
79
|
+
end
|
80
|
+
|
75
81
|
def test_model_attribute
|
76
82
|
assert_kind_of CGI::Session::ActiveRecordStore::Session, @new_session.model
|
77
|
-
assert_equal @new_session.model.data
|
83
|
+
assert_equal({ 'foo' => 'bar' }, @new_session.model.data)
|
78
84
|
end
|
79
85
|
|
80
86
|
def teardown
|
@@ -98,7 +104,7 @@ class ColumnLimitTest < Test::Unit::TestCase
|
|
98
104
|
too_big = ':(' * limit
|
99
105
|
s = @session_class.new(:session_id => '666', :data => {'foo' => too_big})
|
100
106
|
s.data
|
101
|
-
|
107
|
+
assert_raise(ActionController::SessionOverflowError) { s.save }
|
102
108
|
end
|
103
109
|
end
|
104
110
|
|
@@ -132,7 +138,7 @@ class SqlBypassActiveRecordStoreTest < ActiveRecordStoreTest
|
|
132
138
|
|
133
139
|
def test_model_attribute
|
134
140
|
assert_kind_of CGI::Session::ActiveRecordStore::SqlBypass, @new_session.model
|
135
|
-
assert_equal @new_session.model.data
|
141
|
+
assert_equal({ 'foo' => 'bar' }, @new_session.model.data)
|
136
142
|
end
|
137
143
|
end
|
138
144
|
|
@@ -14,6 +14,14 @@ module Fun
|
|
14
14
|
|
15
15
|
def rescue_action(e) raise end
|
16
16
|
end
|
17
|
+
|
18
|
+
class PDFController < ActionController::Base
|
19
|
+
def test
|
20
|
+
render :inline => "test: <%= foobar %>"
|
21
|
+
end
|
22
|
+
|
23
|
+
def rescue_action(e) raise end
|
24
|
+
end
|
17
25
|
end
|
18
26
|
|
19
27
|
module LocalAbcHelper
|
@@ -100,11 +108,19 @@ class HelperTest < Test::Unit::TestCase
|
|
100
108
|
end
|
101
109
|
|
102
110
|
def test_helper_for_nested_controller
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
assert_equal
|
111
|
+
request = ActionController::TestRequest.new
|
112
|
+
response = ActionController::TestResponse.new
|
113
|
+
request.action = 'render_hello_world'
|
114
|
+
|
115
|
+
assert_equal 'hello: Iz guuut!', Fun::GamesController.process(request, response).body
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_helper_for_acronym_controller
|
119
|
+
request = ActionController::TestRequest.new
|
120
|
+
response = ActionController::TestResponse.new
|
121
|
+
request.action = 'test'
|
122
|
+
|
123
|
+
assert_equal 'test: baz', Fun::PDFController.process(request, response).body
|
108
124
|
end
|
109
125
|
|
110
126
|
private
|
@@ -43,6 +43,22 @@ class NewRenderTestController < ActionController::Base
|
|
43
43
|
def render_custom_code
|
44
44
|
render :text => "hello world", :status => "404 Moved"
|
45
45
|
end
|
46
|
+
|
47
|
+
def render_file_with_instance_variables
|
48
|
+
@secret = 'in the sauce'
|
49
|
+
path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar.rhtml')
|
50
|
+
render :file => path
|
51
|
+
end
|
52
|
+
|
53
|
+
def render_file_with_locals
|
54
|
+
path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_locals.rhtml')
|
55
|
+
render :file => path, :locals => {:secret => 'in the sauce'}
|
56
|
+
end
|
57
|
+
|
58
|
+
def render_file_not_using_full_path
|
59
|
+
@secret = 'in the sauce'
|
60
|
+
render :file => 'test/render_file_with_ivar', :use_full_path => true
|
61
|
+
end
|
46
62
|
|
47
63
|
def render_xml_hello
|
48
64
|
@name = "David"
|
@@ -242,6 +258,21 @@ class NewRenderTest < Test::Unit::TestCase
|
|
242
258
|
assert_response :missing
|
243
259
|
end
|
244
260
|
|
261
|
+
def test_render_file_with_instance_variables
|
262
|
+
get :render_file_with_instance_variables
|
263
|
+
assert_equal "The secret is in the sauce\n", @response.body
|
264
|
+
end
|
265
|
+
|
266
|
+
def test_render_file_not_using_full_path
|
267
|
+
get :render_file_not_using_full_path
|
268
|
+
assert_equal "The secret is in the sauce\n", @response.body
|
269
|
+
end
|
270
|
+
|
271
|
+
def test_render_file_with_locals
|
272
|
+
get :render_file_with_locals
|
273
|
+
assert_equal "The secret is in the sauce\n", @response.body
|
274
|
+
end
|
275
|
+
|
245
276
|
def test_attempt_to_access_object_method
|
246
277
|
assert_raises(ActionController::UnknownAction, "No action responded to [clone]") { get :clone }
|
247
278
|
end
|
@@ -100,6 +100,11 @@ class RequestTest < Test::Unit::TestCase
|
|
100
100
|
@request.relative_url_root = nil
|
101
101
|
@request.env['SCRIPT_NAME'] = "/collaboration/hieraki/dispatch.cgi"
|
102
102
|
assert_equal "/collaboration/hieraki", @request.relative_url_root
|
103
|
+
|
104
|
+
# apache/scgi case
|
105
|
+
@request.relative_url_root = nil
|
106
|
+
@request.env['SCRIPT_NAME'] = "/collaboration/hieraki"
|
107
|
+
assert_equal "/collaboration/hieraki", @request.relative_url_root
|
103
108
|
end
|
104
109
|
|
105
110
|
def test_request_uri
|
@@ -0,0 +1 @@
|
|
1
|
+
The secret is <%= @secret %>
|
@@ -0,0 +1 @@
|
|
1
|
+
The secret is <%= secret %>
|
@@ -103,25 +103,35 @@ class FormOptionsHelperTest < Test::Unit::TestCase
|
|
103
103
|
options_for_select([ "ruby", "rubyonrails" ], "ruby")
|
104
104
|
)
|
105
105
|
end
|
106
|
-
|
106
|
+
|
107
107
|
def test_hash_options_for_select
|
108
108
|
assert_dom_equal(
|
109
109
|
"<option value=\"<Kroner>\"><DKR></option>\n<option value=\"Dollar\">$</option>",
|
110
110
|
options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" })
|
111
111
|
)
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_hash_options_for_select_with_selection
|
115
112
|
assert_dom_equal(
|
116
113
|
"<option value=\"<Kroner>\"><DKR></option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
|
117
114
|
options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" }, "Dollar")
|
118
115
|
)
|
116
|
+
assert_dom_equal(
|
117
|
+
"<option value=\"<Kroner>\" selected=\"selected\"><DKR></option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
|
118
|
+
options_for_select({ "$" => "Dollar", "<DKR>" => "<Kroner>" }, [ "Dollar", "<Kroner>" ])
|
119
|
+
)
|
119
120
|
end
|
120
121
|
|
121
|
-
def
|
122
|
+
def test_ducktyped_options_for_select
|
123
|
+
quack = Struct.new(:first, :last)
|
124
|
+
assert_dom_equal(
|
125
|
+
"<option value=\"<Kroner>\"><DKR></option>\n<option value=\"Dollar\">$</option>",
|
126
|
+
options_for_select([quack.new("<DKR>", "<Kroner>"), quack.new("$", "Dollar")])
|
127
|
+
)
|
128
|
+
assert_dom_equal(
|
129
|
+
"<option value=\"<Kroner>\"><DKR></option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
|
130
|
+
options_for_select([quack.new("<DKR>", "<Kroner>"), quack.new("$", "Dollar")], "Dollar")
|
131
|
+
)
|
122
132
|
assert_dom_equal(
|
123
133
|
"<option value=\"<Kroner>\" selected=\"selected\"><DKR></option>\n<option value=\"Dollar\" selected=\"selected\">$</option>",
|
124
|
-
options_for_select(
|
134
|
+
options_for_select([quack.new("<DKR>", "<Kroner>"), quack.new("$", "Dollar")], ["Dollar", "<Kroner>"])
|
125
135
|
)
|
126
136
|
end
|
127
137
|
|
@@ -161,6 +161,13 @@ class TextHelperTest < Test::Unit::TestCase
|
|
161
161
|
assert_equal %(<p><a href="#{url1}">#{url1}</a><br /><a href="#{url2}">#{url2}</a><br /></p>), auto_link("<p>#{url1}<br />#{url2}<br /></p>")
|
162
162
|
end
|
163
163
|
|
164
|
+
def test_auto_link_with_block
|
165
|
+
url = "http://api.rubyonrails.com/Foo.html"
|
166
|
+
email = "fantabulous@shiznadel.ic"
|
167
|
+
|
168
|
+
assert_equal %(<p><a href="#{url}">#{url[0..7]}...</a><br /><a href="mailto:#{email}">#{email[0..7]}...</a><br /></p>), auto_link("<p>#{url}<br />#{email}<br /></p>") { |url| truncate(url, 10) }
|
169
|
+
end
|
170
|
+
|
164
171
|
def test_sanitize_form
|
165
172
|
raw = "<form action=\"/foo/bar\" method=\"post\"><input></form>"
|
166
173
|
result = sanitize(raw)
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
|
|
3
3
|
specification_version: 1
|
4
4
|
name: actionpack
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.11.
|
7
|
-
date: 2005-
|
6
|
+
version: 1.11.1
|
7
|
+
date: 2005-12-07 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
|
@@ -107,6 +107,7 @@ files:
|
|
107
107
|
- lib/action_controller/vendor/html-scanner/html
|
108
108
|
- lib/action_controller/vendor/html-scanner/html/document.rb
|
109
109
|
- lib/action_controller/vendor/html-scanner/html/node.rb
|
110
|
+
- lib/action_controller/vendor/html-scanner/html/node.rb.rej
|
110
111
|
- lib/action_controller/vendor/html-scanner/html/tokenizer.rb
|
111
112
|
- lib/action_controller/vendor/html-scanner/html/version.rb
|
112
113
|
- lib/action_pack/version.rb
|
@@ -194,6 +195,7 @@ files:
|
|
194
195
|
- test/fixtures/helpers/abc_helper.rb
|
195
196
|
- test/fixtures/helpers/fun
|
196
197
|
- test/fixtures/helpers/fun/games_helper.rb
|
198
|
+
- test/fixtures/helpers/fun/pdf_helper.rb
|
197
199
|
- test/fixtures/layouts/builder.rxml
|
198
200
|
- test/fixtures/layouts/standard.rhtml
|
199
201
|
- test/fixtures/layouts/talk_from_action.rhtml
|
@@ -219,6 +221,8 @@ files:
|
|
219
221
|
- test/fixtures/test/hello_xml_world.rxml
|
220
222
|
- test/fixtures/test/list.rhtml
|
221
223
|
- test/fixtures/test/potential_conflicts.rhtml
|
224
|
+
- test/fixtures/test/render_file_with_ivar.rhtml
|
225
|
+
- test/fixtures/test/render_file_with_locals.rhtml
|
222
226
|
- test/fixtures/test/render_to_string_test.rhtml
|
223
227
|
- test/fixtures/test/update_element_with_capture.rhtml
|
224
228
|
- test/template/active_record_helper_test.rb
|
@@ -267,5 +271,5 @@ dependencies:
|
|
267
271
|
-
|
268
272
|
- "="
|
269
273
|
- !ruby/object:Gem::Version
|
270
|
-
version: 1.2.
|
274
|
+
version: 1.2.4
|
271
275
|
version:
|