simple-navigation 2.4.1 → 2.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +7 -0
- data/README +1 -1
- data/VERSION.yml +1 -1
- data/lib/simple_navigation/controller_methods.rb +1 -0
- data/lib/simple_navigation/renderer/list.rb +3 -2
- data/spec/lib/simple_navigation/controller_methods_spec.rb +9 -1
- data/spec/lib/simple_navigation/renderer/list_spec.rb +92 -53
- metadata +20 -9
data/CHANGELOG
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
*2.4.2
|
2
|
+
|
3
|
+
* Rails 3.0.0.beta2 compatibility
|
4
|
+
* Renderer::List --> make content of ul-tag html_safe for rails 3.0.0.beta2 (due to rails3 XSS protection). Credits to Johan Svensson and Disha Albaqui.
|
5
|
+
* updated copyright
|
6
|
+
* reduced visibility of 'sn_set_navigation' to protected
|
7
|
+
|
1
8
|
*2.4.1
|
2
9
|
|
3
10
|
* removing depencency to rails. It installs the newest rails, even if a matching version is present. why is that?
|
data/README
CHANGED
data/VERSION.yml
CHANGED
@@ -18,8 +18,9 @@ module SimpleNavigation
|
|
18
18
|
li_content << render_sub_navigation_for(item)
|
19
19
|
end
|
20
20
|
list << content_tag(:li, li_content, html_options)
|
21
|
-
end
|
22
|
-
|
21
|
+
end.join
|
22
|
+
list_content = list_content.html_safe if list_content.respond_to?(:html_safe)
|
23
|
+
content_tag(:ul, list_content, {:id => item_container.dom_id, :class => item_container.dom_class})
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
@@ -53,10 +53,18 @@ describe SimpleNavigation::ControllerMethods do
|
|
53
53
|
call_navigation(:key)
|
54
54
|
@controller.respond_to?(:sn_set_navigation).should be_true
|
55
55
|
end
|
56
|
+
it "the created method should not be public" do
|
57
|
+
call_navigation(:key)
|
58
|
+
@controller.public_methods.map(&:to_sym).should_not include(:sn_set_navigation)
|
59
|
+
end
|
60
|
+
it "the created method should be protected" do
|
61
|
+
call_navigation(:key)
|
62
|
+
@controller.protected_methods.map(&:to_sym).should include(:sn_set_navigation)
|
63
|
+
end
|
56
64
|
it 'the created method should call current_navigation with the specified keys' do
|
57
65
|
call_navigation(:primary, :secondary)
|
58
66
|
@controller.should_receive(:current_navigation).with(:primary, :secondary)
|
59
|
-
@controller.sn_set_navigation
|
67
|
+
@controller.send(:sn_set_navigation)
|
60
68
|
end
|
61
69
|
end
|
62
70
|
|
@@ -54,74 +54,113 @@ describe SimpleNavigation::Renderer::List do
|
|
54
54
|
HTML::Document.new(@renderer.render(primary_navigation)).root
|
55
55
|
end
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
HTML::Selector.new('li[style=float:right]').select(render).should have(1).entries
|
74
|
-
end
|
75
|
-
it "should give the li the id specified in the html_options" do
|
76
|
-
HTML::Selector.new('li#my_id').select(render).should have(1).entries
|
77
|
-
end
|
78
|
-
it "should give the li the default id (stringified key) if no id is specified in the html_options" do
|
79
|
-
HTML::Selector.new('ul li#invoices').select(render).should have(1).entries
|
80
|
-
end
|
81
|
-
it "should not apply the the default id where there is an id specified in the html_options" do
|
82
|
-
HTML::Selector.new('ul li#users').select(render).should be_empty
|
83
|
-
end
|
84
|
-
|
85
|
-
context 'with current_navigation set' do
|
86
|
-
it "should mark the matching li-item as selected (with the css_class specified in configuration)" do
|
87
|
-
HTML::Selector.new('li.selected').select(render(:invoices)).should have(1).entries
|
57
|
+
context 'regarding result' do
|
58
|
+
|
59
|
+
it "should render a ul-tag around the items" do
|
60
|
+
HTML::Selector.new('ul').select(render).should have(1).entries
|
61
|
+
end
|
62
|
+
it "the rendered ul-tag should have the specified dom_id" do
|
63
|
+
HTML::Selector.new('ul#nav_dom_id').select(render).should have(1).entries
|
64
|
+
end
|
65
|
+
it "the rendered ul-tag should have the specified class" do
|
66
|
+
HTML::Selector.new('ul.nav_dom_class').select(render).should have(1).entries
|
67
|
+
end
|
68
|
+
it "should render a li tag for each item" do
|
69
|
+
HTML::Selector.new('li').select(render).should have(3).entries
|
70
|
+
end
|
71
|
+
it "should render an a-tag inside each li-tag" do
|
72
|
+
HTML::Selector.new('li a').select(render).should have(3).entries
|
88
73
|
end
|
89
|
-
it "should
|
90
|
-
HTML::Selector.new('li
|
74
|
+
it "should pass the specified html_options to the li element" do
|
75
|
+
HTML::Selector.new('li[style=float:right]').select(render).should have(1).entries
|
91
76
|
end
|
77
|
+
it "should give the li the id specified in the html_options" do
|
78
|
+
HTML::Selector.new('li#my_id').select(render).should have(1).entries
|
79
|
+
end
|
80
|
+
it "should give the li the default id (stringified key) if no id is specified in the html_options" do
|
81
|
+
HTML::Selector.new('ul li#invoices').select(render).should have(1).entries
|
82
|
+
end
|
83
|
+
it "should not apply the the default id where there is an id specified in the html_options" do
|
84
|
+
HTML::Selector.new('ul li#users').select(render).should be_empty
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'with current_navigation set' do
|
88
|
+
it "should mark the matching li-item as selected (with the css_class specified in configuration)" do
|
89
|
+
HTML::Selector.new('li.selected').select(render(:invoices)).should have(1).entries
|
90
|
+
end
|
91
|
+
it "should also mark the links inside the selected li's as selected" do
|
92
|
+
HTML::Selector.new('li.selected a.selected').select(render(:invoices)).should have(1).entries
|
93
|
+
end
|
92
94
|
|
93
|
-
|
95
|
+
end
|
94
96
|
|
95
|
-
|
96
|
-
|
97
|
-
|
97
|
+
context 'without current_navigation set' do
|
98
|
+
it "should not mark any of the items as selected" do
|
99
|
+
HTML::Selector.new('li.selected').select(render).should be_empty
|
100
|
+
end
|
101
|
+
it "should not mark any links as selected" do
|
102
|
+
HTML::Selector.new('a.selected').select(render).should be_empty
|
103
|
+
end
|
98
104
|
end
|
99
|
-
|
100
|
-
|
105
|
+
|
106
|
+
context 'nested sub_navigation' do
|
107
|
+
it "should nest the current_primary's subnavigation inside the selected li-element" do
|
108
|
+
HTML::Selector.new('li.selected ul li').select(render(:invoices)).should have(2).entries
|
109
|
+
end
|
110
|
+
it "should be possible to identify sub items using an html selector (using ids)" do
|
111
|
+
HTML::Selector.new('#invoices #subnav1').select(render(:invoices)).should have(1).entries
|
112
|
+
end
|
113
|
+
context 'expand_all => false' do
|
114
|
+
it "should not render the invoices submenu if the user-primary is active" do
|
115
|
+
HTML::Selector.new('#invoices #subnav1').select(render(:users, :level => :all, :expand_all => false)).should be_empty
|
116
|
+
HTML::Selector.new('#invoices #subnav2').select(render(:users, :level => :all, :expand_all => false)).should be_empty
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'expand_all => true' do
|
121
|
+
it "should render the invoices submenu even if the user-primary is active" do
|
122
|
+
HTML::Selector.new('#invoices #subnav1').select(render(:users, :level => :all, :expand_all => true)).should have(1).entry
|
123
|
+
HTML::Selector.new('#invoices #subnav2').select(render(:users, :level => :all, :expand_all => true)).should have(1).entry
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
101
127
|
end
|
102
128
|
end
|
103
129
|
|
104
|
-
context '
|
105
|
-
|
106
|
-
|
130
|
+
context 'regarding method calls' do
|
131
|
+
before(:each) do
|
132
|
+
@primary_navigation = primary_container
|
133
|
+
@list_content = stub(:list_content)
|
134
|
+
@list_items = stub(:list_items, :join => @list_content)
|
135
|
+
@items.stub!(:inject => @list_items)
|
136
|
+
@renderer = SimpleNavigation::Renderer::List.new(options)
|
107
137
|
end
|
108
|
-
|
109
|
-
|
138
|
+
|
139
|
+
it "should join the list_items" do
|
140
|
+
@list_items.should_receive(:join)
|
110
141
|
end
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
142
|
+
|
143
|
+
context 'html_safe is defined on the joined list_content' do
|
144
|
+
before(:each) do
|
145
|
+
@safe_list_content = stub(:safe_list_content)
|
146
|
+
@list_content.stub!(:html_safe => @safe_list_content)
|
147
|
+
end
|
148
|
+
|
149
|
+
it "should create the ul-element with the html_safe content" do
|
150
|
+
@renderer.should_receive(:content_tag).with(:ul, @safe_list_content, anything)
|
115
151
|
end
|
116
152
|
end
|
117
153
|
|
118
|
-
context '
|
119
|
-
it "should
|
120
|
-
|
121
|
-
HTML::Selector.new('#invoices #subnav2').select(render(:users, :level => :all, :expand_all => true)).should have(1).entry
|
154
|
+
context 'html_safe is not defined on the joined list_content' do
|
155
|
+
it "should create the ul-element with the normal list content" do
|
156
|
+
@renderer.should_receive(:content_tag).with(:ul, @list_content, anything)
|
122
157
|
end
|
123
158
|
end
|
124
|
-
|
159
|
+
|
160
|
+
after(:each) do
|
161
|
+
@renderer.render(@primary_navigation)
|
162
|
+
end
|
163
|
+
|
125
164
|
end
|
126
165
|
|
127
166
|
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple-navigation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 2
|
7
|
+
- 4
|
8
|
+
- 2
|
9
|
+
version: 2.4.2
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Andi Schacke
|
@@ -9,19 +14,23 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-04-11 00:00:00 +02:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: rspec
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 2
|
30
|
+
- 8
|
23
31
|
version: 1.2.8
|
24
|
-
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
25
34
|
description: 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.
|
26
35
|
email: andreas.schacke@gmail.com
|
27
36
|
executables: []
|
@@ -77,18 +86,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
77
86
|
requirements:
|
78
87
|
- - ">="
|
79
88
|
- !ruby/object:Gem::Version
|
89
|
+
segments:
|
90
|
+
- 0
|
80
91
|
version: "0"
|
81
|
-
version:
|
82
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
93
|
requirements:
|
84
94
|
- - ">="
|
85
95
|
- !ruby/object:Gem::Version
|
96
|
+
segments:
|
97
|
+
- 0
|
86
98
|
version: "0"
|
87
|
-
version:
|
88
99
|
requirements: []
|
89
100
|
|
90
101
|
rubyforge_project: andi
|
91
|
-
rubygems_version: 1.3.
|
102
|
+
rubygems_version: 1.3.6
|
92
103
|
signing_key:
|
93
104
|
specification_version: 3
|
94
105
|
summary: Simple Navigation is a ruby library for creating navigations (with multiple levels) for your Ruby on Rails application.
|