Sha256: 41bf58b877bcd21efefcc722835d18c617de23a8432eb3460629d178ac9d5cea

Contents?: true

Size: 829 Bytes

Versions: 4

Compression:

Stored size: 829 Bytes

Contents

module Ddr::Auth
  RSpec.describe EffectiveRoles do
    
    let(:resource) { FactoryGirl.build(:item) }
    let(:policy) { Collection.new(id: "coll-1") }
    let(:agents) { [ "Editors", "bob@example.com", "public" ] }
    let(:editor) { Roles::Role.build role_type: "Editor", agent: "Editors", scope: "policy" }
    let(:downloader) { FactoryGirl.build(:role, :downloader, :public) }
    
    before do
      resource.admin_policy = policy
      resource.roles.grant downloader
      policy.roles.grant editor
    end

    it "returns the list of roles granted to the agents on the resource in resource scope, plus the roles granted to the agents on the resource's policy in policy scope" do
      expect(described_class.call(resource, agents))
        .to eq(Roles::RoleSet.new(roles: [downloader, editor]))
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ddr-models-3.0.0.beta.4 spec/auth/effective_roles_spec.rb
ddr-models-3.0.0.beta.3 spec/auth/effective_roles_spec.rb
ddr-models-3.0.0.beta.2 spec/auth/effective_roles_spec.rb
ddr-models-3.0.0.beta.1 spec/auth/effective_roles_spec.rb