Skip to content
Browse files

update Rails

  • Loading branch information...
1 parent cd4a384 commit 098f41c6c90c2bcac7591b9456ae9dd966301012 @jweiss jweiss committed
Showing with 3,732 additions and 602 deletions.
  1. +2 −0 CHANGELOG.txt
  2. +1 −1 config/environment.rb
  3. +4 −0 vendor/rails/actionmailer/CHANGELOG
  4. +1 −1 vendor/rails/actionmailer/Rakefile
  5. +2 −0 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/parser.rb
  6. +1 −1 vendor/rails/actionmailer/lib/action_mailer/version.rb
  7. +1 −0 vendor/rails/actionmailer/lib/actionmailer.rb
  8. +1 −1 vendor/rails/actionmailer/test/fixtures/helpers/example_helper.rb
  9. +3 −1 vendor/rails/actionmailer/test/mail_service_test.rb
  10. +12 −0 vendor/rails/actionpack/CHANGELOG
  11. +1 −1 vendor/rails/actionpack/Rakefile
  12. +3 −1 vendor/rails/actionpack/lib/action_controller.rb
  13. +19 −3 vendor/rails/actionpack/lib/action_controller/assertions/dom_assertions.rb
  14. +16 −10 vendor/rails/actionpack/lib/action_controller/assertions/selector_assertions.rb
  15. +1 −1 vendor/rails/actionpack/lib/action_controller/base.rb
  16. +1 −0 vendor/rails/actionpack/lib/action_controller/caching.rb
  17. +2 −1 vendor/rails/actionpack/lib/action_controller/cookies.rb
  18. +3 −2 vendor/rails/actionpack/lib/action_controller/http_authentication.rb
  19. +15 −3 vendor/rails/actionpack/lib/action_controller/integration.rb
  20. +6 −1 vendor/rails/actionpack/lib/action_controller/layout.rb
  21. +2 −0 vendor/rails/actionpack/lib/action_controller/middlewares.rb
  22. +6 −21 vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb
  23. +36 −0 vendor/rails/actionpack/lib/action_controller/rack_lint_patch.rb
  24. +6 −2 vendor/rails/actionpack/lib/action_controller/request_forgery_protection.rb
  25. +2 −1 vendor/rails/actionpack/lib/action_controller/response.rb
  26. +29 −0 vendor/rails/actionpack/lib/action_controller/string_coercion.rb
  27. +6 −1 vendor/rails/actionpack/lib/action_controller/test_case.rb
  28. +1 −1 vendor/rails/actionpack/lib/action_controller/test_process.rb
  29. +2 −2 vendor/rails/actionpack/lib/action_controller/translation.rb
  30. +2 −2 vendor/rails/actionpack/lib/action_controller/uploaded_file.rb
  31. +1 −1 vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb
  32. +1 −1 vendor/rails/actionpack/lib/action_pack/version.rb
  33. +3 −3 vendor/rails/actionpack/lib/action_view.rb
  34. +6 −1 vendor/rails/actionpack/lib/action_view/base.rb
  35. +6 −0 vendor/rails/actionpack/lib/action_view/erb/util.rb
  36. +2 −0 vendor/rails/actionpack/lib/action_view/helpers.rb
  37. +3 −3 vendor/rails/actionpack/lib/action_view/helpers/active_record_helper.rb
  38. +2 −2 vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb
  39. +2 −2 vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb
  40. +27 −15 vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb
  41. +32 −11 vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb
  42. +1 −1 vendor/rails/actionpack/lib/action_view/helpers/form_options_helper.rb
  43. +3 −3 vendor/rails/actionpack/lib/action_view/helpers/form_tag_helper.rb
  44. +6 −1 vendor/rails/actionpack/lib/action_view/helpers/number_helper.rb
  45. +1 −1 vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb
  46. +9 −0 vendor/rails/actionpack/lib/action_view/helpers/raw_output_helper.rb
  47. +10 −2 vendor/rails/actionpack/lib/action_view/helpers/sanitize_helper.rb
  48. +4 −4 vendor/rails/actionpack/lib/action_view/helpers/tag_helper.rb
  49. +1 −1 vendor/rails/actionpack/lib/action_view/helpers/translation_helper.rb
  50. +3 −3 vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb
  51. +3 −0 vendor/rails/actionpack/lib/action_view/locale/en.yml
  52. +1 −1 vendor/rails/actionpack/lib/action_view/partials.rb
  53. +28 −0 vendor/rails/actionpack/lib/action_view/safe_buffer.rb
  54. +8 −2 vendor/rails/actionpack/lib/action_view/template.rb
  55. +102 −27 vendor/rails/actionpack/lib/action_view/test_case.rb
  56. +1 −0 vendor/rails/actionpack/lib/actionpack.rb
  57. +7 −0 vendor/rails/actionpack/test/controller/cookie_test.rb
  58. +53 −0 vendor/rails/actionpack/test/controller/dom_assertions_test.rb
  59. +1 −0 vendor/rails/actionpack/test/controller/filter_params_test.rb
  60. +1 −0 vendor/rails/actionpack/test/controller/html-scanner/sanitizer_test.rb
  61. +22 −0 vendor/rails/actionpack/test/controller/http_digest_authentication_test.rb
  62. +38 −0 vendor/rails/actionpack/test/controller/integration_test.rb
  63. +11 −0 vendor/rails/actionpack/test/controller/layout_test.rb
  64. +4 −0 vendor/rails/actionpack/test/controller/polymorphic_routes_test.rb
  65. +19 −1 vendor/rails/actionpack/test/controller/request_forgery_protection_test.rb
  66. +23 −15 vendor/rails/actionpack/test/controller/routing_test.rb
  67. +2 −2 vendor/rails/actionpack/test/controller/session/test_session_test.rb
  68. +1 −0 vendor/rails/actionpack/test/fixtures/layout_tests/abs_path_layout.rhtml
  69. +1 −0 vendor/rails/actionpack/test/fixtures/test/_from_helper.erb
  70. +1 −1 vendor/rails/actionpack/test/template/active_record_helper_test.rb
  71. +12 −0 vendor/rails/actionpack/test/template/asset_tag_helper_test.rb
  72. +6 −6 vendor/rails/actionpack/test/template/benchmark_helper_test.rb
  73. +2 −1 vendor/rails/actionpack/test/template/compiled_templates_test.rb
  74. +10 −9 vendor/rails/actionpack/test/template/date_helper_i18n_test.rb
  75. +29 −13 vendor/rails/actionpack/test/template/date_helper_test.rb
  76. +90 −10 vendor/rails/actionpack/test/template/form_helper_test.rb
  77. +4 −0 vendor/rails/actionpack/test/template/number_helper_test.rb
  78. +21 −0 vendor/rails/actionpack/test/template/raw_output_helper_test.rb
  79. +10 −1 vendor/rails/actionpack/test/template/sanitize_helper_test.rb
  80. +1 −0 vendor/rails/actionpack/test/template/tag_helper_test.rb
  81. +36 −0 vendor/rails/actionpack/test/view/safe_buffer_test.rb
  82. +173 −5 vendor/rails/actionpack/test/view/test_case_test.rb
  83. +8 −0 vendor/rails/activerecord/CHANGELOG
  84. +1 −1 vendor/rails/activerecord/Rakefile
  85. +10 −7 vendor/rails/activerecord/lib/active_record/associations.rb
  86. +7 −8 vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb
  87. +2 −2 vendor/rails/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
  88. +9 −0 vendor/rails/activerecord/lib/active_record/associations/has_one_association.rb
  89. +32 −23 vendor/rails/activerecord/lib/active_record/autosave_association.rb
  90. +7 −0 vendor/rails/activerecord/lib/active_record/base.rb
  91. +6 −2 vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
  92. +1 −1 vendor/rails/activerecord/lib/active_record/fixtures.rb
  93. +0 −33 vendor/rails/activerecord/lib/active_record/locking/optimistic.rb
  94. +0 −22 vendor/rails/activerecord/lib/active_record/locking/pessimistic.rb
  95. +101 −38 vendor/rails/activerecord/lib/active_record/nested_attributes.rb
  96. +35 −35 vendor/rails/activerecord/lib/active_record/validations.rb
  97. +1 −1 vendor/rails/activerecord/lib/active_record/version.rb
  98. +1 −0 vendor/rails/activerecord/lib/activerecord.rb
  99. +12 −0 vendor/rails/activerecord/test/cases/associations/has_many_associations_test.rb
  100. +22 −0 vendor/rails/activerecord/test/cases/associations/has_many_through_associations_test.rb
  101. +21 −0 vendor/rails/activerecord/test/cases/associations/has_one_associations_test.rb
  102. +230 −11 vendor/rails/activerecord/test/cases/autosave_association_test.rb
  103. +2 −0 vendor/rails/activerecord/test/cases/base_test.rb
  104. +8 −0 vendor/rails/activerecord/test/cases/connection_test_mysql.rb
  105. +2 −2 vendor/rails/activerecord/test/cases/fixtures_test.rb
  106. +0 −18 vendor/rails/activerecord/test/cases/locking_test.rb
  107. +109 −37 vendor/rails/activerecord/test/cases/nested_attributes_test.rb
  108. +3 −3 vendor/rails/activerecord/test/cases/reflection_test.rb
  109. +8 −0 vendor/rails/activerecord/test/cases/validations_i18n_test.rb
  110. +37 −9 vendor/rails/activerecord/test/cases/validations_test.rb
  111. +1 −0 vendor/rails/activerecord/test/fixtures/accounts.yml
  112. BIN vendor/rails/activerecord/test/fixtures/fixture_database.sqlite3
  113. BIN vendor/rails/activerecord/test/fixtures/fixture_database_2.sqlite3
  114. +10 −0 vendor/rails/activerecord/test/models/company.rb
  115. +9 −2 vendor/rails/activerecord/test/models/pirate.rb
  116. +2 −0 vendor/rails/activerecord/test/models/treasure.rb
  117. +12 −0 vendor/rails/activerecord/test/schema/mysql_specific_schema.rb
  118. +1 −0 vendor/rails/activerecord/test/schema/schema.rb
  119. +9 −0 vendor/rails/activeresource/CHANGELOG
  120. +1 −1 vendor/rails/activeresource/Rakefile
  121. +2 −2 vendor/rails/activeresource/lib/active_resource/validations.rb
  122. +1 −1 vendor/rails/activeresource/lib/active_resource/version.rb
  123. +1 −0 vendor/rails/activeresource/lib/activeresource.rb
  124. +2 −2 vendor/rails/activeresource/test/base_errors_test.rb
  125. +1,728 −0 vendor/rails/activeresource/test/debug.log
  126. +8 −0 vendor/rails/activesupport/CHANGELOG
  127. +7 −0 vendor/rails/activesupport/lib/active_support/cache.rb
  128. +5 −0 vendor/rails/activesupport/lib/active_support/cache/mem_cache_store.rb
  129. +5 −5 vendor/rails/activesupport/lib/active_support/cache/strategy/local_cache.rb
  130. +7 −3 vendor/rails/activesupport/lib/active_support/core_ext.rb
  131. +2 −58 vendor/rails/activesupport/lib/active_support/core_ext/blank.rb
  132. +1 −0 vendor/rails/activesupport/lib/active_support/core_ext/kernel/debugger.rb
  133. +3 −1 vendor/rails/activesupport/lib/active_support/core_ext/name_error.rb
  134. +1 −0 vendor/rails/activesupport/lib/active_support/core_ext/object.rb
  135. +58 −0 vendor/rails/activesupport/lib/active_support/core_ext/object/blank.rb
  136. +2 −0 vendor/rails/activesupport/lib/active_support/core_ext/string.rb
  137. +48 −0 vendor/rails/activesupport/lib/active_support/core_ext/string/output_safety.rb
  138. +2 −1 vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb
  139. +1 −1 vendor/rails/activesupport/lib/active_support/deprecation.rb
  140. +2 −3 vendor/rails/activesupport/lib/active_support/json/backends/jsongem.rb
  141. +1 −5 vendor/rails/activesupport/lib/active_support/json/backends/yaml.rb
  142. +2 −0 vendor/rails/activesupport/lib/active_support/json/decoding.rb
  143. +30 −10 vendor/rails/activesupport/lib/active_support/message_verifier.rb
  144. +1 −1 vendor/rails/activesupport/lib/active_support/multibyte/chars.rb
  145. +4 −4 vendor/rails/activesupport/lib/active_support/multibyte/utils.rb
  146. +7 −0 vendor/rails/activesupport/lib/active_support/ordered_hash.rb
  147. +2 −2 vendor/rails/activesupport/lib/active_support/vendor.rb
  148. +1 −1 vendor/rails/activesupport/lib/active_support/version.rb
  149. +8 −2 vendor/rails/activesupport/lib/active_support/whiny_nil.rb
  150. +13 −21 vendor/rails/activesupport/lib/active_support/xml_mini/nokogiri.rb
  151. +1 −0 vendor/rails/activesupport/lib/activesupport.rb
  152. +6 −0 vendor/rails/railties/CHANGELOG
  153. +6 −6 vendor/rails/railties/Rakefile
  154. +1 −1 vendor/rails/railties/lib/commands/plugin.rb
  155. +2 −0 vendor/rails/railties/lib/rails/rack/debugger.rb
  156. +1 −1 vendor/rails/railties/lib/rails/version.rb
  157. +7 −7 vendor/rails/railties/lib/rails_generator/options.rb
  158. +2 −1 vendor/rails/railties/lib/tasks/rails.rb
