semantic_navigation 0.1.1 → 0.1.3
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/.editorconfig +14 -0
- data/.gitignore +2 -0
- data/.travis.yml +10 -2
- data/Appraisals +7 -0
- data/Gemfile +1 -1
- data/MIT-LICENSE +20 -0
- data/README.md +31 -20
- data/Rakefile +2 -1
- data/TODO +14 -0
- data/gemfiles/3.2.gemfile +7 -0
- data/gemfiles/3.2.gemfile.lock +112 -0
- data/gemfiles/4.0.gemfile +7 -0
- data/gemfiles/4.0.gemfile.lock +107 -0
- data/lib/generators/semantic_navigation/breadcrumb_renderer/templates/breadcrumb_renderer.rb +5 -5
- data/lib/generators/semantic_navigation/list_renderer/list_renderer_generator.rb +0 -1
- data/lib/generators/semantic_navigation/list_renderer/templates/list_renderer.rb +4 -4
- data/lib/semantic_navigation.rb +30 -0
- data/lib/semantic_navigation/configuration.rb +8 -9
- data/lib/semantic_navigation/core.rb +8 -6
- data/lib/semantic_navigation/core/leaf.rb +2 -2
- data/lib/semantic_navigation/core/mix_in/name_methods.rb +24 -0
- data/lib/semantic_navigation/core/mix_in/url_methods.rb +25 -0
- data/lib/semantic_navigation/core/navigation.rb +8 -2
- data/lib/semantic_navigation/core/node.rb +2 -2
- data/lib/semantic_navigation/deprecations/renderers/acts_as_breadcrumb.rb +14 -0
- data/lib/semantic_navigation/deprecations/renderers/acts_as_list.rb +12 -0
- data/lib/semantic_navigation/deprecations/renderers/render_helpers.rb +14 -0
- data/lib/semantic_navigation/helper_methods.rb +8 -4
- data/lib/semantic_navigation/railtie.rb +9 -19
- data/lib/semantic_navigation/renderers.rb +15 -8
- data/lib/semantic_navigation/renderers/bread_crumb.rb +6 -6
- data/lib/semantic_navigation/renderers/list.rb +6 -6
- data/lib/semantic_navigation/renderers/mix_in/acts_as_breadcrumb.rb +43 -0
- data/lib/semantic_navigation/renderers/mix_in/acts_as_list.rb +49 -0
- data/lib/semantic_navigation/renderers/mix_in/render_helpers.rb +110 -0
- data/lib/semantic_navigation/twitter_bootstrap/breadcrumb.rb +5 -5
- data/lib/semantic_navigation/twitter_bootstrap/list.rb +2 -2
- data/lib/semantic_navigation/twitter_bootstrap/tabs.rb +2 -2
- data/lib/semantic_navigation/version.rb +1 -1
- data/semantic_navigation.gemspec +3 -2
- data/spec/lib/semantic_navigation/configuration_spec.rb +29 -24
- data/spec/lib/semantic_navigation/core/leaf_spec.rb +121 -114
- data/spec/lib/semantic_navigation/core/navigation_spec.rb +81 -76
- data/spec/lib/semantic_navigation/core/node_spec.rb +52 -49
- data/spec/lib/semantic_navigation/helper_methods_spec.rb +47 -42
- data/spec/lib/semantic_navigation/renderers/bread_crumb_spec.rb +191 -187
- data/spec/lib/semantic_navigation/renderers/deprecations_spec.rb +67 -0
- data/spec/lib/semantic_navigation/renderers/list_spec.rb +260 -258
- data/spec/lib/semantic_navigation/twitter_bootstrap/breadcrumb_spec.rb +163 -159
- data/spec/lib/semantic_navigation/twitter_bootstrap/list_spec.rb +263 -262
- data/spec/lib/semantic_navigation/twitter_bootstrap/tabs_spec.rb +269 -266
- data/spec/spec_helper.rb +6 -0
- metadata +41 -13
- data/gemfiles/rails3 +0 -7
- data/lib/semantic_navigation/core/name_methods.rb +0 -24
- data/lib/semantic_navigation/core/url_methods.rb +0 -24
- data/lib/semantic_navigation/renderers/acts_as_breadcrumb.rb +0 -42
- data/lib/semantic_navigation/renderers/acts_as_list.rb +0 -48
- data/lib/semantic_navigation/renderers/render_helpers.rb +0 -109
@@ -1,23 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SemanticNavigation::Core::Navigation do
|
4
|
-
|
4
|
+
|
5
5
|
describe '#initialize' do
|
6
|
-
|
7
|
-
it '
|
6
|
+
|
7
|
+
it 'creates instance of navigation with level 0 and empty subitems' do
|
8
8
|
navigation = SemanticNavigation::Core::Navigation.new({})
|
9
9
|
navigation.level.should == 0
|
10
10
|
navigation.sub_elements.should be_empty
|
11
11
|
end
|
12
12
|
|
13
|
-
it '
|
13
|
+
it 'creates instance and save sended options' do
|
14
14
|
navigation = SemanticNavigation::Core::Navigation.new :id => :some_id,
|
15
15
|
:classes => [:one, :two]
|
16
16
|
navigation.id.should == :some_id
|
17
17
|
navigation.classes.should == [:one,:two]
|
18
18
|
end
|
19
19
|
|
20
|
-
it '
|
20
|
+
it 'creates instance and save unintended properties' do
|
21
21
|
navigation = SemanticNavigation::Core::Navigation.new :some_attribute => :some_value
|
22
22
|
navigation.instance_variable_get("@some_attribute").should == :some_value
|
23
23
|
end
|
@@ -25,25 +25,25 @@ describe SemanticNavigation::Core::Navigation do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
describe '#item' do
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
before :each do
|
29
|
+
@navigation = SemanticNavigation::Core::Navigation.new({})
|
30
|
+
end
|
31
31
|
|
32
|
-
|
32
|
+
it "receives item method and make the leaf" do
|
33
33
|
@navigation.item :some_id, 'some_url'
|
34
34
|
@navigation.sub_elements.size.should == 1
|
35
35
|
@navigation.sub_elements.first.is_a?(SemanticNavigation::Core::Leaf).should be_true
|
36
|
-
|
36
|
+
end
|
37
37
|
|
38
|
-
|
38
|
+
it "receives item method with block and create node" do
|
39
39
|
@navigation.item :node_id, 'node_url' do
|
40
|
-
|
40
|
+
item :leaf_id, 'leaf_url'
|
41
41
|
end
|
42
42
|
@navigation.sub_elements.size.should == 1
|
43
43
|
@navigation.sub_elements.first.is_a?(SemanticNavigation::Core::Node).should be_true
|
44
|
-
|
44
|
+
end
|
45
45
|
|
46
|
-
it "
|
46
|
+
it "receives item method with array of urls and save them properly" do
|
47
47
|
@navigation.item :leaf_id, ['string/url',"controller#action",:symbolic_name,['array','like','url']]
|
48
48
|
urls = @navigation.sub_elements.first.instance_variable_get("@url")
|
49
49
|
urls.should == ['string/url',
|
@@ -52,18 +52,18 @@ describe SemanticNavigation::Core::Navigation do
|
|
52
52
|
['array','like','url']]
|
53
53
|
end
|
54
54
|
|
55
|
-
it "
|
55
|
+
it "receives item with Proc url and decode it to normal url (leaf)" do
|
56
56
|
@navigation.item :leaf_id, proc{'some' + 'func'}
|
57
57
|
@navigation.sub_elements.first.url.should == 'somefunc'
|
58
58
|
end
|
59
59
|
|
60
|
-
it '
|
60
|
+
it 'receives item with array of urls one of each is a Proc (leaf)' do
|
61
61
|
@navigation.item :leaf_id, ['string_url',proc{'some' + 'func'}]
|
62
62
|
urls = @navigation.sub_elements.first.send :urls
|
63
63
|
urls.should == ['string_url', 'somefunc']
|
64
64
|
end
|
65
65
|
|
66
|
-
it "
|
66
|
+
it "receives item with Proc url and decode it to normal url (node)" do
|
67
67
|
@navigation.item :leaf_id, proc{'some' + 'func'} do
|
68
68
|
item :first_value, '#'
|
69
69
|
item :second_value, '#'
|
@@ -71,59 +71,59 @@ describe SemanticNavigation::Core::Navigation do
|
|
71
71
|
@navigation.sub_elements.first.url.should == 'somefunc'
|
72
72
|
end
|
73
73
|
|
74
|
-
it '
|
74
|
+
it 'receives item with array of urls one of each is a Proc (node)' do
|
75
75
|
@navigation.item :leaf_id, ['string_url',proc{'some' + 'func'}] do
|
76
76
|
item :first_value, '#'
|
77
77
|
item :second_value, '#'
|
78
78
|
end
|
79
79
|
urls = @navigation.sub_elements.first.send :urls
|
80
80
|
urls.should == ['string_url', 'somefunc']
|
81
|
-
end
|
81
|
+
end
|
82
82
|
end
|
83
83
|
|
84
84
|
describe '#header' do
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
85
|
+
before :each do
|
86
|
+
@navigation = SemanticNavigation::Core::Navigation.new({})
|
87
|
+
@navigation.header :some_id
|
88
|
+
end
|
89
|
+
|
90
|
+
it "creates item with nil url" do
|
91
|
+
@navigation.sub_elements.size.should == 1
|
92
|
+
@navigation.sub_elements.first.url.should be_nil
|
93
|
+
end
|
94
94
|
end
|
95
95
|
|
96
96
|
describe "#divider" do
|
97
|
-
|
98
|
-
|
99
|
-
|
97
|
+
before :each do
|
98
|
+
@navigation = SemanticNavigation::Core::Navigation.new({})
|
99
|
+
end
|
100
100
|
|
101
|
-
|
101
|
+
it "creates divider item with nil url and name" do
|
102
102
|
@navigation.divider
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
it "
|
109
|
-
|
110
|
-
|
103
|
+
@navigation.sub_elements.size.should == 1
|
104
|
+
@navigation.sub_elements.first.url.should be_nil
|
105
|
+
@navigation.sub_elements.first.name.should be_empty
|
106
|
+
end
|
107
|
+
|
108
|
+
it "receives any length method containing char `_` and create divider" do
|
109
|
+
|
110
|
+
(1..10).each do |c|
|
111
111
|
@navigation.send ('_'*c).to_sym
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
112
|
+
end
|
113
|
+
@navigation.sub_elements.size.should == 10
|
114
|
+
@navigation.sub_elements.map(&:id).should == [:divider]*10
|
115
|
+
end
|
116
116
|
end
|
117
117
|
|
118
118
|
describe "#decode_url" do
|
119
|
-
|
119
|
+
|
120
120
|
before :each do
|
121
121
|
@navigation = SemanticNavigation::Core::Navigation.new({})
|
122
122
|
end
|
123
123
|
|
124
124
|
it "while creating the item make support for urls in format controller#action" do
|
125
125
|
view_object = mock
|
126
|
-
|
126
|
+
|
127
127
|
@navigation.item :some_id, 'controller#action'
|
128
128
|
@navigation.sub_elements.size.should == 1
|
129
129
|
@navigation.sub_elements.first.url.should == {:controller => "controller", :action => "action"}
|
@@ -131,31 +131,36 @@ describe SemanticNavigation::Core::Navigation do
|
|
131
131
|
end
|
132
132
|
|
133
133
|
describe '#render_if' do
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
134
|
+
context :returns do
|
135
|
+
it 'true if render_if proc is nil' do
|
136
|
+
navigation = SemanticNavigation::Core::Navigation.new({})
|
137
|
+
navigation.render_if.should be_true
|
138
|
+
end
|
138
139
|
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
140
|
+
it 'true if render_if proc return true' do
|
141
|
+
navigation = SemanticNavigation::Core::Navigation.new({:render_if => proc{true}})
|
142
|
+
navigation.render_if.should be_true
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'false if render_if proc return false' do
|
146
|
+
navigation = SemanticNavigation::Core::Navigation.new({:render_if => proc{false}})
|
147
|
+
navigation.render_if.should be_false
|
148
|
+
end
|
143
149
|
|
144
|
-
it 'should return false if render_if proc return false' do
|
145
|
-
navigation = SemanticNavigation::Core::Navigation.new({:render_if => proc{false}})
|
146
|
-
navigation.render_if.should be_false
|
147
150
|
end
|
148
151
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
152
|
+
context :passes do
|
153
|
+
it 'self to passed proc' do
|
154
|
+
navigation = SemanticNavigation::Core::Navigation.new({:id => :some_id, :render_if => proc{|o| o.id == :some_id}})
|
155
|
+
navigation.render_if.should be_true
|
156
|
+
navigation = SemanticNavigation::Core::Navigation.new({:id => :another_id, :render_if => proc{|o| o.id == :some_id}})
|
157
|
+
navigation.render_if.should be_false
|
158
|
+
end
|
154
159
|
end
|
155
160
|
end
|
156
161
|
|
157
162
|
describe '#render' do
|
158
|
-
it '
|
163
|
+
it 'calls renderer class :render_navigation method' do
|
159
164
|
renderer = mock
|
160
165
|
navigation = SemanticNavigation::Core::Navigation.new({})
|
161
166
|
renderer.should_receive(:render_navigation).with(navigation)
|
@@ -171,21 +176,21 @@ describe SemanticNavigation::Core::Navigation do
|
|
171
176
|
SemanticNavigation::Configuration.stub(:view_object).and_return @view_object
|
172
177
|
end
|
173
178
|
|
174
|
-
it '
|
179
|
+
it 'defines @active variable to false if no sub_elemetns' do
|
175
180
|
@navigation.mark_active
|
176
181
|
@navigation.instance_variable_get("@active").should be false
|
177
182
|
end
|
178
183
|
|
179
|
-
it '
|
184
|
+
it 'defines @active variable to true if at least one sub_element is active' do
|
180
185
|
@navigation.item :first_item, '111'
|
181
186
|
@navigation.item :second_item, '222'
|
182
187
|
@view_object.should_receive(:current_page?).with('111').and_return true
|
183
188
|
@view_object.should_receive(:current_page?).with('222').and_return false
|
184
|
-
|
189
|
+
|
185
190
|
@navigation.mark_active
|
186
191
|
end
|
187
192
|
|
188
|
-
it '
|
193
|
+
it 'defines @active variable to false if all sub_elements is unactive' do
|
189
194
|
@navigation.item :first_item, '333'
|
190
195
|
@navigation.item :secodn_item, '444'
|
191
196
|
@view_object.should_receive(:current_page?).with('333').and_return false
|
@@ -194,17 +199,17 @@ describe SemanticNavigation::Core::Navigation do
|
|
194
199
|
@navigation.mark_active
|
195
200
|
end
|
196
201
|
|
197
|
-
it '
|
202
|
+
it 'uses custom current_page? for Hash url params' do
|
198
203
|
@navigation.item :first_item, {:controller => "controller1", :action => "action"}
|
199
204
|
@navigation.item :second_item, {:controller => "controller2", :action => "action"}
|
200
205
|
@view_object.stub(:params).and_return({:controller => "controller1", :action => "action", :some_other_params => "blablabla"})
|
201
|
-
|
206
|
+
|
202
207
|
@navigation.mark_active
|
203
208
|
@navigation.sub_elements[0].active.should be_true
|
204
209
|
@navigation.sub_elements[1].active.should be_false
|
205
210
|
end
|
206
211
|
|
207
|
-
it '
|
212
|
+
it 'works for route like urls as good as for Hash url params' do
|
208
213
|
@navigation.item :first_item, "controller1#action"
|
209
214
|
@navigation.item :second_item, "controller2#action"
|
210
215
|
@view_object.stub(:params).and_return({:controller => "controller1", :action => "action", :some_other_params => "blablabla"})
|
@@ -212,7 +217,7 @@ describe SemanticNavigation::Core::Navigation do
|
|
212
217
|
@navigation.mark_active
|
213
218
|
@navigation.sub_elements[0].active.should be_true
|
214
219
|
@navigation.sub_elements[1].active.should be_false
|
215
|
-
end
|
220
|
+
end
|
216
221
|
|
217
222
|
end
|
218
223
|
|
@@ -224,7 +229,7 @@ describe SemanticNavigation::Core::Navigation do
|
|
224
229
|
SemanticNavigation::Configuration.stub(:view_object).and_return @view_object
|
225
230
|
end
|
226
231
|
|
227
|
-
it "
|
232
|
+
it "scopes the items" do
|
228
233
|
@navigation.scope do
|
229
234
|
item :first_item, "controller1#action"
|
230
235
|
item :second_item, "controller2#action"
|
@@ -233,7 +238,7 @@ describe SemanticNavigation::Core::Navigation do
|
|
233
238
|
@navigation.sub_elements.size.should == 2
|
234
239
|
end
|
235
240
|
|
236
|
-
it "
|
241
|
+
it "scopes the creating items options" do
|
237
242
|
some_condition = mock
|
238
243
|
@navigation.scope :render_if => some_condition do
|
239
244
|
item :first_item, "controller1#action"
|
@@ -245,7 +250,7 @@ describe SemanticNavigation::Core::Navigation do
|
|
245
250
|
end
|
246
251
|
end
|
247
252
|
|
248
|
-
it "
|
253
|
+
it "doesnt scope unscoped items" do
|
249
254
|
some_condition = mock
|
250
255
|
@navigation.scope render_if: some_condition do
|
251
256
|
item :first_item, "controller1#action"
|
@@ -257,7 +262,7 @@ describe SemanticNavigation::Core::Navigation do
|
|
257
262
|
last_item.instance_variable_get(:"@render_if").should == nil
|
258
263
|
end
|
259
264
|
|
260
|
-
it "
|
265
|
+
it "doesnt override defined scopes" do
|
261
266
|
some_condition = mock
|
262
267
|
some_condition2 = mock
|
263
268
|
@navigation.scope :render_if => some_condition do
|
@@ -275,7 +280,7 @@ describe SemanticNavigation::Core::Navigation do
|
|
275
280
|
end
|
276
281
|
|
277
282
|
describe '#method_missing' do
|
278
|
-
it '
|
283
|
+
it 'gets unknown method and call super' do
|
279
284
|
@navigation = SemanticNavigation::Core::Navigation.new({})
|
280
285
|
lambda{@navigation.unknow_method}.should raise_exception
|
281
286
|
end
|
@@ -1,58 +1,58 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SemanticNavigation::Core::Node do
|
4
|
-
|
4
|
+
|
5
5
|
describe '#name' do
|
6
6
|
|
7
|
-
it '
|
7
|
+
it 'returns basic name even if renderer name sended' do
|
8
8
|
node = SemanticNavigation::Core::Node.new({:id => :first, :name => 'first'},1)
|
9
|
-
node.name(:renderer_name).should == 'first'
|
9
|
+
node.name(:renderer_name).should == 'first'
|
10
10
|
end
|
11
11
|
|
12
|
-
it '
|
13
|
-
node = SemanticNavigation::Core::Node.new({:id => :first,
|
12
|
+
it 'returns the name for renderer' do
|
13
|
+
node = SemanticNavigation::Core::Node.new({:id => :first,
|
14
14
|
:name => {:some_renderer => 'some_renderer_name'}},
|
15
15
|
1)
|
16
16
|
node.name(:some_renderer).should == 'some_renderer_name'
|
17
17
|
end
|
18
18
|
|
19
|
-
it '
|
20
|
-
node = SemanticNavigation::Core::Node.new({:id => :first,
|
19
|
+
it 'returns default name for unexpected renderer' do
|
20
|
+
node = SemanticNavigation::Core::Node.new({:id => :first,
|
21
21
|
:name => {:default => 'default_name',
|
22
22
|
:some_renderer => 'some_renderer_name'}},
|
23
23
|
1)
|
24
24
|
node.name(:unexpected_renderer).should == 'default_name'
|
25
25
|
end
|
26
26
|
|
27
|
-
it '
|
27
|
+
it 'returns nil if no name defined' do
|
28
28
|
node = SemanticNavigation::Core::Node.new({:id => :first}, 1)
|
29
29
|
node.name.should == ''
|
30
|
-
end
|
30
|
+
end
|
31
31
|
|
32
|
-
it '
|
32
|
+
it 'returns passed name while creating node' do
|
33
33
|
node = SemanticNavigation::Core::Node.new({:name => 'some name'}, 1)
|
34
34
|
node.name.should == 'some name'
|
35
35
|
end
|
36
|
-
|
37
|
-
it '
|
36
|
+
|
37
|
+
it 'returns i18n name if passed name is nil' do
|
38
38
|
node = SemanticNavigation::Core::Node.new({:id => :some_id, :i18n_name => :parent_name}, 1)
|
39
39
|
I18n.should_receive(:t).with("parent_name.some_id", {:default=>""}).and_return 'some name'
|
40
40
|
node.name.should == 'some name'
|
41
41
|
end
|
42
42
|
|
43
|
-
it '
|
43
|
+
it 'returns result of proc if passed name is a proc' do
|
44
44
|
node = SemanticNavigation::Core::Node.new({:name => proc{'some name'}},1)
|
45
45
|
node.name.should == 'some name'
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
-
describe '#url' do
|
50
|
-
it '
|
49
|
+
describe '#url' do
|
50
|
+
it 'returns passed url' do
|
51
51
|
node = SemanticNavigation::Core::Node.new({:url => {:controller => 'controller', :action => 'action'}},1)
|
52
52
|
node.url.should == {:controller => 'controller', :action => 'action'}
|
53
53
|
end
|
54
54
|
|
55
|
-
it '
|
55
|
+
it 'returns first url if passed array of urls' do
|
56
56
|
node = SemanticNavigation::Core::Node.new({:url => [{:controller => 'controller1', :action => 'action'},
|
57
57
|
{:controller => 'controller2', :action => 'action'}]},1)
|
58
58
|
node.url.should == {:controller => 'controller1', :action => 'action'}
|
@@ -65,51 +65,54 @@ describe SemanticNavigation::Core::Node do
|
|
65
65
|
{:controller => :node_controller2, :action => :action}]},1)
|
66
66
|
|
67
67
|
@view_object = mock
|
68
|
-
@view_object.stub(:params).and_return({:action => "some", :action => "some"})
|
68
|
+
@view_object.stub(:params).and_return({:action => "some", :action => "some"})
|
69
69
|
SemanticNavigation::Configuration.stub(:view_object).and_return @view_object
|
70
70
|
end
|
71
71
|
|
72
|
-
|
73
|
-
@node.mark_active
|
74
|
-
@node.instance_variable_get("@active").should be_false
|
75
|
-
end
|
72
|
+
context :defines do
|
76
73
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
@view_object.should_receive(:current_page?).with('222').and_return false
|
82
|
-
|
83
|
-
@node.mark_active
|
84
|
-
@node.sub_elements[0].active.should be_true
|
85
|
-
@node.sub_elements[1].active.should be_false
|
86
|
-
@node.active.should be_true
|
87
|
-
end
|
74
|
+
it '@active variable to false if no active sub_elements and node url is not active' do
|
75
|
+
@node.mark_active
|
76
|
+
@node.instance_variable_get("@active").should be_false
|
77
|
+
end
|
88
78
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
79
|
+
it '@active variable to true if at least one sub_element is active' do
|
80
|
+
@node.item :first_item, '111'
|
81
|
+
@node.item :second_item, '222'
|
82
|
+
@view_object.should_receive(:current_page?).with('111').and_return true
|
83
|
+
@view_object.should_receive(:current_page?).with('222').and_return false
|
94
84
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
85
|
+
@node.mark_active
|
86
|
+
@node.sub_elements[0].active.should be_true
|
87
|
+
@node.sub_elements[1].active.should be_false
|
88
|
+
@node.active.should be_true
|
89
|
+
end
|
90
|
+
|
91
|
+
it '@active variable to false if all sub_elements is unactive' do
|
92
|
+
@node.item :first_item, '333'
|
93
|
+
@node.item :second_item, '444'
|
94
|
+
@view_object.should_receive(:current_page?).with('333').and_return false
|
95
|
+
@view_object.should_receive(:current_page?).with('444').and_return false
|
96
|
+
|
97
|
+
@node.mark_active
|
98
|
+
@node.sub_elements[0].active.should be_false
|
99
|
+
@node.sub_elements[1].active.should be_false
|
100
|
+
@node.active.should be_false
|
101
|
+
end
|
99
102
|
end
|
100
103
|
|
101
|
-
it '
|
104
|
+
it 'uses custom current_page? for Hash url params' do
|
102
105
|
@node.item :first_item, {:controller => "controller1", :action => "action"}
|
103
106
|
@node.item :second_item, {:controller => "controller2", :action => "action"}
|
104
107
|
@view_object.stub(:params).and_return({:controller => "controller1", :action => "action", :some_other_params => "blablabla"})
|
105
|
-
|
108
|
+
|
106
109
|
@node.mark_active
|
107
110
|
@node.sub_elements[0].active.should be_true
|
108
111
|
@node.sub_elements[1].active.should be_false
|
109
112
|
@node.active.should be true
|
110
113
|
end
|
111
114
|
|
112
|
-
it '
|
115
|
+
it 'works for route like urls as good as for Hash url params' do
|
113
116
|
@node.item :first_item, "controller1#action"
|
114
117
|
@node.item :second_item, "controller2#action"
|
115
118
|
@view_object.stub(:params).and_return({:controller => "controller1", :action => "action", :some_other_params => "blablabla"})
|
@@ -117,16 +120,16 @@ describe SemanticNavigation::Core::Node do
|
|
117
120
|
@node.mark_active
|
118
121
|
@node.sub_elements[0].active.should be_true
|
119
122
|
@node.sub_elements[1].active.should be_false
|
120
|
-
@node.active.should be true
|
123
|
+
@node.active.should be true
|
121
124
|
end
|
122
125
|
|
123
|
-
it '
|
126
|
+
it 'is active if at least one url in passed array is active' do
|
124
127
|
@view_object.stub(:params).and_return(:controller => 'node_controller2', :action => 'action')
|
125
128
|
@node.mark_active
|
126
129
|
@node.active.should be_true
|
127
130
|
end
|
128
131
|
|
129
|
-
it '
|
132
|
+
it 'accepts array like urls with other urls' do
|
130
133
|
node = SemanticNavigation::Core::Node.new({:url => [['url','with','id'],
|
131
134
|
:symbol_url_name,
|
132
135
|
{:controller => 'hash', :action => 'url'},
|
@@ -138,6 +141,6 @@ describe SemanticNavigation::Core::Node do
|
|
138
141
|
node.mark_active
|
139
142
|
end
|
140
143
|
|
141
|
-
end
|
144
|
+
end
|
142
145
|
|
143
|
-
end
|
146
|
+
end
|