[Rt-commit] rt branch, 4.6/log-view-db-config-change-history, repushed
Aaron Trevena
ast at bestpractical.com
Fri Feb 14 05:38:29 EST 2020
The branch 4.6/log-view-db-config-change-history was deleted and repushed:
was b9dd4bca7bdce3a8f888e0ef571aa1c33b48d355
now 46cd2e3a531944f7ab131586dd889c971c51e806
1: b5ddf186d = 1: b5ddf186d Schema updates for tracking db configuration changes in transactions
2: ee7a01114 ! 2: 230ace51e Log DB config changes as transactions
@@ -13,7 +13,7 @@
my $settings = RT::Configurations->new(RT->SystemUser);
- $settings->UnLimit;
-+ $settings->Limit( FIELD => 'Disabled', VALUE => 0);
++ $settings->LimitToEnabled;
my %seen;
@@ -46,13 +46,12 @@
+ ObjectId => $self->id,
+ NewValue => ( $args{content_type} ) ? sprintf('%s value', $args{content_type}) : $content,
+ OldValue => ( $old_content_type ) ? sprintf('%s value', $old_content_type) : $old_value,
-+ Data => $self->CurrentUser->Name . " created " . $self->Name,
+ ReferenceType => ref($self),
+ NewReference => $self->id,
);
- return ( $id, $self->loc( '[_1] changed from "[_2]" to "[_3]"', $self->Name, $old_value // '', $content // '' ) );
+
-+ if ( RT->Config->Get('DevelMode') or not ($old_content_type || $args{content_type}) ) {
++ if (not ($old_content_type || $args{content_type}) ) {
+ RT->Logger->info($self->CurrentUser->Name . " changed " . $self->Name . " from " . $old_value . " to " . $content);
+ return ($id, $self->loc('[_1] changed from "[_2]" to "[_3]"', $self->Name, $old_value // '', $content // ''));
+ } else {
@@ -82,7 +81,6 @@
+ ReferenceType => ref($self),
+ OldReference => $self->id,
+ OldValue => $old_value,
-+ Data => $self->CurrentUser->Name . " deleted " . $self->Name
+ );
+
return ($ok, $self->loc("Database setting removed."));
@@ -133,13 +131,12 @@
+ ObjectId => $new_id,
+ NewValue => ( $content_type ) ? sprintf('%s value', $content_type) : $value,
+ OldValue => ( $self->ContentType ) ? sprintf('%s value', $self->ContentType) : $self->Content,
-+ Data => $self->CurrentUser->Name . " updated " . $self->Name,
+ ReferenceType => ref($self),
+ OldReference => $self->id,
+ NewReference => $new_id,
+ );
+
-+ if ( RT->Config->Get('DevelMode') or not ($self->ContentType || $content_type) ) {
++ if ( not ($self->ContentType || $content_type) ) {
RT->Logger->info($self->CurrentUser->Name . " changed " . $self->Name . " from " . $old_value . " to " . $value);
return ($ok, $self->loc('[_1] changed from "[_2]" to "[_3]"', $self->Name, $old_value, $value));
} else {
@@ -190,10 +187,8 @@
my $self = shift;
return "Attachment content modified";
},
-+ # **** you are here, need to add SetConfig/CreateConfig and helper here, need to change from set/create
+ SetConfig => sub {
+ my $self = shift;
-+ my $description = '<b>'.$self->Data.'</b><br>';
+ my $new_value = $self->NewValue;
+ my $old_value = $self->OldValue;
+
@@ -211,12 +206,13 @@
+ $new_value = $newobj->Content;
+ }
+
-+ $description .= $self->loc('[_1] changed from "[_2]" to "[_3]"', $self->Field, $old_value, $new_value);
++ my $description = sprintf('<b>%s updated %s</b><br/>%s', $self->CreatorObj->Name, $self->Field, "\n");
++ $description .= $self->loc('[_1] changed from "[_2]" to "[_3]"', $self->Field, $old_value || '', $new_value || '');
+ return $description;
+ },
+ DeleteConfig => sub {
+ my $self = shift;
-+ my $description = '<b>'.$self->Data.'</b><br>';
++ my $description = sprintf('<b>%s deleted %s</b><br/>%s', $self->CreatorObj->Name, $self->Field,"\n");
+ my $old_value = $self->OldValue;
+ # pull in old value from reference if data structure
+ if ($old_value =~ m/^(perl|json).value$/) {
3: b9dd4bca7 ! 3: 46cd2e3a5 Test updates for tracking db configuration changes in transactions
@@ -6,8 +6,11 @@
--- a/t/web/admin_tools_editconfig.t
+++ b/t/web/admin_tools_editconfig.t
@@
+ my ( $url, $m ) = RT::Test->started_ok;
ok( $m->login(), 'logged in' );
++note('using url ' . $m->rt_base_url());
++
$m->follow_link_ok( { text => 'System Configuration' }, 'followed link to "System Configuration"' );
+$m->follow_link_ok( { text => 'History' }, 'followed link to History page' );
$m->follow_link_ok( { text => 'Edit' }, 'followed link to Edit page' );
@@ -39,6 +42,15 @@
my %args = @_;
@@
+ # ensure the config object in the test is up to date with the changes.
+ RT->Config->LoadConfigFromDatabase();
+
+- $m->content_like( qr/$args{setting} changed from/, 'UI indicated the value was changed' );
++ $m->content_like( qr/$args{setting} changed/, 'UI indicated the value was changed' );
+
+ # RT::Configuration->Content returns the value as string.
+ # in the test below we need to also ensure the new value is string.
+@@
cmp_deeply( $rt_config_value, $args{new_value}, 'value from RT->Config->Get matches new value' );
}
@@ -58,7 +70,7 @@
+ my $link_m = $m->clone;
+ $link_m->get_ok($link, 'fetched tx link in history ok');
+ $link_m->content_contains(stringify($change->{new_value}), 'fetched tx has new value');
-+ $link_m->content_contains( $change->{setting}, 'fetched tx has changed field');
++ $link_m->content_contains( "$change->{setting} changed from", 'fetched tx has changed field');
+}
+
+
More information about the rt-commit
mailing list