Permalink
Browse files

Merge commit 'mainstream/master'

  • Loading branch information...
2 parents aaea12c + a2270ef commit d6c2285e31cbc7150cf99ff3a537eddbdb50fb29 @lifo lifo committed Dec 28, 2008
Showing with 769 additions and 411 deletions.
  1. +1 −0 actionpack/lib/action_controller/assertions/selector_assertions.rb
  2. +3 −3 actionpack/lib/action_controller/helpers.rb
  3. +19 −4 actionpack/lib/action_controller/mime_responds.rb
  4. +11 −7 actionpack/lib/action_controller/polymorphic_routes.rb
  5. +1 −1 actionpack/lib/action_controller/request.rb
  6. +31 −30 actionpack/lib/action_controller/routing/route_set.rb
  7. +1 −5 actionpack/lib/action_controller/test_process.rb
  8. +7 −3 actionpack/lib/action_view/helpers/form_helper.rb
  9. +8 −0 actionpack/test/controller/assert_select_test.rb
  10. +12 −10 actionpack/test/controller/layout_test.rb
  11. +2 −2 actionpack/test/controller/rack_test.rb
  12. +4 −5 actionpack/test/controller/session/cookie_store_test.rb
  13. +2 −0 activerecord/CHANGELOG
  14. +20 −15 activerecord/lib/active_record/association_preload.rb
  15. +18 −18 activerecord/lib/active_record/associations.rb
  16. +49 −3 activerecord/lib/active_record/base.rb
  17. +6 −6 activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb
  18. +24 −24 activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
  19. +13 −11 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
  20. +7 −7 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  21. +1 −1 activerecord/lib/active_record/dirty.rb
  22. +8 −0 activerecord/test/cases/associations/cascaded_eager_loading_test.rb
  23. +15 −0 activerecord/test/cases/associations/eager_test.rb
  24. +5 −0 activerecord/test/cases/base_test.rb
  25. +10 −1 activerecord/test/fixtures/people.yml
  26. +6 −0 activerecord/test/models/person.rb
  27. +4 −2 activerecord/test/schema/schema.rb
  28. +8 −0 activeresource/lib/active_resource/http_mock.rb
  29. +7 −7 activesupport/lib/active_support/buffered_logger.rb
  30. +18 −14 activesupport/lib/active_support/callbacks.rb
  31. +24 −24 activesupport/lib/active_support/core_ext/class/attribute_accessors.rb
  32. +20 −19 activesupport/lib/active_support/core_ext/class/delegating_attributes.rb
  33. +34 −34 activesupport/lib/active_support/core_ext/class/inheritable_attributes.rb
  34. +8 −1 activesupport/lib/active_support/core_ext/hash/slice.rb
  35. +6 −6 activesupport/lib/active_support/core_ext/logger.rb
  36. +3 −3 activesupport/lib/active_support/core_ext/module/aliasing.rb
  37. +4 −4 activesupport/lib/active_support/core_ext/module/attr_accessor_with_default.rb
  38. +24 −24 activesupport/lib/active_support/core_ext/module/attribute_accessors.rb
  39. +3 −3 activesupport/lib/active_support/core_ext/module/delegation.rb
  40. +5 −5 activesupport/lib/active_support/core_ext/module/synchronization.rb
  41. +9 −4 activesupport/lib/active_support/deprecation.rb
  42. +30 −28 activesupport/lib/active_support/memoizable.rb
  43. +4 −4 activesupport/lib/active_support/multibyte/unicode_database.rb
  44. +3 −3 activesupport/lib/active_support/time_with_zone.rb
  45. +17 −3 activesupport/test/core_ext/hash_ext_test.rb
  46. +64 −67 railties/lib/rails_generator/generators/applications/app/template_runner.rb
  47. +190 −0 railties/test/generators/rails_template_runner_test.rb
