[Rt-commit] rt branch, 4.6/log-view-db-config-change-history, updated. rt-4.4.4-697-gb9dd4bca7b

Aaron Trevena ast at bestpractical.com
Tue Feb 11 11:50:01 EST 2020


The branch, 4.6/log-view-db-config-change-history has been updated
       via  b9dd4bca7bdce3a8f888e0ef571aa1c33b48d355 (commit)
      from  ee7a01114e423bb56029e5d82649608c3fb2bc45 (commit)

Summary of changes:
 t/web/admin_tools_editconfig.t | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

- Log -----------------------------------------------------------------
commit b9dd4bca7bdce3a8f888e0ef571aa1c33b48d355
Author: Aaron Trevena <ast at bestpractical.com>
Date:   Tue Feb 11 16:49:47 2020 +0000

    Test updates for tracking db configuration changes in transactions

diff --git a/t/web/admin_tools_editconfig.t b/t/web/admin_tools_editconfig.t
index 5b4cbd43ac..cadce80985 100644
--- a/t/web/admin_tools_editconfig.t
+++ b/t/web/admin_tools_editconfig.t
@@ -10,6 +10,7 @@ my ( $url, $m ) = RT::Test->started_ok;
 ok( $m->login(), 'logged in' );
 
 $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' );
 
 my $tests = [
@@ -41,6 +42,24 @@ my $tests = [
 
 run_test( %{$_} ) for @{$tests};
 
+# check tx log for configuration
+my $transactions = RT::Transactions->new(RT->SystemUser);
+$transactions->Limit(FIELD => 'ObjectType', VALUE =>  'RT::Configuration');
+$transactions->OrderBy(FIELD => 'Created', ORDER => 'ASC');
+my $tx_items = $transactions->ItemsArrayRef;
+
+my $i = 0;
+foreach my $change (@{$tests}) {
+    check_transaction( $tx_items->[$i++], $change );
+}
+
+# check config history page
+$m->get_ok( $url . '/Admin/Tools/ConfigHistory.html');
+$i = 0;
+foreach my $change (@{$tests}) {
+    check_history_page_item($tx_items->[$i++], $change );
+}
+
 sub run_test {
     my %args = @_;
 
@@ -74,6 +93,26 @@ sub run_test {
     cmp_deeply( $rt_config_value, $args{new_value}, 'value from RT->Config->Get matches new value' );
 }
 
+sub check_transaction {
+    my ($tx, $change) = @_;
+    is($tx->ObjectType, 'RT::Configuration', 'tx is config change');
+    is($tx->Field, $change->{setting}, 'tx matches field changed');
+    is($tx->NewValue, stringify($change->{new_value}), 'tx value matches');
+    $change->{tx_id} = $tx->id;
+}
+
+sub check_history_page_item {
+    my ($tx, $change) = @_;
+    my $link = "/Transaction/Display.html?id=".$tx->id;
+    ok($m->find_link(url => $link), 'found tx link in history');
+
+    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');
+}
+
+
 sub stringify {
     my $value = shift;
 

-----------------------------------------------------------------------


More information about the rt-commit mailing list