Skip to content
This repository has been archived by the owner on Jun 24, 2018. It is now read-only.

Commit

Permalink
Merging artists merges all annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver committed Jan 24, 2009
1 parent 1ee46f0 commit 68e29eb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
7 changes: 5 additions & 2 deletions lib/MusicBrainz/Schema/Result/Artist.pm
Expand Up @@ -63,10 +63,13 @@ sub end_date_label
sub merge_into {
my ($self, $destination) = @_;

$self->aliases->update({ ref => $destination->id });
$self->releases->update({ artist => $destination->id });
my $d_id = $destination->id;
$self->aliases->update({ ref => $d_id });
$self->releases->update({ artist => $d_id });
$self->annotations->update({ rowid => $d_id });

$self->delete;
return $destination;
}

sub annotations {
Expand Down
19 changes: 17 additions & 2 deletions t/artist.t
Expand Up @@ -3,7 +3,7 @@ use warnings;

use Data::UUID;
use MusicBrainz::Utils qw/ valid_uuid /;
use Test::More tests => 14;
use Test::More tests => 15;
use Test::Exception;

BEGIN { use_ok('MusicBrainz::Schema'); }
Expand All @@ -17,6 +17,11 @@ my $artist_rs = $schema->resultset('Artist');
$schema->txn_begin;

# Create test data
my $editor = $schema->resultset('Editor')->create({
name => 'Fake',
password => 'fake',
});
my $mod_count;
my ($source, $target) = create_artists();

# Do the merge
Expand All @@ -35,6 +40,9 @@ is($target->aliases->count, 2, 'should have 2 aliases');
# Check releases
is($target->releases->count, 2, 'should have 2 releases');

# Check annotations
is($target->annotations->count, 2, 'should have 2 annotations');

# Clean up
$schema->txn_rollback;

Expand Down Expand Up @@ -74,5 +82,12 @@ sub create_artist {

$artist->create_related('aliases', { name => "$name alias" });

return $artist
$artist->annotations->create_artist_annotation({
artist => $artist,
editor => $editor,
text => 'An annotation',
moderation => $mod_count++,
});

return $artist;
}

0 comments on commit 68e29eb

Please sign in to comment.