about summary refs log tree commit diff
path: root/spec/models/account_filter_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/account_filter_spec.rb')
-rw-r--r--spec/models/account_filter_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/models/account_filter_spec.rb b/spec/models/account_filter_spec.rb
index c2bd8c220..3032260fe 100644
--- a/spec/models/account_filter_spec.rb
+++ b/spec/models/account_filter_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 require 'rails_helper'
 
 describe AccountFilter do
@@ -16,4 +18,30 @@ describe AccountFilter do
       expect { filter.results }.to raise_error(/wrong/)
     end
   end
+
+  describe 'with origin and by_domain interacting' do
+    let!(:local_account) { Fabricate(:account, domain: nil) }
+    let!(:remote_account_one) { Fabricate(:account, domain: 'example.org') }
+    let(:remote_account_two) { Fabricate(:account, domain: 'other.domain') }
+
+    it 'works with domain first and origin remote' do
+      filter = described_class.new(by_domain: 'example.org', origin: 'remote')
+      expect(filter.results).to match_array [remote_account_one]
+    end
+
+    it 'works with domain last and origin remote' do
+      filter = described_class.new(origin: 'remote', by_domain: 'example.org')
+      expect(filter.results).to match_array [remote_account_one]
+    end
+
+    it 'works with domain first and origin local' do
+      filter = described_class.new(by_domain: 'example.org', origin: 'local')
+      expect(filter.results).to match_array [local_account]
+    end
+
+    it 'works with domain last and origin local' do
+      filter = described_class.new(origin: 'local', by_domain: 'example.org')
+      expect(filter.results).to match_array [remote_account_one]
+    end
+  end
 end