permission_spec.rb 710 B

123456789101112131415161718192021
  1. require 'rails_helper'
  2. require 'models/concerns/has_collection_update_examples'
  3. RSpec.describe Permission, type: :model do
  4. it_behaves_like 'HasCollectionUpdate', collection_factory: :permission
  5. describe '.with_parents' do
  6. context 'when given a simple string (no dots)' do
  7. it 'returns an array containing only that string' do
  8. expect(described_class.with_parents('foo')).to eq(['foo'])
  9. end
  10. end
  11. context 'when given a String permission name (dot-delimited identifier)' do
  12. it 'returns an array of String ancestors (desc. from root)' do
  13. expect(described_class.with_parents('foo.bar.baz'))
  14. .to eq(%w[foo foo.bar foo.bar.baz])
  15. end
  16. end
  17. end
  18. end