[Rt-commit] rt branch, 4.0/delete-user-attributes-on-reset, updated. rt-4.0.4-117-gef23ab5
Jason May
jasonmay at bestpractical.com
Fri Feb 10 15:23:43 EST 2012
The branch, 4.0/delete-user-attributes-on-reset has been updated
via ef23ab538a49078d64f4f7ba105e92e78acf004b (commit)
from fbf9ae9c00bc6a850f7c100937d7e792b37bb460 (commit)
Summary of changes:
share/html/Prefs/Search.html | 4 +-
t/web/reset_prefs.t | 57 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 2 deletions(-)
create mode 100644 t/web/reset_prefs.t
- Log -----------------------------------------------------------------
commit ef23ab538a49078d64f4f7ba105e92e78acf004b
Author: Jason May <jasonmay at bestpractical.com>
Date: Fri Feb 10 15:22:46 2012 -0500
Add tests for resetting preferences
diff --git a/share/html/Prefs/Search.html b/share/html/Prefs/Search.html
index 2d02eb1..204f164 100644
--- a/share/html/Prefs/Search.html
+++ b/share/html/Prefs/Search.html
@@ -69,10 +69,10 @@
</form>
<&|/Widgets/TitleBox, title => loc("Reset adjustments") &>
-<form method="post" action="Search.html">
+<form method="post" name="ResetSearchOptions" action="Search.html">
<input type="hidden" name="Reset" value="1" />
<input type="hidden" name="name" value="<%$ARGS{name}%>" class="hidden" />
-<input type="submit" class="button" value="<% loc('Reset to default') %>">
+<input type="submit" class="button" name="ResetSearchOptions" value="<% loc('Reset to default') %>">
</form>
</&>
diff --git a/t/web/reset_prefs.t b/t/web/reset_prefs.t
new file mode 100644
index 0000000..9ad777f
--- /dev/null
+++ b/t/web/reset_prefs.t
@@ -0,0 +1,57 @@
+#!/usr/bin/perl -w
+use strict;
+
+use RT::Test tests => undef;
+my ($baseurl, $m) = RT::Test->started_ok;
+$m->login;
+my $url = $m->rt_base_url;
+
+#TODO Test resetting RT at a glance
+
+# find a saved search
+my $search;
+{
+ my $system = RT::System->new(RT->SystemUser);
+ while (my $attribute = $system->Attributes->Next) {
+ if ($attribute->Name =~ /^Search - /) {
+ $search = $attribute;
+ last;
+ }
+ }
+}
+
+my $search_name = 'RT::Attribute-'.$search->id;
+my $pref_name = 'Pref-'.$search_name;
+my $uri = URI->new($url.'Prefs/Search.html');
+$uri->query_form(
+ OrderBy => 'Priority|Due', # something different from the default
+ name => $search_name,
+);
+
+$m->get($uri);
+
+require RT::User;
+my $user = RT::User->new(RT->SystemUser);
+$user->Load('root');
+
+require RT::Attribute;
+my $pref = RT::Attribute->new($user);
+
+my ($pref_created, $pref_exists);
+($pref_exists) = $pref->LoadByNameAndObject(Name => $pref_name, Object => $user);
+ok(!$pref_exists, 'Preference does not exist yet');
+
+$m->form_name('BuildQuery');
+$m->click_button(name => 'Save');
+
+($pref_created) = $pref->LoadByNameAndObject(Name => $pref_name, Object => $user);
+ok($pref_created, 'Preference was successfully created upon saving');
+
+$m->form_name('ResetSearchOptions');
+$m->click_button(name => 'ResetSearchOptions');
+
+$m->form_name('BuildQuery');
+isnt($m->value('OrderBy', 2), 'Due', 'Custom prefs were cleared');
+
+undef $m;
+done_testing();
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list