View
2 CHANGELOG.txt
@@ -1,6 +1,8 @@
edge
+* Update to Rails 2.3.5
+
* When cloning, also clone roles. Provided by Sergio Cambra.
* Update to Rails 2.3.4
View
2 config/environment.rb
@@ -5,7 +5,7 @@
# ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
-RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION
+RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
View
4 vendor/rails/actionmailer/CHANGELOG
@@ -1,3 +1,7 @@
+*2.3.5 (November 25, 2009)*
+
+* Minor Bug Fixes and deprecation warnings
+
*2.3.4 (September 4, 2009)*
* Minor bug fixes.
View
2 vendor/rails/actionmailer/Rakefile
@@ -54,7 +54,7 @@ spec = Gem::Specification.new do |s|
s.rubyforge_project = "actionmailer"
s.homepage = "http://www.rubyonrails.org"
- s.add_dependency('actionpack', '= 2.3.4' + PKG_BUILD)
+ s.add_dependency('actionpack', '= 2.3.5' + PKG_BUILD)
s.has_rdoc = true
s.requirements << 'none'
View
2 vendor/rails/actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/parser.rb
@@ -43,6 +43,7 @@ module Racc
class Parser
+ old_verbose, $VERBOSE = $VERBOSE, nil
Racc_Runtime_Version = '1.4.5'
Racc_Runtime_Revision = '$Revision: 1.7 $'.split[1]
@@ -71,6 +72,7 @@ class Parser
Racc_Runtime_Core_Revision = Racc_Runtime_Core_Revision_R
Racc_Runtime_Type = 'ruby'
end
+ $VERBOSE = old_verbose
def Parser.racc_runtime_type
Racc_Runtime_Type
View
2 vendor/rails/actionmailer/lib/action_mailer/version.rb
@@ -2,7 +2,7 @@ module ActionMailer
module VERSION #:nodoc:
MAJOR = 2
MINOR = 3
- TINY = 4
+ TINY = 5
STRING = [MAJOR, MINOR, TINY].join('.')
end
View
1 vendor/rails/actionmailer/lib/actionmailer.rb
@@ -1 +1,2 @@
require 'action_mailer'
+ActiveSupport::Deprecation.warn 'require "actionmailer" is deprecated and will be removed in Rails 3. Use require "action_mailer" instead.'
View
2 vendor/rails/actionmailer/test/fixtures/helpers/example_helper.rb
@@ -1,5 +1,5 @@
module ExampleHelper
def example_format(text)
- "<em><strong><small>#{text}</small></strong></em>"
+ "<em><strong><small>#{h(text)}</small></strong></em>".html_safe!
end
end
View
4 vendor/rails/actionmailer/test/mail_service_test.rb
@@ -570,7 +570,9 @@ def test_delivery_logs_sent_mail
mail = TestMailer.create_signed_up(@recipient)
logger = mock()
logger.expects(:info).with("Sent mail to #{@recipient}")
- logger.expects(:debug).with("\n#{mail.encoded}")
+ logger.expects(:debug).with() do |logged_text|
+ logged_text =~ /\[Signed up\] Welcome/
+ end
TestMailer.logger = logger
TestMailer.deliver_signed_up(@recipient)
end
View
12 vendor/rails/actionpack/CHANGELOG
@@ -1,3 +1,15 @@
+*2.3.5 (November 25, 2009)*
+
+* Minor Bug Fixes and deprecation warnings
+
+* Ruby 1.9 Support
+
+* Fix filtering parameters when there are Fixnum or other un-dupable values.
+
+* Improvements to ActionView::TestCase
+
+* Compatiblity with the rails_xss plugin
+
*2.3.4 (September 4, 2009)*
* Sanitize multibyte strings before escaping them with escape_once. CVE-2009-3009
View
2 vendor/rails/actionpack/Rakefile
@@ -79,7 +79,7 @@ spec = Gem::Specification.new do |s|
s.has_rdoc = true
s.requirements << 'none'
- s.add_dependency('activesupport', '= 2.3.4' + PKG_BUILD)
+ s.add_dependency('activesupport', '= 2.3.5' + PKG_BUILD)
s.add_dependency('rack', '~> 1.0.0')
s.require_path = 'lib'
View
4 vendor/rails/actionpack/lib/action_controller.rb
@@ -31,8 +31,9 @@
end
end
-gem 'rack', '~> 1.0.0'
+gem 'rack', '~> 1.0.1'
require 'rack'
+require 'action_controller/cgi_ext'
module ActionController
# TODO: Review explicit to see if they will automatically be handled by
@@ -70,6 +71,7 @@ def self.load_all!
autoload :SessionManagement, 'action_controller/session_management'
autoload :StatusCodes, 'action_controller/status_codes'
autoload :Streaming, 'action_controller/streaming'
+ autoload :StringCoercion, 'action_controller/string_coercion'
autoload :TestCase, 'action_controller/test_case'
autoload :TestProcess, 'action_controller/test_process'
autoload :Translation, 'action_controller/translation'
View
22 vendor/rails/actionpack/lib/action_controller/assertions/dom_assertions.rb
@@ -1,6 +1,18 @@
module ActionController
module Assertions
module DomAssertions
+ def self.strip_whitespace!(nodes)
+ nodes.reject! do |node|
+ if node.is_a?(HTML::Text)
+ node.content.strip!
+ node.content.empty?
+ else
+ strip_whitespace! node.children
+ false
+ end
+ end
+ end
+
# Test two HTML strings for equivalency (e.g., identical up to reordering of attributes)
#
# ==== Examples
@@ -12,13 +24,15 @@ def assert_dom_equal(expected, actual, message = "")
clean_backtrace do
expected_dom = HTML::Document.new(expected).root
actual_dom = HTML::Document.new(actual).root
- full_message = build_message(message, "<?> expected to be == to\n<?>.", expected_dom.to_s, actual_dom.to_s)
+ DomAssertions.strip_whitespace!(expected_dom.children)
+ DomAssertions.strip_whitespace!(actual_dom.children)
+ full_message = build_message(message, "<?> expected but was\n<?>.", expected_dom.to_s, actual_dom.to_s)
assert_block(full_message) { expected_dom == actual_dom }
end
end
- # The negated form of +assert_dom_equivalent+.
+ # The negated form of +assert_dom_equal+.
#
# ==== Examples
#
@@ -29,8 +43,10 @@ def assert_dom_not_equal(expected, actual, message = "")
clean_backtrace do
expected_dom = HTML::Document.new(expected).root
actual_dom = HTML::Document.new(actual).root
- full_message = build_message(message, "<?> expected to be != to\n<?>.", expected_dom.to_s, actual_dom.to_s)
+ DomAssertions.strip_whitespace!(expected_dom.children)
+ DomAssertions.strip_whitespace!(actual_dom.children)
+ full_message = build_message(message, "<?> expected to be != to\n<?>.", expected_dom.to_s, actual_dom.to_s)
assert_block(full_message) { expected_dom != actual_dom }
end
end
View
26 vendor/rails/actionpack/lib/action_controller/assertions/selector_assertions.rb
@@ -16,7 +16,7 @@ module Assertions
#
# Use +css_select+ to select elements without making an assertions, either
# from the response HTML or elements selected by the enclosing assertion.
- #
+ #
# In addition to HTML responses, you can make the following assertions:
# * +assert_select_rjs+ - Assertions on HTML content of RJS update and insertion operations.
# * +assert_select_encoded+ - Assertions on HTML encoded inside XML, for example for dealing with feed item descriptions.
@@ -24,6 +24,12 @@ module Assertions
#
# Also see HTML::Selector to learn how to use selectors.
module SelectorAssertions
+
+ def initialize(*args)
+ super
+ @selected = nil
+ end
+
# :call-seq:
# css_select(selector) => array
# css_select(element, selector) => array
@@ -53,8 +59,8 @@ module SelectorAssertions
# end
#
# # Selects all list items in unordered lists
- # items = css_select("ul>li")
- #
+ # items = css_select("ul>li")
+ #
# # Selects all form tags and then all inputs inside the form
# forms = css_select("form")
# forms.each do |form|
@@ -212,7 +218,7 @@ def assert_select(*args, &block)
# Otherwise just operate on the response document.
root = response_from_page_or_rjs
end
-
+
# First or second argument is the selector: string and we pass
# all remaining arguments. Array and we pass the argument. Also
# accepts selector itself.
@@ -225,7 +231,7 @@ def assert_select(*args, &block)
selector = arg
else raise ArgumentError, "Expecting a selector as the first argument"
end
-
+
# Next argument is used for equality tests.
equals = {}
case arg = args.shift
@@ -315,10 +321,10 @@ def assert_select(*args, &block)
# Returns all matches elements.
matches
end
-
+
def count_description(min, max) #:nodoc:
pluralize = lambda {|word, quantity| word << (quantity == 1 ? '' : 's')}
-
+
if min && max && (max != min)
"between #{min} and #{max} elements"
elsif min && !(min == 1 && max == 1)
@@ -327,7 +333,7 @@ def count_description(min, max) #:nodoc:
"at most #{max} #{pluralize['element', max]}"
end
end
-
+
# :call-seq:
# assert_select_rjs(id?) { |elements| ... }
# assert_select_rjs(statement, id?) { |elements| ... }
@@ -344,7 +350,7 @@ def count_description(min, max) #:nodoc:
# that update or insert an element with that identifier.
#
# Use the first argument to narrow down assertions to only statements
- # of that type. Possible values are <tt>:replace</tt>, <tt>:replace_html</tt>,
+ # of that type. Possible values are <tt>:replace</tt>, <tt>:replace_html</tt>,
# <tt>:show</tt>, <tt>:hide</tt>, <tt>:toggle</tt>, <tt>:remove</tt> and
# <tt>:insert_html</tt>.
#
@@ -488,7 +494,7 @@ def assert_select_rjs(*args, &block)
# end
# end
# end
- #
+ #
#
# # Selects all paragraph tags from within the description of an RSS feed
# assert_select_feed :rss, 2.0 do
View
2 vendor/rails/actionpack/lib/action_controller/base.rb
@@ -502,7 +502,7 @@ def filter_parameter_logging(*filter_words, &block)
end
elsif block_given?
key = key.dup
- value = value.dup if value
+ value = value.dup if value.duplicable?
yield key, value
filtered_parameters[key] = value
else
View
1 vendor/rails/actionpack/lib/action_controller/caching.rb
@@ -22,6 +22,7 @@ module ActionController #:nodoc:
# ActionController::Base.cache_store = :file_store, "/path/to/cache/directory"
# ActionController::Base.cache_store = :drb_store, "druby://localhost:9192"
# ActionController::Base.cache_store = :mem_cache_store, "localhost"
+ # ActionController::Base.cache_store = :mem_cache_store, Memcached::Rails.new("localhost:11211")
# ActionController::Base.cache_store = MyOwnStore.new("parameter")
module Caching
autoload :Actions, 'action_controller/caching/actions'
View
3 vendor/rails/actionpack/lib/action_controller/cookies.rb
@@ -87,8 +87,9 @@ def []=(key, options)
def delete(key, options = {})
options.symbolize_keys!
options[:path] = "/" unless options.has_key?(:path)
- super(key.to_s)
+ value = super(key.to_s)
@controller.response.delete_cookie(key, options)
+ value
end
end
end
View
5 vendor/rails/actionpack/lib/action_controller/http_authentication.rb
@@ -227,9 +227,9 @@ def decode_credentials_header(request)
end
def decode_credentials(header)
- header.to_s.gsub(/^Digest\s+/,'').split(',').inject({}) do |hash, pair|
+ header.to_s.gsub(/^Digest\s+/,'').split(',').inject({}.with_indifferent_access) do |hash, pair|
key, value = pair.split('=', 2)
- hash[key.strip.to_sym] = value.to_s.gsub(/^"|"$/,'').gsub(/'/, '')
+ hash[key.strip] = value.to_s.gsub(/^"|"$/,'').gsub(/'/, '')
hash
end
end
@@ -289,6 +289,7 @@ def nonce(time = Time.now)
# allow a user to use new nonce without prompting user again for their
# username and password.
def validate_nonce(request, value, seconds_to_timeout=5*60)
+ return false if value.nil?
t = Base64.decode64(value).split(":").first.to_i
nonce(t) == value && (t - Time.now.to_i).abs <= seconds_to_timeout
end
View
18 vendor/rails/actionpack/lib/action_controller/integration.rb
@@ -1,6 +1,7 @@
require 'stringio'
require 'uri'
require 'active_support/test_case'
+require 'action_controller/rack_lint_patch'
module ActionController
module Integration #:nodoc:
@@ -268,7 +269,9 @@ def process(method, path, parameters = nil, headers = nil)
env["QUERY_STRING"] ||= ""
- data = data.is_a?(IO) ? data : StringIO.new(data || '')
+ data ||= ''
+ data.force_encoding(Encoding::ASCII_8BIT) if data.respond_to?(:force_encoding)
+ data = data.is_a?(IO) ? data : StringIO.new(data)
env.update(
"REQUEST_METHOD" => method.to_s.upcase,
@@ -476,6 +479,11 @@ def new_with_capture(*args)
end
module Runner
+ def initialize(*args)
+ super
+ @integration_session = nil
+ end
+
# Reset the current session. This is useful for testing multiple sessions
# in a single test case.
def reset!
@@ -543,8 +551,12 @@ def copy_session_variables! #:nodoc:
# Delegate unhandled messages to the current session instance.
def method_missing(sym, *args, &block)
reset! unless @integration_session
- returning @integration_session.__send__(sym, *args, &block) do
- copy_session_variables!
+ if @integration_session.respond_to?(sym)
+ returning @integration_session.__send__(sym, *args, &block) do
+ copy_session_variables!
+ end
+ else
+ super
end
end
end
View
7 vendor/rails/actionpack/lib/action_controller/layout.rb
@@ -194,6 +194,11 @@ def normalize_conditions(conditions)
end
end
+ def initialize(*args)
+ super
+ @real_format = nil
+ end
+
# Returns the name of the active layout. If the layout was specified as a method reference (through a symbol), this method
# is called and the return value is used. Likewise if the layout was specified as an inline method (through a proc or method
# object). If the layout was defined without a directory, layouts is assumed. So <tt>layout "weblog/standard"</tt> will return
@@ -221,7 +226,7 @@ def default_layout #:nodoc:
end
def find_layout(layout, format, html_fallback=false) #:nodoc:
- view_paths.find_template(layout.to_s =~ /layouts\// ? layout : "layouts/#{layout}", format, html_fallback)
+ view_paths.find_template(layout.to_s =~ /\A\/|layouts\// ? layout : "layouts/#{layout}", format, html_fallback)
rescue ActionView::MissingTemplate
raise if Mime::Type.lookup_by_extension(format.to_s).html?
end
View
2 vendor/rails/actionpack/lib/action_controller/middlewares.rb
@@ -10,3 +10,5 @@
use "ActionController::ParamsParser"
use "Rack::MethodOverride"
use "Rack::Head"
+
+use "ActionController::StringCoercion"
View
27 vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb
@@ -76,8 +76,7 @@ def polymorphic_url(record_or_hash_or_array, options = {})
record_or_hash_or_array = record_or_hash_or_array[0] if record_or_hash_or_array.size == 1
end
- record = extract_record(record_or_hash_or_array)
- namespace = extract_namespace(record_or_hash_or_array)
+ record = extract_record(record_or_hash_or_array)
args = case record_or_hash_or_array
when Hash; [ record_or_hash_or_array ]
@@ -98,8 +97,7 @@ def polymorphic_url(record_or_hash_or_array, options = {})
end
args.delete_if {|arg| arg.is_a?(Symbol) || arg.is_a?(String)}
-
- named_route = build_named_route_call(record_or_hash_or_array, namespace, inflection, options)
+ named_route = build_named_route_call(record_or_hash_or_array, inflection, options)
url_options = options.except(:action, :routing_type)
unless url_options.empty?
@@ -153,7 +151,7 @@ def routing_type(options)
options[:routing_type] || :url
end
- def build_named_route_call(records, namespace, inflection, options = {})
+ def build_named_route_call(records, inflection, options = {})
unless records.is_a?(Array)
record = extract_record(records)
route = ''
@@ -163,7 +161,7 @@ def build_named_route_call(records, namespace, inflection, options = {})
if parent.is_a?(Symbol) || parent.is_a?(String)
string << "#{parent}_"
else
- string << "#{RecordIdentifier.__send__("plural_class_name", parent)}".singularize
+ string << RecordIdentifier.__send__("plural_class_name", parent).singularize
string << "_"
end
end
@@ -172,12 +170,12 @@ def build_named_route_call(records, namespace, inflection, options = {})
if record.is_a?(Symbol) || record.is_a?(String)
route << "#{record}_"
else
- route << "#{RecordIdentifier.__send__("plural_class_name", record)}"
+ route << RecordIdentifier.__send__("plural_class_name", record)
route = route.singularize if inflection == :singular
route << "_"
end
- action_prefix(options) + namespace + route + routing_type(options).to_s
+ action_prefix(options) + route + routing_type(options).to_s
end
def extract_record(record_or_hash_or_array)
@@ -187,18 +185,5 @@ def extract_record(record_or_hash_or_array)
else record_or_hash_or_array
end
end
-
- # Remove the first symbols from the array and return the url prefix
- # implied by those symbols.
- def extract_namespace(record_or_hash_or_array)
- return "" unless record_or_hash_or_array.is_a?(Array)
-
- namespace_keys = []
- while (key = record_or_hash_or_array.first) && key.is_a?(String) || key.is_a?(Symbol)
- namespace_keys << record_or_hash_or_array.shift
- end
-
- namespace_keys.map {|k| "#{k}_"}.join
- end
end
end
View
36 vendor/rails/actionpack/lib/action_controller/rack_lint_patch.rb
@@ -0,0 +1,36 @@
+# Rack 1.0 does not allow string subclass body. This does not play well with our ActionView::SafeBuffer.
+# The next release of Rack will be allowing string subclass body - http://github.com/rack/rack/commit/de668df02802a0335376a81ba709270e43ba9d55
+# TODO : Remove this monkey patch after the next release of Rack
+
+module RackLintPatch
+ module AllowStringSubclass
+ def self.included(base)
+ base.send :alias_method, :each, :each_with_hack
+ end
+
+ def each_with_hack
+ @closed = false
+
+ @body.each { |part|
+ assert("Body yielded non-string value #{part.inspect}") {
+ part.kind_of?(String)
+ }
+ yield part
+ }
+
+ if @body.respond_to?(:to_path)
+ assert("The file identified by body.to_path does not exist") {
+ ::File.exist? @body.to_path
+ }
+ end
+ end
+ end
+
+ begin
+ app = proc {|env| [200, {"Content-Type" => "text/plain", "Content-Length" => "12"}, [Class.new(String).new("Hello World!")]] }
+ response = Rack::MockRequest.new(Rack::Lint.new(app)).get('/')
+ rescue Rack::Lint::LintError => e
+ raise(e) unless e.message =~ /Body yielded non-string value/
+ Rack::Lint.send :include, AllowStringSubclass
+ end
+end
View
8 vendor/rails/actionpack/lib/action_controller/request_forgery_protection.rb
@@ -89,9 +89,13 @@ def verified_request?
request.method == :get ||
request.xhr? ||
!verifiable_request_format? ||
- form_authenticity_token == params[request_forgery_protection_token]
+ form_authenticity_token == form_authenticity_param
end
-
+
+ def form_authenticity_param
+ params[request_forgery_protection_token]
+ end
+
def verifiable_request_format?
!request.content_type.nil? && request.content_type.verify_request?
end
View
3 vendor/rails/actionpack/lib/action_controller/response.rb
@@ -47,7 +47,8 @@ def initialize
@block = nil
@body = "",
- @session, @assigns = [], []
+ @session = []
+ @assigns = []
end
def location; headers['Location'] end
View
29 vendor/rails/actionpack/lib/action_controller/string_coercion.rb
@@ -0,0 +1,29 @@
+module ActionController
+ class StringCoercion
+ class UglyBody < ActiveSupport::BasicObject
+ def initialize(body)
+ @body = body
+ end
+
+ def each
+ @body.each do |part|
+ yield part.to_s
+ end
+ end
+
+ private
+ def method_missing(*args, &block)
+ @body.__send__(*args, &block)
+ end
+ end
+
+ def initialize(app)
+ @app = app
+ end
+
+ def call(env)
+ status, headers, body = @app.call(env)
+ [status, headers, UglyBody.new(body)]
+ end
+ end
+end
View
7 vendor/rails/actionpack/lib/action_controller/test_case.rb
@@ -105,6 +105,11 @@ module ActionController
class TestCase < ActiveSupport::TestCase
include TestProcess
+ def initialize(*args)
+ super
+ @controller = nil
+ end
+
module Assertions
%w(response selector tag dom routing model).each do |kind|
include ActionController::Assertions.const_get("#{kind.camelize}Assertions")
@@ -195,7 +200,7 @@ def setup_controller_request_and_response
@controller.send(:initialize_current_url)
end
end
-
+
# Cause the action to be rescued according to the regular rules for rescue_action when the visitor is not local
def rescue_action_in_public!
@request.remote_addr = '208.77.188.166' # example.com
View
2 vendor/rails/actionpack/lib/action_controller/test_process.rb
@@ -91,7 +91,7 @@ def path(*args)
@path || super()
end
- def assign_parameters(controller_path, action, parameters)
+ def assign_parameters(controller_path, action, parameters = {})
parameters = parameters.symbolize_keys.merge(:controller => controller_path, :action => action)
extra_keys = ActionController::Routing::Routes.extra_keys(parameters)
non_path_parameters = get? ? query_parameters : request_parameters
View
4 vendor/rails/actionpack/lib/action_controller/translation.rb
@@ -1,12 +1,12 @@
module ActionController
module Translation
def translate(*args)
- I18n.translate *args
+ I18n.translate(*args)
end
alias :t :translate
def localize(*args)
- I18n.localize *args
+ I18n.localize(*args)
end
alias :l :localize
end
View
4 vendor/rails/actionpack/lib/action_controller/uploaded_file.rb
@@ -3,14 +3,14 @@ module UploadedFile
def self.included(base)
base.class_eval do
attr_accessor :original_path, :content_type
- alias_method :local_path, :path
+ alias_method :local_path, :path if method_defined?(:path)
end
end
def self.extended(object)
object.class_eval do
attr_accessor :original_path, :content_type
- alias_method :local_path, :path
+ alias_method :local_path, :path if method_defined?(:path)
end
end
View
2 vendor/rails/actionpack/lib/action_controller/vendor/html-scanner/html/node.rb
@@ -162,7 +162,7 @@ def parse(parent, line, pos, content, strict=true)
end
closing = ( scanner.scan(/\//) ? :close : nil )
- return Text.new(parent, line, pos, content) unless name = scanner.scan(/[\w:-]+/)
+ return Text.new(parent, line, pos, content) unless name = scanner.scan(/[-:\w\x00-\x09\x0b-\x0c\x0e-\x1f]+/)
name.downcase!
unless closing
View
2 vendor/rails/actionpack/lib/action_pack/version.rb
@@ -2,7 +2,7 @@ module ActionPack #:nodoc:
module VERSION #:nodoc:
MAJOR = 2
MINOR = 3
- TINY = 4
+ TINY = 5
STRING = [MAJOR, MINOR, TINY].join('.')
end
View
6 vendor/rails/actionpack/lib/action_view.rb
@@ -49,10 +49,10 @@ def self.load_all!
autoload :TemplateHandler, 'action_view/template_handler'
autoload :TemplateHandlers, 'action_view/template_handlers'
autoload :Helpers, 'action_view/helpers'
+ autoload :SafeBuffer, 'action_view/safe_buffer'
end
-class ERB
- autoload :Util, 'action_view/erb/util'
-end
+require 'action_view/erb/util'
+
I18n.load_path << "#{File.dirname(__FILE__)}/action_view/locale/en.yml"
View
7 vendor/rails/actionpack/lib/action_view/base.rb
@@ -187,13 +187,18 @@ class << self
@@cache_template_loading = nil
cattr_accessor :cache_template_loading
+ # :nodoc:
+ def self.xss_safe?
+ false
+ end
+
def self.cache_template_loading?
ActionController::Base.allow_concurrency || (cache_template_loading.nil? ? !ActiveSupport::Dependencies.load? : cache_template_loading)
end
attr_internal :request
- delegate :request_forgery_protection_token, :template, :params, :session, :cookies, :response, :headers,
+ delegate :request_forgery_protection_token, :params, :session, :cookies, :response, :headers,
:flash, :logger, :action_name, :controller_name, :to => :controller
module CompiledTemplates #:nodoc:
View
6 vendor/rails/actionpack/lib/action_view/erb/util.rb
@@ -18,6 +18,12 @@ def html_escape(s)
s.to_s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }
end
+ undef :h
+ alias h html_escape
+
+ module_function :html_escape
+ module_function :h
+
# A utility method for escaping HTML entities in JSON strings.
# This method is also aliased as <tt>j</tt>.
#
View
2 vendor/rails/actionpack/lib/action_view/helpers.rb
@@ -14,6 +14,7 @@ module Helpers #:nodoc:
autoload :JavaScriptHelper, 'action_view/helpers/javascript_helper'
autoload :NumberHelper, 'action_view/helpers/number_helper'
autoload :PrototypeHelper, 'action_view/helpers/prototype_helper'
+ autoload :RawOutputHelper, 'action_view/helpers/raw_output_helper'
autoload :RecordIdentificationHelper, 'action_view/helpers/record_identification_helper'
autoload :RecordTagHelper, 'action_view/helpers/record_tag_helper'
autoload :SanitizeHelper, 'action_view/helpers/sanitize_helper'
@@ -45,6 +46,7 @@ module ClassMethods
include JavaScriptHelper
include NumberHelper
include PrototypeHelper
+ include RawOutputHelper
include RecordIdentificationHelper
include RecordTagHelper
include SanitizeHelper
View
6 vendor/rails/actionpack/lib/action_view/helpers/active_record_helper.rb
@@ -3,7 +3,7 @@
module ActionView
class Base
- @@field_error_proc = Proc.new{ |html_tag, instance| "<div class=\"fieldWithErrors\">#{html_tag}</div>" }
+ @@field_error_proc = Proc.new{ |html_tag, instance| "<div class=\"fieldWithErrors\">#{html_tag}</div>".html_safe! }
cattr_accessor :field_error_proc
end
@@ -171,7 +171,7 @@ def error_messages_for(*params)
options = params.extract_options!.symbolize_keys
if object = options.delete(:object)
- objects = [object].flatten
+ objects = Array.wrap(object)
else
objects = params.collect {|object_name| instance_variable_get("@#{object_name}") }.compact
end
@@ -290,7 +290,7 @@ def to_time_select_tag(options = {}, html_options = {})
end
def error_wrapping(html_tag, has_error)
- has_error ? Base.field_error_proc.call(html_tag, self) : html_tag
+ has_error ? Base.field_error_proc.call(html_tag, self).html_safe! : html_tag
end
def error_message
View
4 vendor/rails/actionpack/lib/action_view/helpers/asset_tag_helper.rb
@@ -285,7 +285,7 @@ def javascript_include_tag(*sources)
end
javascript_src_tag(joined_javascript_name, options)
else
- expand_javascript_sources(sources, recursive).collect { |source| javascript_src_tag(source, options) }.join("\n")
+ expand_javascript_sources(sources, recursive).collect { |source| javascript_src_tag(source, options) }.join("\n").html_safe!
end
end
@@ -434,7 +434,7 @@ def stylesheet_link_tag(*sources)
end
stylesheet_tag(joined_stylesheet_name, options)
else
- expand_stylesheet_sources(sources, recursive).collect { |source| stylesheet_tag(source, options) }.join("\n")
+ expand_stylesheet_sources(sources, recursive).collect { |source| stylesheet_tag(source, options) }.join("\n").html_safe!
end
end
View
4 vendor/rails/actionpack/lib/action_view/helpers/capture_helper.rb
@@ -118,13 +118,13 @@ def capture(*args, &block)
def content_for(name, content = nil, &block)
ivar = "@content_for_#{name}"
content = capture(&block) if block_given?
- instance_variable_set(ivar, "#{instance_variable_get(ivar)}#{content}")
+ instance_variable_set(ivar, "#{instance_variable_get(ivar)}#{content}".html_safe!)
nil
end
# Use an alternate output buffer for the duration of the block.
# Defaults to a new empty string.
- def with_output_buffer(buf = '') #:nodoc:
+ def with_output_buffer(buf = "") #:nodoc:
self.output_buffer, old_buffer = buf, output_buffer
yield
output_buffer
View
42 vendor/rails/actionpack/lib/action_view/helpers/date_helper.rb
@@ -26,8 +26,10 @@ module DateHelper
# 47 hrs, 59 mins, 29 secs <-> 29 days, 23 hrs, 59 mins, 29 secs # => [2..29] days
# 29 days, 23 hrs, 59 mins, 30 secs <-> 59 days, 23 hrs, 59 mins, 29 secs # => about 1 month
# 59 days, 23 hrs, 59 mins, 30 secs <-> 1 yr minus 1 sec # => [2..12] months
- # 1 yr <-> 2 yrs minus 1 secs # => about 1 year
- # 2 yrs <-> max time or date # => over [2..X] years
+ # 1 yr <-> 1 yr, 3 months # => about 1 year
+ # 1 yr, 3 months <-> 1 yr, 9 months # => over 1 year
+ # 1 yr, 9 months <-> 2 yr minus 1 sec # => almost 2 years
+ # 2 yrs <-> max time or date # => (same rules as 1 yr)
#
# With <tt>include_seconds</tt> = true and the difference < 1 minute 29 seconds:
# 0-4 secs # => less than 5 seconds
@@ -43,17 +45,18 @@ module DateHelper
# distance_of_time_in_words(from_time, 50.minutes.from_now) # => about 1 hour
# distance_of_time_in_words(from_time, from_time + 15.seconds) # => less than a minute
# distance_of_time_in_words(from_time, from_time + 15.seconds, true) # => less than 20 seconds
- # distance_of_time_in_words(from_time, 3.years.from_now) # => over 3 years
+ # distance_of_time_in_words(from_time, 3.years.from_now) # => about 3 years
# distance_of_time_in_words(from_time, from_time + 60.hours) # => about 3 days
# distance_of_time_in_words(from_time, from_time + 45.seconds, true) # => less than a minute
# distance_of_time_in_words(from_time, from_time - 45.seconds, true) # => less than a minute
# distance_of_time_in_words(from_time, 76.seconds.from_now) # => 1 minute
# distance_of_time_in_words(from_time, from_time + 1.year + 3.days) # => about 1 year
- # distance_of_time_in_words(from_time, from_time + 4.years + 9.days + 30.minutes + 5.seconds) # => over 4 years
+ # distance_of_time_in_words(from_time, from_time + 3.years + 6.months) # => over 3 years
+ # distance_of_time_in_words(from_time, from_time + 4.years + 9.days + 30.minutes + 5.seconds) # => about 4 years
#
# to_time = Time.now + 6.years + 19.days
- # distance_of_time_in_words(from_time, to_time, true) # => over 6 years
- # distance_of_time_in_words(to_time, from_time, true) # => over 6 years
+ # distance_of_time_in_words(from_time, to_time, true) # => about 6 years
+ # distance_of_time_in_words(to_time, from_time, true) # => about 6 years
# distance_of_time_in_words(Time.now, Time.now) # => less than a minute
#
def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false, options = {})
@@ -81,12 +84,21 @@ def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false, o
when 2..44 then locale.t :x_minutes, :count => distance_in_minutes
when 45..89 then locale.t :about_x_hours, :count => 1
when 90..1439 then locale.t :about_x_hours, :count => (distance_in_minutes.to_f / 60.0).round
- when 1440..2879 then locale.t :x_days, :count => 1
- when 2880..43199 then locale.t :x_days, :count => (distance_in_minutes / 1440).round
+ when 1440..2529 then locale.t :x_days, :count => 1
+ when 2530..43199 then locale.t :x_days, :count => (distance_in_minutes.to_f / 1440.0).round
when 43200..86399 then locale.t :about_x_months, :count => 1
- when 86400..525599 then locale.t :x_months, :count => (distance_in_minutes / 43200).round
- when 525600..1051199 then locale.t :about_x_years, :count => 1
- else locale.t :over_x_years, :count => (distance_in_minutes / 525600).round
+ when 86400..525599 then locale.t :x_months, :count => (distance_in_minutes.to_f / 43200.0).round
+ else
+ distance_in_years = distance_in_minutes / 525600
+ minute_offset_for_leap_year = (distance_in_years / 4) * 1440
+ remainder = ((distance_in_minutes - minute_offset_for_leap_year) % 525600)
+ if remainder < 131400
+ locale.t(:about_x_years, :count => distance_in_years)
+ elsif remainder < 394200
+ locale.t(:over_x_years, :count => distance_in_years)
+ else
+ locale.t(:almost_x_years, :count => distance_in_years + 1)
+ end
end
end
end
@@ -904,15 +916,15 @@ def separator(type)
class InstanceTag #:nodoc:
def to_date_select_tag(options = {}, html_options = {})
- datetime_selector(options, html_options).select_date
+ datetime_selector(options, html_options).select_date.html_safe!
end
def to_time_select_tag(options = {}, html_options = {})
- datetime_selector(options, html_options).select_time
+ datetime_selector(options, html_options).select_time.html_safe!
end
def to_datetime_select_tag(options = {}, html_options = {})
- datetime_selector(options, html_options).select_datetime
+ datetime_selector(options, html_options).select_datetime.html_safe!
end
private
@@ -923,7 +935,7 @@ def datetime_selector(options, html_options)
options[:field_name] = @method_name
options[:include_position] = true
options[:prefix] ||= @object_name
- options[:index] = @auto_index if @auto_index && !options.has_key?(:index)
+ options[:index] = @auto_index if defined?(@auto_index) && @auto_index && !options.has_key?(:index)
options[:datetime_separator] ||= ' &mdash; '
options[:time_separator] ||= ' : '
View
43 vendor/rails/actionpack/lib/action_view/helpers/form_helper.rb
@@ -280,7 +280,7 @@ def form_for(record_or_name_or_array, *args, &proc)
concat(form_tag(options.delete(:url) || {}, options.delete(:html) || {}))
fields_for(object_name, *(args << options), &proc)
- concat('</form>')
+ concat('</form>'.html_safe!)
end
def apply_form_for_options!(object_or_array, options) #:nodoc:
@@ -445,6 +445,15 @@ def apply_form_for_options!(object_or_array, options) #:nodoc:
# <% end %>
# <% end %>
#
+ # Or a collection to be used:
+ #
+ # <% form_for @person, :url => { :action => "update" } do |person_form| %>
+ # ...
+ # <% person_form.fields_for :projects, @active_projects do |project_fields| %>
+ # Name: <%= project_fields.text_field :name %>
+ # <% end %>
+ # <% end %>
+ #
# When projects is already an association on Person you can use
# +accepts_nested_attributes_for+ to define the writer method for you:
#
@@ -788,7 +797,7 @@ def to_check_box_tag(options = {}, checked_value = "1", unchecked_value = "0")
add_default_name_and_id(options)
hidden = tag("input", "name" => options["name"], "type" => "hidden", "value" => options['disabled'] && checked ? checked_value : unchecked_value)
checkbox = tag("input", options)
- hidden + checkbox
+ (hidden + checkbox).html_safe!
end
def to_boolean_select_tag(options = {})
@@ -930,7 +939,7 @@ def initialize(object_name, object, template, options, proc)
end
end
- (field_helpers - %w(label check_box radio_button fields_for)).each do |selector|
+ (field_helpers - %w(label check_box radio_button fields_for hidden_field)).each do |selector|
src = <<-end_src
def #{selector}(method, options = {}) # def text_field(method, options = {})
@template.send( # @template.send(
@@ -989,6 +998,11 @@ def check_box(method, options = {}, checked_value = "1", unchecked_value = "0")
def radio_button(method, tag_value, options = {})
@template.radio_button(@object_name, method, tag_value, objectify_options(options))
end
+
+ def hidden_field(method, options = {})
+ @emitted_hidden_id = true if method == :id
+ @template.hidden_field(@object_name, method, objectify_options(options))
+ end
def error_message_on(method, *args)
@template.error_message_on(@object, method, *args)
@@ -1002,6 +1016,10 @@ def submit(value = "Save changes", options = {})
@template.submit_tag(value, options.reverse_merge(:id => "#{object_name}_submit"))
end
+ def emitted_hidden_id?
+ @emitted_hidden_id
+ end
+
private
def objectify_options(options)
@default_options.merge(options.merge(:object => @object))
@@ -1013,18 +1031,21 @@ def nested_attributes_association?(association_name)
def fields_for_with_nested_attributes(association_name, args, block)
name = "#{object_name}[#{association_name}_attributes]"
- association = @object.send(association_name)
- explicit_object = args.first if args.first.respond_to?(:new_record?)
+ association = args.first
+
+ if association.respond_to?(:new_record?)
+ association = [association] if @object.send(association_name).is_a?(Array)
+ elsif !association.is_a?(Array)
+ association = @object.send(association_name)
+ end
if association.is_a?(Array)
- children = explicit_object ? [explicit_object] : association
explicit_child_index = args.last[:child_index] if args.last.is_a?(Hash)
-
- children.map do |child|
+ association.map do |child|
fields_for_nested_model("#{name}[#{explicit_child_index || nested_child_index(name)}]", child, args, block)
end.join
- else
- fields_for_nested_model(name, explicit_object || association, args, block)
+ elsif association
+ fields_for_nested_model(name, association, args, block)
end
end
@@ -1033,8 +1054,8 @@ def fields_for_nested_model(name, object, args, block)
@template.fields_for(name, object, *args, &block)
else
@template.fields_for(name, object, *args) do |builder|
- @template.concat builder.hidden_field(:id)
block.call(builder)
+ @template.concat builder.hidden_field(:id) unless builder.emitted_hidden_id?
end
end
end
View
2 vendor/rails/actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -296,7 +296,7 @@ def options_for_select(container, selected = nil)
options << %(<option value="#{html_escape(value.to_s)}"#{selected_attribute}#{disabled_attribute}>#{html_escape(text.to_s)}</option>)
end
- options_for_select.join("\n")
+ options_for_select.join("\n").html_safe!
end
# Returns a string of option tags that have been compiled by iterating over the +collection+ and assigning the
View
6 vendor/rails/actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -432,7 +432,7 @@ def field_set_tag(legend = nil, options = nil, &block)
concat(tag(:fieldset, options, true))
concat(content_tag(:legend, legend)) unless legend.blank?
concat(content)
- concat("</fieldset>")
+ concat("</fieldset>".html_safe!)
end
private
@@ -459,14 +459,14 @@ def extra_tags_for_form(html_options)
def form_tag_html(html_options)
extra_tags = extra_tags_for_form(html_options)
- tag(:form, html_options, true) + extra_tags
+ (tag(:form, html_options, true) + extra_tags).html_safe!
end
def form_tag_in_block(html_options, &block)
content = capture(&block)
concat(form_tag_html(html_options))
concat(content)
- concat("</form>")
+ concat("</form>".html_safe!)
end
def token_tag
View
7 vendor/rails/actionpack/lib/action_view/helpers/number_helper.rb
@@ -246,6 +246,11 @@ def number_with_precision(number, *args)
# number_to_human_size(483989, :precision => 0) # => 473 KB
# number_to_human_size(1234567, :precision => 2, :separator => ',') # => 1,18 MB
#
+ # Zeros after the decimal point are always stripped out, regardless of the
+ # specified precision:
+ # helper.number_to_human_size(1234567890123, :precision => 5) # => "1.12283 TB"
+ # helper.number_to_human_size(524288000, :precision=>5) # => "500 MB"
+ #
# You can still use <tt>number_to_human_size</tt> with the old API that accepts the
# +precision+ as its optional second parameter:
# number_to_human_size(1234567, 2) # => 1.18 MB
@@ -291,7 +296,7 @@ def number_to_human_size(number, *args)
:precision => precision,
:separator => separator,
:delimiter => delimiter
- ).sub(/(\d)(#{escaped_separator}[1-9]*)?0+\z/, '\1\2').sub(/#{escaped_separator}\z/, '')
+ ).sub(/(#{escaped_separator})(\d*[1-9])?0+\z/, '\1\2').sub(/#{escaped_separator}\z/, '')
storage_units_format.gsub(/%n/, formatted_number).gsub(/%u/, unit)
rescue
number
View
2 vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb
@@ -393,7 +393,7 @@ def remote_form_for(record_or_name_or_array, *args, &proc)
concat(form_remote_tag(options))
fields_for(object_name, *(args << options), &proc)
- concat('</form>')
+ concat('</form>'.html_safe!)
end
alias_method :form_remote_for, :remote_form_for
View
9 vendor/rails/actionpack/lib/action_view/helpers/raw_output_helper.rb
@@ -0,0 +1,9 @@
+module ActionView #:nodoc:
+ module Helpers #:nodoc:
+ module RawOutputHelper
+ def raw(stringish)
+ stringish.to_s.html_safe!
+ end
+ end
+ end
+end
View
12 vendor/rails/actionpack/lib/action_view/helpers/sanitize_helper.rb
@@ -49,7 +49,11 @@ module SanitizeHelper
# confuse browsers.
#
def sanitize(html, options = {})
- self.class.white_list_sanitizer.sanitize(html, options)
+ returning self.class.white_list_sanitizer.sanitize(html, options) do |sanitized|
+ if sanitized
+ sanitized.html_safe!
+ end
+ end
end
# Sanitizes a block of CSS code. Used by +sanitize+ when it comes across a style attribute.
@@ -72,7 +76,11 @@ def sanitize_css(style)
# strip_tags("<div id='top-bar'>Welcome to my website!</div>")
# # => Welcome to my website!
def strip_tags(html)
- self.class.full_sanitizer.sanitize(html)
+ returning self.class.full_sanitizer.sanitize(html) do |sanitized|
+ if sanitized
+ sanitized.html_safe!
+ end
+ end
end
# Strips all link tags from +text+ leaving just the link text.
View
8 vendor/rails/actionpack/lib/action_view/helpers/tag_helper.rb
@@ -38,7 +38,7 @@ module TagHelper
# tag("img", { :src => "open &amp; shut.png" }, false, false)
# # => <img src="open &amp; shut.png" />
def tag(name, options = nil, open = false, escape = true)
- "<#{name}#{tag_options(options, escape) if options}#{open ? ">" : " />"}"
+ "<#{name}#{tag_options(options, escape) if options}#{open ? ">" : " />"}".html_safe!
end
# Returns an HTML block tag of type +name+ surrounding the +content+. Add
@@ -91,7 +91,7 @@ def content_tag(name, content_or_options_with_block = nil, options = nil, escape
# cdata_section(File.read("hello_world.txt"))
# # => <![CDATA[<hello from a text file]]>
def cdata_section(content)
- "<![CDATA[#{content}]]>"
+ "<![CDATA[#{content}]]>".html_safe!
end
# Returns an escaped version of +html+ without affecting existing escaped entities.
@@ -125,7 +125,7 @@ def block_called_from_erb?(block)
def content_tag_string(name, content, options, escape = true)
tag_options = tag_options(options, escape) if options
- "<#{name}#{tag_options}>#{content}</#{name}>"
+ "<#{name}#{tag_options}>#{content}</#{name}>".html_safe!
end
def tag_options(options, escape = true)
@@ -142,7 +142,7 @@ def tag_options(options, escape = true)
else
attrs = options.map { |key, value| %(#{key}="#{value}") }
end
- " #{attrs.sort * ' '}" unless attrs.empty?
+ " #{attrs.sort * ' '}".html_safe! unless attrs.empty?
end
end
end
View
2 vendor/rails/actionpack/lib/action_view/helpers/translation_helper.rb
@@ -21,7 +21,7 @@ def translate(key, options = {})
# Delegates to I18n.localize with no additional functionality.
def localize(*args)
- I18n.localize *args
+ I18n.localize(*args)
end
alias :l :localize
View
6 vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb
@@ -219,7 +219,7 @@ def link_to(*args, &block)
if block_given?
options = args.first || {}
html_options = args.second
- concat(link_to(capture(&block), options, html_options))
+ concat(link_to(capture(&block), options, html_options).html_safe!)
else
name = args.first
options = args.second || {}
@@ -237,7 +237,7 @@ def link_to(*args, &block)
end
href_attr = "href=\"#{url}\"" unless href
- "<a #{href_attr}#{tag_options}>#{name || url}</a>"
+ "<a #{href_attr}#{tag_options}>#{name || url}</a>".html_safe!
end
end
@@ -309,7 +309,7 @@ def button_to(name, options = {}, html_options = {})
html_options.merge!("type" => "submit", "value" => name)
"<form method=\"#{form_method}\" action=\"#{escape_once url}\" class=\"button-to\"><div>" +
- method_tag + tag("input", html_options) + request_token_tag + "</div></form>"
+ method_tag + tag("input", html_options) + request_token_tag + "</div></form>".html_safe!
end
View
3 vendor/rails/actionpack/lib/action_view/locale/en.yml
@@ -91,6 +91,9 @@
over_x_years:
one: "over 1 year"
other: "over {{count}} years"
+ almost_x_years:
+ one: "almost 1 year"
+ other: "almost {{count}} years"
prompts:
year: "Year"
month: "Month"
View
2 vendor/rails/actionpack/lib/action_view/partials.rb
@@ -221,7 +221,7 @@ def render_partial_collection(options = {}) #:nodoc:
result = template.render_partial(self, object, local_assigns.dup, as)
index += 1
result
- end.join(spacer)
+ end.join(spacer).html_safe!
end
def _pick_partial_template(partial_path) #:nodoc:
View
28 vendor/rails/actionpack/lib/action_view/safe_buffer.rb
@@ -0,0 +1,28 @@
+
+module ActionView #:nodoc:
+ class SafeBuffer < String
+ def <<(value)
+ if value.html_safe?
+ super(value)
+ else
+ super(ERB::Util.h(value))
+ end
+ end
+
+ def concat(value)
+ self << value
+ end
+
+ def html_safe?
+ true
+ end
+
+ def html_safe!
+ self
+ end
+
+ def to_s
+ self
+ end
+ end
+end
View
10 vendor/rails/actionpack/lib/action_view/template.rb
@@ -57,9 +57,14 @@ def relative_path_for_template_file(full_file_path)
end
class EagerPath < Path
+ def initialize(path)
+ super
+ @loaded = false
+ end
+
def load!
return if @loaded
-
+
@paths = {}
templates_in_path do |template|
template.load!
@@ -103,8 +108,9 @@ def self.exempt_from_layout(*extensions)
@@exempt_from_layout.merge(regexps)
end
- attr_accessor :template_path, :filename, :load_path, :base_path
+ attr_accessor :template_path, :load_path, :base_path
attr_accessor :locale, :name, :format, :extension
+ attr_writer :filename
delegate :to_s, :to => :path
def initialize(template_path, load_path = nil)
View
129 vendor/rails/actionpack/lib/action_view/test_case.rb
@@ -22,11 +22,52 @@ def render(view, local_assigns = {})
end
class TestCase < ActiveSupport::TestCase
+ class TestController < ActionController::Base
+ attr_accessor :request, :response, :params
+
+ def self.controller_path
+ ''
+ end
+
+ def initialize
+ @request = ActionController::TestRequest.new
+ @response = ActionController::TestResponse.new
+
+ @params = {}
+ send(:initialize_current_url)
+ end
+ end
+
include ActionController::TestCase::Assertions
include ActionController::TestProcess
+ include ActionController::PolymorphicRoutes
+ include ActionController::RecordIdentifier
+
+ include ActionView::Helpers
+ include ActionController::Helpers
+
class_inheritable_accessor :helper_class
- @@helper_class = nil
+ attr_accessor :controller, :output_buffer, :rendered
+
+ setup :setup_with_controller
+ def setup_with_controller
+ @controller = TestController.new
+ @output_buffer = ''
+ @rendered = ''
+
+ self.class.send(:include_helper_modules!)
+ make_test_case_available_to_view!
+ end
+
+ def render(options = {}, local_assigns = {}, &block)
+ @rendered << output = _view.render(options, local_assigns, &block)
+ output
+ end
+
+ def protect_against_forgery?
+ false
+ end
class << self
def tests(helper_class)
@@ -46,42 +87,76 @@ def determine_default_helper_class(name)
rescue NameError
nil
end
- end
- include ActionView::Helpers
- include ActionController::PolymorphicRoutes
- include ActionController::RecordIdentifier
+ def helper_method(*methods)
+ # Almost a duplicate from ActionController::Helpers
+ methods.flatten.each do |method|
+ master_helper_module.module_eval <<-end_eval
+ def #{method}(*args, &block) # def current_user(*args, &block)
+ _test_case.send(%(#{method}), *args, &block) # test_case.send(%(current_user), *args, &block)
+ end # end
+ end_eval
+ end
+ end
- setup :setup_with_helper_class
+ private
+ def include_helper_modules!
+ helper(helper_class) if helper_class
+ include master_helper_module
+ end
+ end
- def setup_with_helper_class
- if helper_class && !self.class.ancestors.include?(helper_class)
- self.class.send(:include, helper_class)
+ private
+ def make_test_case_available_to_view!
+ test_case_instance = self
+ master_helper_module.module_eval do
+ define_method(:_test_case) { test_case_instance }
+ private :_test_case
+ end
end
- self.output_buffer = ''
- end
+ def _view
+ view = ActionView::Base.new(ActionController::Base.view_paths, _assigns, @controller)
+ view.helpers.include master_helper_module
+ view.output_buffer = self.output_buffer
+ view
+ end
- class TestController < ActionController::Base
- attr_accessor :request, :response, :params
+ # Support the selector assertions
+ #
+ # Need to experiment if this priority is the best one: rendered => output_buffer
+ def response_from_page_or_rjs
+ HTML::Document.new(rendered.blank? ? output_buffer : rendered).root
+ end
- def initialize
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
-
- @params = {}
- send(:initialize_current_url)
+ EXCLUDE_IVARS = %w{
+ @output_buffer
+ @fixture_cache
+ @method_name
+ @_result
+ @loaded_fixtures
+ @test_passed
+ @view
+ }
+
+ def _instance_variables
+ instance_variables - EXCLUDE_IVARS
end
- end
- protected
- attr_accessor :output_buffer
+ def _assigns
+ _instance_variables.inject({}) do |hash, var|
+ name = var[1..-1].to_sym
+ hash[name] = instance_variable_get(var)
+ hash
+ end
+ end
- private
def method_missing(selector, *args)
- controller = TestController.new
- return controller.__send__(selector, *args) if ActionController::Routing::Routes.named_routes.helpers.include?(selector)
- super
+ if ActionController::Routing::Routes.named_routes.helpers.include?(selector)
+ @controller.__send__(selector, *args)
+ else
+ super
+ end
end
end
-end
+end
View
1 vendor/rails/actionpack/lib/actionpack.rb
@@ -1 +1,2 @@
require 'action_pack'
+ActiveSupport::Deprecation.warn 'require "actionpack" is deprecated and will be removed in Rails 3. Use require "action_pack" instead.'
View
7 vendor/rails/actionpack/test/controller/cookie_test.rb
@@ -114,6 +114,13 @@ def test_cookiejar_accessor_with_array_value
assert_equal %w{1 2 3}, jar["pages"]
end
+ def test_cookiejar_delete_removes_item_and_returns_its_value
+ @request.cookies["user_name"] = "david"
+ @controller.response = @response
+ jar = ActionController::CookieJar.new(@controller)
+ assert_equal "david", jar.delete("user_name")
+ end
+
def test_delete_cookie_with_path
get :delete_cookie_with_path
assert_equal ["user_name=; path=/beaten; expires=Thu, 01-Jan-1970 00:00:00 GMT"], @response.headers["Set-Cookie"]
View
53 vendor/rails/actionpack/test/controller/dom_assertions_test.rb
@@ -0,0 +1,53