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.

41 lines
1.5 KiB

  1. require 'rails_helper'
  2. RSpec.describe Api::SalmonController, type: :controller do
  3. render_views
  4. let(:account) { Fabricate(:user, account: Fabricate(:account, username: 'catsrgr8')).account }
  5. before do
  6. stub_request(:get, "https://quitter.no/.well-known/host-meta").to_return(request_fixture('.host-meta.txt'))
  7. stub_request(:get, "https://quitter.no/.well-known/webfinger?resource=acct:gargron@quitter.no").to_return(request_fixture('webfinger.txt'))
  8. stub_request(:get, "https://quitter.no/api/statuses/user_timeline/7477.atom").to_return(request_fixture('feed.txt'))
  9. stub_request(:get, "https://quitter.no/avatar/7477-300-20160211190340.png").to_return(request_fixture('avatar.txt'))
  10. end
  11. describe 'POST #update' do
  12. before do
  13. request.env['RAW_POST_DATA'] = File.read(File.join(Rails.root, 'spec', 'fixtures', 'salmon', 'mention.xml'))
  14. post :update, params: { id: account.id }
  15. end
  16. it 'contains XML in the request body' do
  17. expect(request.body.read).to be_a String
  18. end
  19. it 'returns http success' do
  20. expect(response).to have_http_status(:success)
  21. end
  22. it 'creates remote account' do
  23. expect(Account.find_by(username: 'gargron', domain: 'quitter.no')).to_not be_nil
  24. end
  25. it 'creates status' do
  26. expect(Status.find_by(uri: 'tag:quitter.no,2016-03-20:noticeId=1276923:objectType=note')).to_not be_nil
  27. end
  28. it 'creates mention for target account' do
  29. expect(account.mentions.count).to eq 1
  30. end
  31. end
  32. end