actionpack 1.9.0 → 1.9.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.

@@ -24,8 +24,9 @@ module ActionView
24
24
 
25
25
  private
26
26
  def tag_options(options)
27
- unless options.empty?
28
- " " + options.symbolize_keys.map { |key, value|
27
+ cleaned_options = options.reject { |key, value| value.nil? }
28
+ unless cleaned_options.empty?
29
+ " " + cleaned_options.symbolize_keys.map { |key, value|
29
30
  %(#{key}="#{html_escape(value.to_s)}")
30
31
  }.sort.join(" ")
31
32
  end
@@ -113,7 +113,7 @@ module ActionView
113
113
  text.gsub!(/\n\n/, '</p>\0<p>') # turn two newlines into paragraph
114
114
  text.gsub!(/([^\n])(\n)([^\n])/, '\1\2<br />\3') # turn single newline into <br />
115
115
 
116
- return '<p>' + text + '</p>' # wrap the first and last line in paragraphs before we're done
116
+ content_tag("p", text)
117
117
  end
118
118
 
119
119
  # Turns all urls and email addresses into clickable links. The +link+ parameter can limit what should be linked.
@@ -143,7 +143,7 @@ module ActionView
143
143
  if block_given?
144
144
  block.arity <= 1 ? yield(name) : yield(name, options, html_options, *parameters_for_method_reference)
145
145
  else
146
- html_escape(name)
146
+ name
147
147
  end
148
148
  else
149
149
  link_to(name, options, html_options, *parameters_for_method_reference)
data/rakefile CHANGED
@@ -8,7 +8,7 @@ require 'rake/contrib/rubyforgepublisher'
8
8
 
9
9
  PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
10
10
  PKG_NAME = 'actionpack'
11
- PKG_VERSION = '1.9.0' + PKG_BUILD
11
+ PKG_VERSION = '1.9.1' + PKG_BUILD
12
12
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
13
13
 
14
14
  RELEASE_NAME = "REL #{PKG_VERSION}"
@@ -61,7 +61,7 @@ spec = Gem::Specification.new do |s|
61
61
  s.has_rdoc = true
62
62
  s.requirements << 'none'
63
63
 
64
- s.add_dependency('activesupport', '= 1.1.0' + PKG_BUILD)
64
+ s.add_dependency('activesupport', '= 1.1.1' + PKG_BUILD)
65
65
 
66
66
  s.require_path = 'lib'
67
67
  s.autorequire = 'action_controller'
@@ -18,8 +18,14 @@ begin
18
18
  CGI::Session::ActiveRecordStore::Session.establish_connection(:adapter => 'sqlite3', :dbfile => ':memory:')
19
19
  CGI::Session::ActiveRecordStore::Session.connection
20
20
  rescue Object
21
- $stderr.puts 'SQLite 3 unavailable; falling to SQLite 2.'
22
- CGI::Session::ActiveRecordStore::Session.establish_connection(:adapter => 'sqlite', :dbfile => ':memory:')
21
+ $stderr.puts 'SQLite 3 unavailable; falling back to SQLite 2.'
22
+ begin
23
+ CGI::Session::ActiveRecordStore::Session.establish_connection(:adapter => 'sqlite', :dbfile => ':memory:')
24
+ CGI::Session::ActiveRecordStore::Session.connection
25
+ rescue Object
26
+ $stderr.puts 'SQLite 2 unavailable; skipping ActiveRecordStore test suite.'
27
+ raise SystemExit
28
+ end
23
29
  end
24
30
 
25
31
 
@@ -27,7 +33,7 @@ module CommonActiveRecordStoreTests
27
33
  def test_basics
28
34
  s = session_class.new(:session_id => '1234', :data => { 'foo' => 'bar' })
29
35
  assert_equal 'bar', s.data['foo']
30
- assert s.save!
36
+ assert s.save
31
37
  assert_equal 'bar', s.data['foo']
32
38
 
33
39
  assert_not_nil t = session_class.find_by_session_id('1234')
@@ -203,6 +203,18 @@ class FilterTest < Test::Unit::TestCase
203
203
  end
204
204
  end
205
205
 
206
+ class DynamicDispatchController < ActionController::Base
207
+ before_filter :choose
208
+
209
+ %w(foo bar baz).each do |action|
210
+ define_method(action) { render :text => action }
211
+ end
212
+
213
+ private
214
+ def choose
215
+ self.action_name = params[:choose]
216
+ end
217
+ end
206
218
 
207
219
  def test_added_filter_to_inheritance_graph
208
220
  assert_equal [ :fire_flash, :ensure_login ], TestController.before_filters
@@ -321,6 +333,15 @@ class FilterTest < Test::Unit::TestCase
321
333
  end
322
334
  end
323
335
 
336
+ def test_dynamic_dispatch
337
+ %w(foo bar baz).each do |action|
338
+ request = ActionController::TestRequest.new
339
+ request.query_parameters[:choose] = action
340
+ response = DynamicDispatchController.process(request, ActionController::TestResponse.new)
341
+ assert_equal action, response.body
342
+ end
343
+ end
344
+
324
345
  private
325
346
  def test_process(controller, action = "show")
326
347
  request = ActionController::TestRequest.new
@@ -99,6 +99,21 @@ class NewRenderTestController < ActionController::Base
99
99
  render "test/hello_world"
100
100
  end
101
101
 
102
+ def double_render
103
+ render :text => "hello"
104
+ render :text => "world"
105
+ end
106
+
107
+ def double_redirect
108
+ redirect_to :action => "double_render"
109
+ redirect_to :action => "double_render"
110
+ end
111
+
112
+ def render_and_redirect
113
+ render :text => "hello"
114
+ redirect_to :action => "double_render"
115
+ end
116
+
102
117
  def rescue_action(e) raise end
103
118
 
104
119
  private
@@ -260,4 +275,16 @@ class NewRenderTest < Test::Unit::TestCase
260
275
  get :render_with_explicit_template
261
276
  assert_response :success
262
277
  end
278
+
279
+ def test_double_render
280
+ assert_raises(ActionController::DoubleRenderError) { get :double_render }
281
+ end
282
+
283
+ def test_double_redirect
284
+ assert_raises(ActionController::DoubleRenderError) { get :double_redirect }
285
+ end
286
+
287
+ def test_render_and_redirect
288
+ assert_raises(ActionController::DoubleRenderError) { get :render_and_redirect }
289
+ end
263
290
  end
@@ -109,6 +109,9 @@ module Object::Controllers
109
109
 
110
110
  class UserController
111
111
  end
112
+
113
+ class NewsFeedController
114
+ end
112
115
  end
113
116
  end
114
117
 
@@ -661,7 +664,17 @@ class RouteSetTests < Test::Unit::TestCase
661
664
  x = setup_for_named_route
662
665
  assert_equal({:controller => '/content', :action => 'show_page', :title => 'new stuff'},
663
666
  x.new.send(:page_url, :title => 'new stuff'))
664
- end
667
+ end
668
+
669
+ def test_named_route_with_default
670
+ rs.page 'page/:title', :controller => 'content', :action => 'show_page', :title => 'AboutPage'
671
+ x = setup_for_named_route
672
+ assert_equal({:controller => '/content', :action => 'show_page', :title => 'AboutPage'},
673
+ x.new.send(:page_url))
674
+ assert_equal({:controller => '/content', :action => 'show_page', :title => 'AboutRails'},
675
+ x.new.send(:page_url, :title => "AboutRails"))
676
+
677
+ end
665
678
 
666
679
  def setup_for_named_route
667
680
  x = Class.new
@@ -683,6 +696,35 @@ class RouteSetTests < Test::Unit::TestCase
683
696
  )
684
697
  end
685
698
 
699
+ def test_paths_escaped
700
+ rs.draw do |map|
701
+ rs.path 'file/*path', :controller => 'content', :action => 'show_file'
702
+ rs.connect ':controller/:action/:id'
703
+ end
704
+
705
+ results = rs.recognize_path %w(file hello+world how+are+you%3F)
706
+ assert results, "Recognition should have succeeded"
707
+ assert_equal ['hello world', 'how are you?'], results['path']
708
+
709
+ results = rs.recognize_path %w(file)
710
+ assert results, "Recognition should have succeeded"
711
+ assert_equal [], results['path']
712
+ end
713
+
714
+ def test_paths_do_not_accept_defaults
715
+ assert_raises(ActionController::RoutingError) do
716
+ rs.draw do |map|
717
+ rs.path 'file/*path', :controller => 'content', :action => 'show_file', :path => %w(fake default)
718
+ rs.connect ':controller/:action/:id'
719
+ end
720
+ end
721
+
722
+ rs.draw do |map|
723
+ rs.path 'file/*path', :controller => 'content', :action => 'show_file', :path => []
724
+ rs.connect ':controller/:action/:id'
725
+ end
726
+ end
727
+
686
728
  def test_backwards
687
729
  rs.draw do |map|
688
730
  rs.connect 'page/:id/:action', :controller => 'pages', :action => 'show'
@@ -694,9 +736,36 @@ class RouteSetTests < Test::Unit::TestCase
694
736
  assert_equal ['/pages/boo', {}], rs.generate(:controller => 'pages', :action => 'boo')
695
737
  end
696
738
 
739
+ def test_route_with_fixnum_default
740
+ rs.draw do |map|
741
+ rs.connect 'page/:id', :controller => 'content', :action => 'show_page', :id => 1
742
+ rs.connect ':controller/:action/:id'
743
+ end
744
+
745
+ assert_equal ['/page', {}], rs.generate(:controller => 'content', :action => 'show_page')
746
+ assert_equal ['/page', {}], rs.generate(:controller => 'content', :action => 'show_page', :id => 1)
747
+ assert_equal ['/page', {}], rs.generate(:controller => 'content', :action => 'show_page', :id => '1')
748
+ assert_equal ['/page/10', {}], rs.generate(:controller => 'content', :action => 'show_page', :id => 10)
749
+
750
+ ctrl = ::Controllers::ContentController
751
+
752
+ assert_equal({'controller' => ctrl, 'action' => 'show_page', 'id' => 1}, rs.recognize_path(%w(page)))
753
+ assert_equal({'controller' => ctrl, 'action' => 'show_page', 'id' => '1'}, rs.recognize_path(%w(page 1)))
754
+ assert_equal({'controller' => ctrl, 'action' => 'show_page', 'id' => '10'}, rs.recognize_path(%w(page 10)))
755
+ end
756
+
697
757
  def test_action_expiry
698
758
  assert_equal ['/content', {}], rs.generate({:controller => 'content'}, {:controller => 'content', :action => 'show'})
699
759
  end
760
+
761
+ def test_recognition_with_uppercase_controller_name
762
+ assert_equal({'controller' => ::Controllers::ContentController, 'action' => 'index'}, rs.recognize_path(%w(Content)))
763
+ assert_equal({'controller' => ::Controllers::ContentController, 'action' => 'list'}, rs.recognize_path(%w(Content list)))
764
+ assert_equal({'controller' => ::Controllers::ContentController, 'action' => 'show', 'id' => '10'}, rs.recognize_path(%w(Content show 10)))
765
+
766
+ assert_equal({'controller' => ::Controllers::Admin::NewsFeedController, 'action' => 'index'}, rs.recognize_path(%w(Admin NewsFeed)))
767
+ assert_equal({'controller' => ::Controllers::Admin::NewsFeedController, 'action' => 'index'}, rs.recognize_path(%w(Admin News_Feed)))
768
+ end
700
769
  end
701
770
 
702
771
  end
@@ -114,10 +114,44 @@ HTML
114
114
  )
115
115
  end
116
116
 
117
- def test_path_params_are_strings
117
+ def test_id_converted_to_string
118
118
  get :test_params, :id => 20, :foo => Object.new
119
- @request.path_parameters.each do |key, value|
120
- assert_kind_of String, value
119
+ assert_kind_of String, @request.path_parameters['id']
120
+ end
121
+
122
+ def test_array_path_parameter_handled_properly
123
+ with_routing do |set|
124
+ set.draw do
125
+ set.connect 'file/*path', :controller => 'test_test/test', :action => 'test_params'
126
+ set.connect ':controller/:action/:id'
127
+ end
128
+
129
+ get :test_params, :path => ['hello', 'world']
130
+ assert_equal ['hello', 'world'], @request.path_parameters['path']
131
+ assert_equal 'hello/world', @request.path_parameters['path'].to_s
132
+ end
133
+ end
134
+
135
+ def test_assert_realistic_path_parameters
136
+ get :test_params, :id => 20, :foo => Object.new
137
+
138
+ # All elements of path_parameters should use string keys
139
+ @request.path_parameters.keys.each do |key|
140
+ assert_kind_of String, key
141
+ end
142
+ end
143
+
144
+ def test_with_routing_places_routes_back
145
+ assert ActionController::Routing::Routes
146
+ routes_id = ActionController::Routing::Routes.object_id
147
+
148
+ begin
149
+ with_routing { raise 'fail' }
150
+ fail 'Should not be here.'
151
+ rescue RuntimeError
121
152
  end
