action_logs_controller_spec.rb 965 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe Admin::ActionLogsController do
  4. render_views
  5. # Action logs typically cause issues when their targets are not in the database
  6. let!(:account) { Fabricate(:account) }
  7. before do
  8. orphaned_log_types.map do |type|
  9. Fabricate(:action_log, account: account, action: 'destroy', target_type: type, target_id: 1312)
  10. end
  11. end
  12. describe 'GET #index' do
  13. it 'returns 200' do
  14. sign_in Fabricate(:user, role: UserRole.find_by(name: 'Admin'))
  15. get :index, params: { page: 1 }
  16. expect(response).to have_http_status(200)
  17. end
  18. end
  19. private
  20. def orphaned_log_types
  21. %w(
  22. Account
  23. AccountWarning
  24. Announcement
  25. Appeal
  26. CanonicalEmailBlock
  27. CustomEmoji
  28. DomainAllow
  29. DomainBlock
  30. EmailDomainBlock
  31. Instance
  32. IpBlock
  33. Report
  34. Status
  35. UnavailableDomain
  36. User
  37. UserRole
  38. )
  39. end
  40. end