update_account_service_spec.rb 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. require 'rails_helper'
  2. RSpec.describe UpdateAccountService, type: :service do
  3. subject { UpdateAccountService.new }
  4. describe 'switching form locked to unlocked accounts' do
  5. let(:account) { Fabricate(:account, locked: true) }
  6. let(:alice) { Fabricate(:user, email: 'alice@example.com', account: Fabricate(:account, username: 'alice')).account }
  7. let(:bob) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob')).account }
  8. let(:eve) { Fabricate(:user, email: 'eve@example.com', account: Fabricate(:account, username: 'eve')).account }
  9. before do
  10. bob.touch(:silenced_at)
  11. account.mute!(eve)
  12. FollowService.new.call(alice, account)
  13. FollowService.new.call(bob, account)
  14. FollowService.new.call(eve, account)
  15. subject.call(account, { locked: false })
  16. end
  17. it 'auto-accepts pending follow requests' do
  18. expect(alice.following?(account)).to be true
  19. expect(alice.requested?(account)).to be false
  20. end
  21. it 'does not auto-accept pending follow requests from silenced users' do
  22. expect(bob.following?(account)).to be false
  23. expect(bob.requested?(account)).to be true
  24. end
  25. it 'auto-accepts pending follow requests from muted users so as to not leak mute' do
  26. expect(eve.following?(account)).to be true
  27. expect(eve.requested?(account)).to be false
  28. end
  29. end
  30. end