Permalink
Browse files

Merge branch 'master' of git://github.com/lifo/docrails

  • Loading branch information...
2 parents 018bf0f + cffae06 commit 62eb00a62e3868c3500372def52968b919332b51 @rajinder-yadav rajinder-yadav committed Oct 16, 2010
Showing with 3,185 additions and 2,204 deletions.
  1. +6 −0 Gemfile
  2. +1 −0 actionmailer/lib/action_mailer.rb
  3. +3 −6 actionmailer/lib/action_mailer/base.rb
  4. +2 −2 actionmailer/lib/action_mailer/old_api.rb
  5. +3 −3 actionmailer/lib/action_mailer/railtie.rb
  6. +1 −1 actionmailer/lib/rails/generators/mailer/templates/mailer.rb
  7. +1 −4 actionmailer/test/old_base/mail_service_test.rb
  8. +11 −3 actionpack/CHANGELOG
  9. +8 −5 actionpack/RUNNING_UNIT_TESTS
  10. +5 −4 actionpack/lib/abstract_controller/base.rb
  11. +2 −3 actionpack/lib/abstract_controller/rendering.rb
  12. +5 −0 actionpack/lib/action_controller/metal.rb
  13. +1 −1 actionpack/lib/action_controller/metal/conditional_get.rb
  14. +2 −4 actionpack/lib/action_controller/metal/head.rb
  15. +10 −12 actionpack/lib/action_controller/metal/http_authentication.rb
  16. +0 −1 actionpack/lib/action_controller/metal/rendering.rb
  17. +0 −4 actionpack/lib/action_controller/metal/streaming.rb
  18. +4 −4 actionpack/lib/action_controller/railtie.rb
  19. +4 −2 actionpack/lib/action_controller/railties/paths.rb
  20. +7 −4 actionpack/lib/action_controller/test_case.rb
  21. +1 −21 actionpack/lib/action_dispatch/http/cache.rb
  22. +10 −11 actionpack/lib/action_dispatch/http/request.rb
  23. +1 −1 actionpack/lib/action_dispatch/http/response.rb
  24. +13 −12 actionpack/lib/action_dispatch/http/upload.rb
  25. +0 −5 actionpack/lib/action_dispatch/http/url.rb
  26. +54 −229 actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
  27. +20 −44 actionpack/lib/action_dispatch/middleware/session/cookie_store.rb
  28. +7 −46 actionpack/lib/action_dispatch/middleware/session/mem_cache_store.rb
  29. +3 −3 actionpack/lib/action_dispatch/middleware/static.rb
  30. +28 −46 actionpack/lib/action_dispatch/routing/mapper.rb
  31. +2 −1 actionpack/lib/action_dispatch/routing/route_set.rb
  32. +2 −6 actionpack/lib/action_dispatch/testing/assertions/response.rb
  33. +1 −2 actionpack/lib/action_dispatch/testing/performance_test.rb
  34. +8 −1 actionpack/lib/action_view.rb
  35. +19 −19 actionpack/lib/action_view/base.rb
  36. +1 −4 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  37. +5 −10 actionpack/lib/action_view/helpers/form_helper.rb
  38. +0 −1 actionpack/lib/action_view/helpers/form_options_helper.rb
  39. +1 −1 actionpack/lib/action_view/helpers/prototype_helper.rb
  40. +1 −1 actionpack/lib/action_view/helpers/text_helper.rb
  41. +2 −2 actionpack/lib/action_view/helpers/translation_helper.rb
  42. +24 −27 actionpack/lib/action_view/helpers/url_helper.rb
  43. +21 −10 actionpack/lib/action_view/lookup_context.rb
  44. +2 −2 actionpack/lib/action_view/paths.rb
  45. +0 −83 actionpack/lib/action_view/render/layouts.rb
  46. +4 −157 actionpack/lib/action_view/render/partials.rb
  47. +67 −28 actionpack/lib/action_view/render/rendering.rb
  48. +36 −0 actionpack/lib/action_view/renderer/abstract_renderer.rb
  49. +166 −0 actionpack/lib/action_view/renderer/partial_renderer.rb
  50. +97 −0 actionpack/lib/action_view/renderer/template_renderer.rb
  51. +112 −44 actionpack/lib/action_view/template.rb
  52. +3 −2 actionpack/lib/action_view/template/error.rb
  53. +9 −1 actionpack/lib/action_view/template/handler.rb
  54. +3 −7 actionpack/lib/action_view/template/handlers.rb
  55. +4 −4 actionpack/lib/action_view/template/handlers/builder.rb
  56. +15 −10 actionpack/lib/action_view/template/handlers/erb.rb
  57. +4 −8 actionpack/lib/action_view/template/handlers/rjs.rb
  58. +20 −0 actionpack/lib/action_view/template/inline.rb
  59. +86 −29 actionpack/lib/action_view/template/resolver.rb
  60. +0 −4 actionpack/lib/action_view/template/text.rb
  61. +21 −5 actionpack/lib/action_view/test_case.rb
  62. +8 −5 actionpack/lib/action_view/testing/resolvers.rb
  63. +35 −0 actionpack/test/abstract_unit.rb
  64. +7 −0 actionpack/test/controller/action_pack_assertions_test.rb
  65. +5 −1 actionpack/test/controller/capture_test.rb
  66. +12 −12 actionpack/test/controller/content_type_test.rb
  67. +3 −2 actionpack/test/controller/filters_test.rb
  68. +1 −1 actionpack/test/controller/integration_test.rb
  69. +9 −9 actionpack/test/controller/layout_test.rb
  70. +3 −3 actionpack/test/controller/log_subscriber_test.rb
  71. +15 −0 actionpack/test/controller/new_base/bare_metal_test.rb
  72. +0 −46 actionpack/test/controller/new_base/etag_test.rb
  73. +72 −0 actionpack/test/controller/new_base/render_once_test.rb
  74. +15 −2 actionpack/test/controller/new_base/render_partial_test.rb
  75. +25 −1 actionpack/test/controller/new_base/render_template_test.rb
  76. +1 −26 actionpack/test/controller/record_identifier_test.rb
  77. +0 −18 actionpack/test/controller/redirect_test.rb
  78. +0 −118 actionpack/test/controller/render_test.rb
  79. +0 −16 actionpack/test/controller/rescue_test.rb
  80. +77 −16 actionpack/test/dispatch/prefix_generation_test.rb
  81. +0 −7 actionpack/test/dispatch/request/multipart_params_parsing_test.rb
  82. +3 −8 actionpack/test/dispatch/response_test.rb
  83. +0 −12 actionpack/test/dispatch/session/cookie_store_test.rb
  84. +0 −14 actionpack/test/dispatch/show_exceptions_test.rb
  85. +27 −20 actionpack/test/dispatch/static_test.rb
  86. +58 −0 actionpack/test/dispatch/uploaded_file_test.rb
  87. +1 −0 actionpack/test/fixtures/layout_tests/alt/hello.erb
  88. +0 −1 actionpack/test/fixtures/layout_tests/alt/hello.rhtml
  89. 0 actionpack/test/fixtures/layout_tests/alt/layouts/{alt.rhtml → alt.erb}
  90. +1 −0 actionpack/test/fixtures/layout_tests/layouts/controller_name_space/nested.erb
  91. +0 −1 actionpack/test/fixtures/layout_tests/layouts/controller_name_space/nested.rhtml
  92. +1 −0 actionpack/test/fixtures/layout_tests/layouts/item.erb
  93. +0 −1 actionpack/test/fixtures/layout_tests/layouts/item.rhtml
  94. +1 −0 actionpack/test/fixtures/layout_tests/layouts/layout_test.erb
  95. +0 −1 actionpack/test/fixtures/layout_tests/layouts/layout_test.rhtml
  96. +1 −0 actionpack/test/fixtures/layout_tests/views/goodbye.erb
  97. +0 −1 actionpack/test/fixtures/layout_tests/views/goodbye.rhtml
  98. +1 −0 actionpack/test/fixtures/layout_tests/views/hello.erb
  99. +0 −1 actionpack/test/fixtures/layout_tests/views/hello.rhtml
  100. 0 ...est/fixtures/old_content_type/{render_default_for_rxml.rxml → render_default_for_builder.builder}
  101. 0 ...pack/test/fixtures/old_content_type/{render_default_for_rhtml.rhtml → render_default_for_erb.erb}
  102. +1 −0 actionpack/test/fixtures/test/_object_inspector.erb
  103. +1 −1 actionpack/test/fixtures/test/proper_block_detection.erb
  104. +19 −0 actionpack/test/lib/controller/fake_models.rb
  105. +15 −30 actionpack/test/template/form_helper_test.rb
  106. +68 −2 actionpack/test/template/lookup_context_test.rb
  107. +16 −1 actionpack/test/template/render_test.rb
  108. +105 −13 actionpack/test/template/template_test.rb
  109. +31 −0 actionpack/test/template/test_case_test.rb
  110. +2 −2 actionpack/test/template/translation_helper_test.rb
  111. +1 −19 actionpack/test/template/url_helper_test.rb
  112. +1 −2 activemodel/lib/active_model.rb
  113. +5 −1 activemodel/lib/active_model/naming.rb
  114. +4 −0 activemodel/test/cases/naming_test.rb
  115. +7 −0 activemodel/test/models/track_back.rb
  116. +6 −1 activerecord/RUNNING_UNIT_TESTS
  117. +1 −1 activerecord/examples/performance.rb
  118. +3 −3 activerecord/lib/active_record.rb
  119. +12 −0 activerecord/lib/active_record/associations/association_collection.rb
  120. +1 −1 activerecord/lib/active_record/associations/belongs_to_polymorphic_association.rb
  121. +26 −10 activerecord/lib/active_record/base.rb
  122. +0 −10 activerecord/lib/active_record/callbacks.rb
  123. +6 −10 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
  124. +4 −4 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  125. +41 −28 activerecord/lib/active_record/migration.rb
  126. +1 −1 activerecord/lib/active_record/railtie.rb
  127. +27 −25 activerecord/lib/active_record/railties/databases.rake
  128. +14 −11 activerecord/lib/active_record/relation/calculations.rb
  129. +5 −11 activerecord/lib/active_record/relation/predicate_builder.rb
  130. +3 −3 activerecord/lib/active_record/relation/query_methods.rb
  131. +7 −5 activerecord/lib/active_record/schema_dumper.rb
  132. +1 −1 activerecord/lib/active_record/serialization.rb
  133. +5 −2 activerecord/lib/active_record/session_store.rb
  134. +6 −0 activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb
  135. +6 −0 activerecord/test/cases/associations/has_many_associations_test.rb
  136. +14 −0 activerecord/test/cases/associations/has_many_through_associations_test.rb
  137. +11 −1 activerecord/test/cases/calculations_test.rb
  138. +29 −0 activerecord/test/cases/connection_pool_test.rb
  139. +14 −0 activerecord/test/cases/inheritance_test.rb
  140. +42 −22 activerecord/test/cases/migration_test.rb
  141. +7 −0 activerecord/test/migrations/to_copy2/1_create_articles.rb
  142. +7 −0 activerecord/test/migrations/to_copy2/2_create_comments.rb
  143. +7 −0 activerecord/test/migrations/to_copy_with_timestamps2/20090101010101_create_articles.rb
  144. +7 −0 activerecord/test/migrations/to_copy_with_timestamps2/20090101010202_create_comments.rb
  145. +1 −0 activeresource/lib/active_resource.rb
  146. +37 −19 activeresource/lib/active_resource/http_mock.rb
  147. +1 −1 activeresource/lib/active_resource/validations.rb
  148. +1 −1 activeresource/test/cases/format_test.rb
  149. +32 −4 activeresource/test/cases/http_mock_test.rb
  150. +1 −0 activesupport/lib/active_support.rb
  151. +2 −2 activesupport/lib/active_support/cache/mem_cache_store.rb
  152. +3 −3 activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb
  153. +1 −4 activesupport/lib/active_support/core_ext/enumerable.rb
  154. +11 −38 activesupport/lib/active_support/core_ext/logger.rb
  155. +2 −2 activesupport/lib/active_support/core_ext/time/conversions.rb
  156. +2 −0 activesupport/lib/active_support/hash_with_indifferent_access.rb
  157. +1 −2 activesupport/lib/active_support/test_case.rb
  158. +0 −9 activesupport/lib/active_support/testing/default.rb
  159. +1 −1 activesupport/lib/active_support/xml_mini.rb
  160. +10 −0 activesupport/test/core_ext/hash_ext_test.rb
  161. +57 −0 activesupport/test/test_case_test.rb
  162. +0 −7 activesupport/test/test_test.rb
  163. +3 −1 railties/CHANGELOG
  164. +0 −3 railties/guides/source/action_view_overview.textile
  165. +1 −1 railties/guides/source/association_basics.textile
  166. +1 −1 railties/guides/source/command_line.textile
  167. +1 −3 railties/guides/source/debugging_rails_applications.textile
  168. +1 −1 railties/guides/source/generators.textile
  169. +2 −2 railties/guides/source/getting_started.textile
  170. +4 −0 railties/guides/source/index.html.erb
  171. +1 −1 railties/guides/source/initialization.textile
  172. +1 −0 railties/guides/source/layout.html.erb
  173. +8 −8 railties/guides/source/layouts_and_rendering.textile
  174. +1 −1 railties/guides/source/routing.textile
  175. +77 −0 railties/guides/source/ruby_on_rails_guides_guidelines.textile
  176. +1 −1 railties/lib/rails.rb
  177. +12 −16 railties/lib/rails/application.rb
  178. +1 −1 railties/lib/rails/application/bootstrap.rb
  179. +10 −9 railties/lib/rails/application/configuration.rb
  180. +1 −1 railties/lib/rails/application/finisher.rb
  181. +45 −0 railties/lib/rails/application/routes_reloader.rb
  182. +18 −1 railties/lib/rails/commands.rb
  183. +1 −1 railties/lib/rails/commands/plugin.rb
  184. +137 −80 railties/lib/rails/engine.rb
  185. +46 −25 railties/lib/rails/engine/configuration.rb
  186. +1 −1 railties/lib/rails/engine/railties.rb
  187. +2 −2 railties/lib/rails/generators/actions.rb
  188. +11 −14 railties/lib/rails/generators/rails/app/app_generator.rb
  189. +3 −0 railties/lib/rails/generators/rails/app/templates/Gemfile
  190. +1 −1 railties/lib/rails/generators/rails/app/templates/app/views/layouts/application.html.erb.tt
  191. +1 −1 railties/lib/rails/generators/rails/app/templates/config/databases/oracle.yml
  192. +104 −50 railties/lib/rails/paths.rb
  193. +3 −3 railties/lib/rails/plugin.rb
  194. +8 −1 railties/lib/rails/railtie.rb
  195. +13 −20 railties/lib/rails/railtie/configuration.rb
  196. +1 −1 railties/lib/rails/tasks/documentation.rake
  197. +2 −2 railties/lib/rails/tasks/railties.rake
  198. +1 −1 railties/lib/rails/test_unit/railtie.rb
  199. +6 −1 railties/lib/rails/test_unit/testing.rake
  200. +1 −1 railties/railties.gemspec
  201. +2 −2 railties/test/application/configuration_test.rb
  202. +2 −3 railties/test/application/console_test.rb
  203. +1 −1 railties/test/application/generators_test.rb
  204. +26 −0 railties/test/application/middleware/best_practices_test.rb
  205. +0 −12 railties/test/application/middleware/cache_test.rb
  206. +63 −0 railties/test/application/middleware/remote_ip_test.rb
  207. +56 −0 railties/test/application/middleware/sendfile_test.rb
  208. +34 −103 railties/test/application/middleware_test.rb
  209. +14 −14 railties/test/application/paths_test.rb
  210. +14 −47 railties/test/application/routing_test.rb
  211. +5 −1 railties/test/generators/app_generator_test.rb
  212. +1 −1 railties/test/generators/generated_attribute_test.rb
  213. +9 −0 railties/test/generators/mailer_generator_test.rb
  214. +2 −2 railties/test/generators/namespaced_generators_test.rb
  215. +27 −0 railties/test/isolation/abstract_unit.rb
  216. +149 −119 railties/test/paths_test.rb
  217. +123 −24 railties/test/railties/engine_test.rb
  218. +1 −1 railties/test/railties/mounted_engine_test.rb
  219. +1 −1 railties/test/railties/plugin_test.rb
  220. +24 −0 railties/test/railties/railtie_test.rb
  221. +17 −10 railties/test/railties/shared_tests.rb
