From e2c89354b6199ad4bb6dc22d3f479d8011e43511 Mon Sep 17 00:00:00 2001 From: Kuangda He Date: Wed, 4 Jun 2014 18:21:44 +1000 Subject: [PATCH 1/3] Add spec for controller with action highlighting --- spec/core/item_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/spec/core/item_spec.rb b/spec/core/item_spec.rb index 7ed98a9..3f31a65 100644 --- a/spec/core/item_spec.rb +++ b/spec/core/item_spec.rb @@ -73,6 +73,12 @@ item.highlights_on?('/other_path', {controller: 'bar'}).should be(false) end + it "uses it's own path (as hash) with actions" do + item = subject.new 'Label', {controller: 'foo', action: 'baz'}, true + item.highlights_on?('/path/action', {controller: 'foo', action: 'baz'}).should be(true) + item.highlights_on?('/other_path/action', {controller: 'bar', action: 'baz'}).should be(false) + end + it "highlights on multiple controllers" do item = subject.new 'Label', '/foo', true, highlights_on: [{controller: 'foo'}, {controller: 'bar'}] item.highlights_on?('/path', {controller: 'foo'}).should be(true) From 4928544515593ac9c214d7699c6b30ca499dfd69 Mon Sep 17 00:00:00 2001 From: Kuangda He Date: Wed, 4 Jun 2014 18:24:05 +1000 Subject: [PATCH 2/3] Fix controller with action highlighting --- lib/navigasmic/core/item.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/navigasmic/core/item.rb b/lib/navigasmic/core/item.rb index d642cc8..caf8410 100644 --- a/lib/navigasmic/core/item.rb +++ b/lib/navigasmic/core/item.rb @@ -35,7 +35,7 @@ def highlights_on?(path, params) when FalseClass false when Hash - rule.except(*unwanted_keys).detect do |key, value| + rule.except(*unwanted_keys).all? do |key, value| value = value.gsub(/^\//, '') if key == :controller value == params[key].to_s end From 44ab31c0ca57a5127b96c7fdc208119f89c2de1a Mon Sep 17 00:00:00 2001 From: Kuangda He Date: Fri, 6 Jun 2014 23:45:02 +1000 Subject: [PATCH 3/3] Fix grammar in item spec --- spec/core/item_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/core/item_spec.rb b/spec/core/item_spec.rb index 3f31a65..a7949ab 100644 --- a/spec/core/item_spec.rb +++ b/spec/core/item_spec.rb @@ -61,19 +61,19 @@ end describe "#highlights_on?" do - it "uses it's own link (as a string)" do + it "uses its own link (as a string)" do item = subject.new 'Label', '/path', true item.highlights_on?('/path', {}).should be(true) item.highlights_on?('/other_path', {}).should be(false) end - it "uses it's own path (as hash)" do + it "uses its own path (as hash)" do item = subject.new 'Label', {controller: 'foo'}, true item.highlights_on?('/path', {controller: 'foo'}).should be(true) item.highlights_on?('/other_path', {controller: 'bar'}).should be(false) end - it "uses it's own path (as hash) with actions" do + it "uses its own path (as hash) with actions" do item = subject.new 'Label', {controller: 'foo', action: 'baz'}, true item.highlights_on?('/path/action', {controller: 'foo', action: 'baz'}).should be(true) item.highlights_on?('/other_path/action', {controller: 'bar', action: 'baz'}).should be(false)