logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

report_filter_spec.rb (954B)


  1. require 'rails_helper'
  2. describe ReportFilter do
  3. describe 'with empty params' do
  4. it 'defaults to unresolved reports list' do
  5. filter = ReportFilter.new({})
  6. expect(filter.results).to eq Report.unresolved
  7. end
  8. end
  9. describe 'with invalid params' do
  10. it 'raises with key error' do
  11. filter = ReportFilter.new(wrong: true)
  12. expect { filter.results }.to raise_error(/wrong/)
  13. end
  14. end
  15. describe 'with valid params' do
  16. it 'combines filters on Report' do
  17. filter = ReportFilter.new(account_id: '123', resolved: true, target_account_id: '456')
  18. allow(Report).to receive(:where).and_return(Report.none)
  19. allow(Report).to receive(:resolved).and_return(Report.none)
  20. filter.results
  21. expect(Report).to have_received(:where).with(account_id: '123')
  22. expect(Report).to have_received(:where).with(target_account_id: '456')
  23. expect(Report).to have_received(:resolved)
  24. end
  25. end
  26. end