View
@@ -6,6 +6,7 @@ else
gem "arel", :git => "git://github.com/rails/arel.git"
end
+gem "rack", :git => "git://github.com/rack/rack.git"
gem "rails", :path => File.dirname(__FILE__)
gem "rake", ">= 0.8.7"
@@ -54,6 +55,11 @@ platforms :jruby do
gem "activerecord-jdbcsqlite3-adapter"
+ # This is needed by now to let tests work on JRuby
+ # TODO: When the JRuby guys merge jruby-openssl in
+ # jruby this will be removed
+ gem "jruby-openssl"
+
group :db do
gem "activerecord-jdbcmysql-adapter"
gem "activerecord-jdbcpostgresql-adapter"
@@ -26,6 +26,7 @@
require 'abstract_controller'
require 'action_view'
+require 'action_mailer/version'
# Common Active Support usage in Action Mailer
require 'active_support/core_ext/class'
@@ -409,7 +409,7 @@ def respond_to?(method, *args) #:nodoc:
protected
def set_payload_for_mail(payload, mail) #:nodoc:
- payload[:mailer] = self.name
+ payload[:mailer] = name
payload[:message_id] = mail.message_id
payload[:subject] = mail.subject
payload[:to] = mail.to
@@ -421,11 +421,8 @@ def set_payload_for_mail(payload, mail) #:nodoc:
end
def method_missing(method, *args) #:nodoc:
- if action_methods.include?(method.to_s)
- new(method, *args).message
- else
- super
- end
+ return super unless respond_to?(method)
+ new(method, *args).message
end
end
@@ -247,8 +247,8 @@ def parse_content_type(defaults=nil)
[ nil, {} ]
else
ctype, *attrs = @content_type.split(/;\s*/)
- attrs = attrs.inject({}) { |h,s| k,v = s.split(/\=/, 2); h[k] = v; h }
- [ctype, {"charset" => @charset}.merge(attrs)]
+ attrs = Hash[attrs.map { |attr| attr.split(/\=/, 2) }]
+ [ctype, {"charset" => @charset}.merge!(attrs)]
end
end
end
@@ -14,9 +14,9 @@ class Railtie < Rails::Railtie
paths = app.config.paths
options = app.config.action_mailer
- options.assets_dir ||= paths.public.to_a.first
- options.javascripts_dir ||= paths.public.javascripts.to_a.first
- options.stylesheets_dir ||= paths.public.stylesheets.to_a.first
+ options.assets_dir ||= paths["public"].first
+ options.javascripts_dir ||= paths["public/javascripts"].first
+ options.stylesheets_dir ||= paths["public/stylesheets"].first
# make sure readers methods get compiled
options.asset_path ||= nil
@@ -6,7 +6,7 @@ class <%= class_name %> < ActionMailer::Base
# Subject can be set in your I18n file at config/locales/en.yml
# with the following lookup:
#
- # en.<%= file_name %>.<%= action %>.subject
+ # en.<%= file_path.gsub("/",".") %>.<%= action %>.subject
#
def <%= action %>
@greeting = "Hi"
@@ -328,22 +328,19 @@ def new_mail( charset="UTF-8" )
mail
end
- # Replacing logger work around for mocha bug. Should be fixed in mocha 0.3.3
def setup
set_delivery_method :test
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.raise_delivery_errors = true
ActionMailer::Base.deliveries.clear
ActiveSupport::Deprecation.silenced = true
- @original_logger = TestMailer.logger
@recipient = 'test@localhost'
TestMailer.delivery_method = :test
end
def teardown
- TestMailer.logger = @original_logger
ActiveSupport::Deprecation.silenced = false
restore_delivery_method
end
@@ -1097,4 +1094,4 @@ def test_starttls_is_not_enabled
ensure
TestMailer.smtp_settings.merge!(:enable_starttls_auto => true)
end
-end
+end
View
@@ -1,12 +1,20 @@
*Rails 3.1.0 (unreleased)*
+* Added render :once. You can pass either a string or an array of strings and Rails will ensure they each of them are rendered just once. [José Valim]
+
+* Deprecate old template handler API. The new API simply requires a template handler to respond to call. [José Valim]
+
+* :rhtml and :rxml were finally removed as template handlers. [José Valim]
+
+* Moved etag responsibility from ActionDispatch::Response to the middleware stack. [José Valim]
+
+* Rely on Rack::Session stores API for more compatibility across the Ruby world. This is backwards incompatible since Rack::Session expects #get_session to accept 4 arguments and requires #destroy_session instead of simply #destroy. [José Valim]
+
* file_field automatically adds :multipart => true to the enclosing form. [Santiago Pastorino]
* Renames csrf_meta_tag -> csrf_meta_tags, and aliases csrf_meta_tag for backwards compatibility. [fxn]
-* Add Rack::Cache to the default stack. Create a Rails store that delegates to the Rails cache, so by default, whatever caching layer you are using will be used
- for HTTP caching. Note that Rack::Cache will be used if you use #expires_in, #fresh_when or #stale with :public => true. Otherwise, the caching rules will apply
- to the browser only.
+* Add Rack::Cache to the default stack. Create a Rails store that delegates to the Rails cache, so by default, whatever caching layer you are using will be used for HTTP caching. Note that Rack::Cache will be used if you use #expires_in, #fresh_when or #stale with :public => true. Otherwise, the caching rules will apply to the browser only. [Yehuda Katz, Carl Lerche]
*Rails 3.0.0 (August 29, 2010)*
@@ -8,15 +8,18 @@ Rake can be found at http://rake.rubyforge.org
== Running by hand
-If you only want to run a single test suite, or don't want to bother with Rake,
-you can do so with something like:
+To run a single test suite
- ruby -Itest test/controller/base_tests.rb
+ rake test TEST=path/to/test.rb
-== Dependency on ActiveRecord and database setup
+which can be further narrowed down to one test:
+
+ rake test TEST=path/to/test.rb TESTOPTS="--name=test_something"
+
+== Dependency on Active Record and database setup
Test cases in the test/controller/active_record/ directory depend on having
-activerecord and sqlite installed. If ActiveRecord is not in
+activerecord and sqlite installed. If Active Record is not in
actionpack/../activerecord directory, or the sqlite rubygem is not installed,
these tests are skipped.
@@ -13,6 +13,7 @@ class ActionNotFound < StandardError; end
class Base
attr_internal :response_body
attr_internal :action_name
+ attr_internal :formats
include ActiveSupport::Configurable
extend ActiveSupport::DescendantsTracker
@@ -61,13 +62,13 @@ def hidden_actions
def action_methods
@action_methods ||= begin
# All public instance methods of this class, including ancestors
- methods = public_instance_methods(true).map { |m| m.to_s }.to_set -
+ methods = (public_instance_methods(true) -
# Except for public instance methods of Base and its ancestors
- internal_methods.map { |m| m.to_s } +
+ internal_methods +
# Be sure to include shadowed public instance methods of this class
- public_instance_methods(false).map { |m| m.to_s } -
+ public_instance_methods(false)).uniq.map { |x| x.to_s } -
# And always exclude explicitly hidden actions
- hidden_actions
+ hidden_actions.to_a
# Clear out AS callback method pollution
methods.reject { |method| method =~ /_one_time_conditions/ }
@@ -12,7 +12,6 @@ def initialize(message = nil)
# This is a class to fix I18n global state. Whenever you provide I18n.locale during a request,
# it will trigger the lookup_context and consequently expire the cache.
- # TODO Add some deprecation warnings to remove I18n.locale from controllers
class I18nProxy < ::I18n::Config #:nodoc:
attr_reader :i18n_config, :lookup_context
@@ -50,7 +49,7 @@ def view_context_class
if controller.respond_to?(:_helpers)
include controller._helpers
- if controller.respond_to?(:_routes)
+ if controller.respond_to?(:_routes) && controller._routes
include controller._routes.url_helpers
include controller._routes.mounted_helpers
end
@@ -156,7 +155,7 @@ def _normalize_options(options)
options[:partial] = action_name
end
- if (options.keys & [:partial, :file, :template]).empty?
+ if (options.keys & [:partial, :file, :template, :once]).empty?
options[:prefix] ||= _prefix
end
@@ -119,6 +119,11 @@ def location=(url)
headers["Location"] = url
end
+ # basic url_for that can be overridden for more robust functionality
+ def url_for(string)
+ string
+ end
+
def status
@_status
end
@@ -66,7 +66,7 @@ def stale?(options)
# Examples:
# expires_in 20.minutes
# expires_in 3.hours, :public => true
- # expires in 3.hours, 'max-stale' => 5.hours, :public => true
+ # expires_in 3.hours, 'max-stale' => 5.hours, :public => true
#
# This method will overwrite an existing Cache-Control header.
# See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html for more possibilities.
@@ -2,8 +2,6 @@ module ActionController
module Head
extend ActiveSupport::Concern
- include ActionController::UrlFor
-
# Return a response that has no content (merely headers). The options
# argument is interpreted to be a hash of header names and values.
# This allows you to easily return a response that consists only of
@@ -27,8 +25,8 @@ def head(status, options = {})
self.status = status
self.location = url_for(location) if location
- self.content_type = Mime[formats.first]
+ self.content_type = Mime[formats.first] if formats
self.response_body = " "
end
end
-end
+end
@@ -214,7 +214,7 @@ def ha1(credentials, password)
def encode_credentials(http_method, credentials, password, password_is_ha1)
credentials[:response] = expected_response(http_method, credentials[:uri], credentials, password, password_is_ha1)
- "Digest " + credentials.sort_by {|x| x[0].to_s }.inject([]) {|a, v| a << "#{v[0]}='#{v[1]}'" }.join(', ')
+ "Digest " + credentials.sort_by {|x| x[0].to_s }.map {|v| "#{v[0]}='#{v[1]}'" }.join(', ')
end
def decode_credentials_header(request)
@@ -423,14 +423,13 @@ def authenticate(controller, &login_procedure)
# Returns nil if no token is found.
def token_and_options(request)
if header = request.authorization.to_s[/^Token (.*)/]
- values = $1.split(',').
- inject({}) do |memo, value|
- value.strip! # remove any spaces between commas and values
- key, value = value.split(/\=\"?/) # split key=value pairs
- value.chomp!('"') # chomp trailing " in value
- value.gsub!(/\\\"/, '"') # unescape remaining quotes
- memo.update(key => value)
- end
+ values = Hash[$1.split(',').map do |value|
+ value.strip! # remove any spaces between commas and values
+ key, value = value.split(/\=\"?/) # split key=value pairs
+ value.chomp!('"') # chomp trailing " in value
+ value.gsub!(/\\\"/, '"') # unescape remaining quotes
+ [key, value]
+ end]
[values.delete("token"), values.with_indifferent_access]
end
end
@@ -442,9 +441,8 @@ def token_and_options(request)
#
# Returns String.
def encode_credentials(token, options = {})
- values = ["token=#{token.to_s.inspect}"]
- options.each do |key, value|
- values << "#{key}=#{value.to_s.inspect}"
+ values = ["token=#{token.to_s.inspect}"] + options.map do |key, value|
+ "#{key}=#{value.to_s.inspect}"
end
"Token #{values * ", "}"
end
@@ -2,7 +2,6 @@ module ActionController
module Rendering
extend ActiveSupport::Concern
- include ActionController::RackDelegation
include AbstractController::Rendering
# Before processing, set the request formats in current controller formats.
@@ -101,10 +101,6 @@ def send_file(path, options = {}) #:doc:
# send_data image.data, :type => image.content_type, :disposition => 'inline'
#
# See +send_file+ for more information on HTTP Content-* headers and caching.
- #
- # <b>Tip:</b> if you want to stream large amounts of on-the-fly generated
- # data to the browser, then use <tt>render :text => proc { ... }</tt>
- # instead. See ActionController::Base#render for more information.
def send_data(data, options = {}) #:doc:
send_file_headers! options.dup
render options.slice(:status, :content_type).merge(:text => data)
@@ -21,10 +21,10 @@ class Railtie < Rails::Railtie
paths = app.config.paths
options = app.config.action_controller
- options.assets_dir ||= paths.public.to_a.first
- options.javascripts_dir ||= paths.public.javascripts.to_a.first
- options.stylesheets_dir ||= paths.public.stylesheets.to_a.first
- options.page_cache_directory ||= paths.public.to_a.first
+ options.assets_dir ||= paths["public"].first
+ options.javascripts_dir ||= paths["public/javascripts"].first
+ options.stylesheets_dir ||= paths["public/stylesheets"].first
+ options.page_cache_directory ||= paths["public"].first
# make sure readers methods get compiled
options.asset_path ||= nil
@@ -5,12 +5,14 @@ def self.with(app)
Module.new do
define_method(:inherited) do |klass|
super(klass)
+
if namespace = klass.parents.detect {|m| m.respond_to?(:_railtie) }
- klass.helpers_path = namespace._railtie.config.paths.app.helpers.to_a
+ paths = namespace._railtie.paths["app/helpers"].existent
else
- klass.helpers_path = app.config.helpers_paths
+ paths = app.config.helpers_paths
end
+ klass.helpers_path = paths
klass.helper :all if klass.superclass == ActionController::Base
end
end
@@ -187,15 +187,18 @@ def recycle!
end
end
- class TestSession < ActionDispatch::Session::AbstractStore::SessionHash #:nodoc:
- DEFAULT_OPTIONS = ActionDispatch::Session::AbstractStore::DEFAULT_OPTIONS
+ class TestSession < Rack::Session::Abstract::SessionHash #:nodoc:
+ DEFAULT_OPTIONS = Rack::Session::Abstract::ID::DEFAULT_OPTIONS
def initialize(session = {})
+ @env, @by = nil, nil
replace(session.stringify_keys)
@loaded = true
end
- def exists?; true; end
+ def exists?
+ true
+ end
end
# Superclass for ActionController functional tests. Functional tests allow you to
@@ -394,7 +397,7 @@ def process(action, parameters = nil, session = nil, flash = nil, http_method =
parameters ||= {}
@request.assign_parameters(@routes, @controller.class.name.underscore.sub(/_controller$/, ''), action.to_s, parameters)
- @request.session = ActionController::TestSession.new(session) unless session.nil?
+ @request.session = ActionController::TestSession.new(session) if session
@request.session["flash"] = @request.flash.update(flash || {})
@request.session["flash"].sweep
Oops, something went wrong.

0 comments on commit 62eb00a

Please sign in to comment.