You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
1.3 KiB

  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe RemoteUnfollowsController do
  4. render_views
  5. describe '#create' do
  6. subject { post :create, params: { acct: acct } }
  7. let(:current_user) { Fabricate(:user, account: current_account) }
  8. let(:current_account) { Fabricate(:account) }
  9. let(:remote_account) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob', protocol: :activitypub, domain: 'example.com', inbox_url: 'http://example.com/inbox')).account }
  10. before do
  11. sign_in current_user
  12. current_account.follow!(remote_account)
  13. stub_request(:post, 'http://example.com/inbox') { { status: 200 } }
  14. end
  15. context 'when successfully unfollow remote account' do
  16. let(:acct) { "acct:#{remote_account.username}@#{remote_account.domain}" }
  17. it do
  18. is_expected.to render_template :success
  19. expect(current_account.following?(remote_account)).to be false
  20. end
  21. end
  22. context 'when fails to unfollow remote account' do
  23. let(:acct) { "acct:#{remote_account.username + '_test'}@#{remote_account.domain}" }
  24. it do
  25. is_expected.to render_template :error
  26. expect(current_account.following?(remote_account)).to be true
  27. end
  28. end
  29. end
  30. end