[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.8-160-gd1315a5
? sunnavy
sunnavy at bestpractical.com
Tue Sep 21 00:05:01 EDT 2010
The branch, 3.8-trunk has been updated
via d1315a58baf117b8fb14b17d8b17f5591aa7f72b (commit)
via 53d5b8f15bac78b7c5c5072d09ed887965b54c1d (commit)
from 20693815e7942dc00603f748f74d2e1eb8f36d4b (commit)
Summary of changes:
share/html/Search/Elements/EditSearches | 34 ++++++++++++++---
t/web/saved_search_update.t | 63 +++++++++++++++++++++++++++++++
2 files changed, 91 insertions(+), 6 deletions(-)
create mode 100644 t/web/saved_search_update.t
- Log -----------------------------------------------------------------
commit 53d5b8f15bac78b7c5c5072d09ed887965b54c1d
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Sep 21 11:46:40 2010 +0800
can not do SetObjectType and SetObjectId orderly to an attribute, as they affect the Object arg HasRight will focus on: do the check before instead
diff --git a/share/html/Search/Elements/EditSearches b/share/html/Search/Elements/EditSearches
index fbc1df9..ad4a7e7 100644
--- a/share/html/Search/Elements/EditSearches
+++ b/share/html/Search/Elements/EditSearches
@@ -254,13 +254,35 @@ if ( $obj && $obj->id ) {
if ( $new_obj_type && $new_obj_id ) {
my ($val, $msg);
- if ( $new_obj_type ne $obj_type ) {
- ($val, $msg ) = $obj->SetObjectType($new_obj_type);
- push @results, loc ('Unable to set privacy object: [_1]', $msg) unless ( $val );
+
+ # we need to check right before we change any of ObjectType and ObjectId,
+ # or it will fail the 2nd change if we use SetObjectType and
+ # SetObjectId sequentially
+
+ if ( $obj->CurrentUserHasRight('update') ) {
+ if ( $new_obj_type ne $obj_type ) {
+ ( $val, $msg ) = $obj->__Set(
+ Field => 'ObjectType',
+ Value => $new_obj_type,
+ );
+ push @results, loc( 'Unable to set privacy object: [_1]', $msg )
+ unless ($val);
+ }
+ if ( $new_obj_id != $obj_id ) {
+ ( $val, $msg ) = $obj->__Set(
+ Field => 'ObjectId',
+ Value => $new_obj_id,
+ );
+ push @results, loc( 'Unable to set privacy id: [_1]', $msg )
+ unless ($val);
+ }
}
- if ( $new_obj_id != $obj_id ) {
- ($val, $msg) = $obj->SetObjectId($new_obj_id);
- push @results, loc ('Unable to set privacy id: [_1]', $msg) unless ( $val );
+ else {
+ # two loc are just for convenience so we don't need to
+ # write an extra i18n translation item
+ push @results,
+ loc( 'Unable to set privacy object or id: [_1]',
+ loc('Permission Denied') )
}
} else {
push @results, loc('Unable to determine object type or id');
commit d1315a58baf117b8fb14b17d8b17f5591aa7f72b
Author: sunnavy <sunnavy at bestpractical.com>
Date: Tue Sep 21 11:48:01 2010 +0800
regression test for the SetObjectType and SetObjectId of RT::Attribute
diff --git a/t/web/saved_search_update.t b/t/web/saved_search_update.t
new file mode 100644
index 0000000..9b2724e
--- /dev/null
+++ b/t/web/saved_search_update.t
@@ -0,0 +1,63 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use RT::Test tests => 16;
+
+my $root = RT::User->new( $RT::SystemUser );
+$root->Load('root');
+my $uid = $root->id;
+ok( $uid, 'loaded root' );
+
+my $group = RT::Group->new( $RT::SystemUser );
+my ($gid) = $group->CreateUserDefinedGroup( Name => 'foo' );
+ok( $gid, 'created group foo');
+ok( $group->AddMember( $root->PrincipalId ) );
+
+my ( $baseurl, $m ) = RT::Test->started_ok;
+ok($m->login, 'logged in');
+
+$m->follow_link_ok({text => "Tickets"}, "to query builder");
+
+$m->form_name("BuildQuery");
+
+$m->field(ValueOfid => 10 );
+$m->click("AddClause");
+$m->content_contains( 'id < 10', "added new clause");
+
+$m->form_name("BuildQuery");
+$m->field(SavedSearchDescription => 'user_saved');
+$m->click("SavedSearchSave");
+
+$m->form_name("BuildQuery");
+is($m->value('SavedSearchDescription'), 'user_saved', "name is correct");
+like($m->value('SavedSearchOwner'), qr/^RT::User-\d+$/, "name is correct");
+ok(
+ scalar grep { $_ eq "RT::Group-$gid" }
+ $m->current_form->find_input('SavedSearchOwner')->possible_values,
+ 'found group foo'
+);
+$m->field(SavedSearchDescription => 'group_saved');
+$m->select(SavedSearchOwner => "RT::Group-$gid");
+$m->click("SavedSearchSave");
+
+$m->form_name("BuildQuery");
+is($m->value('SavedSearchOwner'), "RT::Group-$gid", "privacy is correct");
+is($m->value('SavedSearchDescription'), 'group_saved', "name is correct");
+$m->select(SavedSearchOwner => "RT::User-$uid");
+$m->field(SavedSearchDescription => 'user_saved');
+$m->click("SavedSearchSave");
+
+
+$m->form_name("BuildQuery");
+is($m->value('SavedSearchOwner'), "RT::User-$uid", "privacy is correct");
+is($m->value('SavedSearchDescription'), 'user_saved', "name is correct");
+$m->select(SavedSearchOwner => "RT::System-1");
+$m->field(SavedSearchDescription => 'system_saved');
+$m->click("SavedSearchSave");
+
+$m->form_name("BuildQuery");
+is($m->value('SavedSearchOwner'), "RT::System-1", "privacy is correct");
+is($m->value('SavedSearchDescription'), 'system_saved', "name is correct");
+
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list