From c6045b0028128cc6757efc709d355fb516c4244d Mon Sep 17 00:00:00 2001 From: Daniel Munn Date: Tue, 31 Jul 2012 08:12:53 +0100 Subject: [PATCH] Starting implementation of Permission models (very early commit) --- app/models/dmsf_lock.rb | 2 +- app/models/dmsf_permission.rb | 22 ++++++++++++++++++++++ test/fixtures/dmsf_permissions.yml | 0 test/unit/dmsf_permission_test.rb | 26 ++++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 app/models/dmsf_permission.rb create mode 100644 test/fixtures/dmsf_permissions.yml create mode 100644 test/unit/dmsf_permission_test.rb diff --git a/app/models/dmsf_lock.rb b/app/models/dmsf_lock.rb index a3d603f1..1fba2785 100644 --- a/app/models/dmsf_lock.rb +++ b/app/models/dmsf_lock.rb @@ -1,6 +1,7 @@ # Redmine plugin for Document Management System "Features" # # Copyright (C) 2011 Vít Jonáš +# Copyright (C) 2012 Daniel Munn # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -17,7 +18,6 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class DmsfLock < ActiveRecord::Base -# unloadable before_create :generate_uuid belongs_to :file, :class_name => "DmsfFile", :foreign_key => "entity_id" belongs_to :folder, :class_name => "DmsfFolder", :foreign_key => "entity_id" diff --git a/app/models/dmsf_permission.rb b/app/models/dmsf_permission.rb new file mode 100644 index 00000000..42f351ea --- /dev/null +++ b/app/models/dmsf_permission.rb @@ -0,0 +1,22 @@ +# Redmine plugin for Document Management System "Features" +# +# Copyright (C) 2011 Vít Jonáš +# Copyright (C) 2012 Daniel Munn +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class DmsfPermission < ActiveRecord::Base + as_enum :scope, [:SCOPE_WRITE, :SCOPE_READ, :SCOPE_MODIFY, :SCOPE_LOCK, :SCOPE] +end diff --git a/test/fixtures/dmsf_permissions.yml b/test/fixtures/dmsf_permissions.yml new file mode 100644 index 00000000..e69de29b diff --git a/test/unit/dmsf_permission_test.rb b/test/unit/dmsf_permission_test.rb new file mode 100644 index 00000000..e50e3acf --- /dev/null +++ b/test/unit/dmsf_permission_test.rb @@ -0,0 +1,26 @@ +require File.expand_path('../../test_helper.rb', __FILE__) + +class DmsfPermissionTest < RedmineDmsf::Test::UnitTest + attr_reader :perm + fixtures :projects, :users, :dmsf_folders, :dmsf_files, :dmsf_file_revisions, + :roles, :members, :member_roles, :enabled_modules, :enumerations + + def setup + end + + test "Static values compute" do + assert_equal 1, DmsfPermission::READ #Read / Browse + assert_equal 2, DmsfPermission::WRITE #Write (new file / owned file) + assert_equal 4, DmsfPermission::MODIFY #Modify existing file/folder - create revision + assert_equal 8, DmsfPermission::LOCK #Ability to lock/unlock + + assert_equal 7, DmsfPermission::MODIFY | DmsfPermission::WRITE | DmsfPermission::READ + end + + test "create" do + +# DmsfPermission + end + +end +