6 use Test::More 'no_plan';
10 use_ok('Text::Tradition::Directory');
12 my $fh = File::Temp->new();
13 my $file = $fh->filename;
15 my $dsn = "dbi:SQLite:dbname=$file";
17 my $user_store = Text::Tradition::Directory->new(
19 'extra_args' => { 'create' => 1 }
23 my $email = 'john@doe.com';
25 my $scope = $user_store->new_scope;
28 my $new_user = $user_store->add_user(
30 password => 'bloggspass'
34 my $t = Text::Tradition->new(
37 'file' => 't/data/simple.txt',
40 $uuid = $user_store->save($t);
41 $new_user->add_tradition($t);
42 $new_user->email($email);
43 $user_store->update($new_user);
47 my $scope = $user_store->new_scope;
49 # change attribute in the user object
50 my $user = $user_store->find_user( { username => 'fred' } );
51 $user->email('foo@bar.baz');
52 $user_store->update($user);
53 is(scalar @{$user->traditions}, 1);
57 my $scope = $user_store->new_scope;
60 my $fetched_t = $user_store->tradition($uuid);
62 # assert that the associated user also changed
63 is( $fetched_t->user->email, 'foo@bar.baz' );
67 my $scope = $user_store->new_scope;
68 my $user = $user_store->find_user( { username => 'fred' } );
70 # change the email back to what it was
72 $user_store->update($user);
76 my $scope = $user_store->new_scope;
79 my $fetched_t = $user_store->tradition( $uuid );
81 # assert that email has actually been reverted
82 is( $fetched_t->user->email, $email );