Permalink
Browse files

Resolved conflict

  • Loading branch information...
2 parents 8fe01de + 90c930f commit 73ade4fe100ae7f48c5f95dcdf7067f6a0cd51fa @dhh dhh committed Jul 16, 2008
Showing with 5,080 additions and 1,990 deletions.
  1. +1 −1 actionmailer/lib/action_mailer/base.rb
  2. +2 −2 actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/address.rb
  3. +1 −1 actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/header.rb
  4. +1 −1 actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/interface.rb
  5. +2 −2 actionmailer/lib/action_mailer/vendor/tmail-1.2.3/tmail/mail.rb
  6. +1 −2 actionmailer/test/abstract_unit.rb
  7. +47 −0 actionpack/CHANGELOG
  8. +6 −12 actionpack/README
  9. +29 −78 actionpack/lib/action_controller/assertions/response_assertions.rb
  10. +2 −4 actionpack/lib/action_controller/assertions/selector_assertions.rb
  11. +45 −32 actionpack/lib/action_controller/base.rb
  12. +12 −11 actionpack/lib/action_controller/caching/actions.rb
  13. +2 −4 actionpack/lib/action_controller/caching/fragments.rb
  14. +10 −0 actionpack/lib/action_controller/cookies.rb
  15. +219 −195 actionpack/lib/action_controller/filters.rb
  16. +1 −1 actionpack/lib/action_controller/integration.rb
  17. +1 −1 actionpack/lib/action_controller/layout.rb
  18. +5 −1 actionpack/lib/action_controller/mime_responds.rb
  19. +43 −39 actionpack/lib/action_controller/mime_type.rb
  20. +3 −7 actionpack/lib/action_controller/rack_process.rb
  21. +44 −11 actionpack/lib/action_controller/request.rb
  22. +1 −1 actionpack/lib/action_controller/request_forgery_protection.rb
  23. +16 −12 actionpack/lib/action_controller/rescue.rb
  24. +4 −0 actionpack/lib/action_controller/resources.rb
  25. +4 −0 actionpack/lib/action_controller/routing.rb
  26. +1 −2 actionpack/lib/action_controller/routing/builder.rb
  27. +15 −8 actionpack/lib/action_controller/streaming.rb
  28. +23 −0 actionpack/lib/action_controller/test_case.rb
  29. +5 −25 actionpack/lib/action_controller/test_process.rb
  30. +2 −2 actionpack/lib/action_controller/vendor/html-scanner/html/selector.rb
  31. +5 −3 actionpack/lib/action_view.rb
  32. +88 −79 actionpack/lib/action_view/base.rb
  33. +1 −1 actionpack/lib/action_view/helpers/active_record_helper.rb
  34. +44 −18 actionpack/lib/action_view/helpers/asset_tag_helper.rb
  35. +1 −2 actionpack/lib/action_view/helpers/cache_helper.rb
  36. +10 −10 actionpack/lib/action_view/helpers/capture_helper.rb
  37. +30 −18 actionpack/lib/action_view/helpers/date_helper.rb
  38. +20 −13 actionpack/lib/action_view/helpers/debug_helper.rb
  39. +47 −14 actionpack/lib/action_view/helpers/form_helper.rb
  40. +13 −11 actionpack/lib/action_view/helpers/form_options_helper.rb
  41. +19 −30 actionpack/lib/action_view/helpers/javascript_helper.rb
  42. +197 −192 actionpack/lib/action_view/helpers/prototype_helper.rb
  43. +1 −1 actionpack/lib/action_view/helpers/sanitize_helper.rb
  44. +1 −1 actionpack/lib/action_view/helpers/scriptaculous_helper.rb
  45. +13 −7 actionpack/lib/action_view/helpers/tag_helper.rb
  46. +1 −1 actionpack/lib/action_view/helpers/text_helper.rb
  47. +4 −6 actionpack/lib/action_view/helpers/url_helper.rb
  48. +11 −9 actionpack/lib/action_view/inline_template.rb
  49. +0 −74 actionpack/lib/action_view/partial_template.rb
  50. +21 −22 actionpack/lib/action_view/partials.rb
  51. +104 −0 actionpack/lib/action_view/paths.rb
  52. +87 −0 actionpack/lib/action_view/renderable.rb
  53. +36 −0 actionpack/lib/action_view/renderable_partial.rb
  54. +65 −63 actionpack/lib/action_view/template.rb
  55. +2 −2 actionpack/lib/action_view/template_error.rb
  56. +0 −88 actionpack/lib/action_view/template_file.rb
  57. +1 −13 actionpack/lib/action_view/template_handler.rb
  58. +5 −15 actionpack/lib/action_view/template_handlers/builder.rb
  59. +2 −116 actionpack/lib/action_view/template_handlers/compilable.rb
  60. +0 −6 actionpack/lib/action_view/template_handlers/erb.rb
  61. +2 −17 actionpack/lib/action_view/template_handlers/rjs.rb
  62. +0 −99 actionpack/lib/action_view/view_load_paths.rb
  63. +3 −1 actionpack/test/abstract_unit.rb
  64. +9 −8 actionpack/test/activerecord/render_partial_with_record_identification_test.rb
  65. +7 −33 actionpack/test/controller/action_pack_assertions_test.rb
  66. +0 −2 actionpack/test/controller/addresses_render_test.rb
  67. +73 −66 actionpack/test/controller/caching_test.rb
  68. +0 −2 actionpack/test/controller/capture_test.rb
  69. +46 −4 actionpack/test/controller/cgi_test.rb
  70. +1 −1 actionpack/test/controller/components_test.rb
  71. +14 −2 actionpack/test/controller/content_type_test.rb
  72. +0 −2 actionpack/test/controller/deprecation/deprecated_base_methods_test.rb
  73. +3 −2 actionpack/test/controller/layout_test.rb
  74. +5 −2 actionpack/test/controller/mime_responds_test.rb
  75. +10 −9 actionpack/test/controller/new_render_test.rb
  76. +77 −4 actionpack/test/controller/rack_test.rb
  77. +8 −16 actionpack/test/controller/redirect_test.rb
  78. +10 −13 actionpack/test/controller/render_test.rb
  79. +1 −1 actionpack/test/controller/request_test.rb
  80. +9 −0 actionpack/test/controller/rescue_test.rb
  81. +15 −17 actionpack/test/controller/resources_test.rb
  82. +20 −0 actionpack/test/controller/routing_test.rb
  83. +0 −2 actionpack/test/controller/send_file_test.rb
  84. +0 −18 actionpack/test/controller/test_test.rb
  85. +0 −16 actionpack/test/controller/view_paths_test.rb
  86. +1 −0 actionpack/test/fixtures/developers/_developer.erb
  87. +1 −0 actionpack/test/fixtures/fun/games/_game.erb
  88. +1 −0 actionpack/test/fixtures/fun/serious/games/_game.erb
  89. +3 −0 actionpack/test/fixtures/functional_caching/formatted_fragment_cached.html.erb
  90. +6 −0 actionpack/test/fixtures/functional_caching/formatted_fragment_cached.js.rjs
  91. +5 −0 actionpack/test/fixtures/functional_caching/formatted_fragment_cached.xml.builder
  92. +2 −0 actionpack/test/fixtures/functional_caching/inline_fragment_cached.html.erb
  93. +1 −0 actionpack/test/fixtures/projects/_project.erb
  94. +1 −0 actionpack/test/fixtures/public/javascripts/subdir/subdir.js
  95. +1 −0 actionpack/test/fixtures/public/stylesheets/subdir/subdir.css
  96. +1 −0 actionpack/test/fixtures/replies/_reply.erb
  97. +1 −0 actionpack/test/fixtures/test/hyphen-ated.erb
  98. +45 −1 actionpack/test/template/asset_tag_helper_test.rb
  99. +41 −0 actionpack/test/template/compiled_templates_test.rb
  100. +15 −0 actionpack/test/template/date_helper_test.rb
  101. +907 −22 actionpack/test/template/form_options_helper_test.rb
  102. +3 −5 actionpack/test/template/javascript_helper_test.rb
  103. +8 −4 actionpack/test/template/prototype_helper_test.rb
  104. +7 −8 actionpack/test/template/render_test.rb
  105. +11 −9 actionpack/test/template/url_helper_test.rb
  106. +27 −0 activerecord/CHANGELOG
  107. +13 −4 activerecord/lib/active_record/association_preload.rb
  108. +28 −14 activerecord/lib/active_record/associations.rb
  109. +13 −4 activerecord/lib/active_record/associations/association_collection.rb
  110. +10 −2 activerecord/lib/active_record/associations/has_many_association.rb
  111. +10 −1 activerecord/lib/active_record/associations/has_one_association.rb
  112. +5 −6 activerecord/lib/active_record/base.rb
  113. +3 −3 activerecord/lib/active_record/callbacks.rb
  114. +8 −6 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
  115. +1 −1 activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
  116. +13 −0 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
  117. +31 −9 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
  118. +14 −2 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  119. +12 −0 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
  120. +6 −6 activerecord/lib/active_record/dirty.rb
  121. +8 −7 activerecord/lib/active_record/fixtures.rb
  122. +2 −1 activerecord/lib/active_record/named_scope.rb
  123. +4 −5 activerecord/lib/active_record/observer.rb
  124. +13 −2 activerecord/lib/active_record/test_case.rb
  125. +3 −14 activerecord/lib/active_record/transactions.rb
  126. +35 −31 activerecord/lib/active_record/validations.rb
  127. +6 −0 activerecord/test/cases/adapter_test.rb
  128. +35 −0 activerecord/test/cases/associations/has_many_associations_test.rb
  129. +7 −0 activerecord/test/cases/associations/has_one_associations_test.rb
  130. +108 −0 activerecord/test/cases/associations_test.rb
  131. +19 −2 activerecord/test/cases/base_test.rb
  132. +36 −0 activerecord/test/cases/column_definition_test.rb
  133. +32 −3 activerecord/test/cases/fixtures_test.rb
  134. +5 −5 activerecord/test/cases/helper.rb
  135. +7 −0 activerecord/test/cases/inheritance_test.rb
  136. +10 −2 activerecord/test/cases/lifecycle_test.rb
  137. +56 −1 activerecord/test/cases/migration_test.rb
  138. +25 −0 activerecord/test/cases/multiple_db_test.rb
  139. +26 −0 activerecord/test/cases/named_scope_test.rb
  140. +3 −3 activerecord/test/cases/reflection_test.rb
  141. +18 −5 activerecord/test/cases/validations_test.rb
  142. +1 −0 activerecord/test/fixtures/companies.yml
  143. +1 −1 activerecord/test/models/author.rb
  144. +3 −0 activerecord/test/models/company.rb
  145. +6 −0 activerecord/test/models/post.rb
  146. +2 −0 activerecord/test/models/topic.rb
  147. +2 −0 activerecord/test/schema/schema.rb
  148. +1 −1 activeresource/README
  149. +11 −11 activeresource/lib/active_resource/base.rb
  150. +2 −2 activeresource/lib/active_resource/custom_methods.rb
  151. +1 −1 activeresource/lib/active_resource/http_mock.rb
  152. +14 −0 activesupport/CHANGELOG
  153. +1 −0 activesupport/lib/active_support.rb
  154. +9 −1 activesupport/lib/active_support/callbacks.rb
  155. +45 −2 activesupport/lib/active_support/core_ext/array/grouping.rb
  156. +1 −1 activesupport/lib/active_support/core_ext/bigdecimal/conversions.rb
  157. +1 −1 activesupport/lib/active_support/core_ext/hash/except.rb
  158. +12 −5 activesupport/lib/active_support/core_ext/hash/reverse_merge.rb
  159. +18 −7 activesupport/lib/active_support/core_ext/module/introspection.rb
  160. +1 −0 activesupport/lib/active_support/core_ext/object.rb
  161. +1 −1 activesupport/lib/active_support/core_ext/object/instance_variables.rb
  162. +8 −0 activesupport/lib/active_support/core_ext/object/metaclass.rb
  163. +2 −2 activesupport/lib/active_support/core_ext/string/inflections.rb
  164. +0 −1 activesupport/lib/active_support/core_ext/test.rb
  165. +1 −1 activesupport/lib/active_support/core_ext/time/calculations.rb
  166. +2 −2 activesupport/lib/active_support/dependencies.rb
  167. +1 −1 activesupport/lib/active_support/json.rb
  168. +9 −2 activesupport/lib/active_support/json/encoders/date.rb
  169. +10 −3 activesupport/lib/active_support/json/encoders/date_time.rb
  170. +10 −3 activesupport/lib/active_support/json/encoders/time.rb
  171. +35 −0 activesupport/lib/active_support/memoizable.rb
  172. +1 −5 activesupport/lib/active_support/test_case.rb
  173. +6 −0 activesupport/lib/active_support/testing/core_ext/test.rb
  174. +4 −3 activesupport/lib/active_support/{ → testing}/core_ext/test/unit/assertions.rb
  175. +14 −2 activesupport/lib/active_support/time_with_zone.rb
  176. +1 −1 activesupport/lib/active_support/vendor/builder-2.1.2/builder/xmlevents.rb
  177. +2 −2 activesupport/lib/active_support/vendor/memcache-client-1.5.0/memcache.rb
  178. +1 −1 activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/data_timezone.rb
  179. +1 −1 activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/data_timezone_info.rb
  180. +1 −1 activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/linked_timezone.rb
  181. +1 −1 activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/timezone.rb
  182. +1 −1 activesupport/lib/active_support/vendor/tzinfo-0.3.9/tzinfo/timezone_transition_info.rb
  183. +3 −3 activesupport/lib/active_support/vendor/xml-simple-1.0.11/xmlsimple.rb
  184. +24 −0 activesupport/test/callbacks_test.rb
  185. +46 −4 activesupport/test/core_ext/array_ext_test.rb
  186. +8 −0 activesupport/test/core_ext/object_and_class_ext_test.rb
  187. +6 −0 activesupport/test/core_ext/time_with_zone_test.rb
  188. +49 −0 activesupport/test/memoizable_test.rb
  189. +0 −1 cleanlogs.sh
  190. +7 −0 railties/CHANGELOG
  191. +17 −0 railties/config.ru
  192. +2 −0 railties/configs/routes.rb
  193. +91 −0 railties/doc/guides/actionview/helpers.markdown
  194. +90 −0 railties/doc/guides/actionview/partials.markdown
  195. +56 −0 railties/doc/guides/activerecord/basics.markdown
  196. +861 −0 railties/doc/guides/creating_plugins/basics.markdown
  197. +4 −4 railties/environments/boot.rb
  198. +0 −1 railties/environments/production.rb
  199. +1 −5 railties/helpers/performance_test_helper.rb
  200. +32 −15 railties/lib/commands/plugin.rb
  201. +2 −2 railties/lib/commands/process/spawner.rb
  202. +1 −1 railties/lib/console_with_helpers.rb
  203. +50 −33 railties/lib/initializer.rb
  204. +5 −0 railties/lib/performance_test_help.rb
  205. +1 −1 railties/lib/rails/plugin/locator.rb
  206. +9 −16 railties/lib/rails_generator/commands.rb
  207. +1 −0 railties/lib/rails_generator/generators/applications/app/app_generator.rb
  208. +9 −5 railties/lib/rails_generator/generators/components/scaffold/USAGE
  209. +1 −1 railties/lib/rails_generator/lookup.rb
  210. +1 −1 railties/lib/rails_generator/scripts.rb
  211. +6 −7 railties/lib/rails_generator/scripts/destroy.rb
  212. +1 −1 railties/lib/rails_generator/secret_key_generator.rb
  213. +8 −11 railties/lib/tasks/annotations.rake
  214. +20 −14 railties/lib/tasks/databases.rake
  215. +1 −1 railties/lib/tasks/misc.rake
  216. +1 −1 railties/test/generators/generator_test_helper.rb
  217. +19 −0 railties/test/generators/rails_controller_generator_test.rb
