Commit 6bcae58c4c4f723f972ec8e3c68fc12d4e48b612
Committed by
Antonio Terceiro
1 parent
962cb352
Exists in
master
and in
29 other branches
ActionItem1200: Update feed block after reduce limit
Showing
2 changed files
with
13 additions
and
1 deletions
Show diff stats
app/models/feed_reader_block.rb
| ... | ... | @@ -28,7 +28,7 @@ class FeedReaderBlock < Block |
| 28 | 28 | |
| 29 | 29 | def formatted_feed_content |
| 30 | 30 | return "<ul>\n" + |
| 31 | - self.feed_items.map{ |item| "<li><a href='#{item[:link]}'>#{item[:title]}</a></li>" }.join("\n") + | |
| 31 | + self.feed_items[0..(limit-1)].map{ |item| "<li><a href='#{item[:link]}'>#{item[:title]}</a></li>" }.join("\n") + | |
| 32 | 32 | "</ul>" |
| 33 | 33 | end |
| 34 | 34 | ... | ... |
test/unit/feed_reader_block_test.rb
| ... | ... | @@ -81,4 +81,16 @@ class FeedReaderBlockTest < ActiveSupport::TestCase |
| 81 | 81 | assert_equal %w[ last-post second-post first-post ], feed.feed_items.map{|i|i[:title]} |
| 82 | 82 | end |
| 83 | 83 | |
| 84 | + should 'display only limit posts' do | |
| 85 | + feed.limit = 1; feed.save! | |
| 86 | + %w[ first-post second-post ].each do |i| | |
| 87 | + feed.add_item(i, "http://localhost/#{i}", Date.today, "some contet for #{i}") | |
| 88 | + end | |
| 89 | + | |
| 90 | + assert_tag_in_string feed.formatted_feed_content, :tag => 'a', :attributes => { :href => 'http://localhost/second-post' }, :content => 'second-post' | |
| 91 | + assert_no_tag_in_string feed.formatted_feed_content, :tag => 'a', :attributes => { :href => 'http://localhost/first-post' }, :content => 'first-post' | |
| 92 | + end | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 84 | 96 | end | ... | ... |