summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-16 23:40:34 +0000
committerkou <kou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-09-16 23:40:34 +0000
commitdcaeabb076431af137e371c5d8b98d149b8b02bf (patch)
treed01f73b65de63703a5295d7f5d0c940daea1e237
parentab28565b7eede19739757c2c91f5213fde3e7a56 (diff)
* 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/branches/ruby_1_8@9189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--lib/rss/maker/base.rb6
-rw-r--r--test/rss/test_maker_1.0.rb54
3 files changed, 67 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 1341a47..8f58fbd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
+
Fri Sep 16 23:09:20 2005 Masaki Suketa <masaki.suketa@nifty.ne.jp>
* ext/win32ole/win32ole.c (ole_search_event_at): bug fix
diff --git a/lib/rss/maker/base.rb b/lib/rss/maker/base.rb
index 4972821..dbd8bf9 100644
--- a/lib/rss/maker/base.rb
+++ b/lib/rss/maker/base.rb
@@ -401,7 +401,11 @@ EOC
end
def normalize
- sort_if_need[0..@max_size]
+ if @max_size >= 0
+ sort_if_need[0...@max_size]
+ else
+ sort_if_need[0..@max_size]
+ end
end
def current_element(rss)
diff --git a/test/rss/test_maker_1.0.rb b/test/rss/test_maker_1.0.rb
index 1fa8666..dca50f7 100644
--- a/test/rss/test_maker_1.0.rb
+++ b/test/rss/test_maker_1.0.rb
@@ -256,6 +256,60 @@ module RSS
assert_equal("#{link}#{i}", item.link)
assert_equal("#{description}#{i}", item.description)
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
def test_not_valid_items