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

80 lines
2.0 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. stub_request(:post, "https://pubsubhubbub.superfeedr.com/").to_return(:status => 200, :body => "", :headers => {})
  7. allow(controller).to receive(:doorkeeper_token) { token }
  8. end
  9. context 'with a user context' do
  10. let(:token) { double acceptable?: true, resource_owner_id: user.id }
  11. describe 'GET #home' do
  12. it 'returns http success' do
  13. get :home
  14. expect(response).to have_http_status(:success)
  15. end
  16. end
  17. describe 'GET #mentions' do
  18. it 'returns http success' do
  19. get :mentions
  20. expect(response).to have_http_status(:success)
  21. end
  22. end
  23. describe 'GET #public' do
  24. it 'returns http success' do
  25. get :public
  26. expect(response).to have_http_status(:success)
  27. end
  28. end
  29. describe 'GET #tag' do
  30. before do
  31. PostStatusService.new.call(user.account, 'It is a #test')
  32. end
  33. it 'returns http success' do
  34. get :tag, params: { id: 'test' }
  35. expect(response).to have_http_status(:success)
  36. end
  37. end
  38. end
  39. context 'without a user context' do
  40. let(:token) { double acceptable?: true, resource_owner_id: nil }
  41. describe 'GET #home' do
  42. it 'returns http unprocessable entity' do
  43. get :home
  44. expect(response).to have_http_status(:unprocessable_entity)
  45. end
  46. end
  47. describe 'GET #mentions' do
  48. it 'returns http unprocessable entity' do
  49. get :mentions
  50. expect(response).to have_http_status(:unprocessable_entity)
  51. end
  52. end
  53. describe 'GET #public' do
  54. it 'returns http success' do
  55. get :public
  56. expect(response).to have_http_status(:success)
  57. end
  58. end
  59. describe 'GET #tag' do
  60. it 'returns http success' do
  61. get :tag, params: { id: 'test' }
  62. expect(response).to have_http_status(:success)
  63. end
  64. end
  65. end
  66. end