Revision history for Catalyst-Plugin-Authentication-Store-DBIx-Class
* Fix doc bugs. RT#87372
+ * Fix calling User->can() as a class method. RT#90715
0.1505 2013-06-10
* Fix RT#82944 - test fails on perl >= 5.17.3
my $self = shift;
return $self->SUPER::can(@_) || do {
my ($method) = @_;
- if (not $self->_user) {
+ if (not ref $self) {
+ undef;
+ } elsif (not $self->_user) {
undef;
} elsif (my $code = $self->_user->can($method)) {
sub { shift->_user->$code(@_) }
(my $method) = (our $AUTOLOAD =~ /([^:]+)$/);
return if $method eq "DESTROY";
+ return unless ref $self;
+
if (my $code = $self->_user->can($method)) {
return $self->_user->$code(@_);
}
use strict;
use warnings;
use Test::More;
+use Try::Tiny;
use Catalyst::Authentication::Store::DBIx::Class::User;
my $message = 'I exist';
sub exists { $message }
}
+my $class = 'Catalyst::Authentication::Store::DBIx::Class::User';
my $o = bless({
_user => bless({}, 'My::Test'),
-}, 'Catalyst::Authentication::Store::DBIx::Class::User');
+}, $class);
is($o->exists, $message, 'AUTOLOAD proxies ok');
is($o->can('non_existent_method'), undef, 'can on non existent method returns undef');
+is($o->non_existent_method, undef, 'AUTOLOAD traps non existent method');
+
+try {
+ is($class->can('non_existent_method'), undef, "can on non existent class method");
+} catch {
+ my $e = $_;
+ fail('can on non existent class method');
+ diag("Got exception: $e");
+};
+
+try {
+ is($class->non_existent_method, undef, 'AUTOLOAD traps non existent class method');
+} catch {
+ my $e = $_;
+ fail('AUTOLOAD traps non existent class method');
+ diag("Got exception: $e");
+};
+
done_testing;