Sha256: da247ab5aa2c873074b29cf62be8f840cc77b72d54bb8eb08648127e673ac152

Contents?: true

Size: 1.13 KB

Versions: 15

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

RSpec.shared_examples 'Permissions' do
  context 'AAF shared implementation' do
    subject { build :permission }

    it { is_expected.to be_valid }

    it 'is invalid without a role' do
      subject.role = nil
      expect(subject).not_to be_valid
    end

    it 'is invalid without a value' do
      subject.value = nil
      expect(subject).not_to be_valid
    end

    it 'allows wildcard values' do
      subject.value = '*'
      expect(subject).to be_valid
    end

    it 'allows permission string values' do
      subject.value = 'a:b:c:d'
      expect(subject).to be_valid
    end

    it 'disallows invalid characters' do
      subject.value = 'a:b:%'
      expect(subject).not_to be_valid
    end

    it 'must have a unique value per role' do
      other = create(:permission, role: subject.role, value: 'other')

      expect { subject.value = other.value }
        .to change { subject.valid? }.to(be_falsey)
    end

    it 'can have a value used in a different role' do
      other = create(:permission, value: 'other')
      subject.value = other.value
      expect(subject).to be_valid
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
aaf-gumboot-2.6.3 lib/gumboot/shared_examples/permissions.rb
aaf-gumboot-2.6.2 lib/gumboot/shared_examples/permissions.rb
aaf-gumboot-2.6.1 lib/gumboot/shared_examples/permissions.rb
aaf-gumboot-2.6.0 lib/gumboot/shared_examples/permissions.rb
aaf-gumboot-2.5.1 lib/gumboot/shared_examples/permissions.rb
aaf-gumboot-2.5.0 lib/gumboot/shared_examples/permissions.rb
aaf-gumboot-2.4.0 lib/gumboot/shared_examples/permissions.rb
aaf-gumboot-2.2.0 lib/gumboot/shared_examples/permissions.rb
aaf-gumboot-2.1.4 lib/gumboot/shared_examples/permissions.rb
aaf-gumboot-2.1.3 lib/gumboot/shared_examples/permissions.rb
aaf-gumboot-2.1.1 lib/gumboot/shared_examples/permissions.rb
aaf-gumboot-2.1.0 lib/gumboot/shared_examples/permissions.rb
aaf-gumboot-2.0.1 lib/gumboot/shared_examples/permissions.rb
aaf-gumboot-1.2.0 lib/gumboot/shared_examples/permissions.rb
aaf-gumboot-1.1.0 lib/gumboot/shared_examples/permissions.rb