link_to_active_state 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module LinkToActiveState
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.6"
3
3
  end
@@ -20,6 +20,7 @@ module LinkToActiveState
20
20
 
21
21
  link_options ||= {}
22
22
  html_options ||= {}
23
+ wrapper_options = html_options.delete(:active_wrapper_options) || {}
23
24
 
24
25
  if html_options.present? && html_options[:active_on].present?
25
26
  active_on = html_options.delete(:active_on)
@@ -36,9 +37,12 @@ module LinkToActiveState
36
37
  end
37
38
 
38
39
  if html_options.present? && html_options[:active_wrapper]
40
+ if wrapper_options[:class].present?
41
+ options[:class] = merge_class(wrapper_options[:class], options[:class])
42
+ end
43
+
39
44
  element_or_proc = html_options.delete(:active_wrapper)
40
- wrapper_options = html_options.delete(:active_wrapper_options) || {}
41
- wrapper_options = wrapper_options.merge(options)
45
+ wrapper_options.merge!(options)
42
46
 
43
47
  render_with_wrapper(element_or_proc, wrapper_options) do
44
48
  link_to_without_active_state(*args, &block)
@@ -101,6 +101,17 @@ describe LinkToActiveState::ViewHelpers::UrlHelper do
101
101
  li.should match(/<li class=\"active\">/i)
102
102
  li.should match(/<a href/i)
103
103
  end
104
+
105
+ it "supports options on proc wrapper elements" do
106
+ request.stub!(:fullpath).and_return("/")
107
+ li = helper.link_to "Home", "/",
108
+ :active_on => "/",
109
+ :active_wrapper_options => { :class => "wibble" },
110
+ :active_wrapper => proc { |link, wrapper_options|
111
+ "<li class=\"#{wrapper_options[:class]}\">#{link}</li>"
112
+ }
113
+ li.should match(/<li class=\"wibble active\">/i)
114
+ end
104
115
  end
105
116
  end
106
117
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: link_to_active_state
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: