Skip to content
Browse files

Merge commit 'rails/master'

  • Loading branch information...
2 parents 260c847 + 92bff2e commit 084e4a2dd4322c9ea748a426cb37bf90ab83613d @miloops miloops committed Jul 1, 2009
View
3 actionmailer/test/abstract_unit.rb
@@ -1,9 +1,6 @@
require 'rubygems'
require 'test/unit'
-gem 'mocha', '>= 0.9.5'
-require 'mocha'
-
$:.unshift "#{File.dirname(__FILE__)}/../lib"
$:.unshift "#{File.dirname(__FILE__)}/../../activesupport/lib"
$:.unshift "#{File.dirname(__FILE__)}/../../actionpack/lib"
View
2 actionpack/lib/action_view/template/handlers/erb.rb
@@ -17,7 +17,7 @@ class ERB < TemplateHandler
def compile(template)
require 'erb'
- magic = $1 if template.source =~ /\A(<%#.*coding:\s*(\S+)\s*-?%>)/
+ magic = $1 if template.source =~ /\A(<%#.*coding[:=]\s*(\S+)\s*-?%>)/
erb = "#{magic}<% __in_erb_template=true %>#{template.source}"
::ERB.new(erb, nil, erb_trim_mode, '@output_buffer').src
end
View
3 actionpack/test/old_base/abstract_unit.rb
@@ -12,9 +12,6 @@
require 'stringio'
require 'test/unit'
-gem 'mocha', '>= 0.9.5'
-require 'mocha'
-
begin
require 'ruby-debug'
Debugger.settings[:autoeval] = true
View
2 activemodel/test/cases/helper.rb
@@ -10,8 +10,6 @@
require 'rubygems'
require 'test/unit'
-gem 'mocha', '>= 0.9.5'
-require 'mocha'
begin
require 'ruby-debug'
View
7 activerecord/lib/active_record/base.rb
@@ -2864,6 +2864,13 @@ def frozen?
@attributes.frozen?
end
+ # Returns duplicated record with unfreezed attributes.
+ def dup
+ obj = super
+ obj.instance_variable_set('@attributes', instance_variable_get('@attributes').dup)
+ obj
+ end
+
# Returns +true+ if the record is read only. Records loaded through joins with piggy-back
# attributes will be marked as read only since they cannot be saved.
def readonly?
View
4 activerecord/test/cases/base_test.rb
@@ -2116,4 +2116,8 @@ def test_create_with_custom_timestamps
assert_equal custom_datetime, parrot[attribute]
end
end
+
+ def test_dup
+ assert !Minimalistic.new.freeze.dup.frozen?
+ end
end
View
2 activerecord/test/cases/helper.rb
@@ -6,8 +6,6 @@
require 'rubygems'
require 'test/unit'
require 'stringio'
-gem 'mocha', '>= 0.9.5'
-require 'mocha'
require 'active_record'
require 'active_record/test_case'
View
4 activeresource/test/abstract_unit.rb
@@ -1,8 +1,6 @@
require 'rubygems'
require 'test/unit'
-
-gem 'mocha', '>= 0.9.5'
-require 'mocha'
+require 'active_support/test_case'
$:.unshift "#{File.dirname(__FILE__)}/../lib"
require 'active_resource'
View
2 activesupport/lib/active_support/cache/memory_store.rb
@@ -26,7 +26,7 @@ def read(name, options = nil)
def write(name, value, options = nil)
super
- @data[name] = value.freeze
+ @data[name] = (value.duplicable? ? value.dup : value).freeze
end
def delete(name, options = nil)
View
17 activesupport/lib/active_support/core_ext/module/delegation.rb
@@ -108,14 +108,21 @@ def delegate(*methods)
prefix = options[:prefix] && "#{options[:prefix] == true ? to : options[:prefix]}_"
- allow_nil = options[:allow_nil] && "#{to} && "
-
- file, line = caller[0].split(":")
+ file, line = caller.first.split(':', 2)
+ line = line.to_i
methods.each do |method|
- module_eval(<<-EOS, file, line.to_i)
+ on_nil =
+ if options[:allow_nil]
+ 'return'
+ else
+ %(raise "#{self}##{prefix}#{method} delegated to #{to}.#{method}, but #{to} is nil: \#{self.inspect}")
+ end
+
+ module_eval(<<-EOS, file, line)
def #{prefix}#{method}(*args, &block) # def customer_name(*args, &block)
- #{allow_nil}#{to}.__send__(#{method.inspect}, *args, &block) # client && client.__send__(:name, *args, &block)
+ #{on_nil} if #{to}.nil?
+ #{to}.__send__(#{method.inspect}, *args, &block) # client && client.__send__(:name, *args, &block)
end # end
EOS
end
View
2 activesupport/lib/active_support/inflector.rb
@@ -183,7 +183,7 @@ def camelize(lower_case_and_underscored_word, first_letter_in_uppercase = true)
if first_letter_in_uppercase
lower_case_and_underscored_word.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
else
- lower_case_and_underscored_word.first.downcase + camelize(lower_case_and_underscored_word)[1..-1]
+ lower_case_and_underscored_word.to_s.first.downcase + camelize(lower_case_and_underscored_word)[1..-1]
end
end
View
14 activesupport/lib/active_support/json/encoding.rb
@@ -1,5 +1,7 @@
-# encoding: binary
+# encoding: utf-8
require 'active_support/core_ext/array/wrap'
+require 'active_support/core_ext/hash/except'
+require 'active_support/core_ext/hash/slice'
require 'active_support/core_ext/module/delegation'
require 'active_support/core_ext/object/instance_variables'
require 'active_support/deprecation'
@@ -95,12 +97,14 @@ def escape_html_entities_in_json=(value)
def escape(string)
string = string.dup.force_encoding(::Encoding::BINARY) if string.respond_to?(:force_encoding)
- json = '"' + string.gsub(escape_regex) { |s| ESCAPED_CHARS[s] }
- json.gsub(/([\xC0-\xDF][\x80-\xBF]|
+ json = string.
+ gsub(escape_regex) { |s| ESCAPED_CHARS[s] }.
+ gsub(/([\xC0-\xDF][\x80-\xBF]|
[\xE0-\xEF][\x80-\xBF]{2}|
[\xF0-\xF7][\x80-\xBF]{3})+/nx) { |s|
- s.unpack("U*").pack("n*").unpack("H*")[0].gsub(/.{4}/, '\\\\u\&')
- } + '"'
+ s.unpack("U*").pack("n*").unpack("H*")[0].gsub(/.{4}/n, '\\\\u\&')
+ }
+ %("#{json}")
end
end
View
18 activesupport/lib/active_support/test_case.rb
@@ -1,12 +1,3 @@
-begin
- gem 'mocha', '>= 0.9.3'
- require 'mocha'
-rescue LoadError
- # Fake Mocha::ExpectationError so we can rescue it in #run. Bleh.
- Object.const_set :Mocha, Module.new
- Mocha.const_set :ExpectationError, Class.new(StandardError)
-end
-
require 'test/unit/testcase'
require 'active_support/testing/setup_and_teardown'
require 'active_support/testing/assertions'
@@ -15,6 +6,15 @@
require 'active_support/testing/pending'
require 'active_support/testing/isolation'
+begin
+ gem 'mocha', ">= 0.9.7"
+ require 'mocha'
+rescue LoadError
+ # Fake Mocha::ExpectationError so we can rescue it in #run. Bleh.
+ Object.const_set :Mocha, Module.new
+ Mocha.const_set :ExpectationError, Class.new(StandardError)
+end
+
module ActiveSupport
class TestCase < ::Test::Unit::TestCase
if defined? MiniTest
View
1 activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_exceptions_test.rb
@@ -2,7 +2,6 @@
require 'rubygems'
require 'test/unit'
-require 'mocha'
require 'i18n'
require 'active_support'
View
1 activesupport/lib/active_support/vendor/i18n-0.1.3/test/i18n_test.rb
@@ -2,7 +2,6 @@
require 'rubygems'
require 'test/unit'
-require 'mocha'
require 'i18n'
require 'active_support'
View
1 activesupport/lib/active_support/vendor/i18n-0.1.3/test/simple_backend_test.rb
@@ -3,7 +3,6 @@
require 'rubygems'
require 'test/unit'
-require 'mocha'
require 'i18n'
require 'time'
require 'yaml'
View
3 activesupport/test/abstract_unit.rb
@@ -3,9 +3,6 @@
require 'rubygems'
require 'test/unit'
-gem 'mocha', '>= 0.9.5'
-require 'mocha'
-
ENV['NO_RELOAD'] = '1'
$:.unshift "#{File.dirname(__FILE__)}/../lib"
require 'active_support'
View
6 activesupport/test/caching_test.rb
@@ -176,6 +176,12 @@ def test_store_objects_should_be_immutable
assert_raise(ActiveSupport::FrozenObjectError) { @cache.read('foo').gsub!(/.*/, 'baz') }
assert_equal 'bar', @cache.read('foo')
end
+
+ def test_original_store_objects_should_not_be_immutable
+ bar = 'bar'
+ @cache.write('foo', bar)
+ assert_nothing_raised { bar.gsub!(/.*/, 'baz') }
+ end
end
uses_memcached 'memcached backed store' do
View
2 activesupport/test/core_ext/module_test.rb
@@ -142,7 +142,7 @@ def test_delegation_with_allow_nil_and_nil_value_and_prefix
def test_delegation_without_allow_nil_and_nil_value
david = Someone.new("David")
- assert_raise(NoMethodError) { david.street }
+ assert_raise(RuntimeError) { david.street }
end
def test_parent
View
2 activesupport/test/fixtures/omgomg.rb
@@ -0,0 +1,2 @@
+class OmgOmg
+end
View
6 activesupport/test/inflector_test.rb
@@ -202,6 +202,12 @@ def test_underscore_to_lower_camel
end
end
+ def test_symbol_to_lower_camel
+ SymbolToLowerCamel.each do |symbol, lower_camel|
+ assert_equal(lower_camel, ActiveSupport::Inflector.camelize(symbol, false))
+ end
+ end
+
%w{plurals singulars uncountables humans}.each do |inflection_type|
class_eval "
def test_clear_#{inflection_type}
View
7 activesupport/test/inflector_test_cases.rb
@@ -117,6 +117,13 @@ module InflectorTestCases
"area51_controller" => "area51Controller"
}
+ SymbolToLowerCamel = {
+ :product => 'product',
+ :special_guest => 'specialGuest',
+ :application_controller => 'applicationController',
+ :area51_controller => 'area51Controller'
+ }
+
CamelToUnderscoreWithoutReverse = {
"HTMLTidy" => "html_tidy",
"HTMLTidyGenerator" => "html_tidy_generator",
View
10 activesupport/test/isolation_test.rb
@@ -50,13 +50,15 @@ def teardown
end
test "resets requires one" do
- assert !defined?(Racc)
- require 'racc/parser'
+ assert !defined?(OmgOmg)
+ assert_equal 0, $LOADED_FEATURES.grep(/fixtures\/omgomg/).size
+ require File.expand_path(File.join(File.dirname(__FILE__), "fixtures", "omgomg"))
end
test "resets requires two" do
- assert !defined?(Racc)
- require 'racc/parser'
+ assert !defined?(OmgOmg)
+ assert_equal 0, $LOADED_FEATURES.grep(/fixtures\/omgomg/).size
+ require File.expand_path(File.join(File.dirname(__FILE__), "fixtures", "omgomg"))
end
end
else
View
9 activesupport/test/json/encoding_test.rb
@@ -75,8 +75,13 @@ def test_hash_encoding
def test_utf8_string_encoded_properly_when_kcode_is_utf8
with_kcode 'UTF8' do
- assert_equal '"\\u20ac2.99"', ActiveSupport::JSON.encode('€2.99')
- assert_equal '"\\u270e\\u263a"', ActiveSupport::JSON.encode('✎☺')
+ result = ActiveSupport::JSON.encode('€2.99')
+ assert_equal '"\\u20ac2.99"', result
+ assert_equal(Encoding::UTF_8, result.encoding) if result.respond_to?(:encoding)
+
+ result = ActiveSupport::JSON.encode('✎☺')
+ assert_equal '"\\u270e\\u263a"', result
+ assert_equal(Encoding::UTF_8, result.encoding) if result.respond_to?(:encoding)
end
end
View
2 ci/geminstaller.yml
@@ -7,7 +7,7 @@ gems:
- name: memcache-client
version: >= 1.5.0
- name: mocha
- version: >= 0.9.5
+ version: >= 0.9.7
- name: mysql
#version: >= 2.7
version: = 2.7
View
5 railties/lib/test_help.rb
@@ -30,7 +30,10 @@ def create_fixtures(*table_names, &block)
begin
require_library_or_gem 'ruby-debug'
Debugger.start
- Debugger.settings[:autoeval] = true if Debugger.respond_to?(:settings)
+ if Debugger.respond_to?(:settings)
+ Debugger.settings[:autoeval] = true
+ Debugger.settings[:autolist] = 1
+ end
rescue LoadError
# ruby-debug wasn't available so neither can the debugging be
end
View
3 railties/test/abstract_unit.rb
@@ -12,9 +12,6 @@
require 'rubygems'
require 'test/unit'
-gem 'mocha', '>= 0.9.5'
-require 'mocha'
-
require 'active_support'
require 'active_support/test_case'

0 comments on commit 084e4a2

Please sign in to comment.
Something went wrong with that request. Please try again.