153
+
154
+ assert ActionController::Routing::Routes
155
+ assert_equal routes_id, ActionController::Routing::Routes.object_id
122
156
  end
123
157
  end
@@ -37,7 +37,7 @@ class FormHelperTest < Test::Unit::TestCase
37
37
  '<input id="post_title" name="post[title]" size="30" type="password" value="Hello World" />', password_field("post", "title")
38
38
  )
39
39
  assert_equal(
40
- '<input id="person_name" name="person[name]" size="30" type="password" value="" />', password_field("person", "name")
40
+ '<input id="person_name" name="person[name]" size="30" type="password" />', password_field("person", "name")
41
41
  )
42
42
  end
43
43
 
@@ -71,7 +71,7 @@ class FormHelperTest < Test::Unit::TestCase
71
71
  check_box("post", "secret")
72
72
  )
73
73
  assert_equal(
74
- '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',
74
+ '<input checked="checked" id="post_secret" name="post[secret]" type="checkbox" value="1" /><input name="post[secret]" type="hidden" value="0" />',
75
75
  check_box("post", "secret" ,{"checked"=>"checked"})
76
76
  )
77
77
  @post.secret = true
@@ -80,7 +80,7 @@ class FormHelperTest < Test::Unit::TestCase
80
80
  check_box("post", "secret")
81
81
  )
82
82
  end
83
-
83
+
84
84
  def test_check_box_with_explicit_checked_and_unchecked_values
85
85
  @post.secret = "on"
86
86
  assert_equal(
@@ -22,7 +22,7 @@ class FormTagHelperTest < Test::Unit::TestCase
22
22
  end
23
23
 
24
24
  def test_form_tag
25
- actual = form_tag
25
+ actual = form_tag
26
26
  expected = %(<form action="http://www.example.com" method="post">)
27
27
  assert_equal expected, actual
28
28
  end
@@ -41,7 +41,7 @@ class FormTagHelperTest < Test::Unit::TestCase
41
41
 
42
42
  def test_password_field_tag
43
43
  actual = password_field_tag
44
- expected = %(<input id="password" name="password" type="password" value="" />)
44
+ expected = %(<input id="password" name="password" type="password" />)
45
45
  assert_equal expected, actual
46
46
  end
47
47
 
@@ -35,46 +35,50 @@ class JavaScriptHelperTest < Test::Unit::TestCase
35
35
  end
36
36
 
37
37
  def test_link_to_remote
38
- assert_equal %(<a class=\"fine\" href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {evalScripts:true, asynchronous:true}); return false;\">Remote outpost</a>),
38
+ assert_equal %(<a class=\"fine\" href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true}); return false;\">Remote outpost</a>),
39
39
  link_to_remote("Remote outpost", { :url => { :action => "whatnot" }}, { :class => "fine" })
40
- assert_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {onComplete:function(request){alert(request.reponseText)}, evalScripts:true, asynchronous:true}); return false;\">Remote outpost</a>),
40
+ assert_equal %(<a href=\"#\" onclick=\"new Ajax.Request('http://www.example.com/whatnot', {asynchronous:true, evalScripts:true, onComplete:function(request){alert(request.reponseText)}}); return false;\">Remote outpost</a>),
41
41
  link_to_remote("Remote outpost", :complete => "alert(request.reponseText)", :url => { :action => "whatnot" })
42
42
  end
43
43
 
44
44
  def test_periodically_call_remote
45
- assert_equal %(<script>new PeriodicalExecuter(function() {new Ajax.Updater('schremser_bier', 'http://www.example.com/mehr_bier', {evalScripts:true, asynchronous:true})}, 10)</script>),
45
+ assert_equal %(<script>new PeriodicalExecuter(function() {new Ajax.Updater('schremser_bier', 'http://www.example.com/mehr_bier', {asynchronous:true, evalScripts:true})}, 10)</script>),
46
46
  periodically_call_remote(:update => "schremser_bier", :url => { :action => "mehr_bier" })
47
47
  end
48
48
 
49
49
  def test_form_remote_tag
50
- assert_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {parameters:Form.serialize(this), evalScripts:true, asynchronous:true}); return false;\">),
50
+ assert_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater('glass_of_beer', 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\">),
51
51
  form_remote_tag(:update => "glass_of_beer", :url => { :action => :fast })
52
- assert_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater({success:'glass_of_beer'}, 'http://www.example.com/fast', {parameters:Form.serialize(this), evalScripts:true, asynchronous:true}); return false;\">),
52
+ assert_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater({success:'glass_of_beer'}, 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\">),
53
53
  form_remote_tag(:update => { :success => "glass_of_beer" }, :url => { :action => :fast })
54
- assert_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater({failure:'glass_of_water'}, 'http://www.example.com/fast', {parameters:Form.serialize(this), evalScripts:true, asynchronous:true}); return false;\">),
54
+ assert_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater({failure:'glass_of_water'}, 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\">),
55
55
  form_remote_tag(:update => { :failure => "glass_of_water" }, :url => { :action => :fast })
56
- assert_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater({success:'glass_of_beer',failure:'glass_of_water'}, 'http://www.example.com/fast', {parameters:Form.serialize(this), evalScripts:true, asynchronous:true}); return false;\">),
56
+ assert_equal %(<form action=\"http://www.example.com/fast\" method=\"post\" onsubmit=\"new Ajax.Updater({success:'glass_of_beer',failure:'glass_of_water'}, 'http://www.example.com/fast', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;\">),
57
57
  form_remote_tag(:update => { :success => 'glass_of_beer', :failure => "glass_of_water" }, :url => { :action => :fast })
58
58
  end
59
59
 
60
60
  def test_submit_to_remote
61
- assert_equal %(<input name=\"More beer!\" onclick=\"new Ajax.Updater('empty_bottle', 'http://www.example.com/', {parameters:Form.serialize(this.form), evalScripts:true, asynchronous:true}); return false;\" type=\"button\" value=\"1000000\" />),
61
+ assert_equal %(<input name=\"More beer!\" onclick=\"new Ajax.Updater('empty_bottle', 'http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this.form)}); return false;\" type=\"button\" value=\"1000000\" />),
62
62
  submit_to_remote("More beer!", 1_000_000, :update => "empty_bottle")
63
63
  end
64
64
 
65
65
  def test_observe_field
66
- assert_equal %(<script type=\"text/javascript\">new Form.Element.Observer('glass', 300, function(element, value) {new Ajax.Request('http://www.example.com/reorder_if_empty', {evalScripts:true, asynchronous:true})})</script>),
66
+ assert_equal %(<script type=\"text/javascript\">new Form.Element.Observer('glass', 300, function(element, value) {new Ajax.Request('http://www.example.com/reorder_if_empty', {asynchronous:true, evalScripts:true})})</script>),
67
67
  observe_field("glass", :frequency => 5.minutes, :url => { :action => "reorder_if_empty" })
68
68
  end
69
69
 
70
70
  def test_observe_form
71
- assert_equal %(<script type=\"text/javascript\">new Form.Observer('cart', 2, function(element, value) {new Ajax.Request('http://www.example.com/cart_changed', {evalScripts:true, asynchronous:true})})</script>),
71
+ assert_equal %(<script type=\"text/javascript\">new Form.Observer('cart', 2, function(element, value) {new Ajax.Request('http://www.example.com/cart_changed', {asynchronous:true, evalScripts:true})})</script>),
72
72
  observe_form("cart", :frequency => 2, :url => { :action => "cart_changed" })
73
73
  end
74
74
 
75
75
  def test_auto_complete_field
76
76
  assert_equal %(<script type=\"text/javascript\">new Ajax.Autocompleter('some_input', 'some_input_auto_complete', 'http://www.example.com/autocomplete', {})</script>),
77
- auto_complete_field("some_input", :url => { :action => "autocomplete" });
77
+ auto_complete_field("some_input", :url => { :action => "autocomplete" });
78
+ assert_equal %(<script type=\"text/javascript\">new Ajax.Autocompleter('some_input', 'some_input_auto_complete', 'http://www.example.com/autocomplete', {tokens:','})</script>),
79
+ auto_complete_field("some_input", :url => { :action => "autocomplete" }, :tokens => ',');
80
+ assert_equal %(<script type=\"text/javascript\">new Ajax.Autocompleter('some_input', 'some_input_auto_complete', 'http://www.example.com/autocomplete', {tokens:[',']})</script>),
81
+ auto_complete_field("some_input", :url => { :action => "autocomplete" }, :tokens => [',']);
78
82
  end
79
83
 
80
84
  def test_auto_complete_result
@@ -88,7 +92,7 @@ class JavaScriptHelperTest < Test::Unit::TestCase
88
92
  def test_text_field_with_auto_complete
89
93
  assert_match "<style>",
90
94
  text_field_with_auto_complete(:message, :recipient)
91
- assert_equal %(<input autocomplete=\"off\" id=\"message_recipient\" name=\"message[recipient]\" size=\"30\" type=\"text\" value=\"\" /><div class=\"auto_complete\" id=\"message_recipient_auto_complete\"></div><script type=\"text/javascript\">new Ajax.Autocompleter('message_recipient', 'message_recipient_auto_complete', 'http://www.example.com/auto_complete_for_message_recipient', {})</script>),
95
+ assert_equal %(<input autocomplete=\"off\" id=\"message_recipient\" name=\"message[recipient]\" size=\"30\" type=\"text\" /><div class=\"auto_complete\" id=\"message_recipient_auto_complete\"></div><script type=\"text/javascript\">new Ajax.Autocompleter('message_recipient', 'message_recipient_auto_complete', 'http://www.example.com/auto_complete_for_message_recipient', {})</script>),
92
96
  text_field_with_auto_complete(:message, :recipient, {}, :skip_style => true)
93
97
  end
94
98
 
@@ -101,13 +105,13 @@ class JavaScriptHelperTest < Test::Unit::TestCase
101
105
  end
102
106
 
103
107
  def test_sortable_element
104
- assert_equal %(<script type=\"text/javascript\">Sortable.create('mylist', {onUpdate:function(){new Ajax.Request('http://www.example.com/order', {parameters:Sortable.serialize('mylist'), evalScripts:true, asynchronous:true})}})</script>),
108
+ assert_equal %(<script type=\"text/javascript\">Sortable.create('mylist', {onUpdate:function(){new Ajax.Request('http://www.example.com/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize('mylist')})}})</script>),
105
109
  sortable_element("mylist", :url => { :action => "order" })
106
- assert_equal %(<script type=\"text/javascript\">Sortable.create('mylist', {tag:'div', constraint:'horizontal', onUpdate:function(){new Ajax.Request('http://www.example.com/order', {parameters:Sortable.serialize('mylist'), evalScripts:true, asynchronous:true})}})</script>),
110
+ assert_equal %(<script type=\"text/javascript\">Sortable.create('mylist', {constraint:'horizontal', onUpdate:function(){new Ajax.Request('http://www.example.com/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize('mylist')})}, tag:'div'})</script>),
107
111
  sortable_element("mylist", :tag => "div", :constraint => "horizontal", :url => { :action => "order" })
108
- assert_equal %(<script type=\"text/javascript\">Sortable.create('mylist', {constraint:'horizontal', containment:['list1','list2'], onUpdate:function(){new Ajax.Request('http://www.example.com/order', {parameters:Sortable.serialize('mylist'), evalScripts:true, asynchronous:true})}})</script>),
112
+ assert_equal %|<script type=\"text/javascript\">Sortable.create('mylist', {constraint:'horizontal', containment:['list1','list2'], onUpdate:function(){new Ajax.Request('http://www.example.com/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize('mylist')})}})</script>|,
109
113
  sortable_element("mylist", :containment => ['list1','list2'], :constraint => "horizontal", :url => { :action => "order" })
110
- assert_equal %(<script type=\"text/javascript\">Sortable.create('mylist', {constraint:'horizontal', containment:'list1', onUpdate:function(){new Ajax.Request('http://www.example.com/order', {parameters:Sortable.serialize('mylist'), evalScripts:true, asynchronous:true})}})</script>),
114
+ assert_equal %(<script type=\"text/javascript\">Sortable.create('mylist', {constraint:'horizontal', containment:'list1', onUpdate:function(){new Ajax.Request('http://www.example.com/order', {asynchronous:true, evalScripts:true, parameters:Sortable.serialize('mylist')})}})</script>),
111
115
  sortable_element("mylist", :containment => 'list1', :constraint => "horizontal", :url => { :action => "order" })
112
116
  end
113
117
 
@@ -119,13 +123,13 @@ class JavaScriptHelperTest < Test::Unit::TestCase
119
123
  end
120
124
 
121
125
  def test_drop_receiving_element
122
- assert_equal %(<script type=\"text/javascript\">Droppables.add('droptarget1', {onDrop:function(element){new Ajax.Request('http://www.example.com/', {parameters:'id=' + encodeURIComponent(element.id), evalScripts:true, asynchronous:true})}})</script>),
126
+ assert_equal %(<script type=\"text/javascript\">Droppables.add('droptarget1', {onDrop:function(element){new Ajax.Request('http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)})}})</script>),
123
127
  drop_receiving_element('droptarget1')
124
- assert_equal %(<script type=\"text/javascript\">Droppables.add('droptarget1', {accept:'products', onDrop:function(element){new Ajax.Request('http://www.example.com/', {parameters:'id=' + encodeURIComponent(element.id), evalScripts:true, asynchronous:true})}})</script>),
128
+ assert_equal %(<script type=\"text/javascript\">Droppables.add('droptarget1', {accept:'products', onDrop:function(element){new Ajax.Request('http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)})}})</script>),
125
129
  drop_receiving_element('droptarget1', :accept => 'products')
126
- assert_equal %(<script type=\"text/javascript\">Droppables.add('droptarget1', {accept:'products', onDrop:function(element){new Ajax.Updater('infobox', 'http://www.example.com/', {parameters:'id=' + encodeURIComponent(element.id), evalScripts:true, asynchronous:true})}})</script>),
130
+ assert_equal %(<script type=\"text/javascript\">Droppables.add('droptarget1', {accept:'products', onDrop:function(element){new Ajax.Updater('infobox', 'http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)})}})</script>),
127
131
  drop_receiving_element('droptarget1', :accept => 'products', :update => 'infobox')
128
- assert_equal %(<script type=\"text/javascript\">Droppables.add('droptarget1', {accept:['tshirts','mugs'], onDrop:function(element){new Ajax.Updater('infobox', 'http://www.example.com/', {parameters:'id=' + encodeURIComponent(element.id), evalScripts:true, asynchronous:true})}})</script>),
132
+ assert_equal %(<script type=\"text/javascript\">Droppables.add('droptarget1', {accept:['tshirts','mugs'], onDrop:function(element){new Ajax.Updater('infobox', 'http://www.example.com/', {asynchronous:true, evalScripts:true, parameters:'id=' + encodeURIComponent(element.id)})}})</script>),
129
133
  drop_receiving_element('droptarget1', :accept => ['tshirts','mugs'], :update => 'infobox')
130
134
  end
131
135