upload_cache_policy_spec.rb 754 B

123456789101112131415161718192021222324252627282930313233
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. require 'rails_helper'
  3. describe UploadCachePolicy do
  4. subject { described_class.new(effective_user, record) }
  5. let(:user) { create(:user) }
  6. let(:record) do
  7. cache = UploadCache.new(123)
  8. cache.add(
  9. filename: 'hello_world.txt',
  10. data: 'Hello, World!',
  11. preferences: { 'Content-Type' => 'text/plain' },
  12. created_by_id: user.id
  13. )
  14. cache
  15. end
  16. context 'with different user' do
  17. let(:effective_user) { create(:user) }
  18. it { is_expected.to forbid_actions :show, :destroy }
  19. end
  20. context 'with given user' do
  21. let(:effective_user) { user }
  22. it { is_expected.to permit_actions :show, :destroy }
  23. end
  24. end