闭社主体 forked from https://github.com/tootsuite/mastodon
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.

45 lines
1.4 KiB

  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe ApplicationController, type: :controller do
  4. controller do
  5. include AccountControllerConcern
  6. def success
  7. head 200
  8. end
  9. end
  10. before do
  11. routes.draw { get 'success' => 'anonymous#success' }
  12. end
  13. context 'when account is suspended' do
  14. it 'returns http gone' do
  15. account = Fabricate(:account, suspended: true)
  16. get 'success', params: { account_username: account.username }
  17. expect(response).to have_http_status(410)
  18. end
  19. end
  20. context 'when account is not suspended' do
  21. it 'assigns @account' do
  22. account = Fabricate(:account)
  23. get 'success', params: { account_username: account.username }
  24. expect(assigns(:account)).to eq account
  25. end
  26. it 'sets link headers' do
  27. account = Fabricate(:account, username: 'username')
  28. get 'success', params: { account_username: 'username' }
  29. expect(response.headers['Link'].to_s).to eq '<http://test.host/.well-known/webfinger?resource=acct%3Ausername%40cb6e6126.ngrok.io>; rel="lrdd"; type="application/xrd+xml", <http://test.host/users/username.atom>; rel="alternate"; type="application/atom+xml"'
  30. end
  31. it 'returns http success' do
  32. account = Fabricate(:account)
  33. get 'success', params: { account_username: account.username }
  34. expect(response).to have_http_status(:success)
  35. end
  36. end
  37. end