scope_spec.rb 925 B

123456789101112131415161718192021222324252627
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. RSpec.describe TaskbarPolicy::Scope do
  4. subject(:scope) { described_class.new(user, Taskbar) }
  5. let(:user) { create(:agent) }
  6. let(:taskbar) { create(:taskbar, user:, prio: 3) }
  7. let(:taskbar_2) { create(:taskbar, user:, prio: 1) }
  8. let(:taskbar_3) { create(:taskbar, user:, prio: 4) }
  9. let(:taskbar_nonexistant_entity) { create(:taskbar, callback: 'nonexistant', user:, prio: 2) }
  10. let(:taskbar_other_user) { create(:taskbar, user: create(:agent)) }
  11. before do
  12. taskbar && taskbar_2 && taskbar_3
  13. taskbar_nonexistant_entity && taskbar_other_user
  14. end
  15. describe '#resolve' do
  16. it 'returns user taskbars ordered by prio and filtered to legit entities' do
  17. expect(scope.resolve).to eq([taskbar_2, taskbar, taskbar_3])
  18. end
  19. end
  20. end