I'm doing Bug 216: Renaming, and maaaaaan.
It's kind of funny -- I studiously ignored most of the renaming support requests back on LJ, because it seemed complicated and I didn't want to dig into the code, and now here I am, writing similar logic from scratch *snickers*
I'm having great fun. This seemed like one of the projects where tests would have a great effect, so I spent some time figuring out how to write tests from scratch, rather than just trying to tweak existing tests.
My tests look kinda like this:
I'm coding by first writing a bunch of tests, then writing code to make the tests pass. Every time I think of something new I should check for, I dash off a quick TODO block and then go back to writing either my test or my module. That helps me not lose my train of thought, but also means that I don't lose my ideas.
I'm starting with a small set of limited functionality, and then gradually expanding the scope. I actually started by disallowing everything except user-to-unregistered, and now I'm relaxing the rules as I add more. So far, I have personal-user-to-unregistered, with redirect and without redirect, and lots of checking for whether $fromu can rename to $tousername.
I'm in the middle of user-to-other-user, where the second user is just moved out of the way.
I estimate that I'm only about 10% of the way through -- I still need community-to-unregistered, community-to-other-community (or journal??), two-username-swap, keeping or removing various links -- subscriptions and the like, then catching edge cases (loops, openid attempts to rename, etc). And then I need to integrate it into the shop. And after that, I need to build a frontend so people can buy it from the shop *g*
At some point, I'll probably need to catch someone in chat to ask certain questions about the renaming process -- what should happen to usernames that were renamed away from, is swapping usernames one token or two, should you be able to rename a comm to a journal and vice versa, blah blah blah, buuut that can all wait a bit, because I'm sure I'll end up with still yet more questions.
It's kind of funny -- I studiously ignored most of the renaming support requests back on LJ, because it seemed complicated and I didn't want to dig into the code, and now here I am, writing similar logic from scratch *snickers*
I'm having great fun. This seemed like one of the projects where tests would have a great effect, so I spent some time figuring out how to write tests from scratch, rather than just trying to tweak existing tests.
My tests look kinda like this:
# user-to-other-user, no redirect
{
my $fromu = temp_user();
my $tou = temp_user();
my $fromuid = $fromu->userid;
my $touid = $tou->userid;
my $tousername = $tou->user;
$fromu->rename( $tousername );
is( $fromu->user, $tousername, "Rename fromu to tou, which is under the control of fromu" );
my $ex_user = substr( $tou->user, 0, 10 );
like( $tou->user, qr/^ex_$ex_user/ , "Moved out of the way." );
is( $fromu->userid, $fromuid, "Id of fromu remains the same after rename." );
is( $tou->userid, $touid, "Id of tou remains the same after rename." );
}
# user-to-other-user, with redirect
TODO: {
local $TODO = "rename unimplemented";
}
TODO: {
local $TODO = "rename to an expunged user";
}
TODO: {
local $TODO = "rename to a deleted user; should not work";
}
I'm coding by first writing a bunch of tests, then writing code to make the tests pass. Every time I think of something new I should check for, I dash off a quick TODO block and then go back to writing either my test or my module. That helps me not lose my train of thought, but also means that I don't lose my ideas.
I'm starting with a small set of limited functionality, and then gradually expanding the scope. I actually started by disallowing everything except user-to-unregistered, and now I'm relaxing the rules as I add more. So far, I have personal-user-to-unregistered, with redirect and without redirect, and lots of checking for whether $fromu can rename to $tousername.
I'm in the middle of user-to-other-user, where the second user is just moved out of the way.
I estimate that I'm only about 10% of the way through -- I still need community-to-unregistered, community-to-other-community (or journal??), two-username-swap, keeping or removing various links -- subscriptions and the like, then catching edge cases (loops, openid attempts to rename, etc). And then I need to integrate it into the shop. And after that, I need to build a frontend so people can buy it from the shop *g*
At some point, I'll probably need to catch someone in chat to ask certain questions about the renaming process -- what should happen to usernames that were renamed away from, is swapping usernames one token or two, should you be able to rename a comm to a journal and vice versa, blah blah blah, buuut that can all wait a bit, because I'm sure I'll end up with still yet more questions.
no subject
Date: 2009-12-05 01:44 pm (UTC)