You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
954 B
33 lines
954 B
require 'rails_helper'
|
|
|
|
describe ReportFilter do
|
|
describe 'with empty params' do
|
|
it 'defaults to unresolved reports list' do
|
|
filter = ReportFilter.new({})
|
|
|
|
expect(filter.results).to eq Report.unresolved
|
|
end
|
|
end
|
|
|
|
describe 'with invalid params' do
|
|
it 'raises with key error' do
|
|
filter = ReportFilter.new(wrong: true)
|
|
|
|
expect { filter.results }.to raise_error(/wrong/)
|
|
end
|
|
end
|
|
|
|
describe 'with valid params' do
|
|
it 'combines filters on Report' do
|
|
filter = ReportFilter.new(account_id: '123', resolved: true, target_account_id: '456')
|
|
|
|
allow(Report).to receive(:where).and_return(Report.none)
|
|
allow(Report).to receive(:resolved).and_return(Report.none)
|
|
filter.results
|
|
expect(Report).to have_received(:where).with(account_id: '123')
|
|
expect(Report).to have_received(:where).with(target_account_id: '456')
|
|
expect(Report).to have_received(:resolved)
|
|
end
|
|
end
|
|
end
|