Permalink
Browse files

Merge remote branch 'rails/master'

  • Loading branch information...
2 parents c37f7d6 + ebee77a commit 4329f8133fee8e4f3e558787f67de59f0c4a4dd1 @fxn fxn committed Jun 27, 2010
Showing with 3,105 additions and 2,206 deletions.
  1. +1 −0 Gemfile
  2. +1 −0 actionmailer/lib/action_mailer/base.rb
  3. +22 −0 actionmailer/lib/action_mailer/log_subscriber.rb
  4. +0 −3 actionmailer/lib/action_mailer/railtie.rb
  5. +0 −22 actionmailer/lib/action_mailer/railties/log_subscriber.rb
  6. +4 −4 actionmailer/test/log_subscriber_test.rb
  7. +3 −3 actionmailer/test/old_base/mail_service_test.rb
  8. +8 −0 actionpack/CHANGELOG
  9. +1 −1 actionpack/actionpack.gemspec
  10. +2 −0 actionpack/lib/action_controller/base.rb
  11. +56 −0 actionpack/lib/action_controller/log_subscriber.rb
  12. +1 −1 actionpack/lib/action_controller/metal.rb
  13. +13 −5 actionpack/lib/action_controller/metal/responder.rb
  14. +0 −3 actionpack/lib/action_controller/railtie.rb
  15. +0 −56 actionpack/lib/action_controller/railties/log_subscriber.rb
  16. +15 −3 actionpack/lib/action_controller/test_case.rb
  17. +4 −1 actionpack/lib/action_dispatch/http/request.rb
  18. +9 −2 actionpack/lib/action_dispatch/middleware/flash.rb
  19. +113 −36 actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
  20. +25 −18 actionpack/lib/action_dispatch/middleware/session/cookie_store.rb
  21. +9 −0 actionpack/lib/action_dispatch/middleware/session/mem_cache_store.rb
  22. +50 −33 actionpack/lib/action_dispatch/routing/mapper.rb
  23. +27 −4 actionpack/lib/action_dispatch/routing/route_set.rb
  24. +0 −1 actionpack/lib/action_dispatch/testing/assertions/routing.rb
  25. +19 −23 actionpack/lib/action_dispatch/testing/assertions/selector.rb
  26. +6 −1 actionpack/lib/action_view/base.rb
  27. +16 −2 actionpack/lib/action_view/helpers/active_model_helper.rb
  28. +14 −33 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  29. +2 −2 actionpack/lib/action_view/helpers/date_helper.rb
  30. +14 −15 actionpack/lib/action_view/helpers/form_helper.rb
  31. +6 −8 actionpack/lib/action_view/helpers/prototype_helper.rb
  32. +2 −4 actionpack/lib/action_view/helpers/scriptaculous_helper.rb
  33. +27 −0 actionpack/lib/action_view/log_subscriber.rb
  34. +14 −3 actionpack/lib/action_view/railtie.rb
  35. +0 −27 actionpack/lib/action_view/railties/log_subscriber.rb
  36. +1 −1 actionpack/lib/action_view/template/resolver.rb
  37. +33 −13 actionpack/lib/action_view/test_case.rb
  38. +12 −2 actionpack/test/abstract/callbacks_test.rb
  39. +15 −0 actionpack/test/abstract_unit.rb
  40. +45 −2 actionpack/test/activerecord/active_record_store_test.rb
  41. +5 −5 actionpack/test/activerecord/controller_runtime_test.rb
  42. +17 −3 actionpack/test/controller/flash_test.rb
  43. +5 −5 actionpack/test/controller/log_subscriber_test.rb
  44. +38 −0 actionpack/test/controller/new_base/base_test.rb
  45. +9 −3 actionpack/test/controller/url_for_test.rb
  46. +185 −4 actionpack/test/dispatch/routing_test.rb
  47. +39 −4 actionpack/test/dispatch/session/cookie_store_test.rb
  48. +65 −2 actionpack/test/dispatch/session/mem_cache_store_test.rb
  49. +10 −0 actionpack/test/fixtures/session_autoload_test/session_autoload_test/foo.rb
  50. +7 −0 actionpack/test/template/active_model_helper_test.rb
  51. +7 −15 actionpack/test/template/asset_tag_helper_test.rb
  52. +15 −0 actionpack/test/template/form_helper_test.rb
  53. +5 −5 actionpack/test/template/log_subscriber_test.rb
  54. +36 −9 actionpack/test/template/test_case_test.rb
  55. +22 −0 actionpack/test/template/url_helper_test.rb
  56. +1 −1 activemodel/lib/active_model/deprecated_error_methods.rb
  57. +50 −24 activemodel/lib/active_model/errors.rb
  58. +0 −1 activemodel/lib/active_model/observing.rb
  59. +2 −2 activemodel/lib/active_model/validations/acceptance.rb
  60. +3 −3 activemodel/lib/active_model/validations/confirmation.rb
  61. +3 −2 activemodel/lib/active_model/validations/exclusion.rb
  62. +3 −3 activemodel/lib/active_model/validations/format.rb
  63. +3 −2 activemodel/lib/active_model/validations/inclusion.rb
  64. +6 −2 activemodel/lib/active_model/validations/length.rb
  65. +9 −4 activemodel/lib/active_model/validations/numericality.rb
  66. +1 −1 activemodel/lib/active_model/validations/presence.rb
  67. +0 −3 activemodel/lib/active_model/validations/with.rb
  68. +1 −0 activemodel/test/cases/helper.rb
  69. +2 −1 activemodel/test/cases/validations/callbacks_test.rb
  70. +41 −41 activemodel/test/cases/validations/i18n_generate_message_validation_test.rb
  71. +169 −338 activemodel/test/cases/validations/i18n_validation_test.rb
  72. +1 −1 activemodel/test/cases/validations/presence_validation_test.rb
  73. +33 −9 activemodel/test/cases/validations_test.rb
  74. +254 −254 activerecord/CHANGELOG
  75. +4 −1 activerecord/Rakefile
  76. +3 −3 activerecord/examples/performance.rb
  77. +2 −4 activerecord/lib/active_record/aggregations.rb
  78. +7 −7 activerecord/lib/active_record/associations/association_collection.rb
  79. +2 −2 activerecord/lib/active_record/autosave_association.rb
  80. +4 −10 activerecord/lib/active_record/base.rb
  81. +3 −1 activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
  82. +10 −0 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
  83. +48 −4 activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
  84. +4 −3 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
  85. +1 −1 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
  86. +12 −15 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  87. +7 −3 activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
  88. +5 −15 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
  89. +32 −0 activerecord/lib/active_record/log_subscriber.rb
  90. +11 −8 activerecord/lib/active_record/nested_attributes.rb
  91. +0 −3 activerecord/lib/active_record/railtie.rb
  92. +0 −32 activerecord/lib/active_record/railties/log_subscriber.rb
  93. +10 −1 activerecord/lib/active_record/relation.rb
  94. +4 −4 activerecord/lib/active_record/relation/finder_methods.rb
  95. +1 −1 activerecord/lib/active_record/relation/predicate_builder.rb
  96. +97 −72 activerecord/lib/active_record/relation/query_methods.rb
  97. +8 −0 activerecord/lib/active_record/session_store.rb
  98. +1 −1 activerecord/lib/active_record/validations/associated.rb
  99. +1 −1 activerecord/lib/active_record/validations/uniqueness.rb
  100. +8 −6 activerecord/lib/rails/generators/active_record/migration/templates/migration.rb
  101. +1 −1 activerecord/lib/rails/generators/active_record/model/model_generator.rb
  102. 0 activerecord/test/cases/{connection_test_firebird.rb → adapters/firebird/connection_test.rb}
  103. 0 activerecord/test/cases/{default_test_firebird.rb → adapters/firebird/default_test.rb}
  104. 0 activerecord/test/cases/{migration_test_firebird.rb → adapters/firebird/migration_test.rb}
  105. +3 −3 activerecord/test/cases/{active_schema_test_mysql.rb → adapters/mysql/active_schema_test.rb}
  106. 0 activerecord/test/cases/{connection_test_mysql.rb → adapters/mysql/connection_test.rb}
  107. 0 activerecord/test/cases/{reserved_word_test_mysql.rb → adapters/mysql/reserved_word_test.rb}
  108. 0 activerecord/test/cases/{synonym_test_oracle.rb → adapters/oracle/synonym_test.rb}
  109. +4 −1 ...erecord/test/cases/{active_schema_test_postgresql.rb → adapters/postgresql/active_schema_test.rb}
  110. +1 −1 activerecord/test/cases/{datatype_test_postgresql.rb → adapters/postgresql/datatype_test.rb}
  111. +1 −1 ...ases/{schema_authorization_test_postgresql.rb → adapters/postgresql/schema_authorization_test.rb}
  112. +4 −0 activerecord/test/cases/{schema_test_postgresql.rb → adapters/postgresql/schema_test.rb}
  113. 0 activerecord/test/cases/{copy_table_test_sqlite.rb → adapters/sqlite/copy_table_test.rb}
  114. +56 −0 activerecord/test/cases/adapters/sqlite/sqlite3_adapter_test.rb
  115. +0 −28 activerecord/test/cases/aggregations_test.rb
  116. +2 −2 activerecord/test/cases/associations/cascaded_eager_loading_test.rb
  117. +9 −1 activerecord/test/cases/base_test.rb
  118. +1 −1 activerecord/test/cases/calculations_test.rb
  119. +4 −5 activerecord/test/cases/log_subscriber_test.rb
  120. +5 −3 activerecord/test/cases/method_scoping_test.rb
  121. +108 −4 activerecord/test/cases/migration_test.rb
  122. +15 −13 activerecord/test/cases/nested_attributes_test.rb
  123. +5 −5 activerecord/test/cases/reflection_test.rb
  124. +52 −4 activerecord/test/cases/relations_test.rb
  125. +6 −6 activerecord/test/cases/validations/i18n_generate_message_validation_test.rb
  126. +28 −22 activerecord/test/cases/validations/i18n_validation_test.rb
  127. +1 −1 activerecord/test/fixtures/topics.yml
  128. +1 −0 activerecord/test/schema/schema.rb
  129. +1 −0 activeresource/lib/active_resource/base.rb
  130. +14 −2 activeresource/lib/active_resource/http_mock.rb
  131. +15 −0 activeresource/lib/active_resource/log_subscriber.rb
  132. +0 −3 activeresource/lib/active_resource/railtie.rb
  133. +0 −15 activeresource/lib/active_resource/railties/log_subscriber.rb
  134. +1 −1 activeresource/lib/active_resource/validations.rb
  135. +12 −1 activeresource/test/cases/base_errors_test.rb
  136. +71 −0 activeresource/test/cases/http_mock_test.rb
  137. +4 −5 activeresource/test/cases/log_subscriber_test.rb
  138. +2 −0 activesupport/CHANGELOG
  139. +2 −1 activesupport/lib/active_support.rb
  140. +1 −0 activesupport/lib/active_support/all.rb
  141. +40 −25 activesupport/lib/active_support/cache.rb
  142. +2 −2 activesupport/lib/active_support/cache/mem_cache_store.rb
  143. +1 −0 activesupport/lib/active_support/core_ext/class.rb
  144. +1 −1 activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb
  145. +0 −38 activesupport/lib/active_support/core_ext/logger.rb
  146. +4 −11 activesupport/lib/active_support/core_ext/string/conversions.rb
  147. +11 −0 activesupport/lib/active_support/core_ext/string/inflections.rb
  148. +27 −18 activesupport/lib/active_support/dependencies.rb
  149. +2 −2 activesupport/lib/active_support/file_update_checker.rb
  150. +14 −5 activesupport/lib/active_support/json/encoding.rb
  151. +43 −40 {railties/lib/rails → activesupport/lib/active_support}/log_subscriber.rb
  152. +9 −16 {railties/lib/rails → activesupport/lib/active_support}/log_subscriber/test_helper.rb
  153. +39 −40 activesupport/lib/active_support/multibyte/chars.rb
  154. +6 −0 activesupport/lib/active_support/ordered_hash.rb
  155. +11 −8 activesupport/lib/active_support/testing/isolation.rb
  156. +146 −148 activesupport/lib/active_support/values/time_zone.rb
  157. +3 −1 activesupport/test/abstract_unit.rb
  158. +8 −0 activesupport/test/core_ext/string_ext_test.rb
  159. +18 −18 activesupport/test/dependencies_test.rb
  160. +1 −1 activesupport/test/descendants_tracker_test.rb
  161. +17 −17 {railties → activesupport}/test/log_subscriber_test.rb
  162. +19 −0 activesupport/test/ordered_hash_test.rb
  163. +3 −0 railties/CHANGELOG
  164. +2 −2 railties/Rakefile
  165. +1 −1 railties/guides/source/initialization.textile
  166. +0 −1 railties/lib/rails.rb
  167. +3 −2 railties/lib/rails/application.rb
  168. +1 −1 railties/lib/rails/application/configuration.rb
  169. +6 −6 railties/lib/rails/application/finisher.rb
  170. +1 −0 railties/lib/rails/commands/runner.rb
  171. +1 −1 railties/lib/rails/commands/server.rb
  172. +0 −2 railties/lib/rails/console/app.rb
  173. +8 −8 railties/lib/rails/engine.rb
  174. +5 −5 railties/lib/rails/engine/configuration.rb
  175. +1 −2 railties/lib/rails/generators.rb
  176. +1 −1 railties/lib/rails/generators/base.rb
  177. +1 −6 railties/lib/rails/generators/erb/scaffold/scaffold_generator.rb
  178. +4 −4 railties/lib/rails/generators/erb/scaffold/templates/_form.html.erb
  179. +2 −2 railties/lib/rails/generators/erb/scaffold/templates/edit.html.erb
  180. +7 −7 railties/lib/rails/generators/erb/scaffold/templates/index.html.erb
  181. +1 −1 railties/lib/rails/generators/erb/scaffold/templates/new.html.erb
  182. +2 −2 railties/lib/rails/generators/erb/scaffold/templates/show.html.erb
  183. +17 −1 railties/lib/rails/generators/named_base.rb
  184. +4 −3 railties/lib/rails/generators/rails/app/templates/Gemfile
  185. +1 −1 railties/lib/rails/generators/rails/app/templates/config/application.rb
  186. +1 −1 railties/lib/rails/generators/rails/model/USAGE
  187. +4 −14 railties/lib/rails/generators/rails/resource/resource_generator.rb
  188. +0 −2 railties/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb
  189. +27 −29 railties/lib/rails/generators/rails/scaffold_controller/templates/controller.rb
  190. +1 −1 railties/lib/rails/generators/resource_helpers.rb
  191. +1 −1 railties/lib/rails/generators/test_unit/model/model_generator.rb
  192. +0 −1 railties/lib/rails/generators/test_unit/scaffold/scaffold_generator.rb
  193. +12 −14 railties/lib/rails/generators/test_unit/scaffold/templates/functional_test.rb
  194. +3 −16 railties/lib/rails/initializable.rb
  195. +11 −13 railties/lib/rails/rack/logger.rb
  196. +2 −32 railties/lib/rails/railtie.rb
  197. +0 −156 railties/lib/rails/webrick_server.rb
  198. +0 −2 railties/test/abstract_unit.rb
  199. +6 −4 railties/test/application/initializers/frameworks_test.rb
  200. +11 −0 railties/test/application/middleware_test.rb
  201. +49 −0 railties/test/application/runner_test.rb
  202. +3 −3 railties/test/generators/actions_test.rb
  203. +0 −8 railties/test/generators/resource_generator_test.rb
  204. +0 −14 railties/test/generators/scaffold_controller_generator_test.rb
  205. +106 −0 railties/test/generators/scaffold_generator_test.rb
  206. +14 −25 railties/test/initializable_test.rb
  207. +1 −1 railties/test/railties/engine_test.rb
  208. +0 −9 railties/test/railties/railtie_test.rb
  209. +6 −2 tools/profile
  210. +1 −1 version.rb
View
@@ -1,6 +1,7 @@
source 'http://rubygems.org'
gem "arel", :git => "git://github.com/rails/arel.git"
+gem "rack-mount", :git => "git://github.com/rails/rack-mount.git"
gem "rails", :path => File.dirname(__FILE__)
gem "rake", ">= 0.8.7"
@@ -4,6 +4,7 @@
require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/object/blank'
require 'active_support/core_ext/proc'
+require 'action_mailer/log_subscriber'
module ActionMailer #:nodoc:
# Action Mailer allows you to send email from your application using a mailer model and views.
@@ -0,0 +1,22 @@
+require 'active_support/core_ext/array/wrap'
+
+module ActionMailer
+ class LogSubscriber < ActiveSupport::LogSubscriber
+ def deliver(event)
+ recipients = Array.wrap(event.payload[:to]).join(', ')
+ info("\nSent mail to #{recipients} (%1.fms)" % event.duration)
+ debug(event.payload[:mail])
+ end
+
+ def receive(event)
+ info("\nReceived mail (%.1fms)" % event.duration)
+ debug(event.payload[:mail])
+ end
+
+ def logger
+ ActionMailer::Base.logger
+ end
+ end
+end
+
+ActionMailer::LogSubscriber.attach_to :action_mailer
@@ -5,9 +5,6 @@ module ActionMailer
class Railtie < Rails::Railtie
config.action_mailer = ActiveSupport::OrderedOptions.new
- require "action_mailer/railties/log_subscriber"
- log_subscriber :action_mailer, ActionMailer::Railties::LogSubscriber.new
-
initializer "action_mailer.logger" do
ActiveSupport.on_load(:action_mailer) { self.logger ||= Rails.logger }
end
@@ -1,22 +0,0 @@
-require 'active_support/core_ext/array/wrap'
-
-module ActionMailer
- module Railties
- class LogSubscriber < Rails::LogSubscriber
- def deliver(event)
- recipients = Array.wrap(event.payload[:to]).join(', ')
- info("\nSent mail to #{recipients} (%1.fms)" % event.duration)
- debug(event.payload[:mail])
- end
-
- def receive(event)
- info("\nReceived mail (%.1fms)" % event.duration)
- debug(event.payload[:mail])
- end
-
- def logger
- ActionMailer::Base.logger
- end
- end
- end
-end
@@ -1,13 +1,13 @@
require "abstract_unit"
-require "rails/log_subscriber/test_helper"
-require "action_mailer/railties/log_subscriber"
+require "active_support/log_subscriber/test_helper"
+require "action_mailer/log_subscriber"
class AMLogSubscriberTest < ActionMailer::TestCase
- include Rails::LogSubscriber::TestHelper
+ include ActiveSupport::LogSubscriber::TestHelper
def setup
super
- Rails::LogSubscriber.add(:action_mailer, ActionMailer::Railties::LogSubscriber.new)
+ ActionMailer::LogSubscriber.attach_to :action_mailer
end
class TestMailer < ActionMailer::Base
@@ -674,7 +674,7 @@ def test_unquote_quoted_printable_subject
EOF
mail = Mail.new(msg)
assert_equal "testing testing \326\244", mail.subject
- assert_equal "Subject: testing testing =?UTF-8?Q?_=D6=A4=?=\r\n", mail[:subject].encoded
+ assert_equal "Subject: =?UTF-8?Q?testing_testing_=D6=A4?=\r\n", mail[:subject].encoded
end
def test_unquote_7bit_subject
@@ -863,15 +863,15 @@ def test_multipart_with_mime_version
def test_multipart_with_utf8_subject
mail = TestMailer.multipart_with_utf8_subject(@recipient)
- regex = Regexp.escape('Subject: Foo =?UTF-8?Q?=C3=A1=C3=AB=C3=B4=?= =?UTF-8?Q?_=C3=AE=C3=BC=?=')
+ regex = Regexp.escape('Subject: =?UTF-8?Q?Foo_=C3=A1=C3=AB=C3=B4_=C3=AE=C3=BC?=')
assert_match(/#{regex}/, mail.encoded)
string = "Foo áëô îü"
assert_match(string, mail.subject)
end
def test_implicitly_multipart_with_utf8
mail = TestMailer.implicitly_multipart_with_utf8
- regex = Regexp.escape('Subject: Foo =?UTF-8?Q?=C3=A1=C3=AB=C3=B4=?= =?UTF-8?Q?_=C3=AE=C3=BC=?=')
+ regex = Regexp.escape('Subject: =?UTF-8?Q?Foo_=C3=A1=C3=AB=C3=B4_=C3=AE=C3=BC?=')
assert_match(/#{regex}/, mail.encoded)
string = "Foo áëô îü"
assert_match(string, mail.subject)
View
@@ -1,5 +1,13 @@
*Rails 3.0.0 [Release Candidate] (unreleased)*
+* Allow :path to be given to match/get/post/put/delete instead of :path_names in the new router [Carlos Antônio da Silva]
+
+* Added resources_path_names to the new router DSL [José Valim]
+
+* Allow options to be given to the namespace method in the new router [Carlos Antônio da Silva]
+
+* Deprecate :name_prefix in the new router DSL [José Valim]
+
* Add shallow routes back to the new router [Diego Carrion, Andrew White]
resources :posts do
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
s.add_dependency('i18n', '~> 0.4.1')
s.add_dependency('rack', '~> 1.1.0')
s.add_dependency('rack-test', '~> 0.5.4')
- s.add_dependency('rack-mount', '~> 0.6.4')
+ s.add_dependency('rack-mount', '~> 0.6.5')
s.add_dependency('tzinfo', '~> 0.3.16')
s.add_dependency('erubis', '~> 2.6.5')
end
@@ -1,3 +1,5 @@
+require "action_controller/log_subscriber"
+
module ActionController
class Base < Metal
abstract!
@@ -0,0 +1,56 @@
+require 'active_support/core_ext/object/blank'
+
+module ActionController
+ class LogSubscriber < ActiveSupport::LogSubscriber
+ INTERNAL_PARAMS = %w(controller action format _method only_path)
+
+ def start_processing(event)
+ payload = event.payload
+ params = payload[:params].except(*INTERNAL_PARAMS)
+
+ info " Processing by #{payload[:controller]}##{payload[:action]} as #{payload[:formats].first.to_s.upcase}"
+ info " Parameters: #{params.inspect}" unless params.empty?
+ end
+
+ def process_action(event)
+ payload = event.payload
+ additions = ActionController::Base.log_process_action(payload)
+
+ message = "Completed #{payload[:status]} #{Rack::Utils::HTTP_STATUS_CODES[payload[:status]]} in %.0fms" % event.duration
+ message << " (#{additions.join(" | ")})" unless additions.blank?
+
+ info(message)
+ end
+
+ def send_file(event)
+ message = "Sent file %s"
+ message << " (%.1fms)"
+ info(message % [event.payload[:path], event.duration])
+ end
+
+ def redirect_to(event)
+ info "Redirected to #{event.payload[:location]}"
+ end
+
+ def send_data(event)
+ info("Sent data %s (%.1fms)" % [event.payload[:filename], event.duration])
+ end
+
+ %w(write_fragment read_fragment exist_fragment?
+ expire_fragment expire_page write_page).each do |method|
+ class_eval <<-METHOD, __FILE__, __LINE__ + 1
+ def #{method}(event)
+ key_or_path = event.payload[:key] || event.payload[:path]
+ human_name = #{method.to_s.humanize.inspect}
+ info("\#{human_name} \#{key_or_path} (%.1fms)" % event.duration)
+ end
+ METHOD
+ end
+
+ def logger
+ ActionController::Base.logger
+ end
+ end
+end
+
+ActionController::LogSubscriber.attach_to :action_controller
@@ -61,7 +61,7 @@ class Metal < AbstractController::Base
# ==== Returns
# String
def self.controller_name
- @controller_name ||= controller_path.split("/").last
+ @controller_name ||= self.name.demodulize.sub(/Controller$/, '').underscore
end
# Delegates to the class' #controller_name
@@ -89,9 +89,7 @@ class Responder
def initialize(controller, resources, options={})
@controller = controller
- @request = controller.request
- @format = controller.formats.first
- @resource = resources.is_a?(Array) ? resources.last : resources
+ @resource = resources.last
@resources = resources
@options = options
@action = options.delete(:action)
@@ -101,6 +99,14 @@ def initialize(controller, resources, options={})
delegate :head, :render, :redirect_to, :to => :controller
delegate :get?, :post?, :put?, :delete?, :to => :request
+ def request
+ @request ||= @controller.request
+ end
+
+ def format
+ @format ||= @controller.formats.first
+ end
+
# Undefine :to_json and :to_yaml since it's defined on Object
undef_method(:to_json) if method_defined?(:to_json)
undef_method(:to_yaml) if method_defined?(:to_yaml)
@@ -147,7 +153,7 @@ def navigation_behavior(error)
elsif has_errors? && default_action
render :action => default_action
else
- redirect_to resource_location
+ redirect_to navigation_location
end
end
@@ -160,7 +166,7 @@ def api_behavior(error)
elsif has_errors?
display resource.errors, :status => :unprocessable_entity
elsif post?
- display resource, :status => :created, :location => resource_location
+ display resource, :status => :created, :location => api_location
else
head :ok
end
@@ -178,6 +184,8 @@ def resourceful?
def resource_location
options[:location] || resources
end
+ alias :navigation_location :resource_location
+ alias :api_location :resource_location
# If a given response block was given, use it, otherwise call render on
# controller.
@@ -6,7 +6,6 @@
require "active_support/deprecation/proxy_wrappers"
require "active_support/deprecation"
-require "action_controller/railties/log_subscriber"
require "action_controller/railties/url_helpers"
module ActionController
@@ -35,8 +34,6 @@ class Railtie < Rails::Railtie
end
end
- log_subscriber :action_controller, ActionController::Railties::LogSubscriber.new
-
initializer "action_controller.set_configs" do |app|
paths = app.config.paths
ac = app.config.action_controller
@@ -1,56 +0,0 @@
-require 'active_support/core_ext/object/blank'
-
-module ActionController
- module Railties
- class LogSubscriber < Rails::LogSubscriber
- INTERNAL_PARAMS = %w(controller action format _method only_path)
-
- def start_processing(event)
- payload = event.payload
- params = payload[:params].except(*INTERNAL_PARAMS)
-
- info " Processing by #{payload[:controller]}##{payload[:action]} as #{payload[:formats].first.to_s.upcase}"
- info " Parameters: #{params.inspect}" unless params.empty?
- end
-
- def process_action(event)
- payload = event.payload
- additions = ActionController::Base.log_process_action(payload)
-
- message = "Completed #{payload[:status]} #{Rack::Utils::HTTP_STATUS_CODES[payload[:status]]} in %.0fms" % event.duration
- message << " (#{additions.join(" | ")})" unless additions.blank?
-
- info(message)
- end
-
- def send_file(event)
- message = "Sent file %s"
- message << " (%.1fms)"
- info(message % [event.payload[:path], event.duration])
- end
-
- def redirect_to(event)
- info "Redirected to #{event.payload[:location]}"
- end
-
- def send_data(event)
- info("Sent data %s (%.1fms)" % [event.payload[:filename], event.duration])
- end
-
- %w(write_fragment read_fragment exist_fragment?
- expire_fragment expire_page write_page).each do |method|
- class_eval <<-METHOD, __FILE__, __LINE__ + 1
- def #{method}(event)
- key_or_path = event.payload[:key] || event.payload[:path]
- human_name = #{method.to_s.humanize.inspect}
- info("\#{human_name} \#{key_or_path} (%.1fms)" % event.duration)
- end
- METHOD
- end
-
- def logger
- ActionController::Base.logger
- end
- end
- end
-end
@@ -40,7 +40,7 @@ def teardown_subscriptions
ActiveSupport::Notifications.unsubscribe("!render_template.action_view")
end
- # Asserts that the request was rendered with the appropriate template file or partials
+ # Asserts that the request was rendered with the appropriate template file or partials.
#
# ==== Examples
#
@@ -53,6 +53,12 @@ def teardown_subscriptions
# # assert that no partials were rendered
# assert_template :partial => false
#
+ # In a view test case, you can also assert that specific locals are passed
+ # to partials:
+ #
+ # # assert that the "_customer" partial was rendered with a specific object
+ # assert_template :partial => '_customer', :locals => { :customer => @customer }
+ #
def assert_template(options = {}, message = nil)
validate_request!
@@ -72,9 +78,13 @@ def assert_template(options = {}, message = nil)
end
when Hash
if expected_partial = options[:partial]
- if expected_count = options[:count]
+ if expected_locals = options[:locals]
+ actual_locals = @locals[expected_partial.to_s.sub(/^_/,'')]
+ expected_locals.each_pair do |k,v|
+ assert_equal(v, actual_locals[k])
+ end
+ elsif expected_count = options[:count]
actual_count = @partials[expected_partial]
- # actual_count = found.nil? ? 0 : found[1]
msg = build_message(message,
"expecting ? to be rendered ? time(s) but rendered ? time(s)",
expected_partial, expected_count, actual_count)
@@ -183,6 +193,8 @@ def initialize(session = {})
replace(session.stringify_keys)
@loaded = true
end
+
+ def exists?; true; end
end
# Superclass for ActionController functional tests. Functional tests allow you to
Oops, something went wrong.

0 comments on commit 4329f81

Please sign in to comment.