闭社主体 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.

79 lines
1.9 KiB

  1. require 'rails_helper'
  2. RSpec.describe Api::V1::TimelinesController, type: :controller do
  3. render_views
  4. let(:user) { Fabricate(:user, account: Fabricate(:account, username: 'alice')) }
  5. before do
  6. allow(controller).to receive(:doorkeeper_token) { token }
  7. end
  8. context 'with a user context' do
  9. let(:token) { double acceptable?: true, resource_owner_id: user.id }
  10. describe 'GET #home' do
  11. it 'returns http success' do
  12. get :home
  13. expect(response).to have_http_status(:success)
  14. end
  15. end
  16. describe 'GET #mentions' do
  17. it 'returns http success' do
  18. get :mentions
  19. expect(response).to have_http_status(:success)
  20. end
  21. end
  22. describe 'GET #public' do
  23. it 'returns http success' do
  24. get :public
  25. expect(response).to have_http_status(:success)
  26. end
  27. end
  28. describe 'GET #tag' do
  29. before do
  30. PostStatusService.new.call(user.account, 'It is a #test')
  31. end
  32. it 'returns http success' do
  33. get :tag, params: { id: 'test' }
  34. expect(response).to have_http_status(:success)
  35. end
  36. end
  37. end
  38. context 'without a user context' do
  39. let(:token) { double acceptable?: true, resource_owner_id: nil }
  40. describe 'GET #home' do
  41. it 'returns http unprocessable entity' do
  42. get :home
  43. expect(response).to have_http_status(:unprocessable_entity)
  44. end
  45. end
  46. describe 'GET #mentions' do
  47. it 'returns http unprocessable entity' do
  48. get :mentions
  49. expect(response).to have_http_status(:unprocessable_entity)
  50. end
  51. end
  52. describe 'GET #public' do
  53. it 'returns http success' do
  54. get :public
  55. expect(response).to have_http_status(:success)
  56. end
  57. end
  58. describe 'GET #tag' do
  59. it 'returns http success' do
  60. get :tag, params: { id: 'test' }
  61. expect(response).to have_http_status(:success)
  62. end
  63. end
  64. end
  65. end