[jifty-devel] More warnings when update permission fails.

Edmund von der Burg evdb at ecclestoad.co.uk
Wed Mar 7 07:59:47 EST 2007


I've just spent a little while being confused about why this test
suite passes but the database is not changed:

  ok $normal->set_name('test'), "change name";

I now realise that because 'set_name' returns '($status, $msg)' that
test will always pass, even if it does not set the value.

Two things:

1) What is the most elegant way to write these sort of tests? Looking
through Jifty::Test there is nothing like the follows:

  model_ok $normal->set_name('good value'), "change name";
  model_not_ok $normal->set_name('bad value'), "change name";

Would this be the way to go or is there a better way? If this is the
best approach then I'll code it up and add it.

2) Could we add more diagnostics when permissions fail. My guess is
that ideally they never should in a properly written app as the user
should never be given a chance to try a bad action. Hence changing
Jifty::Record's '_set' to this would make it easier to debug:

# in Jifty::Record
sub _set {
    my $self = shift;

    unless ( $self->check_update_rights(@_) ) {
        carp "Update permission denied"; #                    <--- new line
        return ( 0, _('Permission denied') );

Possibly this should only be enabled in devel mode or something?


In reality I'm evdb at ecclestoad.co.uk - http://ecclestoad.co.uk

More information about the jifty-devel mailing list