actionpack 1.11.2 → 1.12.0

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 (149) hide show
  1. data/CHANGELOG +392 -5
  2. data/lib/action_controller.rb +8 -4
  3. data/lib/action_controller/assertions.rb +9 -10
  4. data/lib/action_controller/base.rb +177 -88
  5. data/lib/action_controller/benchmarking.rb +5 -5
  6. data/lib/action_controller/caching.rb +44 -36
  7. data/lib/action_controller/cgi_ext/cgi_methods.rb +71 -6
  8. data/lib/action_controller/cgi_ext/cookie_performance_fix.rb +1 -1
  9. data/lib/action_controller/cgi_process.rb +36 -24
  10. data/lib/action_controller/components.rb +152 -52
  11. data/lib/action_controller/dependencies.rb +1 -1
  12. data/lib/action_controller/deprecated_redirects.rb +2 -2
  13. data/lib/action_controller/deprecated_request_methods.rb +34 -0
  14. data/lib/action_controller/filters.rb +59 -19
  15. data/lib/action_controller/flash.rb +53 -47
  16. data/lib/action_controller/helpers.rb +2 -2
  17. data/lib/action_controller/integration.rb +524 -0
  18. data/lib/action_controller/layout.rb +58 -23
  19. data/lib/action_controller/mime_responds.rb +163 -0
  20. data/lib/action_controller/mime_type.rb +142 -0
  21. data/lib/action_controller/pagination.rb +13 -7
  22. data/lib/action_controller/request.rb +59 -56
  23. data/lib/action_controller/rescue.rb +1 -1
  24. data/lib/action_controller/routing.rb +29 -10
  25. data/lib/action_controller/scaffolding.rb +8 -0
  26. data/lib/action_controller/session/active_record_store.rb +21 -10
  27. data/lib/action_controller/session/mem_cache_store.rb +18 -12
  28. data/lib/action_controller/session_management.rb +30 -11
  29. data/lib/action_controller/templates/rescues/_trace.rhtml +1 -1
  30. data/lib/action_controller/templates/scaffolds/layout.rhtml +4 -4
  31. data/lib/action_controller/templates/scaffolds/list.rhtml +1 -1
  32. data/lib/action_controller/test_process.rb +189 -118
  33. data/lib/action_controller/vendor/html-scanner/html/node.rb +20 -1
  34. data/lib/action_controller/vendor/html-scanner/html/tokenizer.rb +3 -0
  35. data/lib/action_controller/vendor/html-scanner/html/version.rb +1 -1
  36. data/lib/action_controller/vendor/xml_node.rb +97 -0
  37. data/lib/action_controller/verification.rb +2 -0
  38. data/lib/action_pack/version.rb +3 -3
  39. data/lib/action_view.rb +0 -2
  40. data/lib/action_view/base.rb +109 -36
  41. data/lib/action_view/compiled_templates.rb +1 -1
  42. data/lib/action_view/helpers/active_record_helper.rb +4 -2
  43. data/lib/action_view/helpers/asset_tag_helper.rb +6 -7
  44. data/lib/action_view/helpers/capture_helper.rb +49 -12
  45. data/lib/action_view/helpers/date_helper.rb +14 -4
  46. data/lib/action_view/helpers/form_helper.rb +136 -20
  47. data/lib/action_view/helpers/form_options_helper.rb +29 -7
  48. data/lib/action_view/helpers/form_tag_helper.rb +22 -20
  49. data/lib/action_view/helpers/java_script_macros_helper.rb +29 -9
  50. data/lib/action_view/helpers/javascript_helper.rb +50 -446
  51. data/lib/action_view/helpers/javascripts/controls.js +95 -30
  52. data/lib/action_view/helpers/javascripts/dragdrop.js +161 -21
  53. data/lib/action_view/helpers/javascripts/effects.js +310 -211
  54. data/lib/action_view/helpers/javascripts/prototype.js +228 -28
  55. data/lib/action_view/helpers/number_helper.rb +9 -9
  56. data/lib/action_view/helpers/pagination_helper.rb +1 -1
  57. data/lib/action_view/helpers/prototype_helper.rb +900 -0
  58. data/lib/action_view/helpers/scriptaculous_helper.rb +135 -0
  59. data/lib/action_view/helpers/text_helper.rb +7 -6
  60. data/lib/action_view/helpers/url_helper.rb +23 -14
  61. data/lib/action_view/partials.rb +12 -4
  62. data/rakefile +13 -5
  63. data/test/abstract_unit.rb +4 -3
  64. data/test/active_record_unit.rb +88 -0
  65. data/test/{controller → activerecord}/active_record_assertions_test.rb +7 -50
  66. data/test/{controller → activerecord}/active_record_store_test.rb +27 -4
  67. data/test/activerecord/pagination_test.rb +161 -0
  68. data/test/controller/action_pack_assertions_test.rb +18 -15
  69. data/test/controller/base_test.rb +31 -42
  70. data/test/controller/benchmark_test.rb +8 -11
  71. data/test/controller/capture_test.rb +33 -1
  72. data/test/controller/cgi_test.rb +33 -0
  73. data/test/controller/custom_handler_test.rb +8 -0
  74. data/test/controller/fake_controllers.rb +9 -17
  75. data/test/controller/filters_test.rb +32 -3
  76. data/test/controller/flash_test.rb +26 -41
  77. data/test/controller/fragment_store_setting_test.rb +1 -1
  78. data/test/controller/layout_test.rb +73 -0
  79. data/test/controller/mime_responds_test.rb +257 -0
  80. data/test/controller/mime_type_test.rb +24 -0
  81. data/test/controller/new_render_test.rb +157 -1
  82. data/test/controller/redirect_test.rb +23 -0
  83. data/test/controller/render_test.rb +54 -56
  84. data/test/controller/request_test.rb +25 -0
  85. data/test/controller/routing_test.rb +74 -66
  86. data/test/controller/test_test.rb +66 -1
  87. data/test/controller/verification_test.rb +3 -1
  88. data/test/controller/webservice_test.rb +255 -0
  89. data/test/fixtures/companies.yml +24 -0
  90. data/test/fixtures/company.rb +9 -0
  91. data/test/fixtures/db_definitions/sqlite.sql +42 -0
  92. data/test/fixtures/developer.rb +7 -0
  93. data/test/fixtures/developers.yml +21 -0
  94. data/test/fixtures/developers_projects.yml +13 -0
  95. data/test/fixtures/layout_tests/layouts/controller_name_space/nested.rhtml +1 -0
  96. data/test/fixtures/layout_tests/layouts/item.rhtml +1 -0
  97. data/test/fixtures/layout_tests/layouts/layout_test.rhtml +1 -0
  98. data/test/fixtures/layout_tests/layouts/third_party_template_library.mab +1 -0
  99. data/test/fixtures/layout_tests/views/hello.rhtml +1 -0
  100. data/test/fixtures/multipart/mona_lisa.jpg +0 -0
  101. data/test/fixtures/project.rb +3 -0
  102. data/test/fixtures/projects.yml +7 -0
  103. data/test/fixtures/replies.yml +13 -0
  104. data/test/fixtures/reply.rb +5 -0
  105. data/test/fixtures/respond_to/all_types_with_layout.rhtml +1 -0
  106. data/test/fixtures/respond_to/all_types_with_layout.rjs +1 -0
  107. data/test/fixtures/respond_to/layouts/standard.rhtml +1 -0
  108. data/test/fixtures/respond_to/using_defaults.rhtml +1 -0
  109. data/test/fixtures/respond_to/using_defaults.rjs +1 -0
  110. data/test/fixtures/respond_to/using_defaults.rxml +1 -0
  111. data/test/fixtures/respond_to/using_defaults_with_type_list.rhtml +1 -0
  112. data/test/fixtures/respond_to/using_defaults_with_type_list.rjs +1 -0
  113. data/test/fixtures/respond_to/using_defaults_with_type_list.rxml +1 -0
  114. data/test/fixtures/test/block_content_for.rhtml +2 -0
  115. data/test/fixtures/test/delete_with_js.rjs +2 -0
  116. data/test/fixtures/test/dot.directory/render_file_with_ivar.rhtml +1 -0
  117. data/test/fixtures/test/enum_rjs_test.rjs +6 -0
  118. data/test/fixtures/test/erb_content_for.rhtml +2 -0
  119. data/test/fixtures/test/hello_world.rxml +3 -0
  120. data/test/fixtures/test/hello_world_with_layout_false.rhtml +1 -0
  121. data/test/fixtures/test/non_erb_block_content_for.rxml +4 -0
  122. data/test/fixtures/topic.rb +3 -0
  123. data/test/fixtures/topics.yml +22 -0
  124. data/test/template/active_record_helper_test.rb +4 -0
  125. data/test/template/asset_tag_helper_test.rb +7 -2
  126. data/test/template/date_helper_test.rb +39 -2
  127. data/test/template/form_helper_test.rb +238 -5
  128. data/test/template/form_options_helper_test.rb +78 -0
  129. data/test/template/form_tag_helper_test.rb +11 -0
  130. data/test/template/java_script_macros_helper_test.rb +51 -6
  131. data/test/template/javascript_helper_test.rb +7 -153
  132. data/test/template/number_helper_test.rb +14 -13
  133. data/test/template/prototype_helper_test.rb +423 -0
  134. data/test/template/scriptaculous_helper_test.rb +90 -0
  135. data/test/template/text_helper_test.rb +12 -9
  136. data/test/template/url_helper_test.rb +31 -15
  137. metadata +291 -246
  138. data/lib/action_controller/cgi_ext/multipart_progress.rb +0 -169
  139. data/lib/action_controller/upload_progress.rb +0 -473
  140. data/lib/action_controller/vendor/html-scanner/html/node.rb.rej +0 -17
  141. data/lib/action_view/helpers/upload_progress_helper.rb +0 -433
  142. data/lib/action_view/vendor/builder.rb +0 -13
  143. data/lib/action_view/vendor/builder/blankslate.rb +0 -53
  144. data/lib/action_view/vendor/builder/xmlbase.rb +0 -143
  145. data/lib/action_view/vendor/builder/xmlevents.rb +0 -63
  146. data/lib/action_view/vendor/builder/xmlmarkup.rb +0 -308
  147. data/test/controller/multipart_progress_testx.rb +0 -365
  148. data/test/controller/upload_progress_testx.rb +0 -89
  149. data/test/template/upload_progress_helper_testx.rb +0 -136
