Show
Ignore:
Timestamp:
04/16/08 15:36:30 (20 months ago)
Author:
mpaschal
Message:

Land the new implementation of metadata based on narrow tables
BugzID: 68749

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/release-35/t/22-author.t

    r1100 r1927  
    88use lib 'extlib'; 
    99 
    10 use Test::More tests => 54; 
     10use Test::More tests => 64; 
    1111 
    1212use MT; 
     
    3434my $perm = $author->blog_perm(1); 
    3535ok($perm, "$author->blog_perm(1)") || die; 
    36 ok($author->can_edit_entry(1), 'can_edit_entry(1)'); 
    37 ok($author->can_edit_entry(2), 'can_edit_entry(2)'); 
     36ok($author->can_edit_entry(1), 'Chuck D can edit entry #1'); 
     37ok($author->can_edit_entry(2), 'Chuck D can edit entry #2'); 
    3838ok($perm->can_comment, 'can_comment'); 
    3939ok($perm->can_post, 'can_post'); 
     
    5858 
    5959{ 
     60diag('meta field tests'); 
     61 
     62my $author = MT::Author->load({ name => 'Chuck D' }); 
     63ok(eval { $author->widgets(); 1 }, 'Author obj has widgets accessor'); 
     64ok(!defined $author->widgets, "Author's widgets are undefined by default"); 
     65ok(!defined $author->favorite_blogs, "Author's favorite blogs are undefined by default"); 
     66 
     67    # same as in MT::CMS::Dashboard, but that's not necessary 
     68    my $default_widgets = { 
     69        'blog_stats' => 
     70          { param => { tab => 'entry' }, order => 1, set => 'main' }, 
     71        'this_is_you-1' => { order => 1, set => 'sidebar' }, 
     72        'mt_shortcuts'  => { order => 2, set => 'sidebar' }, 
     73        'mt_news'       => { order => 3, set => 'sidebar' }, 
     74    }; 
     75 
     76my $fav_blogs = [1, 7];  # not actually a blog #7, but meh 
     77 
     78ok($author->widgets($default_widgets), "Author's widgets can be set"); 
     79ok($author->favorite_blogs($fav_blogs), "Author's favorite blogs can be set"); 
     80ok($author->save(), "Author with modified widgets can be saved"); 
     81 
     82require MT::ObjectDriver::Driver::Cache::RAM; 
     83MT::ObjectDriver::Driver::Cache::RAM->clear_cache(); 
     84 
     85$author = MT::Author->load({ name => 'Chuck D' }); 
     86 
     87ok($author->widgets, "Modified author has widgets"); 
     88is_deeply($author->widgets, $default_widgets, "Author's widgets survived being saved accurately"); 
     89 
     90ok($author->favorite_blogs, "Modified author has favorite blogs"); 
     91is_deeply($author->favorite_blogs, $fav_blogs, "Author's favorite blogs survived being saved accurately"); 
     92} 
     93 
     94{ 
    6095my $author = MT::Author->load({ name => 'Bob D' }); 
    6196$author = MT::Author->load($author->id);  # silly ruse to force caching....  
     
    68103ok( ! $author->can_view_log, 'can_view_log' ); 
    69104ok( ! $author->can_manage_plugins, 'can manage plugins'); 
    70 ok( ! $author->can_edit_entry(1), 'can_edit_entry(1)' ); 
    71 ok(   $author->can_edit_entry(2), 'can_edit_entry(2)' ); 
     105ok( ! $author->can_edit_entry(1), 'Bob D can edit entry #1' ); 
     106ok(   $author->can_edit_entry(2), 'Bob D can edit entry #2' ); 
    72107ok(   $perm->can_post, 'can_post' ); 
    73108ok(   $perm->can_create_post, 'can_create_post'); 
    74109ok(   $perm->can_publish_post, 'can_publish_post'); 
    75 ok( ! $perm->can_upload, 'can_upload' ); 
    76 ok( ! $perm->can_edit_all_posts, 'can_edit_all_posts' ); 
     110ok(   $perm->can_upload, 'Bob D can *not* upload files' ); 
     111ok( ! $perm->can_edit_all_posts, 'Bob D can *not* edit all posts' ); 
    77112ok( ! $perm->can_manage_pages, 'can_manage_pages'); 
    78 ok(   $perm->can_edit_templates, 'can_edit_templates' ); 
     113ok( ! $perm->can_edit_templates, 'Bob D can *not* edit templates' ); 
    79114ok( ! $perm->can_edit_tags, 'can_edit_tags'); 
    80115ok( ! $perm->can_edit_config, 'can_edit_config' ); 
    81116ok( ! $perm->can_set_publish_paths, 'can_set_publish_paths'); 
    82117ok( ! $perm->can_rebuild, 'can_rebuild' ); 
    83 ok( ! $perm->can_send_notifications, 'can_send_notifications' ); 
     118ok(   $perm->can_send_notifications, 'Bob D can send notifications' ); 
    84119ok( ! $perm->can_edit_categories, 'can_edit_categories' ); 
    85120ok( ! $perm->can_edit_notifications, 'can_edit_notifications' );