Skip to content
This repository
Browse code

Removing MT-version-specific test assumptions in permissions test

* Order of keys in returned JSON dict cannot be relied upon
* "John Doe" test suite user no longer assumed to start with author permissions
  • Loading branch information...
commit 7a0af8c7f665e616f4e6898c994247fd4fa4d32e 1 parent 1bd0e7f
Steve Cook snark authored

Showing 1 changed file with 10 additions and 6 deletions. Show diff stats Hide diff stats

  1. +10 6 plugins/reblog/t/40-permissions.t
16 plugins/reblog/t/40-permissions.t
@@ -20,9 +20,13 @@ my $john = MT::Author->load({ nickname => 'John Doe' });
20 20
21 21 my $blog = MT::Blog->load( 1 );
22 22
23   -my $perms = MT::Permission->load({ blog_id => $blog->id,
24   - author_id => $john->id });
25   -$perms->clear_full_permissions();
  23 +my $perms;
  24 +unless ( $perms =
  25 + MT::Permission->load({ blog_id => $blog->id, author_id => $john->id }) ) {
  26 + $perms = MT::Permission->new();
  27 + $perms->blog_id($blog->id);
  28 + $perms->author_id($john->id);
  29 +}
26 30 $perms->can_create_post(1);
27 31 $perms->can_edit_all_posts(1);
28 32
@@ -41,7 +45,7 @@ out_like ('MT::App::CMS', { __test_user => $john, blog_id => $blog->id }, qr|__m
41 45 out_like ('MT::App::CMS', { __test_user => $john, __mode => 'rb_blog_config', blog_id => $blog->id }, qr|<h2 id="page-title">Configure Reblog</h2>|, "Blog administrator has reblog config access in the CMS");
42 46 out_like ('MT::App::CMS', { __test_user => $john, blog_id => $blog->id }, qr|__mode=rb_view_sourcefeeds|, "Blog administrator has manage sourcefeeds menu access");
43 47 out_like ('MT::App::CMS', { __test_user => $john, __mode => 'rb_view_sourcefeeds', blog_id => $blog->id }, qr|No sourcefeeds could be found.|, "Blog administrator has sourcefeed list access in the CMS");
44   -out_like ('MT::App::CMS', { __test_user => $john, __mode => 'rb_validate_json', blog_id => $blog->id }, qr|{"success":0,"errstr":"No sourcefeed given"}|, "Blog administrator has validate sourcefeed access in the CMS");
  48 +out_like ('MT::App::CMS', { __test_user => $john, __mode => 'rb_validate_json', blog_id => $blog->id }, qr|"success":0}|, "Blog administrator has validate sourcefeed access in the CMS");
45 49 out_like ('MT::App::CMS', { __test_user => $john, __mode => 'edit_sourcefeed', blog_id => $blog->id }, qr|Validation check has not been run|, "Blog administrator has edit sourcefeed access in the CMS");
46 50 out_like ('MT::App::CMS', { __test_user => $john, __mode => 'save_sourcefeed', blog_id => $blog->id }, qr|Invalid request.|, "Blog administrator has save sourcefeed access in the CMS");
47 51
@@ -52,7 +56,7 @@ out_unlike ('MT::App::CMS', { __test_user => $john, blog_id => $blog->id }, qr|R
52 56 out_like ('MT::App::CMS', { __test_user => $john, __mode => 'rb_blog_config', blog_id => $blog->id }, qr|You cannot configure|, "(restrict_reblog setting) Blog administrator user has NO reblog config access in the CMS");
53 57 out_like ('MT::App::CMS', { __test_user => $john, blog_id => $blog->id }, qr|__mode=rb_view_sourcefeeds|, "(restrict_reblog setting) Blog administrator has manage sourcefeeds menu access");
54 58 out_like ('MT::App::CMS', { __test_user => $john, __mode => 'rb_view_sourcefeeds', blog_id => $blog->id }, qr|No sourcefeeds could be found.|, "(restrict_reblog setting) Blog administrator has sourcefeed list access in the CMS");
55   -out_like ('MT::App::CMS', { __test_user => $john, __mode => 'rb_validate_json', blog_id => $blog->id }, qr|{"success":0,"errstr":"No sourcefeed given"}|, "(restrict_reblog setting) Blog administrator has validate sourcefeed access in the CMS");
  59 +out_like ('MT::App::CMS', { __test_user => $john, __mode => 'rb_validate_json', blog_id => $blog->id }, qr|"success":0|, "(restrict_reblog setting) Blog administrator has validate sourcefeed access in the CMS");
56 60 out_like ('MT::App::CMS', { __test_user => $john, __mode => 'edit_sourcefeed', blog_id => $blog->id }, qr|Validation check has not been run|, "(restrict_reblog setting) Blog administrator has edit sourcefeed access in the CMS");
57 61 out_like ('MT::App::CMS', { __test_user => $john, __mode => 'save_sourcefeed', blog_id => $blog->id }, qr|Invalid request.|, "(restrict_reblog setting) Blog administrator has save sourcefeed access in the CMS");
58 62
@@ -76,6 +80,6 @@ out_like ('MT::App::CMS', { __test_user => $john, blog_id => $blog->id }, qr|__m
76 80 out_like ('MT::App::CMS', { __test_user => $john, __mode => 'rb_blog_config', blog_id => $blog->id }, qr|<h2 id="page-title">Configure Reblog</h2>|, "(both restrictions) System administrator has reblog config access in the CMS");
77 81 out_like ('MT::App::CMS', { __test_user => $john, blog_id => $blog->id }, qr|__mode=rb_view_sourcefeeds|, "(both restrictions) System administrator has manage sourcefeeds menu access");
78 82 out_like ('MT::App::CMS', { __test_user => $john, __mode => 'rb_view_sourcefeeds', blog_id => $blog->id }, qr|No sourcefeeds could be found.|, "(both restrictions) System administrator has sourcefeed list access in the CMS");
79   -out_like ('MT::App::CMS', { __test_user => $john, __mode => 'rb_validate_json', blog_id => $blog->id }, qr|{"success":0,"errstr":"No sourcefeed given"}|, "(both restrictions) System administrator has validate sourcefeed access in the CMS");
  83 +out_like ('MT::App::CMS', { __test_user => $john, __mode => 'rb_validate_json', blog_id => $blog->id }, qr|success":0|, "(both restrictions) System administrator has validate sourcefeed access in the CMS");
80 84 out_like ('MT::App::CMS', { __test_user => $john, __mode => 'edit_sourcefeed', blog_id => $blog->id }, qr|Validation check has not been run|, "(both restrictions) System administrator has edit sourcefeed access in the CMS");
81 85 out_like ('MT::App::CMS', { __test_user => $john, __mode => 'save_sourcefeed', blog_id => $blog->id }, qr|Invalid request.|s, "(both restrictions) System administrator has save sourcefeed access in the CMS");

0 comments on commit 7a0af8c

Please sign in to comment.
Something went wrong with that request. Please try again.