aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile46
-rw-r--r--actionpack/lib/action_view/helpers/number_helper.rb48
-rw-r--r--actionpack/lib/action_view/helpers/text_helper.rb21
-rw-r--r--actionpack/test/template/number_helper_test.rb27
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb9
-rw-r--r--activerecord/lib/active_record/autosave_association.rb4
-rw-r--r--activerecord/lib/active_record/base.rb2
-rw-r--r--activerecord/test/cases/autosave_association_test.rb8
-rw-r--r--activeresource/lib/active_resource/base.rb4
-rw-r--r--activeresource/test/cases/base_test.rb1
-rw-r--r--activesupport/lib/active_support/dependencies.rb17
-rw-r--r--activesupport/lib/active_support/deprecation/proxy_wrappers.rb7
-rw-r--r--activesupport/lib/active_support/notifications.rb2
-rw-r--r--activesupport/lib/active_support/xml_mini.rb6
-rw-r--r--activesupport/test/autoloading_fixtures/load_path/loaded_constant.rb3
-rw-r--r--activesupport/test/autoloading_fixtures/loads_constant.rb5
-rw-r--r--activesupport/test/autoloading_fixtures/requires_constant.rb5
-rw-r--r--activesupport/test/dependencies_test.rb51
-rw-r--r--activesupport/test/deprecation/proxy_wrappers_test.rb22
-rw-r--r--activesupport/test/rescuable_test.rb37
-rw-r--r--activesupport/test/test_xml_mini.rb49
-rw-r--r--rails.gemspec2
-rw-r--r--railties/lib/rails/generators/base.rb2
-rw-r--r--railties/railties.gemspec2
-rw-r--r--railties/test/generators/app_generator_test.rb8
25 files changed, 250 insertions, 138 deletions
diff --git a/Gemfile b/Gemfile
index d2377c2d08..b92a6ab7a0 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,6 +1,11 @@
source 'http://rubygems.org'
-gem "arel", :git => "git://github.com/rails/arel.git"
+if ENV['AREL']
+ gem "arel", :path => ENV['AREL']
+else
+ gem "arel", :git => "git://github.com/rails/arel.git"
+end
+
gem "rails", :path => File.dirname(__FILE__)
gem "rake", ">= 0.8.7"
@@ -8,36 +13,35 @@ gem "mocha", ">= 0.9.8"
gem "rdoc", ">= 2.5.9"
gem "horo"
-mri = !defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby"
-if mri && RUBY_VERSION < '1.9'
+# AS
+gem "memcache-client", ">= 1.8.5"
+
+# AM
+gem "text-format", "~> 1.0.0"
+
+platforms :mri_18 do
gem "system_timer"
gem "ruby-debug", ">= 0.10.3"
end
-if mri || RUBY_ENGINE == "rbx"
+platforms :ruby do
gem 'json'
gem 'yajl-ruby'
gem "nokogiri", ">= 1.4.2"
-elsif RUBY_ENGINE == "jruby"
- gem "ruby-debug"
- gem "jruby-openssl"
-end
-# AS
-gem "memcache-client", ">= 1.8.5"
-
-# AM
-gem "text-format", "~> 1.0.0"
-
-# AR
-if mri || RUBY_ENGINE == "rbx"
+ # AR
gem "sqlite3-ruby", "~> 1.3.1", :require => 'sqlite3'
group :db do
gem "pg", ">= 0.9.0"
gem "mysql", ">= 2.8.1"
end
-elsif RUBY_ENGINE == "jruby"
+end
+
+platforms :jruby do
+ gem "system_timer"
+ gem "ruby-debug", ">= 0.10.3"
+
gem "activerecord-jdbcsqlite3-adapter"
group :db do
@@ -46,9 +50,11 @@ elsif RUBY_ENGINE == "jruby"
end
end
-if ENV['CI']
+env 'CI' do
gem "nokogiri", ">= 1.4.2"
- # fcgi gem doesn't compile on 1.9
- gem "fcgi", ">= 0.8.8" if RUBY_VERSION < '1.9.0'
+ platforms :ruby_18 do
+ # fcgi gem doesn't compile on 1.9
+ gem "fcgi", ">= 0.8.8"
+ end
end
diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb
index 37e5d91d8b..f11027bc93 100644
--- a/actionpack/lib/action_view/helpers/number_helper.rb
+++ b/actionpack/lib/action_view/helpers/number_helper.rb
@@ -186,14 +186,7 @@ module ActionView
# number_with_delimiter(12345678.05, :locale => :fr) # => 12 345 678,05
# number_with_delimiter(98765432.98, :delimiter => " ", :separator => ",")
# # => 98 765 432,98
- #
- # You can still use <tt>number_with_delimiter</tt> with the old API that accepts the
- # +delimiter+ as its optional second and the +separator+ as its
- # optional third parameter:
- # number_with_delimiter(12345678, " ") # => 12 345 678
- # number_with_delimiter(12345678.05, ".", ",") # => 12.345.678,05
- def number_with_delimiter(number, *args)
- options = args.extract_options!
+ def number_with_delimiter(number, options = {})
options.symbolize_keys!
begin
@@ -207,14 +200,6 @@ module ActionView
end
defaults = I18n.translate(:'number.format', :locale => options[:locale], :default => {})
-
- unless args.empty?
- ActiveSupport::Deprecation.warn('number_with_delimiter takes an option hash ' +
- 'instead of separate delimiter and precision arguments.', caller)
- options[:delimiter] ||= args[0] if args[0]
- options[:separator] ||= args[1] if args[1]
- end
-
options = options.reverse_merge(defaults)
parts = number.to_s.split('.')
@@ -249,13 +234,7 @@ module ActionView
# number_with_precision(389.32314, :precision => 4, :significant => true) # => 389.3
# number_with_precision(1111.2345, :precision => 2, :separator => ',', :delimiter => '.')
# # => 1.111,23
- #
- # You can still use <tt>number_with_precision</tt> with the old API that accepts the
- # +precision+ as its optional second parameter:
- # number_with_precision(111.2345, 2) # => 111.23
- def number_with_precision(number, *args)
-
- options = args.extract_options!
+ def number_with_precision(number, options = {})
options.symbolize_keys!
number = begin
@@ -272,13 +251,6 @@ module ActionView
precision_defaults = I18n.translate(:'number.precision.format', :locale => options[:locale], :default => {})
defaults = defaults.merge(precision_defaults)
- #Backwards compatibility
- unless args.empty?
- ActiveSupport::Deprecation.warn('number_with_precision takes an option hash ' +
- 'instead of a separate precision argument.', caller)
- options[:precision] ||= args[0] if args[0]
- end
-
options = options.reverse_merge(defaults) # Allow the user to unset default values: Eg.: :significant => false
precision = options.delete :precision
significant = options.delete :significant
@@ -337,13 +309,7 @@ module ActionView
# <tt>:strip_insignificant_zeros</tt> to +false+ to change that):
# number_to_human_size(1234567890123, :precision => 5) # => "1.1229 TB"
# number_to_human_size(524288000, :precision=>5) # => "500 MB"
- #
- # You can still use <tt>number_to_human_size</tt> with the old API that accepts the
- # +precision+ as its optional second parameter:
- # number_to_human_size(1234567, 1) # => 1 MB
- # number_to_human_size(483989, 2) # => 470 KB
- def number_to_human_size(number, *args)
- options = args.extract_options!
+ def number_to_human_size(number, options = {})
options.symbolize_keys!
number = begin
@@ -359,13 +325,7 @@ module ActionView
defaults = I18n.translate(:'number.format', :locale => options[:locale], :default => {})
human = I18n.translate(:'number.human.format', :locale => options[:locale], :default => {})
defaults = defaults.merge(human)
-
- unless args.empty?
- ActiveSupport::Deprecation.warn('number_to_human_size takes an option hash ' +
- 'instead of a separate precision argument.', caller)
- options[:precision] ||= args[0] if args[0]
- end
-
+
options = options.reverse_merge(defaults)
#for backwards compatibility with those that didn't add strip_insignificant_zeros to their locale files
options[:strip_insignificant_zeros] = true if not options.key?(:strip_insignificant_zeros)
diff --git a/actionpack/lib/action_view/helpers/text_helper.rb b/actionpack/lib/action_view/helpers/text_helper.rb
index 0be8a2c36e..52a016c9c1 100644
--- a/actionpack/lib/action_view/helpers/text_helper.rb
+++ b/actionpack/lib/action_view/helpers/text_helper.rb
@@ -61,27 +61,8 @@ module ActionView
#
# truncate("<p>Once upon a time in a world far far away</p>")
# # => "<p>Once upon a time in a wo..."
- #
- # You can still use <tt>truncate</tt> with the old API that accepts the
- # +length+ as its optional second and the +ellipsis+ as its
- # optional third parameter:
- # truncate("Once upon a time in a world far far away", 14)
- # # => "Once upon a..."
- #
- # truncate("And they found that many people were sleeping better.", 25, "... (continued)")
- # # => "And they f... (continued)"
- def truncate(text, *args)
- options = args.extract_options!
- unless args.empty?
- ActiveSupport::Deprecation.warn('truncate takes an option hash instead of separate ' +
- 'length and omission arguments', caller)
-
- options[:length] = args[0] || 30
- options[:omission] = args[1] || "..."
- end
-
+ def truncate(text, options = {})
options.reverse_merge!(:length => 30)
-
text.truncate(options.delete(:length), options) if text
end
diff --git a/actionpack/test/template/number_helper_test.rb b/actionpack/test/template/number_helper_test.rb
index 14e81fc9dc..7f787b7b00 100644
--- a/actionpack/test/template/number_helper_test.rb
+++ b/actionpack/test/template/number_helper_test.rb
@@ -82,16 +82,6 @@ class NumberHelperTest < ActionView::TestCase
assert_equal '12.345.678,05', number_with_delimiter(12345678.05, :delimiter => '.', :separator => ',')
end
- def test_number_with_delimiter_old_api
- silence_deprecation_warnings
- assert_equal '12 345 678', number_with_delimiter(12345678, " ")
- assert_equal '12-345-678.05', number_with_delimiter(12345678.05, '-')
- assert_equal '12.345.678,05', number_with_delimiter(12345678.05, '.', ',')
- assert_equal '12,345,678.05', number_with_delimiter(12345678.05, ',', '.')
- assert_equal '12 345 678-05', number_with_delimiter(12345678.05, ',', '.', :delimiter => ' ', :separator => '-')
- restore_deprecation_warnings
- end
-
def test_number_with_precision
assert_equal("111.235", number_with_precision(111.2346))
assert_equal("31.83", number_with_precision(31.825, :precision => 2))
@@ -146,15 +136,6 @@ class NumberHelperTest < ActionView::TestCase
assert_equal "12", number_with_precision("12.3", :precision => 0, :significant => true )
end
- def test_number_with_precision_old_api
- silence_deprecation_warnings
- assert_equal("31.8250", number_with_precision(31.825, 4))
- assert_equal("111.235", number_with_precision(111.2346, 3))
- assert_equal("111.00", number_with_precision(111, 2))
- assert_equal("111.000", number_with_precision(111, 2, :precision =>3))
- restore_deprecation_warnings
- end
-
def test_number_to_human_size
assert_equal '0 Bytes', number_to_human_size(0)
assert_equal '1 Byte', number_to_human_size(1)
@@ -202,14 +183,6 @@ class NumberHelperTest < ActionView::TestCase
assert_equal '1.000,1 TB', number_to_human_size(terabytes(1000.1), :precision => 5, :delimiter => '.', :separator => ',')
end
- def test_number_to_human_size_old_api
- silence_deprecation_warnings
- assert_equal '1.3143 KB', number_to_human_size(kilobytes(1.3143), 4, :significant => false)
- assert_equal '10.45 KB', number_to_human_size(kilobytes(10.453), 4)
- assert_equal '10 KB', number_to_human_size(kilobytes(10.453), 4, :precision => 2)
- restore_deprecation_warnings
- end
-
def test_number_to_human
assert_equal '123', number_to_human(123)
assert_equal '1.23 Thousand', number_to_human(1234)
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index f346a19a3a..4ce3b34819 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -478,13 +478,10 @@ module ActiveRecord
callback(:before_add, record)
yield(record) if block_given?
@target ||= [] unless loaded?
- index = @target.index(record)
- unless @reflection.options[:uniq] && index
- if index
- @target[index] = record
- else
+ if index = @target.index(record)
+ @target[index] = record
+ else
@target << record
- end
end
callback(:after_add, record)
set_inverse_instance(record, @owner)
diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb
index 7517896235..062b010436 100644
--- a/activerecord/lib/active_record/autosave_association.rb
+++ b/activerecord/lib/active_record/autosave_association.rb
@@ -377,10 +377,6 @@ module ActiveRecord
if association.updated?
association_id = association.send(reflection.options[:primary_key] || :id)
self[reflection.primary_key_name] = association_id
- # TODO: Removing this code doesn't seem to matter...
- if reflection.options[:polymorphic]
- self[reflection.options[:foreign_type]] = association.class.base_class.name.to_s
- end
end
saved if autosave
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index c589b32dd8..5898ec3732 100644
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1255,6 +1255,8 @@ MSG
replace_named_bind_variables(statement, values.first)
elsif statement.include?('?')
replace_bind_variables(statement, values)
+ elsif statement.blank?
+ statement
else
statement % values.collect { |value| connection.quote_string(value.to_s) }
end
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb
index 3b89c12a3f..08694526af 100644
--- a/activerecord/test/cases/autosave_association_test.rb
+++ b/activerecord/test/cases/autosave_association_test.rb
@@ -171,7 +171,7 @@ class TestDefaultAutosaveAssociationOnAHasOneAssociation < ActiveRecord::TestCas
end
class TestDefaultAutosaveAssociationOnABelongsToAssociation < ActiveRecord::TestCase
- fixtures :companies
+ fixtures :companies, :posts, :tags, :taggings
def test_should_save_parent_but_not_invalid_child
client = Client.new(:name => 'Joe (the Plumber)')
@@ -312,6 +312,12 @@ class TestDefaultAutosaveAssociationOnABelongsToAssociation < ActiveRecord::Test
assert_equal num_orders +1, Order.count
assert_equal num_customers +2, Customer.count
end
+
+ def test_store_association_with_a_polymorphic_relationship
+ num_tagging = Tagging.count
+ tags(:misc).create_tagging(:taggable => posts(:thinking))
+ assert_equal num_tagging +1, Tagging.count
+ end
end
class TestDefaultAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCase
diff --git a/activeresource/lib/active_resource/base.rb b/activeresource/lib/active_resource/base.rb
index 1557e090e1..72ad2f5872 100644
--- a/activeresource/lib/active_resource/base.rb
+++ b/activeresource/lib/active_resource/base.rb
@@ -577,7 +577,7 @@ module ActiveResource
# Default value is <tt>site.path</tt>.
def prefix=(value = '/')
# Replace :placeholders with '#{embedded options[:lookups]}'
- prefix_call = value.gsub(/:\w+/) { |key| "\#{options[#{key}]}" }
+ prefix_call = value.gsub(/:\w+/) { |key| "\#{URI.escape options[#{key}].to_s}" }
# Clear prefix parameters in case they have been cached
@prefix_parameters = nil
@@ -622,7 +622,7 @@ module ActiveResource
#
def element_path(id, prefix_options = {}, query_options = nil)
prefix_options, query_options = split_options(prefix_options) if query_options.nil?
- "#{prefix(prefix_options)}#{collection_name}/#{id}.#{format.extension}#{query_string(query_options)}"
+ "#{prefix(prefix_options)}#{collection_name}/#{URI.escape id.to_s}.#{format.extension}#{query_string(query_options)}"
end
# Gets the new element path for REST resources.
diff --git a/activeresource/test/cases/base_test.rb b/activeresource/test/cases/base_test.rb
index a176c037d5..91b375681b 100644
--- a/activeresource/test/cases/base_test.rb
+++ b/activeresource/test/cases/base_test.rb
@@ -563,6 +563,7 @@ class BaseTest < Test::Unit::TestCase
assert_equal '/people/1/addresses/1.xml', StreetAddress.element_path(1, :person_id => 1)
assert_equal '/people/1/addresses/1.xml', StreetAddress.element_path(1, 'person_id' => 1)
assert_equal '/people/Greg/addresses/1.xml', StreetAddress.element_path(1, 'person_id' => 'Greg')
+ assert_equal '/people/ann%20mary/addresses/ann%20mary.xml', StreetAddress.element_path(:'ann mary', 'person_id' => 'ann mary')
end
def test_module_element_path
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index 9a6da38b1c..2b80bd214f 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -72,10 +72,6 @@ module ActiveSupport #:nodoc:
methods.each { |m| class_eval "def #{m}(*) lock { super } end", __FILE__, __LINE__ }
end
- def get(key)
- (val = assoc(key)) ? val[1] : []
- end
-
locked :concat, :each, :delete_if, :<<
def new_constants_for(frames)
@@ -85,7 +81,18 @@ module ActiveSupport #:nodoc:
next unless mod.is_a?(Module)
new_constants = mod.local_constant_names - prior_constants
- get(mod_name).concat(new_constants)
+
+ # If we are checking for constants under, say, :Object, nested under something
+ # else that is checking for constants also under :Object, make sure the
+ # parent knows that we have found, and taken care of, the constant.
+ #
+ # In particular, this means that since Kernel.require discards the constants
+ # it finds, parents will be notified that about those constants, and not
+ # consider them "new". As a result, they will not be added to the
+ # autoloaded_constants list.
+ each do |key, value|
+ value.concat(new_constants) if key == mod_name
+ end
new_constants.each do |suffix|
constants << ([mod_name, suffix] - ["Object"]).join("::")
diff --git a/activesupport/lib/active_support/deprecation/proxy_wrappers.rb b/activesupport/lib/active_support/deprecation/proxy_wrappers.rb
index dec56715be..b22d0a6941 100644
--- a/activesupport/lib/active_support/deprecation/proxy_wrappers.rb
+++ b/activesupport/lib/active_support/deprecation/proxy_wrappers.rb
@@ -3,6 +3,13 @@ require 'active_support/inflector'
module ActiveSupport
module Deprecation
class DeprecationProxy #:nodoc:
+ def self.new(*args, &block)
+ object = args.first
+
+ return object unless object
+ super
+ end
+
instance_methods.each { |m| undef_method m unless m =~ /^__|^object_id$/ }
# Don't give a deprecation warning on inspect since test/unit and error
diff --git a/activesupport/lib/active_support/notifications.rb b/activesupport/lib/active_support/notifications.rb
index 886d7183eb..ca9f5ae1ac 100644
--- a/activesupport/lib/active_support/notifications.rb
+++ b/activesupport/lib/active_support/notifications.rb
@@ -45,7 +45,7 @@ module ActiveSupport
class << self
attr_writer :notifier
- delegate :publish, :unsubscribe, :to => :notifier
+ delegate :publish, :to => :notifier
def instrument(name, payload = {})
if @instrumenters[name]
diff --git a/activesupport/lib/active_support/xml_mini.rb b/activesupport/lib/active_support/xml_mini.rb
index 38e20d32da..352172027b 100644
--- a/activesupport/lib/active_support/xml_mini.rb
+++ b/activesupport/lib/active_support/xml_mini.rb
@@ -129,12 +129,16 @@ module ActiveSupport
camelize = options.has_key?(:camelize) && options[:camelize]
dasherize = !options.has_key?(:dasherize) || options[:dasherize]
key = key.camelize if camelize
- key = key.dasherize if dasherize
+ key = _dasherize(key) if dasherize
key
end
protected
+ def _dasherize(key)
+ key.gsub(/(?!^[_]*)_(?![_]*$)/, '-')
+ end
+
# TODO: Add support for other encodings
def _parse_binary(bin, entity) #:nodoc:
case entity['encoding']
diff --git a/activesupport/test/autoloading_fixtures/load_path/loaded_constant.rb b/activesupport/test/autoloading_fixtures/load_path/loaded_constant.rb
new file mode 100644
index 0000000000..e3d1218c96
--- /dev/null
+++ b/activesupport/test/autoloading_fixtures/load_path/loaded_constant.rb
@@ -0,0 +1,3 @@
+module LoadedConstant
+end
+
diff --git a/activesupport/test/autoloading_fixtures/loads_constant.rb b/activesupport/test/autoloading_fixtures/loads_constant.rb
new file mode 100644
index 0000000000..0b30dc8bca
--- /dev/null
+++ b/activesupport/test/autoloading_fixtures/loads_constant.rb
@@ -0,0 +1,5 @@
+module LoadsConstant
+end
+
+# The _ = assignment is to prevent warnings
+_ = RequiresConstant
diff --git a/activesupport/test/autoloading_fixtures/requires_constant.rb b/activesupport/test/autoloading_fixtures/requires_constant.rb
new file mode 100644
index 0000000000..14804a0de0
--- /dev/null
+++ b/activesupport/test/autoloading_fixtures/requires_constant.rb
@@ -0,0 +1,5 @@
+require "loaded_constant"
+
+module RequiresConstant
+end
+
diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb
index d7bde185bd..f98d823f00 100644
--- a/activesupport/test/dependencies_test.rb
+++ b/activesupport/test/dependencies_test.rb
@@ -213,6 +213,50 @@ class DependenciesTest < Test::Unit::TestCase
end
end
+ def test_doesnt_break_normal_require
+ path = File.expand_path("../autoloading_fixtures/load_path", __FILE__)
+ original_path = $:.dup
+ original_features = $".dup
+ $:.push(path)
+
+ with_autoloading_fixtures do
+ # The _ = assignments are to prevent warnings
+ _ = RequiresConstant
+ assert defined?(RequiresConstant)
+ assert defined?(LoadedConstant)
+ ActiveSupport::Dependencies.clear
+ _ = RequiresConstant
+ assert defined?(RequiresConstant)
+ assert defined?(LoadedConstant)
+ end
+ ensure
+ remove_constants(:RequiresConstant, :LoadedConstant, :LoadsConstant)
+ $".replace(original_features)
+ $:.replace(original_path)
+ end
+
+ def test_doesnt_break_normal_require_nested
+ path = File.expand_path("../autoloading_fixtures/load_path", __FILE__)
+ original_path = $:.dup
+ original_features = $".dup
+ $:.push(path)
+
+ with_autoloading_fixtures do
+ # The _ = assignments are to prevent warnings
+ _ = LoadsConstant
+ assert defined?(LoadsConstant)
+ assert defined?(LoadedConstant)
+ ActiveSupport::Dependencies.clear
+ _ = LoadsConstant
+ assert defined?(LoadsConstant)
+ assert defined?(LoadedConstant)
+ end
+ ensure
+ remove_constants(:RequiresConstant, :LoadedConstant, :LoadsConstant)
+ $".replace(original_features)
+ $:.replace(original_path)
+ end
+
def failing_test_access_thru_and_upwards_fails
with_autoloading_fixtures do
assert ! defined?(ModuleFolder)
@@ -797,4 +841,11 @@ class DependenciesTest < Test::Unit::TestCase
ensure
ActiveSupport::Dependencies.hook!
end
+
+private
+ def remove_constants(*constants)
+ constants.each do |constant|
+ Object.send(:remove_const, constant) if Object.const_defined?(constant)
+ end
+ end
end
diff --git a/activesupport/test/deprecation/proxy_wrappers_test.rb b/activesupport/test/deprecation/proxy_wrappers_test.rb
new file mode 100644
index 0000000000..c507eff38e
--- /dev/null
+++ b/activesupport/test/deprecation/proxy_wrappers_test.rb
@@ -0,0 +1,22 @@
+require 'abstract_unit'
+require 'active_support/deprecation'
+
+class ProxyWrappersTest < Test::Unit::TestCase
+ Waffles = false
+ NewWaffles = :hamburgers
+
+ def test_deprecated_object_proxy_doesnt_wrap_falsy_objects
+ proxy = ActiveSupport::Deprecation::DeprecatedObjectProxy.new(nil, "message")
+ assert !proxy
+ end
+
+ def test_deprecated_instance_variable_proxy_doesnt_wrap_falsy_objects
+ proxy = ActiveSupport::Deprecation::DeprecatedInstanceVariableProxy.new(nil, :waffles)
+ assert !proxy
+ end
+
+ def test_deprecated_constant_proxy_doesnt_wrap_falsy_objects
+ proxy = ActiveSupport::Deprecation::DeprecatedConstantProxy.new(Waffles, NewWaffles)
+ assert !proxy
+ end
+end \ No newline at end of file
diff --git a/activesupport/test/rescuable_test.rb b/activesupport/test/rescuable_test.rb
index ff77e16edd..1c74ce8b2a 100644
--- a/activesupport/test/rescuable_test.rb
+++ b/activesupport/test/rescuable_test.rb
@@ -9,11 +9,16 @@ end
class MadRonon < StandardError
end
+class CoolError < StandardError
+end
+
class Stargate
attr_accessor :result
include ActiveSupport::Rescuable
+ rescue_from WraithAttack, :with => :sos_first
+
rescue_from WraithAttack, :with => :sos
rescue_from NuclearExplosion do
@@ -45,11 +50,30 @@ class Stargate
def sos
@result = 'killed'
end
+
+ def sos_first
+ @result = 'sos_first'
+ end
+
+end
+
+class CoolStargate < Stargate
+ attr_accessor :result
+
+ include ActiveSupport::Rescuable
+
+ rescue_from CoolError, :with => :sos_cool_error
+
+ def sos_cool_error
+ @result = 'sos_cool_error'
+ end
end
+
class RescueableTest < Test::Unit::TestCase
def setup
@stargate = Stargate.new
+ @cool_stargate = CoolStargate.new
end
def test_rescue_from_with_method
@@ -66,4 +90,17 @@ class RescueableTest < Test::Unit::TestCase
@stargate.dispatch :ronanize
assert_equal 'dex', @stargate.result
end
+
+ def test_rescues_defined_later_are_added_at_end_of_the_rescue_handlers_array
+ expected = ["WraithAttack", "WraithAttack", "NuclearExplosion", "MadRonon"]
+ result = @stargate.send(:rescue_handlers).collect {|e| e.first}
+ assert_equal expected, result
+ end
+
+ def test_children_should_inherit_rescue_defintions_from_parents_and_child_rescue_should_be_appended
+ expected = ["WraithAttack", "WraithAttack", "NuclearExplosion", "MadRonon", "CoolError"]
+ result = @cool_stargate.send(:rescue_handlers).collect {|e| e.first}
+ assert_equal expected, result
+ end
+
end
diff --git a/activesupport/test/test_xml_mini.rb b/activesupport/test/test_xml_mini.rb
new file mode 100644
index 0000000000..585eb15c6e
--- /dev/null
+++ b/activesupport/test/test_xml_mini.rb
@@ -0,0 +1,49 @@
+require 'abstract_unit'
+require 'active_support/xml_mini'
+
+class XmlMiniTest < Test::Unit::TestCase
+ def test_rename_key_dasherizes_by_default
+ assert_equal "my-key", ActiveSupport::XmlMini.rename_key("my_key")
+ end
+
+ def test_rename_key_does_nothing_with_dasherize_true
+ assert_equal "my-key", ActiveSupport::XmlMini.rename_key("my_key", :dasherize => true)
+ end
+
+ def test_rename_key_does_nothing_with_dasherize_false
+ assert_equal "my_key", ActiveSupport::XmlMini.rename_key("my_key", :dasherize => false)
+ end
+
+ def test_rename_key_camelizes_with_camelize_true
+ assert_equal "MyKey", ActiveSupport::XmlMini.rename_key("my_key", :camelize => true)
+ end
+
+ def test_rename_key_camelizes_with_camelize_true
+ assert_equal "MyKey", ActiveSupport::XmlMini.rename_key("my_key", :camelize => true)
+ end
+
+ def test_rename_key_does_not_dasherize_leading_underscores
+ assert_equal "_id", ActiveSupport::XmlMini.rename_key("_id")
+ end
+
+ def test_rename_key_with_leading_underscore_dasherizes_interior_underscores
+ assert_equal "_my-key", ActiveSupport::XmlMini.rename_key("_my_key")
+ end
+
+ def test_rename_key_does_not_dasherize_trailing_underscores
+ assert_equal "id_", ActiveSupport::XmlMini.rename_key("id_")
+ end
+
+ def test_rename_key_with_trailing_underscore_dasherizes_interior_underscores
+ assert_equal "my-key_", ActiveSupport::XmlMini.rename_key("my_key_")
+ end
+
+ def test_rename_key_does_not_dasherize_multiple_leading_underscores
+ assert_equal "__id", ActiveSupport::XmlMini.rename_key("__id")
+ end
+
+ def test_rename_key_does_not_dasherize_multiple_leading_underscores
+ assert_equal "id__", ActiveSupport::XmlMini.rename_key("id__")
+ end
+
+end
diff --git a/rails.gemspec b/rails.gemspec
index e3f811966c..db13653ebc 100644
--- a/rails.gemspec
+++ b/rails.gemspec
@@ -25,5 +25,5 @@ Gem::Specification.new do |s|
s.add_dependency('activeresource', version)
s.add_dependency('actionmailer', version)
s.add_dependency('railties', version)
- s.add_dependency('bundler', '>= 1.0.0.beta.5')
+ s.add_dependency('bundler', '>= 1.0.0.beta.10')
end
diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb
index 67a9a6030d..fdfceb14ce 100644
--- a/railties/lib/rails/generators/base.rb
+++ b/railties/lib/rails/generators/base.rb
@@ -3,7 +3,7 @@ begin
rescue LoadError
puts "Thor is not available.\nIf you ran this command from a git checkout " \
"of Rails, please make sure thor is installed,\nand run this command " \
- "as `ruby /path/to/rails new myapp --dev`"
+ "as `ruby #{$0} #{ARGV.join(" ")} --dev`"
exit
end
diff --git a/railties/railties.gemspec b/railties/railties.gemspec
index 38dcb17ff1..d76b74190b 100644
--- a/railties/railties.gemspec
+++ b/railties/railties.gemspec
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
s.has_rdoc = false
s.add_dependency('rake', '>= 0.8.3')
- s.add_dependency('thor', '~> 0.13.7')
+ s.add_dependency('thor', '~> 0.14.0')
s.add_dependency('activesupport', version)
s.add_dependency('actionpack', version)
end
diff --git a/railties/test/generators/app_generator_test.rb b/railties/test/generators/app_generator_test.rb
index aca30e92b6..67a878e926 100644
--- a/railties/test/generators/app_generator_test.rb
+++ b/railties/test/generators/app_generator_test.rb
@@ -172,7 +172,7 @@ class AppGeneratorTest < Rails::Generators::TestCase
template.instance_eval "def read; self; end" # Make the string respond to read
generator([destination_root], :template => path).expects(:open).with(path, 'Accept' => 'application/x-thor-template').returns(template)
- assert_match /It works!/, silence(:stdout){ generator.invoke }
+ assert_match /It works!/, silence(:stdout){ generator.invoke_all }
end
def test_usage_read_from_file
@@ -196,14 +196,14 @@ class AppGeneratorTest < Rails::Generators::TestCase
def test_dev_option
generator([destination_root], :dev => true).expects(:run).with("#{@bundle_command} install")
- silence(:stdout){ generator.invoke }
+ silence(:stdout){ generator.invoke_all }
rails_path = File.expand_path('../../..', Rails.root)
assert_file 'Gemfile', /^gem\s+["']rails["'],\s+:path\s+=>\s+["']#{Regexp.escape(rails_path)}["']$/
end
def test_edge_option
generator([destination_root], :edge => true).expects(:run).with("#{@bundle_command} install")
- silence(:stdout){ generator.invoke }
+ silence(:stdout){ generator.invoke_all }
assert_file 'Gemfile', /^gem\s+["']rails["'],\s+:git\s+=>\s+["']#{Regexp.escape("git://github.com/rails/rails.git")}["']$/
end
@@ -267,7 +267,7 @@ class CustomAppGeneratorTest < Rails::Generators::TestCase
template.instance_eval "def read; self; end" # Make the string respond to read
generator([destination_root], :builder => path).expects(:open).with(path, 'Accept' => 'application/x-thor-template').returns(template)
- capture(:stdout) { generator.invoke }
+ capture(:stdout) { generator.invoke_all }
DEFAULT_APP_FILES.each{ |path| assert_no_file path }
end