about summary refs log tree commit diff
path: root/spec/models/account_filter_spec.rb
diff options
context:
space:
mode:
authorMatt Jankowski <mjankowski@thoughtbot.com>2017-05-05 14:56:00 -0400
committerGitHub <noreply@github.com>2017-05-05 14:56:00 -0400
commit484c9709b67685c95de351a39e3dfb140acd3681 (patch)
tree0d74cd725e46cd75ca1568d866d5d5ef906b8c0a /spec/models/account_filter_spec.rb
parentd08f1112d517788fb66d2683766cc168bac48315 (diff)
Misc spec coverage improvements (#2821)
* Dont use raise_error by itself (avoids warning)

* Add coverage for AccountFilter

* Improve coverage and refactor for Subscription#lease_seconds

* Improve coverage and refactor for NotificationMailer

* Simplify assignment of min/max threshold on subscription
Diffstat (limited to 'spec/models/account_filter_spec.rb')
-rw-r--r--spec/models/account_filter_spec.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/spec/models/account_filter_spec.rb b/spec/models/account_filter_spec.rb
index 1599c5ae8..52b4c4893 100644
--- a/spec/models/account_filter_spec.rb
+++ b/spec/models/account_filter_spec.rb
@@ -3,7 +3,7 @@ require 'rails_helper'
 describe AccountFilter do
   describe 'with empty params' do
     it 'defaults to alphabetic account list' do
-      filter = AccountFilter.new({})
+      filter = described_class.new({})
 
       expect(filter.results).to eq Account.alphabetic
     end
@@ -11,7 +11,7 @@ describe AccountFilter do
 
   describe 'with invalid params' do
     it 'raises with key error' do
-      filter = AccountFilter.new(wrong: true)
+      filter = described_class.new(wrong: true)
 
       expect { filter.results }.to raise_error(/wrong/)
     end
@@ -19,7 +19,7 @@ describe AccountFilter do
 
   describe 'with valid params' do
     it 'combines filters on Account' do
-      filter = AccountFilter.new(by_domain: 'test.com', silenced: true)
+      filter = described_class.new(by_domain: 'test.com', silenced: true)
 
       allow(Account).to receive(:where).and_return(Account.none)
       allow(Account).to receive(:silenced).and_return(Account.none)
@@ -27,5 +27,17 @@ describe AccountFilter do
       expect(Account).to have_received(:where).with(domain: 'test.com')
       expect(Account).to have_received(:silenced)
     end
+
+    describe 'that call account methods' do
+      %i(local remote silenced recent).each do |option|
+        it "delegates the #{option} option" do
+          allow(Account).to receive(option).and_return(Account.none)
+          filter = described_class.new({ option => true })
+          filter.results
+
+          expect(Account).to have_received(option)
+        end
+      end
+    end
   end
 end