The code powering m.abunchtell.com https://m.abunchtell.com
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 

50 lignes
1.5 KiB

  1. require 'rails_helper'
  2. RSpec.describe RejectFollowService do
  3. let(:sender) { Fabricate(:account, username: 'alice') }
  4. subject { RejectFollowService.new }
  5. describe 'local' do
  6. let(:bob) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob')).account }
  7. before do
  8. FollowRequest.create(account: bob, target_account: sender)
  9. subject.call(bob, sender)
  10. end
  11. it 'removes follow request' do
  12. expect(bob.requested?(sender)).to be false
  13. end
  14. it 'does not create follow relation' do
  15. expect(bob.following?(sender)).to be false
  16. end
  17. end
  18. describe 'remote' do
  19. let(:bob) { Fabricate(:user, email: 'bob@example.com', account: Fabricate(:account, username: 'bob', domain: 'example.com', salmon_url: 'http://salmon.example.com')).account }
  20. before do
  21. FollowRequest.create(account: bob, target_account: sender)
  22. stub_request(:post, "http://salmon.example.com/").to_return(:status => 200, :body => "", :headers => {})
  23. subject.call(bob, sender)
  24. end
  25. it 'removes follow request' do
  26. expect(bob.requested?(sender)).to be false
  27. end
  28. it 'does not create follow relation' do
  29. expect(bob.following?(sender)).to be false
  30. end
  31. it 'sends a follow request rejection salmon slap' do
  32. expect(a_request(:post, "http://salmon.example.com/").with { |req|
  33. xml = OStatus2::Salmon.new.unpack(req.body)
  34. xml.match(TagManager::VERBS[:reject])
  35. }).to have_been_made.once
  36. end
  37. end
  38. end