Sha256: bbd641fbffd8c416adb1ed7967d4ae66aa2745cbbdbeedfd861d85a51d063894

Contents?: true

Size: 1.26 KB

Versions: 57

Compression:

Stored size: 1.26 KB

Contents

module Ddr::Auth
  RSpec.describe LegacyPermissions do

    subject { described_class.new(obj) }

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

    before do
      @deprecation_behavior = Deprecation.default_deprecation_behavior
      Deprecation.default_deprecation_behavior = :silence
      obj.permissions_attributes = [{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 permissions to resource roles" do
      expect(subject.to_roles)
        .to eq(Roles::DetachedRoleSet.new(
                [ Roles::Role.build(type: "Editor", agent: "Editors", scope: "resource"),
                  Roles::Role.build(type: "Viewer", agent: "public", scope: "resource"),
                  Roles::Role.build(type: "Viewer", agent: "bob@example.com", scope: "resource")
                ]
              ))
    end

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

  end
end

Version data entries

57 entries across 57 versions & 1 rubygems

Version Path
ddr-models-2.4.8 spec/auth/legacy_permissions_spec.rb
ddr-models-2.4.7 spec/auth/legacy_permissions_spec.rb
ddr-models-2.4.6 spec/auth/legacy_permissions_spec.rb
ddr-models-2.4.5 spec/auth/legacy_permissions_spec.rb
ddr-models-2.4.4 spec/auth/legacy_permissions_spec.rb
ddr-models-2.4.3 spec/auth/legacy_permissions_spec.rb
ddr-models-2.4.2 spec/auth/legacy_permissions_spec.rb
ddr-models-2.4.1 spec/auth/legacy_permissions_spec.rb
ddr-models-2.4.0 spec/auth/legacy_permissions_spec.rb
ddr-models-2.4.0.rc6 spec/auth/legacy_permissions_spec.rb
ddr-models-2.4.0.rc5 spec/auth/legacy_permissions_spec.rb
ddr-models-2.4.0.rc4 spec/auth/legacy_permissions_spec.rb
ddr-models-2.4.0.rc3 spec/auth/legacy_permissions_spec.rb
ddr-models-2.4.0.rc2 spec/auth/legacy_permissions_spec.rb
ddr-models-2.4.0.rc1 spec/auth/legacy_permissions_spec.rb
ddr-models-2.3.2 spec/auth/legacy_permissions_spec.rb
ddr-models-2.3.1 spec/auth/legacy_permissions_spec.rb
ddr-models-2.3.0 spec/auth/legacy_permissions_spec.rb
ddr-models-2.2.0 spec/auth/legacy_permissions_spec.rb
ddr-models-2.1.3 spec/auth/legacy_permissions_spec.rb