@@ -426,7 +426,7 @@ def register_template_extension(extension)
end
def template_root=(root)
- write_inheritable_attribute(:template_root, ActionView::ViewLoadPaths.new(Array(root)))
+ write_inheritable_attribute(:template_root, ActionView::PathSet.new(Array(root)))
end
end
@@ -38,7 +38,7 @@ module TMail
# = Class Address
#
# Provides a complete handling library for email addresses. Can parse a string of an
- # address directly or take in preformatted addresses themseleves. Allows you to add
+ # address directly or take in preformatted addresses themselves. Allows you to add
# and remove phrases from the front of the address and provides a compare function for
# email addresses.
#
@@ -143,7 +143,7 @@ def initialize( local, domain )
# This is to catch an unquoted "@" symbol in the local part of the
# address. Handles addresses like <"@"@me.com> and makes sure they
- # stay like <"@"@me.com> (previously were becomming <@@me.com>)
+ # stay like <"@"@me.com> (previously were becoming <@@me.com>)
if local && (local.join == '@' || local.join =~ /\A[^"].*?@.*?[^"]\Z/)
@local = "\"#{local.join}\""
else
@@ -59,7 +59,7 @@ def new( name, body, conf = DEFAULT_CONFIG )
#
# This is because a mailbox doesn't have the : after the From that designates the
# beginning of the envelope sender (which can be different to the from address of
- # the emial)
+ # the email)
#
# Other fields can be passed as normal, "Reply-To", "Received" etc.
#
@@ -42,7 +42,7 @@ class Mail
# Allows you to query the mail object with a string to get the contents
# of the field you want.
#
- # Returns a string of the exact contnts of the field
+ # Returns a string of the exact contents of the field
#
# mail.from = "mikel <mikel@lindsaar.net>"
# mail.header_string("From") #=> "mikel <mikel@lindsaar.net>"
@@ -255,7 +255,7 @@ def sub_header(key, param)
alias fetch []
# Allows you to set or delete TMail header objects at will.
- # Eamples:
+ # Examples:
# @mail = TMail::Mail.new
# @mail['to'].to_s # => 'mikel@test.com.au'
# @mail['to'] = 'mikel@elsewhere.org'
@@ -265,7 +265,7 @@ def sub_header(key, param)
# @mail['to'].to_s # => nil
# @mail.encoded # => "\r\n"
#
- # Note: setting mail[] = nil actualy deletes the header field in question from the object,
+ # Note: setting mail[] = nil actually deletes the header field in question from the object,
# it does not just set the value of the hash to nil
def []=( key, val )
dkey = key.downcase
@@ -32,8 +32,7 @@ def self.start(*args)
# Wrap tests that use Mocha and skip if unavailable.
def uses_mocha(test_name)
- gem 'mocha', ">=0.5"
- require 'stubba'
+ gem 'mocha', ">=0.9.0"
yield
rescue Gem::LoadError
$stderr.puts "Skipping #{test_name} tests (Mocha >= 0.5 is required). `gem install mocha` and try again."
View
@@ -2,6 +2,43 @@
* Fixed that AssetTagHelper#compute_public_path shouldn't cache the asset_host along with the source or per-request proc's won't run [DHH]
+* Removed config.action_view.cache_template_loading, use config.cache_classes instead [Josh Peek]
+
+* Get buffer for fragment cache from template's @output_buffer [Josh Peek]
+
+* Set config.action_view.warn_cache_misses = true to receive a warning if you perform an action that results in an expensive disk operation that could be cached [Josh Peek]
+
+* Refactor template preloading. New abstractions include Renderable mixins and a refactored Template class [Josh Peek]
+
+* Changed ActionView::TemplateHandler#render API method signature to render(template, local_assigns = {}) [Josh Peek]
+
+* Changed PrototypeHelper#submit_to_remote to PrototypeHelper#button_to_remote to stay consistent with link_to_remote (submit_to_remote still works as an alias) #8994 [clemens]
+
+* Add :recursive option to javascript_include_tag and stylesheet_link_tag to be used along with :all. #480 [Damian Janowski]
+
+* Allow users to disable the use of the Accept header [Michael Koziarski]
+
+ The accept header is poorly implemented by browsers and causes strange
+ errors when used on public sites where crawlers make requests too. You
+ can use formatted urls (e.g. /people/1.xml) to support API clients in a
+ much simpler way.
+
+ To disable the header you need to set:
+
+ config.action_controller.use_accept_header = false
+
+* Do not stat template files in production mode before rendering. You will no longer be able to modify templates in production mode without restarting the server [Josh Peek]
+
+* Deprecated TemplateHandler line offset [Josh Peek]
+
+* Allow caches_action to accept cache store options. #416. [José Valim]. Example:
+
+ caches_action :index, :redirected, :if => Proc.new { |c| !c.request.format.json? }, :expires_in => 1.hour
+
+* Remove define_javascript_functions, javascript_include_tag and friends are far superior. [Michael Koziarski]
+
+* Deprecate :use_full_path render option. The supplying the option no longer has an effect [Josh Peek]
+
* Add :as option to render a collection of partials with a custom local variable name. #509 [Simon Jefford, Pratik Naik]
render :partial => 'other_people', :collection => @people, :as => :person
@@ -12,6 +49,16 @@
* Made ActionView::Base#render_file private [Josh Peek]
+* Refactor and simplify the implementation of assert_redirected_to. Arguments are now normalised relative to the controller being tested, not the root of the application. [Michael Koziarski]
+
+ This could cause some erroneous test failures if you were redirecting between controllers
+ in different namespaces and wrote your assertions relative to the root of the application.
+
+* Remove follow_redirect from controller functional tests.
+
+ If you want to follow redirects you can use integration tests. The functional test
+ version was only useful if you were using redirect_to :id=>...
+
* Fix polymorphic_url with singleton resources. #461 [Tammer Saleh]
* Replaced TemplateFinder abstraction with ViewLoadPaths [Josh Peek]
View
@@ -31,7 +31,7 @@ http://www.rubyonrails.org.
A short rundown of the major features:
* Actions grouped in controller as methods instead of separate command objects
- and can therefore share helper methods.
+ and can therefore share helper methods
BlogController < ActionController::Base
def show
@@ -168,7 +168,7 @@ A short rundown of the major features:
{Learn more}[link:classes/ActionController/Base.html]
-* Javascript and Ajax integration.
+* Javascript and Ajax integration
link_to_function "Greeting", "alert('Hello world!')"
link_to_remote "Delete this post", :update => "posts",
@@ -177,7 +177,7 @@ A short rundown of the major features:
{Learn more}[link:classes/ActionView/Helpers/JavaScriptHelper.html]
-* Pagination for navigating lists of results.
+* Pagination for navigating lists of results
# controller
def list
@@ -192,23 +192,17 @@ A short rundown of the major features:
{Learn more}[link:classes/ActionController/Pagination.html]
-* Easy testing of both controller and template result through TestRequest/Response
-
- class LoginControllerTest < Test::Unit::TestCase
- def setup
- @controller = LoginController.new
- @request = ActionController::TestRequest.new
- @response = ActionController::TestResponse.new
- end
+* Easy testing of both controller and rendered template through ActionController::TestCase
+ class LoginControllerTest < ActionController::TestCase
def test_failing_authenticate
process :authenticate, :user_name => "nop", :password => ""
assert flash.has_key?(:alert)
assert_redirected_to :action => "index"
end
end
- {Learn more}[link:classes/ActionController/TestRequest.html]
+ {Learn more}[link:classes/ActionController/TestCase.html]
* Automated benchmarking and integrated logging
@@ -56,74 +56,24 @@ def assert_response(type, message = nil)
# # assert that the redirection was to the named route login_url
# assert_redirected_to login_url
#
+ # # assert that the redirection was to the url for @customer
+ # assert_redirected_to @customer
+ #
def assert_redirected_to(options = {}, message=nil)
clean_backtrace do
assert_response(:redirect, message)
return true if options == @response.redirected_to
- ActionController::Routing::Routes.reload if ActionController::Routing::Routes.empty?
-
- begin
- url = {}
- original = { :expected => options, :actual => @response.redirected_to.is_a?(Symbol) ? @response.redirected_to : @response.redirected_to.dup }
- original.each do |key, value|
- if value.is_a?(Symbol)
- value = @controller.respond_to?(value, true) ? @controller.send(value) : @controller.send("hash_for_#{value}_url")
- end
-
- unless value.is_a?(Hash)
- request = case value
- when NilClass then nil
- when /^\w+:\/\// then recognized_request_for(%r{^(\w+://.*?(/|$|\?))(.*)$} =~ value ? $3 : nil)
- else recognized_request_for(value)
- end
- value = request.path_parameters if request
- end
-
- if value.is_a?(Hash) # stringify 2 levels of hash keys
- if name = value.delete(:use_route)
- route = ActionController::Routing::Routes.named_routes[name]
- value.update(route.parameter_shell)
- end
-
- value.stringify_keys!
- value.values.select { |v| v.is_a?(Hash) }.collect { |v| v.stringify_keys! }
- if key == :expected && value['controller'] == @controller.controller_name && original[:actual].is_a?(Hash)
- original[:actual].stringify_keys!
- value.delete('controller') if original[:actual]['controller'].nil? || original[:actual]['controller'] == value['controller']
- end
- end
-
- if value.respond_to?(:[]) && value['controller']
- value['controller'] = value['controller'].to_s
- if key == :actual && value['controller'].first != '/' && !value['controller'].include?('/')
- new_controller_path = ActionController::Routing.controller_relative_to(value['controller'], @controller.class.controller_path)
- value['controller'] = new_controller_path if value['controller'] != new_controller_path && ActionController::Routing.possible_controllers.include?(new_controller_path) && @response.redirected_to.is_a?(Hash)
- end
- value['controller'] = value['controller'][1..-1] if value['controller'].first == '/' # strip leading hash
- end
- url[key] = value
- end
-
- @response_diff = url[:actual].diff(url[:expected]) if url[:actual]
- msg = build_message(message, "expected a redirect to <?>, found one to <?>, a difference of <?> ", url[:expected], url[:actual], @response_diff)
-
- assert_block(msg) do
- url[:expected].keys.all? do |k|
- if k == :controller then url[:expected][k] == ActionController::Routing.controller_relative_to(url[:actual][k], @controller.class.controller_path)
- else parameterize(url[:expected][k]) == parameterize(url[:actual][k])
- end
- end
- end
- rescue ActionController::RoutingError # routing failed us, so match the strings only.
- msg = build_message(message, "expected a redirect to <?>, found one to <?>", options, @response.redirect_url)
- url_regexp = %r{^(\w+://.*?(/|$|\?))(.*)$}
- eurl, epath, url, path = [options, @response.redirect_url].collect do |url|
- u, p = (url_regexp =~ url) ? [$1, $3] : [nil, url]
- [u, (p.first == '/') ? p : '/' + p]
- end.flatten
+
+ # Support partial arguments for hash redirections
+ if options.is_a?(Hash) && @response.redirected_to.is_a?(Hash)
+ return true if options.all? {|(key, value)| @response.redirected_to[key] == value}
+ end
+
+ redirected_to_after_normalisation = normalize_argument_to_redirection(@response.redirected_to)
+ options_after_normalisation = normalize_argument_to_redirection(options)
- assert_equal(eurl, url, msg) if eurl && url
- assert_equal(epath, path, msg) if epath && path
+ if redirected_to_after_normalisation != options_after_normalisation
+ flunk "Expected response to be a redirect to <#{options_after_normalisation}> but was a redirect to <#{redirected_to_after_normalisation}>"
end
end
end
@@ -137,36 +87,37 @@ def assert_redirected_to(options = {}, message=nil)
#
def assert_template(expected = nil, message=nil)
clean_backtrace do
- rendered = expected ? @response.rendered_file(!expected.include?('/')) : @response.rendered_file
+ rendered = @response.rendered_template
msg = build_message(message, "expecting <?> but rendering with <?>", expected, rendered)
assert_block(msg) do
if expected.nil?
- !@response.rendered_with_file?
+ @response.rendered_template.nil?
else
- expected == rendered
+ rendered.to_s.match(expected)
end
end
end
end
private
- # Recognizes the route for a given path.
- def recognized_request_for(path, request_method = nil)
- path = "/#{path}" unless path.first == '/'
-
- # Assume given controller
- request = ActionController::TestRequest.new({}, {}, nil)
- request.env["REQUEST_METHOD"] = request_method.to_s.upcase if request_method
- request.path = path
-
- ActionController::Routing::Routes.recognize(request)
- request
- end
# Proxy to to_param if the object will respond to it.
def parameterize(value)
value.respond_to?(:to_param) ? value.to_param : value
end
+
+ def normalize_argument_to_redirection(fragment)
+ after_routing = @controller.url_for(fragment)
+ if after_routing =~ %r{^\w+://.*}
+ after_routing
+ else
+ # FIXME - this should probably get removed.
+ if after_routing.first != '/'
+ after_routing = '/' + after_routing
+ end
+ @request.protocol + @request.host_with_port + after_routing
+ end
+ end
end
end
end
@@ -21,10 +21,8 @@ module Assertions
# 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.
+ # * +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.
# * +assert_select_email+ - Assertions on the HTML body of an e-mail.
#
# Also see HTML::Selector to learn how to use selectors.
Oops, something went wrong.

0 comments on commit 73ade4f

Please sign in to comment.