Sha256: 3ee9e9f82786845df8de3caf0d2abd62a732819e0c6c04d55f5d6c5ab82357a5

Contents?: true

Size: 1.02 KB

Versions: 14

Compression:

Stored size: 1.02 KB

Contents

require "spec_helper"

describe Shamu::Security::Roles do

  describe "#role" do
    it "adds a role" do
      klass = Class.new do
        include Shamu::Security::Roles

        role :admin
      end

      expect( klass.roles ).to have_key :admin
      expect( klass.roles[:admin] ).to be_a Hash
    end
  end

  describe "#expand_roles" do
    let( :klass ) do
      Class.new do
        include Shamu::Security::Roles

        role :admin, inherits: :manager
        role :manager, inherits: :user
        role :user
      end
    end

    it "includes base roles" do
      expect( klass.expand_roles( :user ) ).to include :user
    end

    it "excludes unknown roles" do
      expect( klass.expand_roles( :magician ) ).to be_empty
    end

    it "includes inherited roles" do
      expect( klass.expand_roles( :manager ) ).to include :user
    end

    it "includes inherited inherited roles" do
      expect( klass.expand_roles( :admin ) ).to include :manager
      expect( klass.expand_roles( :admin ) ).to include :user
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
shamu-0.0.19 spec/lib/shamu/security/roles_spec.rb
shamu-0.0.18 spec/lib/shamu/security/roles_spec.rb
shamu-0.0.17 spec/lib/shamu/security/roles_spec.rb
shamu-0.0.15 spec/lib/shamu/security/roles_spec.rb
shamu-0.0.14 spec/lib/shamu/security/roles_spec.rb
shamu-0.0.13 spec/lib/shamu/security/roles_spec.rb
shamu-0.0.11 spec/lib/shamu/security/roles_spec.rb
shamu-0.0.9 spec/lib/shamu/security/roles_spec.rb
shamu-0.0.8 spec/lib/shamu/security/roles_spec.rb
shamu-0.0.7 spec/lib/shamu/security/roles_spec.rb
shamu-0.0.5 spec/lib/shamu/security/roles_spec.rb
shamu-0.0.4 spec/lib/shamu/security/roles_spec.rb
shamu-0.0.3 spec/lib/shamu/security/roles_spec.rb
shamu-0.0.2 spec/lib/shamu/security/roles_spec.rb