Sha256: 82c47309402a7cb648e69d4a95eab27fbe2f5bc77ae581b19808785b14d906b1
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
require 'rubygems' require 'test/unit' require 'shoulda' require 'mocha' $LOAD_PATH.unshift(File.dirname(__FILE__)) require 'has_permission' # this doesn't seem like the best way to do this - maybe someone will suggest a better method class Model include ActiveRecord::Has::Permission has_permission def read_attribute(attr_name) "test" end def write_attribute(attr_name, value) value end def attributes {:read_access => "test", :no_access => "test"} end def some_method "no permission" end def self.all ["no permission"] end end class ModelB include ActiveRecord::Has::Permission has_permission :namespace => '' end class ModelBPermission end module Permission class ModelPermission < Permission::Base def can_read?(attr_name) case attr_name when :read_access : true when :no_access : false else true end end def can_write?(attr_name) case attr_name when :write_access : true when :no_access : false else true end end def some_method "with permission" end def method_missing(method, *args) if method.to_s.match(DEFAULT_FINDERS) ["with permission"] else object.send(method, *args) end end end end class Test::Unit::TestCase end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
johnsbrn-has_permission-0.2.1 | test/test_helper.rb |