Sha256: 8c89783e46cdc2be75d365739491e92bcb7ad064f767d4805670863c137fce7e

Contents?: true

Size: 994 Bytes

Versions: 12

Compression:

Stored size: 994 Bytes

Contents

module Ddr::Auth
  RSpec.describe LegacyRoles do

    subject { described_class.new(obj) }

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

    before do
      @deprecation_behavior = Deprecation.default_deprecation_behavior
      Deprecation.default_deprecation_behavior = :silence
      obj.adminMetadata.downloader = ["bob@example.com", "Downloaders"]
    end

    after do
      Deprecation.default_deprecation_behavior = @deprecation_behavior
    end

    it "should convert the legacy roles to new roles" do
      expect(subject.to_roles)
        .to eq(Roles::DetachedRoleSet.new(
                [ Roles::Role.build(type: "Downloader", agent: "Downloaders", scope: "resource"),
                  Roles::Role.build(type: "Downloader", agent: "bob@example.com", scope: "resource")
                ]
              ))
    end

    it "should clear the legacy roles" do
      expect { subject.clear }.to change(obj.adminMetadata.downloader, :empty?).from(false).to(true)
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ddr-models-2.0.1 spec/auth/legacy_roles_spec.rb
ddr-models-2.0.0 spec/auth/legacy_roles_spec.rb
ddr-models-2.0.0.rc6 spec/auth/legacy_roles_spec.rb
ddr-models-2.0.0.rc5 spec/auth/legacy_roles_spec.rb
ddr-models-2.0.0.rc4 spec/auth/legacy_roles_spec.rb
ddr-models-2.0.0.rc3 spec/auth/legacy_roles_spec.rb
ddr-models-2.0.0.rc2 spec/auth/legacy_roles_spec.rb
ddr-models-2.0.0.rc1 spec/auth/legacy_roles_spec.rb
ddr-models-2.0.0.pre.5 spec/auth/legacy_roles_spec.rb
ddr-models-2.0.0.pre.4 spec/auth/legacy_roles_spec.rb
ddr-models-2.0.0.pre.3 spec/auth/legacy_roles_spec.rb
ddr-models-2.0.0.pre.2 spec/auth/legacy_roles_spec.rb