@@ -402,6 +402,7 @@ def assert_select_rjs(*args, &block)
if rjs_type
if rjs_type == :insert
position = args.shift
+ id = args.shift
insertion = "insert_#{position}".to_sym
raise ArgumentError, "Unknown RJS insertion type #{position}" unless RJS_STATEMENTS[insertion]
statement = "(#{RJS_STATEMENTS[insertion]})"
@@ -163,9 +163,9 @@ def helper(*args, &block)
def helper_method(*methods)
methods.flatten.each do |method|
master_helper_module.module_eval <<-end_eval
- def #{method}(*args, &block)
- controller.send(%(#{method}), *args, &block)
- end
+ def #{method}(*args, &block) # def current_user(*args, &block)
+ controller.send(%(#{method}), *args, &block) # controller.send(%(current_user), *args, &block)
+ end # end
end_eval
end
end
@@ -143,12 +143,27 @@ def any(*args, &block)
custom(@mime_type_priority.first, &block)
end
end
+
+ def self.generate_method_for_mime(mime)
+ sym = mime.is_a?(Symbol) ? mime : mime.to_sym
+ const = sym.to_s.upcase
+ class_eval <<-RUBY, __FILE__, __LINE__ + 1
+ def #{sym}(&block) # def html(&block)
+ custom(Mime::#{const}, &block) # custom(Mime::HTML, &block)
+ end # end
+ RUBY
+ end
- def method_missing(symbol, &block)
- mime_constant = symbol.to_s.upcase
+ Mime::SET.each do |mime|
+ generate_method_for_mime(mime)
+ end
- if Mime::SET.include?(Mime.const_get(mime_constant))
- custom(Mime.const_get(mime_constant), &block)
+ def method_missing(symbol, &block)
+ mime_constant = Mime.const_get(symbol.to_s.upcase)
+
+ if Mime::SET.include?(mime_constant)
+ self.class.generate_method_for_mime(mime_constant)
+ send(symbol, &block)
else
super
end
@@ -118,13 +118,17 @@ def polymorphic_path(record_or_hash_or_array, options = {})
%w(edit new).each do |action|
module_eval <<-EOT, __FILE__, __LINE__
- def #{action}_polymorphic_url(record_or_hash, options = {})
- polymorphic_url(record_or_hash, options.merge(:action => "#{action}"))
- end
-
- def #{action}_polymorphic_path(record_or_hash, options = {})
- polymorphic_url(record_or_hash, options.merge(:action => "#{action}", :routing_type => :path))
- end
+ def #{action}_polymorphic_url(record_or_hash, options = {}) # def edit_polymorphic_url(record_or_hash, options = {})
+ polymorphic_url( # polymorphic_url(
+ record_or_hash, # record_or_hash,
+ options.merge(:action => "#{action}")) # options.merge(:action => "edit"))
+ end # end
+ #
+ def #{action}_polymorphic_path(record_or_hash, options = {}) # def edit_polymorphic_path(record_or_hash, options = {})
+ polymorphic_url( # polymorphic_url(
+ record_or_hash, # record_or_hash,
+ options.merge(:action => "#{action}", :routing_type => :path)) # options.merge(:action => "edit", :routing_type => :path))
+ end # end
EOT
end
@@ -288,7 +288,7 @@ def raw_host_with_port
if forwarded = env["HTTP_X_FORWARDED_HOST"]
forwarded.split(/,\s?/).last
else
- env['HTTP_HOST'] || env['SERVER_NAME'] || "#{env['SERVER_ADDR']}:#{env['SERVER_PORT']}"
+ env['HTTP_HOST'] || "#{env['SERVER_NAME'] || env['SERVER_ADDR']}:#{env['SERVER_PORT']}"
end
end
@@ -145,10 +145,10 @@ def named_helper_module_eval(code, *args)
def define_hash_access(route, name, kind, options)
selector = hash_access_name(name, kind)
named_helper_module_eval <<-end_eval # We use module_eval to avoid leaks
- def #{selector}(options = nil)
- options ? #{options.inspect}.merge(options) : #{options.inspect}
- end
- protected :#{selector}
+ def #{selector}(options = nil) # def hash_for_users_url(options = nil)
+ options ? #{options.inspect}.merge(options) : #{options.inspect} # options ? {:only_path=>false}.merge(options) : {:only_path=>false}
+ end # end
+ protected :#{selector} # protected :hash_for_users_url
end_eval
helpers << selector
end
@@ -173,32 +173,33 @@ def define_url_helper(route, name, kind, options)
# foo_url(bar, baz, bang, :sort_by => 'baz')
#
named_helper_module_eval <<-end_eval # We use module_eval to avoid leaks
- def #{selector}(*args)
-
- #{generate_optimisation_block(route, kind)}
-
- opts = if args.empty? || Hash === args.first
- args.first || {}
- else
- options = args.extract_options!
- args = args.zip(#{route.segment_keys.inspect}).inject({}) do |h, (v, k)|
- h[k] = v
- h
- end
- options.merge(args)
- end
-
- url_for(#{hash_access_method}(opts))
-
- end
- #Add an alias to support the now deprecated formatted_* URL.
- def formatted_#{selector}(*args)
- ActiveSupport::Deprecation.warn(
- "formatted_#{selector}() has been deprecated. please pass format to the standard" +
- "#{selector}() method instead.", caller)
- #{selector}(*args)
- end
- protected :#{selector}
+ def #{selector}(*args) # def users_url(*args)
+ #
+ #{generate_optimisation_block(route, kind)} # #{generate_optimisation_block(route, kind)}
+ #
+ opts = if args.empty? || Hash === args.first # opts = if args.empty? || Hash === args.first
+ args.first || {} # args.first || {}
+ else # else
+ options = args.extract_options! # options = args.extract_options!
+ args = args.zip(#{route.segment_keys.inspect}).inject({}) do |h, (v, k)| # args = args.zip([]).inject({}) do |h, (v, k)|
+ h[k] = v # h[k] = v
+ h # h
+ end # end
+ options.merge(args) # options.merge(args)
+ end # end
+ #
+ url_for(#{hash_access_method}(opts)) # url_for(hash_for_users_url(opts))
+ #
+ end # end
+ #Add an alias to support the now deprecated formatted_* URL. # #Add an alias to support the now deprecated formatted_* URL.
+ def formatted_#{selector}(*args) # def formatted_users_url(*args)
+ ActiveSupport::Deprecation.warn( # ActiveSupport::Deprecation.warn(
+ "formatted_#{selector}() has been deprecated. " + # "formatted_users_url() has been deprecated. " +
+ "please pass format to the standard" + # "please pass format to the standard" +
+ "#{selector}() method instead.", caller) # "users_url() method instead.", caller)
+ #{selector}(*args) # users_url(*args)
+ end # end
+ protected :#{selector} # protected :users_url
end_eval
helpers << selector
end
@@ -33,11 +33,7 @@ class TestRequest < Request #:nodoc:
attr_accessor :host
def initialize
- env = Rack::MockRequest.env_for("/")
-
- # TODO: Fix Request to assume env['SERVER_ADDR'] doesn't contain port number
- env['SERVER_ADDR'] = env.delete("SERVER_NAME")
- super(env)
+ super(Rack::MockRequest.env_for("/"))
@query_parameters = {}
@session = TestSession.new
@@ -737,9 +737,13 @@ def initialize(object_name, object, template, options, proc)
(field_helpers - %w(label check_box radio_button fields_for)).each do |selector|
src = <<-end_src
- def #{selector}(method, options = {})
- @template.send(#{selector.inspect}, @object_name, method, objectify_options(options))
- end
+ def #{selector}(method, options = {}) # def text_field(method, options = {})
+ @template.send( # @template.send(
+ #{selector.inspect}, # "text_field",
+ @object_name, # @object_name,
+ method, # method,
+ objectify_options(options)) # objectify_options(options))
+ end # end
end_src
class_eval src, __FILE__, __LINE__
end
@@ -248,6 +248,14 @@ def test_assert_select_from_rjs_with_multiple_results
end
end
+ def test_assert_select_rjs_for_positioned_insert_should_fail_when_mixing_arguments
+ render_rjs do |page|
+ page.insert_html :top, "test1", "<div id=\"1\">foo</div>"
+ page.insert_html :bottom, "test2", "<div id=\"2\">foo</div>"
+ end
+ assert_raises(Assertion) {assert_select_rjs :insert, :top, "test2"}
+ end
+
#
# Test css_select.
#
@@ -165,15 +165,17 @@ def test_layout_status_is_rendered
end
end
-class LayoutSymlinkedTest < LayoutTest
- layout "symlinked/symlinked_layout"
-end
-
-class LayoutSymlinkedIsRenderedTest < ActionController::TestCase
- def test_symlinked_layout_is_rendered
- @controller = LayoutSymlinkedTest.new
- get :hello
- assert_response 200
- assert_equal "layouts/symlinked/symlinked_layout", @response.layout
+unless RUBY_PLATFORM =~ /(:?mswin|mingw|bccwin)/
+ class LayoutSymlinkedTest < LayoutTest
+ layout "symlinked/symlinked_layout"
+ end
+
+ class LayoutSymlinkedIsRenderedTest < ActionController::TestCase
+ def test_symlinked_layout_is_rendered
+ @controller = LayoutSymlinkedTest.new
+ get :hello
+ assert_response 200
+ assert_equal "layouts/symlinked/symlinked_layout", @response.layout
+ end
end
end
@@ -4,7 +4,7 @@ class BaseRackTest < Test::Unit::TestCase
def setup
@env = {
"HTTP_MAX_FORWARDS" => "10",
- "SERVER_NAME" => "glu.ttono.us:8007",
+ "SERVER_NAME" => "glu.ttono.us",
"FCGI_ROLE" => "RESPONDER",
"AUTH_TYPE" => "Basic",
"HTTP_X_FORWARDED_HOST" => "glu.ttono.us",
@@ -145,7 +145,7 @@ def test_cgi_environment_variables
assert_equal "kevin", @request.remote_user
assert_equal :get, @request.request_method
assert_equal "/dispatch.fcgi", @request.script_name
- assert_equal "glu.ttono.us:8007", @request.server_name
+ assert_equal "glu.ttono.us", @request.server_name
assert_equal 8007, @request.server_port
assert_equal "HTTP/1.1", @request.server_protocol
assert_equal "lighttpd", @request.server_software
@@ -25,7 +25,7 @@ def persistent_session_id
def set_session_value
session[:foo] = "bar"
- render :text => Marshal.dump(session.to_hash)
+ render :text => Verifier.generate(session.to_hash)
end
def get_session_value
@@ -94,8 +94,7 @@ def test_setting_session_value
with_test_route_set do
get '/set_session_value'
assert_response :success
- session_payload = Verifier.generate(Marshal.load(response.body))
- assert_equal ["_myapp_session=#{session_payload}; path=/"],
+ assert_equal ["_myapp_session=#{response.body}; path=/"],
headers['Set-Cookie']
end
end
@@ -148,8 +147,8 @@ def test_setting_session_value_after_session_reset
with_test_route_set do
get '/set_session_value'
assert_response :success
- session_payload = Verifier.generate(Marshal.load(response.body))
- assert_equal ["_myapp_session=#{session_payload}; path=/"],
+ session_payload = response.body
+ assert_equal ["_myapp_session=#{response.body}; path=/"],
headers['Set-Cookie']
get '/call_reset_session'
@@ -1,5 +1,7 @@
*2.3.0/3.0*
+* Fixed that ActiveRecord::Base#new_record? should return false (not nil) for existing records #1219 [Yaroslav Markin]
+
* I18n the word separator for error messages. Introduces the activerecord.errors.format.separator translation key. #1294 [Akira Matsuda]
* Add :having as a key to find and the relevant associations. [Emilio Tagua]
Oops, something went wrong.

0 comments on commit d6c2285

Please sign in to comment.