From 0498f440486830afd172f871235f7b191225efab Mon Sep 17 00:00:00 2001 From: AntonioTerceiro Date: Sat, 9 Feb 2008 17:59:27 +0000 Subject: [PATCH] ActionItem154: adding an accessor for permissions instead of initializing it in constructor --- vendor/plugins/access_control/lib/role.rb | 3 +++ vendor/plugins/access_control/test/role_test.rb | 5 +++++ 2 files changed, 8 insertions(+), 0 deletions(-) diff --git a/vendor/plugins/access_control/lib/role.rb b/vendor/plugins/access_control/lib/role.rb index ec0258e..a6d2df0 100644 --- a/vendor/plugins/access_control/lib/role.rb +++ b/vendor/plugins/access_control/lib/role.rb @@ -8,6 +8,9 @@ class Role < ActiveRecord::Base def initialize(*args) super(*args) + end + + def permissions self[:permissions] ||= [] end diff --git a/vendor/plugins/access_control/test/role_test.rb b/vendor/plugins/access_control/test/role_test.rb index 4e1fb18..68cc4e9 100644 --- a/vendor/plugins/access_control/test/role_test.rb +++ b/vendor/plugins/access_control/test/role_test.rb @@ -68,4 +68,9 @@ class RoleTest < Test::Unit::TestCase end + def test_should_have_an_empty_array_as_permissions_by_default + role = Role.new + assert_equal [], role.permissions + end + end -- libgit2 0.21.2