simple-navigation 2.5.0 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/VERSION.yml +1 -1
- data/lib/simple_navigation.rb +1 -1
- data/spec/lib/simple_navigation_spec.rb +45 -11
- metadata +3 -3
data/CHANGELOG
CHANGED
data/VERSION.yml
CHANGED
data/lib/simple_navigation.rb
CHANGED
@@ -47,7 +47,7 @@ module SimpleNavigation
|
|
47
47
|
|
48
48
|
def set_template_from(context)
|
49
49
|
SimpleNavigation.controller = extract_controller_from context
|
50
|
-
SimpleNavigation.template = SimpleNavigation.controller.instance_variable_get(:@template)
|
50
|
+
SimpleNavigation.template = SimpleNavigation.controller.instance_variable_get(:@template) || (SimpleNavigation.controller.respond_to?(:view_context) ? SimpleNavigation.controller.view_context : nil)
|
51
51
|
end
|
52
52
|
|
53
53
|
# Returns the context in which the config file should be evaluated.
|
@@ -58,18 +58,52 @@ describe SimpleNavigation do
|
|
58
58
|
@context = stub :context
|
59
59
|
SimpleNavigation.stub!(:extract_controller_from => @controller)
|
60
60
|
end
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
61
|
+
context 'regarding setting the controller' do
|
62
|
+
it "should set the controller" do
|
63
|
+
@controller = Object.new
|
64
|
+
SimpleNavigation.should_receive(:extract_controller_from).with(@context).and_return(@controller)
|
65
|
+
SimpleNavigation.should_receive(:controller=).with(@controller)
|
66
|
+
SimpleNavigation.set_template_from @context
|
67
|
+
end
|
66
68
|
end
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
69
|
+
context 'regarding setting the template' do
|
70
|
+
before(:each) do
|
71
|
+
@template = stub :template
|
72
|
+
@controller = Object.new
|
73
|
+
SimpleNavigation.stub!(:controller => @controller)
|
74
|
+
end
|
75
|
+
context 'template is stored in controller as instance_var (Rails2)' do
|
76
|
+
context 'template is set' do
|
77
|
+
before(:each) do
|
78
|
+
@controller.stub!(:instance_variable_get => @template)
|
79
|
+
end
|
80
|
+
it {SimpleNavigation.should_receive(:template=).with(@template)}
|
81
|
+
end
|
82
|
+
context 'template is not set' do
|
83
|
+
before(:each) do
|
84
|
+
@controller.stub!(:instance_variable_get => nil)
|
85
|
+
end
|
86
|
+
it {SimpleNavigation.should_receive(:template=).with(nil)}
|
87
|
+
end
|
88
|
+
end
|
89
|
+
context 'template is stored in controller as view_context (Rails3)' do
|
90
|
+
context 'template is set' do
|
91
|
+
before(:each) do
|
92
|
+
@controller.stub!(:view_context => @template)
|
93
|
+
end
|
94
|
+
it {SimpleNavigation.should_receive(:template=).with(@template)}
|
95
|
+
end
|
96
|
+
context 'template is not set' do
|
97
|
+
before(:each) do
|
98
|
+
@controller.stub!(:view_context => nil)
|
99
|
+
end
|
100
|
+
it {SimpleNavigation.should_receive(:template=).with(nil)}
|
101
|
+
end
|
102
|
+
end
|
103
|
+
after(:each) do
|
104
|
+
SimpleNavigation.set_template_from @context
|
105
|
+
end
|
106
|
+
|
73
107
|
end
|
74
108
|
end
|
75
109
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 2
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 2.5.
|
8
|
+
- 1
|
9
|
+
version: 2.5.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Andi Schacke
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-22 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|