Skip to content

Commit

Permalink
stop to_sing method names
Browse files Browse the repository at this point in the history
Module#methods are Symbols in Ruby >= 1.9
  • Loading branch information
amatsuda committed Jun 6, 2012
1 parent 9fb7003 commit edee2c7
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 24 deletions.
32 changes: 16 additions & 16 deletions actionpack/test/controller/helper_test.rb
Expand Up @@ -109,13 +109,13 @@ def test_helper

def test_helper_method
assert_nothing_raised { @controller_class.helper_method :delegate_method }
assert master_helper_methods.include?('delegate_method')
assert master_helper_methods.include?(:delegate_method)
end

def test_helper_attr
assert_nothing_raised { @controller_class.helper_attr :delegate_attr }
assert master_helper_methods.include?('delegate_attr')
assert master_helper_methods.include?('delegate_attr=')
assert master_helper_methods.include?(:delegate_attr)
assert master_helper_methods.include?(:delegate_attr=)
end

def call_controller(klass, action)
Expand Down Expand Up @@ -160,16 +160,16 @@ def test_lib_helper_methods_after_clear_helpers
end

def test_all_helpers
methods = AllHelpersController._helpers.instance_methods.map {|m| m.to_s}
methods = AllHelpersController._helpers.instance_methods

# abc_helper.rb
assert methods.include?('bare_a')
assert methods.include?(:bare_a)

# fun/games_helper.rb
assert methods.include?('stratego')
assert methods.include?(:stratego)

# fun/pdf_helper.rb
assert methods.include?('foobar')
assert methods.include?(:foobar)
end

def test_all_helpers_with_alternate_helper_dir
Expand All @@ -180,35 +180,35 @@ def test_all_helpers_with_alternate_helper_dir
@controller_class.helper :all

# helpers/abc_helper.rb should not be included
assert !master_helper_methods.include?('bare_a')
assert !master_helper_methods.include?(:bare_a)

# alternate_helpers/foo_helper.rb
assert master_helper_methods.include?('baz')
assert master_helper_methods.include?(:baz)
end

def test_helper_proxy
methods = AllHelpersController.helpers.methods.map(&:to_s)
methods = AllHelpersController.helpers.methods

# Action View
assert methods.include?('pluralize')
assert methods.include?(:pluralize)

# abc_helper.rb
assert methods.include?('bare_a')
assert methods.include?(:bare_a)

# fun/games_helper.rb
assert methods.include?('stratego')
assert methods.include?(:stratego)

# fun/pdf_helper.rb
assert methods.include?('foobar')
assert methods.include?(:foobar)
end

private
def expected_helper_methods
TestHelper.instance_methods.map {|m| m.to_s }
TestHelper.instance_methods
end

def master_helper_methods
@controller_class._helpers.instance_methods.map {|m| m.to_s }
@controller_class._helpers.instance_methods
end

def missing_methods
Expand Down
3 changes: 1 addition & 2 deletions activerecord/test/cases/finder_respond_to_test.rb
Expand Up @@ -80,7 +80,6 @@ def test_should_not_respond_to_find_by_invalid_method_syntax
private

def ensure_topic_method_is_not_cached(method_id)
class << Topic; self; end.send(:remove_method, method_id) if Topic.public_methods.any? { |m| m.to_s == method_id.to_s }
class << Topic; self; end.send(:remove_method, method_id) if Topic.public_methods.include? method_id
end

end
2 changes: 1 addition & 1 deletion activerecord/test/cases/finder_test.rb
Expand Up @@ -629,7 +629,7 @@ def test_find_by_two_attributes_with_one_being_an_aggregate

def test_dynamic_finder_on_one_attribute_with_conditions_returns_same_results_after_caching
# ensure this test can run independently of order
class << Account; self; end.send(:remove_method, :find_by_credit_limit) if Account.public_methods.any? { |m| m.to_s == 'find_by_credit_limit' }
class << Account; self; end.send(:remove_method, :find_by_credit_limit) if Account.public_methods.include?(:find_by_credit_limit)
a = Account.where('firm_id = ?', 6).find_by_credit_limit(50)
assert_equal a, Account.where('firm_id = ?', 6).find_by_credit_limit(50) # find_by_credit_limit has been cached
end
Expand Down
Expand Up @@ -39,7 +39,7 @@ def to_formatted_s(format = :default)
to_default_s
end
end
alias_method :to_default_s, :to_s unless (instance_methods(false) & [:to_s, 'to_s']).empty?
alias_method :to_default_s, :to_s if instance_methods(false).include?(:to_s)
alias_method :to_s, :to_formatted_s

#
Expand Down
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/log_subscriber.rb
Expand Up @@ -61,7 +61,7 @@ def attach_to(namespace, log_subscriber=new, notifier=ActiveSupport::Notificatio
@@flushable_loggers = nil

log_subscriber.public_methods(false).each do |event|
next if 'call' == event.to_s
next if :call == event

notifier.subscribe("#{event}.#{namespace}", log_subscriber)
end
Expand Down
4 changes: 1 addition & 3 deletions railties/test/railties/engine_test.rb
Expand Up @@ -1009,9 +1009,7 @@ def baz

boot_rails

methods = Bukkits::Engine.helpers.public_instance_methods.collect(&:to_s).sort
expected = ["bar", "baz"]
assert_equal expected, methods
assert_equal [:bar, :baz], Bukkits::Engine.helpers.public_instance_methods.sort
end

test "setting priority for engines with config.railties_order" do
Expand Down

0 comments on commit edee2c7

Please sign in to comment.