field_scope.rb 684 B

12345678910111213
  1. # Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
  2. RSpec::Matchers.define :permit_fields do |expected|
  3. match { expected.all? { |f| actual.field_authorized?(f) } }
  4. description { 'checks if FieldScope permits expected fields' }
  5. failure_message { "did not grant field authorization for #{expected.reject { |f| actual.field_authorized?(f) }}" }
  6. end
  7. RSpec::Matchers.define :forbid_fields do |expected|
  8. match { expected.all? { |f| !actual.field_authorized?(f) } }
  9. description { 'checks if FieldScope forbids expected fields' }
  10. failure_message { "incorrectly grants field authorization for #{expected.select { |f| actual.field_authorized?(f) }}" }
  11. end