Sha256: 637e7113f6d0edb589b8580974cb5bb3d1c9bc3a2e2a287cfa0f1bfd501d584b
Contents?: true
Size: 1.78 KB
Versions: 1
Compression:
Stored size: 1.78 KB
Contents
require "spec_helper" module Tuersteher describe ModelAccessRule do context "grant with roles" do before(:all) do @rule = ModelAccessRule.new(String).grant.permission(:read).role(:sysadmin).role(:admin) end context "for User with role :admin" do before do @user = stub('user') @user.stub(:has_role?) { |role| role==:admin } end it "should be fired for String-Object and access-type :read" do @rule.fired?("test", :read, @user).should be_true end it "should not be fired for Non-String-Object" do @rule.fired?(12345, :read, @user).should_not be_true end it "should not be fired for String-Object and other access-type as :read" do @rule.fired?("test", :delete, @user).should_not be_true end end context "for User without role :admin" do before do @user = stub('user') @user.stub(:has_role?).and_return(false) end it "should not be fired for String-Object and access-type :read" do @rule.fired?("test", :read, @user).should_not be_true end end end # of context "grant with roles" context "deny with not.role" do before(:all) do @rule = ModelAccessRule.new(String).deny.permission(:append).not.role(:admin) @user = stub('user') end it "should not fired for user with role :admin" do @user.stub(:has_role?){|role| role==:admin} @rule.fired?("/admin", :append, @user).should_not be_true end it "should fired for user with role :user" do @user.stub(:has_role?){|role| role==:user} @rule.fired?("/admin", :append, @user).should be_true end end # of context "deny with not.role" end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tuersteher-0.3.0 | spec/model_access_rule_spec.rb |