Commit 60ac6a28 authored by Robert Speicher's avatar Robert Speicher

Allow current_controller? helper to take an Array of options

parent cada511f
...@@ -3,13 +3,16 @@ module ApplicationHelper ...@@ -3,13 +3,16 @@ module ApplicationHelper
# Check if a particular controller is the current one # Check if a particular controller is the current one
# #
# args - One or more controller names to check
#
# Examples # Examples
# #
# # On TreeController # # On TreeController
# current_controller?(:tree) # => true # current_controller?(:tree) # => true
# current_controller?(:commits) # => false # current_controller?(:commits) # => false
def current_controller?(name) # current_controller?(:commits, :tree) # => true
controller.controller_name == name.to_s.downcase def current_controller?(*args)
args.any? { |v| v.to_s.downcase == controller.controller_name }
end end
def gravatar_icon(user_email = '', size = 40) def gravatar_icon(user_email = '', size = 40)
......
...@@ -13,6 +13,11 @@ describe ApplicationHelper do ...@@ -13,6 +13,11 @@ describe ApplicationHelper do
it "returns false when controller does not match argument" do it "returns false when controller does not match argument" do
current_controller?(:bar).should_not be_true current_controller?(:bar).should_not be_true
end end
it "should take any number of arguments" do
current_controller?(:baz, :bar).should_not be_true
current_controller?(:baz, :bar, :foo).should be_true
end
end end
describe "gravatar_icon" do describe "gravatar_icon" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment