diff options
author | Matt Jankowski <mjankowski@thoughtbot.com> | 2017-04-18 13:36:18 -0400 |
---|---|---|
committer | Eugen <eugen@zeonfederated.com> | 2017-04-18 19:36:18 +0200 |
commit | 66d8f99a30f9e6062f1bff37d5115beddce9b55d (patch) | |
tree | 5f7c752043054bc86fb57faa89332660688044bc /spec | |
parent | f23281e31ead38a1cabbb73f0dbb8b36cb38cadb (diff) |
Admin reports with accounts (#2092)
* Add a ReportFilter class * Add reports and targeted_reports relationships to Account * Use ReportFilter from admin/reports controller * Link to admin/reports filtered views from admin account show view * Add indexes to reports.account_id and reports.target_account_id
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/report_filter_spec.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/spec/models/report_filter_spec.rb b/spec/models/report_filter_spec.rb new file mode 100644 index 000000000..fc0b7d7b5 --- /dev/null +++ b/spec/models/report_filter_spec.rb @@ -0,0 +1,31 @@ +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) + + 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(:resolved) + end + end +end |