simple-navigation 2.5.0 → 2.5.1

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 CHANGED
@@ -1,3 +1,7 @@
1
+ *2.5.1
2
+
3
+ * set template correctly for Rails3 (brings auto highlighting to life again). Credits to Josep Jaume Rey.
4
+
1
5
  *2.5.0
2
6
 
3
7
  * added new renderer Renderer::Links to simply render the navigation as links inside a div.
@@ -1,4 +1,4 @@
1
1
  ---
2
- :patch: 0
3
2
  :major: 2
4
3
  :minor: 5
4
+ :patch: 1
@@ -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
- it "should set the controller" do
62
- @controller = stub(:controller)
63
- SimpleNavigation.should_receive(:extract_controller_from).with(@context).and_return(@controller)
64
- SimpleNavigation.should_receive(:controller=).with(@controller)
65
- SimpleNavigation.set_template_from @context
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
- it "should set the template" do
68
- @template = stub(:template)
69
- @controller = stub(:controller, :instance_variable_get => @template)
70
- SimpleNavigation.stub!(:controller => @controller)
71
- SimpleNavigation.should_receive(:template=).with(@template)
72
- SimpleNavigation.set_template_from @context
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
- - 0
9
- version: 2.5.0
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-13 00:00:00 +02:00
17
+ date: 2010-04-22 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency