Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 3.2.x is now compatible with Ruby 2.0.0 #9406

Merged
merged 14 commits into from Feb 24, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 0 additions & 3 deletions .travis.yml
Expand Up @@ -13,9 +13,6 @@ env:
- "GEM=ar:mysql2"
- "GEM=ar:sqlite3"
- "GEM=ar:postgresql"
matrix:
allow_failures:
- rvm: 2.0.0
notifications:
email: false
irc:
Expand Down
3 changes: 2 additions & 1 deletion actionpack/lib/action_controller/metal/compatibility.rb
Expand Up @@ -58,7 +58,8 @@ def _handle_method_missing
end

def method_for_action(action_name)
super || (respond_to?(:method_missing) && "_handle_method_missing")
super || ((self.class.public_method_defined?(:method_missing) ||
self.class.protected_method_defined?(:method_missing)) && "_handle_method_missing")
end
end
end
10 changes: 2 additions & 8 deletions actionpack/lib/action_controller/metal/hide_actions.rb
Expand Up @@ -27,20 +27,14 @@ def hide_action(*args)
self.hidden_actions = hidden_actions.dup.merge(args.map(&:to_s)).freeze
end

def inherited(klass)
klass.class_eval { @visible_actions = {} }
super
end

def visible_action?(action_name)
return @visible_actions[action_name] if @visible_actions.key?(action_name)
@visible_actions[action_name] = !hidden_actions.include?(action_name)
action_methods.include?(action_name)
end

# Overrides AbstractController::Base#action_methods to remove any methods
# that are listed as hidden methods.
def action_methods
@action_methods ||= Set.new(super.reject { |name| hidden_actions.include?(name) })
@action_methods ||= Set.new(super.reject { |name| hidden_actions.include?(name) }).freeze
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion actionpack/test/template/html-scanner/sanitizer_test.rb
Expand Up @@ -210,7 +210,7 @@ def test_should_not_fall_for_ridiculous_hack

# TODO: Clean up
def test_should_sanitize_attributes
assert_sanitized %(<SPAN title="'><script>alert()</script>">blah</SPAN>), %(<span title="'&gt;&lt;script&gt;alert()&lt;/script&gt;">blah</span>)
assert_sanitized %(<SPAN title="'><script>alert()</script>">blah</SPAN>), %(<span title="#{CGI.escapeHTML "'><script>alert()</script>"}">blah</span>)
end

def test_should_sanitize_illegal_style_properties
Expand Down
1 change: 1 addition & 0 deletions actionpack/test/template/template_test.rb
@@ -1,3 +1,4 @@
# encoding: US-ASCII
require "abstract_unit"
require "logger"

Expand Down
@@ -1,7 +1,6 @@
require 'active_support/hash_with_indifferent_access'

class Hash

# Returns an <tt>ActiveSupport::HashWithIndifferentAccess</tt> out of its receiver:
#
# {:a => 1}.with_indifferent_access["a"] # => 1
Expand Down
4 changes: 2 additions & 2 deletions activesupport/lib/active_support/core_ext/hash/slice.rb
Expand Up @@ -13,7 +13,7 @@ class Hash
# valid_keys = [:mass, :velocity, :time]
# search(options.slice(*valid_keys))
def slice(*keys)
keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true)
hash = self.class.new
keys.each { |k| hash[k] = self[k] if has_key?(k) }
hash
Expand All @@ -23,7 +23,7 @@ def slice(*keys)
# Returns a hash contained the removed key/value pairs
# {:a => 1, :b => 2, :c => 3, :d => 4}.slice!(:a, :b) # => {:c => 3, :d => 4}
def slice!(*keys)
keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key)
keys = keys.map! { |key| convert_key(key) } if respond_to?(:convert_key, true)
omit = slice(*self.keys - keys)
hash = slice(*keys)
replace(hash)
Expand Down
2 changes: 2 additions & 0 deletions activesupport/lib/active_support/core_ext/kernel/reporting.rb
@@ -1,4 +1,6 @@
require 'rbconfig'
require 'stringio'

module Kernel
# Sets $VERBOSE to nil for the duration of the block and back to its original value afterwards.
#
Expand Down
Expand Up @@ -6,7 +6,7 @@

module ActiveSupport
class HashWithIndifferentAccess < Hash

# Always returns true, so that <tt>Array#extract_options!</tt> finds members of this class.
def extractable_options?
true
Expand Down
12 changes: 10 additions & 2 deletions activesupport/lib/active_support/testing/isolation.rb
Expand Up @@ -12,8 +12,8 @@ def initialize(exception)
end

class ProxyTestResult
def initialize
@calls = []
def initialize(calls = [])
@calls = calls
end

def add_error(e)
Expand All @@ -27,6 +27,14 @@ def __replay__(result)
end
end

def marshal_dump
@calls
end

def marshal_load(calls)
initialize(calls)
end

def method_missing(name, *args)
@calls << [name, args]
end
Expand Down
1 change: 0 additions & 1 deletion activesupport/test/caching_test.rb
Expand Up @@ -690,7 +690,6 @@ def setup
@data = @cache.instance_variable_get(:@data)
@cache.clear
@cache.silence!
@cache.logger = Logger.new("/dev/null")
end

include CacheStoreBehavior
Expand Down
1 change: 0 additions & 1 deletion activesupport/test/ordered_hash_test.rb
Expand Up @@ -221,7 +221,6 @@ def test_alternate_initialization_with_array
alternate = ActiveSupport::OrderedHash[ [
[1, 2],
[3, 4],
"bad key value pair",
[ 'missing value' ]
]]

Expand Down
3 changes: 3 additions & 0 deletions activesupport/test/test_case_test.rb
Expand Up @@ -16,6 +16,9 @@ def puke(klass, name, e)
def options
nil
end

def record(*args)
end
end

if defined?(MiniTest::Assertions) && TestCase < MiniTest::Assertions
Expand Down
Expand Up @@ -214,6 +214,18 @@ def finish_template

public_task :apply_rails_template, :run_bundle

def name
@name ||= begin
# same as ActiveSupport::Inflector#underscore except not replacing '-'
underscored = original_name.dup
underscored.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
underscored.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
underscored.downcase!

underscored
end
end

protected

def app_templates_dir
Expand Down Expand Up @@ -254,18 +266,6 @@ def original_name
@original_name ||= File.basename(destination_root)
end

def name
@name ||= begin
# same as ActiveSupport::Inflector#underscore except not replacing '-'
underscored = original_name.dup
underscored.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
underscored.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
underscored.downcase!

underscored
end
end

def camelized
@camelized ||= name.gsub(/\W/, '_').squeeze('_').camelize
end
Expand Down
1 change: 1 addition & 0 deletions railties/test/application/assets_test.rb
Expand Up @@ -2,6 +2,7 @@
require 'isolation/abstract_unit'
require 'active_support/core_ext/kernel/reporting'
require 'rack/test'
require 'yaml'

module ApplicationTests
class AssetsTest < Test::Unit::TestCase
Expand Down
15 changes: 11 additions & 4 deletions railties/test/application/initializers/active_record_test.rb
Expand Up @@ -23,10 +23,17 @@ def teardown
boot_rails
simple_controller

get '/foo'
assert last_response.body.include?("We're sorry, but something went wrong (500)")
# ActiveSupport::LogSubscriber.flush_all! in lib/rails/rack/logger.rb blew up in Ruby 2.0
# because it tries to open the database. This behavior doesn't happen in Ruby 1.9.3.
# However, regardless, the server blew up.
if RUBY_VERSION >= '2.0.0'
assert_raises (Errno::ENOENT) { get '/foo' }
else
get '/foo'
assert last_response.body.include?("We're sorry, but something went wrong (500)")
end
end

test "uses DATABASE_URL env var when config/database.yml doesn't exist" do
database_path = "/db/foo.sqlite3"
FileUtils.rm_rf("#{app_path}/config/database.yml")
Expand All @@ -35,7 +42,7 @@ def teardown

get '/foo'
assert_equal 'foo', last_response.body

# clean up
FileUtils.rm("#{app_path}/#{database_path}")
end
Expand Down
4 changes: 2 additions & 2 deletions railties/test/application/route_inspect_test.rb
Expand Up @@ -18,7 +18,7 @@ def setup

def test_displaying_routes_for_engines
engine = Class.new(Rails::Engine) do
def self.to_s
def self.inspect
"Blog::Engine"
end
end
Expand Down Expand Up @@ -136,7 +136,7 @@ def test_rake_routes_shows_route_with_rack_app

def test_rake_routes_shows_route_with_rack_app_nested_with_dynamic_constraints
constraint = Class.new do
def to_s
def inspect
"( my custom constraint )"
end
end
Expand Down