about summary refs log tree commit diff
path: root/spec/models
diff options
context:
space:
mode:
authorMatt Jankowski <mjankowski@thoughtbot.com>2017-04-18 15:09:07 -0400
committerEugen <eugen@zeonfederated.com>2017-04-18 21:09:07 +0200
commit55e150352204bc790345cf81ef02bfcb1d7e0594 (patch)
treeb9c58621d9d6921a1d970a48f8e0713eef790345 /spec/models
parent66d8f99a30f9e6062f1bff37d5115beddce9b55d (diff)
Instances list in admin (#2095)
* Add admin/instances index action

* Add link to instances admin page

* View lists instances

* Instances, grouped by domain, ordered by count

* Use Account.remote scope

* Extract method: Account.by_domain_accounts
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/account_spec.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb
index c39e7986e..3edbc3253 100644
--- a/spec/models/account_spec.rb
+++ b/spec/models/account_spec.rb
@@ -410,6 +410,20 @@ RSpec.describe Account, type: :model do
       end
     end
 
+    describe 'by_domain_accounts' do
+      it 'returns accounts grouped by domain sorted by accounts' do
+        2.times { Fabricate(:account, domain: 'example.com') }
+        Fabricate(:account, domain: 'example2.com')
+
+        results = Account.by_domain_accounts
+        expect(results.length).to eq 2
+        expect(results.first.domain).to eq 'example.com'
+        expect(results.first.accounts_count).to eq 2
+        expect(results.last.domain).to eq 'example2.com'
+        expect(results.last.accounts_count).to eq 1
+      end
+    end
+
     describe 'local' do
       it 'returns an array of accounts who do not have a domain' do
         account_1 = Fabricate(:account, domain: nil)