mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rss/maker/base.rb (RSS::Maker::ItemsBase#normalize): fixed
strange RSS::Maker::Item#max_size behavior. Thanks to Kazuhiko <kazuhiko@fdiary.net>. * test/rss/test_maker_1.0.rb (RSS::TestMaker10#test_items): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
aa6393778a
commit
446eef82cf
3 changed files with 67 additions and 1 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Sat Sep 17 08:35:39 2005 Kouhei Sutou <kou@cozmixng.org>
|
||||||
|
|
||||||
|
* lib/rss/maker/base.rb (RSS::Maker::ItemsBase#normalize): fixed
|
||||||
|
strange RSS::Maker::Item#max_size behavior.
|
||||||
|
Thanks to Kazuhiko <kazuhiko@fdiary.net>.
|
||||||
|
|
||||||
|
* test/rss/test_maker_1.0.rb (RSS::TestMaker10#test_items): ditto.
|
||||||
|
|
||||||
Sat Sep 17 08:02:53 2005 Shugo Maeda <shugo@ruby-lang.org>
|
Sat Sep 17 08:02:53 2005 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
* lib/net/imap.rb: supported DIGEST-MD5. Thanks, Mathieu Arnold.
|
* lib/net/imap.rb: supported DIGEST-MD5. Thanks, Mathieu Arnold.
|
||||||
|
|
|
@ -401,8 +401,12 @@ EOC
|
||||||
end
|
end
|
||||||
|
|
||||||
def normalize
|
def normalize
|
||||||
|
if @max_size >= 0
|
||||||
|
sort_if_need[0...@max_size]
|
||||||
|
else
|
||||||
sort_if_need[0..@max_size]
|
sort_if_need[0..@max_size]
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def current_element(rss)
|
def current_element(rss)
|
||||||
rss.items
|
rss.items
|
||||||
|
|
|
@ -256,6 +256,60 @@ module RSS
|
||||||
assert_equal("#{link}#{i}", item.link)
|
assert_equal("#{link}#{i}", item.link)
|
||||||
assert_equal("#{description}#{i}", item.description)
|
assert_equal("#{description}#{i}", item.description)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
max_size = item_size / 2
|
||||||
|
rss = RSS::Maker.make("1.0") do |maker|
|
||||||
|
setup_dummy_channel(maker)
|
||||||
|
|
||||||
|
item_size.times do |i|
|
||||||
|
item = maker.items.new_item
|
||||||
|
item.title = "#{title}#{i}"
|
||||||
|
item.link = "#{link}#{i}"
|
||||||
|
item.description = "#{description}#{i}"
|
||||||
|
end
|
||||||
|
maker.items.max_size = max_size
|
||||||
|
end
|
||||||
|
assert_equal(max_size, rss.items.size)
|
||||||
|
rss.items.each_with_index do |item, i|
|
||||||
|
assert_equal("#{link}#{i}", item.about)
|
||||||
|
assert_equal("#{title}#{i}", item.title)
|
||||||
|
assert_equal("#{link}#{i}", item.link)
|
||||||
|
assert_equal("#{description}#{i}", item.description)
|
||||||
|
end
|
||||||
|
|
||||||
|
max_size = 0
|
||||||
|
rss = RSS::Maker.make("1.0") do |maker|
|
||||||
|
setup_dummy_channel(maker)
|
||||||
|
|
||||||
|
item_size.times do |i|
|
||||||
|
item = maker.items.new_item
|
||||||
|
item.title = "#{title}#{i}"
|
||||||
|
item.link = "#{link}#{i}"
|
||||||
|
item.description = "#{description}#{i}"
|
||||||
|
end
|
||||||
|
maker.items.max_size = max_size
|
||||||
|
end
|
||||||
|
assert_equal(max_size, rss.items.size)
|
||||||
|
|
||||||
|
max_size = -2
|
||||||
|
rss = RSS::Maker.make("1.0") do |maker|
|
||||||
|
setup_dummy_channel(maker)
|
||||||
|
|
||||||
|
item_size.times do |i|
|
||||||
|
item = maker.items.new_item
|
||||||
|
item.title = "#{title}#{i}"
|
||||||
|
item.link = "#{link}#{i}"
|
||||||
|
item.description = "#{description}#{i}"
|
||||||
|
end
|
||||||
|
maker.items.max_size = max_size
|
||||||
|
end
|
||||||
|
assert_equal(item_size + max_size + 1, rss.items.size)
|
||||||
|
rss.items.each_with_index do |item, i|
|
||||||
|
assert_equal("#{link}#{i}", item.about)
|
||||||
|
assert_equal("#{title}#{i}", item.title)
|
||||||
|
assert_equal("#{link}#{i}", item.link)
|
||||||
|
assert_equal("#{description}#{i}", item.description)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_not_valid_items
|
def test_not_valid_items
|
||||||
|
|
Loading…
Reference in a new issue