Commit e1db8da3c08b21fc00b7f120f76539e1719664ed

Authored by Moises Machado
Committed by Antonio Terceiro
1 parent 959d88c4

ActionItem1114: reorder entries in feed block

fixed also a test in the feed_handler that relied in the order of the items
app/models/feed_reader_block.rb
... ... @@ -41,7 +41,7 @@ class FeedReaderBlock < Block
41 41 end
42 42  
43 43 def add_item(title, link, date, content)
44   - self.feed_items << {:title => title, :link => link}
  44 + self.feed_items.unshift( {:title => title, :link => link})
45 45 end
46 46  
47 47 def clear
... ...
test/unit/feed_handler_test.rb
... ... @@ -26,7 +26,7 @@ class FeedHandlerTest &lt; Test::Unit::TestCase
26 26 should 'process feed and populate container' do
27 27 handler.process(container)
28 28 assert_equal 'Feed for unit tests', container.feed_title
29   - assert_equal ["First POST", "Second POST", "Last POST"], container.feed_items.map {|item| item[:title]}
  29 + assert_equivalent ["First POST", "Second POST", "Last POST"], container.feed_items.map {|item| item[:title]}
30 30 end
31 31  
32 32 should 'raise exception when parser nil' do
... ...
test/unit/feed_reader_block_test.rb
... ... @@ -73,4 +73,12 @@ class FeedReaderBlockTest &lt; ActiveSupport::TestCase
73 73 feed.finish_fetch
74 74 end
75 75  
  76 + should 'display the latest post first' do
  77 + %w[ first-post second-post last-post ].each do |i|
  78 + feed.add_item(i, "http://localhost/#{i}", Date.today, "some contet for #{i}")
  79 + end
  80 +
  81 + assert_equal %w[ last-post second-post first-post ], feed.feed_items.map{|i|i[:title]}
  82 + end
  83 +
76 84 end
... ...