actionpack 1.9.1 → 1.10.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.

Files changed (123) hide show
  1. data/CHANGELOG +237 -0
  2. data/README +12 -12
  3. data/lib/action_controller.rb +17 -12
  4. data/lib/action_controller/assertions.rb +119 -67
  5. data/lib/action_controller/base.rb +184 -102
  6. data/lib/action_controller/benchmarking.rb +35 -6
  7. data/lib/action_controller/caching.rb +115 -58
  8. data/lib/action_controller/cgi_ext/cgi_methods.rb +54 -21
  9. data/lib/action_controller/cgi_ext/cookie_performance_fix.rb +39 -35
  10. data/lib/action_controller/cgi_ext/raw_post_data_fix.rb +34 -21
  11. data/lib/action_controller/cgi_process.rb +23 -20
  12. data/lib/action_controller/components.rb +11 -2
  13. data/lib/action_controller/dependencies.rb +0 -5
  14. data/lib/action_controller/deprecated_redirects.rb +17 -0
  15. data/lib/action_controller/filters.rb +13 -9
  16. data/lib/action_controller/flash.rb +7 -7
  17. data/lib/action_controller/helpers.rb +1 -14
  18. data/lib/action_controller/layout.rb +40 -29
  19. data/lib/action_controller/macros/auto_complete.rb +52 -0
  20. data/lib/action_controller/macros/in_place_editing.rb +32 -0
  21. data/lib/action_controller/pagination.rb +44 -28
  22. data/lib/action_controller/request.rb +54 -40
  23. data/lib/action_controller/rescue.rb +8 -6
  24. data/lib/action_controller/routing.rb +77 -28
  25. data/lib/action_controller/scaffolding.rb +10 -14
  26. data/lib/action_controller/session/active_record_store.rb +36 -7
  27. data/lib/action_controller/session_management.rb +126 -0
  28. data/lib/action_controller/streaming.rb +14 -5
  29. data/lib/action_controller/templates/rescues/_request_and_response.rhtml +1 -1
  30. data/lib/action_controller/templates/rescues/_trace.rhtml +24 -0
  31. data/lib/action_controller/templates/rescues/diagnostics.rhtml +2 -13
  32. data/lib/action_controller/templates/rescues/template_error.rhtml +4 -2
  33. data/lib/action_controller/templates/scaffolds/list.rhtml +1 -1
  34. data/lib/action_controller/test_process.rb +35 -17
  35. data/lib/action_controller/upload_progress.rb +52 -0
  36. data/lib/action_controller/url_rewriter.rb +21 -16
  37. data/lib/action_controller/vendor/html-scanner/html/document.rb +2 -2
  38. data/lib/action_controller/vendor/html-scanner/html/node.rb +30 -3
  39. data/lib/action_pack/version.rb +9 -0
  40. data/lib/action_view.rb +1 -1
  41. data/lib/action_view/base.rb +204 -60
  42. data/lib/action_view/compiled_templates.rb +70 -0
  43. data/lib/action_view/helpers/active_record_helper.rb +7 -3
  44. data/lib/action_view/helpers/asset_tag_helper.rb +22 -12
  45. data/lib/action_view/helpers/capture_helper.rb +2 -10
  46. data/lib/action_view/helpers/date_helper.rb +21 -13
  47. data/lib/action_view/helpers/form_helper.rb +14 -10
  48. data/lib/action_view/helpers/form_options_helper.rb +4 -4
  49. data/lib/action_view/helpers/form_tag_helper.rb +59 -25
  50. data/lib/action_view/helpers/java_script_macros_helper.rb +188 -0
  51. data/lib/action_view/helpers/javascript_helper.rb +68 -133
  52. data/lib/action_view/helpers/javascripts/controls.js +427 -165
  53. data/lib/action_view/helpers/javascripts/dragdrop.js +256 -277
  54. data/lib/action_view/helpers/javascripts/effects.js +766 -277
  55. data/lib/action_view/helpers/javascripts/prototype.js +906 -218
  56. data/lib/action_view/helpers/javascripts/slider.js +258 -0
  57. data/lib/action_view/helpers/number_helper.rb +4 -3
  58. data/lib/action_view/helpers/pagination_helper.rb +42 -27
  59. data/lib/action_view/helpers/tag_helper.rb +25 -11
  60. data/lib/action_view/helpers/text_helper.rb +119 -13
  61. data/lib/action_view/helpers/upload_progress_helper.rb +2 -2
  62. data/lib/action_view/helpers/url_helper.rb +68 -21
  63. data/lib/action_view/partials.rb +17 -6
  64. data/lib/action_view/template_error.rb +19 -24
  65. data/rakefile +4 -3
  66. data/test/abstract_unit.rb +2 -1
  67. data/test/controller/action_pack_assertions_test.rb +62 -2
  68. data/test/controller/active_record_assertions_test.rb +5 -6
  69. data/test/controller/active_record_store_test.rb +23 -1
  70. data/test/controller/addresses_render_test.rb +4 -0
  71. data/test/controller/{base_tests.rb → base_test.rb} +4 -3
  72. data/test/controller/benchmark_test.rb +36 -0
  73. data/test/controller/caching_filestore.rb +22 -40
  74. data/test/controller/capture_test.rb +10 -1
  75. data/test/controller/cgi_test.rb +145 -23
  76. data/test/controller/components_test.rb +50 -0
  77. data/test/controller/custom_handler_test.rb +3 -3
  78. data/test/controller/fake_controllers.rb +24 -0
  79. data/test/controller/filters_test.rb +6 -6
  80. data/test/controller/flash_test.rb +6 -6
  81. data/test/controller/fragment_store_setting_test.rb +45 -0
  82. data/test/controller/helper_test.rb +1 -3
  83. data/test/controller/new_render_test.rb +119 -7
  84. data/test/controller/redirect_test.rb +11 -1
  85. data/test/controller/render_test.rb +34 -1
  86. data/test/controller/request_test.rb +14 -5
  87. data/test/controller/routing_test.rb +238 -42
  88. data/test/controller/send_file_test.rb +11 -10
  89. data/test/controller/session_management_test.rb +94 -0
  90. data/test/controller/test_test.rb +194 -5
  91. data/test/controller/url_rewriter_test.rb +46 -0
  92. data/test/fixtures/layouts/talk_from_action.rhtml +2 -0
  93. data/test/fixtures/layouts/yield.rhtml +2 -0
  94. data/test/fixtures/multipart/binary_file +0 -0
  95. data/test/fixtures/multipart/large_text_file +10 -0
  96. data/test/fixtures/multipart/mixed_files +0 -0
  97. data/test/fixtures/multipart/single_parameter +5 -0
  98. data/test/fixtures/multipart/text_file +10 -0
  99. data/test/fixtures/test/_customer_greeting.rhtml +1 -0
  100. data/test/fixtures/test/_hash_object.rhtml +1 -0
  101. data/test/fixtures/test/_person.rhtml +2 -0
  102. data/test/fixtures/test/action_talk_to_layout.rhtml +2 -0
  103. data/test/fixtures/test/content_for.rhtml +2 -0
  104. data/test/fixtures/test/potential_conflicts.rhtml +4 -0
  105. data/test/template/active_record_helper_test.rb +15 -8
  106. data/test/template/asset_tag_helper_test.rb +40 -16
  107. data/test/template/compiled_templates_tests.rb +63 -0
  108. data/test/template/date_helper_test.rb +80 -4
  109. data/test/template/form_helper_test.rb +48 -42
  110. data/test/template/form_options_helper_test.rb +40 -40
  111. data/test/template/form_tag_helper_test.rb +21 -15
  112. data/test/template/java_script_macros_helper_test.rb +56 -0
  113. data/test/template/javascript_helper_test.rb +70 -47
  114. data/test/template/number_helper_test.rb +2 -0
  115. data/test/template/tag_helper_test.rb +9 -0
  116. data/test/template/text_helper_test.rb +146 -1
  117. data/test/template/upload_progress_helper_testx.rb +11 -147
  118. data/test/template/url_helper_test.rb +90 -22
  119. data/test/testing_sandbox.rb +26 -0
  120. metadata +37 -7
  121. data/lib/action_controller/auto_complete.rb +0 -47
  122. data/lib/action_controller/deprecated_renders_and_redirects.rb +0 -76
  123. data/lib/action_controller/session.rb +0 -14
@@ -32,142 +32,6 @@ class MockProgress
32
32
  end
33
33
  end
34
34
 
35
- class UploadProgressHelperTest < Test::Unit::TestCase
36
- include ActionView::Helpers::DateHelper
37
- include ActionView::Helpers::NumberHelper
38
- include ActionView::Helpers::AssetTagHelper
39
- include ActionView::Helpers::FormTagHelper
40
- include ActionView::Helpers::TagHelper
41
- include ActionView::Helpers::UrlHelper
42
- include ActionView::Helpers::JavaScriptHelper
43
- include ActionView::Helpers::UploadProgressHelper
44
-
45
- def next_upload_id; @upload_id = last_upload_id.succ; end
46
- def last_upload_id; @upload_id ||= 0; end
47
- def current_upload_id; last_upload_id; end
48
- def upload_progress(upload_id = nil); @upload_progress or MockProgress.new(false, true); end
49
-
50
- def setup
51
- @controller = Class.new do
52
- def url_for(options, *parameters_for_method_reference)
53
- "http://www.example.com"
54
- end
55
- end
56
- @controller = @controller.new
57
- end
58
-
59
- def test_upload_status_tag
60
- assert_equal(
61
- '<div class="progressBar" id="UploadProgressBar0"><div class="border"><div class="background"><div class="foreground"></div></div></div></div><div class="uploadStatus" id="UploadStatus0"></div>',
62
- upload_status_tag
63
- )
64
- end
65
-
66
- def test_upload_status_text_tag
67
- assert_equal(
68
- '<div class="my-upload" id="my-id">Starting</div>',
69
- upload_status_text_tag('Starting', :class => 'my-upload', :id => 'my-id')
70
- )
71
- end
72
-
73
-
74
- def test_upload_progress_text
75
- @upload_progress = MockProgress.new(false, false)
76
- assert_equal(
77
- "Upload starting...",
78
- upload_progress_text
79
- )
80
-
81
- @upload_progress = MockProgress.new(true, false)
82
- assert_equal(
83
- "828.7 MB of 456.2 MB at 990.1 MB/s; 10227 days remaining",
84
- upload_progress_text
85
- )
86
-
87
- @upload_progress = MockProgress.new(true, true)
88
- assert_equal(
89
- "Upload finished. A message",
90
- upload_progress_text
91
- )
92
- end
93
-
94
- def test_upload_progress_update_bar_js
95
- assert_equal(
96
- "$('UploadProgressBar0').firstChild.firstChild.style.width='0%';",
97
- upload_progress_update_bar_js
98
- )
99
-
100
- assert_equal(
101
- "$('UploadProgressBar0').firstChild.firstChild.style.width='50%';",
102
- upload_progress_update_bar_js(50)
103
- )
104
- end
105
-
106
- def test_finish_upload_status
107
- assert_equal(
108
- "<html><head><script language=\"javascript\" type=\"text/javascript\">function finish() { if (parent.document.uploadStatus0) { parent.document.uploadStatus0.stop();\n }\n }</script></head><body onload=\"finish()\"></body></html>",
109
- finish_upload_status
110
- )
111
-
112
- assert_equal(
113
- "<html><head><script language=\"javascript\" type=\"text/javascript\">function finish() { if (parent.document.uploadStatus0) { parent.document.uploadStatus0.stop(123);\n }\n }</script></head><body onload=\"finish()\"></body></html>",
114
- finish_upload_status(:client_js_argument => 123)
115
- )
116
-
117
- assert_equal(
118
- "<html><head><script language=\"javascript\" type=\"text/javascript\">function finish() { if (parent.document.uploadStatus0) { parent.document.uploadStatus0.stop();\nparent.location.replace('/redirected/');\n }\n }</script></head><body onload=\"finish()\"></body></html>",
119
- finish_upload_status(:redirect_to => '/redirected/')
120
- )
121
- end
122
-
123
- def test_form_tag_with_upload_progress
124
- assert_equal(
125
- "<form action=\"http://www.example.com\" enctype=\"multipart/form-data\" method=\"post\" onsubmit=\"if (this.action.indexOf('upload_id') &lt; 0){ this.action += '?upload_id=1'; }this.target = 'UploadTarget1';$('UploadProgressBar1').firstChild.firstChild.style.width='0%';; document.uploadStatus1 = new Ajax.PeriodicalUpdater('UploadStatus1','http://www.example.com',{script:true, onComplete:function(request){$('UploadProgressBar1').firstChild.firstChild.style.width='100%';; }, asynchronous:true}.extend({decay:1.8,frequency:2.0})); return true\"><iframe id=\"UploadTarget1\" name=\"UploadTarget1\" src=\"\" style=\"width:0px;height:0px;border:0\"></iframe>",
126
- form_tag_with_upload_progress
127
- )
128
- end
129
-
130
- def test_form_tag_with_upload_progress_custom
131
- assert_equal(
132
- "<form action=\"http://www.example.com\" enctype=\"multipart/form-data\" method=\"post\" onsubmit=\"if (this.action.indexOf('upload_id') &lt; 0){ this.action += '?upload_id=5'; }this.target = 'awindow';$('UploadProgressBar0').firstChild.firstChild.style.width='0%';; alert('foo'); document.uploadStatus0 = new Ajax.PeriodicalUpdater('UploadStatus0','http://www.example.com',{script:true, onComplete:function(request){$('UploadProgressBar0').firstChild.firstChild.style.width='100%';; alert('bar'); alert('bar')}, asynchronous:true}.extend({decay:7,frequency:6})); return true\" target=\"awindow\">",
133
- form_tag_with_upload_progress({:upload_id => 5}, {:begin => "alert('foo')", :finish => "alert('bar')", :frequency => 6, :decay => 7, :target => 'awindow'})
134
- )
135
- end
136
- end
137
- require File.dirname(__FILE__) + '/../abstract_unit'
138
-
139
- require File.dirname(__FILE__) + '/../../lib/action_view/helpers/date_helper'
140
- require File.dirname(__FILE__) + '/../../lib/action_view/helpers/number_helper'
141
- require File.dirname(__FILE__) + '/../../lib/action_view/helpers/asset_tag_helper'
142
- require File.dirname(__FILE__) + '/../../lib/action_view/helpers/form_tag_helper'
143
- require File.dirname(__FILE__) + '/../../lib/action_view/helpers/tag_helper'
144
- require File.dirname(__FILE__) + '/../../lib/action_view/helpers/javascript_helper'
145
- require File.dirname(__FILE__) + '/../../lib/action_view/helpers/upload_progress_helper'
146
- require File.dirname(__FILE__) + '/../../../activesupport/lib/active_support/core_ext/hash' #for stringify keys
147
-
148
- class MockProgress
149
- def initialize(started, finished)
150
- @started, @finished = [started, finished]
151
- end
152
-
153
- def started?
154
- @started
155
- end
156
-
157
- def finished?
158
- @finished
159
- end
160
-
161
- def message
162
- "A message"
163
- end
164
-
165
- def method_missing(meth, *args)
166
- # Just return some consitant number
167
- meth.to_s.hash.to_i.abs + args.hash.to_i.abs
168
- end
169
- end
170
-
171
35
  class UploadProgressHelperTest < Test::Unit::TestCase
172
36
  include ActionView::Helpers::DateHelper
173
37
  include ActionView::Helpers::NumberHelper
@@ -193,14 +57,14 @@ class UploadProgressHelperTest < Test::Unit::TestCase
193
57
  end
194
58
 
195
59
  def test_upload_status_tag
196
- assert_equal(
60
+ assert_dom_equal(
197
61
  '<div class="progressBar" id="UploadProgressBar0"><div class="border"><div class="background"><div class="foreground"></div></div></div></div><div class="uploadStatus" id="UploadStatus0"></div>',
198
62
  upload_status_tag
199
63
  )
200
64
  end
201
65
 
202
66
  def test_upload_status_text_tag
203
- assert_equal(
67
+ assert_dom_equal(
204
68
  '<div class="my-upload" id="my-id">Starting</div>',
205
69
  upload_status_text_tag('Starting', :class => 'my-upload', :id => 'my-id')
206
70
  )
@@ -229,43 +93,43 @@ class UploadProgressHelperTest < Test::Unit::TestCase
229
93
 
230
94
  def test_upload_progress_update_bar_js
231
95
  assert_equal(
232
- "$('UploadProgressBar0').firstChild.firstChild.style.width='0%'",
96
+ "if($('UploadProgressBar0')){$('UploadProgressBar0').firstChild.firstChild.style.width='0%'}",
233
97
  upload_progress_update_bar_js
234
98
  )
235
99
 
236
100
  assert_equal(
237
- "$('UploadProgressBar0').firstChild.firstChild.style.width='50%'",
101
+ "if($('UploadProgressBar0')){$('UploadProgressBar0').firstChild.firstChild.style.width='50%'}",
238
102
  upload_progress_update_bar_js(50)
239
103
  )
240
104
  end
241
105
 
242
106
  def test_finish_upload_status
243
- assert_equal(
107
+ assert_dom_equal(
244
108
  "<html><head><script language=\"javascript\" type=\"text/javascript\">function finish() { if (parent.document.uploadStatus0) { parent.document.uploadStatus0.stop();\n }\n }</script></head><body onload=\"finish()\"></body></html>",
245
109
  finish_upload_status
246
110
  )
247
111
 
248
- assert_equal(
112
+ assert_dom_equal(
249
113
  "<html><head><script language=\"javascript\" type=\"text/javascript\">function finish() { if (parent.document.uploadStatus0) { parent.document.uploadStatus0.stop(123);\n }\n }</script></head><body onload=\"finish()\"></body></html>",
250
114
  finish_upload_status(:client_js_argument => 123)
251
115
  )
252
116
 
253
- assert_equal(
117
+ assert_dom_equal(
254
118
  "<html><head><script language=\"javascript\" type=\"text/javascript\">function finish() { if (parent.document.uploadStatus0) { parent.document.uploadStatus0.stop();\nparent.location.replace('/redirected/');\n }\n }</script></head><body onload=\"finish()\"></body></html>",
255
119
  finish_upload_status(:redirect_to => '/redirected/')
256
120
  )
257
121
  end
258
122
 
259
123
  def test_form_tag_with_upload_progress
260
- assert_equal(
261
- "<form action=\"http://www.example.com\" enctype=\"multipart/form-data\" method=\"post\" onsubmit=\"if (this.action.indexOf('upload_id') &lt; 0){ this.action += '?upload_id=1'; }this.target = 'UploadTarget1';$('UploadStatus1').innerHTML='Upload starting...'; $('UploadProgressBar1').firstChild.firstChild.style.width='0%'; if (document.uploadStatus1) { document.uploadStatus1.stop(); }document.uploadStatus1 = new Ajax.PeriodicalUpdater('UploadStatus1','http://www.example.com', {onComplete:function(request){$('UploadStatus1').innerHTML='A message';$('UploadProgressBar1').firstChild.firstChild.style.width='100%';document.uploadStatus1 = null}, evalScripts:true, asynchronous:true}.extend({decay:1.8,frequency:2.0})); return true\"><iframe id=\"UploadTarget1\" name=\"UploadTarget1\" src=\"\" style=\"width:0px;height:0px;border:0\"></iframe>",
124
+ assert_dom_equal(
125
+ "<form action=\"http://www.example.com\" enctype=\"multipart/form-data\" method=\"post\" onsubmit=\"if (this.action.indexOf('upload_id') &lt; 0){ this.action += '?upload_id=1'; }this.target = 'UploadTarget1';$('UploadStatus1').innerHTML='Upload starting...'; if($('UploadProgressBar1')){$('UploadProgressBar1').firstChild.firstChild.style.width='0%'}; if (document.uploadStatus1) { document.uploadStatus1.stop(); }document.uploadStatus1 = new Ajax.PeriodicalUpdater('UploadStatus1','http://www.example.com', Object.extend({asynchronous:true, evalScripts:true, onComplete:function(request){$('UploadStatus1').innerHTML='A message';if($('UploadProgressBar1')){$('UploadProgressBar1').firstChild.firstChild.style.width='100%'};document.uploadStatus1 = null}},{decay:1.8,frequency:2.0})); return true\"><iframe id=\"UploadTarget1\" name=\"UploadTarget1\" src=\"\" style=\"width:0px;height:0px;border:0\"></iframe>",
262
126
  form_tag_with_upload_progress
263
127
  )
264
128
  end
265
129
 
266
130
  def test_form_tag_with_upload_progress_custom
267
- assert_equal(
268
- "<form action=\"http://www.example.com\" enctype=\"multipart/form-data\" method=\"post\" onsubmit=\"if (this.action.indexOf('upload_id') &lt; 0){ this.action += '?upload_id=5'; }this.target = 'awindow';$('UploadStatus0').innerHTML='Upload starting...'; $('UploadProgressBar0').firstChild.firstChild.style.width='0%'; alert('foo'); if (document.uploadStatus0) { document.uploadStatus0.stop(); }document.uploadStatus0 = new Ajax.PeriodicalUpdater('UploadStatus0','http://www.example.com', {onComplete:function(request){$('UploadStatus0').innerHTML='A message';$('UploadProgressBar0').firstChild.firstChild.style.width='100%';document.uploadStatus0 = null; alert('bar')}, evalScripts:true, asynchronous:true}.extend({decay:7,frequency:6})); return true\" target=\"awindow\">",
131
+ assert_dom_equal(
132
+ "<form action=\"http://www.example.com\" enctype=\"multipart/form-data\" method=\"post\" onsubmit=\"if (this.action.indexOf('upload_id') &lt; 0){ this.action += '?upload_id=5'; }this.target = 'awindow';$('UploadStatus0').innerHTML='Upload starting...'; if($('UploadProgressBar0')){$('UploadProgressBar0').firstChild.firstChild.style.width='0%'}; alert('foo'); if (document.uploadStatus0) { document.uploadStatus0.stop(); }document.uploadStatus0 = new Ajax.PeriodicalUpdater('UploadStatus0','http://www.example.com', Object.extend({asynchronous:true, evalScripts:true, onComplete:function(request){$('UploadStatus0').innerHTML='A message';if($('UploadProgressBar0')){$('UploadProgressBar0').firstChild.firstChild.style.width='100%'};document.uploadStatus0 = null; alert('bar')}},{decay:7,frequency:6})); return true\" target=\"awindow\">",
269
133
  form_tag_with_upload_progress({:upload_id => 5}, {:begin => "alert('foo')", :finish => "alert('bar')", :frequency => 6, :decay => 7, :target => 'awindow'})
270
134
  )
271
135
  end
@@ -22,45 +22,113 @@ class UrlHelperTest < Test::Unit::TestCase
22
22
 
23
23
  # todo: missing test cases
24
24
  def test_button_to_with_straight_url
25
- assert_equal "<form method=\"post\" action=\"http://www.example.com\" class=\"button-to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>", button_to("Hello", "http://www.example.com")
25
+ assert_dom_equal "<form method=\"post\" action=\"http://www.example.com\" class=\"button-to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>", button_to("Hello", "http://www.example.com")
26
+ end
27
+
28
+ def test_button_to_with_query
29
+ assert_dom_equal "<form method=\"post\" action=\"http://www.example.com/q1=v1&amp;q2=v2\" class=\"button-to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>", button_to("Hello", "http://www.example.com/q1=v1&q2=v2")
30
+ end
31
+
32
+ def test_button_to_with_query_and_no_name
33
+ assert_dom_equal "<form method=\"post\" action=\"http://www.example.com?q1=v1&amp;q2=v2\" class=\"button-to\"><div><input type=\"submit\" value=\"http://www.example.com?q1=v1&amp;q2=v2\" /></div></form>", button_to(nil, "http://www.example.com?q1=v1&q2=v2")
26
34
  end
27
35
 
28
36
  def test_button_to_with_javascript_confirm
29
- assert_equal(
37
+ assert_dom_equal(
30
38
  "<form method=\"post\" action=\"http://www.example.com\" class=\"button-to\"><div><input onclick=\"return confirm('Are you sure?');\" type=\"submit\" value=\"Hello\" /></div></form>",
31
39
  button_to("Hello", "http://www.example.com", :confirm => "Are you sure?")
32
40
  )
33
41
  end
34
42
 
35
43
  def test_button_to_enabled_disabled
36
- assert_equal(
44
+ assert_dom_equal(
37
45
  "<form method=\"post\" action=\"http://www.example.com\" class=\"button-to\"><div><input type=\"submit\" value=\"Hello\" /></div></form>",
38
46
  button_to("Hello", "http://www.example.com", :disabled => false)
39
47
  )
40
- assert_equal(
48
+ assert_dom_equal(
41
49
  "<form method=\"post\" action=\"http://www.example.com\" class=\"button-to\"><div><input disabled=\"disabled\" type=\"submit\" value=\"Hello\" /></div></form>",
42
50
  button_to("Hello", "http://www.example.com", :disabled => true)
43
51
  )
44
52
  end
45
53
 
46
54
  def test_link_tag_with_straight_url
47
- assert_equal "<a href=\"http://www.example.com\">Hello</a>", link_to("Hello", "http://www.example.com")
55
+ assert_dom_equal "<a href=\"http://www.example.com\">Hello</a>", link_to("Hello", "http://www.example.com")
56
+ end
57
+
58
+ def test_link_tag_with_query
59
+ assert_dom_equal "<a href=\"http://www.example.com?q1=v1&amp;q2=v2\">Hello</a>", link_to("Hello", "http://www.example.com?q1=v1&q2=v2")
60
+ end
61
+
62
+ def test_link_tag_with_query_and_no_name
63
+ assert_dom_equal "<a href=\"http://www.example.com?q1=v1&amp;q2=v2\">http://www.example.com?q1=v1&amp;q2=v2</a>", link_to(nil, "http://www.example.com?q1=v1&q2=v2")
64
+ end
65
+
66
+ def test_link_tag_with_custom_onclick
67
+ assert_dom_equal "<a href=\"http://www.example.com\" onclick=\"alert('yay!')\">Hello</a>", link_to("Hello", "http://www.example.com", :onclick => "alert('yay!')")
48
68
  end
49
69
 
50
70
  def test_link_tag_with_javascript_confirm
51
- assert_equal(
71
+ assert_dom_equal(
52
72
  "<a href=\"http://www.example.com\" onclick=\"return confirm('Are you sure?');\">Hello</a>",
53
73
  link_to("Hello", "http://www.example.com", :confirm => "Are you sure?")
54
74
  )
55
- assert_equal(
75
+ assert_dom_equal(
56
76
  "<a href=\"http://www.example.com\" onclick=\"return confirm('You can\\'t possibly be sure, can you?');\">Hello</a>",
57
77
  link_to("Hello", "http://www.example.com", :confirm => "You can't possibly be sure, can you?")
58
78
  )
79
+ assert_dom_equal(
80
+ "<a href=\"http://www.example.com\" onclick=\"return confirm('You can\\'t possibly be sure,\\n can you?');\">Hello</a>",
81
+ link_to("Hello", "http://www.example.com", :confirm => "You can't possibly be sure,\n can you?")
82
+ )
59
83
  end
60
84
 
85
+ def test_link_tag_with_popup
86
+ assert_dom_equal(
87
+ "<a href=\"http://www.example.com\" onclick=\"window.open(this.href);return false;\">Hello</a>",
88
+ link_to("Hello", "http://www.example.com", :popup => true)
89
+ )
90
+ assert_dom_equal(
91
+ "<a href=\"http://www.example.com\" onclick=\"window.open(this.href);return false;\">Hello</a>",
92
+ link_to("Hello", "http://www.example.com", :popup => 'true')
93
+ )
94
+ assert_dom_equal(
95
+ "<a href=\"http://www.example.com\" onclick=\"window.open(this.href,'window_name','width=300,height=300');return false;\">Hello</a>",
96
+ link_to("Hello", "http://www.example.com", :popup => ['window_name', 'width=300,height=300'])
97
+ )
98
+ end
99
+
100
+ def test_link_tag_with_popup_and_javascript_confirm
101
+ assert_dom_equal(
102
+ "<a href=\"http://www.example.com\" onclick=\"if (confirm('Fo\\' sho\\'?')) { window.open(this.href); };return false;\">Hello</a>",
103
+ link_to("Hello", "http://www.example.com", { :popup => true, :confirm => "Fo' sho'?" })
104
+ )
105
+ assert_dom_equal(
106
+ "<a href=\"http://www.example.com\" onclick=\"if (confirm('Are you serious?')) { window.open(this.href,'window_name','width=300,height=300'); };return false;\">Hello</a>",
107
+ link_to("Hello", "http://www.example.com", { :popup => ['window_name', 'width=300,height=300'], :confirm => "Are you serious?" })
108
+ )
109
+ end
110
+
111
+ def test_link_tag_using_post_javascript
112
+ assert_dom_equal(
113
+ "<a href=\"http://www.example.com\" onclick=\"f = document.createElement('form'); document.body.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit();return false;\">Hello</a>",
114
+ link_to("Hello", "http://www.example.com", :post => true)
115
+ )
116
+ end
117
+
118
+ def test_link_tag_using_post_javascript_and_confirm
119
+ assert_dom_equal(
120
+ "<a href=\"http://www.example.com\" onclick=\"if (confirm('Are you serious?')) { f = document.createElement('form'); document.body.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit(); };return false;\">Hello</a>",
121
+ link_to("Hello", "http://www.example.com", :post => true, :confirm => "Are you serious?")
122
+ )
123
+ end
124
+
125
+ def test_link_tag_using_post_javascript_and_popup
126
+ assert_raises(ActionView::ActionViewError) { link_to("Hello", "http://www.example.com", :popup => true, :post => true, :confirm => "Are you serious?") }
127
+ end
128
+
61
129
  def test_link_to_unless
62
130
  assert_equal "Showing", link_to_unless(true, "Showing", :action => "show", :controller => "weblog")
63
- assert "<a href=\"http://www.example.com\">Listing</a>", link_to_unless(false, "Listing", :action => "list", :controller => "weblog")
131
+ assert_dom_equal "<a href=\"http://www.example.com\">Listing</a>", link_to_unless(false, "Listing", :action => "list", :controller => "weblog")
64
132
  assert_equal "Showing", link_to_unless(true, "Showing", :action => "show", :controller => "weblog", :id => 1)
65
133
  assert_equal "<strong>Showing</strong>", link_to_unless(true, "Showing", :action => "show", :controller => "weblog", :id => 1) { |name, options, html_options, *parameters_for_method_reference|
66
134
  "<strong>#{name}</strong>"
@@ -75,12 +143,12 @@ class UrlHelperTest < Test::Unit::TestCase
75
143
 
76
144
  def test_link_to_if
77
145
  assert_equal "Showing", link_to_if(false, "Showing", :action => "show", :controller => "weblog")
78
- assert "<a href=\"http://www.example.com\">Listing</a>", link_to_if(true, "Listing", :action => "list", :controller => "weblog")
146
+ assert_dom_equal "<a href=\"http://www.example.com\">Listing</a>", link_to_if(true, "Listing", :action => "list", :controller => "weblog")
79
147
  assert_equal "Showing", link_to_if(false, "Showing", :action => "show", :controller => "weblog", :id => 1)
80
148
  end
81
149
 
82
150
 
83
- def test_link_unless_current
151
+ def xtest_link_unless_current
84
152
  @request = RequestMock.new("http://www.example.com")
85
153
  assert_equal "Showing", link_to_unless_current("Showing", :action => "show", :controller => "weblog")
86
154
  @request = RequestMock.new("http://www.example.org")
@@ -91,9 +159,9 @@ class UrlHelperTest < Test::Unit::TestCase
91
159
  end
92
160
 
93
161
  def test_mail_to
94
- assert_equal "<a href=\"mailto:david@loudthinking.com\">david@loudthinking.com</a>", mail_to("david@loudthinking.com")
95
- assert_equal "<a href=\"mailto:david@loudthinking.com\">David Heinemeier Hansson</a>", mail_to("david@loudthinking.com", "David Heinemeier Hansson")
96
- assert_equal(
162
+ assert_dom_equal "<a href=\"mailto:david@loudthinking.com\">david@loudthinking.com</a>", mail_to("david@loudthinking.com")
163
+ assert_dom_equal "<a href=\"mailto:david@loudthinking.com\">David Heinemeier Hansson</a>", mail_to("david@loudthinking.com", "David Heinemeier Hansson")
164
+ assert_dom_equal(
97
165
  "<a class=\"admin\" href=\"mailto:david@loudthinking.com\">David Heinemeier Hansson</a>",
98
166
  mail_to("david@loudthinking.com", "David Heinemeier Hansson", "class" => "admin")
99
167
  )
@@ -102,29 +170,29 @@ class UrlHelperTest < Test::Unit::TestCase
102
170
  end
103
171
 
104
172
  def test_mail_to_with_javascript
105
- assert_equal "<script type=\"text/javascript\" language=\"javascript\">eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%22%3e%4d%79%20%65%6d%61%69%6c%3c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", "My email", :encode => "javascript")
173
+ assert_dom_equal "<script type=\"text/javascript\" language=\"javascript\">eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%22%3e%4d%79%20%65%6d%61%69%6c%3c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", "My email", :encode => "javascript")
106
174
  end
107
175
 
108
176
  def test_mail_with_options
109
- assert_equal(
177
+ assert_dom_equal(
110
178
  %(<a href="mailto:me@example.com?cc=ccaddress%40example.com&amp;bcc=bccaddress%40example.com&amp;body=This%20is%20the%20body%20of%20the%20message.&amp;subject=This%20is%20an%20example%20email">My email</a>),
111
179
  mail_to("me@example.com", "My email", :cc => "ccaddress@example.com", :bcc => "bccaddress@example.com", :subject => "This is an example email", :body => "This is the body of the message.")
112
180
  )
113
181
  end
114
182
 
115
183
  def test_mail_to_with_hex
116
- assert_equal "<a href=\"mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">My email</a>", mail_to("me@domain.com", "My email", :encode => "hex")
184
+ assert_dom_equal "<a href=\"mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">My email</a>", mail_to("me@domain.com", "My email", :encode => "hex")
117
185
  end
118
186
 
119
187
  def test_mail_to_with_replace_options
120
- assert_equal "<a href=\"mailto:wolfgang@stufenlos.net\">wolfgang(at)stufenlos(dot)net</a>", mail_to("wolfgang@stufenlos.net", nil, :replace_at => "(at)", :replace_dot => "(dot)")
121
- assert_equal "<a href=\"mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">me(at)domain.com</a>", mail_to("me@domain.com", nil, :encode => "hex", :replace_at => "(at)")
122
- assert_equal "<a href=\"mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">My email</a>", mail_to("me@domain.com", "My email", :encode => "hex", :replace_at => "(at)")
123
- assert_equal "<a href=\"mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">me(at)domain(dot)com</a>", mail_to("me@domain.com", nil, :encode => "hex", :replace_at => "(at)", :replace_dot => "(dot)")
124
- assert_equal "<script type=\"text/javascript\" language=\"javascript\">eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%22%3e%4d%79%20%65%6d%61%69%6c%3c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", "My email", :encode => "javascript", :replace_at => "(at)", :replace_dot => "(dot)")
188
+ assert_dom_equal "<a href=\"mailto:wolfgang@stufenlos.net\">wolfgang(at)stufenlos(dot)net</a>", mail_to("wolfgang@stufenlos.net", nil, :replace_at => "(at)", :replace_dot => "(dot)")
189
+ assert_dom_equal "<a href=\"mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">me(at)domain.com</a>", mail_to("me@domain.com", nil, :encode => "hex", :replace_at => "(at)")
190
+ assert_dom_equal "<a href=\"mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">My email</a>", mail_to("me@domain.com", "My email", :encode => "hex", :replace_at => "(at)")
191
+ assert_dom_equal "<a href=\"mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d\">me(at)domain(dot)com</a>", mail_to("me@domain.com", nil, :encode => "hex", :replace_at => "(at)", :replace_dot => "(dot)")
192
+ assert_dom_equal "<script type=\"text/javascript\" language=\"javascript\">eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%69%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%22%3e%4d%79%20%65%6d%61%69%6c%3c%2f%61%3e%27%29%3b'))</script>", mail_to("me@domain.com", "My email", :encode => "javascript", :replace_at => "(at)", :replace_dot => "(dot)")
125
193
  end
126
194
 
127
195
  def test_link_with_nil_html_options
128
- assert_equal "<a href=\"http://www.example.com\">Hello</a>", link_to("Hello", {:action => 'myaction'}, nil)
196
+ assert_dom_equal "<a href=\"http://www.example.com\">Hello</a>", link_to("Hello", {:action => 'myaction'}, nil)
129
197
  end
130
198
  end
@@ -0,0 +1,26 @@
1
+ module TestingSandbox
2
+
3
+ # This whole thing *could* be much simpler, but I don't think Tempfile,
4
+ # popen and others exist on all platforms (like Windows).
5
+ def execute_in_sandbox(code)
6
+ test_name = "#{File.dirname(__FILE__)}/test.#{$$}.rb"
7
+ res_name = "#{File.dirname(__FILE__)}/test.#{$$}.out"
8
+
9
+ File.open(test_name, "w+") do |file|
10
+ file.write(<<-CODE)
11
+ $:.unshift "../lib"
12
+ block = Proc.new do
13
+ #{code}
14
+ end
15
+ print block.call
16
+ CODE
17
+ end
18
+
19
+ system("ruby #{test_name} > #{res_name}") or raise "could not run test in sandbox"
20
+ File.read(res_name)
21
+ ensure
22
+ File.delete(test_name) rescue nil
23
+ File.delete(res_name) rescue nil
24
+ end
25
+
26
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
3
3
  specification_version: 1
4
4
  name: actionpack
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.9.1
7
- date: 2005-07-11
6
+ version: 1.10.1
7
+ date: 2005-10-19
8
8
  summary: Web-flow and rendering framework putting the VC in MVC.
9
9
  require_paths:
10
10
  - lib
@@ -38,10 +38,10 @@ files:
38
38
  - examples/.htaccess
39
39
  - lib/action_controller
40
40
  - lib/action_controller.rb
41
+ - lib/action_pack
41
42
  - lib/action_view
42
43
  - lib/action_view.rb
43
44
  - lib/action_controller/assertions.rb
44
- - lib/action_controller/auto_complete.rb
45
45
  - lib/action_controller/base.rb
46
46
  - lib/action_controller/benchmarking.rb
47
47
  - lib/action_controller/caching.rb
@@ -52,11 +52,12 @@ files:
52
52
  - lib/action_controller/cookies.rb
53
53
  - lib/action_controller/dependencies.rb
54
54
  - lib/action_controller/deprecated_assertions.rb
55
- - lib/action_controller/deprecated_renders_and_redirects.rb
55
+ - lib/action_controller/deprecated_redirects.rb
56
56
  - lib/action_controller/filters.rb
57
57
  - lib/action_controller/flash.rb
58
58
  - lib/action_controller/helpers.rb
59
59
  - lib/action_controller/layout.rb
60
+ - lib/action_controller/macros
60
61
  - lib/action_controller/pagination.rb
61
62
  - lib/action_controller/request.rb
62
63
  - lib/action_controller/rescue.rb
@@ -64,7 +65,7 @@ files:
64
65
  - lib/action_controller/routing.rb
65
66
  - lib/action_controller/scaffolding.rb
66
67
  - lib/action_controller/session
67
- - lib/action_controller/session.rb
68
+ - lib/action_controller/session_management.rb
68
69
  - lib/action_controller/streaming.rb
69
70
  - lib/action_controller/templates
70
71
  - lib/action_controller/test_process.rb
@@ -77,6 +78,8 @@ files:
77
78
  - lib/action_controller/cgi_ext/cookie_performance_fix.rb
78
79
  - lib/action_controller/cgi_ext/multipart_progress.rb
79
80
  - lib/action_controller/cgi_ext/raw_post_data_fix.rb
81
+ - lib/action_controller/macros/auto_complete.rb
82
+ - lib/action_controller/macros/in_place_editing.rb
80
83
  - lib/action_controller/session/active_record_store.rb
81
84
  - lib/action_controller/session/drb_server.rb
82
85
  - lib/action_controller/session/drb_store.rb
@@ -84,6 +87,7 @@ files:
84
87
  - lib/action_controller/templates/rescues
85
88
  - lib/action_controller/templates/scaffolds
86
89
  - lib/action_controller/templates/rescues/_request_and_response.rhtml
90
+ - lib/action_controller/templates/rescues/_trace.rhtml
87
91
  - lib/action_controller/templates/rescues/diagnostics.rhtml
88
92
  - lib/action_controller/templates/rescues/layout.rhtml
89
93
  - lib/action_controller/templates/rescues/missing_template.rhtml
@@ -102,7 +106,9 @@ files:
102
106
  - lib/action_controller/vendor/html-scanner/html/node.rb
103
107
  - lib/action_controller/vendor/html-scanner/html/tokenizer.rb
104
108
  - lib/action_controller/vendor/html-scanner/html/version.rb
109
+ - lib/action_pack/version.rb
105
110
  - lib/action_view/base.rb
111
+ - lib/action_view/compiled_templates.rb
106
112
  - lib/action_view/helpers
107
113
  - lib/action_view/partials.rb
108
114
  - lib/action_view/template_error.rb
@@ -117,6 +123,7 @@ files:
117
123
  - lib/action_view/helpers/form_helper.rb
118
124
  - lib/action_view/helpers/form_options_helper.rb
119
125
  - lib/action_view/helpers/form_tag_helper.rb
126
+ - lib/action_view/helpers/java_script_macros_helper.rb
120
127
  - lib/action_view/helpers/javascript_helper.rb
121
128
  - lib/action_view/helpers/javascripts
122
129
  - lib/action_view/helpers/number_helper.rb
@@ -129,6 +136,7 @@ files:
129
136
  - lib/action_view/helpers/javascripts/dragdrop.js
130
137
  - lib/action_view/helpers/javascripts/effects.js
131
138
  - lib/action_view/helpers/javascripts/prototype.js
139
+ - lib/action_view/helpers/javascripts/slider.js
132
140
  - lib/action_view/vendor/builder
133
141
  - lib/action_view/vendor/builder.rb
134
142
  - lib/action_view/vendor/builder/blankslate.rb
@@ -139,19 +147,23 @@ files:
139
147
  - test/controller
140
148
  - test/fixtures
141
149
  - test/template
150
+ - test/testing_sandbox.rb
142
151
  - test/controller/action_pack_assertions_test.rb
143
152
  - test/controller/active_record_assertions_test.rb
144
153
  - test/controller/active_record_store_test.rb
145
154
  - test/controller/addresses_render_test.rb
146
- - test/controller/base_tests.rb
155
+ - test/controller/base_test.rb
156
+ - test/controller/benchmark_test.rb
147
157
  - test/controller/caching_filestore.rb
148
158
  - test/controller/capture_test.rb
149
159
  - test/controller/cgi_test.rb
150
160
  - test/controller/components_test.rb
151
161
  - test/controller/cookie_test.rb
152
162
  - test/controller/custom_handler_test.rb
163
+ - test/controller/fake_controllers.rb
153
164
  - test/controller/filters_test.rb
154
165
  - test/controller/flash_test.rb
166
+ - test/controller/fragment_store_setting_test.rb
155
167
  - test/controller/helper_test.rb
156
168
  - test/controller/multipart_progress_testx.rb
157
169
  - test/controller/new_render_test.rb
@@ -161,13 +173,16 @@ files:
161
173
  - test/controller/request_test.rb
162
174
  - test/controller/routing_test.rb
163
175
  - test/controller/send_file_test.rb
176
+ - test/controller/session_management_test.rb
164
177
  - test/controller/test_test.rb
165
178
  - test/controller/upload_progress_testx.rb
179
+ - test/controller/url_rewriter_test.rb
166
180
  - test/controller/verification_test.rb
167
181
  - test/fixtures/addresses
168
182
  - test/fixtures/fun
169
183
  - test/fixtures/helpers
170
184
  - test/fixtures/layouts
185
+ - test/fixtures/multipart
171
186
  - test/fixtures/scope
172
187
  - test/fixtures/test
173
188
  - test/fixtures/addresses/list.rhtml
@@ -178,24 +193,39 @@ files:
178
193
  - test/fixtures/helpers/fun/games_helper.rb
179
194
  - test/fixtures/layouts/builder.rxml
180
195
  - test/fixtures/layouts/standard.rhtml
196
+ - test/fixtures/layouts/talk_from_action.rhtml
197
+ - test/fixtures/layouts/yield.rhtml
198
+ - test/fixtures/multipart/binary_file
199
+ - test/fixtures/multipart/large_text_file
200
+ - test/fixtures/multipart/mixed_files
201
+ - test/fixtures/multipart/single_parameter
202
+ - test/fixtures/multipart/text_file
181
203
  - test/fixtures/scope/test
182
204
  - test/fixtures/scope/test/modgreet.rhtml
183
205
  - test/fixtures/test/_customer.rhtml
206
+ - test/fixtures/test/_customer_greeting.rhtml
207
+ - test/fixtures/test/_hash_object.rhtml
184
208
  - test/fixtures/test/_partial_only.rhtml
209
+ - test/fixtures/test/_person.rhtml
210
+ - test/fixtures/test/action_talk_to_layout.rhtml
185
211
  - test/fixtures/test/capturing.rhtml
212
+ - test/fixtures/test/content_for.rhtml
186
213
  - test/fixtures/test/greeting.rhtml
187
214
  - test/fixtures/test/hello.rxml
188
215
  - test/fixtures/test/hello_world.rhtml
189
216
  - test/fixtures/test/hello_xml_world.rxml
190
217
  - test/fixtures/test/list.rhtml
218
+ - test/fixtures/test/potential_conflicts.rhtml
191
219
  - test/fixtures/test/update_element_with_capture.rhtml
192
220
  - test/template/active_record_helper_test.rb
193
221
  - test/template/asset_tag_helper_test.rb
194
222
  - test/template/benchmark_helper_test.rb
223
+ - test/template/compiled_templates_tests.rb
195
224
  - test/template/date_helper_test.rb
196
225
  - test/template/form_helper_test.rb
197
226
  - test/template/form_options_helper_test.rb
198
227
  - test/template/form_tag_helper_test.rb
228
+ - test/template/java_script_macros_helper_test.rb
199
229
  - test/template/javascript_helper_test.rb
200
230
  - test/template/number_helper_test.rb
201
231
  - test/template/tag_helper_test.rb
@@ -233,5 +263,5 @@ dependencies:
233
263
  -
234
264
  - "="
235
265
  - !ruby/object:Gem::Version
236
- version: 1.1.1
266
+ version: 1.2.1
237
267
  version: