Permalink
Browse files

we should not highlight items that are only partial matches.

  • Loading branch information...
1 parent a5cd097 commit d5e5418c907f65c0afb2314eb5f607d71da37c75 @troynt troynt committed Sep 26, 2012
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/simple_navigation/core/item.rb
  2. +6 −0 spec/lib/simple_navigation/core/item_spec.rb
@@ -88,7 +88,7 @@ def selected_by_condition?
when Proc
highlights_on.call
when :subpath
- !!(SimpleNavigation.request_uri =~ /^#{Regexp.escape url_without_anchor}/)
+ !!(SimpleNavigation.request_uri =~ /^#{Regexp.escape url_without_anchor}(\/|$|\?)/i)
else
raise ArgumentError, ':highlights_on must be a Regexp, Proc or :subpath'
end
@@ -389,6 +389,12 @@
end
it {@item.send(:selected_by_condition?).should be_true}
end
+ context 'we are in a route that has a similar name' do
+ before(:each) do
+ SimpleNavigation.stub!(:request_uri => '/resources_group/id')
+ end
+ it {@item.send(:selected_by_condition?).should be_false}
+ end
context 'we are in a route not beginning with this item path' do
before(:each) do
SimpleNavigation.stub!(:request_uri => '/another_resource/id')

0 comments on commit d5e5418

Please sign in to comment.