@@ -0,0 +1,135 @@
1
+ require File.dirname(__FILE__) + '/javascript_helper'
2
+
3
+ module ActionView
4
+ module Helpers
5
+ # Provides a set of helpers for calling Scriptaculous JavaScript
6
+ # functions, including those which create Ajax controls and visual effects.
7
+ #
8
+ # To be able to use these helpers, you must include the Prototype
9
+ # JavaScript framework and the Scriptaculous JavaScript library in your
10
+ # pages. See the documentation for ActionView::Helpers::JavaScriptHelper
11
+ # for more information on including the necessary JavaScript.
12
+ #
13
+ # The Scriptaculous helpers' behavior can be tweaked with various options.
14
+ # See the documentation at http://script.aculo.us for more information on
15
+ # using these helpers in your application.
16
+ module ScriptaculousHelper
17
+ unless const_defined? :TOGGLE_EFFECTS
18
+ TOGGLE_EFFECTS = [:toggle_appear, :toggle_slide, :toggle_blind]
19
+ end
20
+
21
+ # Returns a JavaScript snippet to be used on the Ajax callbacks for
22
+ # starting visual effects.
23
+ #
24
+ # Example:
25
+ # <%= link_to_remote "Reload", :update => "posts",
26
+ # :url => { :action => "reload" },
27
+ # :complete => visual_effect(:highlight, "posts", :duration => 0.5)
28
+ #
29
+ # If no element_id is given, it assumes "element" which should be a local
30
+ # variable in the generated JavaScript execution context. This can be
31
+ # used for example with drop_receiving_element:
32
+ #
33
+ # <%= drop_receving_element (...), :loading => visual_effect(:fade) %>
34
+ #
35
+ # This would fade the element that was dropped on the drop receiving
36
+ # element.
37
+ #
38
+ # For toggling visual effects, you can use :toggle_appear, :toggle_slide, and
39
+ # :toggle_blind which will alternate between appear/fade, slidedown/slideup, and
40
+ # blinddown/blindup respectively.
41
+ #
42
+ # You can change the behaviour with various options, see
43
+ # http://script.aculo.us for more documentation.
44
+ def visual_effect(name, element_id = false, js_options = {})
45
+ element = element_id ? element_id.to_json : "element"
46
+
47
+ js_options[:queue] = if js_options[:queue].is_a?(Hash)
48
+ '{' + js_options[:queue].map {|k, v| k == :limit ? "#{k}:#{v}" : "#{k}:'#{v}'" }.join(',') + '}'
49
+ elsif js_options[:queue]
50
+ "'#{js_options[:queue]}'"
51
+ end if js_options[:queue]
52
+
53
+ if TOGGLE_EFFECTS.include? name.to_sym
54
+ "Effect.toggle(#{element},'#{name.to_s.gsub(/^toggle_/,'')}',#{options_for_javascript(js_options)});"
55
+ else
56
+ "new Effect.#{name.to_s.camelize}(#{element},#{options_for_javascript(js_options)});"
57
+ end
58
+ end
59
+
60
+ # Makes the element with the DOM ID specified by +element_id+ sortable
61
+ # by drag-and-drop and make an Ajax call whenever the sort order has
62
+ # changed. By default, the action called gets the serialized sortable
63
+ # element as parameters.
64
+ #
65
+ # Example:
66
+ # <%= sortable_element("my_list", :url => { :action => "order" }) %>
67
+ #
68
+ # In the example, the action gets a "my_list" array parameter
69
+ # containing the values of the ids of elements the sortable consists
70
+ # of, in the current order.
71
+ #
72
+ # You can change the behaviour with various options, see
73
+ # http://script.aculo.us for more documentation.
74
+ def sortable_element(element_id, options = {})
75
+ javascript_tag(sortable_element_js(element_id, options).chop!)
76
+ end
77
+
78
+ def sortable_element_js(element_id, options = {}) #:nodoc:
79
+ options[:with] ||= "Sortable.serialize(#{element_id.to_json})"
80
+ options[:onUpdate] ||= "function(){" + remote_function(options) + "}"
81
+ options.delete_if { |key, value| PrototypeHelper::AJAX_OPTIONS.include?(key) }
82
+
83
+ [:tag, :overlap, :constraint, :handle].each do |option|
84
+ options[option] = "'#{options[option]}'" if options[option]
85
+ end
86
+
87
+ options[:containment] = array_or_string_for_javascript(options[:containment]) if options[:containment]
88
+ options[:only] = array_or_string_for_javascript(options[:only]) if options[:only]
89
+
90
+ %(Sortable.create(#{element_id.to_json}, #{options_for_javascript(options)});)
91
+ end
92
+
93
+ # Makes the element with the DOM ID specified by +element_id+ draggable.
94
+ #
95
+ # Example:
96
+ # <%= draggable_element("my_image", :revert => true)
97
+ #
98
+ # You can change the behaviour with various options, see
99
+ # http://script.aculo.us for more documentation.
100
+ def draggable_element(element_id, options = {})
101
+ javascript_tag(draggable_element_js(element_id, options).chop!)
102
+ end
103
+
104
+ def draggable_element_js(element_id, options = {}) #:nodoc:
105
+ %(new Draggable(#{element_id.to_json}, #{options_for_javascript(options)});)
106
+ end
107
+
108
+ # Makes the element with the DOM ID specified by +element_id+ receive
109
+ # dropped draggable elements (created by draggable_element).
110
+ # and make an AJAX call By default, the action called gets the DOM ID
111
+ # of the element as parameter.
112
+ #
113
+ # Example:
114
+ # <%= drop_receiving_element("my_cart", :url =>
115
+ # { :controller => "cart", :action => "add" }) %>
116
+ #
117
+ # You can change the behaviour with various options, see
118
+ # http://script.aculo.us for more documentation.
119
+ def drop_receiving_element(element_id, options = {})
120
+ javascript_tag(drop_receiving_element_js(element_id, options).chop!)
121
+ end
122
+
123
+ def drop_receiving_element_js(element_id, options = {}) #:nodoc:
124
+ options[:with] ||= "'id=' + encodeURIComponent(element.id)"
125
+ options[:onDrop] ||= "function(element){" + remote_function(options) + "}"
126
+ options.delete_if { |key, value| PrototypeHelper::AJAX_OPTIONS.include?(key) }
127
+
128
+ options[:accept] = array_or_string_for_javascript(options[:accept]) if options[:accept]
129
+ options[:hoverclass] = "'#{options[:hoverclass]}'" if options[:hoverclass]
130
+
131
+ %(Droppables.add(#{element_id.to_json}, #{options_for_javascript(options)});)
132
+ end
133
+ end
134
+ end
135
+ end
@@ -20,12 +20,12 @@ module ActionView
20
20
  # if the +text+ is longer than +length+.
21
21
  def truncate(text, length = 30, truncate_string = "...")
22
22
  if text.nil? then return end
23
-
23
+ l = length - truncate_string.length
24
24
  if $KCODE == "NONE"
25
- text.length > length ? text[0..(length - 3)] + truncate_string : text
25
+ text.length > length ? text[0...l] + truncate_string : text
26
26
  else
27
27
  chars = text.split(//)
28
- chars.length > length ? chars[0..(length-3)].join + truncate_string : text
28
+ chars.length > length ? chars[0...l].join + truncate_string : text
29
29
  end
30
30
  end
31
31
 
@@ -77,7 +77,7 @@ module ActionView
77
77
  end
78
78
 
79
79
  begin
80
- require "redcloth"
80
+ require_library_or_gem "redcloth"
81
81
 
82
82
  # Returns the text with all the Textile codes turned into HTML-tags.
83
83
  # <i>This method is only available if RedCloth can be required</i>.
@@ -104,7 +104,7 @@ module ActionView
104
104
  end
105
105
 
106
106
  begin
107
- require "bluecloth"
107
+ require_library_or_gem "bluecloth"
108
108
 
109
109
  # Returns the text with all the Markdown codes turned into HTML-tags.
110
110
  # <i>This method is only available if BlueCloth can be required</i>.
@@ -142,6 +142,7 @@ module ActionView
142
142
  # truncate(text, 15)
143
143
  # end
144
144
  def auto_link(text, link = :all, href_options = {}, &block)
145
+ return '' if text.blank?
145
146
  case link
146
147
  when :all then auto_link_urls(auto_link_email_addresses(text, &block), href_options, &block)
147
148
  when :email_addresses then auto_link_email_addresses(text, &block)
@@ -324,7 +325,7 @@ module ActionView
324
325
  (?:www\.) # www.*
325
326
  )
326
327
  (
327
- ([\w]+[=?&\/.-]?)* # url segment
328
+ ([\w]+:?[=?&\/.-]?)* # url segment
328
329
  \w+[\/]? # url tail
329
330
  (?:\#\w*)? # trailing anchor
330
331
  )
@@ -10,16 +10,26 @@ module ActionView
10
10
  include JavaScriptHelper
11
11
 
12
12
  # Returns the URL for the set of +options+ provided. This takes the same options
13
- # as url_for. For a list, see the url_for documentation in link:classes/ActionController/Base.html#M000079.
13
+ # as url_for. For a list, see the documentation for ActionController::Base#url_for.
14
14
  # Note that it'll set :only_path => true so you'll get /controller/action instead of the
15
15
  # http://example.com/controller/action part (makes it harder to parse httpd log files)
16
+ #
17
+ # When called from a view, url_for returns an HTML escaped url. If you need an unescaped
18
+ # url, pass :escape => false to url_for.
19
+ #
16
20
  def url_for(options = {}, *parameters_for_method_reference)
17
- options = { :only_path => true }.update(options.symbolize_keys) if options.kind_of? Hash
18
- @controller.send(:url_for, options, *parameters_for_method_reference)
21
+ if options.kind_of? Hash
22
+ options = { :only_path => true }.update(options.symbolize_keys)
23
+ escape = options.key?(:escape) ? options.delete(:escape) : true
24
+ else
25
+ escape = true
26
+ end
27
+ url = @controller.send(:url_for, options, *parameters_for_method_reference)
28
+ escape ? html_escape(url) : url
19
29
  end
20
30
 
21
31
  # Creates a link tag of the given +name+ using an URL created by the set of +options+. See the valid options in
22
- # link:classes/ActionView/Helpers/UrlHelper.html#M000304. It's also possible to pass a string instead of an options hash to
32
+ # the documentation for ActionController::Base#url_for. It's also possible to pass a string instead of an options hash to
23
33
  # get a link tag that just points without consideration. If nil is passed as a name, the link itself will become the name.
24
34
  #
25
35
  # The html_options has three special features. One for creating javascript confirm alerts where if you pass :confirm => 'Are you sure?',
@@ -46,8 +56,8 @@ module ActionView
46
56
  else
47
57
  tag_options = nil
48
58
  end
49
- url = html_escape(options.is_a?(String) ? options : url_for(options, *parameters_for_method_reference))
50
- "<a href=\"#{url}\"#{tag_options}>#{name||url}</a>"
59
+ url = options.is_a?(String) ? options : self.url_for(options, *parameters_for_method_reference)
60
+ "<a href=\"#{url}\"#{tag_options}>#{name || url}</a>"
51
61
  end
52
62
 
53
63
  # Generates a form containing a sole button that submits to the
@@ -104,11 +114,10 @@ module ActionView
104
114
  if confirm = html_options.delete("confirm")
105
115
  html_options["onclick"] = "return #{confirm_javascript_function(confirm)};"
106
116
  end
107
-
108
- url, name = options.is_a?(String) ?
109
- [ options, name || options ] :
110
- [ url_for(options), name || html_escape(url_for(options)) ]
111
-
117
+
118
+ url = options.is_a?(String) ? options : url_for(options)
119
+ name ||= url
120
+
112
121
  html_options.merge!("type" => "submit", "value" => name)
113
122
 
114
123
  "<form method=\"post\" action=\"#{h url}\" class=\"button-to\"><div>" +
@@ -218,7 +227,7 @@ module ActionView
218
227
  for i in 0...tmp.length
219
228
  string << sprintf("%%%x",tmp[i])
220
229
  end
221
- "<script type=\"text/javascript\" language=\"javascript\">eval(unescape('#{string}'))</script>"
230
+ "<script type=\"text/javascript\">eval(unescape('#{string}'))</script>"
222
231
  elsif encode == 'hex'
223
232
  for i in 0...email_address.length
224
233
  if email_address[i,1] =~ /\w/
@@ -235,7 +244,7 @@ module ActionView
235
244
 
236
245
  # Returns true if the current page uri is generated by the options passed (in url_for format).
237
246
  def current_page?(options)
238
- url_for(options) == @controller.request.request_uri
247
+ CGI.escapeHTML(url_for(options)) == @controller.request.request_uri
239
248
  end
240
249
 
241
250
  private
@@ -269,7 +278,7 @@ module ActionView
269
278
  end
270
279
 
271
280
  def post_javascript_function
272
- "f = document.createElement('form'); document.body.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit();"
281
+ "var f = document.createElement('form'); this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href; f.submit();"
273
282
  end
274
283
 
275
284
  # Processes the _html_options_ hash, converting the boolean
@@ -54,7 +54,11 @@ module ActionView
54
54
  add_counter_to_local_assigns!(partial_name, local_assigns)
55
55
  add_object_to_local_assigns!(partial_name, local_assigns, object)
56
56
 
57
- ActionController::Base.benchmark("Rendered #{path}/_#{partial_name}", Logger::DEBUG, false) do
57
+ if logger
58
+ ActionController::Base.benchmark("Rendered #{path}/_#{partial_name}", Logger::DEBUG, false) do
59
+ render("#{path}/_#{partial_name}", local_assigns)
60
+ end
61
+ else
58
62
  render("#{path}/_#{partial_name}", local_assigns)
59
63
  end
60
64
  end
@@ -111,10 +115,14 @@ module ActionView
111
115
  counter_name = partial_counter_name(partial_name)
112
116
  local_assigns[counter_name] = 1 unless local_assigns.has_key?(counter_name)
113
117
  end
114
-
118
+
115
119
  def add_object_to_local_assigns!(partial_name, local_assigns, object)
116
- local_assigns[partial_name.intern] ||= object.is_a?(ActionView::Base::ObjectWrapper) ? object.value : object
117
- local_assigns[partial_name.intern] ||= controller.instance_variable_get("@#{partial_name}")
120
+ local_assigns[partial_name.intern] ||=
121
+ if object.is_a?(ActionView::Base::ObjectWrapper)
122
+ object.value
123
+ else
124
+ object
125
+ end || controller.instance_variable_get("@#{partial_name}")
118
126
  end
119
127
  end
120
128
  end
data/rakefile CHANGED
@@ -31,19 +31,25 @@ Rake::TestTask.new { |t|
31
31
  t.verbose = true
32
32
  }
33
33
 
34
+ desc 'ActiveRecord Integration Tests'
35
+ Rake::TestTask.new(:test_active_record_integration) do |t|
36
+ t.libs << "test"
37
+ t.test_files = Dir.glob("test/activerecord/*_test.rb")
38
+ t.verbose = true
39
+ end
40
+
34
41
 
35
42
  # Genereate the RDoc documentation
36
43
 
37
44
  Rake::RDocTask.new { |rdoc|
38
45
  rdoc.rdoc_dir = 'doc'
39
46
  rdoc.title = "Action Pack -- On rails from request to response"
40
- rdoc.options << '--line-numbers --inline-source --main README'
47
+ rdoc.options << '--line-numbers' << '--inline-source'
41
48
  rdoc.template = "#{ENV['template']}.rb" if ENV['template']
42
49
  rdoc.rdoc_files.include('README', 'RUNNING_UNIT_TESTS', 'CHANGELOG')
43
50
  rdoc.rdoc_files.include('lib/**/*.rb')
44
51
  }
45
52
 
46
-
47
53
  # Create compressed packages
48
54
  dist_dirs = [ "lib", "test", "examples" ]
49
55
 
@@ -62,7 +68,7 @@ spec = Gem::Specification.new do |s|
62
68
  s.has_rdoc = true
63
69
  s.requirements << 'none'
64
70
 
65
- s.add_dependency('activesupport', '= 1.2.5' + PKG_BUILD)
71
+ s.add_dependency('activesupport', '= 1.3.0' + PKG_BUILD)
66
72
 
67
73
  s.require_path = 'lib'
68
74
  s.autorequire = 'action_controller'
@@ -108,11 +114,13 @@ end
108
114
  # Publishing ------------------------------------------------------
109
115
 
110
116
  task :update_scriptaculous do
111
- system("svn export --force http://dev.rubyonrails.org/svn/rails/spinoffs/scriptaculous/src/ #{File.dirname(__FILE__)}/lib/action_view/helpers/javascripts/")
117
+ for js in %w( controls dragdrop effects )
118
+ system("svn export --force http://dev.rubyonrails.org/svn/rails/spinoffs/scriptaculous/src/#{js}.js #{File.dirname(__FILE__)}/lib/action_view/helpers/javascripts/#{js}.js")
119
+ end
112
120
  end
113
121
 
114
122
  desc "Updates actionpack to the latest version of the javascript spinoffs"
115
- task :update_js => [:update_scriptaculous]
123
+ task :update_js => [ :update_scriptaculous ]
116
124
 
117
125
  # Publishing ------------------------------------------------------
118
126
 
@@ -1,13 +1,14 @@
1
1
  $:.unshift(File.dirname(__FILE__) + '/../lib')
2
- $:.unshift(File.dirname(__FILE__) + '/../../activesupport/lib')
2
+ $:.unshift(File.dirname(__FILE__) + '/../../activesupport/lib/active_support')
3
3
  $:.unshift(File.dirname(__FILE__) + '/fixtures/helpers')
4
4
 
5
+ require 'yaml'
5
6
  require 'test/unit'
6
7
  require 'action_controller'
8
+ require 'breakpoint'
7
9
 
8
10
  require 'action_controller/test_process'
9
11
 
10
12
  ActionController::Base.logger = nil
11
13
  ActionController::Base.ignore_missing_templates = false
12
- ActionController::Routing::Routes.reload rescue nil
13
-
14
+ ActionController::Routing::Routes.reload rescue nil
@@ -0,0 +1,88 @@
1
+ require File.dirname(__FILE__) + '/abstract_unit'
2
+
3
+ # Define the essentials
4
+ class ActiveRecordTestConnector
5
+ cattr_accessor :able_to_connect
6
+ cattr_accessor :connected
7
+
8
+ # Set our defaults
9
+ self.connected = false
10
+ self.able_to_connect = true
11
+ end
12
+
13
+ # Try to grab AR
14
+ begin
15
+ PATH_TO_AR = File.dirname(__FILE__) + '/../../activerecord'
16
+ require "#{PATH_TO_AR}/lib/active_record" unless Object.const_defined?(:ActiveRecord)
17
+ require "#{PATH_TO_AR}/lib/active_record/fixtures" unless Object.const_defined?(:Fixtures)
18
+ rescue Object => e
19
+ $stderr.puts "\nSkipping ActiveRecord assertion tests: #{e}"
20
+ ActiveRecordTestConnector.able_to_connect = false
21
+ end
22
+
23
+ # Define the rest of the connector
24
+ class ActiveRecordTestConnector
25
+ def self.setup
26
+ unless self.connected || !self.able_to_connect
27
+ setup_connection
28
+ load_schema
29
+ self.connected = true
30
+ end
31
+ rescue Object => e
32
+ $stderr.puts "\nSkipping ActiveRecord assertion tests: #{e}"
33
+ #$stderr.puts " #{e.backtrace.join("\n ")}\n"
34
+ self.able_to_connect = false
35
+ end
36
+
37
+ private
38
+
39
+ def self.setup_connection
40
+ if Object.const_defined?(:ActiveRecord)
41
+
42
+ begin
43
+ ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :dbfile => ':memory:')
44
+ ActiveRecord::Base.connection
45
+ rescue Object
46
+ $stderr.puts 'SQLite 3 unavailable; falling to SQLite 2.'
47
+ ActiveRecord::Base.establish_connection(:adapter => 'sqlite', :dbfile => ':memory:')
48
+ ActiveRecord::Base.connection
49
+ end
50
+
51
+ Object.send(:const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type')) unless Object.const_defined?(:QUOTED_TYPE)
52
+ else
53
+ raise "Couldn't locate ActiveRecord."
54
+ end
55
+ end
56
+
57
+ # Load actionpack sqlite tables
58
+ def self.load_schema
59
+ File.read(File.dirname(__FILE__) + "/fixtures/db_definitions/sqlite.sql").split(';').each do |sql|
60
+ ActiveRecord::Base.connection.execute(sql) unless sql.blank?
61
+ end
62
+ end
63
+ end
64
+
65
+ # Test case for inheiritance
66
+ class ActiveRecordTestCase < Test::Unit::TestCase
67
+ # Set our fixture path
68
+ self.fixture_path = "#{File.dirname(__FILE__)}/fixtures/"
69
+
70
+ def setup
71
+ abort_tests unless ActiveRecordTestConnector.connected = true
72
+ end
73
+
74
+ # Default so Test::Unit::TestCase doesn't complain
75
+ def test_truth
76
+ end
77
+
78
+ private
79
+
80
+ # If things go wrong, we don't want to run our test cases. We'll just define them to test nothing.
81
+ def abort_tests
82
+ self.class.public_instance_methods.grep(/^test./).each do |method|
83
+ self.class.class_eval { define_method(method.to_sym){} }
84
+ end
85
+ end
86
+ end
87
+
88
+ ActiveRecordTestConnector.setup