added test to asset user updates are propagating to the objects associated to traditions
Eden Cardim [Mon, 6 Aug 2012 15:58:33 +0000 (12:58 -0300)]
t/text_tradition_user.t

index a401ebe..7d8b0c7 100644 (file)
@@ -115,6 +115,27 @@ ok($changed->check_password('passbloggs'), 'Modified & retrieved with correct ne
     my $fetched_t = $user_store->tradition($tlist[0]->{id});
     is($fetched_t->user->id, $user->id, 'Traditionlist returns item belonging to this user');
 
+    {
+       # change attribute in the user object
+       my $email = $user->email;
+       $user->email('foo@bar.baz');
+       $user_store->update($user);
+
+       # refetch tradition
+       $fetched_t = $user_store->tradition($tlist[0]->{id});
+       # assert that the associated user also changed
+       is($fetched_t->user->email, 'foo@bar.baz');
+
+       # change the email back to what it was
+       $user->email($email);
+       $user_store->update($user);
+
+       # refetch tradition
+       $fetched_t = $user_store->tradition($tlist[0]->{id});
+       # assert that email has actually been reverted
+       is($fetched_t->user->email, $email);
+    }
+
     ## add a second, not owned by this user, we shouldn't return it from
     ## traditionslist
     my $t2 = Text::Tradition->new(