permission_spec.rb 836 B

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