Fixed bug #807245, changetopic reorders topics.

This commit is contained in:
Jeremy Fincher 2003-09-16 18:08:33 +00:00
parent 7719b8dad3
commit 9ed2dcbc31
2 changed files with 17 additions and 0 deletions

View File

@ -175,6 +175,8 @@ class Topic(callbacks.Privmsg):
irc.error(msg, 'You can only modify your own topics.') irc.error(msg, 'You can only modify your own topics.')
return return
newTopic = self.topicFormatter % (replacer(topic), name) newTopic = self.topicFormatter % (replacer(topic), name)
if number < 0:
number = len(topics)+1+number
topics.insert(number, newTopic) topics.insert(number, newTopic)
newTopic = self.topicSeparator.join(topics) newTopic = self.topicSeparator.join(topics)
irc.queueMsg(ircmsgs.topic(channel, newTopic)) irc.queueMsg(ircmsgs.topic(channel, newTopic))

View File

@ -44,6 +44,21 @@ class TopicTestCase(PluginTestCase, PluginDocumentation):
self.assertEqual(m.command, 'TOPIC') self.assertEqual(m.command, 'TOPIC')
self.assertEqual(m.args[0], '#foo') self.assertEqual(m.args[0], '#foo')
def testChangetopic(self):
_ = self.getMsg('join #foo')
_ = self.getMsg(' ')
_ = self.getMsg('addtopic #foo foo')
_ = self.getMsg('addtopic #foo bar')
_ = self.getMsg('addtopic #foo baz')
self.assertRegexp('changetopic #foo -1 s/baz/biff/',
r'foo.*bar.*biff')
self.assertRegexp('changetopic #foo 1 s/bar/baz/',
r'foo.*baz.*biff')
self.assertRegexp('changetopic #foo 0 s/foo/bar/',
r'bar.*baz.*biff')
self.assertRegexp('changetopic #foo -2 s/baz/bazz/',
r'bar.*bazz.*biff')
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: # vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78: