simple-navigation 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ *2.0.1
2
+
3
+ * fixed handling of a non-existent explicit navigation item for a navigation context
4
+
1
5
  *2.0.0
2
6
 
3
7
  * added auto_highlight feature. Active navigation is determined by comparing urls, no need to explicitly set it in the controllers anymore. Thanks to Jack Dempsey and Florian Hanke for the support on this.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 0
2
+ :patch: 1
3
3
  :major: 2
4
4
  :minor: 0
@@ -61,8 +61,13 @@ module SimpleNavigation
61
61
  # the correct instance variable in the controller.
62
62
  def handle_explicit_navigation
63
63
  if SimpleNavigation.explicit_navigation_args
64
- level, navigation = parse_explicit_navigation_args
65
- self.controller.instance_variable_set(:"@sn_current_navigation_#{level}", navigation)
64
+ begin
65
+ level, navigation = parse_explicit_navigation_args
66
+ self.controller.instance_variable_set(:"@sn_current_navigation_#{level}", navigation)
67
+ rescue
68
+ #we do nothing here
69
+ #TODO: check if this is the right way to handle wrong explicit navigation
70
+ end
66
71
  end
67
72
  end
68
73
 
@@ -78,7 +83,7 @@ module SimpleNavigation
78
83
  options = {}
79
84
  if args.size == 1 #only an navi-key has been specified, try to find out level
80
85
  level = SimpleNavigation.primary_navigation.level_for_item(args.first)
81
- options[:"level_#{level}"] = args.first
86
+ options[:"level_#{level}"] = args.first if level
82
87
  else
83
88
  args.each_with_index {|arg, i| options[:"level_#{i + 1}"] = arg}
84
89
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{simple-navigation}
8
- s.version = "2.0.0"
8
+ s.version = "2.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andi Schacke"]
12
- s.date = %q{2009-10-10}
12
+ s.date = %q{2009-10-13}
13
13
  s.description = %q{With the simple-navigation gem installed you can easily create multilevel navigations for your Ruby on Rails applications. The navigation is defined in a single configuration file. It supports automatic as well as explicit highlighting of the currently active navigation.}
14
14
  s.email = %q{andreas.schacke@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -180,14 +180,26 @@ describe SimpleNavigation do
180
180
  end
181
181
  end
182
182
  context 'single navigation' do
183
- before(:each) do
184
- @primary = stub(:primary, :level_for_item => 2)
185
- SimpleNavigation.stub!(:primary_navigation => @primary)
186
- args :key
183
+ context 'specified key is a valid navigation item' do
184
+ before(:each) do
185
+ @primary = stub(:primary, :level_for_item => 2)
186
+ SimpleNavigation.stub!(:primary_navigation => @primary)
187
+ args :key
188
+ end
189
+ it "should set the correct instance var in the controller" do
190
+ @controller.should_receive(:instance_variable_set).with(:@sn_current_navigation_2, :key)
191
+ SimpleNavigation.handle_explicit_navigation
192
+ end
187
193
  end
188
- it "should set the correct instance var in the controller" do
189
- @controller.should_receive(:instance_variable_set).with(:@sn_current_navigation_2, :key)
190
- SimpleNavigation.handle_explicit_navigation
194
+ context 'specified key is an invalid navigation item' do
195
+ before(:each) do
196
+ @primary = stub(:primary, :level_for_item => nil)
197
+ SimpleNavigation.stub!(:primary_navigation => @primary)
198
+ args :key
199
+ end
200
+ it "should not raise an ArgumentError" do
201
+ lambda {SimpleNavigation.handle_explicit_navigation}.should_not raise_error(ArgumentError)
202
+ end
191
203
  end
192
204
  end
193
205
  context 'hash with level' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-navigation
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andi Schacke
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-10 00:00:00 +02:00
12
+ date: 2009-10-13 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies: []
15
15