Sha256: b6898193259d9432d8c9b54cdeaa5536f97691183f91ad4cc9ab2f4941e52c92

Contents?: true

Size: 1.23 KB

Versions: 16

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'

describe RoleMapper do
  it "should define the 4 roles" do
    expect(RoleMapper.role_names.sort).to eq %w(admin_policy_object_editor archivist donor patron researcher) 
  end
  it "should quer[iy]able for roles for a given user" do
    expect(RoleMapper.roles('leland_himself@example.com').sort).to eq ['archivist', 'donor', 'patron']
    expect(RoleMapper.roles('archivist2@example.com')).to eq ['archivist']
  end

  it "should not change it's response when it's called repeatedly" do
    u = User.new(:uid=>'leland_himself@example.com')
    allow(u).to receive(:new_record?).and_return(false)
    expect(RoleMapper.roles(u).sort).to eq ['archivist', 'donor', 'patron', "registered"]
    expect(RoleMapper.roles(u).sort).to eq ['archivist', 'donor', 'patron', "registered"]
  end

  it "should return an empty array if there are no roles" do
    expect(RoleMapper.roles('zeus@olympus.mt')).to be_empty
  end
  it "should know who is what" do
    expect(RoleMapper.whois('archivist').sort).to eq %w(archivist1@example.com archivist2@example.com leland_himself@example.com)
    expect(RoleMapper.whois('salesman')).to be_empty
    expect(RoleMapper.whois('admin_policy_object_editor').sort).to eq %w(archivist1@example.com)
  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
hydra-access-controls-9.2.2 spec/unit/role_mapper_spec.rb
hydra-access-controls-9.2.1 spec/unit/role_mapper_spec.rb
hydra-access-controls-9.2.0 spec/unit/role_mapper_spec.rb
hydra-access-controls-9.2.0.rc1 spec/unit/role_mapper_spec.rb
hydra-access-controls-9.1.4 spec/unit/role_mapper_spec.rb
hydra-access-controls-9.1.3 spec/unit/role_mapper_spec.rb
hydra-access-controls-9.1.2 spec/unit/role_mapper_spec.rb
hydra-access-controls-9.1.1 spec/unit/role_mapper_spec.rb
hydra-access-controls-9.1.0 spec/unit/role_mapper_spec.rb
hydra-access-controls-9.0.1 spec/unit/role_mapper_spec.rb
hydra-access-controls-9.0.0 spec/unit/role_mapper_spec.rb
hydra-access-controls-9.0.0.rc3 spec/unit/role_mapper_spec.rb
hydra-access-controls-9.0.0.rc2 spec/unit/role_mapper_spec.rb
hydra-access-controls-9.0.0.rc1 spec/unit/role_mapper_spec.rb
hydra-access-controls-9.0.0.beta2 spec/unit/role_mapper_spec.rb
hydra-access-controls-9.0.0.beta1 spec/unit/role_mapper_spec.rb