[Bps-public-commit] RT-Extension-MandatoryOnTransition branch, master, updated. 0.14-2-gb1fe403
Alex Vandiver
alexmv at bestpractical.com
Mon Nov 7 03:13:45 EST 2016
The branch, master has been updated
via b1fe403f5a23f3cebe1c2bb45365a5689d593986 (commit)
via 31bf41a70079871108d7e1833e1d0e453a4a5119 (commit)
from b44e9c78b6ab4de343f625a95ecfcda4fb71f376 (commit)
Summary of changes:
MANIFEST | 1 -
META.yml | 2 +-
README | 5 +++++
inc/Module/Install.pm | 35 ++++++-------------------------
inc/Module/Install/Base.pm | 2 +-
inc/Module/Install/Can.pm | 13 ++++++++++--
inc/Module/Install/Fetch.pm | 2 +-
inc/Module/Install/Include.pm | 2 +-
inc/Module/Install/Makefile.pm | 2 +-
inc/Module/Install/Metadata.pm | 2 +-
inc/Module/Install/Win32.pm | 2 +-
inc/Module/Install/WriteAll.pm | 2 +-
lib/RT/Extension/MandatoryOnTransition.pm | 27 +++++++++++++++++++++++-
xt/mandatory_on_create.t | 18 +++++++++++++++-
14 files changed, 73 insertions(+), 42 deletions(-)
- Log -----------------------------------------------------------------
commit 31bf41a70079871108d7e1833e1d0e453a4a5119
Author: Alex Vandiver <alex at chmrr.net>
Date: Mon Nov 7 00:03:08 2016 -0800
Core RT trims whitespace before updating; do so for "emptyness" check
RT trims leading and trailing whitespace of CF values submitted before
checking them for emptyness or applying them. Not doing so in
MandatoryOnTransition can allow one to skate past a mandatory CF by
entering spaces, which MandatoryOnTransition will treat as "non-empty"
but core RT will ignore.
Use _NormalizeObjectCustomFieldValue to trim whitespace as core RT
does before validating "emptyness" of CFs. This also deals with
multiple-entry and multi-line CFs -- while exposing that
MandatoryOnTransition's behavior for them is not well-defined.
Specifically, it always checks the first value submitted or the first
existing value, which may be insufficient for `must_be` or
`must_not_be` checks. This commit does not attempt to resolve that;
it does document this limitation, however.
diff --git a/lib/RT/Extension/MandatoryOnTransition.pm b/lib/RT/Extension/MandatoryOnTransition.pm
index e7c125f..b17a0a1 100644
--- a/lib/RT/Extension/MandatoryOnTransition.pm
+++ b/lib/RT/Extension/MandatoryOnTransition.pm
@@ -76,6 +76,12 @@ SelfService, for example. See L</TODO> for others.
On 4.0, Basics and Jumbo are not supported because they do not have the
needed code, which is present in 4.2.
+=head2 Multiple-entry CFs do not play well with C<must_be> and C<must_not_be>
+
+The C<must_be> and C<must_not_be> configurations are currently not
+well-defined for multiply-valued CFs. At current, only their first
+value is validated against the configured whitelist or blacklist.
+
=head1 INSTALLATION
=over
@@ -485,11 +491,29 @@ sub CheckMandatoryFields {
my $submitted = $CFArgs->{$cf->id};
# Pick the first grouping
$submitted = $submitted ? $submitted->{(sort keys %$submitted)[0]} : {};
- $value = $submitted->{Values} // $submitted->{Value};
+
+ my @values;
+ for my $argtype (qw/Values Value/) {
+ next if @values;
+ @values = HTML::Mason::Commands::_NormalizeObjectCustomFieldValue(
+ CustomField => $cf,
+ Param => "Object-RT::Ticket-".$TicketId."-CustomField-".$cf->Id."-".$argtype,
+ Value => $submitted->{$argtype},
+ );
+ }
+ # TODO: Understand multi-value CFs
+ ($value) = @values;
}
else {
my $arg = "Object-RT::Ticket-".$TicketId."-CustomField-".$cf->Id."-Value";
$value = ($ARGSRef->{"${arg}s-Magic"} and exists $ARGSRef->{"${arg}s"}) ? $ARGSRef->{$arg . "s"} : $ARGSRef->{$arg};
+ ($value) = grep length, map {
+ s/\r+\n/\n/g;
+ s/^\s+//;
+ s/\s+$//;
+ $_;
+ }
+ grep defined, $value;
}
# Check for specific values
@@ -498,6 +522,7 @@ sub CheckMandatoryFields {
if ( not defined $cf_value and $args{'Ticket'} ){
# Fetch the current value if we didn't receive a new one
+ # TODO: Understand multi-value CFs
$cf_value = $args{'Ticket'}->FirstCustomFieldValue($cf->Name);
}
diff --git a/xt/mandatory_on_create.t b/xt/mandatory_on_create.t
index 6511c86..af5e947 100644
--- a/xt/mandatory_on_create.t
+++ b/xt/mandatory_on_create.t
@@ -1,7 +1,7 @@
use strict;
use warnings;
-use RT::Extension::MandatoryOnTransition::Test tests => 32;
+use RT::Extension::MandatoryOnTransition::Test tests => 38;
use_ok('RT::Extension::MandatoryOnTransition');
@@ -49,6 +49,14 @@ diag "Test mandatory fields on create";
$m->submit_form_ok( { form_name => 'TicketCreate',
fields => { Status => 'resolved',
+ "Object-RT::Ticket--CustomField-$id-Values" => ' '},
+ }, 'Submit with resolved status');
+
+ $m->content_contains('Time Worked is required when changing Status to resolved');
+ $m->content_contains('Test Field is required when changing Status to resolved');
+
+ $m->submit_form_ok( { form_name => 'TicketCreate',
+ fields => { Status => 'resolved',
"Object-RT::Ticket--CustomField-$id-Values" => 'foo'},
}, 'Submit with resolved status');
@@ -80,6 +88,14 @@ diag "Test mandatory fields on create for mobile";
$m->submit_form_ok( { form_name => 'TicketCreate',
fields => { Status => 'resolved',
+ "Object-RT::Ticket--CustomField-$id-Values" => ' '},
+ }, 'Submit with resolved status');
+
+ $m->content_contains('Time Worked is required when changing Status to resolved');
+ $m->content_contains('Test Field is required when changing Status to resolved');
+
+ $m->submit_form_ok( { form_name => 'TicketCreate',
+ fields => { Status => 'resolved',
"Object-RT::Ticket--CustomField-$id-Values" => 'foo'},
}, 'Submit with resolved status');
commit b1fe403f5a23f3cebe1c2bb45365a5689d593986
Author: Alex Vandiver <alex at chmrr.net>
Date: Mon Nov 7 00:13:31 2016 -0800
Update Module::Install, and other packaging
diff --git a/MANIFEST b/MANIFEST
index 868663b..7057039 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -36,4 +36,3 @@ README
xt/basic.t
xt/mandatory_on_create.t
xt/required_fields.t
-
diff --git a/META.yml b/META.yml
index e1ea526..9acc235 100644
--- a/META.yml
+++ b/META.yml
@@ -8,7 +8,7 @@ configure_requires:
ExtUtils::MakeMaker: 6.59
distribution_type: module
dynamic_config: 1
-generated_by: 'Module::Install version 1.16'
+generated_by: 'Module::Install version 1.17'
license: gplv2
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
diff --git a/README b/README
index 85ef7e8..5840638 100644
--- a/README
+++ b/README
@@ -57,6 +57,11 @@ CAVEATS
On 4.0, Basics and Jumbo are not supported because they do not have the
needed code, which is present in 4.2.
+ Multiple-entry CFs do not play well with must_be and must_not_be
+ The must_be and must_not_be configurations are currently not
+ well-defined for multiply-valued CFs. At current, only their first value
+ is validated against the configured whitelist or blacklist.
+
INSTALLATION
perl Makefile.PL
make
diff --git a/inc/Module/Install.pm b/inc/Module/Install.pm
index f44ab4d..dbe10ca 100644
--- a/inc/Module/Install.pm
+++ b/inc/Module/Install.pm
@@ -31,7 +31,7 @@ BEGIN {
# This is not enforced yet, but will be some time in the next few
# releases once we can make sure it won't clash with custom
# Module::Install extensions.
- $VERSION = '1.16';
+ $VERSION = '1.17';
# Storage for the pseudo-singleton
$MAIN = undef;
@@ -244,6 +244,8 @@ sub new {
}
return $args{_self} if $args{_self};
+ $base_path = VMS::Filespec::unixify($base_path) if $^O eq 'VMS';
+
$args{dispatch} ||= 'Admin';
$args{prefix} ||= 'inc';
$args{author} ||= ($^O eq 'VMS' ? '_author' : '.author');
@@ -322,7 +324,7 @@ sub find_extensions {
my ($self, $path) = @_;
my @found;
- File::Find::find( sub {
+ File::Find::find( {no_chdir => 1, wanted => sub {
my $file = $File::Find::name;
return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is;
my $subpath = $1;
@@ -336,7 +338,7 @@ sub find_extensions {
# correctly. Otherwise, root through the file to locate the case-preserved
# version of the package name.
if ( $subpath eq lc($subpath) || $subpath eq uc($subpath) ) {
- my $content = Module::Install::_read($subpath . '.pm');
+ my $content = Module::Install::_read($File::Find::name);
my $in_pod = 0;
foreach ( split /\n/, $content ) {
$in_pod = 1 if /^=\w/;
@@ -351,7 +353,7 @@ sub find_extensions {
}
push @found, [ $file, $pkg ];
- }, $path ) if -d $path;
+ }}, $path ) if -d $path;
@found;
}
@@ -373,8 +375,6 @@ sub _caller {
return $call;
}
-# Done in evals to avoid confusing Perl::MinimumVersion
-eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@;
sub _read {
local *FH;
open( FH, '<', $_[0] ) or die "open($_[0]): $!";
@@ -383,16 +383,6 @@ sub _read {
close FH or die "close($_[0]): $!";
return $string;
}
-END_NEW
-sub _read {
- local *FH;
- open( FH, "< $_[0]" ) or die "open($_[0]): $!";
- binmode FH;
- my $string = do { local $/; <FH> };
- close FH or die "close($_[0]): $!";
- return $string;
-}
-END_OLD
sub _readperl {
my $string = Module::Install::_read($_[0]);
@@ -413,8 +403,6 @@ sub _readpod {
return $string;
}
-# Done in evals to avoid confusing Perl::MinimumVersion
-eval( $] >= 5.006 ? <<'END_NEW' : <<'END_OLD' ); die $@ if $@;
sub _write {
local *FH;
open( FH, '>', $_[0] ) or die "open($_[0]): $!";
@@ -424,17 +412,6 @@ sub _write {
}
close FH or die "close($_[0]): $!";
}
-END_NEW
-sub _write {
- local *FH;
- open( FH, "> $_[0]" ) or die "open($_[0]): $!";
- binmode FH;
- foreach ( 1 .. $#_ ) {
- print FH $_[$_] or die "print($_[0]): $!";
- }
- close FH or die "close($_[0]): $!";
-}
-END_OLD
# _version is for processing module versions (eg, 1.03_05) not
# Perl versions (eg, 5.8.1).
diff --git a/inc/Module/Install/Base.pm b/inc/Module/Install/Base.pm
index 5762a74..3d89918 100644
--- a/inc/Module/Install/Base.pm
+++ b/inc/Module/Install/Base.pm
@@ -4,7 +4,7 @@ package Module::Install::Base;
use strict 'vars';
use vars qw{$VERSION};
BEGIN {
- $VERSION = '1.16';
+ $VERSION = '1.17';
}
# Suspend handler for "redefined" warnings
diff --git a/inc/Module/Install/Can.pm b/inc/Module/Install/Can.pm
index d859276..fc699b3 100644
--- a/inc/Module/Install/Can.pm
+++ b/inc/Module/Install/Can.pm
@@ -8,7 +8,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.16';
+ $VERSION = '1.17';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
@@ -121,6 +121,15 @@ END_C
# Can we locate a (the) C compiler
sub can_cc {
my $self = shift;
+
+ if ($^O eq 'VMS') {
+ require ExtUtils::CBuilder;
+ my $builder = ExtUtils::CBuilder->new(
+ quiet => 1,
+ );
+ return $builder->have_compiler;
+ }
+
my @chunks = split(/ /, $Config::Config{cc}) or return;
# $Config{cc} may contain args; try to find out the program part
@@ -151,4 +160,4 @@ if ( $^O eq 'cygwin' ) {
__END__
-#line 236
+#line 245
diff --git a/inc/Module/Install/Fetch.pm b/inc/Module/Install/Fetch.pm
index 41d3517..3ee0aa1 100644
--- a/inc/Module/Install/Fetch.pm
+++ b/inc/Module/Install/Fetch.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.16';
+ $VERSION = '1.17';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
diff --git a/inc/Module/Install/Include.pm b/inc/Module/Install/Include.pm
index 2eb1d1f..e8a73b8 100644
--- a/inc/Module/Install/Include.pm
+++ b/inc/Module/Install/Include.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.16';
+ $VERSION = '1.17';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
diff --git a/inc/Module/Install/Makefile.pm b/inc/Module/Install/Makefile.pm
index e9918d2..bc81e06 100644
--- a/inc/Module/Install/Makefile.pm
+++ b/inc/Module/Install/Makefile.pm
@@ -8,7 +8,7 @@ use Fcntl qw/:flock :seek/;
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.16';
+ $VERSION = '1.17';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
diff --git a/inc/Module/Install/Metadata.pm b/inc/Module/Install/Metadata.pm
index 9792685..29934cf 100644
--- a/inc/Module/Install/Metadata.pm
+++ b/inc/Module/Install/Metadata.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.16';
+ $VERSION = '1.17';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
diff --git a/inc/Module/Install/Win32.pm b/inc/Module/Install/Win32.pm
index 218a66b..dba25f9 100644
--- a/inc/Module/Install/Win32.pm
+++ b/inc/Module/Install/Win32.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.16';
+ $VERSION = '1.17';
@ISA = 'Module::Install::Base';
$ISCORE = 1;
}
diff --git a/inc/Module/Install/WriteAll.pm b/inc/Module/Install/WriteAll.pm
index 530749b..d553bd7 100644
--- a/inc/Module/Install/WriteAll.pm
+++ b/inc/Module/Install/WriteAll.pm
@@ -6,7 +6,7 @@ use Module::Install::Base ();
use vars qw{$VERSION @ISA $ISCORE};
BEGIN {
- $VERSION = '1.16';
+ $VERSION = '1.17';
@ISA = qw{Module::Install::Base};
$ISCORE = 1;
}
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list