~cytrogen/masto-fe

ref: e9385e93e9b4601c87d1f5d6b8ddfd815f7aedcb masto-fe/spec/lib/admin/metrics/measure/instance_follows_measure_spec.rb -rw-r--r-- 1.2 KiB
e9385e93 — Claire Add a confirmation screen when suspending a domain (#25144) 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# frozen_string_literal: true

require 'rails_helper'

describe Admin::Metrics::Measure::InstanceFollowsMeasure do
  subject(:measure) { described_class.new(start_at, end_at, params) }

  let(:domain) { 'example.com' }

  let(:start_at) { 2.days.ago }
  let(:end_at)   { Time.now.utc }

  let(:params) { ActionController::Parameters.new(domain: domain) }

  before do
    local_account = Fabricate(:account)

    local_account.follow!(Fabricate(:account, domain: domain))
    local_account.follow!(Fabricate(:account, domain: domain))
    Fabricate(:account, domain: domain)

    local_account.follow!(Fabricate(:account, domain: "foo.#{domain}"))
    local_account.follow!(Fabricate(:account, domain: "foo.#{domain}"))
    Fabricate(:account, domain: "bar.#{domain}")
  end

  describe 'total' do
    context 'without include_subdomains' do
      it 'returns the expected number of accounts' do
        expect(measure.total).to eq 2
      end
    end

    context 'with include_subdomains' do
      let(:params) { ActionController::Parameters.new(domain: domain, include_subdomains: 'true') }

      it 'returns the expected number of accounts' do
        expect(measure.total).to eq 4
      end
    end
  end
end