Sha256: 88e88d7dfea8cc6a873b87b39bc7132f71d9ec431823576a5e086c9fad270ca5

Contents?: true

Size: 1.29 KB

Versions: 57

Compression:

Stored size: 1.29 KB

Contents

module Ddr::Auth
  RSpec.describe LegacyDefaultPermissions do

    subject { described_class.new(obj) }

    let(:obj) { FactoryGirl.build(:collection) }

    before do
      @deprecation_behavior = Deprecation.default_deprecation_behavior
      Deprecation.default_deprecation_behavior = :silence
      obj.default_permissions = [{access: "edit", type: "group", name: "Editors"},
                                 {access: "discover", type: "group", name: "public"},
                                 {access: "read", type: "person", name: "bob@example.com"}]
    end
    
    after do
      Deprecation.default_deprecation_behavior = @deprecation_behavior
    end

    it "should convert the default permissions to policy roles" do
      expect(subject.to_roles)
        .to eq(Roles::DetachedRoleSet.new(
                [ Roles::Role.build(type: "Curator", agent: "Editors", scope: "policy"),
                  Roles::Role.build(type: "Viewer", agent: "public", scope: "policy"),
                  Roles::Role.build(type: "Viewer", agent: "bob@example.com", scope: "policy")
                ]
              ))
    end

    it "should clear the legacy default permissions" do
      expect(obj.default_permissions).not_to be_empty
      subject.clear
      expect(obj.default_permissions).to be_empty
    end

  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
ddr-models-2.6.2 spec/auth/legacy_default_permissions_spec.rb
ddr-models-2.6.1 spec/auth/legacy_default_permissions_spec.rb
ddr-models-2.6.0 spec/auth/legacy_default_permissions_spec.rb
ddr-models-2.6.0.rc4 spec/auth/legacy_default_permissions_spec.rb
ddr-models-2.6.0.rc3 spec/auth/legacy_default_permissions_spec.rb
ddr-models-2.6.0.rc2 spec/auth/legacy_default_permissions_spec.rb
ddr-models-2.6.0.rc1 spec/auth/legacy_default_permissions_spec.rb
ddr-models-2.5.3 spec/auth/legacy_default_permissions_spec.rb
ddr-models-2.5.2 spec/auth/legacy_default_permissions_spec.rb
ddr-models-2.5.1 spec/auth/legacy_default_permissions_spec.rb
ddr-models-2.5.0 spec/auth/legacy_default_permissions_spec.rb
ddr-models-2.5.0.rc1 spec/auth/legacy_default_permissions_spec.rb
ddr-models-2.4.16 spec/auth/legacy_default_permissions_spec.rb
ddr-models-2.4.15 spec/auth/legacy_default_permissions_spec.rb
ddr-models-2.4.14 spec/auth/legacy_default_permissions_spec.rb
ddr-models-2.4.13 spec/auth/legacy_default_permissions_spec.rb
ddr-models-2.4.12 spec/auth/legacy_default_permissions_spec.rb
ddr-models-2.4.11 spec/auth/legacy_default_permissions_spec.rb
ddr-models-2.4.10 spec/auth/legacy_default_permissions_spec.rb
ddr-models-2.4.9 spec/auth/legacy_default_permissions_spec.rb