Permalink
Browse files

Made the path argument optional.

  • Loading branch information...
1 parent a2d7328 commit d3349cf0246e11bbaf9cc77e8429c454117b9826 @mpartel mpartel committed Sep 26, 2012
@@ -19,7 +19,7 @@ module ActionController
protected
- def add_breadcrumb(name, path, options = {})
+ def add_breadcrumb(name, path = nil, options = {})
self.breadcrumbs << Breadcrumbs::Element.new(name, path, options)
end
@@ -60,7 +60,7 @@ def self.convert_to_set_of_strings(value, keys)
module ClassMethods
- def add_breadcrumb(name, path, filter_options = {})
+ def add_breadcrumb(name, path = nil, filter_options = {})
# This isn't really nice here
if eval = Utils.convert_to_set_of_strings(filter_options.delete(:eval), %w(name path))
name = Utils.instance_proc(name) if eval.include?("name")
@@ -120,7 +120,7 @@ class Element
# @param [Hash] options The element/link URL.
# @return [Element]
#
- def initialize(name, path, options = {})
+ def initialize(name, path = nil, options = {})
self.name = name
self.path = path
self.options = options
View
@@ -2,10 +2,9 @@
class ElementTest < ActiveSupport::TestCase
- def test_initialize_should_require_name_and_path
+ def test_initialize_should_require_name
assert_raise(ArgumentError) { BreadcrumbsOnRails::Breadcrumbs::Element.new }
- assert_raise(ArgumentError) { BreadcrumbsOnRails::Breadcrumbs::Element.new(nil) }
- assert_nothing_raised { BreadcrumbsOnRails::Breadcrumbs::Element.new(nil, nil) }
+ assert_nothing_raised { BreadcrumbsOnRails::Breadcrumbs::Element.new(nil) }
end
def test_initialize_should_set_name
@@ -41,5 +40,10 @@ def test_options
element.options = { :title => "Go to the Homepage" }
assert_equal({ :title => "Go to the Homepage" }, element.options)
end
+
+ def test_path_is_optional
+ element = BreadcrumbsOnRails::Breadcrumbs::Element.new(:homepage)
+ assert_nil element.path
+ end
end

0 comments on commit d3349cf

Please sign in to comment.