about summary refs log tree commit diff
path: root/spec/services
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-09-10 09:58:38 +0200
committerGitHub <noreply@github.com>2017-09-10 09:58:38 +0200
commit7d7844a47fdfb8862847f025dc4c1b1bc5fdafe5 (patch)
treef15741c04d74eb2999a8c36ea758cc20da17830f /spec/services
parentf2cbfb2eb375cde302461a91e5fb0a3af8f6eeb5 (diff)
Default follows for new users (#4871)
When a new user confirms their e-mail, bootstrap their home timeline
by automatically following a set of accounts. By default, all local
admin accounts (that are unlocked). Can be customized by new admin
setting (comma-separated usernames, local and unlocked only)
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/bootstrap_timeline_service_spec.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/services/bootstrap_timeline_service_spec.rb b/spec/services/bootstrap_timeline_service_spec.rb
new file mode 100644
index 000000000..5189b1de8
--- /dev/null
+++ b/spec/services/bootstrap_timeline_service_spec.rb
@@ -0,0 +1,37 @@
+require 'rails_helper'
+
+RSpec.describe BootstrapTimelineService do
+  subject { described_class.new }
+
+  describe '#call' do
+    let(:source_account) { Fabricate(:account) }
+
+    context 'when setting is empty' do
+      let!(:admin) { Fabricate(:user, admin: true) }
+
+      before do
+        Setting.bootstrap_timeline_accounts = nil
+        subject.call(source_account)
+      end
+
+      it 'follows admin accounts from account' do
+        expect(source_account.following?(admin.account)).to be true
+      end
+    end
+
+    context 'when setting is set' do
+      let!(:alice) { Fabricate(:account, username: 'alice') }
+      let!(:bob)   { Fabricate(:account, username: 'bob') }
+
+      before do
+        Setting.bootstrap_timeline_accounts = 'alice, bob'
+        subject.call(source_account)
+      end
+
+      it 'follows found accounts from account' do
+        expect(source_account.following?(alice)).to be true
+        expect(source_account.following?(bob)).to be true
+      end
+    end
+  end
+end