Fix bug where groups were being created with no defaults.
Update Group test to check for default values in groups created with gid "new" and "".
This commit is contained in:
parent
cce6dc6e0a
commit
206a294988
3 changed files with 49 additions and 22 deletions
|
|
@ -15,4 +15,4 @@
|
|||
- fix: Pagination not working in User Management System
|
||||
- fix: Upgrade 6.8.10 to 6.99.5 (Thanks to Erik Svanberg for the patch)
|
||||
- fix: Adding Survey Choices
|
||||
|
||||
- fix: User/Group problem
|
||||
|
|
|
|||
|
|
@ -80,7 +80,15 @@ These methods are available from this class:
|
|||
sub _create {
|
||||
my $self = shift;
|
||||
my $override = shift;
|
||||
$self->{_groupId} = $self->session->db->setRow("groups","groupId",{
|
||||
$self->{_groupId} = $self->session->db->setRow("groups","groupId", $self->_defaults, $override);
|
||||
$self->addGroups([3]);
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub _defaults {
|
||||
my $self = shift;
|
||||
return {
|
||||
groupId=>"new",
|
||||
dateCreated=>$self->session->datetime->time(),
|
||||
expireOffset=>314496000,
|
||||
|
|
@ -91,9 +99,12 @@ sub _create {
|
|||
expireNotify=>0,
|
||||
databaseLinkId=>0,
|
||||
groupCacheTimeout=>3600,
|
||||
lastUpdated=>$self->session->datetime->time()
|
||||
}, $override);
|
||||
$self->addGroups([3]);
|
||||
lastUpdated=>$self->session->datetime->time(),
|
||||
autoAdd=>0,
|
||||
autoDelete=>0,
|
||||
isEditable=>1,
|
||||
showInForms=>1,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -971,7 +982,12 @@ sub new {
|
|||
my $cached = $self->{_session}->stow->get("groupObj");
|
||||
return $cached->{$self->{_groupId}} if ($cached->{$self->{_groupId}});
|
||||
bless $self, $class;
|
||||
$self->_create($override) if ($self->{_groupId} eq "new");
|
||||
if ($self->{_groupId} eq "new") {
|
||||
$self->_create($override);
|
||||
}
|
||||
elsif ($self->{_groupId} eq "") {
|
||||
$self->{_group} = $self->_defaults();
|
||||
}
|
||||
$cached->{$self->{_groupId}} = $self;
|
||||
$self->{_session}->stow->set("groupObj", $cached);
|
||||
return $self;
|
||||
|
|
|
|||
43
t/Group.t
43
t/Group.t
|
|
@ -75,35 +75,46 @@ my @ipTests = (
|
|||
);
|
||||
|
||||
|
||||
plan tests => (103 + scalar(@scratchTests) + scalar(@ipTests)); # increment this value for each test you create
|
||||
plan tests => (118 + scalar(@scratchTests) + scalar(@ipTests)); # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
my $testCache = WebGUI::Cache->new($session, 'myTestKey');
|
||||
$testCache->flush;
|
||||
|
||||
foreach my $gid ('new', '') {
|
||||
my $g = WebGUI::Group->new($session, $gid);
|
||||
|
||||
##Check defaults
|
||||
is (ref $g, "WebGUI::Group", "Group object creation");
|
||||
isnt ($g->getId, "new", "Group assigned new groupId, not new");
|
||||
is ($g->name(), 'New Group', 'Default name');
|
||||
is ($g->expireOffset(), 314496000, 'Default expireOffset');
|
||||
is ($g->karmaThreshold(), 1_000_000_000, 'Default karma threshold');
|
||||
is ($g->expireNotifyOffset(), -14, 'Default expire notify offset time');
|
||||
is ($g->deleteOffset(), 14, 'Default delete offset time');
|
||||
is ($g->expireNotify(), 0, 'Default expire notify time');
|
||||
is ($g->databaseLinkId(), 0, 'Default databaseLinkId');
|
||||
is ($g->groupCacheTimeout(), 3600, 'Default external database cache timeout');
|
||||
is ($g->dateCreated(), $g->lastUpdated(), 'lastUpdated = create time');
|
||||
is ($g->autoAdd(), 0, 'auto Add is off by default');
|
||||
is ($g->autoDelete(), 0, 'auto Delete is off by default');
|
||||
is ($g->isEditable(), 1, 'isEditable is on by default');
|
||||
is ($g->showInForms(), 1, 'show in forms is on by default');
|
||||
|
||||
$g->delete;
|
||||
}
|
||||
|
||||
my $empty = WebGUI::Group->new($session, '');
|
||||
|
||||
my $g = WebGUI::Group->new($session, "new");
|
||||
|
||||
is (ref $g, "WebGUI::Group", "Group object creation");
|
||||
my $gid = $g->getId;
|
||||
isnt ($gid, "new", "Group assigned new groupId, not new");
|
||||
is (length($gid), 22, "GroupId is proper length");
|
||||
is ($g->name(), 'New Group', 'Default name');
|
||||
is ($g->expireOffset(), 314496000, 'Default karma threshold');
|
||||
is ($g->karmaThreshold(), 1_000_000_000, 'Default karma threshold');
|
||||
is ($g->expireNotifyOffset(), -14, 'Default expire notify offset time');
|
||||
is ($g->deleteOffset(), 14, 'Default delete offset time');
|
||||
is ($g->expireNotify(), 0, 'Default expire notify time');
|
||||
is ($g->databaseLinkId(), 0, 'Default databaseLinkId');
|
||||
is ($g->groupCacheTimeout(), 3600, 'Default external database cache timeout');
|
||||
is ($g->dateCreated(), $g->lastUpdated(), 'lastUpdated = create time');
|
||||
|
||||
is_deeply ($g->getGroupsIn(), [3], 'Admin group added by default to this group');
|
||||
is_deeply ($g->getGroupsFor(), [], 'Group not added to any other group');
|
||||
is_deeply ($g->getUsers(), [], 'No users added by default');
|
||||
is_deeply ($g->getAllUsers(), [3], 'No users added by default in any method');
|
||||
is ($g->autoAdd(), 0, 'auto Add is off by default');
|
||||
is ($g->autoDelete(), 0, 'auto Delete is off by default');
|
||||
is ($g->isEditable(), 1, 'isEditable is on by default');
|
||||
is ($g->showInForms(), 1, 'show in forms is on by default');
|
||||
|
||||
my $gname = '**TestGroup**';
|
||||
is ($g->name($gname), $gname, 'Set name');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue