[Bps-public-commit] jifty-plugin-recordhistory branch, master, updated. 0.05-4-gd99239c

Shawn Moore sartak at bestpractical.com
Thu Feb 24 18:29:11 EST 2011


The branch, master has been updated
       via  d99239cb746c149af409601487048f165447d406 (commit)
      from  484c472a156886d509c1c4e32d311aeb3510f77a (commit)

Summary of changes:
 .../TestApp/Plugin/RecordHistory/Model/Ticket.pm   |   35 ++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)
 create mode 100644 t/TestApp-Plugin-RecordHistory/lib/TestApp/Plugin/RecordHistory/Model/Ticket.pm

- Log -----------------------------------------------------------------
commit d99239cb746c149af409601487048f165447d406
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Thu Feb 24 18:28:57 2011 -0500

    Add a Ticket model with explicit access control for testing

diff --git a/t/TestApp-Plugin-RecordHistory/lib/TestApp/Plugin/RecordHistory/Model/Ticket.pm b/t/TestApp-Plugin-RecordHistory/lib/TestApp/Plugin/RecordHistory/Model/Ticket.pm
new file mode 100644
index 0000000..d5cd59a
--- /dev/null
+++ b/t/TestApp-Plugin-RecordHistory/lib/TestApp/Plugin/RecordHistory/Model/Ticket.pm
@@ -0,0 +1,35 @@
+use strict;
+use warnings;
+
+package TestApp::Plugin::RecordHistory::Model::Ticket;
+use Jifty::DBI::Schema;
+
+use TestApp::Plugin::RecordHistory::Record schema {
+    column subject =>
+        type is 'varchar';
+    column readable =>
+        type is 'integer',
+        default is 1;
+    column updatable =>
+        type is 'integer',
+        default is 1;
+    column deletable =>
+        type is 'integer',
+        default is 1;
+};
+
+use Jifty::Plugin::RecordHistory::Mixin::Model::RecordHistory;
+
+sub current_user_can {
+    my $self  = shift;
+    my $right = shift;
+
+    return 1 if $right eq 'read'   && $self->__value('readable');
+    return 1 if $right eq 'update' && $self->__value('updatable');
+    return 1 if $right eq 'delete' && $self->__value('deletable');
+
+    return $self->SUPER::current_user_can($right, @_);
+}
+
+1;
+

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list