active_link_to 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.8
1
+ 0.0.9
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{active_link_to}
8
- s.version = "0.0.8"
8
+ s.version = "0.0.9"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Oleg Khabarov"]
12
- s.date = %q{2011-06-23}
12
+ s.date = %q{2011-07-18}
13
13
  s.description = %q{Extremely helpful when you need to add some logic that figures out if the link (or more often navigation item) is selected based on the current page or other arbitrary condition}
14
14
  s.email = %q{oleg@theworkinggroup.ca}
15
15
  s.extra_rdoc_files = [
@@ -148,8 +148,8 @@ module ActiveLinkTo
148
148
  when Regexp
149
149
  !request.fullpath.match(options[:when]).blank?
150
150
  when Array
151
- controllers = options[:when][0]
152
- actions = options[:when][1]
151
+ controllers = [*options[:when][0]]
152
+ actions = [*options[:when][1]]
153
153
  (controllers.blank? || controllers.member?(params[:controller])) &&
154
154
  (actions.blank? || actions.member?(params[:action]))
155
155
  when TrueClass
@@ -49,6 +49,20 @@ class ActiveLinkToTest < Test::Unit::TestCase
49
49
  assert_equal '<a href="/test">name</a>', out
50
50
  end
51
51
 
52
+
53
+ def test_matching_controller_action_singular_values
54
+ request.fullpath = '/test/23'
55
+ params[:controller], params[:action] = 'tests', 'show'
56
+ out = active_link_to 'name', '/test/23', :active => { :when => ['tests', ['show', 'edit']]}
57
+ assert_equal '<a href="/test/23" class="active">name</a>', out
58
+ out = active_link_to 'name', '/test/23', :active => { :when => [ 'tests' ]}
59
+ assert_equal '<a href="/test/23" class="active">name</a>', out
60
+ out = active_link_to 'name', '/test/23', :active => { :when => [nil, 'show']}
61
+ assert_equal '<a href="/test/23" class="active">name</a>', out
62
+ out = active_link_to 'name', '/test/23', :active => { :when => ['tests', 'update']}
63
+ assert_equal '<a href="/test/23">name</a>', out
64
+ end
65
+
52
66
  def test_matching_controller_action_touples
53
67
  request.fullpath = '/test/23'
54
68
  params[:controller], params[:action] = 'tests', 'show'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_link_to
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-06-23 00:00:00.000000000 -04:00
12
+ date: 2011-07-18 00:00:00.000000000 -04:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
  description: Extremely helpful when you need to add some logic that figures out if