From fe4fce80f3ee80b089fca482f04788af0b9d4d17 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Thu, 21 Feb 2013 18:47:18 -0500 Subject: Add in missing requires --- activesupport/lib/active_support/core_ext/kernel/reporting.rb | 2 ++ railties/test/application/assets_test.rb | 1 + 2 files changed, 3 insertions(+) diff --git a/activesupport/lib/active_support/core_ext/kernel/reporting.rb b/activesupport/lib/active_support/core_ext/kernel/reporting.rb index 526b8378a5..84986dff3c 100644 --- a/activesupport/lib/active_support/core_ext/kernel/reporting.rb +++ b/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. # diff --git a/railties/test/application/assets_test.rb b/railties/test/application/assets_test.rb index 9e9702efb6..adec9533a9 100644 --- a/railties/test/application/assets_test.rb +++ b/railties/test/application/assets_test.rb @@ -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 -- cgit v1.2.3 From 9a0cdc68b5b0fc08e60069cb5512bf2ad6b2a76b Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Thu, 24 May 2012 14:55:38 -0700 Subject: `name` should be public. --- .../rails/plugin_new/plugin_new_generator.rb | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb index 6c53d8bebb..1b7f5dee2a 100644 --- a/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb +++ b/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb @@ -214,6 +214,18 @@ task :default => :test 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 @@ -254,18 +266,6 @@ task :default => :test @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 -- cgit v1.2.3 From b59b72a5aeb799ddaa43dc7ed8ef8101a6c95896 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Thu, 21 Feb 2013 20:21:24 -0500 Subject: Fix failing test case when no database.yml --- .../test/application/initializers/active_record_test.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/railties/test/application/initializers/active_record_test.rb b/railties/test/application/initializers/active_record_test.rb index edf78a8a0a..b62943a278 100644 --- a/railties/test/application/initializers/active_record_test.rb +++ b/railties/test/application/initializers/active_record_test.rb @@ -23,10 +23,17 @@ module ApplicationTests 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") @@ -35,7 +42,7 @@ module ApplicationTests get '/foo' assert_equal 'foo', last_response.body - + # clean up FileUtils.rm("#{app_path}/#{database_path}") end -- cgit v1.2.3 From 45e9cac12ca99a51ef10e5ee423a6712818ae145 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Thu, 21 Feb 2013 21:24:02 -0500 Subject: Define #inspect instead of #to_s Ruby 2.0 Object#inspect does not call #to_s by default anymore. --- railties/test/application/route_inspect_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/railties/test/application/route_inspect_test.rb b/railties/test/application/route_inspect_test.rb index 5c920cb33a..dea0ee71c9 100644 --- a/railties/test/application/route_inspect_test.rb +++ b/railties/test/application/route_inspect_test.rb @@ -18,7 +18,7 @@ module ApplicationTests def test_displaying_routes_for_engines engine = Class.new(Rails::Engine) do - def self.to_s + def self.inspect "Blog::Engine" end end @@ -136,7 +136,7 @@ module ApplicationTests 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 -- cgit v1.2.3 From 7cc26fd15e27c4a13705a844538bebfdd0461729 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 20 Mar 2012 09:58:42 -0700 Subject: search private and protected methods for convert_key --- activesupport/lib/active_support/core_ext/hash/indifferent_access.rb | 1 - activesupport/lib/active_support/core_ext/hash/slice.rb | 4 ++-- activesupport/lib/active_support/hash_with_indifferent_access.rb | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb b/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb index 7d54c9fae6..e5042c6c18 100644 --- a/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb +++ b/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb @@ -1,7 +1,6 @@ require 'active_support/hash_with_indifferent_access' class Hash - # Returns an ActiveSupport::HashWithIndifferentAccess out of its receiver: # # {:a => 1}.with_indifferent_access["a"] # => 1 diff --git a/activesupport/lib/active_support/core_ext/hash/slice.rb b/activesupport/lib/active_support/core_ext/hash/slice.rb index 0484d8e5d8..a983cae39e 100644 --- a/activesupport/lib/active_support/core_ext/hash/slice.rb +++ b/activesupport/lib/active_support/core_ext/hash/slice.rb @@ -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 @@ -23,7 +23,7 @@ class Hash # 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) diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb index 9e7cb76307..9dc93de5a9 100644 --- a/activesupport/lib/active_support/hash_with_indifferent_access.rb +++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb @@ -6,7 +6,7 @@ require 'active_support/core_ext/hash/keys' module ActiveSupport class HashWithIndifferentAccess < Hash - + # Always returns true, so that Array#extract_options! finds members of this class. def extractable_options? true -- cgit v1.2.3 From 2a5f6d8fe6898f2570ba66382336d56894a43322 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 12 Nov 2012 18:17:06 -0800 Subject: Ruby 2.0.0 defaults source encoding to utf-8 so we need to specifically tag this file with us-ascii --- actionpack/test/template/template_test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/actionpack/test/template/template_test.rb b/actionpack/test/template/template_test.rb index 56943381d8..b7f785fe3a 100644 --- a/actionpack/test/template/template_test.rb +++ b/actionpack/test/template/template_test.rb @@ -1,3 +1,4 @@ +# encoding: US-ASCII require "abstract_unit" require "logger" -- cgit v1.2.3 From 42d7927c22a2c219d6145d9375be65a04a83dce3 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 6 Oct 2012 21:06:10 -0700 Subject: Ruby 2 compat. CGI.escapeHTML has changed the way it escapes apostrophes a few times, so fix up the test to work with however it chooses to escape. --- actionpack/test/template/html-scanner/sanitizer_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actionpack/test/template/html-scanner/sanitizer_test.rb b/actionpack/test/template/html-scanner/sanitizer_test.rb index 62ad6be680..844484ee47 100644 --- a/actionpack/test/template/html-scanner/sanitizer_test.rb +++ b/actionpack/test/template/html-scanner/sanitizer_test.rb @@ -210,7 +210,7 @@ class SanitizerTest < ActionController::TestCase # TODO: Clean up def test_should_sanitize_attributes - assert_sanitized %(blah), %(blah) + assert_sanitized %(blah), %("}">blah) end def test_should_sanitize_illegal_style_properties -- cgit v1.2.3 From abf0c710210440e50b33b3e708b1e7e1dfbf9d65 Mon Sep 17 00:00:00 2001 From: thedarkone Date: Sat, 30 Jun 2012 17:09:12 +0200 Subject: There is already a Set of non-hidden action_names lying around. --- actionpack/lib/action_controller/metal/hide_actions.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/actionpack/lib/action_controller/metal/hide_actions.rb b/actionpack/lib/action_controller/metal/hide_actions.rb index b55c4643be..109484d88c 100644 --- a/actionpack/lib/action_controller/metal/hide_actions.rb +++ b/actionpack/lib/action_controller/metal/hide_actions.rb @@ -27,20 +27,14 @@ module ActionController 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 -- cgit v1.2.3 From 979e198c14a95010aca17b6e640f386961360794 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Fri, 22 Feb 2013 14:26:20 -0500 Subject: Check for `method_missing` in public and protected Ruby 2.0 changed the behavior of `respond_to?` without argument to return only search for public method. We actually want to perform the action only if `method_missing` is either in public or protected. --- actionpack/lib/action_controller/metal/compatibility.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/actionpack/lib/action_controller/metal/compatibility.rb b/actionpack/lib/action_controller/metal/compatibility.rb index de3354d4f9..9d1ff8cbe4 100644 --- a/actionpack/lib/action_controller/metal/compatibility.rb +++ b/actionpack/lib/action_controller/metal/compatibility.rb @@ -58,7 +58,8 @@ module ActionController 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 -- cgit v1.2.3 From 0190dcae3c7d4dba5d8b322c04236feea22fc0f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Mon, 5 Nov 2012 15:12:09 -0200 Subject: Make the tests pass with minitest 4.2 --- activesupport/test/test_case_test.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/activesupport/test/test_case_test.rb b/activesupport/test/test_case_test.rb index c4653b1ae6..ab74d579fc 100644 --- a/activesupport/test/test_case_test.rb +++ b/activesupport/test/test_case_test.rb @@ -16,6 +16,9 @@ module ActiveSupport def options nil end + + def record(*args) + end end if defined?(MiniTest::Assertions) && TestCase < MiniTest::Assertions -- cgit v1.2.3 From 5693d444686d84d403de5af5d3e23ffe8147001d Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sat, 6 Oct 2012 20:57:22 -0700 Subject: Ruby 2 compat. Hash[] now raises on bad elements rather than ignoring them. No sense over-testing this MRI-specific behavior. See ruby/ruby@8d6add973ebcb3b4c1efbfaf07786550a3e219af --- activesupport/test/ordered_hash_test.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/activesupport/test/ordered_hash_test.rb b/activesupport/test/ordered_hash_test.rb index 0b5f912dc4..a7fd9402c8 100644 --- a/activesupport/test/ordered_hash_test.rb +++ b/activesupport/test/ordered_hash_test.rb @@ -221,7 +221,6 @@ class OrderedHashTest < Test::Unit::TestCase alternate = ActiveSupport::OrderedHash[ [ [1, 2], [3, 4], - "bad key value pair", [ 'missing value' ] ]] -- cgit v1.2.3 From 8598633cc1d5ea402f8b49b1f71cd92180cc1138 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Fri, 22 Feb 2013 17:29:08 -0500 Subject: Do not redirect cache logger to /dev/null in test For some reason, redirecting cache's logger to '/dev/null' resulting in a test failures and LoadError. I think it's because of Thread issue. Instead of trying to make every logger threadsafe for Rails 3.2, I think it's better to just don't set the logger for now. (Note: resetting the logger back to original value in the teardown block didn't fix the problem.) --- activesupport/test/caching_test.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/activesupport/test/caching_test.rb b/activesupport/test/caching_test.rb index c4c753caed..6db1746672 100644 --- a/activesupport/test/caching_test.rb +++ b/activesupport/test/caching_test.rb @@ -690,7 +690,6 @@ uses_memcached 'memcached backed store' do @data = @cache.instance_variable_get(:@data) @cache.clear @cache.silence! - @cache.logger = Logger.new("/dev/null") end include CacheStoreBehavior -- cgit v1.2.3 From 621b5b7f0e608bc916a66a6e046f11485317949c Mon Sep 17 00:00:00 2001 From: SHIBATA Hiroshi Date: Sat, 29 Dec 2012 14:07:09 +0900 Subject: added marshal_load and marshal_dump for ProxyTestResult. Behavior of method_missing with Marshal.dump and Marshal.load is changing in ruby 2.0.0 later. --- activesupport/lib/active_support/testing/isolation.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/activesupport/lib/active_support/testing/isolation.rb b/activesupport/lib/active_support/testing/isolation.rb index 6b29ba4c10..77c04758ba 100644 --- a/activesupport/lib/active_support/testing/isolation.rb +++ b/activesupport/lib/active_support/testing/isolation.rb @@ -12,8 +12,8 @@ module ActiveSupport end class ProxyTestResult - def initialize - @calls = [] + def initialize(calls = []) + @calls = calls end def add_error(e) @@ -27,6 +27,14 @@ module ActiveSupport end end + def marshal_dump + @calls + end + + def marshal_load(calls) + initialize(calls) + end + def method_missing(name, *args) @calls << [name, args] end -- cgit v1.2.3 From 2a12a04a54590d3a5f2abf4cd4eff3a7b1ee6ef4 Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Sun, 24 Feb 2013 16:33:18 -0500 Subject: Rails 3.2.x is now compatible with Ruby 2.0.0 --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0951d0cf92..e130252522 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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: -- cgit v1.2.3