# Copyright (c) 2011 bivio Software, Inc. All Rights Reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: MailUnsubscribeForm.bunit,v 2.1 2011/02/06 01:50:07 nagler Exp $ FormModel(); my($case) = sub { my($realm, $user, $button, @roles) = @_; req()->set_realm_and_user($realm, $user); my($date) = class('Type.DateTime')->rfc822(DateTime()->now); my($message_id) = random_string() . '@bivio.biz'; my($rm) = model('RealmMail'); $rm->create_from_rfc822(\(<<"EOF")); Message-Id: <$message_id> Subject: Re: MailUnsubscribeForm1 From: any user Date: $date text1 EOF return ( req_state({ user => $user, realm => $user, path_info => '/' . $rm->get('realm_file_id'), }), [{$button => 1}] => sub { req()->set_realm($realm); assert_equals( \@roles, model('RealmUser')->map_iterate( sub {shift->get('role')}, 'role', {user_id => realm_id($user)}, ), ); assert_equals( [], model('RealmUser')->map_iterate( sub {shift->get('realm_id')}, 'unauth_iterate_start', 'realm_id', { user_id => realm_id($user), role => Auth_Role('MAIL_RECIPIENT'), }, ), ) if $button eq 'all_button'; return 1; }, ); }; [ $case->(qw(mail_forum mail_user1 ok_button ADMINISTRATOR FILE_WRITER)), $case->(qw(bulletin bulletin_user ok_button)), $case->(qw(mail_forum mail_user1 all_button ADMINISTRATOR FILE_WRITER)), $case->(qw(bulletin bulletin_user all_button)), ];