simple-navigation 3.12.1 → 3.12.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 CHANGED
@@ -1,3 +1,7 @@
1
+ *3.12.2
2
+
3
+ * Fixing issue #154. Thanks to Simon Curtois.
4
+
1
5
  *3.12.1
2
6
 
3
7
  * bugfix (error in generator)
@@ -74,6 +74,7 @@ module SimpleNavigation
74
74
  def items=(new_items)
75
75
  @items += new_items.map { |item| ItemAdapter.new(item) }
76
76
  .keep_if { |item| should_add_item?(item.options) }
77
+ .map { |item| item.to_simple_navigation_item(self) }
77
78
  end
78
79
 
79
80
  # Returns the Item with the specified key, nil otherwise.
@@ -1,3 +1,3 @@
1
1
  module SimpleNavigation
2
- VERSION = '3.12.1'
2
+ VERSION = '3.12.2'
3
3
  end
@@ -69,42 +69,31 @@ module SimpleNavigation
69
69
  end
70
70
 
71
71
  describe '#items=' do
72
- let(:item) { double(:item) }
72
+ let(:item) {{ key: :my_key, name: 'test', url: '/' }}
73
73
  let(:items) { [item] }
74
74
  let(:item_adapter) { double(:item_adapter).as_null_object }
75
+ let(:real_item) { double(:real_item) }
75
76
 
76
77
  before do
77
- ItemAdapter.stub(new: item_adapter)
78
- item_container.stub(should_add_item?: true)
79
- end
80
-
81
- it 'wraps each item in an ItemAdapter' do
82
- expect(ItemAdapter).to receive(:new)
83
- item_container.items = items
78
+ ItemAdapter.stub(:new).and_return(item_adapter)
79
+ item_adapter.stub(to_simple_navigation_item: real_item)
84
80
  end
85
81
 
86
- context 'when item should be added' do
87
- let(:wrapped_item) { double(:wrapped_item).as_null_object }
88
-
89
- before { ItemAdapter.stub(:new).with(item).and_return(wrapped_item) }
82
+ context 'when the item should be added' do
83
+ before { item_container.stub(should_add_item?: true) }
90
84
 
91
- it 'converts item to an Item and adds it to the items collection' do
85
+ it 'converts it to an Item and adds it to the items collection' do
92
86
  item_container.items = items
93
- expect(item_container.items).to include(wrapped_item)
87
+ expect(item_container.items).to include(real_item)
94
88
  end
95
89
  end
96
90
 
97
- context 'when item should not be added' do
91
+ context 'when the item should not be added' do
98
92
  before { item_container.stub(should_add_item?: false) }
99
93
 
100
- it "doesn't convert the item to an Item" do
101
- expect(item_adapter).not_to receive(:to_simple_navigation_item)
102
- item_container.items = items
103
- end
104
-
105
- it "doesn't add the item to the items-collection" do
106
- expect(item_container.items).not_to receive(:<<)
94
+ it "doesn't add it to the items collection" do
107
95
  item_container.items = items
96
+ expect(item_container.items).not_to include(real_item)
108
97
  end
109
98
  end
110
99
  end
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: 3.12.1
4
+ version: 3.12.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-02-26 00:00:00.000000000 Z
13
+ date: 2014-03-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport