Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Breadcrumbs now accepts a polymorphic path (closes GH-15)

  • Loading branch information...
commit 0a534857831ce642c14e453c6ccb453817cee22a 1 parent c770762
Simone Carletti authored
4 CHANGELOG.md
View
@@ -5,8 +5,12 @@
* FIXED: In some circumstances the BreadcrumbsOnRails::ActionController::HelperMethods is not mixed into the controller.
+* FIXED: Breadcrumbs now accepts a polymorphic path (GH-15).
+
* CHANGED: Second argument on `add_breadcrumb` is now optional (GH-6, GH-32). [Thanks @mpartel]
+* CHANGED: Breadcrumb path computation fallbacks to url_for in case of unknown arguments.
+
## Release 2.2.0
4 lib/breadcrumbs_on_rails/breadcrumbs.rb
View
@@ -61,10 +61,8 @@ def compute_path(element)
@context.send(path)
when Proc
path.call(@context)
- when Hash
- @context.url_for(path)
else
- path.to_s
+ @context.url_for(path)
end
end
8 test/unit/action_controller_test.rb
View
@@ -16,6 +16,7 @@ def action_default
def action_compute_paths
add_breadcrumb "String", "/"
add_breadcrumb "Proc", proc { |c| "/?proc" }
+ add_breadcrumb "Polymorfic", [:admin, :namespace]
execute("action_default")
end
@@ -28,6 +29,11 @@ def execute(method)
end
end
+ def admin_namespace_path(*)
+ "/?polymorfic"
+ end
+ helper_method :admin_namespace_path
+
end
class ExampleControllerTest < ActionController::TestCase
@@ -41,7 +47,7 @@ def test_render_default
def test_render_compute_paths
get :action_compute_paths
- assert_dom_equal %(<a href="/">String</a> &raquo; <a href="/?proc">Proc</a>),
+ assert_dom_equal %(<a href="/">String</a> &raquo; <a href="/?proc">Proc</a> &raquo; <a href="/?polymorfic">Polymorfic</a>),
@response.body
end
7 test/unit/builder_test.rb
View
@@ -81,7 +81,12 @@ def test_compute_path_with_string
def url_for(params)
- "http://localhost?" + params.to_param
+ case params
+ when String
+ params
+ else
+ "http://localhost?" + params.to_param
+ end
end
protected
Please sign in to comment.
Something went wrong with that request. Please try again.